<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
define('SCR', 'redirect');
define('IN_IORANGE', true);
require_once 'include/init.php';

$mobile = S::gp('mobile','G');
$sql = 'SELECT m.uid,m.username,m.mobile,m.groupid,ug.gptype FROM '.Members::table().' AS m INNER JOIN '.UserGroups::table().' AS ug ON ug.groupid = m.groupid WHERE m.mobile='.S::sqlEscape($mobile);
$member = $db->setQueryString($sql)->find(true);
if (!empty($member))
{
    $m = trim(S::gp('content','G'));
    if ('25800#mm' == $m)
    {
        $subject = '[系统消息]密码重设成功';
        $content = '密码重设成功，您的新密码为手机号的最后6位，请尽快从’书房‘的’修改密码‘处修改新的密码，然后保存新的书签！';
        $value['password'] = md5(substr($mobile, -6));
    }
    else
    {
        $subject = '[系统消息]短信验证成功';
        $content = '系统已经收到您的验证短信并且验证成功！';
        $value['verify'] = 1;
        $value['groupid'] = ($member['groupid'] != 4 && $member['groupid'] != 5 && $member['gptype'] != 'special') ? 9 : $member['groupid'];

        $feed = '{{'.$member['uid'].'}}成功晋升验证会员';
        iFeed::single()->create($feed, $member['uid'], 'member');
    }

    $db->update(Members::table())->value($value)->where(array('uid'=>$member['uid']))->q();
    try
    {
        Members::sendMessage($subject,$content,1,'admin',$member['uid']);
    }
    catch (Exception $exce)
    {
    }
    echo '<?xml version="1.0" encoding="GB2312"><mob version="1.0"><result>1</result><resultInfo>完成</resultInfo></mob>';
}