Example #1
0
 /**
  * 入口函数。此函数会被自动调用
  * */
 public function run()
 {
     //检查验证码
     if (!(APP_DEBUG && C('Not_VerifyCode'))) {
         check_verify(I('post.verifycode')) or drop(EC_4841);
     }
     //校验登陆信息
     test_token() or drop(EC_4842);
     //校验是否需要登记信息
     get_state() == '100' or drop(EC_4843);
     //获取uid
     $_POST['uid'] = cookie('uid');
     //尝试创建数据对象
     //user_inf表
     $uiMo = new UserInfModel();
     $uiMo->create(I('post.'), Model::MODEL_INSERT) or drop($uiMo->getError());
     //users表
     $uMo = new UsersModel();
     $uMo->field('uid,state');
     $uMo->create(array('uid' => $_POST['uid'], 'state' => 200), Model::MODEL_UPDATE) or drop($uMo->getError());
     //注册信息
     $uiMo->add() or drop(EC_4861);
     $uMo->save() or drop(EC_4862);
     //End 注册信息
     drop(true);
 }
Example #2
0
 /**
  * 检测令牌是否有效
  * 通过此接口可以检测当前令牌是否有效。确切的说是检测现在是否是成功登陆的状态。
  * @param $uid 协会编号,默认获取cookie('uid')
  * @param $token 协会编号,默认获取cookie('token')
  * @access public
  * */
 public function test_token($uid, $token)
 {
     if (test_token($uid, $token)) {
         echo 1;
     } else {
         echo 0;
     }
 }
 /**
  * 入口函数。此函数会被自动调用
  * */
 public function run()
 {
     //检查验证码
     if (!(APP_DEBUG && C('Not_VerifyCode'))) {
         check_verify(I('post.verifycode')) or drop(EC_4341);
     }
     //校验登陆信息
     test_token() or drop(EC_4342);
     //尝试创建数据对象
     $mo = new UsersModel();
     $mo->field('uid,password');
     $mo->create(array('uid' => cookie('uid'), 'password' => I('post.password')), Model::MODEL_UPDATE) or drop($mo->getError());
     //检测字段值
     if (I('post.password') != I('post.re_password')) {
         drop(EC_4343);
     }
     //写入数据
     $mo->save() or drop(EC_4351 . $mo->getError());
     //执行登出操作
     R('Service/_empty', 'action=SignOut') or drop(EC_4361);
 }
Example #4
0
<?php

require_once 'includes/inc.global.php';
if (isset($_POST['action'])) {
    test_token();
    try {
        switch ($_POST['action']) {
            case 'read':
                $Message->set_message_read($_POST['ids']);
                break;
            case 'unread':
                $Message->set_message_unread($_POST['ids']);
                break;
            case 'delete':
                $Message->delete_message($_POST['ids']);
                break;
            default:
                break;
        }
    } catch (MyException $e) {
        Flash::store('Message Action FAILED !', true);
    }
}
$meta['title'] = 'Message Center';
$meta['head_data'] = '
	<script type="text/javascript" src="scripts/messages.js"></script>
';
$contents = '
		<form method="post" action="' . $_SERVER['REQUEST_URI'] . '"><div>
			<input type="button" name="send" id="send" value="Send Message" />
		</div></form>';
Example #5
0
/**
 * 查询当前是否正常登陆且账号状态可用
 * @param String(4) $uid 协会编号,默认cookie('uid')
 * @param String(20) $token 令牌值,默认cookie('token')
 * @return bool
 * */
function test_uid($uid, $token)
{
    $pass_code = array('200', '999');
    return test_token($uid, $token) && in_array(get_state($uid), $pass_code);
}
Example #6
0
if (empty($_SESSION['game_id'])) {
    echo 'ERROR: Game not found';
    exit;
}
// init our game
if (!isset($Game)) {
    $Game = new Game((int) $_SESSION['game_id']);
}
// run the game refresh check
if (isset($_POST['refresh'])) {
    echo $Game->last_move;
    exit;
}
// do some validity checking
if (empty($DEBUG) && empty($_POST['notoken'])) {
    test_token(!empty($_POST['keep_token']));
}
if ($_POST['game_id'] != $_SESSION['game_id']) {
    throw new MyException('ERROR: Incorrect game id given.  Was #' . $_POST['game_id'] . ', should be #' . $_SESSION['game_id'] . '.');
}
// make sure we are the player we say we are
// unless we're an admin, then it's ok
$player_id = (int) $_POST['player_id'];
if ($player_id != $_SESSION['player_id'] && !$GLOBALS['Player']->is_admin) {
    throw new MyException('ERROR: Incorrect player id given');
}
// run the simple button actions
$actions = array('nudge', 'resign', 'offer_draw', 'accept_draw', 'reject_draw', 'request_undo', 'accept_undo', 'reject_undo');
foreach ($actions as $action) {
    if (isset($_POST[$action])) {
        try {