Beispiel #1
0
 public function actionIndex()
 {
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $pagesize = 10;
     $query = Doubanmz::find();
     $total_count = $query->count();
     $total_page = ceil($total_count / $pagesize);
     $offset = ($p - 1) * $pagesize;
     $mz_list = $query->orderBy("id desc")->offset($offset)->limit($pagesize)->all();
     $data = [];
     if ($mz_list) {
         foreach ($mz_list as $_mz_info) {
             $data[] = ["id" => $_mz_info["id"], "title" => DataHelper::encode($_mz_info["title"]), "src_url" => $_mz_info['src_url']];
         }
     }
     $has_pre = $has_next = false;
     if (count($data) >= $pagesize && $p <= $total_page) {
         $has_next = true;
     }
     if ($p > 1) {
         $has_pre = true;
     }
     $this->setTitle("美女也耍流氓 -- 一睹眼福");
     $this->setSubTitle("美女耍流氓");
     return $this->render("index", ["list" => $data, "p" => $p, "urls" => ["has_pre" => $has_pre, "has_next" => $has_next]]);
 }
Beispiel #2
0
 public static function add($title, $url)
 {
     $hash_key = md5($url);
     $has_in = Doubanmz::findOne(['hash_key' => $hash_key]);
     if ($has_in) {
         return true;
     }
     //$tmp_ret = UploadService::uploadByUrl($url,"","pic2");
     $tmp_ret = '';
     $model_doubanmz = new Doubanmz();
     $model_doubanmz->hash_key = $hash_key;
     $model_doubanmz->title = $title;
     $model_doubanmz->src_url = $url;
     $model_doubanmz->image_url = $tmp_ret ? $tmp_ret['uri'] : '';
     $model_doubanmz->status = 1;
     $model_doubanmz->created_time = date("Y-m-d H:i:s");
     $model_doubanmz->save(0);
     return true;
 }
Beispiel #3
0
 public function actionMz()
 {
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $pagesize = 20;
     $query = Doubanmz::find();
     $total_count = $query->count();
     $offset = ($p - 1) * $pagesize;
     $mz_list = $query->orderBy("id desc")->offset($offset)->limit($pagesize)->all();
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $pagesize, "page" => $p, "display" => 10]);
     $data = [];
     if ($mz_list) {
         foreach ($mz_list as $_mz_info) {
             $data[] = ["id" => $_mz_info["id"], "title" => mb_substr(DataHelper::encode($_mz_info["title"]), 0, 10, "utf-8"), "src_url" => $_mz_info['src_url']];
         }
     }
     return $this->render("mz", ["mz_list" => $data, "page_info" => $page_info, "page_url" => "/douban/mz"]);
 }