Ejemplo n.º 1
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionProfile($username = '')
 {
     $this->layout = '//layouts/column1';
     if (!$username and Yii::app()->user->isGuest) {
         Yii::app()->user->setReturnUrl(Yii::app()->getRequest()->url);
         $this->redirect(array('site/login'));
     }
     if (!$username) {
         $this->redirect(array('profile/' . Yii::app()->user->name));
     }
     if (!($this->model = User::model()->find('username=:username', array(':username' => $username)))) {
         throw new CHttpException(404, 'The username ' . $username . ' does not exist.');
     }
     //$this->model=$this->loadModel($id);
     $this->model->country = Country::model()->findByPk($this->model->country_id)->name;
     $status = Yii::app()->db->createCommand()->select('*')->from('user_status')->queryRow();
     $this->model->status = $status['name'];
     $type = Yii::app()->db->createCommand()->select('*')->from('user_type')->queryRow();
     $this->model->type = $type['name'];
     $this->model->country_created = Country::model()->findByPk($this->model->country_id_created)->name;
     $stat_subs = Subject::model()->count('user_id=:user_id', array(':user_id' => $this->model->id));
     $stat_comments = Comment::model()->count('user_id=:user_id', array(':user_id' => $this->model->id));
     $stat_usage_counter = Log::model()->count('user_id=:user_id', array(':user_id' => $this->model->id));
     $last_log_line = Log::model()->find(array('limit' => 2, 'offset' => 1, 'order' => 't.id DESC', 'params' => array(':user_id' => $this->model->id)));
     $this->render('view', array('model' => $this->model, 'stat_subs' => $stat_subs, 'stat_comments' => $stat_comments, 'stat_last_online' => $last_log_line->time, 'stat_usage_counter' => $stat_usage_counter));
 }
Ejemplo n.º 2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Log::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Ejemplo n.º 3
0
 public function loadModel($id)
 {
     $model = Log::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     // if(!$model->hasAccess(Yii::app()->user->id))
     //    throw new CHttpException(403,'Access Denaid');
     return $model;
 }
Ejemplo n.º 4
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     if (!($snapFeed = Yii::app()->cache->get('snapFeed'))) {
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, 'http://www.snapfrozen.com.au/feed/atom/');
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         $snapFeed = curl_exec($curl);
         curl_close($curl);
         Yii::app()->cache->set('snapFeed', $snapFeed, 60 * 60 * 24);
     }
     $RecentActivity = Log::model()->findAll(array('limit' => 10, 'order' => 'logtime DESC', 'condition' => 'level="info"'));
     $this->render('index', array('snapFeed' => simplexml_load_string($snapFeed), 'feedLimit' => 5, 'RecentActivity' => $RecentActivity));
 }
 /**
  * 获取学员详细信息
  */
 public function actionGetStudentInfo()
 {
     if (!isset($_REQUEST['userId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['memberId'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('userId', null));
     $token = trim(Yii::app()->request->getParam('token', null));
     $memberId = trim(Yii::app()->request->getParam('memberId', null));
     // 用户ID格式错误
     if (!ctype_digit($user_id)) {
         $this->_return('MSG_ERR_FAIL_USER');
     }
     // 用户不存在,返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     if (empty($memberId) || $memberId <= 0) {
         $this->_return('MSG_ERR_FAIL_STUDENT');
     }
     // 验证要添加的memberId是否和userId有绑定关系存在
     $existMemberId = User::model()->existUserIdMemberId($user_id, $memberId);
     if (!$existMemberId) {
         $this->_return('MSG_ERR_FAIL_MEMBER');
     }
     // 验证token
     if (Token::model()->verifyToken($user_id, $token)) {
         // 获取学员详细信息
         $data = Student::model()->getStudentInfo($memberId);
         if (!$data) {
             $this->_return('MSG_NO_MEMBER');
         }
         // 增加用户操作log
         $action_id = 2301;
         $params = '';
         foreach ($_REQUEST as $key => $value) {
             $params .= $key . '=' . $value . '&';
         }
         $params = substr($params, 0, -1);
         Log::model()->action_log($user_id, $action_id, $params);
         $this->_return('MSG_SUCCESS', $data);
     } else {
         $this->_return('MSG_ERR_TOKEN');
     }
 }
Ejemplo n.º 6
0
 public function _return($error_code, $data = NULL)
 {
     require 'ErrorCode.php';
     $this->runtime->stop();
     if (isset($GLOBALS['_SERVER']['REQUEST_URI'])) {
         $temp_arr = explode('?', $GLOBALS['_SERVER']['REQUEST_URI']);
         if (isset($temp_arr[0])) {
             $temp1_arr = explode('index.php', $temp_arr[0]);
             if (isset($temp1_arr[1])) {
                 $action_arr = explode('/', $temp1_arr[1]);
                 $user_id = trim(Yii::app()->request->getParam('user_id'));
                 if (isset($action_arr[1]) && isset($action_arr[2])) {
                     Log::model()->_time_log($action_arr[1], $action_arr[2], $this->runtime->spent(), $user_id);
                 }
             }
         }
     }
     //
     if (!isset($GLOBALS['__APPID']) || $GLOBALS['__APPID'] == '') {
         $GLOBALS['__APPID'] = 10;
     }
     if (!$data) {
         $dstr = json_encode(array('error' => $_error_code[$GLOBALS['__APPID']][$error_code][1], 'success' => $_error_code[$GLOBALS['__APPID']][$error_code][0]));
         exit(str_replace('\\/', '/', $dstr));
         /*	5.3.* 的版本不支持JSON_UNESCAPED_SLASHES参数
         			exit(json_encode(array('error' => $_error_code[$error_code][1],
         							   'success' => $_error_code[$error_code][0]), JSON_UNESCAPED_SLASHES));
         			*/
     } else {
         $dstr = json_encode(array('error' => $_error_code[$GLOBALS['__APPID']][$error_code][1], 'success' => $_error_code[$GLOBALS['__APPID']][$error_code][0], 'result' => $data));
         exit(str_replace('\\/', '/', $dstr));
         /*	5.3.* 的版本不支持JSON_UNESCAPED_SLASHES参数
         			exit(json_encode(array('error' => $_error_code[$error_code][1],
         							   'success' => $_error_code[$error_code][0],
         							   'result' => $data), JSON_UNESCAPED_SLASHES));
         							   */
     }
 }
 /**
  * 版本升级
  * $GLOBALS['__PLATFORM']   系统平台: 1-Android; 2-iOS
  * $GLOBALS['__APP_ID']     应用编号: 10-学员端; 11-教师端
  */
 public function actionUpdateVersion()
 {
     $platform = intval(trim($GLOBALS['__PLATFORM']));
     $app_id = intval(trim($GLOBALS['__APP_ID']));
     $plat = array(1, 2);
     // 平台数组: 1-Android; 2-iOS
     $app = array(10, 11);
     // 应用编号数组: 10-学员端; 11-教师端
     if (in_array($platform, $plat, true) && in_array($app_id, $app, true)) {
         $result = Common::model()->updateVersion($platform, $app_id);
         if ($result === false) {
             $this->_return('MSG_ERR_UNKOWN');
         }
         $data = array();
         if (isset($result['newVersion'])) {
             if (strcmp($_REQUEST['app_version'], $result['newVersion']) != 0) {
                 $data = $result;
             }
         }
         if (empty($data)) {
             $this->_return('MSG_ERR_FAIL_UPDATE_VERSION');
         } else {
             // 增加用户操作log
             $action_id = 2401;
             $params = '';
             foreach ($_REQUEST as $key => $value) {
                 $params .= $key . '=' . $value . '&';
             }
             $params = substr($params, 0, -1);
             Log::model()->action_log(0, $action_id, $params);
             $this->_return('MSG_SUCCESS', $data);
         }
     } else {
         $this->_return('MSG_ERR_FAIL_PLATFORM|APP_ID');
     }
 }
Ejemplo n.º 8
0
 /**
  * 金币解锁照片
  *
  * @param int $user_id
  * @param int $goddess_id
  * @param int $token
  * @param int $image_id
  *
  */
 public function actionGoldUnlockPhoto()
 {
     // 参数检查
     if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['goddess_id']) || !isset($_REQUEST['image_id'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('user_id'));
     $token = trim(Yii::app()->request->getParam('token'));
     $goddess_id = trim(Yii::app()->request->getParam('goddess_id'));
     $image_id = trim(Yii::app()->request->getParam('image_id'));
     $now = date("Y-m-d H:i:s");
     if (!is_numeric($user_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     //用户不存在 返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     if (!Goddess::model()->isExitsGoddess($goddess_id)) {
         //不存在此女神
         $this->_return("MSG_ERR_NO_EXIST_GODDESS");
     }
     //验证token
     if (Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) {
         //金币解锁照片
         $res = Goddess::model()->GoldUnlockPhoto($user_id, $goddess_id, $image_id);
         switch ($res) {
             case -1:
                 $this->_return('MSG_ERR_NO_FOUND_IMG');
             case -2:
                 $this->_return('MSG_ERR_FAIL_UNLOCKED');
             case -3:
                 $this->_return('MSG_ERR_NO_GOLD');
             default:
                 break;
         }
         $memo = $res['log']['gold'];
         //记录日志 金币解锁照片
         Log::model()->_photo_log($user_id, $goddess_id, $image_id, 'GOLD_UNLOCK_IMG', date('Y-m-d H:i:s'), $memo);
     } else {
         $this->_return('MSG_ERR_TOKEN');
     }
     // 发送返回值
     $this->_return('MSG_SUCCESS', $res['result']);
 }
Ejemplo n.º 9
0
 /**
  * IOS IAP 支付验证
  * $uid
  * $token
  * $item_id
  * $receipt
  */
 public function actionIosVerify()
 {
     // error_log(json_encode($_POST));
     if (!isset($_REQUEST['receipt']) || !isset($_REQUEST['uid']) || !isset($_REQUEST['token']) || !isset($_REQUEST['trade_no'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     /*沙盒测试开关,正式发布时,需置为false**********************************/
     $isSandbox = true;
     /********************************************************************/
     $receipt = Yii::app()->request->getParam('receipt');
     $uid = trim(Yii::app()->request->getParam('uid'));
     $token = trim(Yii::app()->request->getParam('token'));
     $trade_no = Yii::app()->request->getParam('trade_no');
     $now = date('Y-m-d H:i:s');
     if (!Token::model()->verifyToken($uid, $token, $GLOBALS['__APPID'])) {
         $this->_return('MSG_ERR_TOKEN');
         //#token 错误
     }
     $param = array('uid' => $uid, 'receipt' => $receipt, 'create_ts' => $now, 'trade_no' => $trade_no);
     $trade_info = Pay::model()->getTradeInfo($trade_no);
     if ($trade_info['uid'] != $uid || $trade_info['status'] != 0) {
         Pay::model()->recordIOSIAPInfo($param);
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, $trade_no, "无效或重复的订单");
         $this->_return('MSG_ISO_PAY_WRONG');
     }
     if ($isSandbox) {
         $endpoint = 'https://sandbox.itunes.apple.com/verifyReceipt';
     } else {
         $endpoint = 'https://buy.itunes.apple.com/verifyReceipt';
     }
     $postData = json_encode(array('receipt-data' => $receipt));
     $ch = curl_init($endpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, true);
     //curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     //curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     //这两行一定要加,不加会报SSL 错误
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     $response = curl_exec($ch);
     $errno = curl_errno($ch);
     $errmsg = curl_error($ch);
     curl_close($ch);
     if ($errno != 0) {
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, trade_no, $errno . ">" . $errmsg);
         Pay::model()->recordIOSIAPInfo($param);
         $this->_return('MSG_ISO_PAY_WRONG');
     }
     $param['verify_data'] = $response;
     $data = json_decode($response);
     if (!is_object($data)) {
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, $trade_no, '不能解析返回数据>' . $response);
         Pay::model()->recordIOSIAPInfo($param);
         $this->_return('MSG_ISO_PAY_WRONG');
         //throw new Exception('Invalid response data');
     }
     if (!isset($data->status) || $data->status != 0) {
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_FAIL', $now, $trade_no);
         Pay::model()->recordIOSIAPInfo($param);
         $this->_return('MSG_ISO_PAY_FAIL');
     }
     $add_coin = $trade_info['coin'] + $trade_info['free'];
     Pay::model()->iosPaySuccess($uid, $trade_no, $add_coin);
     Pay::model()->recordIOSIAPInfo($param);
     Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_OK', $now, $trade_no);
     $res = array('gold' => $add_coin);
     $this->_return('MSG_SUCCESS', $res);
 }
Ejemplo n.º 10
0
 public function actionDelete()
 {
     $id = Yii::app()->request->getParam('id');
     $qr = $this->loadModel($id);
     Log::model()->deleteAll('qr_id = :qr_id', array(':qr_id' => $id));
     $qr->delete();
     Utility::setFlash(Yii::t('dict', 'Deleted successfully.'), 'success');
     $this->redirect(array('list'));
 }
Ejemplo n.º 11
0
 /**
  * 拒绝/接受 好友邀请
  *
  * @param string $user_id
  * @param string $token
  * @param string $friend_id
  * @param string $status   1-已确认, 2-拒绝, 3-取消
  */
 public function actionInviting()
 {
     // 参数检查
     if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['friend_id']) || !isset($_REQUEST['status'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('user_id'));
     $token = trim(Yii::app()->request->getParam('token'));
     $status = trim(Yii::app()->request->getParam('status'));
     $friend_id = trim(Yii::app()->request->getParam('friend_id'));
     if ($status != 1 && $status != 2 && $status != 3) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     if (!is_numeric($user_id) || !is_numeric($friend_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     //用户不存在 返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     //用户不存在 返回错误
     if ($friend_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     //验证token
     if (!Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) {
         $this->_return('MSG_ERR_TOKEN');
     }
     $ids = array();
     $ids = UserFriend::model()->newFriendMess($user_id);
     $friend = array();
     foreach ($ids as $id) {
         $friend[] = $id['friend_user_id'];
     }
     if (!in_array($friend_id, $friend)) {
         $this->_return('MSG_ERR_NO_FRIEND_REQ');
     }
     $friend_transaction = Yii::app()->db_friend->beginTransaction();
     try {
         UserFriend::model()->updateFriend($user_id, $friend_id, $status);
         $friend_transaction->commit();
         //log 日志
         $memo = $user_id . '|' . $friend_id . '|' . $status;
         Log::model()->_user_log($user_id, 'REPLY_INVITATION', date("Y-m-d H:i:s"), $memo);
     } catch (Exception $e) {
         error_log($e);
         $friend_transaction->rollback();
         $this->_return('MSG_ERR_UNKOWN');
     }
     $this->_return('MSG_SUCCESS');
 }
 /**
  *  用户提交课时请假信息
  */
 public function actionLessonStudentLeave()
 {
     if (!isset($_REQUEST['userId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['lessonStudentId']) || !isset($_REQUEST['memberId']) || !isset($_REQUEST['dateTime']) || !isset($_REQUEST['reason']) || !isset($_REQUEST['courseId'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('userId', null));
     $token = trim(Yii::app()->request->getParam('token', null));
     $lessonStudentId = trim(Yii::app()->request->getParam('lessonStudentId', null));
     $memberId = trim(Yii::app()->request->getParam('memberId', null));
     $dateTime = trim(Yii::app()->request->getParam('dateTime', null));
     $reason = trim(Yii::app()->request->getParam('reason', null));
     $courseId = trim(Yii::app()->request->getParam('courseId', null));
     // 用户名不存在,返回错误
     if (!ctype_digit($user_id) || $user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     if (empty($lessonStudentId) || $lessonStudentId < 1) {
         $this->_return('MSG_ERR_FAIL_LESSON_STUDENT_ID');
     }
     // 规范提前请假时间
     $leaveTime = Lesson::model()->isLessonLeaveTime($lessonStudentId);
     if ($leaveTime < 1) {
         $this->_return('MSG_ERR_FAIL_LEAVE_TIME');
     }
     if (Lesson::model()->isExistLessonStudentId($lessonStudentId)) {
         $this->_return('MSG_EXIST_LESSON_STUDENT_ID');
     }
     if (!ctype_digit($memberId) || $memberId < 1) {
         $this->_return('MSG_NO_MEMBER');
     }
     if (!ctype_digit($courseId) || $courseId < 1) {
         $this->_return('MSG_NO_MEMBER');
     }
     // 验证日期格式合法
     if (!$this->isDate($dateTime)) {
         $this->_return('MSG_ERR_FAIL_DATE_FORMAT');
     }
     // 验证token
     if (Token::model()->verifyToken($user_id, $token)) {
         // 提交课时请假信息
         $lesson = Lesson::model()->lessonStudentLeave($memberId, $courseId, $lessonStudentId, $dateTime, $reason);
         // 增加用户操作log
         $action_id = 2202;
         $params = '';
         foreach ($_REQUEST as $key => $value) {
             $params .= $key . '=' . $value . '&';
         }
         $params = substr($params, 0, -1);
         Log::model()->action_log($user_id, $action_id, $params);
         //            if ($lesson) {
         //                $this->_return('MSG_SUCCESS');
         //            } else {
         //                $this->_return('MSG_ERR_UNKOWN');
         //            }
         $this->_return('MSG_SUCCESS');
     } else {
         $this->_return('MSG_ERR_TOKEN');
     }
 }
Ejemplo n.º 13
0
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Syslog the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
Ejemplo n.º 14
0
 public function actionSoftwareToGold()
 {
     // 参数检查
     if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['software_id'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('user_id'));
     $token = trim(Yii::app()->request->getParam('token'));
     $software_id = trim(Yii::app()->request->getParam('software_id'));
     if (!is_numeric($user_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     //用户不存在 返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     //验证token
     if (Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) {
         //
         $res = User::model()->software_to_gold($user_id, $software_id);
         switch ($res) {
             //系统繁忙,请稍后再试
             case -1:
                 $this->_return('MSG_ERR_UNKOWN');
                 //软件金币已经领取,不能重复领取
             //软件金币已经领取,不能重复领取
             case -2:
                 $this->_return('MSG_ERR_SOFTWARE_TO_GOLD');
             case -3:
                 $this->_return('MSG_ERR_FAIL_SEARCH');
             default:
                 break;
         }
         $memo = '';
         //软件兑换金币
         Log::model()->_gold_log($user_id, $res['log']['gold'], $res['log']['gold_after'], 'GOLD_SOFTWARE_TO_GOLD', date('Y-m-d H:i:s'), $memo);
     }
     // 发送返回值
     $this->_return('MSG_SUCCESS', $res['result']);
 }
Ejemplo n.º 15
0
 public function actionOnOff()
 {
     // 参数检查
     if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['open'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('user_id'));
     $token = trim(Yii::app()->request->getParam('token'));
     $status = trim(Yii::app()->request->getParam('open'));
     if (!is_numeric($user_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     //用户不存在 返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     //验证token
     if (Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) {
         $param['push_enabled'] = $status;
         // 如果由更新参数 那么更新
         if (!empty($param)) {
             try {
                 Characters::model()->updateCharacters($user_id, $param);
                 // 更新角色信息表  日志 防打扰
                 Log::model()->_goddess_log($user_id, '', 'DO_NOT_DISTURB', date("Y-m-d H:i:s"), '');
                 // 发送返回值
                 $this->_return('MSG_SUCCESS');
             } catch (Exception $e) {
                 error_log($e);
                 $this->_return('MSG_ERR_UNKOWN');
             }
         }
     } else {
         $this->_return('MSG_ERR_TOKEN');
     }
 }
Ejemplo n.º 16
0
 /**
  * 删除消息
  *
  * @param int    $user_id
  * @param string $token
  * @param int    $message_id
  * @param int    $status        //1:已读:0未读  2删除
  *
  */
 public function actionDelMess()
 {
     // 参数检查
     if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['message_id']) || !isset($_REQUEST['status'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('user_id'));
     $token = trim(Yii::app()->request->getParam('token'));
     $message_id = trim(Yii::app()->request->getParam('message_id'));
     $status = trim(Yii::app()->request->getParam('status'));
     //过滤message_id
     if (!is_numeric($message_id) || $message_id < 1) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     if (!is_numeric($status)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     if ($status != 0 && $status != 1 && $status != 2) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     if (!is_numeric($user_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     //前段送0未读状态过来,直接判定为删除。直接删除
     if ($status == 0) {
         $status = 2;
     }
     //用户不存在 返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     //验证token
     if (Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) {
         if (Message::model()->updateMessType($user_id, $message_id, $status)) {
             //读消息
             $memo = $message_id . '|2';
             Log::model()->_goddess_log($user_id, 0, 'READ_MESSAGE', date('Y-m-d H:i:s'), $memo);
             $this->_return('MSG_SUCCESS', '');
         } else {
             $this->_return('MSG_ERR_UNKOWN');
         }
     } else {
         //token 错误
         $this->_return('MSG_ERR_TOKEN');
     }
 }
Ejemplo n.º 17
0
 /**
  * 给女神送礼物
  *
  * @param int    $user_id
  * @param string $token
  * @param int    $goddess_id
  * @param int    $gift_id
  *
  */
 public function actionGiftGiving()
 {
     // 参数检查
     if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['goddess_id']) || !isset($_REQUEST['gift_id']) || !isset($_REQUEST['gift_num'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('user_id'));
     $token = trim(Yii::app()->request->getParam('token'));
     $goddess_id = trim(Yii::app()->request->getParam('goddess_id'));
     $gift_id = trim(Yii::app()->request->getParam('gift_id'));
     $number = trim(Yii::app()->request->getParam('gift_num'));
     //判断女神id 和 礼品id 数据类型
     if (!is_numeric($goddess_id) || !is_numeric($gift_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     if (!is_numeric($user_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     if ($number <= 0) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     //用户不存在 返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     //验证token
     if (Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) {
         //送礼物
         $res = Gift::model()->giveGift($user_id, $goddess_id, $gift_id, $number);
         switch ($res) {
             case -1:
                 $this->_return('MSG_ERR_UNKOWN');
             case -2:
                 $this->_return('MSG_ERR_NO_GIFT');
             case -3:
                 $this->_return('MSG_ERR_NO_FOLLOW');
             case -4:
                 $this->_return('MSG_ERR_NO_GOLD');
             default:
                 break;
         }
         if (isset($res['log']['gold_after']) && isset($res['log']['gold'])) {
             //道具购买
             Log::model()->_gold_log($user_id, $res['log']['gold'], $res['log']['gold_after'], 'GOLD_BUY_ITEM', date('Y-m-d H:i:s'), '');
         }
         //送礼物日志
         Log::model()->_gift_log($user_id, $goddess_id, $gift_id, $number, $res['log']['gold'], 'DS_TRIBUTE_GIFT', date('Y-m-d H:i:s'), '');
         //成功
         $this->_return('MSG_SUCCESS', $res['result']);
     } else {
         //token 错误
         $this->_return('MSG_ERR_TOKEN');
     }
 }
Ejemplo n.º 18
0
 public function iosPaySuccess($uid, $trade_no, $add_coin)
 {
     $con_pay = Yii::app()->db_pay;
     $now = date('Y-m-d H:i:s');
     $con_pay->createCommand()->update('orders', array('status' => 1, 'charge_ts' => $now, 'notify_ts' => $now), 'trade_no=:Trade_no', array(':Trade_no' => $trade_no));
     //给玩家金币
     $p_info = Characters::model()->getCharactersInfo($uid);
     Characters::model()->updateCharacters($uid, array('gold' => $p_info['gold'] + $add_coin));
     //添加金币log
     Log::model()->_gold_log($uid, $add_coin, $p_info['gold'] + $add_coin, 'PAY_BUY_GOLD', $now);
 }
Ejemplo n.º 19
0
 public function init()
 {
     $this->actCheck('log', false);
     $this->_logObj = Log::model();
     $this->layout = '//layouts/column1';
 }