/
verificationimg.php
138 lines (117 loc) · 3.64 KB
/
verificationimg.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* This file is part of OXID eShop Community Edition.
*
* OXID eShop Community Edition is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OXID eShop Community Edition is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OXID eShop Community Edition. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://www.oxid-esales.com
* @copyright (C) OXID eSales AG 2003-2016
* @version OXID eShop CE
*/
// #1428C - spam spider prevention
if (isset($_GET['e_mac'])) {
$sEMac = $_GET['e_mac'];
} else {
return;
}
require_once '../../bootstrap.php';
if (!function_exists('generateVerificationImg')) {
/**
* Generates image
*
* @param string $sMac verification code
*
* @return null
*/
function generateVerificationImg($sMac)
{
$iWidth = 80;
$iHeight = 18;
$iFontSize = 14;
if (function_exists('imagecreatetruecolor')) {
// GD2
$oImage = imagecreatetruecolor($iWidth, $iHeight);
} elseif (function_exists('imagecreate')) {
// GD1
$oImage = imagecreate($iWidth, $iHeight);
} else {
// GD not found
return;
}
$iTextX = ($iWidth - strlen($sMac) * imagefontwidth($iFontSize)) / 2;
$iTextY = ($iHeight - imagefontheight($iFontSize)) / 2;
$aColors = array();
$aColors["text"] = imagecolorallocate($oImage, 0, 0, 0);
$aColors["shadow1"] = imagecolorallocate($oImage, 200, 200, 200);
$aColors["shadow2"] = imagecolorallocate($oImage, 100, 100, 100);
$aColors["background"] = imagecolorallocate($oImage, 255, 255, 255);
$aColors["border"] = imagecolorallocate($oImage, 0, 0, 0);
imagefill($oImage, 0, 0, $aColors["background"]);
imagerectangle($oImage, 0, 0, $iWidth - 1, $iHeight - 1, $aColors["border"]);
imagestring($oImage, $iFontSize, $iTextX + 1, $iTextY + 0, $sMac, $aColors["shadow2"]);
imagestring($oImage, $iFontSize, $iTextX + 0, $iTextY + 1, $sMac, $aColors["shadow1"]);
imagestring($oImage, $iFontSize, $iTextX, $iTextY, $sMac, $aColors["text"]);
header('Content-type: image/png');
imagepng($oImage);
imagedestroy($oImage);
}
}
if (!function_exists('strRem')) {
require_once '../oxdecryptor.php';
/**
* OXID specific string manipulation method
*
* @param string $sVal string
*
* @return string
*/
function strRem($sVal)
{
$oDecryptor = new oxDecryptor;
$sKey = oxRegistry::getConfig()->getConfigParam('captchaKey');
if (empty($sKey)) {
$oCfg = new oxConfKey();
$sKey = $oCfg->sConfigKey;
}
return $oDecryptor->decrypt($sVal, $sKey);
}
}
/**
* Simple class returning config key.
*/
class oxConfKey
{
/**
* @var $sConfigKey string
*/
public $sConfigKey;
/**
* Config class constructor.
*/
public function __construct()
{
include_once '../oxconfk.php';
}
/**
* Config key getter.
*
* @return string
*/
public function get()
{
return $this->sConfigKey;
}
}
$sMac = strRem($sEMac);
generateVerificationImg($sMac);