Ejemplo n.º 1
0
 function op_updateuser()
 {
     $msg = '';
     $reg_type = !empty($_POST['reg_type']) ? $_POST['reg_type'] : '';
     $_POST['sex'] = isset($_POST['sex']) ? $_POST['sex'] : 0;
     $pattern2 = "/^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+\$/";
     if ($reg_type == 'email') {
         if (empty($_POST['email']) || !preg_match($pattern2, $_POST['email'])) {
             $msg = array('s' => 400, 'm' => lang('insertemail'), 'd' => '');
             exit(json_output($msg));
         }
     }
     if (!empty($_POST['password']) && strlen($_POST['password']) < 6) {
         $msg = array('s' => 400, 'm' => lang('pwdrule'), 'd' => '');
         exit(json_output($msg));
     }
     $_POST['nickname'] = trim($_POST['nickname']);
     $nickname_len = mb_strlen($_POST['nickname'], "UTF-8");
     if (empty($_POST['nickname']) || $nickname_len < 2 || $nickname_len > 16) {
         $msg = array('s' => 400, 'm' => lang('nicknamerule'), 'd' => '');
         exit(json_output($msg));
     }
     $_POST['sex'] = intval($_POST['sex']);
     if (empty($_POST['sex'])) {
         $msg = array('s' => 400, 'm' => lang('sexrule'), 'd' => '');
         exit(json_output($msg));
     }
     $user = $_POST['user'];
     $user_id = $_POST['user_id'];
     include_once "PassportModel.class.php";
     $passmod = new PassportModel();
     $updates['user_email'] = $_POST['email'];
     if ($_POST['password'] != '') {
         $updates['user_password'] = PassportModel::encryptpwd($_POST['password'], $user);
     }
     $updates['user_nickname'] = htmlspecialchars($_POST['nickname']);
     $updates['user_sex'] = $_POST['sex'];
     // 1. update db user
     $row = $passmod->updateUser($updates, $user_id, $user);
     if ($row !== false) {
         $msg = array('s' => 200, 'm' => lang('success'), 'd' => '');
         exit(json_output($msg));
     } else {
         $msg = array('s' => 400, 'm' => lang('failed'), 'd' => '');
         exit(json_output($msg));
     }
 }
Ejemplo n.º 2
0
 function op_resetpwd()
 {
     if (empty($_POST['code'])) {
         show_message_goback(lang('invalidurl'));
     }
     if (empty($_POST['newpwd1']) or empty($_POST['newpwd2'])) {
         show_message_goback(lang('insertpwd'));
     }
     $new1 = $_POST['newpwd1'];
     $new2 = $_POST['newpwd2'];
     if (strlen($new1) < 6 or strlen($new2) < 6) {
         show_message_goback(lang('pwdrule'));
     }
     if (trim($new1) != trim($new2)) {
         show_message_goback(lang('pwdnotsame'));
     }
     $code = $_POST['code'];
     include_once "PassportModel.class.php";
     $passmod = new PassportModel();
     $row = $passmod->checkForget($code);
     if ($row) {
         if (false != $passmod->updatePassByUser($row['user'], PassportModel::encryptpwd($new1, $row['user']))) {
             $passmod->updateForgetPwd($row['user']);
             show_message(lang('pwdreset'));
             redirect($GLOBALS['gSiteInfo']['www_site_url'] . '/index.php/passport/login');
         } else {
             show_message_goback(lang('failture'));
         }
     } else {
         show_message(lang('invalidurl'));
         echo "<script> alert('" . lang('invalidurl') . "')</script>";
         redirect($GLOBALS['gSiteInfo']['www_site_url'] . '/index.php/passport/login');
     }
 }