Ejemplo n.º 1
0
 public function action()
 {
     //页面展示
     $AdminAjaxModel = new AdminAjaxModel();
     $result = $AdminAjaxModel->getResult();
     $type = $result['params']['safe']['type'];
     if ($type == 'user') {
         $DaoUser = new DaoUser();
         $result = $DaoUser->getUserInfoByUsername($result['params']['safe']['userName']);
         if ($result) {
             echo '1';
         } else {
             echo '0';
         }
     } else {
         if ($type == 'fenlei') {
             $DaoFenlei = new DaoFenlei();
             $result = $DaoFenlei->getFenleiInfoByName($result['params']['safe']['fenleiName']);
             if ($result) {
                 echo '1';
             } else {
                 echo '0';
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function preform()
 {
     $DaoFenlei = new DaoFenlei();
     $result = $DaoFenlei->getFenleiInfo();
     $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
     }
     $this->result['data']['list'] = $result;
     $DaoFenlei->getFenleiCount() / $limit > 1 ? $this->result['count'] = 1 : ($this->result['count'] = $DaoFenlei->getFenleiCount() / $limit);
     $this->result['page'] = $this->params['safe']['page'];
 }
Ejemplo n.º 3
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);
         }
     }
 }