Поставил себе Danneo CMS, но код подтвеждения не может сгенерироватся, показывает пустую картинку. Это можно както исправить?
Вот код image.php:
<?php
/* ==================================================== ##
## COPYRIGHTS © DANNEO PHP TEAM ##
## ==================================================== ##
## PRODUCT : CMS(CONTENT MANAGEMENT SYSTEM) ##
## LICENSE : GNU 2(General Public License v.2) ##
## TECHNOLOGIES : PHP & MySQL ##
## WWW : www.danneo.com | www.danneo.org ##
## E-MAIL : help@danneo.com ##
## ==================================================== */
/* ==================================================== ##
## Базовые константы ##
## ==================================================== */
$DNBASE = dirname(__FILE__);
define("DNBASE",$DNBASE.'/');
define("DNREAD",1);
/* ==================================================== ##
## Основные рабочие переменные ##
## ==================================================== */
$siteglobal = array();
$setting = array();
/* ==================================================== ##
## Языковые переменные ##
## ==================================================== */
$lang = array();
$langdate = array();
/* ==================================================== ##
## Подключение : danneo.initapi.php ##
## Основной рабочий класс ядра ##
## ==================================================== */
require_once(DNBASE."base/danneo.initapi.php");
/* ==================================================== ##
## Подключение : danneo.setting.php ##
## Файл настроек соединения с СУБД ##
## ==================================================== */
require_once(DNBASE."base/danneo.setting.php");
/* ==================================================== ##
## $api,$db - обьявление ##
## ==================================================== */
$api = new api();
$db = new db($hostname,$nameuser,$password,$namebase);
/* ==================================================== ##
## Подключение : danneo.template.php ##
## Файл шаблонизатора ядра ##
## ==================================================== */
require_once(DNBASE."base/danneo.template.php");
/* ==================================================== ##
## $setting['mod'] ##
## ==================================================== */
$setting['mod'] = '';
/* ==================================================== ##
## Подключение : danneo.function.php ##
## Файл основных функций ядра ##
## ==================================================== */
require_once(DNBASE."base/danneo.function.php");
/* ==================================================== ##
## Сообщение о закрытом сайте ##
## ==================================================== */
if($setting['closed']=="yes"){ $tm->closeprint($setting['closedtext']); }
/* ==================================================== ##
## LEGAL TODO ##
## ==================================================== */
$legaltodo = array('index','captcha');
/* ==================================================== ##
## IF EMPTY OR UNLEGAL ##
## ==================================================== */
$to = (isset($to) && in_array($api->sitedn($to),$legaltodo)) ? $api->sitedn($to) : 'index';
/* ==================================================== ##
## INDEX LEGALTODO ##
## ==================================================== */
if($to=='index'){ exit(); }
/* ==================================================== ##
## START CLASS CAPTCHA ##
## ==================================================== */
class captcha{
/* ==================================================== ##
## VAR CLASS CAPTCHA ##
## ==================================================== */
var $code = array(); // Рабочий массив
var $life = 60; // Время жизни проверочного кода
var $chars = '123456789'; // Символы проверочного кода, пока только цифры
var $fonts = 'base/truefonts/danneo.captcha.void.ttf'; // Шрифт проверочного кода, пока только цифры
var $imagewidth = 110; // Ширина проверочного кода
var $imageheight = 40; // Высота проверочного кода
var $imagebg = array(249,249,249); // Цвет фона проверочного кода
/* ==================================================== ##
## FUNCTION FIND | CLASS CAPTCHA ##
## ==================================================== */
function find(){
global $db,$basepref;
$db->query("DELETE FROM ".$basepref."_captcha WHERE captchtime < ".(NEWTIME - $this->life)."");
// ISSET
$captchaitem = $db->fetchrow($db->query("SELECT captchcode FROM ".$basepref."_captcha WHERE captchip = '".REMOTE_ADDRS."' AND captchtime > ".(NEWTIME - $this->life)." ORDER BY captchtime ASC LIMIT 1"));
// ISSET
if($captchaitem['captchcode']){
for($i=0; $i < strlen($captchaitem['captchcode']); $i++){
$this->code[$i] = $captchaitem['captchcode']{$i};
}
// ISSET
} else {
// ISSET
$insertcode = '';
for($i=0; $i < 5; $i++){
$insertcode.= $symbol = substr($this->chars,(mt_rand() % strlen($this->chars)),1);
$this->code[$i] = $symbol;
}
$db->query("INSERT INTO ".$basepref."_captcha VALUES (NULL,'".REMOTE_ADDRS."','".$insertcode."','".NEWTIME."')");
// ISSET
}
// ISSET
}
/* ==================================================== ##
## FUNCTION BLUR | CLASS CAPTCHA ##
## ==================================================== */
function blur($img) {
$imagex = imagesx($img);
$imagey = imagesy($img);
$dist = 0.5;
for($x = 0; $x < $imagex; ++$x){
for($y = 0; $y < $imagey; ++$y){
$newr = 0;
$newg = 0;
$newb = 0;
$colours = array();
$thiscol = imagecolorat($img, $x, $y);
for($k = $x - $dist; $k <= $x + $dist; ++$k){
for($l = $y - $dist; $l <= $y + $dist; ++$l){
if($k < 0){ $colours[] = $thiscol; continue; }
if($k >= $imagex){ $colours[] = $thiscol; continue; }
if($l < 0){ $colours[] = $thiscol; continue; }
if($l >= $imagey) { $colours[] = $thiscol; continue; }
$colours[] = imagecolorat($img, $k, $l);
}
}
foreach($colours as $colour) {
$newr += ($colour >> 16) & 0xFF;
$newg += ($colour >> 8) & 0xFF;
$newb += $colour & 0xFF;
}
$numelements = count($colours);
$newr /= $numelements;
$newg /= $numelements;
$newb /= $numelements;
$newcol = imagecolorallocate($img,$newr,$newg,$newb);
imagesetpixel($img,$x,$y,$newcol);
}
}
return $img;
}
/* ==================================================== ##
## FUNCTION WAVE | CLASS CAPTCHA ##
## ==================================================== */
function wave($img){
$input = array(-6,6);
$rand_keys = array_rand($input,1);
$tempimage = @imagecreatetruecolor($this->imagewidth,$this->imageheight);
$tempbg = @imagecolorallocate($tempimage,$this->imagebg[0],$this->imagebg[1],$this->imagebg[2]);
@imagefilledrectangle($tempimage,0,0,$this->imagewidth,$this->imageheight,$tempbg);
for($x=0; $x < $this->imagewidth; $x++){
$y = $input[$rand_keys] * cos(4.5 * 3.14 * $x / 100);
@imagecopy($tempimage,$img,$x,$y,$x,0,1,$this->imageheight);
}
return $tempimage;
}
/* ==================================================== ##
## FUNCTION VIEW | CLASS CAPTCHA ##
## ==================================================== */
function view(){
// ПОЛУЧАЕМ КОД
$this->find();
// ЗАГОЛОВОК
@header("Expires: Tue, 11 Jun 1985 05:00:00 GMT");
@header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
@header("Cache-Control: no-store, no-cache, must-revalidate");
@header("Cache-Control: post-check=0, pre-check=0",false);
@header("Pragma: no-cache");
@header("Content-type: image/gif");
// СОЗДАЁМ ИЗОБРАЖЕНИЕ
$image = @imagecreatetruecolor($this->imagewidth,$this->imageheight);
// ЦВЕТ ФОНА
$bgcolor = imagecolorallocate($image,$this->imagebg[0],$this->imagebg[1],$this->imagebg[2]);
// ЦВЕТ ОБВОДКИ
$licolor = imagecolorallocate($image,174,174,174);
// ЗАЛИВКА
imagefilledrectangle($image,0,0,$this->imagewidth,$this->imageheight,$bgcolor);
// ВЫВОД
for($i=0; $i < count($this->code); $i++){
$rotator = mt_rand(5,-5); // наклон случайно
$rotatos = mt_rand(-5,5); // наклон случайно
$r = mt_rand(10,128); // RGB - случайно
$g = mt_rand(10,128); // RGB - случайно
$b = mt_rand(10,128); // RGB - случайно
$textcol = @imagecolorallocate($image,$r,$g,$b);
imagettftext($image,19,$rotator,7 + ($i * 20),27 + $rotatos,$licolor,$this->fonts,$this->code[$i]);
imagettftext($image,19,$rotator,7 + ($i * 19),27 + $rotatos,$textcol,$this->fonts,$this->code[$i]);
}
// Макса
$image = $this->wave($image);
$image = $this->blur($image);
// ОБВОДКА
imageline($image,0,0,$this->imagewidth,0,$licolor);
imageline($image,0,0,0,$this->imageheight,$licolor);
imageline($image,0,$this->imageheight-1,$this->imagewidth,$this->imageheight-1,$licolor);
imageline($image,$this->imagewidth-1,0,$this->imagewidth-1,$this->imageheight,$licolor);
imagegif($image);
imagedestroy($image);
}
/* ==================================================== ##
## END CLASS CAPTCHA ##
## ==================================================== */
}
/* ==================================================== ##
## CAPTCHA LEGALTODO ##
## ==================================================== */
if($to=='captcha'){
$captcha = new captcha();
$captcha->view();
}
?>