Ejemplo n.º 1
0
 public function preform()
 {
     $DaoArticle = new DaoArticle();
     $result = $DaoArticle->getArticleByFenlei($this->result['params']['safe']['fenleiId'] ? $this->result['params']['safe']['fenleiId'] : 1);
     $pageInfo = Tools::_pageInfo($this->params['safe']['page'], count($result), $limit = 5);
     if (is_array($result)) {
         $result = array_slice($result, $pageInfo['start'], $pageInfo['limit']);
         //10
     }
     if (empty($result)) {
         $this->result['data']['list'] = array('code' => 0);
     } else {
         $this->result['data']['list'] = $result;
         $this->result['pageInfo'] = $pageInfo;
     }
 }
Ejemplo n.º 2
0
 public function preform()
 {
     $DaoBlog = new DaoArticle();
     $list = $DaoBlog->getBlogList();
     $pageInfo = Tools::_pageInfo($this->params['safe']['page'], count($list), $limit = 10);
     //=============
     if (is_array($list)) {
         $list = array_slice($list, $pageInfo['start'], $pageInfo['limit']);
         //10
     }
     $DaoUser = new DaoUser();
     $hot_user = $DaoUser->getUser();
     $this->result['hot_user'] = $hot_user;
     $this->result['data']['list'] = $list;
     $this->result['pageInfo'] = $pageInfo;
 }
Ejemplo n.º 3
0
 public function preform()
 {
     $aid = $this->result['params']['safe']['articleid'];
     $DaoArticle = new DaoArticle();
     $info = $DaoArticle->getArticleInfoById($aid);
     $DaoReply = new DaoReply();
     $replyList = $DaoReply->selectReplyByArticleId($aid);
     if (!empty($info)) {
         $arr = array('`link`' => $info[0]['link'] + 1);
         $where = array('id' => $aid);
         $DaoArticle->updateArticle($arr, $where);
     }
     if (!empty($info) && !empty($replyList)) {
         $this->result['info']['article'] = $info;
         $this->result['info']['reply'] = $replyList;
     }
 }
Ejemplo n.º 4
0
 public function preform()
 {
     //        echo "WebSiteSittingModel.class.php";
     $DaoArticle = new DaoArticle();
     $result = $DaoArticle->getArticleByUser();
     $ret = $DaoArticle->getBlogList();
     $DaoUser = new DaoUser();
     $limit = 7;
     $pageInfo = Tools::_pageInfo($this->params['safe']['page'], count($result), $limit);
     if (is_array($result)) {
         $result = array_slice($result, $pageInfo['start'], $pageInfo['limit']);
         //10
     }
     //print_r($ret);
     $this->result['data']['list'] = $result;
     $DaoArticle->getArticleCount() / $limit > 1 ? $this->result['count'] = 1 : ($this->result['count'] = $DaoArticle->getArticleCount() / $limit);
     $this->result['page'] = $this->params['safe']['page'];
 }
Ejemplo n.º 5
0
 public function preform()
 {
     $uploadFile = new FileUpload();
     $uploadFile->set("maxsize", 2000000);
     $uploadFile->set("allowtype", array("gif", "png", "jpg", "jpeg"));
     $uploadFile->set("israndname", true);
     if ($this->params['safe']['type'] == "addArticle") {
         $path = "../uploadfile/article/" . $this->params['safe']['fenlei_id'] . "/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('fm_img')) {
             $data = array('uid' => 1, 'title' => $this->params['safe']['title'], 'contents' => $this->params['safe']['contents'], 'fenlei_id' => $this->params['safe']['fenlei_id'], 'fm_img' => $path . $uploadFile->getFileName(), 'time' => time());
             $DaoArticle = new DaoArticle();
             $DaoArticle->insertArticle($data);
         } else {
             //获取上传失败以后的错误提示
             throw new Exception('error_file_upload', $uploadFile->getErrorMsg());
         }
     } elseif ($this->params['safe']['type'] == "addUser") {
         $path = "../uploadfile/user_img/" . $this->params['safe']['user_name'] . "/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('user_img')) {
             $data = array('user_name' => $this->params['safe']['user_name'], 'user_nickname' => $this->params['safe']['user_nickname'], 'user_password' => md5($this->params['safe']['password']), 'user_qm' => "这家伙还没写签名呢!", 'user_img' => $path . $uploadFile->getFileName(), 'user_inTime' => time());
             $DaoUser = new DaoUser();
             $DaoUser->addUser($data);
         } else {
             //获取上传失败以后的错误提示
             throw new Exception('error_file_upload', $uploadFile->getErrorMsg());
         }
     } elseif ($this->params['safe']['type'] == "addfenlei") {
         $path = "../uploadfile/Fenlei/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('fenlei_img')) {
             $data = array('name' => $this->params['safe']['name'], 'time' => time(), 'fenlei_img' => $path . $uploadFile->getFileName());
             $DaoFenlei = new DaoFenlei();
             $DaoFenlei->addFenlei($data);
         }
     }
 }