/
checkcode.class.php
34 lines (29 loc) · 1.09 KB
/
checkcode.class.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
<?php
class CheckCode {
private $codeLenth = 4;
private $tempFile = "./image/temp.jpg";
private $dataPath = "./image/data/";
private $checkCode = "";
public function discernCheckCode() {
$fileArray = File::getFileName($this->dataPath);
$main = new MyMain();
$im = $main->getCheckCode();
$imageArray = $main->getImageArray($im);
YImageTool::save($im, $this->tempFile);
for ($index = 0; $index < $this->codeLenth; $index++) {
$image = new YImage($imageArray[$index]);
$image->quzhao();
$image = $image->getDataAray();
foreach ($fileArray as $value) {
$im = imagecreatefromjpeg($this->dataPath . "" . $value . ".jpg");
$tagImage = new YImage($im);
$tagImage->quzhao();
if ($tagImage->compare($image)) {
$this->checkCode = $this->checkCode . substr_replace($value, '', 1);
break;
}
}
}
return $this->checkCode;
}
}