Exemplo n.º 1
0
 /**
  * function description
  *
  * @param
  * @return void
  */
 public function execute($request)
 {
     if ($request->format == 'json') {
         $user = Sp_Account_User::current();
         $aid = $request->id;
         if (!is_numeric($aid)) {
             $data = array();
             $data['status'] = '-1';
             $data['msg'] = '提交数据有误';
             return $data;
         }
         // 当前页数
         $nowPage = $request->page;
         empty($nowPage) && ($nowPage = 1);
         $limitRow = ($nowPage - 1) * self::PAGE_SIZE;
         // 分页数据
         $array = Sp_Letter_Letter::getListByUser($user->id, $aid, $limitRow, self::PAGE_SIZE);
         $total = Sp_Letter_Letter::getTotalByUser($user->id, $aid);
         if (is_array($array) && count($array)) {
             $cry = new Util_Crypt3Des();
             foreach ($array as $key => $value) {
                 $id = $cry->encrypt($value['id']);
                 $id = base64_encode($id);
                 $array[$key]['sid'] = $id;
             }
         }
         // 分页
         $pager = new Util_Pager($total, $nowPage, self::PAGE_SIZE);
         $pageString = $pager->renderNav(true);
         $data = array();
         if (is_array($array)) {
             $data['status'] = '0';
             $data['data'] = $array;
             $data['msg'] = '';
             $data['pageString'] = $pageString;
             $data['nowtime'] = time();
         } else {
             $data['status'] = '-1';
             $data['data'] = array();
             $data['msg'] = '';
         }
         return $data;
     } else {
         $aid = $request->id;
         if (!is_numeric($aid)) {
             $this->show404();
         }
         $user = Sp_Account_User::current();
         $active = Sp_Active_Active::getActiveById($aid, $user->id);
         if (empty($active)) {
             $this->show404();
         }
         $view = new Sp_View();
         $view->assign('active', $active);
         $view->assign('select', 'letter');
         $view->display("letter/index.html");
     }
 }
Exemplo n.º 2
0
 /**
  * function description
  *
  * @param
  * @return void
  */
 public function execute($request)
 {
     $id = $request->id;
     if (is_numeric($id)) {
         $cry = new Util_Crypt3Des();
         $id = $cry->encrypt($id);
         $id = base64_encode($id);
         include LIB_ROOT . "third/phpqrcode/phpqrcode.php";
         $data = SP_URL_HOME . "letter/show/" . $id . ".html";
         // 纠错级别:L、M、Q、H
         $level = 'L';
         // 点的大小:1到10,用于手机端4就可以了
         $size = 4;
         // 下面注释了把二维码图片保存到本地的代码,如果要保存图片,用$fileName替换第二个参数fal
         QRcode::png($data, false, $level, $size);
     } else {
         $this->show404();
     }
 }
Exemplo n.º 3
0
 /**
  * 设置Cookie
  *
  * @param object $user
  * @return mixed
  */
 protected static function setHttpCookie($user, $nickname = null, $life = null)
 {
     $_timenowstamp = time();
     if (is_object($user)) {
         if (isset($_SERVER['HTTP_HOST'])) {
             // 只有在HTTP请求下才写Cookie
             $user->stateStored = true;
             $username = !is_null($nickname) ? $nickname : $user->login;
             $orig = self::getOrig($user->id, $username);
             $_COOKIE_LIFE = self::COOKIE_LIFE > 0 ? $_timenowstamp + self::COOKIE_LIFE : 0;
             if ($life > 0) {
                 $_COOKIE_LIFE = $_timenowstamp + $life;
             }
             $cry = new Util_Crypt3Des();
             $cookie = $cry->encrypt($orig);
             setcookie(self::COOKIE_NAME, $cookie, $_COOKIE_LIFE, '/', Request::genCookieDomain());
         }
     }
     return $user;
 }