/**
  * Get image
  * @params string
  **/
 function getImage($val)
 {
     $document =& JFactory::getDocument();
     $document->setMimeEncoding('image/jpg');
     $im = @imagecreatetruecolor(100, 40) or die('Cannot create image');
     $text_color = imagecolorallocate($im, 233, 14, 91);
     Imagestring($im, 1, 5, 5, $val, $text_color);
     @ImageJPEG($img, null, 100);
     Imagedestroy($im);
 }
Beispiel #2
0
function img($text)
{
    $img_height = 50;
    $img_width = 18;
    $img = imagecreate($img_height, $img_width);
    ImageColorAllocate($img, 255, 255, 255);
    $black = ImageColorAllocate($img, 0, 0, 0);
    for ($i = 0; $i < 10; $i++) {
        ImageString($img, 1, mt_rand(1, $img_height), mt_rand(0, $img_width), "Q", imageColorAllocate($img, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255)));
    }
    ImageRectangle($img, 0, 0, $img_height - 1, $img_width - 1, $black);
    //
    Imagestring($img, 5, 5, 2, $text, imageColorAllocate($img, mt_rand(0, 100), mt_rand(0, 150), mt_rand(0, 200)));
    Imagepng($img);
    ImageDestroy($img);
}
Beispiel #3
0
 private function create_do()
 {
     $this->im = Imagecreate($this->config['width'], $this->config['height']);
     //设置背景为白色
     Imagecolorallocate($this->im, $this->config['color'][0], $this->config['color'][1], $this->config['color'][2]);
     //为此背景加个边框
     if ($this->config['boxline'] == True) {
         $bordercolor = Imagecolorallocate($this->im, 37, 37, 37);
         Imagerectangle($this->im, 0, 0, $this->config['width'] - 1, $this->config['height'] - 1, $bordercolor);
     }
     //生成验证码
     $this->create_str();
     $coder = $_SESSION[$this->config['codname']];
     //输入文字
     $fontcolor = Imagecolorallocate($this->im, 46, 46, 46);
     for ($i = 0; $i < $this->config['length']; $i++) {
         Imagestring($this->im, 5, $i * 10 + 6, rand(2, 5), $coder[$i], $fontcolor);
     }
     //加入干扰线
     $interfere = $this->config['interfere'];
     $interfere = $interfere > 30 ? "30" : $interfere;
     if (!empty($interfere) && $interfere > 1) {
         for ($i = 1; $i < $interfere; $i++) {
             $linecolor = Imagecolorallocate($this->im, rand(0, 255), rand(0, 255), rand(0, 255));
             $x = rand(1, $this->config['width']);
             $y = rand(1, $this->config['height']);
             $x2 = rand($x - 10, $x + 10);
             $y2 = rand($y - 10, $y + 10);
             Imageline($this->im, $x, $y, $x2, $y2, $linecolor);
         }
     }
     ob_clean();
     Header("Pragma:no-cache\r\n");
     Header("Cache-Control:no-cache\r\n");
     Header("Expires:0\r\n");
     Header("Content-type:Image/jpeg\r\n");
     Imagejpeg($this->im);
     Imagedestroy($this->im);
     exit;
 }
Beispiel #4
0
 /**
  * 指定サイズで画像を出力する.
  *
  * @param string  $FromImgPath ファイル名までのパス
  * @param string  $ToImgPath   出力先パス
  * @param integer $tmpMW       最大横幅
  * @param integer $tmpMH       最大縦幅
  * @param integer $newFileName 新ファイル名
  * @param array 新ファイル名を格納した配列
  */
 public function MakeThumb($FromImgPath, $ToImgPath, $tmpMW, $tmpMH, $newFileName = '')
 {
     // 画像の最大横幅(単位:ピクセル)
     $ThmMaxWidth = LARGE_IMAGE_WIDTH;
     // 画像の最大縦幅(単位:ピクセル)
     $ThmMaxHeight = LARGE_IMAGE_HEIGHT;
     //拡張子取得
     $array_ext = explode('.', $FromImgPath);
     $ext = $array_ext[count($array_ext) - 1];
     $MW = $ThmMaxWidth;
     if ($tmpMW) {
         $MW = $tmpMW;
     }
     // $MWに最大横幅セット
     $MH = $ThmMaxHeight;
     if ($tmpMH) {
         $MH = $tmpMH;
     }
     // $MHに最大縦幅セット
     if (empty($FromImgPath) || empty($ToImgPath)) {
         return array(0, '出力元画像パス、または出力先フォルダが指定されていません。');
     }
     if (!file_exists($FromImgPath)) {
         return array(0, '出力元画像が見つかりません。');
     }
     $size = @GetImageSize($FromImgPath);
     $re_size = $size;
     // 画像の種類が不明 or swf
     if (!$size[2] || $size[2] > 3) {
         return array(0, '画像形式がサポートされていません。');
     }
     //アスペクト比固定処理
     $tmp_w = $size[0] / $MW;
     if ($MH != 0) {
         $tmp_h = $size[1] / $MH;
     }
     if ($tmp_w > 1 || $tmp_h > 1) {
         if ($MH == 0) {
             if ($tmp_w > 1) {
                 $re_size[0] = $MW;
                 $re_size[1] = $size[1] * $MW / $size[0];
             }
         } else {
             if ($tmp_w > $tmp_h) {
                 $re_size[0] = $MW;
                 $re_size[1] = $size[1] * $MW / $size[0];
             } else {
                 $re_size[1] = $MH;
                 $re_size[0] = $size[0] * $MH / $size[1];
             }
         }
     }
     // サムネイル画像ファイル名作成処理
     $tmp = array_pop(explode('/', $FromImgPath));
     // /の一番最後を切り出し
     $FromFileName = array_shift(explode('.', $tmp));
     // .で区切られた部分を切り出し
     $ToFile = $FromFileName;
     // 拡張子以外の部分までを作成
     $ImgNew = imagecreatetruecolor($re_size[0], $re_size[1]);
     switch ($size[2]) {
         case '1':
             //gif形式
             if ($tmp_w <= 1 && $tmp_h <= 1) {
                 if ($newFileName) {
                     $ToFile = $newFileName;
                 } elseif ($ext) {
                     $ToFile .= '.' . $ext;
                 } else {
                     $ToFile .= '.gif';
                 }
                 if (!@copy($FromImgPath, $ToImgPath . $ToFile)) {
                     // エラー処理
                     return array(0, 'ファイルのコピーに失敗しました。');
                 }
                 ImageDestroy($ImgNew);
                 return array(1, $ToFile);
             }
             ImageColorAllocate($ImgNew, 255, 235, 214);
             //背景色
             $black = ImageColorAllocate($ImgNew, 0, 0, 0);
             $red = ImageColorAllocate($ImgNew, 255, 0, 0);
             Imagestring($ImgNew, 4, 5, 5, "GIF {$size['0']}x{$size['1']}", $red);
             ImageRectangle($ImgNew, 0, 0, $re_size[0] - 1, $re_size[1] - 1, $black);
             if ($newFileName) {
                 $ToFile = $newFileName;
             } elseif ($ext) {
                 $ToFile .= '.' . $ext;
             } else {
                 $ToFile .= '.png';
             }
             $TmpPath = $ToImgPath . $ToFile;
             @Imagepng($ImgNew, $TmpPath);
             // 画像が作成されていない場合
             if (!@file_exists($TmpPath)) {
                 return array(0, '画像の出力に失敗しました。');
             }
             ImageDestroy($ImgNew);
             return array(1, $ToFile);
         case '2':
             //jpg形式
             $ImgDefault = ImageCreateFromJpeg($FromImgPath);
             //ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
             if ($re_size[0] != $size[0] || $re_size[0] != $size[0]) {
                 ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
             }
             GcUtils::gfDebugLog($size);
             GcUtils::gfDebugLog($re_size);
             if ($newFileName) {
                 $ToFile = $newFileName;
             } elseif ($ext) {
                 $ToFile .= '.' . $ext;
             } else {
                 $ToFile .= '.jpg';
             }
             $TmpPath = $ToImgPath . $ToFile;
             @ImageJpeg($ImgNew, $TmpPath);
             // 画像が作成されていない場合
             if (!@file_exists($TmpPath)) {
                 return array(0, "画像の出力に失敗しました。<br>{$ImgNew}<br>{$TmpPath}");
             }
             $RetVal = $ToFile;
             break;
         case '3':
             //png形式
             $ImgDefault = ImageCreateFromPNG($FromImgPath);
             //ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
             ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
             if ($newFileName) {
                 $ToFile = $newFileName;
             } elseif ($ext) {
                 $ToFile .= '.' . $ext;
             } else {
                 $ToFile .= '.png';
             }
             $TmpPath = $ToImgPath . $ToFile;
             @ImagePNG($ImgNew, $TmpPath);
             // 画像が作成されていない場合
             if (!@file_exists($TmpPath)) {
                 return array(0, '画像の出力に失敗しました。');
             }
             $RetVal = $ToFile;
             break;
     }
     ImageDestroy($ImgDefault);
     ImageDestroy($ImgNew);
     return array(1, $RetVal);
 }
<?php

// $Header$
// Copyright (c) 2002-2005, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
//session_start();
// hmm. to many session tweaks in setup_smarty ... we need to call this
require_once 'tiki-setup.php';
//random_number.php
$img_number = imagecreate(95, 30);
$white = imagecolorallocate($img_number, 255, 255, 255);
$black = imagecolorallocate($img_number, 0, 0, 0);
$grey_shade = imagecolorallocate($img_number, 204, 204, 204);
imagefill($img_number, 0, 0, $grey_shade);
srand(time());
$number = get_random();
$_SESSION['random_number'] = $number;
for ($i = 0; $i < 5; $i++) {
    Imagestring($img_number, 5, 10 + 17 * $i + rand(0, 2), 1 + rand(0, 10), substr($number, $i, 1), $black);
}
header("Content-type: image/jpeg");
imagejpeg($img_number);
function get_random()
{
    # return a 5 digit value
    return rand(10000, 99999);
}
Beispiel #6
0
<?php

$img_number = imagecreate(275, 25);
$backcolor = imagecolorallocate($img_number, 102, 102, 153);
$textcolor = imagecolorallocate($img_number, 255, 255, 255);
imagefill($img_number, 0, 0, $backcolor);
$number = "{$_SERVER['REMOTE_ADDR']}";
Imagestring($img_number, 10, 5, 5, $number, $textcolor);
header('Content-type: image/jpeg');
imagejpeg($img_number);
Beispiel #7
0
 function addText($str, $x, $y, $col, $f = 0, $biu = '')
 {
     if (!$this->error) {
         if ($f) {
             $colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]);
             imagettftext($this->img, $f, 0, $x, $y, $colour, "./produkty/font.ttf", $str);
         } else {
             $colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]);
             Imagestring($this->img, $font, $x, $y, $str, $colour);
         }
     }
 }
 function DrawBarGraph($image)
 {
     if ($this->_debug) {
         $this->DebugPrint();
     }
     // Setup the margins
     $this->_topMargin = 0;
     $this->_bottomMargin = 30;
     $this->_leftMargin = 20;
     $this->_rightMargin = $this->_barSpacing + 1 + 10;
     // setup the color for the lines
     $tempLineColor = $this->RGBColor($this->_lineColorHex);
     $lineColor = ImageColorAllocate($image, $tempLineColor["red"], $tempLineColor["green"], $tempLineColor["blue"]);
     // setup the color for the bar lines
     $tempBarLineColor = $this->RGBColor($this->_barLineColorHex);
     $barLineColor = ImageColorAllocate($image, $tempBarLineColor["red"], $tempBarLineColor["green"], $tempBarLineColor["blue"]);
     $tempStartColor = $this->RGBColor($this->_startBarColorHex);
     $startColor = ImageColorAllocate($image, $tempStartColor["red"], $tempStartColor["green"], $tempStartColor["blue"]);
     $numEntries = count($this->_values);
     // Figure out how wide each bar is going to be.
     if ($numEntries != 0) {
         $this->_barWidth = ($this->_width - ($this->_leftMargin + $this->_rightMargin + 1) - count($this->_values) * $this->_barSpacing) / count($this->_values);
     }
     // Find out what the smallest and largest amount is.
     $this->_minBarHeight = 1;
     $this->_maxBarHeight = 0;
     $i = $numEntries;
     while ($i--) {
         if ($this->_minBarHeight > $this->_values[$i]["value"]) {
             $this->_minBarHeight = $this->_values[$i]["value"];
         }
         if ($this->_maxBarHeight < $this->_values[$i]["value"]) {
             $this->_maxBarHeight = $this->_values[$i]["value"];
         }
     }
     // Figure out how tall the tallest and smallest bar are going to be.
     $this->_realMinBarHeight = $this->_minBarHeight - ($this->_minBarHeight * $this->_buffer + 1);
     $this->_realMaxBarHeight = $this->_maxBarHeight * ($this->_buffer + 1);
     $workArea = $this->_height - $this->_bottomMargin - $this->_topMargin - 1;
     // Print out all the ticks
     if ($this->_numOfValueTicks > $this->_maxBarHeight) {
         $this->_numOfValueTicks = $this->_maxBarHeight;
     }
     $numTicks = $this->_numOfValueTicks;
     for ($i = 1; $i <= $numTicks; $i++) {
         $thisBarValue = floor(($this->_maxBarHeight - $this->_minBarHeight) / $this->_numOfValueTicks * $i) + $this->_minBarHeight;
         $myTickheight = $workArea / ($this->_maxBarHeight - $this->_realMinBarHeight) * ($thisBarValue - $this->_realMinBarHeight);
         // Figure out where we're going to put this tick..
         $y1 = $this->_height - $this->_bottomMargin - 1 - $myTickheight;
         if ($thisBarValue >= $this->_minBarHeight) {
             imageline($image, $this->_leftMargin - 5 + $this->_x, $y1 + $this->_y, $this->_width - $this->_rightMargin + $this->_barSpacing + $this->_x, $y1 + $this->_y, $lineColor);
             Imagestring($image, 1, $this->_leftMargin + $this->_x - 15, $y1 + $this->_y + 2, $thisBarValue, $lineColor);
         }
     }
     // Print out all the bars
     $numBars = count($this->_values);
     for ($i = 1; $i <= $numBars; $i++) {
         // Get the bar height for this bar.
         $myBarheight = $workArea / ($this->_maxBarHeight - $this->_realMinBarHeight) * ($this->_values[$i - 1]["value"] - $this->_realMinBarHeight);
         // Figure out where we're going to put this bar..
         $x1 = $this->_leftMargin + 1 + ($i - 1) * $this->_barWidth + $i * $this->_barSpacing;
         $y1 = $this->_height - $this->_bottomMargin - 1 - $myBarheight;
         $x2 = $this->_leftMargin + ($i - 1) * $this->_barWidth + $i * $this->_barSpacing + $this->_barWidth;
         $y2 = $this->_height - $this->_bottomMargin - 1;
         if ($this->_values[$i - 1]["value"] != 0) {
             // Print the bar
             $this->fadeBar($image, $x1 + $this->_x, $y1 + $this->_y, $x2 + $this->_x, $y2 + $this->_y, $this->_startBarColorHex, $this->_endBarColorHex, $myBarheight, $this->_barWidth);
             ImageRectangle($image, $x1 + $this->_x, $y1 + $this->_y, $x2 + $this->_x, $y2 + $this->_y + 1, $barLineColor);
         }
         Imagestring($image, 2, $x1 + $this->_x, $this->_height - $this->_bottomMargin / 2 - 10 + $this->_y, $this->_values[$i - 1]["value"], $lineColor);
         Imagestring($image, 2, $x1 + $this->_x, $this->_height - $this->_bottomMargin / 2 + $this->_y, $this->_values[$i - 1]["label"], $lineColor);
     }
     // draw the border box
     ImageRectangle($image, $this->_leftMargin + $this->_x, $this->_topMargin + $this->_y, $this->_width - $this->_rightMargin + $this->_barSpacing + $this->_x, $this->_height - $this->_bottomMargin + $this->_y, $lineColor);
 }
Beispiel #9
0
 *
 */
include "config.php";
include_once "lib/mysql.class.php";
include_once "lib/layout.class.php";
$mysql = new MySQL();
$mysql->Open($db_host, $db_user, $db_pass, $db_name);
$active = $mysql->Query("SELECT * FROM 0xSentinel_settings");
$row = mysql_fetch_array($active);
$image = "images/banner.png";
$im = ImageCreateFromPNG($image);
imageAlphaBlending($im, TRUE);
imageSaveAlpha($im, TRUE);
$txt_color = ImageColorAllocate($im, 80, 80, 80);
if ($row['active'] == 1) {
    $color_status = ImageColorAllocate($im, 80, 80, 80);
} else {
    $color_status = ImageColorAllocate($im, 255, 0, 0);
}
$attack_blocked = intval(mysql_num_rows($mysql->Query("SELECT * FROM 0xSentinel_logs")));
$version = VERSION;
ImageString($im, 2, 10, 25, "Version: {$version}", $txt_color);
ImageString($im, 2, 10, 37, "Status: ", $txt_color);
ImageString($im, 2, 70, 37, $row['active'] ? "Online" : "Offline", $color_status);
Imagestring($im, 2, 10, 49, "Attack Blocked: {$attack_blocked}", $txt_color);
header("Content-type: image/png");
Imagepng($im);
ImageDestroy($im);
?>
 
 function addText($str = '', $x = 0, $y = 0, $col = array(0, 0, 0), $f_size = 2)
 {
     $this->setSize($f_size);
     if (!$this->error) {
         if ($this->font) {
             $colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]);
             if (!imagettftext($this->img, $this->size, 0, $x, $y, $colour, $this->font, $str)) {
                 $this->font = false;
                 $this->errorImage("Error Drawing Text");
             }
         } else {
             $base_font_size = $f_size / 5;
             $colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]);
             Imagestring($this->img, $base_font_size, $x, $y, $str, $colour);
         }
     }
 }
Beispiel #11
0
 function addText($str, $x, $y, $col)
 {
     if (!$this->error) {
         if ($this->font) {
             $colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]);
             if (!imagettftext($this->img, $this->size, 0, $x, $y, $colour, $this->font, $str)) {
                 $this->font = false;
                 $this->errorImage("Error Drawing Text");
             }
         } else {
             $colour = ImageColorAllocate($this->img, $col[0], $col[1], $col[2]);
             Imagestring($this->img, 5, $x, $y, $str, $colour);
         }
     }
 }
Beispiel #12
0
 /**
  * 指定サイズで画像を出力する.
  *
  * @param string $FromImgPath ファイル名までのパス
  * @param string $ToImgPath 出力先パス
  * @param integer $tmpMW 最大横幅
  * @param integer $tmpMH 最大縦幅
  * @param integer $newFileName 新ファイル名
  * @param array 新ファイル名を格納した配列
  */
 function MakeThumb($FromImgPath, $ToImgPath, $tmpMW, $tmpMH, $newFileName = '')
 {
     // 画像の最大横幅(単位:ピクセル)
     $ThmMaxWidth = LARGE_IMAGE_WIDTH;
     // 画像の最大縦幅(単位:ピクセル)
     $ThmMaxHeight = LARGE_IMAGE_HEIGHT;
     //サムネイル画像の接頭文字
     $PreWord = $head;
     //拡張子取得
     $array_ext = explode('.', $FromImgPath);
     $ext = $array_ext[count($array_ext) - 1];
     $MW = $ThmMaxWidth;
     if ($tmpMW) {
         $MW = $tmpMW;
     }
     // $MWに最大横幅セット
     $MH = $ThmMaxHeight;
     if ($tmpMH) {
         $MH = $tmpMH;
     }
     // $MHに最大縦幅セット
     if (empty($FromImgPath) || empty($ToImgPath)) {
         return array(0, t('c_The output source image path or the output destination folder has not been designated._01'));
     }
     if (!file_exists($FromImgPath)) {
         return array(0, t('c_The output source image was not found._01'));
     }
     $size = @GetImageSize($FromImgPath);
     $re_size = $size;
     // 画像の種類が不明 or swf
     if (!$size[2] || $size[2] > 3) {
         return array(0, t('c_The image format is not supported._01'));
     }
     //アスペクト比固定処理
     $tmp_w = $size[0] / $MW;
     if ($MH != 0) {
         $tmp_h = $size[1] / $MH;
     }
     if ($tmp_w > 1 || $tmp_h > 1) {
         if ($MH == 0) {
             if ($tmp_w > 1) {
                 $re_size[0] = $MW;
                 $re_size[1] = $size[1] * $MW / $size[0];
             }
         } else {
             if ($tmp_w > $tmp_h) {
                 $re_size[0] = $MW;
                 $re_size[1] = $size[1] * $MW / $size[0];
             } else {
                 $re_size[1] = $MH;
                 $re_size[0] = $size[0] * $MH / $size[1];
             }
         }
     }
     // サムネイル画像ファイル名作成処理
     $tmp = array_pop(explode('/', $FromImgPath));
     // /の一番最後を切り出し
     $FromFileName = array_shift(explode('.', $tmp));
     // .で区切られた部分を切り出し
     $ToFile = $PreWord . $FromFileName;
     // 拡張子以外の部分までを作成
     $ImgNew = imagecreatetruecolor($re_size[0], $re_size[1]);
     switch ($size[2]) {
         case '1':
             //gif形式
             if ($tmp_w <= 1 && $tmp_h <= 1) {
                 if ($newFileName) {
                     $ToFile = $newFileName;
                 } elseif ($ext) {
                     $ToFile .= '.' . $ext;
                 } else {
                     $ToFile .= '.gif';
                 }
                 if (!@copy($FromImgPath, $ToImgPath . $ToFile)) {
                     // エラー処理
                     return array(0, t('c_File copying failed._01'));
                 }
                 ImageDestroy($ImgNew);
                 return array(1, $ToFile);
             }
             ImageColorAllocate($ImgNew, 255, 235, 214);
             //背景色
             $black = ImageColorAllocate($ImgNew, 0, 0, 0);
             $red = ImageColorAllocate($ImgNew, 255, 0, 0);
             Imagestring($ImgNew, 4, 5, 5, "GIF {$size['0']}x{$size['1']}", $red);
             ImageRectangle($ImgNew, 0, 0, $re_size[0] - 1, $re_size[1] - 1, $black);
             if ($newFileName) {
                 $ToFile = $newFileName;
             } elseif ($ext) {
                 $ToFile .= '.' . $ext;
             } else {
                 $ToFile .= '.png';
             }
             $TmpPath = $ToImgPath . $ToFile;
             @Imagepng($ImgNew, $TmpPath);
             // 画像が作成されていない場合
             if (!@file_exists($TmpPath)) {
                 return array(0, t('c_Image output failed._01'));
             }
             ImageDestroy($ImgNew);
             return array(1, $ToFile);
         case '2':
             //jpg形式
             $ImgDefault = ImageCreateFromJpeg($FromImgPath);
             //ImageCopyResized($ImgNew,$ImgDefault, 0, 0, 0, 0,$re_size[0], $re_size[1],$size[0], $size[1]);
             if ($re_size[0] != $size[0] || $re_size[0] != $size[0]) {
                 ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
             }
             GC_Utils_Ex::gfDebugLog($size);
             GC_Utils_Ex::gfDebugLog($re_size);
             if ($newFileName) {
                 $ToFile = $newFileName;
             } elseif ($ext) {
                 $ToFile .= '.' . $ext;
             } else {
                 $ToFile .= '.jpg';
             }
             $TmpPath = $ToImgPath . $ToFile;
             @ImageJpeg($ImgNew, $TmpPath);
             // 画像が作成されていない場合
             if (!@file_exists($TmpPath)) {
                 return array(0, t('c_Image output failed._01') . "<br>{$ImgNew}<br>{$TmpPath}");
             }
             $RetVal = $ToFile;
             break;
         case '3':
             //png形式
             $ImgDefault = ImageCreateFromPNG($FromImgPath);
             //ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0,$re_size[0], $re_size[1],$size[0], $size[1]);
             ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]);
             if ($newFileName) {
                 $ToFile = $newFileName;
             } elseif ($ext) {
                 $ToFile .= '.' . $ext;
             } else {
                 $ToFile .= '.png';
             }
             $TmpPath = $ToImgPath . $ToFile;
             @ImagePNG($ImgNew, $TmpPath);
             // 画像が作成されていない場合
             if (!@file_exists($TmpPath)) {
                 return array(0, t('c_Image output failed._01'));
             }
             $RetVal = $ToFile;
             break;
     }
     ImageDestroy($ImgDefault);
     ImageDestroy($ImgNew);
     return array(1, $RetVal);
 }
Beispiel #13
0
        $results = getChartDBResults($time_frame, $startDate, $endDate, $betweenClause, $orderBy, false);
        if ($results) {
            $count = count($results);
            for ($i = 0; $i < $count; $i++) {
                $r = $results[$i];
                $val = $r->the_value;
                $myLineGraph->AddValue($r->the_key, $val);
                $totalHits += $val;
                $history++;
            }
        }
        // Set the colors of the bargraph..
        $myLineGraph->SetStartBarColor("0029C1");
        // This is the color on the top of every bar.
        $myLineGraph->SetEndBarColor("00A0FA");
        // This is the color on the bottom of every bar. This is not used when SetShowFade() is set to false.
        $myLineGraph->SetLineColor("000000");
        // This is the color all the lines and text are printed out with.
        $myLineGraph->SetBarLineColor("666666");
        // Print the BarGraph to the image..
        $myLineGraph->DrawLineGraph($image);
    }
}
Imagestring($image, 2, 2, $imageHeight - 14, "{$totalHits} hits from " . date("Y-m-d H:i", st_longDateToTimeObj($startDate)) . " - " . date("Y-m-d H:i", st_longDateToTimeObj($endDate)), $text);
header("Content-type: image/png");
// Output the Image to the browser in PNG format
imagepng($image);
// Destroy the image.
Imagedestroy($image);
?>
 
 function DrawLineGraph($image)
 {
     if ($this->_debug) {
         $this->DebugPrint();
     }
     // Setup the margins
     $this->_topMargin = 0;
     $this->_bottomMargin = 30;
     $this->_leftMargin = 20;
     $this->_rightMargin = $this->_barSpacing + 1 + 10;
     // setup the color for the lines
     $tempLineColor = $this->RGBColor($this->_lineColorHex);
     $lineColor = ImageColorAllocate($image, $tempLineColor["red"], $tempLineColor["green"], $tempLineColor["blue"]);
     // setup the color for the bar lines
     $tempBarLineColor = $this->RGBColor($this->_barLineColorHex);
     $barLineColor = ImageColorAllocate($image, $tempBarLineColor["red"], $tempBarLineColor["green"], $tempBarLineColor["blue"]);
     $tempStartColor = $this->RGBColor($this->_startBarColorHex);
     $startColor = ImageColorAllocate($image, $tempStartColor["red"], $tempStartColor["green"], $tempStartColor["blue"]);
     $numEntries = count($this->_values);
     // Figure out how wide each bar is going to be.
     if ($numEntries != 0) {
         $this->_barWidth = ($this->_width - ($this->_leftMargin + $this->_rightMargin + 1) - count($this->_values) * $this->_barSpacing) / count($this->_values);
     }
     // Find out what the smallest and largest amount is.
     $this->_minBarHeight = 0;
     $this->_maxBarHeight = 0;
     for ($i = 0; $i < $numEntries; $i++) {
         if ($this->_minBarHeight > $this->_values[$i]["value"]) {
             $this->_minBarHeight = $this->_values[$i]["value"];
         }
         if ($this->_maxBarHeight < $this->_values[$i]["value"]) {
             $this->_maxBarHeight = $this->_values[$i]["value"];
         }
     }
     if ($this->_minBarHeight == 0 && $this->_maxBarHeight > 0) {
         $this->_minBarHeight = 1;
     }
     // Figure out how tall the tallest and smallest bar are going to be.
     $this->_realMinBarHeight = $this->_minBarHeight - ($this->_minBarHeight * $this->_buffer + 1);
     $this->_realMaxBarHeight = $this->_maxBarHeight * ($this->_buffer + 1);
     $workArea = $this->_height - $this->_bottomMargin - $this->_topMargin - 1;
     // Print out all the ticks
     if ($this->_numOfValueTicks > $this->_maxBarHeight) {
         $this->_numOfValueTicks = $this->_maxBarHeight;
     }
     for ($i = 1; $i <= $this->_numOfValueTicks; $i++) {
         $thisBarValue = floor(($this->_maxBarHeight - $this->_minBarHeight) / $this->_numOfValueTicks * $i) + $this->_minBarHeight;
         $myTickheight = $workArea / ($this->_maxBarHeight - $this->_realMinBarHeight) * ($thisBarValue - $this->_realMinBarHeight);
         // Figure out where we're going to put this tick..
         $y1 = $this->_height - $this->_bottomMargin - 1 - $myTickheight;
         if ($thisBarValue >= $this->_minBarHeight) {
             imageline($image, $this->_leftMargin - 5 + $this->_x, $y1 + $this->_y, $this->_width - $this->_rightMargin + $this->_barSpacing + $this->_x, $y1 + $this->_y, $lineColor);
             Imagestring($image, 1, $this->_leftMargin + $this->_x - 15, $y1 + $this->_y + 2, $thisBarValue, $lineColor);
         }
     }
     // Print out all the bars
     $num_items = count($this->_values);
     for ($i = 1; $i <= $num_items; $i++) {
         // Get the bar height for this bar.
         $myBarheight = $workArea / ($this->_maxBarHeight - $this->_realMinBarHeight) * ($this->_values[$i - 1]["value"] - $this->_realMinBarHeight);
         $nextBarheight = $workArea / ($this->_maxBarHeight - $this->_realMinBarHeight) * ($this->_values[$i]["value"] - $this->_realMinBarHeight);
         // Figure out where we're going to put this bar..
         $x1 = $this->_leftMargin + 9 + ($i - 1) * $this->_barWidth + $i * $this->_barSpacing;
         $y1 = $this->_height - $this->_bottomMargin - -11 - $myBarheight;
         $x2 = $this->_leftMargin + 9 + ($i - 1) * $this->_barWidth + $i * $this->_barSpacing + $this->_barWidth;
         $y2 = $this->_height - $this->_bottomMargin - -11 - $nextBarheight;
         // Print line
         $values = array($x1, $y1, $x1 + 3, $y1, $x2 + 3, $y2, $x2, $y2);
         imagefilledpolygon($image, $values, 4, $startColor);
         if ($i != $num_items) {
             if ($myBarheight < $nextBarheight) {
                 imagefilledellipse($image, $x2 + 2, $y2 + 2, 10, 10, $startColor);
             } else {
                 imagefilledellipse($image, $x2, $y2, 10, 10, $startColor);
             }
         }
         // Print the amount of the bar
         if ($this->_showValues) {
             Imagestring($image, 2, $x1 + $this->_x, $this->_height - $this->_bottomMargin / 2 - 10 + $this->_y, $this->_values[$i - 1]["value"], $lineColor);
         }
         // Print out the label of the bar.
         if ($this->_showLabels) {
             Imagestring($image, 2, $x1 + $this->_x, $this->_height - $this->_bottomMargin / 2 + $this->_y, $this->_values[$i - 1]["label"], $lineColor);
         }
     }
     // draw the border box
     if ($this->_showOuterBox) {
         ImageRectangle($image, $this->_leftMargin + $this->_x, $this->_topMargin + $this->_y, $this->_width - $this->_rightMargin + $this->_barSpacing + $this->_x, $this->_height - $this->_bottomMargin + $this->_y, $lineColor);
     }
 }