1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 11:20:25 +02:00

Bugtracker #4173 - try and improve operation of secure image rendering

This commit is contained in:
e107steved
2007-11-05 20:12:28 +00:00
parent 1d58d92af2
commit 053f02d40e
2 changed files with 27 additions and 16 deletions

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/secure_img_handler.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/secure_img_handler.php,v $
| $Revision: 1.1.1.1 $ | $Revision: 1.2 $
| $Date: 2006-12-02 04:33:57 $ | $Date: 2007-11-05 20:12:28 $
| $Author: mcfly_e107 $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -30,13 +30,18 @@ class secure_image {
function create_code() { function create_code() {
global $pref, $sql, $IMAGES_DIRECTORY, $HANDLERS_DIRECTORY; global $pref, $sql, $IMAGES_DIRECTORY, $HANDLERS_DIRECTORY;
/*
require_once('e107_class.php'); require_once('e107_class.php');
$e107 = new e107(false, false); $e107 = new e107(false, false);
$e107->set_paths(); $e107->set_paths();
$imgpy = str_replace($HANDLERS_DIRECTORY, "", $e107->file_path); $imgpy = str_replace($HANDLERS_DIRECTORY, "", $e107->file_path);
*/
$imgp = dirname(__FILE__);
if (substr($imgp,-1,1) != '/') $imgp .= '/';
if (!isset($HANDLERS_DIRECTORY)) require_once($imgp.'../e107_config.php');
$imgp = str_replace($HANDLERS_DIRECTORY,$IMAGES_DIRECTORY,$imgp);
$imgp = $imgpy.$IMAGES_DIRECTORY;
mt_srand ((double)microtime() * 1000000); mt_srand ((double)microtime() * 1000000);
$maxran = 1000000; $maxran = 1000000;
$rand_num = mt_rand(0, $maxran); $rand_num = mt_rand(0, $maxran);

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/secure_img_render.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/secure_img_render.php,v $
| $Revision: 1.1.1.1 $ | $Revision: 1.2 $
| $Date: 2006-12-02 04:33:57 $ | $Date: 2007-11-05 20:12:28 $
| $Author: mcfly_e107 $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -52,15 +52,18 @@ if($recnum == false){
$mySQLserver = ""; $mySQLserver = "";
@include_once(dirname(__FILE__)."e107_config.php");
$a = 0; $a = 0;
$p = ""; $p = "";
while(!$mySQLserver && $a < 5){ $ifile = dirname(__FILE__);
$a ++; if (substr($ifile,-1,1) != '/') $ifile .= '/';
$p .= "../"; @include_once($ifile."e107_config.php");
@include_once($p."e107_config.php");
while(!$mySQLserver && $a < 5)
{
$a ++;
$p .= "../";
@include_once($ifile.$p.'e107_config.php'); // *** Revised
} }
mysql_connect($mySQLserver, $mySQLuser, $mySQLpassword); mysql_connect($mySQLserver, $mySQLuser, $mySQLpassword);
@@ -94,7 +97,7 @@ if(is_readable($path."secure_image_custom.php")) {
$secureimg['x'] = "6"; $secureimg['x'] = "6";
$secureimg['y'] = "22"; $secureimg['y'] = "22";
$secureimg['font'] = "imagecode.ttf"; $secureimg['font'] = "imagecode.ttf";
$secureimg['color'] = array(90,90,90); // red,green,blue $secureimg['color'] = "90,90,90"; // red,green,blue
*/ */
$bg_file = $secureimg['image']; $bg_file = $secureimg['image'];
@@ -114,10 +117,13 @@ switch($type) {
break; break;
} }
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);
} }