示例#1
0
文件: Feed.php 项目: ttym7993/Linger
 /**
  * @param $list
  * @return array
  */
 private function getServer($list)
 {
     if (count($list) < 1) {
         return [];
     }
     lib()->load('Server');
     $s = new Server();
     $list = $s->get($list);
     $rt = [];
     if (isset($list[0]['name'])) {
         foreach ($list as &$v) {
             $rt[$v['name']] = $v;
         }
     }
     return $rt;
 }
示例#2
0
 public function pic_server_edit()
 {
     $req = req();
     if ($req->is_post()) {
         try {
             lib()->load('Server');
             $server = new Server();
             $server->update($req->post('name'), $req->post('url'), $req->post('meta_key'), $req->post('meta_value'));
             $this->rt_msg['status'] = true;
         } catch (\Exception $ex) {
             $this->rt_msg['code'] = $ex->getCode();
             $this->rt_msg['msg'] = $ex->getMessage();
         }
     } else {
         $this->rt_msg['msg'] = "必须以POST方式提交数据";
     }
 }
示例#3
0
 /**
  * 对图片文件进行处理
  * @param $info
  */
 public function deleteFile($info)
 {
     lib()->load('Server');
     $server = new Server();
     $meta = $server->get($info['server_name'])[0]['meta'];
     if (isset($meta['_Lib'])) {
         switch ($meta['_Lib']) {
             case "Local":
                 lib()->load('FileAction');
                 $fa = new FileAction($meta);
                 $fa->delete($info['pic_path'], $info['pic_thumbnails_path'], $info['pic_hd_path'], $info['pic_display_path']);
                 break;
             case 'Qiniu':
                 c_lib()->load('upLoad/Qiniu');
                 $qiniu = new Upload\Qiniu("", $meta);
                 $path = $info['pic_path'];
                 $status = $qiniu->qiniu->del($path);
                 if ($status === false) {
                     Log::write("{$info['server_name']} Delete error:" . $path, Log::NOTICE);
                 }
                 $thumb = $info['pic_thumbnails_path'];
                 if (false !== strpos($thumb, '/')) {
                     $status = $qiniu->qiniu->del($thumb);
                     if ($status === false) {
                         Log::write("{$info['server_name']} Delete error:" . $thumb, Log::NOTICE);
                     }
                 }
                 $hd = $info['pic_hd_path'];
                 if (false !== strpos($hd, '/')) {
                     $status = $qiniu->qiniu->del($hd);
                     if ($status === false) {
                         Log::write("{$info['server_name']} Delete error:" . $hd, Log::NOTICE);
                     }
                 }
                 $dis = $info['pic_display_path'];
                 if (false !== strpos($dis, '/')) {
                     $status = $qiniu->qiniu->del($dis);
                     if ($status === false) {
                         Log::write("{$info['server_name']} Delete error:" . $dis, Log::NOTICE);
                     }
                 }
                 break;
             default:
                 Log::write("Now File Lib not found.Please check {$info['server_name']} and {$info['pic_path']}");
         }
     } else {
         Log::write("Now File Lib not set.Please check {$info['server_name']} and {$info['pic_path']}");
     }
 }
示例#4
0
 public function pic_server_edit($name = NULL)
 {
     lib()->load('Server');
     $server = new Server();
     $table = $server->get($name);
     $table = count($table) == 1 ? $table[0] : false;
     $this->__view("Control/pic_server_edit.php", ['list' => $table]);
 }
示例#5
0
 /**
  * 图片上传
  */
 public function picture_upload()
 {
     try {
         $this->ajax = true;
         $req = req()->_plain();
         $this->throwMsgCheck('is_post', 'is_login', 'is_active');
         $this->__lib('Picture', 'Server');
         $pic = new Picture();
         $server = new Server();
         $this->rt_msg['content'] = $pic->add($req->post('name'), $req->post('tag'), $req->post('desc'), @$_FILES['files'], $server->getNowServer(), login_user());
         $this->rt_msg['status'] = count($this->rt_msg['content']['list']) > 0;
         if ($this->rt_msg['status'] && $req->post('get_msg') == 1) {
             $this->rt_msg['content']['msg'] = $pic->get(join(',', $this->rt_msg['content']['list']), login_user()->getId());
         }
     } catch (\Exception $ex) {
         $this->rt_msg['msg'] = $ex->getMessage();
         $this->rt_msg['code'] = $ex->getCode();
     }
 }