当前位置: 首页>>代码示例>>PHP>>正文


PHP Base_Common::cutstr方法代码示例

本文整理汇总了PHP中Base_Common::cutstr方法的典型用法代码示例。如果您正苦于以下问题:PHP Base_Common::cutstr方法的具体用法?PHP Base_Common::cutstr怎么用?PHP Base_Common::cutstr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Base_Common的用法示例。


在下文中一共展示了Base_Common::cutstr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: serviceLogUnloggedAction


//.........这里部分代码省略.........
                     if ($M) {
                         $ServiceNum['complain']['New'] = 1;
                     }
                     if (in_array($QuestionInfo['status'], array(0, 4))) {
                         $NewLog[$QuestionInfo['time']][] = array('QuestionId' => $QuestionInfo['QuestionId'], 'QuestionType' => 'complain');
                     }
                 }
                 unset($ServiceNum['complain']['List']);
             } else {
                 $ServiceNum['complain']['Num'] = 0;
             }
             krsort($NewLog);
             $i = 0;
             $NewServiceList = array();
             foreach ($NewLog as $Time => $TimeList) {
                 foreach ($TimeList as $key => $Question) {
                     if ($i < $User['NewCount']) {
                         switch ($Question['QuestionType']) {
                             case "ask":
                                 $QuestionInfo = $this->oQuestion->getQuestion($Question['QuestionId'], "id,description,time,atime,status,qtype");
                                 //生成问题链接
                                 $QuestionInfo['QuestionUrl'] = $this->oQuestion->getQuestionLink($QuestionInfo['id'], "question");
                                 //复制问题分类
                                 $QuestionInfo['QuestionType'] = $Question['QuestionType'];
                                 //生成问题状态
                                 if ($QuestionInfo['status'] == 1) {
                                     $QuestionInfo['QuestionStatus'] = 1;
                                 } else {
                                     $QuestionInfo['QuestionStatus'] = 2;
                                 }
                                 $NewServiceList[] = $QuestionInfo;
                                 break;
                             case "suggest":
                                 $QuestionInfo = $this->oQuestion->getQuestion($Question['QuestionId'], "id,description,time,atime,status,qtype");
                                 //生成问题链接
                                 $QuestionInfo['QuestionUrl'] = $this->oQuestion->getQuestionLink($QuestionInfo['id'], "question");
                                 //复制问题分类
                                 $QuestionInfo['QuestionType'] = $Question['QuestionType'];
                                 //生成问题状态
                                 if ($QuestionInfo['status'] == 1) {
                                     $QuestionInfo['QuestionStatus'] = 1;
                                 } else {
                                     $QuestionInfo['QuestionStatus'] = 2;
                                 }
                                 $NewServiceList[] = $QuestionInfo;
                                 break;
                             case "complain":
                                 $QuestionInfo = $this->oComplain->getComplain($Question['QuestionId'], "id,description,time,atime,status,qtype");
                                 //生成问题链接
                                 $QuestionInfo['QuestionUrl'] = $this->oComplain->getQuestionLink($QuestionInfo['id'], "complain");
                                 //复制问题分类
                                 $QuestionInfo['QuestionType'] = $Question['QuestionType'];
                                 //生成问题状态
                                 if (in_array($QuestionInfo['status'], array(0, 4))) {
                                     $QuestionInfo['QuestionStatus'] = 1;
                                 } elseif (in_array($QuestionInfo['status'], array(1, 3))) {
                                     $QuestionInfo['QuestionStatus'] = 2;
                                 }
                                 if ($QuestionInfo['status'] == 2) {
                                     $QuestionInfo['QuestionStatus'] = 3;
                                 }
                                 $NewServiceList[] = $QuestionInfo;
                                 break;
                         }
                     }
                     $i++;
                 }
             }
             foreach ($NewServiceList as $key => $QuestionInfo) {
                 if (!isset($QtypeList[$QuestionInfo['qtype']])) {
                     $QtypeList[$QuestionInfo['qtype']] = $this->oQtype->getQtypeById($QuestionInfo['qtype']);
                 }
                 $NewServiceList[$key]['Qtype'] = $QtypeList[$QuestionInfo['qtype']]['name'];
                 //格式化提问时间
                 $NewServiceList[$key]['AddTime'] = date("Y-m-d H:i", $QuestionInfo['time']);
                 //格式化回答时间
                 $NewServiceList[$key]['AnswerTimeLag'] = $QuestionInfo['QuestionStatus'] >= 2 && $QuestionInfo['atime'] ? Base_Common::timeLagToText($QuestionInfo['time'], $QuestionInfo['atime']) : "-";
                 //获取问题状态名称
                 $NewServiceList[$key]['QuestionStatusName'] = $QuestionStatusList[$QuestionInfo['QuestionStatus']];
                 //格式化问题内容
                 $NewServiceList[$key]['Content'] = Base_Common::cutstr($QuestionInfo['description'], 14);
                 //获取问题分类
                 $CategoryInfo = $QuestionTypeList[$QuestionInfo['QuestionType']];
                 //获取问题主分类
                 $NewServiceList[$key]['QuestionType'] = $CategoryInfo;
                 unset($NewServiceList[$key]['description']);
             }
             //服务记录详情页面信息
             $ServiceLogDetail = array('Url' => 'http://sc.5173.com/index.php?question/my_ask.html', 'Content' => '查看全部服务记录');
             //入口信息
             $ServiceEntrance = array('Url' => 'http://sc.5173.com/index.php?question/ask_skip.html', 'Content' => '我要提问');
             $result = array('return' => 1, 'ServiceNum' => $ServiceNum, 'ServiceLogDetail' => $ServiceLogDetail, 'ServiceEntrance' => $ServiceEntrance, 'NewServiceList' => $NewServiceList);
         } else {
             $result = array('return' => 0, 'comment' => "时间有误");
         }
     } else {
         $result = array('return' => 0, 'comment' => "验证失败,请检查URL");
     }
     echo json_encode($result);
 }
开发者ID:032404cxd,项目名称:prototype_main,代码行数:101,代码来源:UserController.php

示例2: questionDetailAction

 /**
  *获取问题详情
  */
 public function questionDetailAction()
 {
     //基础元素,必须参与验证
     $List['QuestionId'] = abs(intval($this->request->QuestionId));
     $List['QuestionType'] = urldecode(trim($this->request->QuestionType));
     $List['UserName'] = urldecode(trim($this->request->UserName));
     $List['QuickAsk'] = urldecode(trim($this->request->QuickAsk));
     $List['Time'] = abs(intval($this->request->Time));
     $oMenCache = new Base_Cache_Memcache("Complaint");
     $Setting = $oMenCache->get('setting');
     //URL验证码
     $sign = $this->request->sign;
     //私钥,以后要移开到数据库存储
     $p_sign = '5173';
     $sign_to_check = base_common::check_sign($List, $p_sign);
     //不参与验证的元素
     //验证URL是否来自可信的发信方
     if ($sign_to_check == $sign) {
         //验证时间戳,时差超过600秒即认为非法
         if (abs($List['Time'] - time()) <= 600) {
             //问题类型为咨询|建议
             if ($List['QuestionType'] == "question") {
                 //获取缓存
                 $M = $oMenCache->get('QuestionDetail_' . $List['QuestionType'] . "_" . $List['QuestionId']);
                 if ($M) {
                     $QuestionDetail = json_decode($M, true);
                     //如果缓存内的数据不正确
                     if (!$QuestionDetail['QuestionId']) {
                         //获取封装完毕的问题详情
                         $QuestionDetail = $this->oQuestion->ProcessQuestionDetail($List);
                     }
                 } else {
                     //获取封装完毕的问题详情
                     $QuestionDetail = $this->oQuestion->ProcessQuestionDetail($List);
                 }
                 if ($QuestionDetail['QuestionId']) {
                     //写入缓存
                     $oMenCache->set('QuestionDetail_' . $List['QuestionType'] . "_" . $List['QuestionId'], json_encode($QuestionDetail), 300);
                     //如果已经被转换分类
                     if ($QuestionDetail['Transformed'] == 1) {
                         //获取转换后的分类信息
                         $CategoryInfo = $this->oCategory->getCategoryByQuestionType($QuestionDetail['QuestionType']);
                         //提示跳转
                         $result = array('return' => 2, 'action' => $this->oQuestion->getQuestionLink($QuestionDetail['QuestionId'], $QuestionDetail['QuestionType']), 'comment' => "此问题已经被转换为" . $CategoryInfo['name']);
                     } else {
                         //cookie验证
                         $CookieAuthor = $this->oUser->authorUserByCookie($List['QuickAsk'], 'zx,jy', $QuestionDetail['QuestionId']);
                         //用户名验证
                         $UserAuthor = $this->oUser->authorUserByName($List['UserName'], $QuestionDetail['AuthorName']);
                         //用户名验证不通过 并且 COOKIE验证不通过
                         if (!$UserAuthor) {
                             if (!$CookieAuthor) {
                                 $QuestionDetail['AuthorName'] = Base_Common::cutstr($QuestionDetail['AuthorName'], 2, '**');
                             }
                         }
                         //如果问题不是隐私状态
                         if ($QuestionDetail['Hidden'] == 1) {
                             //登陆用户 并且 账号不一致
                             if (!$UserAuthor) {
                                 //不显示附件信息
                                 $QuestionDetail['QuestionAttatch'] = "";
                                 //如果浏览器记录中无该问题提问记录
                                 if (!$CookieAuthor) {
                                     //取消追问资格
                                     $QuestionDetail['SubQuestion'] = 0;
                                     //取消评价资格
                                     $QuestionDetail['Assess'] = 0;
                                     //不显示评价
                                     unset($QuestionDetail['AssessStatus']);
                                 }
                             }
                             $result = array('return' => 1, 'QuestionDetail' => $QuestionDetail);
                             //缓存中清除新处理的问题标记
                             if ($CookieAuthor || $UserAuthor) {
                                 //缓存中清除新处理的问题标记
                                 $oMenCache->remove('fw' . $List['QuestionId']);
                             }
                         } else {
                             //登陆用户 并且 账号不一致
                             if (!$UserAuthor) {
                                 //不显示附件信息
                                 $QuestionDetail['QuestionAttatch'] = "";
                                 //如果浏览器记录中无该问题提问记录
                                 if (!$CookieAuthor) {
                                     //取消追问资格
                                     $QuestionDetail['SubQuestion'] = 0;
                                     //取消评价资格
                                     $QuestionDetail['Assess'] = 0;
                                     //不显示评价
                                     unset($QuestionDetail['AssessStatus']);
                                 }
                             }
                             $result = array('return' => 1, 'QuestionDetail' => $QuestionDetail);
                             //如果cookie验证通过 或者 用户验证通过
                             if ($CookieAuthor || $UserAuthor) {
                                 //缓存中清除新处理的问题标记
                                 $oMenCache->remove('fw' . $List['QuestionId']);
//.........这里部分代码省略.........
开发者ID:eappl,项目名称:prototype,代码行数:101,代码来源:ListController.php


注:本文中的Base_Common::cutstr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。