-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d653039
commit d79497d
Showing
2 changed files
with
31 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,33 @@ | |
*/ | ||
class Result | ||
{ | ||
private $CaptchaByte; // 验证码图片 | ||
private $CaptchaMime; // 验证码类型 | ||
private $CaptchaCode; // 验证码内容 | ||
private $CaptchaFile; // 验证码文件 | ||
private $captchaByte; // 验证码图片 | ||
private $captchaMime; // 验证码类型 | ||
private $captchaCode; // 验证码内容 | ||
private $createTime; | ||
|
||
function __construct($Byte, $Code, $Mime,$File) | ||
function __construct($Byte, $Code, $Mime) | ||
{ | ||
$this->CaptchaByte = $Byte; | ||
$this->CaptchaMime = $Mime; | ||
$this->CaptchaCode = $Code; | ||
$this->CaptchaFile = $File; | ||
$this->captchaByte = $Byte; | ||
$this->captchaMime = $Mime; | ||
$this->captchaCode = $Code; | ||
$this->createTime = time(); | ||
} | ||
|
||
function getCreateTime():int | ||
{ | ||
return $this->createTime; | ||
} | ||
|
||
function getCodeHash($code = null,$time = null) | ||
{ | ||
if(!$code){ | ||
$code = $this->captchaCode; | ||
} | ||
if(!$time){ | ||
$time = $this->createTime; | ||
} | ||
return substr(md5($code.$time),8,16); | ||
} | ||
|
||
/** | ||
|
@@ -37,7 +53,7 @@ function __construct($Byte, $Code, $Mime,$File) | |
*/ | ||
function getImageByte() | ||
{ | ||
return $this->CaptchaByte; | ||
return $this->captchaByte; | ||
} | ||
|
||
/** | ||
|
@@ -47,8 +63,8 @@ function getImageByte() | |
*/ | ||
function getImageBase64() | ||
{ | ||
$base64Data = base64_encode($this->CaptchaByte); | ||
$Mime = $this->CaptchaMime; | ||
$base64Data = base64_encode($this->captchaByte); | ||
$Mime = $this->captchaMime; | ||
return "data:{$Mime};base64,{$base64Data}"; | ||
} | ||
|
||
|
@@ -59,7 +75,7 @@ function getImageBase64() | |
*/ | ||
function getImageCode() | ||
{ | ||
return $this->CaptchaCode; | ||
return $this->captchaCode; | ||
} | ||
|
||
/** | ||
|
@@ -68,18 +84,6 @@ function getImageCode() | |
*/ | ||
function getImageMime() | ||
{ | ||
return $this->CaptchaMime; | ||
} | ||
|
||
/** | ||
* 获取验证码文件路径 | ||
* @author: eValor < [email protected] > | ||
*/ | ||
function getImageFile() | ||
{ | ||
if(!file_exists($this->CaptchaFile)){ | ||
file_put_contents($this->CaptchaFile, $this->CaptchaByte); | ||
} | ||
return $this->CaptchaFile; | ||
return $this->captchaMime; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters