[phpbbreloaded-checkins] SF.net SVN: phpbbreloaded: [231] phpBB Reloaded 2/includes
Status: Planning
Brought to you by:
tehphpmaster
From: <mar...@us...> - 2006-06-20 16:31:45
|
Revision: 231 Author: markthedaemon Date: 2006-06-20 09:31:38 -0700 (Tue, 20 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpbbreloaded/?rev=231&view=rev Log Message: ----------- made teh CAPTCHA work again :D Modified Paths: -------------- phpBB Reloaded 2/includes/usercp_confirm.php phpBB Reloaded 2/includes/usercp_register.php Modified: phpBB Reloaded 2/includes/usercp_confirm.php =================================================================== --- phpBB Reloaded 2/includes/usercp_confirm.php 2006-06-19 23:27:34 UTC (rev 230) +++ phpBB Reloaded 2/includes/usercp_confirm.php 2006-06-20 16:31:38 UTC (rev 231) @@ -66,89 +66,98 @@ exit; } -// We can we will generate a single filtered png -// Thanks to DavidMJ for emulating zlib within the code :) -$_png = define_filtered_pngs(); +// If we can we will generate a single filtered png else we will have to simply +// output six seperate original pngs ... first way is preferable! +if (@extension_loaded('gd') || @extension_loaded('gd2')) +{ + require($root_path . "includes/functions_freecap.$phpEx"); -$total_width = 320; -$total_height = 50; -$img_height = 40; -$img_width = 0; -$l = 0; + // output final image :-) + sendImage($im); + // (sendImage also destroys all used images) +} +elseif (@extension_loaded('zlib')) +{ + $_png = define_filtered_pngs(); -list($usec, $sec) = explode(' ', microtime()); -mt_srand($sec * $usec); + $total_width = 320; + $total_height = 50; + $img_height = 40; + $img_width = 0; + $l = 0; -$char_widths = array(); -for ($i = 0; $i < strlen($code); $i++) -{ - $char = $code{$i}; + list($usec, $sec) = explode(' ', microtime()); + mt_srand($sec * $usec); - $width = mt_rand(0, 4); - $char_widths[] = $width; - $img_width += $_png[$char]['width'] - $width; -} + $char_widths = array(); + for ($i = 0; $i < strlen($code); $i++) + { + $char = $code{$i}; -$offset_x = mt_rand(0, $total_width - $img_width); -$offset_y = mt_rand(0, $total_height - $img_height); + $width = mt_rand(0, 4); + $char_widths[] = $width; + $img_width += $_png[$char]['width'] - $width; + } -$image = ''; -$hold_chars = array(); -for ($i = 0; $i < $total_height; $i++) -{ - $image .= chr(0); + $offset_x = mt_rand(0, $total_width - $img_width); + $offset_y = mt_rand(0, $total_height - $img_height); - if ($i > $offset_y && $i < $offset_y + $img_height) + $image = ''; + $hold_chars = array(); + for ($i = 0; $i < $total_height; $i++) { - $j = 0; + $image .= chr(0); - for ($k = 0; $k < $offset_x; $k++) + if ($i > $offset_y && $i < $offset_y + $img_height) { - $image .= chr(mt_rand(140, 255)); - } + $j = 0; - for ($k = 0; $k < strlen($code); $k++) - { - $char = $code{$k}; + for ($k = 0; $k < $offset_x; $k++) + { + $image .= chr(mt_rand(140, 255)); + } - if (empty($hold_chars[$char])) + for ($k = 0; $k < strlen($code); $k++) { - $hold_chars[$char] = explode("\n", chunk_split(base64_decode($_png[$char]['data']), $_png[$char]['width'] + 1, "\n")); + $char = $code{$k}; + + if (empty($hold_chars[$char])) + { + $hold_chars[$char] = explode("\n", chunk_split(base64_decode($_png[$char]['data']), $_png[$char]['width'] + 1, "\n")); + } + $image .= randomise(substr($hold_chars[$char][$l], 1), $char_widths[$j]); + $j++; } - $image .= randomise(substr($hold_chars[$char][$l], 1), $char_widths[$j]); - $j++; - } - for ($k = $offset_x + $img_width; $k < $total_width; $k++) + for ($k = $offset_x + $img_width; $k < $total_width; $k++) + { + $image .= chr(mt_rand(140, 255)); + } + + $l++; + } + else { - $image .= chr(mt_rand(140, 255)); + for ($k = 0; $k < $total_width; $k++) + { + $image .= chr(mt_rand(140, 255)); + } } - $l++; } - else - { - for ($k = 0; $k < $total_width; $k++) - { - $image .= chr(mt_rand(140, 255)); - } - } + unset($hold); -} -unset($hold); + $image = create_png(gzcompress($image), $total_width, $total_height); -$image = create_png($image, $total_width, $total_height); + // Output image + header('Content-Type: image/png'); + header('Cache-control: no-cache, no-store'); + echo $image; -// Output image -header('Content-Type: image/png'); -header('Cache-control: no-cache, no-store'); -echo $image; + unset($image); + unset($_png); + exit; -unset($image); -unset($_png); -exit; - - } else { @@ -212,7 +221,7 @@ // http://www.libpng.org/pub/png/spec/PNG-Contents.html we use // png because it's a fully recognised open standard and supported // by practically all modern browsers and OSs -function create_png($raw_image, $width, $height) +function create_png($gzimage, $width, $height) { // SIG $image = pack('C8', 137, 80, 78, 71, 13, 10, 26, 10); @@ -221,53 +230,8 @@ $raw .= pack('C4', $height >> 24, $height >> 16, $height >> 8, $height); $raw .= pack('C5', 8, 0, 0, 0, 0); $image .= png_chunk(13, 'IHDR', $raw); - if (@extension_loaded('zlib')) - { - $raw_image = gzcompress($raw_image); - $length = strlen($raw_image); - } - else - { - // The total length of this image, uncompressed, is just a calculation of pixels - $length = ($width + 1) * $height; - - // Adler-32 hash generation - // Optimized Adler-32 loop ported from the GNU Classpath project - $temp_length = $length; - $s1 = 1; - $s2 = $index = 0; - - while ($temp_length > 0) - { - // We can defer the modulo operation: - // s1 maximally grows from 65521 to 65521 + 255 * 3800 - // s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31 - $substract_value = ($temp_length < 3800) ? $temp_length : 3800; - $temp_length -= $substract_value; - - while (--$substract_value >= 0) - { - $s1 += ord($raw_image[$index]); - $s2 += $s1; - - $index++; - } - - $s1 %= 65521; - $s2 %= 65521; - } - $adler_hash = pack('N', ($s2 << 16) | $s1); - - // This is the same thing as gzcompress($raw_image, 0) but does not need zlib - $raw_image = pack('C3v2', 0x78, 0x01, 0x01, $length, ~$length) . $raw_image . $adler_hash; - - // The Zlib header + Adler hash make us add on 11 - $length += 11; - } - // IDAT - $image .= png_chunk($length, 'IDAT', $raw_image); - + $image .= png_chunk(strlen($gzimage), 'IDAT', $gzimage); // IEND $image .= png_chunk(0, 'IEND', ''); Modified: phpBB Reloaded 2/includes/usercp_register.php =================================================================== --- phpBB Reloaded 2/includes/usercp_register.php 2006-06-19 23:27:34 UTC (rev 230) +++ phpBB Reloaded 2/includes/usercp_register.php 2006-06-20 16:31:38 UTC (rev 231) @@ -319,13 +319,9 @@ if ($row = $db->sql_fetchrow($result)) { -// ---[ mod : FreeCap Visual Confirmation ]---------------------------------------- -// here we replace -// if ($row['code'] != $confirm_code) -//with - if (@extension_loaded('gd') || @extension_loaded('gd2')) +if (@extension_loaded('gd') || @extension_loaded('gd2')) { - $logic = 'return strtolower($row[\'code\'])) != strtolower($confirm_code);'; + $logic = 'return strtolower($row[\'code\']) != strtolower($confirm_code);'; } else { @@ -333,7 +329,7 @@ } if (eval($logic)) -// ---[ fin mod ]---------------------------------------- + { $error = TRUE; $error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Confirm_code_wrong']; @@ -1157,7 +1153,8 @@ */ //-- add // fix a typo - $code = strtoupper(str_replace('0', 'o', substr($code, 2, 6))); + $code = strtoupper(str_replace('0', 'o', substr($code, 6))); + //-- fin mod : categories hierarchy -------------------------------------------- $code = strtolower(preg_replace('#(\d)#e', 'chr($1 + 96)', $code)); @@ -1172,12 +1169,10 @@ unset($code); -// ---[ mod : FreeCap Visual Confirmation ]---------------------------------------- -// here we replace -// $confirm_image = (@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=6") . '" alt="" title="" />'; -// with - $confirm_image = (@extension_loaded('gd') || @extension_loaded('gd2')) ? "<img src=\"" . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : ((@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=6") . '" alt="" title="" />'); -// ---[ fin mod ]---------------------------------------- +$confirm_image = (@extension_loaded('zlib')) ? '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id") . '" alt="" title="" />' : '<img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=1") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=2") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=3") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=4") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=5") . '" alt="" title="" /><img src="' . append_sid("profile.$phpEx?mode=confirm&id=$confirm_id&c=6") . '" alt="" title="" />'; + + + // ---[ fin mod ]---------------------------------------- $s_hidden_fields .= '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />'; $template->assign_block_vars('switch_confirm', array()); @@ -1354,8 +1349,9 @@ } } } -} + } + $template->pparse('body'); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |