Esempio n. 1
0
if (count($payary) > 0) {
    $money = 0;
    $egold = 0;
    $pids = '';
    foreach ($payary as $v) {
        $money += $v['money'];
        $egold += $v['egold'];
        if (!empty($pids)) {
            $pids .= ', ';
        }
        $pids .= $v['payid'];
    }
    $buyname = $_SESSION['jieqiUserName'];
    $buyid = $_SESSION['jieqiUserId'];
    include_once JIEQI_ROOT_PATH . '/class/users.php';
    $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler');
    if (isset($jieqiPayset[JIEQI_PAY_TYPE]['scorerate'])) {
        $addscore = ceil($egold * $jieqiPayset[JIEQI_PAY_TYPE]['scorerate']);
    } else {
        $addscore = 0;
    }
    $ret = $users_handler->income($buyid, $egold, $jieqiPayset[JIEQI_PAY_TYPE]['paysilver'], $addscore);
    $sql = "UPDATE " . jieqi_dbprefix('pay_paylog') . " SET buyid='" . intval($buyid) . "', buyname='" . jieqi_dbslashes($buyname) . "', rettime='" . intval(JIEQI_NOW_TIME) . "', payflag='1' WHERE payid IN (" . $pids . ')';
    $ret = $paylog_handler->db->query($sql);
    if (!$ret) {
        jieqi_printfail($jieqiLang['pay']['save_paylog_failure']);
    }
    jieqi_msgwin(LANG_DO_SUCCESS, sprintf($jieqiLang['pay']['call_cinfirm_success'], jieqi_htmlstr($buyname), sprintf('%0.2f', $money / 100), $egold, JIEQI_EGOLD_NAME));
} else {
    jieqi_printfail($jieqiLang['pay']['no_buy_record']);
}
Esempio n. 2
0
function pack_down_do($path, $score, $changescore = true, $fname = '')
{
    global $jieqiLang;
    $score = intval($score);
    $ftype = strrchr(trim(strtolower($path)), ".");
    if ($score > 0) {
        jieqi_checklogin();
        jieqi_loadlang('down', JIEQI_MODULE_NAME);
        if ($_SESSION['jieqiUserScore'] < $score) {
            jieqi_printfail(sprintf($jieqiLang['article']['low_down_score'], $score));
        } else {
            if (!is_file($path)) {
                return false;
            }
            //先扣分再下载
            if ($changescore) {
                include_once JIEQI_ROOT_PATH . '/class/users.php';
                $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler');
                $users_handler->changeScore($_SESSION['jieqiUserId'], $score, false, false);
                @session_write_close();
            }
            $filename = empty($fname) ? basename($path) : jieqi_htmlstr($fname) . $ftype;
            pack_down_file($path, $filename);
        }
    } else {
        if (!is_file($path)) {
            return false;
        }
        $filename = empty($fname) ? basename($path) : jieqi_htmlstr($fname) . $ftype;
        pack_down_file($path, $filename);
    }
    return true;
}
Esempio n. 3
0
/**
 * 用户登录后处理
 * 
 * @param      object      $jieqiUsers 用户对象
 * @access     public
 * @return     bool
 */
function jieqi_loginprocess($jieqiUsers, $usecookie = 0)
{
    global $jieqiConfigs;
    global $jieqiHonors;
    global $jieqiGroups;
    if (!isset($jieqiConfigs['system'])) {
        jieqi_getconfigs('system', 'configs');
    }
    include_once JIEQI_ROOT_PATH . '/class/users.php';
    $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler');
    //更新在线用户表
    include_once JIEQI_ROOT_PATH . '/class/online.php';
    $online_handler =& JieqiOnlineHandler::getInstance('JieqiOnlineHandler');
    $criteria = new CriteriaCompo(new Criteria('uid', $jieqiUsers->getVar('uid', 'n')));
    $criteria->setSort('updatetime');
    $criteria->setOrder('DESC');
    $online_handler->queryObjects($criteria);
    $online = $online_handler->getObject();
    //读cookie信息
    $jieqi_user_info = array();
    if (!empty($_COOKIE['jieqiUserInfo'])) {
        $jieqi_user_info = jieqi_strtosary($_COOKIE['jieqiUserInfo']);
    } else {
        $jieqi_user_info = array();
    }
    $jieqi_visit_info = array();
    if (!empty($_COOKIE['jieqiVisitInfo'])) {
        $jieqi_visit_info = jieqi_strtosary($_COOKIE['jieqiVisitInfo']);
    } else {
        $jieqi_visit_info = array();
    }
    if (is_object($online)) {
        $ip = jieqi_userip();
        if (JIEQI_SESSION_EXPRIE > 0) {
            $exprie_time = JIEQI_SESSION_EXPRIE;
        } else {
            $exprie_time = @ini_get('session.gc_maxlifetime');
        }
        if (empty($exprie_time)) {
            $exprie_time = 1800;
        }
        if (defined('JIEQI_DENY_RELOGIN') && JIEQI_DENY_RELOGIN == 1 && JIEQI_NOW_TIME - $online->getVar('updatetime') < $exprie_time && $online->getVar('ip', 'n') != $ip && $jieqi_visit_info['jieqiUserId'] != $jieqiUsers->getVar('uid')) {
            return -8;
        }
        $tmpvar = strlen($jieqiUsers->getVar('name', 'q')) > 0 ? $jieqiUsers->getVar('name', 'q') : $jieqiUsers->getVar('uname', 'q');
        $sql = "UPDATE " . jieqi_dbprefix('system_online') . " SET uid=" . $jieqiUsers->getVar('uid', 'q') . ", sid='" . jieqi_dbslashes(session_id()) . "', uname='" . $jieqiUsers->getVar('uname', 'q') . "', name='" . $tmpvar . "', pass='******'pass', 'q') . "',email='" . $jieqiUsers->getVar('email', 'q') . "', groupid=" . $jieqiUsers->getVar('groupid', 'q') . ", updatetime=" . JIEQI_NOW_TIME . ", ip='" . jieqi_dbslashes($ip) . "' WHERE uid=" . $jieqiUsers->getVar('uid', 'q') . " OR sid='" . jieqi_dbslashes(session_id()) . "'";
        $online_handler->db->query($sql);
    } else {
        include_once JIEQI_ROOT_PATH . '/include/visitorinfo.php';
        $online = $online_handler->create();
        $online->setVar('uid', $jieqiUsers->getVar('uid', 'n'));
        $online->setVar('siteid', JIEQI_SITE_ID);
        $online->setVar('sid', session_id());
        $online->setVar('uname', $jieqiUsers->getVar('uname', 'n'));
        $tmpvar = strlen($jieqiUsers->getVar('name', 'n')) > 0 ? $jieqiUsers->getVar('name', 'n') : $jieqiUsers->getVar('uname', 'n');
        $online->setVar('name', $tmpvar);
        $online->setVar('pass', $jieqiUsers->getVar('pass', 'n'));
        $online->setVar('email', $jieqiUsers->getVar('email', 'n'));
        $online->setVar('groupid', $jieqiUsers->getVar('groupid', 'n'));
        $tmpvar = JIEQI_NOW_TIME;
        $online->setVar('logintime', $tmpvar);
        $online->setVar('updatetime', $tmpvar);
        $online->setVar('operate', '');
        $tmpvar = VisitorInfo::getIp();
        $online->setVar('ip', $tmpvar);
        $online->setVar('browser', VisitorInfo::getBrowser());
        $online->setVar('os', VisitorInfo::getOS());
        $location = VisitorInfo::getIpLocation($tmpvar);
        if (JIEQI_SYSTEM_CHARSET == 'big5') {
            include_once JIEQI_ROOT_PATH . '/include/changecode.php';
            $location = jieqi_gb2big5($location);
        }
        $online->setVar('location', $location);
        $online->setVar('state', '0');
        $online->setVar('flag', '0');
        $online_handler->insert($online);
    }
    //删除过期的在线用户
    unset($criteria);
    $criteria = new CriteriaCompo(new Criteria('updatetime', JIEQI_NOW_TIME - $jieqiConfigs['system']['onlinetime'], '<'));
    $online_handler->delete($criteria);
    //检查短消息
    include_once JIEQI_ROOT_PATH . '/class/message.php';
    $message_handler = JieqiMessageHandler::getInstance('JieqiMessageHandler');
    $criteria = new CriteriaCompo(new Criteria('toid', $jieqiUsers->getVar('uid'), '='));
    $criteria->add(new Criteria('isread', 0, '='));
    $criteria->add(new Criteria('todel', 0, '='));
    $newmsgnum = $message_handler->getCount($criteria);
    unset($criteria);
    //有短消息
    //用户信息
    $previewlogin = intval($jieqiUsers->getVar('lastlogin'));
    $jieqiUsers->setVar('lastlogin', JIEQI_NOW_TIME);
    $userset = unserialize($jieqiUsers->getVar('setting', 'n'));
    if (!isset($userset['lastip']) || $userset['lastip'] != jieqi_userip()) {
        $userset['lastip'] = jieqi_userip();
    }
    if (!isset($userset['logindate']) || $userset['logindate'] != date('Y-m-d')) {
        $userset['logindate'] = date('Y-m-d');
        //增加登陆积分
        $jieqiUsers->setVar('experience', $jieqiUsers->getVar('experience') + $jieqiConfigs['system']['scorelogin']);
        $jieqiUsers->setVar('score', $jieqiUsers->getVar('score') + $jieqiConfigs['system']['scorelogin']);
    }
    //如果换月了,清空月积分
    //if(date('Y-m', $previewlogin) != date('Y-m', JIEQI_NOW_TIME)) $jieqiUsers->setVar('monthscore', 0);
    $jieqiUsers->setVar('setting', serialize($userset));
    $jieqiUsers->unsetNew();
    $users_handler->insert($jieqiUsers);
    header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
    //设置SESSION
    jieqi_setusersession($jieqiUsers);
    if ($newmsgnum > 0) {
        $_SESSION['jieqiNewMessage'] = $newmsgnum;
    }
    //后台登录状态
    $jieqi_online_info = empty($_COOKIE['jieqiOnlineInfo']) ? array() : jieqi_strtosary($_COOKIE['jieqiOnlineInfo']);
    if (isset($jieqi_online_info['jieqiAdminLogin']) && $jieqi_online_info['jieqiAdminLogin'] == 1) {
        $_SESSION['jieqiAdminLogin'] = 1;
    }
    $jieqi_user_info['jieqiUserId'] = $_SESSION['jieqiUserId'];
    $jieqi_user_info['jieqiUserUname'] = $_SESSION['jieqiUserUname'];
    $jieqi_user_info['jieqiUserName'] = $_SESSION['jieqiUserName'];
    $jieqi_user_info['jieqiUserGroup'] = $_SESSION['jieqiUserGroup'];
    $jieqi_user_info['jieqiUserGroupName'] = $jieqiGroups[$_SESSION['jieqiUserGroup']];
    $jieqi_user_info['jieqiUserVip'] = $_SESSION['jieqiUserVip'];
    $jieqi_user_info['jieqiUserHonorId'] = $_SESSION['jieqiUserHonorId'];
    $jieqi_user_info['jieqiUserHonor'] = $_SESSION['jieqiUserHonor'];
    if ($newmsgnum > 0) {
        $jieqi_user_info['jieqiNewMessage'] = $newmsgnum;
    }
    if ($usecookie) {
        $jieqi_user_info['jieqiUserPassword'] = $jieqiUsers->getVar('pass', 'n');
    }
    include_once JIEQI_ROOT_PATH . '/include/changecode.php';
    if (JIEQI_SYSTEM_CHARSET == 'gbk') {
        $jieqi_user_info['jieqiUserUname_un'] = jieqi_gb2unicode($_SESSION['jieqiUserUname']);
        $jieqi_user_info['jieqiUserName_un'] = jieqi_gb2unicode($_SESSION['jieqiUserName']);
        $jieqi_user_info['jieqiUserHonor_un'] = jieqi_gb2unicode($_SESSION['jieqiUserHonor']);
        $jieqi_user_info['jieqiUserGroupName_un'] = jieqi_gb2unicode($jieqiGroups[$_SESSION['jieqiUserGroup']]);
    } else {
        $jieqi_user_info['jieqiUserUname_un'] = jieqi_big52unicode($_SESSION['jieqiUserUname']);
        $jieqi_user_info['jieqiUserName_un'] = jieqi_big52unicode($_SESSION['jieqiUserName']);
        $jieqi_user_info['jieqiUserHonor_un'] = jieqi_big52unicode($_SESSION['jieqiUserHonor']);
        $jieqi_user_info['jieqiUserGroupName_un'] = jieqi_gb2unicode($jieqiGroups[$_SESSION['jieqiUserGroup']]);
    }
    $jieqi_user_info['jieqiUserLogin'] = JIEQI_NOW_TIME;
    if ($usecookie < 0) {
        $usecookie = 0;
    } elseif ($usecookie == 1) {
        $usecookie = 315360000;
    }
    if ($usecookie) {
        $cookietime = JIEQI_NOW_TIME + $usecookie;
    } else {
        $cookietime = 0;
    }
    @setcookie('jieqiUserInfo', jieqi_sarytostr($jieqi_user_info), $cookietime, '/', JIEQI_COOKIE_DOMAIN, 0);
    $jieqi_visit_info['jieqiUserLogin'] = $jieqi_user_info['jieqiUserLogin'];
    $jieqi_visit_info['jieqiUserId'] = $jieqi_user_info['jieqiUserId'];
    @setcookie('jieqiVisitInfo', jieqi_sarytostr($jieqi_visit_info), JIEQI_NOW_TIME + 99999999, '/', JIEQI_COOKIE_DOMAIN, 0);
    //更新在线用户
    include_once JIEQI_ROOT_PATH . '/lib/template/template.php';
    $jieqiTpl =& JieqiTpl::getInstance();
    $jieqiTpl->clear_cache(JIEQI_ROOT_PATH . '/templates/online.html');
    return 0;
}
Esempio n. 4
0
 function setContent($isreturn = false)
 {
     global $jieqiTpl;
     global $jieqiGroups;
     global $jieqiConfigs;
     global $jieqiHonors;
     global $jieqi_image_type;
     global $jieqiModules;
     include_once JIEQI_ROOT_PATH . '/class/users.php';
     $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler');
     $userobj = $users_handler->get($this->blockvars['cacheid']);
     if (!is_object($userobj)) {
         return false;
     }
     $jieqiTpl->assign('uid', $userobj->getVar('uid'));
     $jieqiTpl->assign('uname', $userobj->getVar('uname'));
     $tmpvar = strlen($userobj->getVar('name')) > 0 ? $userobj->getVar('name') : $userobj->getVar('uname');
     $jieqiTpl->assign('name', $tmpvar);
     $jieqiTpl->assign('groupid', $userobj->getVar('groupid'));
     $jieqiTpl->assign('group', $userobj->getGroup());
     $jieqiTpl->assign('sex', $userobj->getSex());
     if ($userobj->getVar('viewemail') == 1) {
         $jieqiTpl->assign('viewemail', 1);
         $jieqiTpl->assign('email', $userobj->getVar('email'));
     } else {
         $jieqiTpl->assign('viewemail', 0);
         $jieqiTpl->assign('email', '');
     }
     $jieqiTpl->assign('qq', $userobj->getVar('qq'));
     $jieqiTpl->assign('icq', $userobj->getVar('icq'));
     $jieqiTpl->assign('msn', $userobj->getVar('msn'));
     $jieqiTpl->assign('url', $userobj->getVar('url'));
     $jieqiTpl->assign('regdate', $userobj->getVar('regdate'));
     $jieqiTpl->assign('experience', $userobj->getVar('experience'));
     $jieqiTpl->assign('score', $userobj->getVar('score'));
     $jieqiTpl->assign('monthscore', $userobj->getVar('monthscore'));
     $jieqiTpl->assign('weekscore', $userobj->getVar('weekscore'));
     $jieqiTpl->assign('dayscore', $userobj->getVar('dayscore'));
     $jieqiTpl->assign('credit', $userobj->getVar('credit'));
     $jieqiTpl->assign('viptype', $userobj->getViptype());
     $jieqiTpl->assign('egoldname', JIEQI_EGOLD_NAME);
     jieqi_getconfigs('system', 'honors');
     $honorid = jieqi_gethonorid($userobj->getVar('score'), $jieqiHonors);
     $jieqiTpl->assign('honor', $jieqiHonors[$honorid]['name'][intval($userobj->getVar('workid'))]);
     $egold = $userobj->getVar('egold');
     $esilver = $userobj->getVar('esilver');
     $emoney = $egold + $esilver;
     $jieqiTpl->assign('egold', $egold);
     $jieqiTpl->assign('esilver', $esilver);
     $jieqiTpl->assign('emoney', $emoney);
     $jieqiTpl->assign('sign', $userobj->getVar('sign'));
     $jieqiTpl->assign('intro', $userobj->getVar('intro'));
     //头像
     $avatar = $userobj->getVar('avatar', 'n');
     $jieqiTpl->assign('avatar', $avatar);
     //徽章
     if (!empty($jieqiModules['badge']['publish']) && is_file($jieqiModules['badge']['path'] . '/include/badgefunction.php')) {
         include_once $jieqiModules['badge']['path'] . '/include/badgefunction.php';
         //等级徽章
         $jieqiTpl->assign('url_group', getbadgeurl(1, $userobj->getVar('groupid'), 0, true));
         //头衔徽章
         $jieqiTpl->assign('url_honor', getbadgeurl(2, $honorid, 0, true));
         //自定义徽章
         $jieqi_badgerows = array();
         $badgeary = unserialize($userobj->getVar('badges', 'n'));
         if (is_array($badgeary) && count($badgeary) > 0) {
             $k = 0;
             foreach ($badgeary as $badge) {
                 $jieqi_badgerows[$k]['imageurl'] = getbadgeurl($badge['btypeid'], $badge['linkid'], $badge['imagetype']);
                 $jieqi_badgerows[$k]['caption'] = jieqi_htmlstr($badge['caption']);
                 $k++;
             }
         }
         $jieqiTpl->assign_by_ref('badgerows', $jieqi_badgerows);
         $jieqiTpl->assign('use_badge', 1);
     } else {
         $jieqiTpl->assign('use_badge', 0);
     }
     $jieqiTpl->assign('ownerid', $this->blockvars['cacheid']);
 }
Esempio n. 5
0
/**
 * 用户接口,登录预处理
 * 
 * @param      array       $params 参数数组
 * 必须参数: $params['username'] - 用户名,$params['password'] - 密码,$params['email'] - 邮箱
 * @access     public
 * @return     int    
 */
function jieqi_ulogin_iprepare(&$params)
{
    global $jieqiLang;
    global $jieqiConfigs;
    //通过接口判断登录帐号的正确性,返回值为数组
    list($uid, $username, $password, $email) = uc_user_login($params['username'], $params['password']);
    //uid 大于 0:返回用户 ID,表示用户登录成功 -1:用户不存在,或者被删除 -2:密码错 -3:安全提问错
    $params['uc_uid'] = $uid;
    //如果uc登录成功,jieqi这个用户不存在,在jieqi自动注册
    if ($params['uc_uid'] > 0) {
        $params['email'] = $email;
        include_once JIEQI_ROOT_PATH . '/class/users.php';
        $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler');
        $user = $users_handler->getByname($params['username'], 3);
        if ($user == false) {
            if (!isset($jieqiConfigs['system'])) {
                jieqi_getconfigs('system', 'configs');
            }
            include_once JIEQI_ROOT_PATH . '/lib/text/textfunction.php';
            $newUser = $users_handler->create();
            $newUser->setVar('siteid', JIEQI_SITE_ID);
            $newUser->setVar('uname', $params['username']);
            $newUser->setVar('name', $params['username']);
            $newUser->setVar('pass', $users_handler->encryptPass($params['password']));
            $newUser->setVar('groupid', JIEQI_GROUP_USER);
            $newUser->setVar('regdate', JIEQI_NOW_TIME);
            $newUser->setVar('initial', jieqi_getinitial($params['username']));
            $newUser->setVar('sex', 0);
            $newUser->setVar('email', $params['email']);
            $newUser->setVar('url', '');
            $newUser->setVar('avatar', 0);
            $newUser->setVar('workid', 0);
            $newUser->setVar('qq', '');
            $newUser->setVar('icq', '');
            $newUser->setVar('msn', '');
            $newUser->setVar('mobile', '');
            $newUser->setVar('sign', '');
            $newUser->setVar('intro', '');
            $newUser->setVar('setting', '');
            $newUser->setVar('badges', '');
            $newUser->setVar('lastlogin', JIEQI_NOW_TIME);
            $newUser->setVar('showsign', 0);
            $newUser->setVar('viewemail', 0);
            $newUser->setVar('notifymode', 0);
            $newUser->setVar('adminemail', 0);
            $newUser->setVar('monthscore', 0);
            $newUser->setVar('experience', intval($jieqiConfigs['system']['scoreregister']));
            $newUser->setVar('score', intval($jieqiConfigs['system']['scoreregister']));
            $newUser->setVar('egold', 0);
            $newUser->setVar('esilver', 0);
            $newUser->setVar('credit', 0);
            $newUser->setVar('goodnum', 0);
            $newUser->setVar('badnum', 0);
            $newUser->setVar('isvip', 0);
            $newUser->setVar('overtime', 0);
            $newUser->setVar('state', 0);
            $users_handler->insert($newUser);
        } elseif (is_object($user)) {
            $upflag = false;
            if ($user->getVar('pass', 'n') != $users_handler->encryptPass($params['password'])) {
                $user->setVar('pass', $users_handler->encryptPass($params['password']));
                $upflag = true;
            }
            if ($user->getVar('email', 'n') != $params['email']) {
                $user->setVar('email', $params['email']);
                $upflag = true;
            }
            if ($upflag) {
                $users_handler->insert($user);
            }
        }
    }
    return true;
}
Esempio n. 6
0
 function setContent($isreturn = false)
 {
     global $jieqiTpl;
     global $jieqiModules;
     $userrows = array();
     if (count($this->exevars) > 0) {
         include_once JIEQI_ROOT_PATH . '/class/users.php';
         $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler');
         $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('uid', '(0,' . implode(',', $this->exevars) . ')', 'IN'));
         $criteria->setLimit(100);
         $criteria->setStart(0);
         $users_handler->queryObjects($criteria);
         $k = 0;
         while ($v = $users_handler->getObject()) {
             $userrows[$k]['uid'] = $v->getVar('uid');
             $userrows[$k]['uname'] = $v->getVar('uname');
             $userrows[$k]['name'] = $v->getVar('name');
             if (empty($userrows[$k]['name'])) {
                 $userrows[$k]['name'] = $v->getVar('uname');
             }
             $userrows[$k]['groupid'] = $v->getVar('groupid');
             $userrows[$k]['group'] = $v->getGroup();
             $userrows[$k]['sex'] = $v->getSex();
             if ($v->getVar('viewemail') == 1) {
                 $userrows[$k]['viewemail'] = 1;
                 $userrows[$k]['email'] = $v->getVar('email');
             } else {
                 $userrows[$k]['viewemail'] = 0;
                 $userrows[$k]['email'] = '';
             }
             $userrows[$k]['qq'] = $v->getVar('qq');
             $userrows[$k]['icq'] = $v->getVar('icq');
             $userrows[$k]['msn'] = $v->getVar('msn');
             $userrows[$k]['url'] = $v->getVar('url');
             $userrows[$k]['regdate'] = $v->getVar('regdate');
             $userrows[$k]['experience'] = $v->getVar('experience');
             $userrows[$k]['score'] = $v->getVar('score');
             $userrows[$k]['monthscore'] = $v->getVar('monthscore');
             $userrows[$k]['weekscore'] = $v->getVar('weekscore');
             $userrows[$k]['dayscore'] = $v->getVar('dayscore');
             $userrows[$k]['credit'] = $v->getVar('credit');
             $userrows[$k]['viptype'] = $v->getViptype();
             jieqi_getconfigs('system', 'honors');
             $honorid = jieqi_gethonorid($v->getVar('score'), $jieqiHonors);
             $userrows[$k]['honor'] = $jieqiHonors[$honorid]['name'][intval($v->getVar('workid'))];
             $egold = $v->getVar('egold');
             $esilver = $v->getVar('esilver');
             $emoney = $egold + $esilver;
             $userrows[$k]['egold'] = $egold;
             $userrows[$k]['esilver'] = $esilver;
             $userrows[$k]['emoney'] = $emoney;
             $userrows[$k]['sign'] = $v->getVar('sign');
             //$userrows[$k]['intro']=$v->getVar('intro');
             //头像
             $avatar = $v->getVar('avatar', 'n');
             $userrows[$k]['avatar'] = $avatar;
             //徽章
             if (!empty($jieqiModules['badge']['publish']) && is_file($jieqiModules['badge']['path'] . '/include/badgefunction.php')) {
                 include_once $jieqiModules['badge']['path'] . '/include/badgefunction.php';
                 //等级徽章
                 $userrows[$k]['url_group'] = getbadgeurl(1, $v->getVar('groupid'), 0, true);
                 //头衔徽章
                 $userrows[$k]['url_honor'] = getbadgeurl(2, $honorid, 0, true);
                 //自定义徽章
                 $jieqi_badgerows = array();
                 $badgeary = unserialize($v->getVar('badges', 'n'));
                 if (is_array($badgeary) && count($badgeary) > 0) {
                     $m = 0;
                     foreach ($badgeary as $badge) {
                         $jieqi_badgerows[$m]['imageurl'] = getbadgeurl($badge['btypeid'], $badge['linkid'], $badge['imagetype']);
                         $jieqi_badgerows[$m]['caption'] = jieqi_htmlstr($badge['caption']);
                         $m++;
                     }
                 }
                 $userrows[$k]['badgerows'] = $jieqi_badgerows;
                 $userrows[$k]['use_badge'] = 1;
             } else {
                 $userrows[$k]['use_badge'] = 0;
             }
             $k++;
         }
     }
     $jieqiTpl->assign_by_ref('userrows', $userrows);
 }
Esempio n. 7
0
function jieqi_article_delchapter($aid, $criteria, $usescore = false)
{
    global $jieqiModules;
    global $article_handler;
    global $chapter_handler;
    global $jieqiArticleuplog;
    global $jieqiConfigs;
    global $jieqi_file_postfix;
    if (!is_object($criteria)) {
        return false;
    }
    $criteria->add(new Criteria('articleid', intval($aid)));
    $article = $article_handler->get($aid);
    if (!is_object($article)) {
        return false;
    }
    //查询符合条件章节
    $posterary = array();
    $chapter_handler->queryObjects($criteria);
    $chapterary = array();
    $k = 0;
    $cids = '';
    $lastchapterid = intval($article->getVar('lastchapterid'));
    $lastvolumeid = intval($article->getVar('lastvolumeid'));
    $uplastchapter = false;
    //是否更新最新章节
    $uplastvolume = false;
    //是否更新最新章节
    $subsize = 0;
    while ($chapterobj = $chapter_handler->getObject()) {
        $chapterary[$k]['id'] = intval($chapterobj->getVar('chapterid'));
        if ($chapterary[$k]['id'] == $lastchapterid) {
            $uplastchapter = true;
        }
        if ($chapterary[$k]['id'] == $lastvolumeid) {
            $uplastvolume = true;
        }
        if ($cids != '') {
            $cids .= ',';
        }
        $cids .= $chapterary[$k]['id'];
        $chapterary[$k]['size'] = $chapterobj->getVar('size');
        $subsize += intval($chapterary[$k]['size']);
        $chapterary[$k]['attach'] = $chapterobj->getVar('attachment', 'n') == '' ? 0 : 1;
        $k++;
        if (!empty($jieqiConfigs['article']['scorechapter'])) {
            $posterid = intval($chapterobj->getVar('posterid'));
            if (isset($posterary[$posterid])) {
                $posterary[$posterid] += $jieqiConfigs['article']['scorechapter'];
            } else {
                $posterary[$posterid] = $jieqiConfigs['article']['scorechapter'];
            }
        }
    }
    //删除章节
    $chapter_handler->delete($criteria);
    //删除附件数据库
    if ($cids != '') {
        $criteria1 = new CriteriaCompo();
        $criteria1->add(new Criteria('chapterid', '(' . $cids . ')', 'IN'));
        include_once $jieqiModules['article']['path'] . '/class/articleattachs.php';
        $attachs_handler =& JieqiArticleattachsHandler::getInstance('JieqiArticleattachsHandler');
        $attachs_handler->delete($criteria1);
    }
    //删除文本文件、附件文件、html
    $txtdir = jieqi_uploadpath($jieqiConfigs['article']['txtdir'], 'article') . jieqi_getsubdir($aid) . '/' . $aid;
    $htmldir = jieqi_uploadpath($jieqiConfigs['article']['htmldir'], 'article') . jieqi_getsubdir($aid) . '/' . $aid;
    $attachdir = jieqi_uploadpath($jieqiConfigs['article']['attachdir'], 'article') . jieqi_getsubdir($aid) . '/' . $aid;
    foreach ($chapterary as $c) {
        if (is_file($txtdir . '/' . $c['id'] . $jieqi_file_postfix['txt'])) {
            jieqi_delfile($txtdir . '/' . $c['id'] . $jieqi_file_postfix['txt']);
        }
        if (is_file($htmldir . '/' . $c['id'] . $jieqiConfigs['article']['htmlfile'])) {
            jieqi_delfile($htmldir . '/' . $c['id'] . $jieqiConfigs['article']['htmlfile']);
        }
        if (is_dir($attachdir . '/' . $c['id'])) {
            jieqi_delfolder($attachdir . '/' . $c['id']);
        }
    }
    //重新生成网页和打包
    include_once $jieqiModules['article']['path'] . '/include/repack.php';
    $ptypes = array('makeopf' => 1, 'makehtml' => $jieqiConfigs['article']['makehtml'], 'makezip' => $jieqiConfigs['article']['makezip'], 'makefull' => $jieqiConfigs['article']['makefull'], 'maketxtfull' => $jieqiConfigs['article']['maketxtfull'], 'makeumd' => $jieqiConfigs['article']['makeumd'], 'makejar' => $jieqiConfigs['article']['makejar']);
    article_repack($aid, $ptypes, 0);
    //减少文章和章节积分
    if ($usescore) {
        include_once JIEQI_ROOT_PATH . '/class/users.php';
        $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler');
        if (!empty($jieqiConfigs['article']['scorearticle'])) {
            $posterid = intval($article->getVar('posterid'));
            if (isset($posterary[$posterid])) {
                $posterary[$posterid] += $jieqiConfigs['article']['scorearticle'];
            } else {
                $posterary[$posterid] = $jieqiConfigs['article']['scorearticle'];
            }
        }
        foreach ($posterary as $pid => $pscore) {
            $users_handler->changeScore($pid, $pscore, false);
        }
    }
    //更新文章信息
    $newsize = $article->getVar('size') - $subsize;
    if ($newsize < 0) {
        $newsize = 0;
    }
    $article->setVar('size', $newsize);
    if ($uplastchapter) {
        $criteria = new CriteriaCompo(new Criteria('articleid', $article->getVar('articleid')));
        $criteria->add(new Criteria('chaptertype', 0, '='));
        $criteria->setSort('chapterorder');
        $criteria->setOrder('DESC');
        $criteria->setStart(0);
        $criteria->setLimit(1);
        $chapter_handler->queryObjects($criteria);
        $tmpchapter = $chapter_handler->getObject();
        if ($tmpchapter) {
            $article->setVar('lastchapter', $tmpchapter->getVar('chaptername', 'n'));
            $article->setVar('lastchapterid', $tmpchapter->getVar('chapterid', 'n'));
            unset($tmpchapter);
        } else {
            $article->setVar('lastchapter', '');
            $article->setVar('lastchapterid', 0);
        }
    }
    if ($uplastvolume) {
        $criteria = new CriteriaCompo(new Criteria('articleid', $article->getVar('articleid')));
        $criteria->add(new Criteria('chaptertype', 1, '='));
        $criteria->setSort('chapterorder');
        $criteria->setOrder('DESC');
        $criteria->setStart(0);
        $criteria->setLimit(1);
        $chapter_handler->queryObjects($criteria);
        $tmpchapter = $chapter_handler->getObject();
        if ($tmpchapter) {
            $article->setVar('lastvolume', $tmpchapter->getVar('chaptername', 'n'));
            $article->setVar('lastvolumeid', $tmpchapter->getVar('chapterid', 'n'));
            unset($tmpchapter);
        } else {
            $article->setVar('lastvolume', '');
            $article->setVar('lastvolumeid', 0);
        }
    }
    $article_handler->insert($article);
    //更新最新文章
    $jieqiArticleuplog['articleuptime'] = JIEQI_NOW_TIME;
    $jieqiArticleuplog['chapteruptime'] = JIEQI_NOW_TIME;
    jieqi_setcachevars('articleuplog', 'jieqiArticleuplog', $jieqiArticleuplog, 'article');
    return $article;
}
Esempio n. 8
0
/**
 * 本地用户编辑,正式处理
 * 
 * @param      array       $params 参数数组
 * 必须参数: $params['username'] - 用户名,$params['password'] - 密码
 * @access     public
 * @return     int    
 */
function jieqi_uedit_lprocess(&$params)
{
    global $users_handler;
    global $jieqiLang;
    global $jieqiConfigs;
    global $jieqiHonors;
    global $jieqiUsersStatus;
    global $jieqiUsersGroup;
    //载入参数设置
    if (!isset($jieqiConfigs['system'])) {
        jieqi_getconfigs('system', 'configs');
    }
    //载入语言包
    if (!isset($jieqiLang['system'])) {
        jieqi_loadlang('users', 'system');
    }
    if (!is_a($users_handler, 'JieqiUsersHandler')) {
        include_once JIEQI_ROOT_PATH . '/class/users.php';
        $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler');
    }
    $user = $users_handler->get($params['uid']);
    if (!is_object($user)) {
        $params['error'] = LANG_NO_USER;
        if ($params['return']) {
            return false;
        } else {
            jieqi_printfail($params['error']);
        }
    }
    $chglog = array();
    $chginfo = '';
    $user->unsetNew();
    if ($params['adminlevel'] > 0) {
        if (strlen($params['newpass']) > 0) {
            $user->setVar('pass', $users_handler->encryptPass($params['newpass']));
        }
    }
    if ($params['adminlevel'] == 1) {
        //本人修改
        $user->setVar('name', $params['nickname']);
        if (strlen($params['newpass']) > 0) {
            $user->setVar('pass', $users_handler->encryptPass($params['newpass']));
        }
        $user->setVar('sex', $params['sex']);
        $user->setVar('email', $params['email']);
        $user->setVar('url', $params['url']);
        $user->setVar('qq', $params['qq']);
        $user->setVar('msn', $params['msn']);
        if ($params['viewemail'] != 1) {
            $params['viewemail'] = 0;
        }
        $user->setVar('viewemail', $params['viewemail']);
        $user->setVar('adminemail', $params['adminemail']);
        if (isset($params['workid']) && intval($user->getVar('workid', 'n')) != intval($params['workid'])) {
            $user->setVar('workid', $params['workid']);
            $params['changework'] = true;
        } else {
            $params['changework'] = false;
        }
        $user->setVar('sign', $params['sign']);
        $user->setVar('intro', $params['intro']);
        if (!$users_handler->insert($user)) {
            $params['error'] = empty($params['lang_failure']) ? $jieqiLang['system']['user_edit_failure'] : $params['lang_failure'];
            if ($params['return']) {
                return false;
            } else {
                jieqi_printfail($params['error']);
            }
        } else {
            if ($params['changework'] && $_SESSION['jieqiUserId'] == $user->getVar('uid')) {
                jieqi_getconfigs('system', 'honors');
                $honorid = jieqi_gethonorid($user->getVar('score'), $jieqiHonors);
                $_SESSION['jieqiUserHonor'] = $jieqiHonors[$honorid]['name'][intval($user->getVar('workid', 'n'))];
            }
            if ($params['changenick'] && $_SESSION['jieqiUserId'] == $user->getVar('uid')) {
                $_SESSION['jieqiUserName'] = strlen($user->getVar('name', 'n')) > 0 ? $user->getVar('name', 'n') : $user->getVar('uname', 'n');
            }
            $user->saveToSession();
            return true;
        }
    } else {
        //管理员修改
        if ($params['adminlevel'] >= 2) {
            //修改密码
            if (strlen($params['pass']) > 0) {
                $user->setVar('pass', $users_handler->encryptPass($params['pass']));
                $chginfo .= $jieqiLang['system']['userlog_change_password'];
            }
            //经验值
            if (is_numeric($params['experience']) && $params['experience'] != $user->getVar('experience')) {
                $chglog['experience']['from'] = $user->getVar('experience');
                $chglog['experience']['to'] = $params['experience'];
                $user->setVar('experience', $params['experience']);
                if ($chglog['experience']['from'] > $chglog['experience']['to']) {
                    $chginfo .= sprintf($jieqiLang['system']['userlog_less_experience'], $chglog['experience']['from'] - $chglog['experience']['to']);
                } else {
                    $chginfo .= sprintf($jieqiLang['system']['userlog_add_experience'], $chglog['experience']['to'] - $chglog['experience']['from']);
                }
            }
            //积分
            if (is_numeric($params['score']) && $params['score'] != $user->getVar('score')) {
                $chglog['score']['from'] = $user->getVar('score');
                $chglog['score']['to'] = $params['score'];
                $user->setVar('score', $params['score']);
                if ($chglog['score']['from'] > $chglog['score']['to']) {
                    $chginfo .= sprintf($jieqiLang['system']['userlog_less_score'], $chglog['score']['from'] - $chglog['score']['to']);
                } else {
                    $chginfo .= sprintf($jieqiLang['system']['userlog_add_score'], $chglog['score']['to'] - $chglog['score']['from']);
                }
            }
        }
        if ($params['adminlevel'] >= 3) {
            //会员等级
            if (is_numeric($params['groupid']) && $params['groupid'] != $user->getVar('groupid')) {
                if ($params['groupid'] == JIEQI_GROUP_ADMIN && $jieqiUsersGroup != JIEQI_GROUP_ADMIN) {
                    $params['error'] = $jieqiLang['system']['cant_set_admin'];
                    if ($params['return']) {
                        return false;
                    } else {
                        jieqi_printfail($params['error']);
                    }
                }
                $chglog['groupid']['from'] = $user->getVar('groupid');
                $chglog['groupid']['to'] = $params['groupid'];
                $user->setVar('groupid', $params['groupid']);
                $chginfo .= sprintf($jieqiLang['system']['userlog_change_group'], $jieqiGroups[$chglog['groupid']['from']], $jieqiGroups[$chglog['groupid']['to']]);
            }
        }
        if ($params['adminlevel'] >= 4) {
            //虚拟货币
            if (is_numeric($params['egold']) && $params['egold'] != $user->getVar('egold')) {
                $chglog['egold']['from'] = $user->getVar('egold');
                $chglog['egold']['to'] = $params['egold'];
                $user->setVar('egold', $params['egold']);
                if ($chglog['egold']['from'] > $chglog['egold']['to']) {
                    $chginfo .= sprintf($jieqiLang['system']['userlog_less_egold'], JIEQI_EGOLD_NAME, $chglog['egold']['from'] - $chglog['egold']['to']);
                } else {
                    $chginfo .= sprintf($jieqiLang['system']['userlog_add_egold'], JIEQI_EGOLD_NAME, $chglog['egold']['to'] - $chglog['egold']['from']);
                }
            }
            //银币
            if (is_numeric($params['esilver']) && $params['esilver'] != $user->getVar('esilver')) {
                $chglog['esilver']['from'] = $user->getVar('esilver');
                $chglog['esilver']['to'] = $peyment;
                $user->setVar('esilver', $params['esilver']);
                if ($chglog['esilver']['from'] > $chglog['esilver']['to']) {
                    $chginfo .= sprintf($jieqiLang['system']['userlog_less_esilver'], $chglog['esilver']['from'] - $chglog['esilver']['to']);
                } else {
                    $chginfo .= sprintf($jieqiLang['system']['userlog_add_esilver'], $chglog['esilver']['to'] - $chglog['esilver']['from']);
                }
            }
            //VIP状态
            if (is_numeric($params['isvip']) && $params['isvip'] != $user->getVar('isvip')) {
                $tmpstr = $user->getViptype();
                $chglog['isvip']['from'] = $user->getVar('isvip');
                $chglog['isvip']['to'] = $params['groupid'];
                $user->setVar('isvip', $params['isvip']);
                $chginfo .= sprintf($jieqiLang['system']['userlog_change_vip'], $tmpstr, $user->getViptype());
            }
        }
        if (!$users_handler->insert($user)) {
            $params['error'] = $jieqiLang['system']['change_user_failure'];
            if ($params['return']) {
                return false;
            } else {
                jieqi_printfail($params['error']);
            }
        } else {
            //记录登录日志
            /*
            include_once(JIEQI_ROOT_PATH.'/class/logs.php');
            $logs_handler = JieqiLogsHandler::getInstance('JieqiLogsHandler');
            $logdata = array('logtype'=>2, 'targetid'=>$user->getVar('uid', 'n'), 'targettitle'=>$user->getVar('uname', 'n'), 'lognote'=>$params['reason'], 'logdata'=>$chginfo, 'fromdata'=>$log_fromdata, 'todata'=>serialize($user));
            $logs_handler->addlog($logdata);
            */
            //记录日志
            include_once JIEQI_ROOT_PATH . '/class/userlog.php';
            $userlog_handler = JieqiUserlogHandler::getInstance('JieqiUserlogHandler');
            $newlog = $userlog_handler->create();
            $newlog->setVar('siteid', JIEQI_SITE_ID);
            $newlog->setVar('logtime', JIEQI_NOW_TIME);
            $newlog->setVar('fromid', $_SESSION['jieqiUserId']);
            $newlog->setVar('fromname', $_SESSION['jieqiUserName']);
            $newlog->setVar('toid', $user->getVar('uid', 'n'));
            $newlog->setVar('toname', $user->getVar('uname', 'n'));
            $newlog->setVar('reason', $params['reason']);
            $newlog->setVar('chginfo', $chginfo);
            $newlog->setVar('chglog', serialize($chglog));
            $newlog->setVar('isdel', '0');
            $newlog->setVar('userlog', '');
            $userlog_handler->insert($newlog);
            return true;
        }
    }
    return true;
}