63 lines
2.3 KiB
PHP
63 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* 2007-2015 PrestaShop
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to the Open Software License (OSL 3.0)
|
|
* that is bundled with this package in the file LICENSE.txt.
|
|
* It is also available through the world-wide-web at this URL:
|
|
* http://opensource.org/licenses/osl-3.0.php
|
|
* If you did not receive a copy of the license and are unable to
|
|
* obtain it through the world-wide-web, please send an email
|
|
* to license@prestashop.com so we can send you a copy immediately.
|
|
*
|
|
* DISCLAIMER
|
|
*
|
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
* versions in the future. If you wish to customize PrestaShop for your
|
|
* needs please refer to http://www.prestashop.com for more information.
|
|
*
|
|
* @author PrestaShop SA <contact@prestashop.com>
|
|
* @copyright 2007-2017 PrestaShop SA
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
|
* @version Release: $Revision$
|
|
* International Registered Trademark & Property of PrestaShop SA
|
|
*/
|
|
|
|
if (!defined('_PS_VERSION_'))
|
|
exit;
|
|
class Ybc_blog_freeCapchaModuleFrontController extends ModuleFrontController
|
|
{
|
|
public function init()
|
|
{
|
|
$this->create_image();
|
|
die;
|
|
}
|
|
public function create_image()
|
|
{
|
|
$md5_hash = md5(rand(0,999));
|
|
$security_code = Tools::substr($md5_hash, 15, 5);
|
|
$context = Context::getContext();
|
|
$context->cookie->security_capcha_code = $security_code;
|
|
$context->cookie->write();
|
|
$width = 100;
|
|
$height = 30;
|
|
$image = ImageCreate($width, $height);
|
|
$black = ImageColorAllocate($image, 0, 0, 0);
|
|
$noise_color = imagecolorallocate($image, 100, 120, 180);
|
|
$background_color = imagecolorallocate($image, 255, 255, 255);
|
|
ImageFill($image,0, 0, $background_color);
|
|
for( $i=0; $i<($width*$height)/3; $i++ ) {
|
|
imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
|
|
}
|
|
for( $i=0; $i<($width*$height)/150; $i++ ) {
|
|
imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
|
|
}
|
|
ImageString($image, 5, 30, 6, $security_code, $black);
|
|
header("Content-Type: image/jpeg");
|
|
ImageJpeg($image);
|
|
ImageDestroy($image);
|
|
exit();
|
|
}
|
|
} |