No changes
This commit is contained in:
parent
8680a02b13
commit
b6b398f5bf
17374 changed files with 2475441 additions and 0 deletions
104
ControlPanel/modules/dsi/includes/SimpleImage.php
Normal file
104
ControlPanel/modules/dsi/includes/SimpleImage.php
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* File: SimpleImage.php
|
||||
* Author: Simon Jarvis
|
||||
* Copyright: 2006 Simon Jarvis
|
||||
* Date: 08/11/06
|
||||
* Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
*/
|
||||
|
||||
class SimpleImage {
|
||||
|
||||
var $image;
|
||||
var $image_type;
|
||||
|
||||
function load($filename) {
|
||||
$image_info = getimagesize($filename);
|
||||
$this->image_type = $image_info['mime'];
|
||||
if( $this->image_type == "image/jpeg" ) {
|
||||
|
||||
$this->image = imagecreatefromjpeg($filename);
|
||||
} elseif( $this->image_type == "image/gif" ) {
|
||||
|
||||
$this->image = imagecreatefromgif($filename);
|
||||
} elseif( $this->image_type == "image/png" ) {
|
||||
|
||||
$this->image = imagecreatefrompng($filename);
|
||||
}
|
||||
}
|
||||
function save($filename, $image_type=IMAGETYPE_PNG, $compression=75, $permissions=null) {
|
||||
|
||||
if( $image_type == IMAGETYPE_JPEG ) {
|
||||
imagejpeg($this->image,$filename,$compression);
|
||||
} elseif( $image_type == IMAGETYPE_GIF ) {
|
||||
|
||||
imagegif($this->image,$filename);
|
||||
} elseif( $image_type == IMAGETYPE_PNG ) {
|
||||
|
||||
imagepng($this->image,$filename);
|
||||
}
|
||||
if( $permissions != null) {
|
||||
|
||||
chmod($filename,$permissions);
|
||||
}
|
||||
}
|
||||
function output($image_type=IMAGETYPE_JPEG) {
|
||||
|
||||
if( $image_type == IMAGETYPE_JPEG ) {
|
||||
imagejpeg($this->image);
|
||||
} elseif( $image_type == IMAGETYPE_GIF ) {
|
||||
|
||||
imagegif($this->image);
|
||||
} elseif( $image_type == IMAGETYPE_PNG ) {
|
||||
|
||||
imagepng($this->image);
|
||||
}
|
||||
}
|
||||
function getWidth() {
|
||||
|
||||
return imagesx($this->image);
|
||||
}
|
||||
function getHeight() {
|
||||
|
||||
return imagesy($this->image);
|
||||
}
|
||||
function resizeToHeight($height) {
|
||||
|
||||
$ratio = $height / $this->getHeight();
|
||||
$width = $this->getWidth() * $ratio;
|
||||
$this->resize($width,$height);
|
||||
}
|
||||
|
||||
function resizeToWidth($width) {
|
||||
$ratio = $width / $this->getWidth();
|
||||
$height = $this->getheight() * $ratio;
|
||||
$this->resize($width,$height);
|
||||
}
|
||||
|
||||
function scale($scale) {
|
||||
$width = $this->getWidth() * $scale/100;
|
||||
$height = $this->getheight() * $scale/100;
|
||||
$this->resize($width,$height);
|
||||
}
|
||||
|
||||
function resize($width,$height) {
|
||||
$new_image = imagecreatetruecolor($width, $height);
|
||||
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
|
||||
$this->image = $new_image;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
135
ControlPanel/modules/dsi/includes/functions.php
Normal file
135
ControlPanel/modules/dsi/includes/functions.php
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
/*
|
||||
* Dynamic Server Image module for Open Game Panel
|
||||
* Copyright (C) 2012 SpiffyTek
|
||||
*
|
||||
* http://spiffytek.com/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Workaround for OGP function not included due to "echo". Needed by protocols *Monitor.php */
|
||||
function print_player_list(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/* DSi functions */
|
||||
function dsi_cleaninput($input){
|
||||
/* Some rules might be paranoid */
|
||||
$remove = array("#\\\\+#", "#/+#", "#\\+#", "#\s+#", "#http+#", "#ftp+#", "#%00+#", "#\\0+#", "#\\x00+#", "#\(+#", "#\)+#", "#\{+#", "#\}+#");
|
||||
|
||||
$input = preg_replace($remove, "", $input);
|
||||
$input = htmlspecialchars($input, ENT_QUOTES);
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
function dsi_error_img($msg0 = false, $msg1 = false, $type = false){
|
||||
if(empty($type)) { $type = "normal"; }
|
||||
$bgimg = DSI_BASEPATH."images/default_".$type.".png";
|
||||
|
||||
$im = imagecreatefrompng($bgimg);
|
||||
$text_color = ImageColorAllocate($im,255,0,0);
|
||||
|
||||
switch($type){
|
||||
case "normal":
|
||||
imagestring($im,6,2,5,"ERROR! ".$msg0,$text_color);
|
||||
imagestring($im,5,2,20,$msg1,$text_color);
|
||||
break;
|
||||
case "small":
|
||||
imagestring($im,6,2,0,"ERROR! ".$msg0,$text_color);
|
||||
imagestring($im,5,2,10,$msg1,$text_color);
|
||||
break;
|
||||
case "sky":
|
||||
$img_map = DSI_BASEPATH."images/offline_bg.png";
|
||||
$im_map_info = getimagesize($img_map);
|
||||
$im_map = imagecreatefrompng($img_map);
|
||||
$im_map_width = 130;
|
||||
$im_map_height = 120;
|
||||
$im_map_posx = 25;
|
||||
$im_map_posy = 112;
|
||||
|
||||
imagecopyresampled($im, $im_map, $im_map_posx, $im_map_posy, 0, 0, $im_map_width, $im_map_height, $im_map_info[0], $im_map_info[1]);
|
||||
imagestring($im,1,6,28,"ERROR! ".$msg0,$text_color);
|
||||
imagestring($im,1,6,45,$msg1,$text_color);
|
||||
break;
|
||||
}
|
||||
dsi_make_img($im);
|
||||
}
|
||||
|
||||
function dsi_make_img($im = false, $cache_on = false, $cache_data = false){
|
||||
header("Content-type: image/png");
|
||||
if($cache_on){
|
||||
$expire = gmdate("D, d M Y H:i:s", $cache_data["cache_expire"])." GMT";
|
||||
header("Expires: ".$expire);
|
||||
readfile($cache_data["file"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
imagepng($im, $cache_data["file"], 9);
|
||||
readfile($cache_data["file"]);
|
||||
}
|
||||
|
||||
imagedestroy($im);
|
||||
exit;
|
||||
}
|
||||
|
||||
function dsi_get_bg($query_name, $mod, $type){
|
||||
$img = DSI_BASEPATH."images/".$query_name."/".$mod."_".$type.".png";
|
||||
if(file_exists($img)){
|
||||
return $img;
|
||||
}
|
||||
else{ return DSI_BASEPATH."images/default_".$type.".png"; }
|
||||
}
|
||||
|
||||
function pretty_text($im, $fontsize, $x, $y, $string, $color, $outline = false) {
|
||||
$black = imagecolorallocate($im, 0, 0, 0);
|
||||
|
||||
// Black outline
|
||||
if($outline){
|
||||
imagestring($im, $fontsize, $x - 1, $y - 1, $string, $black);
|
||||
imagestring($im, $fontsize, $x - 1, $y, $string, $black);
|
||||
imagestring($im, $fontsize, $x - 1, $y + 1, $string, $black);
|
||||
imagestring($im, $fontsize, $x, $y - 1, $string, $black);
|
||||
imagestring($im, $fontsize, $x, $y + 1, $string, $black);
|
||||
imagestring($im, $fontsize, $x + 1, $y - 1, $string, $black);
|
||||
imagestring($im, $fontsize, $x + 1, $y, $string, $black);
|
||||
imagestring($im, $fontsize, $x + 1, $y + 1, $string, $black);
|
||||
}
|
||||
|
||||
// Your text
|
||||
imagestring($im, $fontsize, $x, $y, $string, $color);
|
||||
return $im;
|
||||
}
|
||||
|
||||
function pretty_text_ttf($im, $fontsize, $angle, $x, $y, $color, $font, $string, $outline = false) {
|
||||
$black = imagecolorallocate($im, 0, 0, 0);
|
||||
|
||||
// Black outline
|
||||
if($outline){
|
||||
imagettftext($im, $fontsize, $angle, $x - 1, $y - 1, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x - 1, $y, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x - 1, $y + 1, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x, $y - 1, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x, $y + 1, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x + 1, $y - 1, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x + 1, $y, $black, $font, $string);
|
||||
imagettftext($im, $fontsize, $angle, $x + 1, $y + 1, $black, $font, $string);
|
||||
}
|
||||
|
||||
// Your text
|
||||
imagettftext($im, $fontsize, $angle, $x, $y, $color, $font, $string);
|
||||
return $im;
|
||||
}
|
||||
?>
|
||||
70
ControlPanel/modules/dsi/includes/functions_ui.php
Normal file
70
ControlPanel/modules/dsi/includes/functions_ui.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/*
|
||||
* Dynamic Server Image module for Open Game Panel
|
||||
* Copyright (C) 2012 SpiffyTek
|
||||
*
|
||||
* http://spiffytek.com/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/* DSi functions */
|
||||
function dsi_render_table($ip, $port, $url = false, $use_table = TRUE, $use_rows = TRUE, $show_codes = TRUE, $img_join_link = FALSE, $img_only = FALSE, $img_type = FALSE ){
|
||||
$link = false;
|
||||
$s = ( isset($_SERVER['HTTPS']) and get_true_boolean($_SERVER['HTTPS']) ) ? "s" : "";
|
||||
$base_url = "http$s://".implode('/', (explode('/', $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], -1)));
|
||||
if($url){
|
||||
$link["bb_close"] = "[/url]";
|
||||
$link["bb_type_a"] = "[url=".$url."]";
|
||||
$link["bb_type_b"] = "[url=\"".$url."\"]";
|
||||
$link["href"] = "<a href=\"".$url."\">";
|
||||
$link["href_close"] = "</a>";
|
||||
}
|
||||
|
||||
$types = array("normal", "small", "sky");
|
||||
if($img_type)
|
||||
$types = array($img_type);
|
||||
|
||||
$output = "";
|
||||
if($use_table) $output .= "\n<table class='center' >\n";
|
||||
$image_td_align = $img_only ? "center" : "left";
|
||||
foreach($types as $type)
|
||||
{
|
||||
if($use_rows) $output .= "\t<tr>\n";
|
||||
if(!$img_only) $output .= "\t\t<td align='right' width=30px >\n".
|
||||
"\t\t\t<b>Banner $type</b>\n".
|
||||
"\t\t</td>\n";
|
||||
$output .= "\t\t<td align='$image_td_align' >\n";
|
||||
if($img_join_link) $output .= "\t\t\t{$link['href']}\n";
|
||||
$output .= "\t\t\t<img src='" . DSI_BASEPATH . "s-${ip}_${port}-${type}.png'/>\n";
|
||||
if($img_join_link) $output .= "\t\t\t{$link['href_close']}\n";
|
||||
$output .= "\t\t</td>\n";
|
||||
if($show_codes)
|
||||
$output .= "\t</tr>\n".
|
||||
"\t<tr>\n".
|
||||
"\t\t<td align='right' width=30px >\n".
|
||||
"\t\t\t<b>Codes</b>".
|
||||
"\t\t</td>\n".
|
||||
"\t\t<td align='left' ><input type='text' readonly='readonly' style='width:100%;' onclick='select()' value='".$link["bb_type_a"]."[img]$base_url/" . DSI_BASEPATH . "s-${ip}_${port}-${type}.png[/img]".$link["bb_close"]."' /><br />\n".
|
||||
"\t\t\t<input type='text' readonly='readonly' style='width:100%;' onclick='select()' value='".$link["bb_type_b"]."[img]$base_url/" . DSI_BASEPATH . "s-${ip}_${port}-${type}.png[/img]".$link["bb_close"]."' /><br />\n".
|
||||
"\t\t\t<input type='text' readonly='readonly' style='width:100%;' onclick='select()' value='".$link["href"]."<img src=\"$base_url/" . DSI_BASEPATH . "s-${ip}_${port}-${type}.png\">".$link["href_close"]."' />\n".
|
||||
"\t\t</td>\n";
|
||||
if($use_rows) $output .= "\t</tr>\n";
|
||||
}
|
||||
|
||||
if($use_table) $output .= "</table>\n";
|
||||
|
||||
return $output;
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue