Пример #1
0
 /**
  * 清空回收站
  */
 public function action_clear()
 {
     $rows = DB::select()->from('imgs')->where('userid', '=', (int) $this->auth['uid'])->where('recycle', '=', 1)->fetch_all();
     if (!empty($rows)) {
         $rows = new Arrayobj($rows);
         foreach ($rows as $row) {
             if ($row->userid == (int) $this->auth['uid']) {
                 // 添加图片到删除缓存表中
                 $url = 'http://' . $row->disk_id . '.wal8.com/';
                 $img_path = $row->disk_name . '/' . $row->picname;
                 $thumb_130 = $this->thumb->create2($img_path, 130, 130);
                 $data = array('img_url' => $url . $thumb_130, 'add_time' => time(), 'uid' => $this->auth['uid']);
                 @unlink(Io::strip(DOCROOT . $thumb_130));
                 $this->squid_img($data);
                 /*$thumb_120 = $thumb->create2($img_path, 120, 120);
                   $data['img_url'] = $url . $thumb_120;
                   $this->squid_img($data);
                   @unlink(Io::strip(DOCROOT.  $thumb_120));*/
                 $thumb_65 = $this->thumb->create2($img_path, 65, 65);
                 $data['img_url'] = $url . $thumb_65;
                 $this->squid_img($data);
                 @unlink(Io::strip(DOCROOT . $thumb_65));
                 $thumb_640 = $this->thumb->create2($img_path, 640, 640, 's');
                 $data['img_url'] = $url . $thumb_640;
                 $this->squid_img($data);
                 @unlink(Io::strip(DOCROOT . $thumb_640));
                 $data['img_url'] = $url . $img_path;
                 $this->squid_img($data);
                 // 删除评论
                 DB::delete('comments')->where('item_id', '=', $row->id)->where('app', '=', 'img')->execute();
                 // 删除图片记录
                 DB::delete('imgs')->where('id', '=', $row->id)->execute();
                 @unlink(Io::strip(DOCROOT . $row->disk_name . '/' . $row->picname));
                 // 删除标签
                 $tag = new tags();
                 $tag->del($row->id, 'app');
             }
         }
     }
     echo 'success';
     //$this->request->redirect('/category/list?recycle=1');
     $this->auto_render = false;
 }