Example #1
0
        if (empty($preview)) {
            require_once libfile('function/discuzcode');
            require_once libfile('function/followcode');
            $feedcontent = array('tid' => $tid, 'content' => followcode($post['message'], $post['tid'], $post['pid'], 1000));
            C::t('forum_threadpreview')->insert($feedcontent);
            C::t('forum_thread')->update_status_by_tid($tid, '512');
        } else {
            C::t('forum_threadpreview')->update_relay_by_tid($tid, 1);
        }
        showmessage('relay_feed_success', dreferer(), array(), array('showdialog' => true, 'closetime' => true));
    }
    $fastpost = $_G['setting']['fastpost'];
} elseif ($op == 'checkfeed') {
    header('Content-Type: text/javascript');
    require_once libfile("function/member");
    checkfollowfeed();
    exit;
} elseif ($op == 'getfeed') {
    $archiver = $_GET['archiver'] ? true : false;
    $uid = intval($_GET['uid']);
    $page = empty($_GET['page']) ? 1 : intval($_GET['page']);
    if ($page < 1) {
        $page = 1;
    }
    $perpage = 20;
    $start = ($page - 1) * $perpage;
    if ($uid) {
        $list = getfollowfeed($uid, 'self', $archiver, $start, $perpage);
    } else {
        $type = in_array($_GET['viewtype'], array('special', 'follow', 'other')) ? $_GET['viewtype'] : 'follow';
        $list = getfollowfeed($type == 'other' ? 0 : $_G['uid'], $type, $archiver, $start, $perpage);
function register()
{
    /*{{{*/
    require_once dirname(dirname(dirname(__FILE__))) . '/bigappjson.class.php';
    require_once libfile('function/misc');
    require_once libfile('function/member');
    require_once libfile('class/member');
    $userName = isset($_REQUEST["username"]) ? $_REQUEST["username"] : "";
    $password = isset($_REQUEST["password"]) ? $_REQUEST["password"] : "";
    $email = isset($_REQUEST["email"]) ? strtolower($_REQUEST["email"]) : "";
    global $_G;
    if (function_exists('iconv')) {
        $userName = iconv('UTF-8', CHARSET . '//ignore', $userName);
    } else {
        $userName = mb_convert_encoding($userName, CHARSET, 'UTF-8');
    }
    if (empty($userName) || empty($password) || empty($email)) {
        echo BIGAPPJSON::encode(array('error_code' => 2, 'error_msg' => lang('plugin/bigapp', 'empty_params'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'empty_params'))));
        die(0);
    }
    $userNamelen = dstrlen($userName);
    if ($userNamelen < 3) {
        echo BIGAPPJSON::encode(array('error_code' => 3, 'error_msg' => lang('plugin/bigapp', 'username_short'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_short'))));
        die(0);
    }
    if ($userNamelen > 15) {
        echo BIGAPPJSON::encode(array('error_code' => 4, 'error_msg' => lang('plugin/bigapp', 'username_long'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_long'))));
        die(0);
    }
    $ctlObj = new register_ctl();
    $ctlObj->setting = $_G['setting'];
    if (isset($ctlObj->setting['pwlength']) && $ctlObj->setting['pwlength']) {
        if (strlen($password) < $ctlObj->setting['pwlength']) {
            echo BIGAPPJSON::encode(array('error_code' => 5, 'error_msg' => lang('plugin/bigapp', 'password_length') . ' [ >= ' . $ctlObj->setting['pwlength'] . ' ]', 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'password_not_equal') . ' [ >= ' . $ctlObj->setting['pwlength'] . ' ]')));
            die(0);
        }
    }
    if (isset($ctlObj->setting['strongpw']) && $ctlObj->setting['strongpw']) {
        $strongpw_str = array();
        if (in_array(1, $ctlObj->setting['strongpw']) && !preg_match("/\\d+/", $password)) {
            $strongpw_str[] = lang('plugin/bigapp', 'password_number');
        }
        if (in_array(2, $ctlObj->setting['strongpw']) && !preg_match("/[a-z]+/", $password)) {
            $strongpw_str[] = lang('plugin/bigapp', 'password_lowercase_char');
        }
        if (in_array(3, $ctlObj->setting['strongpw']) && !preg_match("/[A-Z]+/", $password)) {
            $strongpw_str[] = lang('plugin/bigapp', 'password_uppercase_char');
        }
        if (in_array(4, $ctlObj->setting['strongpw']) && !preg_match("/[^a-zA-Z0-9]+/", $password)) {
            $strongpw_str[] = lang('plugin/bigapp', 'password_charset');
        }
        if ($strongpw_str) {
            echo BIGAPPJSON::encode(array('error_code' => 6, 'error_msg' => lang('plugin/bigapp', 'password_invalid') . ' [ ' . implode(', ', $strongpw_str) . ' ]', 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'password_invalid') . ' [ ' . implode(', ', $strongpw_str) . ' ]')));
            die(0);
        }
    }
    /*
    	if(!isset($_G['setting']['mobile']['mobileregister']) || !$_G['setting']['mobile']['mobileregister']){
    		echo BIGAPPJSON::encode(array('error_code' => 7, 'error_msg' => lang('plugin/bigapp', 'forbid_mobreg'), 
    				'Variables' => array('auth' => null),
                    'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_mobreg'))));
    		die(0);
    	}
    */
    loaducenter();
    if (!$ctlObj->setting['regclosed'] && (!$ctlObj->setting['regstatus'] || !$ctlObj->setting['ucactivation'])) {
        if (!$ctlObj->setting['regstatus']) {
            echo BIGAPPJSON::encode(array('error_code' => 8, 'error_msg' => lang('plugin/bigapp', 'forbid_registration'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_registration'))));
            die(0);
        }
    }
    if ($ctlObj->setting['regverify']) {
        if ($ctlObj->setting['areaverifywhite']) {
            $location = $whitearea = '';
            $location = trim(convertip($_G['clientip'], "./"));
            if ($location) {
                $whitearea = preg_quote(trim($ctlObj->setting['areaverifywhite']), '/');
                $whitearea = str_replace(array("\\*"), array('.*'), $whitearea);
                $whitearea = '.*' . $whitearea . '.*';
                $whitearea = '/^(' . str_replace(array("\r\n", ' '), array('.*|.*', ''), $whitearea) . ')$/i';
                if (@preg_match($whitearea, $location)) {
                    $ctlObj->setting['regverify'] = 0;
                }
            }
        }
        if ($_G['cache']['ipctrl']['ipverifywhite']) {
            foreach (explode("\n", $_G['cache']['ipctrl']['ipverifywhite']) as $ctrlip) {
                if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) {
                    $ctlObj->setting['regverify'] = 0;
                    break;
                }
            }
        }
    }
    if ($ctlObj->setting['regverify']) {
        $groupinfo['groupid'] = 8;
    } else {
        $groupinfo['groupid'] = $ctlObj->setting['newusergroupid'];
    }
    if (!$password || $password != addslashes($password)) {
        echo BIGAPPJSON::encode(array('error_code' => 9, 'error_msg' => lang('plugin/bigapp', 'password_invalid_char'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'password_invalid_char'))));
        die(0);
    }
    $censorexp = '/^(' . str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote($ctlObj->setting['censoruser'] = trim($ctlObj->setting['censoruser']), '/')) . ')$/i';
    if ($ctlObj->setting['censoruser'] && @preg_match($censorexp, $userName)) {
        echo BIGAPPJSON::encode(array('error_code' => 10, 'error_msg' => lang('plugin/bigapp', 'forbid_username'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_username'))));
        die(0);
    }
    if ($_G['cache']['ipctrl']['ipregctrl']) {
        foreach (explode("\n", $_G['cache']['ipctrl']['ipregctrl']) as $ctrlip) {
            if (preg_match("/^(" . preg_quote($ctrlip = trim($ctrlip), '/') . ")/", $_G['clientip'])) {
                $ctrlip = $ctrlip . '%';
                $ctlObj->setting['regctrl'] = $ctlObj->setting['ipregctrltime'];
                break;
            } else {
                $ctrlip = $_G['clientip'];
            }
        }
    } else {
        $ctrlip = $_G['clientip'];
    }
    if ($ctlObj->setting['regctrl']) {
        if (C::t('common_regip')->count_by_ip_dateline($ctrlip, $_G['timestamp'] - $ctlObj->setting['regctrl'] * 3600)) {
            echo BIGAPPJSON::encode(array('error_code' => 11, 'error_msg' => lang('plugin/bigapp', 'forbid_ip'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_ip'))));
            die(0);
        }
    }
    $setregip = null;
    if ($ctlObj->setting['regfloodctrl']) {
        $regip = C::t('common_regip')->fetch_by_ip_dateline($_G['clientip'], $_G['timestamp'] - 86400);
        if ($regip) {
            if ($regip['count'] >= $ctlObj->setting['regfloodctrl']) {
                echo BIGAPPJSON::encode(array('error_code' => 12, 'error_msg' => lang('plugin/bigapp', 'forbid_ip_today'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'forbid_ip_today'))));
                die(0);
            } else {
                $setregip = 1;
            }
        } else {
            $setregip = 2;
        }
    }
    $uid = uc_user_register($userName, $password, $email, '', '', $_G['clientip']);
    if ($uid <= 0) {
        if ($uid == -1) {
            echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'username_invalid_char'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_invalid_char'))));
        } elseif ($uid == -2) {
            echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'username_invalid_char'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_invalid_char'))));
        } elseif ($uid == -3) {
            echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'username_used'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'username_used'))));
        } elseif ($uid == -4) {
            echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'invalid_email'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'invalid_email'))));
        } elseif ($uid == -5) {
            echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'invalid_email'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'invalid_email'))));
        } elseif ($uid == -6) {
            echo BIGAPPJSON::encode(array('error_code' => 13, 'error_msg' => lang('plugin/bigapp', 'email_used'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'email_used'))));
        }
        die(0);
    }
    $_G['username'] = $userName;
    $password = md5(random(10));
    if ($setregip !== null) {
        if ($setregip == 1) {
            C::t('common_regip')->update_count_by_ip($_G['clientip']);
        } else {
            C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => 1, 'dateline' => $_G['timestamp']));
        }
    }
    $profile = $verifyarr = array();
    $emailstatus = 0;
    $init_arr = array('credits' => explode(',', $ctlObj->setting['initcredits']), 'profile' => $profile, 'emailstatus' => $emailstatus);
    C::t('common_member')->insert($uid, $userName, $password, $email, $_G['clientip'], $groupinfo['groupid'], $init_arr);
    if ($ctlObj->setting['regctrl'] || $ctlObj->setting['regfloodctrl']) {
        C::t('common_regip')->delete_by_dateline($_G['timestamp'] - ($ctlObj->setting['regctrl'] > 72 ? $ctlObj->setting['regctrl'] : 72) * 3600);
        if ($ctlObj->setting['regctrl']) {
            C::t('common_regip')->insert(array('ip' => $_G['clientip'], 'count' => -1, 'dateline' => $_G['timestamp']));
        }
    }
    if ($ctlObj->setting['regverify'] == 1) {
        $idstring = random(6);
        $authstr = $ctlObj->setting['regverify'] == 1 ? "{$_G['timestamp']}\t2\t{$idstring}" : '';
        C::t('common_member_field_forum')->update($uid, array('authstr' => $authstr));
        $verifyurl = "{$_G[siteurl]}member.php?mod=activate&amp;uid={$uid}&amp;id={$idstring}";
        $email_verify_message = lang('email', 'email_verify_message', array('username' => $username, 'bbname' => $ctlObj->setting['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $verifyurl));
        if (!sendmail("{$username} <{$email}>", lang('email', 'email_verify_subject'), $email_verify_message)) {
            runlog('sendmail', "{$email} sendmail failed.");
        }
    }
    require_once libfile('cache/userstats', 'function');
    build_cache_userstats();
    $_GET['regmessage'] = 'from bigapp client';
    $regmessage = dhtmlspecialchars($_GET['regmessage']);
    if ($ctlObj->setting['regverify'] == 2) {
        C::t('common_member_validate')->insert(array('uid' => $uid, 'submitdate' => $_G['timestamp'], 'moddate' => 0, 'admin' => '', 'submittimes' => 1, 'status' => 0, 'message' => $regmessage, 'remark' => ''), false, true);
        manage_addnotify('verifyuser');
    }
    setloginstatus(array('uid' => $uid, 'username' => $_G['username'], 'password' => $password, 'groupid' => $groupinfo['groupid']), 0);
    include_once libfile('function/stat');
    updatestat('register');
    checkfollowfeed();
    C::t('common_member_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP));
    ////////////////////////////////////////////////
    // 注册成功,绑定第三方openid
    $plat = $_GET["platform"];
    if ($plat == "qq") {
        include_once CUR_PATH . "/../qqconnect/bind.php";
    } else {
        if ($plat == "wechat") {
            include_once CUR_PATH . "/../wechatconnect/bind.php";
        }
    }
    ////////////////////////////////////////////////
    echo BIGAPPJSON::encode(array('error_code' => 0, 'error_msg' => lang('plugin/bigapp', 'regist_succ'), 'Message' => array('messageval' => 'register_succeed', 'messagestr' => lang('plugin/bigapp', 'regist_succ')), 'Variables' => array('auth' => 'in order to be comapatible')));
    die(0);
}
 function on_login()
 {
     global $_G;
     if ($_G['uid']) {
         $referer = dreferer();
         $ucsynlogin = $this->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
         $param = array('username' => $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['member']['uid']);
         showmessage('login_succeed', $referer ? $referer : './', $param, array('showdialog' => 1, 'locationtime' => true, 'extrajs' => $ucsynlogin));
     }
     $from_connect = $this->setting['connect']['allow'] && !empty($_GET['from']) ? 1 : 0;
     $seccodecheck = $from_connect ? false : $this->setting['seccodestatus'] & 2;
     $seccodestatus = !empty($_GET['lssubmit']) ? false : $seccodecheck;
     $invite = getinvite();
     if (!submitcheck('loginsubmit', 1, $seccodestatus)) {
         $auth = '';
         $username = !empty($_G['cookie']['loginuser']) ? dhtmlspecialchars($_G['cookie']['loginuser']) : '';
         if (!empty($_GET['auth'])) {
             list($username, $password, $questionexist) = explode("\t", authcode($_GET['auth'], 'DECODE'));
             $username = dhtmlspecialchars($username);
             $auth = dhtmlspecialchars($_GET['auth']);
         }
         $cookietimecheck = !empty($_G['cookie']['cookietime']) || !empty($_GET['cookietime']) ? 'checked="checked"' : '';
         if ($seccodecheck) {
             $seccode = random(6, 1) + $seccode[0] * 1000000;
         }
         if ($this->extrafile && file_exists($this->extrafile)) {
             require_once $this->extrafile;
         }
         $navtitle = lang('core', 'title_login');
         include template($this->template);
     } else {
         if (!empty($_GET['auth'])) {
             list($_GET['username'], $_GET['password']) = daddslashes(explode("\t", authcode($_GET['auth'], 'DECODE')));
         }
         if (!($_G['member_loginperm'] = logincheck($_GET['username']))) {
             showmessage('login_strike');
         }
         if ($_GET['fastloginfield']) {
             $_GET['loginfield'] = $_GET['fastloginfield'];
         }
         $_G['uid'] = $_G['member']['uid'] = 0;
         $_G['username'] = $_G['member']['username'] = $_G['member']['password'] = '';
         if (!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) {
             showmessage('profile_passwd_illegal');
         }
         $result = userlogin($_GET['username'], $_GET['password'], $_GET['questionid'], $_GET['answer'], $this->setting['autoidselect'] ? 'auto' : $_GET['loginfield'], $_G['clientip']);
         $uid = $result['ucresult']['uid'];
         if (!empty($_GET['lssubmit']) && ($result['ucresult']['uid'] == -3 || $seccodecheck)) {
             $_GET['username'] = $result['ucresult']['username'];
             $this->logging_more($result['ucresult']['uid'] == -3);
         }
         if ($result['status'] == -1) {
             if (!$this->setting['fastactivation']) {
                 $auth = authcode($result['ucresult']['username'] . "\t" . FORMHASH, 'ENCODE');
                 showmessage('location_activation', 'member.php?mod=' . $this->setting['regname'] . '&action=activation&auth=' . rawurlencode($auth) . '&referer=' . rawurlencode(dreferer()), array(), array('location' => true));
             } else {
                 $init_arr = explode(',', $this->setting['initcredits']);
                 $groupid = $this->setting['regverify'] ? 8 : $this->setting['newusergroupid'];
                 C::t('common_member')->insert($uid, $result['ucresult']['username'], md5(random(10)), $result['ucresult']['email'], $_G['clientip'], $groupid, $init_arr);
                 $result['member'] = getuserbyuid($uid);
                 $result['status'] = 1;
             }
         }
         if ($result['status'] > 0) {
             if ($this->extrafile && file_exists($this->extrafile)) {
                 require_once $this->extrafile;
             }
             setloginstatus($result['member'], $_GET['cookietime'] ? 2592000 : 0);
             checkfollowfeed();
             if ($_G['member']['lastip'] && $_G['member']['lastvisit']) {
                 dsetcookie('lip', $_G['member']['lastip'] . ',' . $_G['member']['lastvisit']);
             }
             C::t('common_member_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP));
             $ucsynlogin = $this->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
             if ($invite['id']) {
                 $result = C::t('common_invite')->count_by_uid_fuid($invite['uid'], $uid);
                 if (!$result) {
                     C::t('common_invite')->update($invite['id'], array('fuid' => $uid, 'fusername' => $_G['username']));
                     updatestat('invite');
                 } else {
                     $invite = array();
                 }
             }
             if ($invite['uid']) {
                 require_once libfile('function/friend');
                 friend_make($invite['uid'], $invite['username'], false);
                 dsetcookie('invite_auth', '');
                 if ($invite['appid']) {
                     updatestat('appinvite');
                 }
             }
             $param = array('username' => $result['ucresult']['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['member']['uid'], 'groupid' => $_G['groupid'], 'syn' => $ucsynlogin ? 1 : 0);
             $extra = array('showdialog' => true, 'locationtime' => true, 'extrajs' => $ucsynlogin);
             $loginmessage = $_G['groupid'] == 8 ? 'login_succeed_inactive_member' : 'login_succeed';
             $location = $invite || $_G['groupid'] == 8 ? 'home.php?mod=space&do=home' : dreferer();
             if (empty($_GET['handlekey']) || !empty($_GET['lssubmit'])) {
                 if (defined('IN_MOBILE')) {
                     showmessage($loginmessage, $location, $param, array('location' => true));
                 } else {
                     if (!empty($_GET['lssubmit'])) {
                         if (!$ucsynlogin) {
                             $extra['location'] = true;
                         }
                         showmessage($loginmessage, $location, $param, $extra);
                     } else {
                         $href = str_replace("'", "\\'", $location);
                         showmessage('location_login_succeed', $location, array(), array('showid' => 'succeedmessage', 'extrajs' => '<script type="text/javascript">' . 'setTimeout("window.location.href =\'' . $href . '\';", 3000);' . '$(\'succeedmessage_href\').href = \'' . $href . '\';' . '$(\'main_message\').style.display = \'none\';' . '$(\'main_succeed\').style.display = \'\';' . '$(\'succeedlocation\').innerHTML = \'' . lang('message', $loginmessage, $param) . '\';</script>' . $ucsynlogin, 'striptags' => false, 'showdialog' => true));
                     }
                 }
             } else {
                 showmessage($loginmessage, $location, $param, $extra);
             }
         } else {
             $password = preg_replace("/^(.{" . round(strlen($_GET['password']) / 4) . "})(.+?)(.{" . round(strlen($_GET['password']) / 6) . "})\$/s", "\\1***\\3", $_GET['password']);
             $errorlog = dhtmlspecialchars(TIMESTAMP . "\t" . ($result['ucresult']['username'] ? $result['ucresult']['username'] : $_GET['username']) . "\t" . $password . "\t" . "Ques #" . intval($_GET['questionid']) . "\t" . $_G['clientip']);
             writelog('illegallog', $errorlog);
             loginfailed($_GET['username']);
             $fmsg = $result['ucresult']['uid'] == '-3' ? empty($_GET['questionid']) || $answer == '' ? 'login_question_empty' : 'login_question_invalid' : 'login_invalid';
             if ($_G['member_loginperm'] > 1) {
                 showmessage($fmsg, '', array('loginperm' => $_G['member_loginperm'] - 1));
             } elseif ($_G['member_loginperm'] == -1) {
                 showmessage('login_password_invalid');
             } else {
                 showmessage('login_strike');
             }
         }
     }
 }
Example #4
0
	function on_login() {
		global $_G;
		if($_G['uid']) {
			$referer = dreferer();
			$ucsynlogin = $this->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
			$param = array('username' => $_G['member']['username'], 'usergroup' => $_G['group']['grouptitle'], 'uid' => $_G['member']['uid']);
			showmessage('login_succeed', $referer ? $referer : './', $param, array('showdialog' => 1, 'locationtime' => true, 'extrajs' => $ucsynlogin));
		}

		list($seccodecheck) = seccheck('login');
		if(!empty($_GET['auth'])) {
			$dauth = authcode($_GET['auth'], 'DECODE', $_G['config']['security']['authkey']);
			list(,,,$secchecklogin2) = explode("\t", $dauth);
			if($secchecklogin2) {
				$seccodecheck = true;
			}
		}
		$seccodestatus = !empty($_GET['lssubmit']) ? false : $seccodecheck;
		$invite = getinvite();

		if(!submitcheck('loginsubmit', 1, $seccodestatus)) {

			$auth = '';
			$username = !empty($_G['cookie']['loginuser']) ? dhtmlspecialchars($_G['cookie']['loginuser']) : '';

			if(!empty($_GET['auth'])) {
				list($username, $password, $questionexist) = explode("\t", authcode($_GET['auth'], 'DECODE', $_G['config']['security']['authkey']));
				$username = dhtmlspecialchars($username);
				$auth = dhtmlspecialchars($_GET['auth']);
			}

			$cookietimecheck = !empty($_G['cookie']['cookietime']) || !empty($_GET['cookietime']) ? 'checked="checked"' : '';

			if($seccodecheck) {
				$seccode = random(6, 1) + $seccode{0} * 1000000;
			}

			if($this->extrafile && file_exists($this->extrafile)) {
				require_once $this->extrafile;
			}

			$navtitle = lang('core', 'title_login');
			include template($this->template);

		} else {

			if(!empty($_GET['auth'])) {
				list($_GET['username'], $_GET['password']) = daddslashes(explode("\t", authcode($_GET['auth'], 'DECODE', $_G['config']['security']['authkey'])));
			}

			$loginhash = !empty($_GET['loginhash']) && preg_match('/^\w+$/', $_GET['loginhash']) ? $_GET['loginhash'] : '';

			if(!($_G['member_loginperm'] = logincheck($_GET['username']))) {
				captcha::report($_G['clientip']);
				showmessage('login_strike');
			}
			if($_GET['fastloginfield']) {
				$_GET['loginfield'] = $_GET['fastloginfield'];
			}
			$_G['uid'] = $_G['member']['uid'] = 0;
			$_G['username'] = $_G['member']['username'] = $_G['member']['password'] = '';
			if(!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) {
				showmessage('profile_passwd_illegal');
			}
			$result = userlogin($_GET['username'], $_GET['password'], $_GET['questionid'], $_GET['answer'], $this->setting['autoidselect'] ? 'auto' : $_GET['loginfield'], $_G['clientip']);
			$uid = $result['ucresult']['uid'];

			if(!empty($_GET['lssubmit']) && ($result['ucresult']['uid'] == -3 || $seccodecheck)) {
				$_GET['username'] = $result['ucresult']['username'];
				$this->logging_more($result['ucresult']['uid'] == -3);
			}

			if($result['status'] == -1) {
				if(!$this->setting['fastactivation']) {
					$auth = authcode($result['ucresult']['username']."\t".FORMHASH, 'ENCODE');
					showmessage('location_activation', 'member.php?mod='.$this->setting['regname'].'&action=activation&auth='.rawurlencode($auth).'&referer='.rawurlencode(dreferer()), array(), array('location' => true));
				} else {
					$init_arr = explode(',', $this->setting['initcredits']);
					$groupid = $this->setting['regverify'] ? 8 : $this->setting['newusergroupid'];

					C::t('common_member')->insert($uid, $result['ucresult']['username'], md5(random(10)), $result['ucresult']['email'], $_G['clientip'], $groupid, $init_arr);
					$result['member'] = getuserbyuid($uid);
					$result['status'] = 1;
				}
			}

			if($result['status'] > 0) {

				if($this->extrafile && file_exists($this->extrafile)) {
					require_once $this->extrafile;
				}

				setloginstatus($result['member'], $_GET['cookietime'] ? 2592000 : 0);
				checkfollowfeed();
				if($_G['group']['forcelogin']) {
					if($_G['group']['forcelogin'] == 1) {
						clearcookies();
						showmessage('location_login_force_qq');
					} elseif($_G['group']['forcelogin'] == 2 && $_GET['loginfield'] != 'email') {
						clearcookies();
						showmessage('location_login_force_mail');
					}
				}

				if($_G['member']['lastip'] && $_G['member']['lastvisit']) {
					dsetcookie('lip', $_G['member']['lastip'].','.$_G['member']['lastvisit']);
				}
				C::t('common_member_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'port' => $_G['remoteport'], 'lastvisit' =>TIMESTAMP, 'lastactivity' => TIMESTAMP));
				$ucsynlogin = $this->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';

				$pwold = false;
				if($this->setting['strongpw'] && !$this->setting['pwdsafety']) {
					if(in_array(1, $this->setting['strongpw']) && !preg_match("/\d+/", $_GET['password'])) {
						$pwold = true;
					}
					if(in_array(2, $this->setting['strongpw']) && !preg_match("/[a-z]+/", $_GET['password'])) {
						$pwold = true;
					}
					if(in_array(3, $this->setting['strongpw']) && !preg_match("/[A-Z]+/", $_GET['password'])) {
						$pwold = true;
					}
					if(in_array(4, $this->setting['strongpw']) && !preg_match("/[^a-zA-z0-9]+/", $_GET['password'])) {
						$pwold = true;
					}
				}

				if($_G['member']['adminid'] != 1) {
					if($this->setting['accountguard']['loginoutofdate'] && $_G['member']['lastvisit'] && TIMESTAMP - $_G['member']['lastvisit'] > 90 * 86400) {
						C::t('common_member')->update($_G['uid'], array('freeze' => 2));
						C::t('common_member_validate')->insert(array(
							'uid' => $_G['uid'],
							'submitdate' => TIMESTAMP,
							'moddate' => 0,
							'admin' => '',
							'submittimes' => 1,
							'status' => 0,
							'message' => '',
							'remark' => '',
						), false, true);
						manage_addnotify('verifyuser');
						showmessage('location_login_outofdate', 'home.php?mod=spacecp&ac=profile&op=password&resend=1', array('type' => 1), array('showdialog' => true, 'striptags' => false, 'locationtime' => true));
					}

					if($this->setting['accountguard']['loginpwcheck'] && $pwold) {
						$freeze = $pwold;
						if($this->setting['accountguard']['loginpwcheck'] == 2 && $freeze) {
							C::t('common_member')->update($_G['uid'], array('freeze' => 1));
						}
					}
				}

				$seccheckrule = & $_G['setting']['seccodedata']['rule']['login'];
				if($seccheckrule['allow'] == 2) {
					if($seccheckrule['nolocal']) {
						require_once libfile('function/misc');
						$lastipConvert = process_ipnotice(convertip($_G['member']['lastip']));
						$nowipConvert = process_ipnotice(convertip($_G['clientip']));
						if($lastipConvert != $nowipConvert && stripos($lastipConvert, $nowipConvert) == false && stripos($nowipConvert, $lastipConvert) == false) {
							$seccodecheck = true;
						}
					}
					if(!$seccodecheck && $seccheckrule['pwsimple'] && $pwold) {
						$seccodecheck = true;
					}
					if(!$seccodecheck && $seccheckrule['outofday'] && $_G['member']['lastvisit'] && TIMESTAMP - $_G['member']['lastvisit'] > $seccheckrule['outofday'] * 86400) {
						$seccodecheck = true;
					}
					if(!$seccodecheck && $_G['member_loginperm'] < 4) {
						$seccodecheck = true;
					}
					if(!$seccodecheck && $seccheckrule['numiptry']) {
						$seccodecheck = failedipcheck($seccheckrule['numiptry'], $seccheckrule['timeiptry']);
					}
					if($seccodecheck && !$secchecklogin2) {
						clearcookies();
						$auth = authcode($_GET['username']."\t".$_GET['password']."\t".($result['ucresult']['uid'] == -3 ? 1 : 0)."\t1", 'ENCODE', $_G['config']['security']['authkey']);
						$location = 'member.php?mod=logging&action=login&auth='.rawurlencode($auth).'&referer='.rawurlencode(dreferer()).(!empty($_GET['cookietime']) ? '&cookietime=1' : '');
						if(defined('IN_MOBILE')) {
							showmessage('login_seccheck2', $location);
						} else {
							$js = '<script type="text/javascript">location.href=\''.$location.'\'</script>';
							showmessage('login_seccheck2', '', array('type' => 1), array('extrajs' => $js));
						}
					}
				}

				if($invite['id']) {
					$result = C::t('common_invite')->count_by_uid_fuid($invite['uid'], $uid);
					if(!$result) {
						C::t('common_invite')->update($invite['id'], array('fuid'=>$uid, 'fusername'=>$_G['username']));
						updatestat('invite');
					} else {
						$invite = array();
					}
				}
				if($invite['uid']) {
					require_once libfile('function/friend');
					friend_make($invite['uid'], $invite['username'], false);
					dsetcookie('invite_auth', '');
					if($invite['appid']) {
						updatestat('appinvite');
					}
				}

				$param = array(
					'username' => $result['ucresult']['username'],
					'usergroup' => $_G['group']['grouptitle'],
					'uid' => $_G['member']['uid'],
					'groupid' => $_G['groupid'],
					'syn' => $ucsynlogin ? 1 : 0
				);

				$extra = array(
					'showdialog' => true,
					'locationtime' => true,
					'extrajs' => $ucsynlogin
				);

				if(!$freeze || !$this->setting['accountguard']['loginpwcheck']) {
					$loginmessage = $_G['groupid'] == 8 ? 'login_succeed_inactive_member' : 'login_succeed';
					$location = $invite || $_G['groupid'] == 8 ? 'home.php?mod=space&do=home' : dreferer();
				} else {
					$loginmessage = 'login_succeed_password_change';
					$location = 'home.php?mod=spacecp&ac=profile&op=password';
					$_GET['lssubmit'] = 0;
				}
				if(empty($_GET['handlekey']) || !empty($_GET['lssubmit'])) {
					if(defined('IN_MOBILE')) {
						showmessage($loginmessage, $location, $param, array('location' => true));
					} else {
						if(!empty($_GET['lssubmit'])) {
							if(!$ucsynlogin) {
								$extra['location'] = true;
							}
							showmessage($loginmessage, $location, $param, $extra);
						} else {
							$href = str_replace("'", "\'", $location);
							showmessage('location_login_succeed', $location, array(),
								array(
									'showid' => 'succeedmessage',
									'extrajs' => '<script type="text/javascript">'.
										'setTimeout("window.location.href =\''.$href.'\';", 3000);'.
										'$(\'succeedmessage_href\').href = \''.$href.'\';'.
										'$(\'main_message\').style.display = \'none\';'.
										'$(\'main_succeed\').style.display = \'\';'.
										'$(\'succeedlocation\').innerHTML = \''.lang('message', $loginmessage, $param).'\';</script>'.$ucsynlogin,
									'striptags' => false,
									'showdialog' => true
								)
							);
						}
					}
				} else {
					showmessage($loginmessage, $location, $param, $extra);
				}
			} else {
				$password = preg_replace("/^(.{".round(strlen($_GET['password']) / 4)."})(.+?)(.{".round(strlen($_GET['password']) / 6)."})$/s", "\\1***\\3", $_GET['password']);
				$errorlog = dhtmlspecialchars(
					TIMESTAMP."\t".
					($result['ucresult']['username'] ? $result['ucresult']['username'] : $_GET['username'])."\t".
					$password."\t".
					"Ques #".intval($_GET['questionid'])."\t".
					$_G['clientip']);
				writelog('illegallog', $errorlog);
				loginfailed($_GET['username']);
				failedip();
				$fmsg = $result['ucresult']['uid'] == '-3' ? (empty($_GET['questionid']) || $answer == '' ? 'login_question_empty' : 'login_question_invalid') : 'login_invalid';
				if($_G['member_loginperm'] > 1) {
					showmessage($fmsg, '', array('loginperm' => $_G['member_loginperm'] - 1));
				} elseif($_G['member_loginperm'] == -1) {
					showmessage('login_password_invalid');
				} else {
					showmessage('login_strike');
				}
			}

		}

	}
Example #5
0
 /**
  * 登录写入缓存并改变登录状态
  * 
  * @param array $userInfo 将要登录的用户信息.
  * @param mixed $uid      将要登录用户的uid.
  *
  */
 public static function updateCookie($userInfo = array(), $uid)
 {
     require_once libfile('function/member');
     // discuz的源码,修改有未知风险,所以采用赋值的方式.
     $result['member'] = $userInfo;
     $_G['uid'] = $uid;
     setloginstatus($result['member'], $_GET['cookietime'] ? 2592000 : 0);
     checkfollowfeed();
     C::t('common_member_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP));
     // uc同步登录写入cookie有问题,暂时注释,待以后修复 9.26
     // $ucsynlogin = $ctlObj->setting['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
     if ($invite['id']) {
         $result = C::t('common_invite')->count_by_uid_fuid($invite['uid'], $uid);
         if (!$result) {
             C::t('common_invite')->update($invite['id'], array('fuid' => $uid, 'fusername' => $_G['username']));
             updatestat('invite');
         } else {
             $invite = array();
         }
     }
     if ($invite['uid']) {
         require_once libfile('function/friend');
         friend_make($invite['uid'], $invite['username'], false);
         dsetcookie('invite_auth', '');
         if ($invite['appid']) {
             updatestat('appinvite');
         }
     }
 }
Example #6
0
 function login()
 {
     global $_G;
     $userName = null;
     $password = null;
     if (isset($_REQUEST['username'])) {
         $userName = $_REQUEST['username'];
     }
     if (isset($_REQUEST['password'])) {
         $password = $_REQUEST['password'];
     }
     if (isset($_REQUEST['questionid'])) {
         $questionid = intval($_REQUEST['questionid']);
     } else {
         $questionid = 0;
     }
     if (isset($_REQUEST['answer'])) {
         $answer = $_REQUEST['answer'];
     } else {
         $answer = '';
     }
     if (function_exists('iconv')) {
         $userName = iconv('UTF-8', CHARSET . '//ignore', $userName);
         $answer = iconv('UTF-8', CHARSET . '//ignore', $answer);
     } else {
         $userName = mb_convert_encoding($userName, CHARSET, 'UTF-8');
         $answer = mb_convert_encoding($answer, CHARSET, 'UTF-8');
     }
     $_G['uid'] = $_G['member']['uid'] = 0;
     $_G['username'] = $_G['member']['username'] = $_G['member']['password'] = '';
     if (empty($userName) || empty($password) || $password != addslashes($password)) {
         echo BIGAPPJSON::encode(array('error_code' => 2, 'error_msg' => lang('plugin/bigapp', 'invalid_param'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'invalid_param'))));
         die(0);
     }
     require_once dirname(dirname(dirname(__FILE__))) . '/bigappjson.class.php';
     require_once libfile('function/misc');
     require_once libfile('function/mail');
     loaducenter();
     if (!($_G['member_loginperm'] = logincheck($userName))) {
         echo BIGAPPJSON::encode(array('error_code' => 3, 'error_msg' => lang('plugin/bigapp', 'too_many_errors'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'too_many_errors'))));
         die(0);
     }
     $result = userlogin($userName, $password, $questionid, $answer, 'username', $_G['clientip']);
     if ($result['ucresult']['uid'] == '-3') {
         /*
         			$sql = 'SELECT * FROM ' . DB::table('common_member') . " WHERE username = '******'";
         			$query = DB::query($sql);
         			$userInfo = array();
         			while($tmp = DB::fetch($query)) {
         				$userInfo = $tmp;
         				break;
         			}
         			
         			if(empty($userInfo)){
         				echo BIGAPPJSON::encode(array('error_code' => 4, 'error_msg' => lang('plugin/bigapp', 'user_not_exists'), 
         					'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'user_not_exists'))));
         				die(0);
         			}else */
         //if(!empty($answer)){
         echo BIGAPPJSON::encode(array('error_code' => 9, 'error_msg' => lang('plugin/bigapp', 'user_seq_question'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'user_seq_question'))));
         die(0);
         //}
         /*
         $result['ucresult']['uid'] = $userInfo['uid'];
         $result['member'] = $userInfo;
         $result['status'] = 1;
         */
     }
     $uid = $_G['uid'] = $result['ucresult']['uid'];
     $userName = $result['ucresult']['username'];
     $userAvatar = avatar($_G['uid'], 'big', true);
     $userAvatar = str_replace("\r", '', $userAvatar);
     $userAvatar = str_replace("\n", '', $userAvatar);
     $ctlObj = new logging_ctl();
     $ctlObj->setting = $_G['setting'];
     if ($result['status'] == -1) {
         if (!$ctlObj->setting['fastactivation']) {
             echo BIGAPPJSON::encode(array('error_code' => 5, 'error_msg' => lang('plugin/bigapp', 'activate_first'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'login_failed'))));
             die(0);
         }
         $init_arr = explode(',', $ctlObj->setting['initcredits']);
         $groupid = $ctlObj->setting['regverify'] ? 8 : $ctlObj->setting['newusergroupid'];
         C::t('common_member')->insert($uid, $result['ucresult']['username'], md5(random(10)), $result['ucresult']['email'], $_G['clientip'], $groupid, $init_arr);
         $result['member'] = getuserbyuid($uid);
         $result['status'] = 1;
     }
     if ($result['status'] > 0) {
         if ($ctlObj->extrafile && file_exists($ctlObj->extrafile)) {
             require_once $ctlObj->extrafile;
         }
         setloginstatus($result['member'], $_GET['cookietime'] ? 2592000 : 0);
         checkfollowfeed();
         C::t('common_member_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP));
         if (isset($result['member']['password'])) {
             unset($result['member']['password']);
         }
         if (isset($result['member']['credits'])) {
             unset($result['member']['credits']);
         }
         echo BIGAPPJSON::encode(array('error_code' => 0, 'error_msg' => lang('plugin/bigapp', 'login_succ'), 'data' => $result['member'], 'Message' => array('messageval' => 'login_succeed', 'messagestr' => lang('plugin/bigapp', 'login_succ')), 'Variables' => array('auth' => 'in order to be comapatible')));
         die(0);
     }
     if ($_G['member_loginperm'] > 1) {
         echo BIGAPPJSON::encode(array('error_code' => 6, 'error_msg' => lang('plugin/bigapp', 'login_failed'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'login_failed'))));
     } elseif ($_G['member_loginperm'] == -1) {
         echo BIGAPPJSON::encode(array('error_code' => 7, 'error_msg' => lang('plugin/bigapp', 'error_password'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'error_password'))));
     } else {
         echo BIGAPPJSON::encode(array('error_code' => 8, 'error_msg' => lang('plugin/bigapp', 'too_many_errors'), 'Variables' => array('auth' => null), 'Message' => array('messageval' => 'for comaptible', 'messagestr' => lang('plugin/bigapp', 'too_many_errors'))));
     }
     die(0);
 }