public function verify()
 {
     $type = isset($_GET['type']) ? $_GET['type'] : 'gif';
     Image::buildImageVerify(4, 1, $type);
 }
예제 #2
0
 public function verify()
 {
     $type = I('type', 'gif');
     Image::buildImageVerify(4, 1, $type);
 }
예제 #3
0
 /**
  * 显示登录页面的验证码图片
  */
 function verify()
 {
     Image::buildImageVerify(4, 1, 'png', 48, 22, 'ADMIN_VRERIFY');
 }
예제 #4
0
 public function verify()
 {
     import("ORG.Util.Image");
     \Org\Util\Image::buildImageVerify();
 }
예제 #5
0
 /**
 +----------------------------------------------------------
 * 上传一个文件
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param mixed $name 数据
 * @param string $value  数据表名
 +----------------------------------------------------------
 * @return string
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 private function save($file)
 {
     //         $filename = C('WEB_ROOT').$file['savepath'].$file['savename'];
     $filename = $file['savepath'] . $file['savename'];
     if (!$this->uploadReplace && is_file($filename)) {
         // 不覆盖同名文件
         $this->error = '文件已经存在!' . $filename;
         return false;
     }
     // 如果是图像文件 检测文件格式
     if (in_array(strtolower($file['extension']), array('gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf')) && false === getimagesize($file['tmp_name'])) {
         $this->error = '非法图像文件';
         return false;
     }
     if (!move_uploaded_file($file['tmp_name'], $this->autoCharset($filename, 'utf-8', 'gbk'))) {
         $this->error = '文件上传保存错误!';
         return false;
     }
     if ($this->thumb && in_array(strtolower($file['extension']), array('gif', 'jpg', 'jpeg', 'bmp', 'png'))) {
         $image = getimagesize($filename);
         if (false !== $image) {
             //是图像文件生成缩略图
             $thumbWidth = explode(',', $this->thumbMaxWidth);
             $thumbHeight = explode(',', $this->thumbMaxHeight);
             $thumbPrefix = explode(',', $this->thumbPrefix);
             $thumbSuffix = explode(',', $this->thumbSuffix);
             $thumbFile = explode(',', $this->thumbFile);
             $thumbPath = $this->thumbPath ? $this->thumbPath : $file['savepath'];
             // 生成图像缩略图
             import($this->imageClassPath);
             $realFilename = $this->autoSub ? basename($file['savename']) : $file['savename'];
             for ($i = 0, $len = count($thumbWidth); $i < $len; $i++) {
                 $thumbname = $thumbPath . $thumbPrefix[$i] . substr($realFilename, 0, strrpos($realFilename, '.')) . $thumbSuffix[$i] . '.' . $file['extension'];
                 \Org\Util\Image::thumb($filename, $thumbname, '', $thumbWidth[$i], $thumbHeight[$i], true);
             }
             if ($this->thumbRemoveOrigin) {
                 // 生成缩略图之后删除原图
                 unlink($filename);
             }
         }
     }
     if ($this->zipImags) {
         // TODO 对图片压缩包在线解压
     }
     return true;
 }
예제 #6
0
 /**
  * 上传一个文件
  * @access public
  * @param mixed $name 数据
  * @param string $value  数据表名
  * @return string
  */
 private function save($file)
 {
     $filename = $file['savepath'] . $file['savename'];
     // 如果是图像文件 检测文件格式
     if (in_array(strtolower($file['extension']), array('gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf'))) {
         $info = getimagesize($file['tmp_name']);
         if (false === $info || 'gif' == strtolower($file['extension']) && empty($info['bits'])) {
             $this->error = '非法图像文件';
             return false;
         }
     }
     //FTP上传
     /*
     $config = CP('center_upfile');
     if($config['isRemote']){  //上传到远程服务器
         $ftpConfig = CP('center_upfile','remoteFtp');
         $ftpConfig = str_replace(',', ',', $ftpConfig);
         $ftpConfigArr = explode(',', $ftpConfig);
         if($ftpConfigArr[4]){
             $ftp_connection = ftp_connect($ftpConfigArr[0],$ftpConfigArr[1],$ftpConfigArr[4]);
         }else{
             $ftp_connection = ftp_connect($ftpConfigArr[0],$ftpConfigArr[1]);
         }
     
         $login = ftp_login($ftp_connection, $ftpConfigArr[2], $ftpConfigArr[3]);
         $dirfile = explode('/', $file['savename']);
         $mkdir = ftp_mkdir($ftp_connection,$dirfile[0]);
         $chdir = ftp_chdir($ftp_connection,$dirfile[0]);
         $r = ftp_put($ftp_connection,$dirfile[1], $file['tmp_name'], FTP_BINARY);
         if(!$r){
             $this->error	=	'文件上传到FTP服务器失败!';
             return false;
         }
         ftp_close($ftp_connection);
         return true;
     }
     */
     if (!$this->uploadReplace && is_file($filename)) {
         // 不覆盖同名文件
         $this->error = '文件已经存在!' . $filename;
         return false;
     }
     if (!move_uploaded_file($file['tmp_name'], $this->autoCharset($filename, 'utf-8', 'gbk'))) {
         $this->error = '文件上传保存错误!';
         return false;
     }
     if ($this->thumb && in_array(strtolower($file['extension']), array('gif', 'jpg', 'jpeg', 'bmp', 'png'))) {
         $image = getimagesize($filename);
         if (false !== $image) {
             //是图像文件生成缩略图
             $thumbWidth = explode(',', $this->thumbMaxWidth);
             $thumbHeight = explode(',', $this->thumbMaxHeight);
             $thumbPrefix = explode(',', $this->thumbPrefix);
             $thumbSuffix = explode(',', $this->thumbSuffix);
             $thumbFile = explode(',', $this->thumbFile);
             $thumbPath = $this->thumbPath ? $this->thumbPath : dirname($filename) . '/';
             $thumbExt = $this->thumbExt ? $this->thumbExt : $file['extension'];
             //自定义缩略图扩展名
             // 生成图像缩略图
             import($this->imageClassPath);
             for ($i = 0, $len = count($thumbWidth); $i < $len; $i++) {
                 if (!empty($thumbFile[$i])) {
                     $thumbname = $thumbFile[$i];
                 } else {
                     $prefix = isset($thumbPrefix[$i]) ? $thumbPrefix[$i] : $thumbPrefix[0];
                     $suffix = isset($thumbSuffix[$i]) ? $thumbSuffix[$i] : $thumbSuffix[0];
                     $thumbname = $prefix . basename($filename, '.' . $file['extension']) . $suffix;
                 }
                 if (1 == $this->thumbType) {
                     \Org\Util\Image::thumb2($filename, $thumbPath . $thumbname . '.' . $thumbExt, '', $thumbWidth[$i], $thumbHeight[$i], true);
                 } else {
                     \Org\Util\Image::thumb($filename, $thumbPath . $thumbname . '.' . $thumbExt, '', $thumbWidth[$i], $thumbHeight[$i], true);
                 }
             }
             if ($this->thumbRemoveOrigin) {
                 // 生成缩略图之后删除原图
                 unlink($filename);
             }
         }
     }
     if ($this->zipImags) {
         // TODO 对图片压缩包在线解压
     }
     return true;
 }
예제 #7
0
 /**
  * 显示登录页面的验证码图片
  */
 function verify()
 {
     Image::buildImageVerify(4, 1, 'png', 48, 22, 'CONTROL_VRERIFY');
 }