Mirror von
https://git.d3data.de/3rdParty/captcha-module.git
synchronisiert 2024-11-09 16:43:11 +01:00
107 Zeilen
2.7 KiB
PHP
107 Zeilen
2.7 KiB
PHP
<?php
|
|
/**
|
|
* #PHPHEADER_OECAPTCHA_LICENSE_INFORMATION#
|
|
*/
|
|
|
|
// #1428C - spam spider prevention
|
|
if (isset($_GET['e_mac'])) {
|
|
$emac = $_GET['e_mac'];
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
require_once '../../../../../bootstrap.php';
|
|
|
|
if (!function_exists('generateVerificationImg')) {
|
|
|
|
/**
|
|
* Generates image
|
|
*
|
|
* @param string $mac verification code
|
|
*
|
|
* @return null
|
|
*/
|
|
function generateVerificationImg($mac)
|
|
{
|
|
$width = 80;
|
|
$height = 18;
|
|
$fontSize = 14;
|
|
|
|
if (function_exists('imagecreatetruecolor')) {
|
|
// GD2
|
|
$image = imagecreatetruecolor($width, $height);
|
|
} elseif (function_exists('imagecreate')) {
|
|
// GD1
|
|
$image = imagecreate($width, $height);
|
|
} else {
|
|
// GD not found
|
|
return;
|
|
}
|
|
|
|
$textX = ($width - strlen($mac) * imagefontwidth($fontSize)) / 2;
|
|
$textY = ($height - imagefontheight($fontSize)) / 2;
|
|
|
|
$colors = array();
|
|
$colors["text"] = imagecolorallocate($image, 0, 0, 0);
|
|
$colors["shadow1"] = imagecolorallocate($image, 200, 200, 200);
|
|
$colors["shadow2"] = imagecolorallocate($image, 100, 100, 100);
|
|
$colors["background"] = imagecolorallocate($image, 255, 255, 255);
|
|
$colors["border"] = imagecolorallocate($image, 0, 0, 0);
|
|
|
|
imagefill($image, 0, 0, $colors["background"]);
|
|
imagerectangle($image, 0, 0, $width - 1, $height - 1, $colors["border"]);
|
|
imagestring($image, $fontSize, $textX + 1, $textY + 0, $mac, $colors["shadow2"]);
|
|
imagestring($image, $fontSize, $textX + 0, $textY + 1, $mac, $colors["shadow1"]);
|
|
imagestring($image, $fontSize, $textX, $textY, $mac, $colors["text"]);
|
|
|
|
header('Content-type: image/png');
|
|
imagepng($image);
|
|
imagedestroy($image);
|
|
}
|
|
}
|
|
|
|
if (!function_exists('strRem')) {
|
|
|
|
require_once getShopBasePath() . '/core/oxdecryptor.php';
|
|
|
|
/**
|
|
* OXID specific string manipulation method
|
|
*
|
|
* @param string $value string
|
|
*
|
|
* @return string
|
|
*/
|
|
function strRem($value)
|
|
{
|
|
$decryptor = new oxDecryptor;
|
|
|
|
$key = oxRegistry::getConfig()->getConfigParam('oecaptchakey');
|
|
|
|
if (empty($key)) {
|
|
$key = getOxConfKey();
|
|
}
|
|
|
|
return $decryptor->decrypt($value, $key);
|
|
}
|
|
}
|
|
|
|
if (!function_exists('getOxConfKey')) {
|
|
|
|
/**
|
|
* Get default config key.
|
|
*
|
|
* @return string
|
|
*/
|
|
function getOxConfKey()
|
|
{
|
|
$fileName = getShopBasePath() . '/core/oxconfk.php';
|
|
$configFile = new oxConfigFile($fileName);
|
|
|
|
return $configFile->getVar("sConfigKey");
|
|
}
|
|
|
|
}
|
|
|
|
$mac = strRem($emac);
|
|
generateVerificationImg($mac);
|