发现部分空间是可以部分空间不可以,报下面的错误{ResponseInfo:com.qiniu.http.Response@74d25d10,status:631, reqId:OUgAAEnJhJQ3MY4U, xlog:CFGG:3/612;ZONEPROXY:12/631, xvia:, adress:rsf.qbox.me/183.136.139.24:80, duration:0.000000 s, error:no such bucket}
学习是最好的投资!
<?php
/**
* Verification code category
*/
$code= new Code();
$code->outImage();
class Code
{
protected $number;
protected $codeType;
protected $width;
protected $height;
protected $image;
protected $code;
public function __construct($number=4,$codeType=2,$width=100,$height=30)
$this->number=$number;
$this->codeType=$codeType;
$this->width=$width;
$this->height=$height;
$this->code=$this->createCode();
}
public function __get($name){
if ($name=='code') {
return $this->code;
}else{
return false;
public function __destruct(){
imagedestroy($this->image);
protected function createCode(){
switch ($this->codeType) {
case '0':
$code=$this->getNumberCode();
break;
case '1':
$code=$this->getCharCode();
case '2':
$code=$this->getNumberCharCode();
default:
die("对不起,不支持该验证码类型!!!");
return $code;
protected function getNumberCode(){
$str=join('',range(0, 9));
return substr(str_shuffle($str), 0,$this->number);
protected function getCharCode(){
$str=join('',range(a, z));
$str=$str.strtoupper($str);
protected function getNumberCharCode(){
$str1=join('',range(0, 9));
$str=$str1.$str.strtoupper($str);
public function outImage(){
$this->createImage();
$this->fillBack();
$this->drawChar();
$this->drawDistrub();
$this->show();
protected function createImage(){
$this->image=imagecreatetruecolor($this->width, $this->height);
protected function fillBack(){
imagefill($this->image, 0, 0, $this->lightColor());
protected function lightColor(){
return imagecolorallocate($this->image, mt_rand(130,255), mt_rand(130,255), mt_rand(130,255));
protected function darkColor(){
return imagecolorallocate($this->image, mt_rand(0,120), mt_rand(0,120), mt_rand(0,120));
protected function drawChar(){
for ($i=0; $i <$this->number; $i++) {
$Width=$this->width/$this->number;
$x=mt_rand($i*$Width+10,($i+1)*$Width-15);
$y=mt_rand(0,$this->height-18);
imagechar($this->image, 6, $x, $y, $this->code[$i], $this->darkColor());
protected function drawDistrub(){
for ($i=0; $i < 300; $i++) {
$x=mt_rand(0,$this->width);
$y=mt_rand(0,$this->height);
imagesetpixel($this->image, $x, $y, $this->lightColor());
protected function show(){
header("Content-Type:image/png");
imagepng($this->image);
?>
<?php
/**
* Verification code category
*/
$code= new Code();
$code->outImage();
class Code
{
protected $number;
protected $codeType;
protected $width;
protected $height;
protected $image;
protected $code;
public function __construct($number=4,$codeType=2,$width=100,$height=30)
{
$this->number=$number;
$this->codeType=$codeType;
$this->width=$width;
$this->height=$height;
$this->code=$this->createCode();
}
public function __get($name){
if ($name=='code') {
return $this->code;
}else{
return false;
}
}
public function __destruct(){
imagedestroy($this->image);
}
protected function createCode(){
switch ($this->codeType) {
case '0':
$code=$this->getNumberCode();
break;
case '1':
$code=$this->getCharCode();
break;
case '2':
$code=$this->getNumberCharCode();
break;
default:
die("对不起,不支持该验证码类型!!!");
}
return $code;
}
protected function getNumberCode(){
$str=join('',range(0, 9));
return substr(str_shuffle($str), 0,$this->number);
}
protected function getCharCode(){
$str=join('',range(a, z));
$str=$str.strtoupper($str);
return substr(str_shuffle($str), 0,$this->number);
}
protected function getNumberCharCode(){
$str1=join('',range(0, 9));
$str=join('',range(a, z));
$str=$str1.$str.strtoupper($str);
return substr(str_shuffle($str), 0,$this->number);
}
public function outImage(){
$this->createImage();
$this->fillBack();
$this->drawChar();
$this->drawDistrub();
$this->show();
}
protected function createImage(){
$this->image=imagecreatetruecolor($this->width, $this->height);
}
protected function fillBack(){
imagefill($this->image, 0, 0, $this->lightColor());
}
protected function lightColor(){
return imagecolorallocate($this->image, mt_rand(130,255), mt_rand(130,255), mt_rand(130,255));
}
protected function darkColor(){
return imagecolorallocate($this->image, mt_rand(0,120), mt_rand(0,120), mt_rand(0,120));
}
protected function drawChar(){
for ($i=0; $i <$this->number; $i++) {
$Width=$this->width/$this->number;
$x=mt_rand($i*$Width+10,($i+1)*$Width-15);
$y=mt_rand(0,$this->height-18);
imagechar($this->image, 6, $x, $y, $this->code[$i], $this->darkColor());
}
}
protected function drawDistrub(){
for ($i=0; $i < 300; $i++) {
$x=mt_rand(0,$this->width);
$y=mt_rand(0,$this->height);
imagesetpixel($this->image, $x, $y, $this->lightColor());
}
}
protected function show(){
header("Content-Type:image/png");
imagepng($this->image);
}
}
?>