Exemplo n.º 1
0
 /**
  * File Action: Post 上传文件.
  *
  * @return $this->response. 
  */
 public function actionFile()
 {
     try {
         //安全校验
         $token = "";
         if (isset($_POST['token'])) {
             $token = $_POST['token'];
         }
         $creator = Yii::app()->user->getId();
         //获得文件基本属性
         $file = $this->_getFileAtrr();
         //上传类型判断
         //文件上传
         //$this->_moveTmpFileToNewLoc($fileType,$file);
         $data = file_get_contents($file['tmp_name']);
         //RPCserver调用
         $rpcServer = RpcClient_STD_Topic::Instance();
         $result = $rpcServer->addBackground($token, $file['name'], $file['ext'], base64_encode($data));
         $file = $result['data'];
         $this->response['status'] = 200;
         $this->response['mesg'] = "upload success!";
         $this->response['body'] = $file;
     } catch (Exception $e) {
         $this->response['status'] = 400;
         $this->response['mesg'] = $e->getMessage();
     }
     echo json_encode($this->response);
 }
Exemplo n.º 2
0
 public function actionComments($page = 1)
 {
     $limit = 20;
     $res = RpcClient_STD_Topic::Instance()->getAllCommentList($page, $limit);
     $data = $res['data'];
     $total = isset($data['total']) ? $data['total'] : 0;
     $pages = new CPagination($total);
     $pages->pageSize = $limit;
     $pages->applyLimit(new CDbCriteria());
     $params['comments'] = $data['list'];
     $params['pages'] = $pages;
     $params['total'] = $total;
     $this->jsApp = array('controller/list', 'Init', array("type" => "comment", "apis" => array("delete" => "admin/removecomments")));
     $params['current_time'] = date('y-m-d h:i:s', time());
     $params['current_from'] = $pages->getCurrentPage() * $limit + 1;
     $params['current_to'] = $params['current_from'] + count($params['comments']) - 1;
     $this->render('comments', $params);
 }