Exemple #1
0
 /**
  * 构造函数,若环境不支持gb库则无法使用该类
  * @access public
  * @return boolean
  */
 public function __construct()
 {
     if (!extension_loaded('gd')) {
         F::rest()->show_error(200, 'can\'t load gd extension.');
     }
     $this->supportImageType = array('image/jpeg', 'image/png');
 }
Exemple #2
0
 public function require_params($require_params, $params = array())
 {
     $check_params = FValidator::require_params($require_params, $params);
     if ($check_params) {
         F::rest()->show_error(100, array('requires' => $check_params));
     }
     return $params;
 }
 /**
  * 生成报表数据
  *
  * @access public
  * @param string type 报表类型
  * @param int startTime 报表开始时间
  * @param int endTime 报表结束时间
  * @return array
  */
 public function create()
 {
     $this->params = $this->require_params(array('type', 'startTime', 'endTime'));
     if (method_exists($this->reportModel, $this->params['type'])) {
         $callFunction = $this->params['type'];
         $this->returnData = $this->reportModel->{$callFunction}($this->params['startTime'], $this->params['endTime']);
     } else {
         throw new Exception('报表类型' . $this->params['type'] . '生成方法不存在', 104);
     }
     F::rest()->show_result($this->returnData);
 }
 /**
  * 搜索面试人员信息
  * 
  * @access public
  * @param string phoneNum
  * @return array
  * @example
  * 
  */
 public function seach()
 {
     $this->params = $this->require_params(array('phoneNum'));
     if (!FValidator::phone($this->params['phoneNum'])) {
         throw new Exception('无效的手机号码', 100);
     }
     $this->returnData = $this->auditionModel->seach($this->params['phoneNum']);
     if (empty($this->returnData)) {
         throw new Exception('相关信息未找到', 204);
     }
     F::rest()->show_result($this->returnData);
 }
 /**
  * 每日凌晨统计使用非法维修记录信息
  * @return void
  */
 public function illegalAccountCount()
 {
     #获取起至时间
     $date = date('Y-m-d');
     $startTime = strtotime($date);
     $endTime = strtotime('+1day', $startTime);
     #获取违规数据
     $list = F::db()->fetch_all('select count(id) as num, create_user_id from event where content like "%#维修%" and type != 3 and create_time between ? and ? and status = 1 group by create_user_id', array(date(TIMESTYLE, $startTime), date(TIMESTYLE, $endTime - 1)));
     foreach ($list as $value) {
         $username = F::db()->query('select nickname from user_profile where user_id = ? limit 1', array($value['create_user_id']))->fetch_column('nickname');
         #写入错误日志文件
         file_put_contents('/home/wwwlogs/errorData/' . date('Y-m-d'), $username . ' 违规书写维修记录' . $value['num'] . '个' . "\r\n", FILE_APPEND);
     }
     unset($list);
     F::rest()->show_result();
 }
 /**
  * 更新事件
  *
  * @param int id 事件id
  * @param string content 事件内容
  * @param string accessToken 用户授权信息
  * @throws Exception 206 if 非事件创建者尝试修改信息
  */
 public function update()
 {
     #参数检查
     $this->checkAccessToken();
     $this->params = $this->require_params(array('id', 'content'));
     #获取事件信息
     $this->returnData = $this->eventModel->get($this->params['id']);
     #判断权限
     if ($this->params['createUserId'] != $GLOBALS['userId']) {
         throw new Exception('事件创建者与事件修改者不一致, 无法修改', 205);
     }
     #更新事件
     $this->eventModel->update($this->params['id'], $this->params['content']);
     #记录操作日志
     $this->userLog($GLOBALS['userId'], __CLASS__ . '/' . __FUNCTION__, serialize($this->params));
     #返回操作结果
     F::rest()->show_result();
 }
 /**
  * 获取评论列表
  *
  * @access public
  * @param string type
  * @param int $page
  * @param int $num
  * @return array
  */
 public function getList()
 {
     $this->checkAccessToken();
     $this->params = $this->require_params(array('type'));
     if ($this->params['type'] == 'event') {
         $this->require_params(array('eventId'));
     }
     $this->params['page'] = F::request('page', 1);
     $this->params['num'] = F::request('num', 20);
     switch ($this->params['type']) {
         case 'event':
             $this->returnData = $this->commentModel->getListByEvent($this->params['eventId'], $this->params['page'], $this->params['num']);
             break;
         default:
             throw new Exception('未知的type类型', 100);
             break;
     }
     F::rest()->show_result($this->returnData);
 }
Exemple #8
0
 public static function route()
 {
     try {
         $route = explode('/', F::request('r'));
         if (count($route) == 2) {
             try {
                 $module = F::load_controller($route[0]);
             } catch (Exception $e) {
                 F::log()->log_debug($e);
                 if ($e->getCode()) {
                     $rest = F::rest()->show_error($e->getCode(), $e->getMessage());
                 } else {
                     $rest = F::rest()->show_error(108);
                 }
             }
             if (method_exists($module, $route[1])) {
                 try {
                     $module->{$route}[1]();
                 } catch (Exception $e) {
                     F::log()->log_debug($e);
                     if ($e->getCode()) {
                         $rest = F::rest()->show_error($e->getCode(), $e->getMessage());
                     } else {
                         $rest = F::rest()->show_error(200, $e->getMessage());
                     }
                 }
             } else {
                 throw new Exception('Function Not Found');
             }
         } else {
             throw new Exception('Route error.');
         }
     } catch (Exception $e) {
         F::log()->log_debug($e);
         $rest = F::rest()->show_error(108);
     }
 }
 public function seachRoomByName()
 {
     $this->checkAccessToken();
     $this->params['name'] = F::request('name', '');
     $this->params['page'] = F::request('page', 1);
     $this->params['num'] = F::request('num', 20);
     $this->returnData = $this->groupModel->seachGroupRoomListByName($this->params['name'], $this->params['page'], $this->params['num'], $GLOBALS['userId']);
     F::rest()->show_result($this->returnData);
 }
 /**
  * 获取公司内部人员信息
  *
  * @return array
  */
 public function getUserProfileList()
 {
     $this->checkAccessToken();
     $this->returnData = $this->userModel->getUserProfileListByAccountType(self::ADMIN_ACCOUNT);
     F::rest()->show_result($this->returnData);
 }
 public function seach()
 {
     $this->params['name'] = F::request('name', '');
     $this->params['seachType'] = F::request('type', 0);
     //         $this->returnData = $this->params['seachType'] == 0 ? $this->contactModel->seach($this->params['name']) : $this->contactModel->seachAll($this->params['name']);
     $this->returnData = $this->contactModel->seach($this->params['name']);
     F::rest()->show_result($this->returnData);
 }
Exemple #12
0
 /**
  * 获取全部项目信息列表
  *
  * @access public
  * @return array
  */
 public function getALLProjectInfo()
 {
     $this->checkAccessToken();
     $this->returnData = $this->tagModel->getALLProjectInfo();
     F::rest()->show_result($this->returnData);
 }
 /**
  * 定时脚本,用于完成统计任务
  * 脚本每次执行只统计一组数据
  * @return void
  * @throws 100 If 无效的授权信息
  */
 public function countTask()
 {
     #参数检查
     $this->params = $this->require_params(array('token'));
     if ($this->params['token'] != self::COUNT_TASK_TOKEN) {
         throw new Exception('无效的授权信息', 100);
     }
     #获取待统计数据
     $this->statisticsModel = F::load_model('statistics', array());
     $countDataAll = $this->statisticsModel->getCountTaskData();
     if (empty($countDataAll)) {
         F::rest()->show_result();
     }
     foreach ($countDataAll as $countData) {
         #执行统计
         $this->returnData = $this->statisticsModel->count($countData);
         #通知脚本执行完毕
         $this->userModel = F::load_model('user', array());
         $this->userModel->sendCountTaskEmail($countData['email']);
     }
     F::rest()->show_result();
 }
 /**
  * (non-PHPdoc)
  * @see base_controller::checkAccessToken()
  */
 public function checkAccessToken()
 {
     parent::checkAccessToken();
     $this->userLog($GLOBALS['userId'], __CLASS__ . '/' . __FUNCTION__, serialize($this->params));
     F::rest()->show_result($GLOBALS['userId']);
 }