mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 13:17:24 +02:00
Secure-Image update.
This commit is contained in:
BIN
e107_core/fonts/chaostimes.ttf
Normal file
BIN
e107_core/fonts/chaostimes.ttf
Normal file
Binary file not shown.
BIN
e107_core/fonts/crazy_style.ttf
Normal file
BIN
e107_core/fonts/crazy_style.ttf
Normal file
Binary file not shown.
BIN
e107_core/fonts/puchakhonmagnifier3.ttf
Normal file
BIN
e107_core/fonts/puchakhonmagnifier3.ttf
Normal file
Binary file not shown.
@@ -20,6 +20,7 @@ class secure_image
|
|||||||
public $random_number;
|
public $random_number;
|
||||||
protected $HANDLERS_DIRECTORY;
|
protected $HANDLERS_DIRECTORY;
|
||||||
protected $IMAGES_DIRECTORY;
|
protected $IMAGES_DIRECTORY;
|
||||||
|
protected $FONTS_DIRECTORY;
|
||||||
protected $MYSQL_INFO;
|
protected $MYSQL_INFO;
|
||||||
protected $THIS_DIR;
|
protected $THIS_DIR;
|
||||||
protected $BASE_DIR;
|
protected $BASE_DIR;
|
||||||
@@ -54,6 +55,7 @@ class secure_image
|
|||||||
$this->THIS_DIR = $imgp;
|
$this->THIS_DIR = $imgp;
|
||||||
$this->BASE_DIR = realpath($imgp.'..'.DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
$this->BASE_DIR = realpath($imgp.'..'.DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
|
||||||
$this->HANDLERS_DIRECTORY = $HANDLERS_DIRECTORY;
|
$this->HANDLERS_DIRECTORY = $HANDLERS_DIRECTORY;
|
||||||
|
$this->FONTS_DIRECTORY = isset($CORE_DIRECTORY) ? $CORE_DIRECTORY."fonts/" : "e107_core/fonts/";
|
||||||
// $this->IMAGES_DIRECTORY = str_replace('/', DIRECTORY_SEPARATOR, $IMAGES_DIRECTORY);
|
// $this->IMAGES_DIRECTORY = str_replace('/', DIRECTORY_SEPARATOR, $IMAGES_DIRECTORY);
|
||||||
$this->IMAGES_DIRECTORY = $IMAGES_DIRECTORY;
|
$this->IMAGES_DIRECTORY = $IMAGES_DIRECTORY;
|
||||||
$this->MYSQL_INFO = array('db' => $mySQLdefaultdb, 'server' => $mySQLserver, 'user' => $mySQLuser, 'password' => $mySQLpassword, 'prefix' => $mySQLprefix);
|
$this->MYSQL_INFO = array('db' => $mySQLdefaultdb, 'server' => $mySQLserver, 'user' => $mySQLuser, 'password' => $mySQLpassword, 'prefix' => $mySQLprefix);
|
||||||
@@ -137,7 +139,7 @@ class secure_image
|
|||||||
}
|
}
|
||||||
|
|
||||||
$code = $this->create_code();
|
$code = $this->create_code();
|
||||||
return "<img src='".e_HTTP.$this->IMAGES_DIRECTORY."secimg.php?{$code}' class='icon secure-image' alt='Missing Code' />";
|
return "<img src='".e_HTTP.$this->IMAGES_DIRECTORY."secimg.php?{$code}' class='icon secure-image' alt='Missing Code' style='max-width:100%' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -188,7 +190,7 @@ class secure_image
|
|||||||
if(!is_numeric($qcode)){ exit; }
|
if(!is_numeric($qcode)){ exit; }
|
||||||
$recnum = preg_replace('#\D#',"",$qcode);
|
$recnum = preg_replace('#\D#',"",$qcode);
|
||||||
|
|
||||||
$imgtypes = array('jpg'=>"jpeg",'png'=>"png",'gif'=>"gif");
|
$imgtypes = array('png'=>"png",'gif'=>"gif",'jpg'=>"jpeg",);
|
||||||
|
|
||||||
@mysql_connect($this->MYSQL_INFO['server'], $this->MYSQL_INFO['user'], $this->MYSQL_INFO['password']) || die('db connection failed');
|
@mysql_connect($this->MYSQL_INFO['server'], $this->MYSQL_INFO['user'], $this->MYSQL_INFO['password']) || die('db connection failed');
|
||||||
@mysql_select_db($this->MYSQL_INFO['db']);
|
@mysql_select_db($this->MYSQL_INFO['db']);
|
||||||
@@ -216,6 +218,7 @@ class secure_image
|
|||||||
}
|
}
|
||||||
|
|
||||||
$path = $this->BASE_DIR.$this->IMAGES_DIRECTORY;
|
$path = $this->BASE_DIR.$this->IMAGES_DIRECTORY;
|
||||||
|
$fontpath = $this->BASE_DIR.$this->IMAGES_DIRECTORY;
|
||||||
$secureimg = array();
|
$secureimg = array();
|
||||||
|
|
||||||
if(is_readable($path."secure_image_custom.php"))
|
if(is_readable($path."secure_image_custom.php"))
|
||||||
@@ -234,55 +237,90 @@ class secure_image
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
$bg_file = $secureimg['image'];
|
$bg_file = $secureimg['image'];
|
||||||
|
// var_dump($secureimg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
if(!is_readable($path.$secureimg['font']))
|
$bg_file = "generic/code_bg";
|
||||||
|
$fontpath = $this->BASE_DIR.$this->FONTS_DIRECTORY;
|
||||||
|
$secureimg['angle'] = "0";
|
||||||
|
$secureimg['color'] = "90,90,90"; // red,green,blue
|
||||||
|
$secureimg['x'] = "1";
|
||||||
|
$secureimg['y'] = "21";
|
||||||
|
|
||||||
|
$num = rand(1,3);
|
||||||
|
|
||||||
|
switch ($num)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
$secureimg['font'] = "chaostimes.ttf";
|
||||||
|
$secureimg['size'] = "19";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
$secureimg['font'] = "crazy_style.ttf";
|
||||||
|
$secureimg['size'] = "18";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
$secureimg['font'] = "puchakhonmagnifier3.ttf";
|
||||||
|
$secureimg['size'] = "19";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($secureimg['font']) && !is_readable($path.$secureimg['font']))
|
||||||
{
|
{
|
||||||
echo "Font missing"; // for debug only. translation not necessary.
|
echo "Font missing"; // for debug only. translation not necessary.
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_readable($path.$secureimg['image'].$ext))
|
if(isset($secureimg['font']) && !is_readable($path.$secureimg['image'].$ext))
|
||||||
{
|
{
|
||||||
echo "Missing Background-Image: ".$secureimg['image'].$ext; // for debug only. translation not necessary.
|
echo "Missing Background-Image: ".$secureimg['image'].$ext; // for debug only. translation not necessary.
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
// var_dump($secureimg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$bg_file = "generic/code_bg";
|
|
||||||
}
|
|
||||||
|
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
case "jpeg":
|
case "png": // preferred
|
||||||
$image = ImageCreateFromJPEG($path.$bg_file.".jpg");
|
$image = imagecreatefrompng($path.$bg_file.".png");
|
||||||
break;
|
imagealphablending($image, true);
|
||||||
case "png":
|
|
||||||
$image = ImageCreateFromPNG($path.$bg_file.".png");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "gif":
|
case "gif":
|
||||||
$image = ImageCreateFromGIF($path.$bg_file.".gif");
|
$image = imagecreatefromgif($path.$bg_file.".gif");
|
||||||
|
imagealphablending($image, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "jpeg":
|
||||||
|
$image = imagecreatefromjpeg($path.$bg_file.".jpg");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// removing the black from the placeholder
|
||||||
|
|
||||||
|
|
||||||
if(isset($secureimg['color']))
|
if(isset($secureimg['color']))
|
||||||
{
|
{
|
||||||
$tmp = explode(",",$secureimg['color']);
|
$tmp = explode(",",$secureimg['color']);
|
||||||
$text_color = ImageColorAllocate($image,$tmp[0],$tmp[1],$tmp[2]);
|
$text_color = imagecolorallocate($image,$tmp[0],$tmp[1],$tmp[2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$text_color = ImageColorAllocate($image, 90, 90, 90);
|
$text_color = imagecolorallocate($image, 90, 90, 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-type: image/{$type}");
|
header("Content-type: image/{$type}");
|
||||||
|
|
||||||
if(isset($secureimg['font']) && is_readable($path.$secureimg['font']))
|
if(isset($secureimg['font']) && is_readable($fontpath.$secureimg['font']))
|
||||||
{
|
{
|
||||||
imagettftext($image, $secureimg['size'],$secureimg['angle'], $secureimg['x'], $secureimg['y'], $text_color,$path.$secureimg['font'], $code);
|
imagettftext($image, $secureimg['size'],$secureimg['angle'], $secureimg['x'], $secureimg['y'], $text_color,$fontpath.$secureimg['font'], $code);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 7.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 965 B |
Reference in New Issue
Block a user