function updategroupcreditlog($fid, $uid)
{
    global $_G;
    if (empty($fid) || empty($uid)) {
        return false;
    }
    $today = date('Ymd', TIMESTAMP);
    $updategroupcredit = getcookie('groupcredit_' . $fid);
    if ($updategroupcredit < $today) {
        $status = DB::result_first("SELECT logdate FROM " . DB::table('forum_groupcreditslog') . " WHERE fid='{$fid}' AND uid='{$uid}' AND logdate='{$today}'");
        if (empty($status)) {
            DB::query("UPDATE " . DB::table('forum_forum') . " SET commoncredits=commoncredits+1 WHERE fid='{$fid}'");
            DB::query("REPLACE INTO " . DB::table('forum_groupcreditslog') . " (fid, uid, logdate) VALUES ('{$fid}', '{$uid}', '{$today}')");
            if (empty($_G['forum']) || empty($_G['forum']['level'])) {
                $forum = DB::fetch_first("SELECT name, level, commoncredits FROM " . DB::table('forum_forum') . " WHERE fid='{$fid}'");
            } else {
                $_G['forum']['commoncredits']++;
                $forum =& $_G['forum'];
            }
            if (empty($_G['grouplevels'])) {
                loadcache('grouplevels');
            }
            $grouplevel = $_G['grouplevels'][$forum['level']];
            if ($grouplevel['type'] == 'default' && !($forum['commoncredits'] >= $grouplevel['creditshigher'] && $forum['commoncredits'] < $grouplevel['creditslower'])) {
                $levelid = DB::result_first("SELECT levelid FROM " . DB::table('forum_grouplevel') . " WHERE type='default' AND creditshigher<='{$forum['commoncredits']}' AND creditslower>'{$forum['commoncredits']}' LIMIT 1");
                if (!empty($levelid)) {
                    DB::query("UPDATE " . DB::table('forum_forum') . " SET level='{$levelid}' WHERE fid='{$fid}'");
                    $groupfounderuid = DB::result_first("SELECT founderuid FROM " . DB::table('forum_forumfield') . " WHERE fid='{$fid}' LIMIT 1");
                    notification_add($groupfounderuid, 'system', 'grouplevel_update', array('groupname' => '<a href="forum.php?mod=group&fid=' . $fid . '">' . $forum['name'] . '</a>', 'newlevel' => $_G['grouplevels'][$levelid]['leveltitle']));
                }
            }
        }
        dsetcookie('groupcredit_' . $fid, $today, 86400);
    }
}
 function global_footer()
 {
     global $_G;
     if (!$this->allow) {
         return;
     }
     require_once DISCUZ_ROOT . './source/plugin/smstong/smstong.func.php';
     $data = DB::fetch_first("SELECT mobile FROM " . DB::table("common_member_profile") . " WHERE uid = {$_G['uid']}");
     if ($_G['cache']['plugin']['smstong']['reportmsgnotify'] && $_G['gp_mod'] == 'report' && $_G['gp_reportsubmit']) {
         $content = $_G['cache']['plugin']['smstong']['reportmsgnotifymsg'];
         $rp = array('$username', '$tid', '$message');
         $sm = array($_G['username'], $_G['gp_rid'], $_G['gp_message']);
         $content = str_replace($rp, $sm, $content);
         $arraymobile = explode(',', $_G['cache']['plugin']['smstong']['reportmsgnotifymobile']);
         foreach ($arraymobile as $mobile) {
             $ret = sendsms($_G['cache']['plugin']['smstong']['smsusername'], $_G['cache']['plugin']['smstong']['smspassword'], $mobile, $content);
         }
     } elseif ($_G['cache']['plugin']['smstong']['loggingmsgnotify'] && ismobile($data['mobile']) && $_G['cookie']['loginmark'] != $_G['cookie']['lastvisit']) {
         dsetcookie('loginmark', $_G['cookie']['lastvisit']);
         require_once DISCUZ_ROOT . './source/function/function_misc.php';
         $content = $_G['cache']['plugin']['smstong']['loggingmsgnotifymsg'];
         $rp = array('$username', '$logtime', '$ipaddress', '$location');
         $sm = array($_G['username'], date('Y-m-d H:i:s', TIMESTAMP), $_G['clientip'], str_replace('-', '', str_replace(' ', '', convertip($_G['clientip']))));
         $content = str_replace($rp, $sm, $content);
         $ret = sendsms($_G['cache']['plugin']['smstong']['smsusername'], $_G['cache']['plugin']['smstong']['smspassword'], $data['mobile'], $content);
     }
 }
function cloudaddons_removelog($rid)
{
    global $_G;
    $reason = $_G['cookie']['uninstallreason'];
    dsetcookie('uninstallreason', '', -1);
    cloudaddons_open('&mod=app&ac=removelog&rid=' . $rid . '&reason=' . $reason);
}
Esempio n. 4
0
 function common_base()
 {
     global $_G;
     if (!isset($_G['connect'])) {
         $_G['connect']['url'] = 'http://connect.discuz.qq.com';
         $_G['connect']['api_url'] = 'http://api.discuz.qq.com';
         $_G['connect']['avatar_url'] = 'http://avatar.connect.discuz.qq.com';
         $_G['connect']['qzone_public_share_url'] = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey';
         $_G['connect']['referer'] = !$_G['inajax'] && CURSCRIPT != 'member' ? $_G['basefilename'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '') : dreferer();
         $_G['connect']['weibo_public_appkey'] = 'ce7fb946290e4109bdc9175108b6db3a';
         $_G['connect']['login_url'] = $_G['siteurl'] . 'connect.php?mod=login&op=init&referer=' . urlencode($_G['connect']['referer'] ? $_G['connect']['referer'] : 'index.php');
         $_G['connect']['callback_url'] = $_G['siteurl'] . 'connect.php?mod=login&op=callback';
         $_G['connect']['discuz_new_feed_url'] = $_G['siteurl'] . 'connect.php?mod=feed&op=new';
         $_G['connect']['discuz_remove_feed_url'] = $_G['siteurl'] . 'connect.php?mod=feed&op=remove';
         $_G['connect']['discuz_new_share_url'] = $_G['siteurl'] . 'connect.php?mod=share&op=new';
         $_G['connect']['discuz_new_share_url'] = $_G['siteurl'] . 'home.php?mod=spacecp&ac=plugin&id=qqconnect:spacecp&pluginop=new';
         $_G['connect']['discuz_change_qq_url'] = $_G['siteurl'] . 'connect.php?mod=login&op=change';
         $_G['connect']['auth_fields'] = array('is_user_info' => 1, 'is_feed' => 2);
         if ($_G['uid']) {
             dsetcookie('connect_is_bind', $_G['member']['conisbind'], 31536000);
             if (!$_G['member']['conisbind'] && $_G['cookie']['connect_login']) {
                 $_G['cookie']['connect_login'] = 0;
                 dsetcookie('connect_login');
             }
         }
         if (!$_G['uid'] && !defined('IN_MOBILE')) {
             $_G['setting']['pluginhooks']['global_login_text'] = tpl_login_bar();
         }
     }
 }
function viewthread_updateviews($tableid)
{
    global $_G;
    if (!$_G['setting']['preventrefresh'] || $_G['cookie']['viewid'] != 'tid_' . $_G['tid']) {
        if (!$tableid && $_G['setting']['optimizeviews']) {
            if ($_G['forum_thread']['addviews']) {
                if ($_G['forum_thread']['addviews'] < 100) {
                    C::t('forum_threadaddviews')->update_by_tid($_G['tid']);
                } else {
                    if (!discuz_process::islocked('update_thread_view')) {
                        $row = C::t('forum_threadaddviews')->fetch($_G['tid']);
                        C::t('forum_threadaddviews')->update($_G['tid'], array('addviews' => 0));
                        C::t('forum_thread')->increase($_G['tid'], array('views' => $row['addviews'] + 1), true);
                        discuz_process::unlock('update_thread_view');
                    }
                }
            } else {
                C::t('forum_threadaddviews')->insert(array('tid' => $_G['tid'], 'addviews' => 1), false, true);
            }
        } else {
            C::t('forum_thread')->increase($_G['tid'], array('views' => 1), true, $tableid);
        }
    }
    dsetcookie('viewid', 'tid_' . $_G['tid']);
}
Esempio n. 6
0
 public static function mobileoutput()
 {
     global $_G;
     if (!defined('TPL_DEFAULT')) {
         $content = ob_get_contents();
         ob_end_clean();
         $content = preg_replace("/href=\"(\\w+\\.php)(.*?)\"/e", "mobilereplace('\\1', '\\2')", $content);
         ob_start();
         $content = '<?xml version="1.0" encoding="utf-8"?>' . $content;
         if ('utf-8' != CHARSET) {
             @header('Content-Type: text/html; charset=utf-8');
             $content = diconv($content, CHARSET, 'utf-8');
         }
         echo $content;
         exit;
     } elseif (defined('TPL_DEFAULT') && !$_G['cookie']['dismobilemessage'] && $_G['mobile']) {
         ob_end_clean();
         ob_start();
         $_G['forcemobilemessage'] = true;
         $query_sting_tmp = str_replace(array('&mobile=yes', 'mobile=yes'), array(''), $_SERVER['QUERY_STRING']);
         $_G['setting']['mobile']['pageurl'] = $_G['siteurl'] . substr($_G['PHP_SELF'], 1) . ($query_sting_tmp ? '?' . $query_sting_tmp . '&mobile=no' : '?mobile=no');
         unset($query_sting_tmp);
         dsetcookie('dismobilemessage', '1', 3600);
         showmessage('not_in_mobile');
         exit;
     }
 }
Esempio n. 7
0
function cleartaskstatus()
{
    global $_G;
    if (!DB::result_first("SELECT COUNT(*) FROM " . DB::table('common_mytask') . " WHERE uid='{$_G['uid']}' AND status='0'")) {
        dsetcookie('taskdoing_' . $_G['uid']);
    }
}
Esempio n. 8
0
 function plugin_myrepeats()
 {
     global $_G;
     if (!$_G['uid']) {
         return;
     }
     /* 读取可以使用马甲的用户组 usergroups 变量值。需要注意参数的读取方式,详情见插件手册-参数读取		。 */
     $myrepeatsusergroups = (array) dunserialize($_G['cache']['plugin']['myrepeats']['use		rgroups']);
     if (in_array('', $myrepeatsusergroups)) {
         $myrepeatsusergroups = array();
     }
     $userlist = array();
     /* 对当前登录用户进行马甲验证, 即当前用户组不再权限许可范围内, 但其他帐号所在用户组有权限, 则当		前用户也有使用权限。*/
     if (!in_array($_G['groupid'], $myrepeatsusergroups)) {
         if (!isset($_G['cookie']['myrepeat_rr'])) {
             /* 这里需要注意一下你所建的数据表对象的构建, 即 source/plugin/myrepeats/t				able/下的 table_新建表名.php */
             $users = count(C::t('#myrepeats#myrepeats')->fetch_all_by_username($_G['username']));
             dsetcookie('myrepeat_rr', 'R' . $users, 86400);
         } else {
             $users = substr($_G['cookie']['myrepeat_rr'], 1);
         }
         if (!$users) {
             return '';
         }
     }
     /* 前台显示代码 */
     $this->value['global_usernav_extra1'] = '<script>' . 'function showmyrepeats() {if(!$(\'myrepeats_menu\')) {' . 'menu=document.createElement(\'div\');menu.id=\'myrepeats_menu\';menu.style			.display=\'none\';menu.className=\'p_pop\';' . '$(\'append_parent\').appendChild(menu);' . 'ajaxget(\'plugin.php?id=myrepeats:switch&list=yes\',\'myrepeats_menu\',\'a			jaxwaitid\');}' . 'showMenu({\'ctrlid\':\'myrepeats\',\'duration\':2});}' . '</script>' . '<span class="pipe">|</span><a id="myrepeats" href="home.php?mod=spacecp&ac=plugin&		id=myrepeats:memcp" class="showmenu cur1" onmouseover="delayShow(this, showmyrepeat		s)">' . lang('plugin/myrepeats', 'switch') . '</a>' . "\n";
 }
Esempio n. 9
0
 function global_footer()
 {
     global $_G;
     $qqmedal = unserialize($_G['setting']['qqmedal']);
     if (!$_G['setting']['connect']['allow'] || $_G['cookie']['has_qqmedal'] == 1 || !$_G['cookie']['client_created'] || time() - $_G['cookie']['client_created'] > 60 && $_G['cookie']['client_created'] || !empty($_G['inajax']) || !empty($_G['inshowmessage']) || !$_G['uid'] || !$_G['member']['conisbind'] || !$qqmedal['allowed']) {
         return;
     }
     $mid = $_G['setting']['qqmedalid'];
     if (!$mid) {
         return;
     }
     // 判断勋章是否可用
     $medal = C::t('forum_medal')->fetch_all_by_id($mid);
     $available = $medal[0]['available'];
     if (!$available) {
         return;
     }
     if (C::t('common_member_medal')->count_by_uid_medalid($_G['uid'], $mid)) {
         $cookie_expires = 2592000;
         dsetcookie('has_qqmedal', 1, $cookie_expires);
     } elseif ($_G['cookie']['has_qqmedal'] == 2) {
         // 待发状态奖励勋章
         $result = C::t('common_member_field_forum')->fetch($_G['uid']);
         $medals = $result['medals'];
         $medalsnew = $medals ? $mid . "\t" . $medals : $mid;
         C::t('common_member_field_forum')->update($_G['uid'], array('medals' => $medalsnew));
         C::t('common_member_medal')->insert(array('uid' => $_G['uid'], 'medalid' => $mid), 0, 1);
         C::t('forum_medallog')->insert(array('uid' => $_G['uid'], 'medalid' => $mid, 'type' => 0, 'dateline' => TIMESTAMP, 'expiration' => '', 'status' => 0));
         $cookie_expires = 2592000;
         dsetcookie('has_qqmedal', 1, $cookie_expires);
     } else {
         return '<link rel="stylesheet" type="text/css" href="source/plugin/qqmedal/template/qqmedal.css" /><script>showWindow(\'open_medal\', \'plugin.php?id=qqmedal:medal\');</script>';
     }
 }
Esempio n. 10
0
function check_update()
{
    if (defined('UPDATE_CHECKED')) {
        return;
    }
    $ver = $_COOKIE['ver'];
    if ($ver == VERSION) {
        return;
    }
    $query = DB::query("SELECT v FROM setting WHERE k='version'", 'SILENT');
    $res = DB::fetch($query);
    $current_version = $res['v'];
    dsetcookie('ver', $current_version);
    if ($current_version != VERSION) {
        // load update script
        while ($current_version) {
            $filepath = SYSTEM_ROOT . "./function/updater/{$current_version}.php";
            if (file_exists($filepath)) {
                include $filepath;
                exit;
            } else {
                $current_version = substr($current_version, 0, strrpos($current_version, '.'));
            }
        }
        include SYSTEM_ROOT . './function/updater/fallback.php';
        exit;
    } else {
        define('UPDATE_CHECKED', true);
        return;
    }
}
function make_secqaa($idhash)
{
    global $_G;
    loadcache('secqaa');
    $secqaakey = max(1, random(1, 1));
    if ($_G['cache']['secqaa'][$secqaakey]['type']) {
        $etype = explode(':', $_G['cache']['secqaa'][$secqaakey]['question']);
        if (count($etype) > 1 && preg_match('/^[\\w\\_]+$/', $etype[0]) && preg_match('/^[\\w\\_]+$/', $etype[1])) {
            $qaafile = DISCUZ_ROOT . './source/plugin/' . $etype[0] . '/secqaa/secqaa_' . $etype[1] . '.php';
            $class = $etype[1];
        } else {
            $qaafile = libfile('secqaa/' . $_G['cache']['secqaa'][$secqaakey]['question'], 'class');
            $class = $_G['cache']['secqaa'][$secqaakey]['question'];
        }
        if (file_exists($qaafile)) {
            @(include_once $qaafile);
            $class = 'secqaa_' . $class;
            if (class_exists($class)) {
                $qaa = new $class();
                if (method_exists($qaa, 'make')) {
                    $_G['cache']['secqaa'][$secqaakey]['answer'] = md5($qaa->make($_G['cache']['secqaa'][$secqaakey]['question']));
                }
            }
        }
    }
    dsetcookie('secqaa' . $idhash, authcode($_G['cache']['secqaa'][$secqaakey]['answer'] . "\t" . (TIMESTAMP - 180) . "\t" . $idhash . "\t" . FORMHASH, 'ENCODE', $_G['config']['security']['authkey']), 0, 1, true);
    return $_G['cache']['secqaa'][$secqaakey]['question'];
}
Esempio n. 12
0
function getinvite()
{
    global $_G;
    $result = array();
    $cookies = empty($_G['cookie']['invite_auth']) ? array() : explode(',', $_G['cookie']['invite_auth']);
    $cookiecount = count($cookies);
    if ($cookiecount == 2) {
        $id = intval($cookies[0]);
        $code = $cookies[1];
        $query = DB::query("SELECT * FROM " . DB::table('common_invite') . " WHERE id='{$id}'");
        if ($invite = DB::fetch($query)) {
            if ($invite['code'] == $code && empty($invite['fuid']) && (empty($invite['endtime']) || $_G['timestamp'] < $invite['endtime'])) {
                $result['uid'] = $invite['uid'];
                $result['id'] = $invite['id'];
                $result['appid'] = $invite['appid'];
            }
        }
    } elseif ($cookiecount == 3) {
        $uid = intval($cookies[0]);
        $code = $cookies[1];
        $appid = intval($cookies[2]);
        $invite_code = space_key($uid, $appid);
        if ($code == $invite_code) {
            $result['uid'] = $uid;
            $result['appid'] = $appid;
        }
    }
    if ($result['uid']) {
        $member = getuserbyuid($result['uid']);
        $result['username'] = $member['username'];
    } else {
        dsetcookie('invite_auth', '', -86400 * 365);
    }
    return $result;
}
Esempio n. 13
0
 function updatemembercount($creditarr, $uids = 0, $checkgroup = true, $ruletxt = '')
 {
     global $_G;
     if (!$uids) {
         $uids = intval($_G['uid']);
     }
     $uids = is_array($uids) ? $uids : array($uids);
     if ($uids && ($creditarr || $this->extrasql)) {
         if ($this->extrasql) {
             $creditarr = array_merge($creditarr, $this->extrasql);
         }
         $sql = array();
         $allowkey = array('extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6', 'extcredits7', 'extcredits8', 'friends', 'posts', 'threads', 'oltime', 'digestposts', 'doings', 'blogs', 'albums', 'sharings', 'attachsize', 'views', 'todayattachs', 'todayattachsize');
         $creditnotice = $_G['setting']['creditnotice'] && $_G['uid'] && $uids == array($_G['uid']);
         if ($creditnotice) {
             if (!isset($_G['cookiecredits'])) {
                 $_G['cookiecredits'] = !empty($_COOKIE['creditnotice']) ? explode('D', $_COOKIE['creditnotice']) : array_fill(0, 9, 0);
                 for ($i = 1; $i <= 8; $i++) {
                     $_G['cookiecreditsbase'][$i] = getuserprofile('extcredits' . $i);
                 }
             }
             if ($ruletxt) {
                 $_G['cookiecreditsrule'][$ruletxt] = $ruletxt;
             }
         }
         //$critarr 各项积分参数extcredit设置的值
         $settingValue = WebUtils::getDzPluginAppbymeAppConfig('dzsyscache_forum_extcredit_base');
         foreach ($creditarr as $key => $value) {
             $mutilute = 1;
             foreach ($settingValue as $k => $v) {
                 if ($key == 'extcredits' . $k) {
                     $mutilute = $v * 0.01;
                 }
             }
             if (!empty($key) && $value && in_array($key, $allowkey)) {
                 $sql[$key] = $value * $mutilute;
                 if ($creditnotice && substr($key, 0, 10) == 'extcredits') {
                     $i = substr($key, 10);
                     $_G['cookiecredits'][$i] += $value * $mutilute;
                 }
             }
         }
         if ($creditnotice) {
             dsetcookie('creditnotice', implode('D', $_G['cookiecredits']) . 'D' . $_G['uid']);
             dsetcookie('creditbase', '0D' . implode('D', $_G['cookiecreditsbase']));
             if (!empty($_G['cookiecreditsrule'])) {
                 dsetcookie('creditrule', strip_tags(implode("\t", $_G['cookiecreditsrule'])));
             }
         }
         //var_dump($sql);die;
         if ($sql) {
             C::t('common_member_count')->increase($uids, $sql);
         }
         if ($checkgroup && count($uids) == 1) {
             $this->checkusergroup($uids[0]);
         }
         $this->extrasql = array();
     }
 }
Esempio n. 14
0
function do_login($uid)
{
    global $cookiever;
    $user = DB::fetch_first("SELECT * FROM member WHERE uid='{$uid}'");
    $password_hash = substr(md5($user['password']), 8, 8);
    $login_exp = TIMESTAMP + 900;
    dsetcookie('token', authcode("{$cookiever}\t{$uid}\t{$user[username]}\t{$login_exp}\t{$password_hash}", 'ENCODE'));
}
Esempio n. 15
0
function clearcookies()
{
    global $discuz_uid, $discuz_user, $discuz_pw, $discuz_secques, $adminid, $credits;
    foreach (array('sid', 'auth', 'visitedfid', 'onlinedetail', 'loginuser', 'activationauth', 'indextype') as $k) {
        dsetcookie($k);
    }
    $discuz_uid = $adminid = $credits = 0;
    $discuz_user = $discuz_pw = $discuz_secques = '';
}
Esempio n. 16
0
function get_user_level()
{
    global $_G;
    $status = 0;
    $name = milu_lang('free_user');
    $file_name = PICK_DIR . '/data/pick_auth.txt';
    $msg_arr = array();
    $vip_show = '<img  border="0" src="' . PICK_URL . '/static/image/vip.gif" /> ' . milu_lang('vip_user') . ' ';
    $msg_arr = get_user_pick_info();
    if ($msg_arr < 0) {
        $status = -1;
        $name = milu_lang('no_query_info');
    }
    $web_qq = get_contents(GET_URL . 'plugin.php?id=pick_user:upgrade&myac=get_qq&tpl=no', array('cache' => 3600 * 24 * 2));
    $msg_arr = unserialize($msg_arr);
    extract($msg_arr);
    $show_use_time = $exp_dateline ? " " . milu_lang('no_user_dateline') . ":<font style='color:#09C'>" . dgmdate($exp_dateline) . '</font>' : '';
    if ($msg == 'succeed') {
        dsetcookie('pick_auth', $msg, -1);
        $show_use_time = $show_use_time ? $show_use_time : milu_lang('forever_use');
        $name = $vip_show . $show_use_time;
        $status = 1;
    } else {
        if ($msg == 'timeout') {
            @unlink($file_name);
            $name = milu_lang('no_free_use');
            $status = -2;
        } else {
            if ($msg == 'free' || $msg == 'first') {
                //如果是免费版本
                if (VIP) {
                    $status = 2;
                    $name = milu_lang('free_use') . ' ' . $show_use_time;
                }
            } else {
                $status = -3;
                if ($msg == 'error') {
                    $why = milu_lang('lan_network');
                } else {
                    $why = milu_lang('no_conn_server');
                }
                $name = milu_lang('user_no_query') . '  (' . $why . ')';
            }
        }
    }
    if ($status < 0) {
        $show_upgrade = '';
        //服务器网络限制,无法检测升级
    } else {
        $show_upgrade = VIP ? '<a href="?' . PICK_GO . 'pick_info&ac=pick_check">' . milu_lang('check_new') . '</a>' : '<a href="?' . PICK_GO . 'pick_info&ac=pick_check">' . milu_lang('up_to_vip') . '</a>';
    }
    $re['show_user_name'] = $name;
    $re['show_upgrade'] = $show_upgrade;
    $re['status'] = $status;
    $re['web_qq'] = $web_qq;
    return $re;
}
Esempio n. 17
0
function clearcookies()
{
    global $discuz_uid, $discuz_user, $discuz_pw, $discuz_secques, $adminid, $credits;
    dsetcookie('sid', '', -86400 * 365);
    dsetcookie('auth', '', -86400 * 365);
    dsetcookie('visitedfid', '', -86400 * 365);
    dsetcookie('onlinedetail', '', -86400 * 365, 0);
    $discuz_uid = $adminid = $credits = 0;
    $discuz_user = $discuz_pw = $discuz_secques = '';
}
Esempio n. 18
0
function userlogin()
{
    global $db, $tablepre, $_DCACHE, $ucresult, $username, $password, $questionid, $answer, $loginfield;
    require_once DISCUZ_ROOT . './uc_client/client.php';
    if ($loginfield == 'uid') {
        $isuid = 1;
    } elseif ($loginfield == 'email') {
        $isuid = 2;
    } else {
        $isuid = 0;
    }
    $ucresult = uc_user_login($username, $password, $isuid, 1, $questionid, $answer);
    list($tmp['uid'], $tmp['username'], $tmp['password'], $tmp['email'], $duplicate) = daddslashes($ucresult, 1);
    $ucresult = $tmp;
    if ($duplicate && $ucresult['uid'] > 0) {
        if ($olduid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='******'username']) . "'")) {
            require_once DISCUZ_ROOT . './include/membermerge.func.php';
            membermerge($olduid, $ucresult['uid']);
            uc_user_merge_remove($ucresult['username']);
        } else {
            return 0;
        }
    }
    if ($ucresult['uid'] <= 0) {
        return 0;
    }
    $member = $db->fetch_first("SELECT m.uid AS discuz_uid, m.username AS discuz_user, m.password AS discuz_pw, m.secques AS discuz_secques,\r\n\t\tm.email, m.adminid, m.groupid, m.styleid, m.lastvisit, m.lastpost, u.allowinvisible\r\n\t\tFROM {$tablepre}members m LEFT JOIN {$tablepre}usergroups u USING (groupid)\r\n\t\tWHERE m.uid='{$ucresult['uid']}'");
    if (!$member) {
        return -1;
    }
    $member['discuz_userss'] = $member['discuz_user'];
    $member['discuz_user'] = addslashes($member['discuz_user']);
    foreach ($member as $var => $value) {
        $GLOBALS[$var] = $value;
    }
    if (addslashes($member['email']) != $ucresult['email']) {
        $db->query("UPDATE {$tablepre}members SET email='{$ucresult['email']}' WHERE uid='{$ucresult['uid']}'");
    }
    if ($questionid > 0 && empty($member['discuz_secques'])) {
        $GLOBALS['discuz_secques'] = random(8);
        $db->query("UPDATE {$tablepre}members SET secques='{$GLOBALS['discuz_secques']}' WHERE uid='{$ucresult['uid']}'");
    }
    $GLOBALS['styleid'] = $member['styleid'] ? $member['styleid'] : $_DCACHE['settings']['styleid'];
    $cookietime = intval(isset($_POST['cookietime']) ? $_POST['cookietime'] : 0);
    dsetcookie('cookietime', $cookietime, 31536000);
    dsetcookie('auth', authcode("{$member['discuz_pw']}\t{$member['discuz_secques']}\t{$member['discuz_uid']}", 'ENCODE'), $cookietime, 1, true);
    dsetcookie('loginuser');
    dsetcookie('activationauth');
    dsetcookie('pmnum');
    $GLOBALS['sessionexists'] = 0;
    if ($_DCACHE['settings']['frameon'] && $_DCOOKIE['frameon'] == 'yes') {
        $GLOBALS['extrahead'] .= '<script>if(top != self) {parent.leftmenu.location.reload();}</script>';
    }
    return 1;
}
Esempio n. 19
0
 function global_footer()
 {
     global $_G;
     if ($_G['mod'] == 'forumdisplay' || $_G['mod'] == 'viewthread' || $_G['mod'] == 'post' || $_G['mod'] == 'redirect') {
         $fiddb = DB::fetch_first("SELECT * FROM " . DB::table('dsu_marcofidts') . " WHERE fid='" . intval($_G['fid']) . "'");
         $groups = explode(",", $fiddb['groups']);
         if ($_G['fid'] == $fiddb['fid'] && in_array($_G['groupid'], $groups)) {
             if (!$_G['cookie']["dsu_marcofidts_{$_G[fid]}"]) {
                 dsetcookie('dsu_marcofidts_back', base64_encode($_SERVER['REQUEST_URI']));
                 dheader('Location: plugin.php?id=dsu_marcofidts&fid=' . intval($_G['fid']) . '');
             }
         }
     }
 }
Esempio n. 20
0
function setloginstatus($member, $cookietime)
{
    global $_G;
    $_G['uid'] = $member['uid'];
    $_G['username'] = $member['username'];
    $_G['adminid'] = $member['adminid'];
    $_G['groupid'] = $member['groupid'];
    $_G['formhash'] = formhash();
    $_G['session']['invisible'] = getuserprofile('invisible');
    $_G['member'] = $member;
    $_G['core']->session->isnew = 1;
    dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}", 'ENCODE'), $cookietime, 1, true);
    dsetcookie('loginuser');
    dsetcookie('activationauth');
    dsetcookie('pmnum');
}
Esempio n. 21
0
function connect_login($connect_member)
{
    global $_G;
    if (!($member = getuserbyuid($connect_member['uid'], 1))) {
        return false;
    } else {
        if (isset($member['_inarchive'])) {
            C::t('common_member_archive')->move_to_master($member['uid']);
        }
    }
    require_once libfile('function/member');
    $cookietime = 1296000;
    setloginstatus($member, $cookietime);
    dsetcookie('connect_login', 1, $cookietime);
    dsetcookie('connect_is_bind', '1', 31536000);
    dsetcookie('connect_uin', $connect_member['conopenid'], 31536000);
    return true;
}
Esempio n. 22
0
function updatesession($force = false)
{
    global $_G;
    static $updated = false;
    if (!$updated) {
        if ($_G['uid']) {
            if ($_G['cookie']['ulastactivity']) {
                $ulastactivity = authcode($_G['cookie']['ulastactivity'], 'DECODE');
            } else {
                $ulastactivity = getuserprofile('lastactivity');
                dsetcookie('ulastactivity', authcode($ulastactivity, 'ENCODE'), 31536000);
            }
        }
        $discuz =& discuz_core::instance();
        $oltimespan = $_G['setting']['oltimespan'];
        $lastolupdate = $discuz->session->var['lastolupdate'];
        if ($_G['uid'] && $oltimespan && TIMESTAMP - ($lastolupdate ? $lastolupdate : $ulastactivity) > $oltimespan * 60) {
            DB::query("UPDATE " . DB::table('common_onlinetime') . "\r\n\t\t\t\tSET total=total+'{$oltimespan}', thismonth=thismonth+'{$oltimespan}', lastupdate='" . TIMESTAMP . "'\r\n\t\t\t\tWHERE uid='{$_G['uid']}'");
            if (!DB::affected_rows()) {
                DB::insert('common_onlinetime', array('uid' => $_G['uid'], 'thismonth' => $oltimespan, 'total' => $oltimespan, 'lastupdate' => TIMESTAMP));
            }
            $discuz->session->set('lastolupdate', TIMESTAMP);
        }
        foreach ($discuz->session->var as $k => $v) {
            if (isset($_G['member'][$k]) && $k != 'lastactivity') {
                $discuz->session->set($k, $_G['member'][$k]);
            }
        }
        foreach ($_G['action'] as $k => $v) {
            $discuz->session->set($k, $v);
        }
        $discuz->session->update();
        $updated = true;
        if ($_G['uid'] && TIMESTAMP - $ulastactivity > 21600) {
            if ($oltimespan && TIMESTAMP - $ulastactivity > 43200) {
                $total = DB::result_first("SELECT total FROM " . DB::table('common_onlinetime') . " WHERE uid='{$_G['uid']}'");
                DB::update('common_member_count', array('oltime' => round(intval($total) / 60)), "uid='{$_G['uid']}'", 1);
            }
            dsetcookie('ulastactivity', authcode(TIMESTAMP, 'ENCODE'), 31536000);
            DB::update('common_member_status', array('lastip' => $_G['clientip'], 'lastactivity' => TIMESTAMP, 'lastvisit' => TIMESTAMP), "uid='{$_G['uid']}'", 1);
        }
    }
    return $updated;
}
Esempio n. 23
0
 private function _setThreadSupport($res, $tid, $action)
 {
     global $_G;
     require_once libfile('function/forum');
     dsetcookie('discuz_recommend', '', -1, 0);
     $thread = C::t('forum_thread')->fetch($tid);
     if (!$_G['setting']['recommendthread']['status'] || !$_G['group']['allowrecommend']) {
         return $this->makeErrorInfo($res, 'no_privilege_recommend');
     }
     if ($thread['authorid'] == $_G['uid'] && !$_G['setting']['recommendthread']['ownthread']) {
         return $this->makeErrorInfo($res, 'recommend_self_disallow', array('{recommendc}' => $thread['recommends']));
     }
     if (C::t('forum_memberrecommend')->fetch_by_recommenduid_tid($_G['uid'], $tid)) {
         return $this->makeErrorInfo($res, 'recommend_duplicate', array('{recommendc}' => $thread['recommends']));
     }
     $recommendcount = C::t('forum_memberrecommend')->count_by_recommenduid_dateline($_G['uid'], $_G['timestamp'] - 86400);
     if ($_G['setting']['recommendthread']['daycount'] && $recommendcount >= $_G['setting']['recommendthread']['daycount']) {
         return $this->makeErrorInfo($res, 'recommend_outoftimes', array('{recommendc}' => $thread['recommends']));
     }
     $_G['group']['allowrecommend'] = intval($action == 'support' ? $_G['group']['allowrecommend'] : -$_G['group']['allowrecommend']);
     $fieldarr = array();
     if ($action == 'support') {
         $heatadd = 'recommend_add=recommend_add+1';
         $fieldarr['recommend_add'] = 1;
     } else {
         $heatadd = 'recommend_sub=recommend_sub+1';
         $fieldarr['recommend_sub'] = 1;
     }
     update_threadpartake($tid);
     $fieldarr['heats'] = 0;
     $fieldarr['recommends'] = $_G['group']['allowrecommend'];
     C::t('forum_thread')->increase($tid, $fieldarr);
     C::t('forum_memberrecommend')->insert(array('tid' => $tid, 'recommenduid' => $_G['uid'], 'dateline' => $_G['timestamp']));
     dsetcookie('recommend', 1, 43200);
     $recommendv = $_G['group']['allowrecommend'] > 0 ? '+' . $_G['group']['allowrecommend'] : $_G['group']['allowrecommend'];
     if ($_G['setting']['recommendthread']['daycount']) {
         $daycount = $_G['setting']['recommendthread']['daycount'] - $recommendcount;
         $params = array('noError' => 1, '{recommendv}' => $recommendv, '{recommendc}' => $thread['recommends'], '{daycount}' => $daycount);
         return $this->makeErrorInfo($res, 'recommend_daycount_succeed', $params);
     } else {
         $params = array('noError' => 1, '{recommendv}' => $recommendv, '{recommendc}' => $thread['recommends']);
         return $this->makeErrorInfo($res, 'recommend_succed', $params);
     }
 }
Esempio n. 24
0
 function global_footer()
 {
     global $_G;
     if ($_G['uid']) {
         if (!$this->cookiefooter) {
             $query = DB::fetch_first("SELECT * FROM " . DB::table("plugin_dsuampper") . " WHERE uid = '{$_G['uid']}'");
             $lasttime = dgmdate($query['lasttime'], 'Ymd', $this->vars['offset']);
         } else {
             $lasttime = $this->cookiefooter;
         }
         if ($lasttime <= dgmdate($_G['timestamp'] - 86400, 'Ymd', $this->vars['offset']) && !$this->cookieforce && $_G['mod'] != 'post') {
             $return = "<script>showWindow('pper', 'plugin.php?id=dsu_amupper:ppering');</script>";
         }
         if (!$_G['cache']['plugin']['dsu_amupper']['force'] && !$this->cookieforce) {
             dsetcookie('dsu_amupper_force' . $_G['uid'], $_G['timestamp'], 600);
         }
     }
     return $return;
 }
Esempio n. 25
0
 function common()
 {
     global $_G, $seccodecheck, $secqaacheck, $connect_guest;
     if ($_G['uid'] && $_G['member']['conisbind']) {
         dheader('location: ' . $_G['siteurl'] . 'index.php');
     }
     $connect_guest = array();
     if ($_G['connectguest'] && (submitcheck('regsubmit', 0, $seccodecheck, $secqaacheck) || submitcheck('loginsubmit', 1, $seccodestatus))) {
         if (!$_GET['auth_hash']) {
             $_GET['auth_hash'] = $_G['cookie']['con_auth_hash'];
         }
         $conopenid = authcode($_GET['auth_hash']);
         $connect_guest = C::t('#qqconnect#common_connect_guest')->fetch($conopenid);
         if (!$connect_guest) {
             dsetcookie('con_auth_hash');
             showmessage('qqconnect:connect_login_first');
         }
     }
 }
	function global_footer() {
		global $db, $tablepre, $discuz_uid, $discuz_user, $scriptlang;
		if(!$discuz_uid) {
			return;
		}

		@include DISCUZ_ROOT.'./forumdata/cache/plugin_myrepeats.php';
		$_DPLUGIN['myrepeats']['vars']['usergroups'] = (array)unserialize($_DPLUGIN['myrepeats']['vars']['usergroups']);
		if(in_array('', $_DPLUGIN['myrepeats']['vars']['usergroups'])) {
			$_DPLUGIN['myrepeats']['vars']['usergroups'] = array();
		}
		if(!in_array($GLOBALS['groupid'], $_DPLUGIN['myrepeats']['vars']['usergroups'])) {
			if(isset($GLOBALS['_DCOOKIE']['mrn'])) {
				$count = $GLOBALS['_DCOOKIE']['mrn'];
			} else {
				$count = $db->result_first("SELECT COUNT(*) FROM {$tablepre}myrepeats WHERE username='******'");
				dsetcookie('mrn', $count, 3600);
			}
			if(!$count) {
				return;
			}
		}

		if(isset($GLOBALS['_DCOOKIE']['mrd'])) {
			$userlist = explode("\t", $GLOBALS['_DCOOKIE']['mrd']);
		} else {
			$userlist = array();
			$query = $db->query("SELECT username FROM {$tablepre}myrepeats WHERE uid='$discuz_uid'");
			while($user = $db->fetch_array($query)) {
				$userlist[] = $user['username'];
			}
			dsetcookie('mrd', implode("\t", $userlist), 3600);
		}
		$widthstr = count($userlist) > 5 ? ' inlinelist" style="width:255px;' : '" style="';
		$list = '<script>$(\'umenu\').innerHTML = \'<span id="myrepeats" onmouseover="showMenu(this.id)">['.$scriptlang['myrepeats']['switch'].']</span>\' + $(\'umenu\').innerHTML;</script><ul id="myrepeats_menu" class="popupmenu_popup'.$widthstr.'display:none;">';
		foreach($userlist as $user) {
			$user = stripslashes($user);
			$list .= '<li class="wide"><a href="plugin.php?id=myrepeats:switch&username='******'">'.$user.'</a></li>';
		}
		$list .= '<li class="wide" style="clear:both"><a href="plugin.php?id=myrepeats:memcp">'.$scriptlang['myrepeats']['memcp'].'</a></li></ul>';
		return $list;
	}
Esempio n. 27
0
function make_secqaa($idhash)
{
    global $_G;
    loadcache('secqaa');
    $secqaakey = max(1, random(1, 1));
    if ($_G['cache']['secqaa'][$secqaakey]['type']) {
        if (file_exists($qaafile = libfile('secqaa/' . $_G['cache']['secqaa'][$secqaakey]['question'], 'class'))) {
            @(include_once $qaafile);
            $class = 'secqaa_' . $_G['cache']['secqaa'][$secqaakey]['question'];
            if (class_exists($class)) {
                $qaa = new $class();
                if (method_exists($qaa, 'make')) {
                    $_G['cache']['secqaa'][$secqaakey]['answer'] = md5($qaa->make($_G['cache']['secqaa'][$secqaakey]['question']));
                }
            }
        }
    }
    dsetcookie('secqaa' . $idhash, authcode($_G['cache']['secqaa'][$secqaakey]['answer'] . "\t" . (TIMESTAMP - 180) . "\t" . $idhash . "\t" . FORMHASH, 'ENCODE', $_G['config']['security']['authkey']), 0, 1, true);
    return $_G['cache']['secqaa'][$secqaakey]['question'];
}
Esempio n. 28
0
function updategroupcreditlog($fid, $uid)
{
    global $_G;
    if (empty($fid) || empty($uid)) {
        return false;
    }
    $today = date('Ymd', TIMESTAMP);
    $updategroupcredit = getcookie('groupcredit_' . $fid);
    if ($updategroupcredit < $today) {
        $status = C::t('forum_groupcreditslog')->check_logdate($fid, $uid, $today);
        if (empty($status)) {
            C::t('forum_forum')->update_commoncredits($fid);
            C::t('forum_groupcreditslog')->insert(array('fid' => $fid, 'uid' => $uid, 'logdate' => $today), false, true);
            if (empty($_G['forum']) || empty($_G['forum']['level'])) {
                $forum = C::t('forum_forum')->fetch($fid);
                $forum = array('name' => $forum['name'], 'level' => $forum['level'], 'commoncredits' => $forum['commoncredits']);
            } else {
                $_G['forum']['commoncredits']++;
                $forum =& $_G['forum'];
            }
            if (empty($_G['grouplevels'])) {
                loadcache('grouplevels');
            }
            $grouplevel = $_G['grouplevels'][$forum['level']];
            if ($grouplevel['type'] == 'default' && !($forum['commoncredits'] >= $grouplevel['creditshigher'] && $forum['commoncredits'] < $grouplevel['creditslower'])) {
                $levelinfo = C::t('forum_grouplevel')->fetch_by_credits($forum['commoncredits']);
                $levelid = $levelinfo['levelid'];
                if (!empty($levelid)) {
                    C::t('forum_forum')->update_group_level($levelid, $fid);
                    $query = C::t('forum_forumfield')->fetch($fid);
                    $groupfounderuid = $query['founderuid'];
                    notification_add($groupfounderuid, 'system', 'grouplevel_update', array('groupname' => '<a href="forum.php?mod=group&fid=' . $fid . '">' . $forum['name'] . '</a>', 'newlevel' => $_G['grouplevels'][$levelid]['leveltitle'], 'from_id' => 0, 'from_idtype' => 'changeusergroup'));
                }
            }
        }
        dsetcookie('groupcredit_' . $fid, $today, 86400);
    }
}
Esempio n. 29
0
 function plugin_myrepeats()
 {
     global $_G;
     if (!$_G['uid']) {
         return;
     }
     $myrepeatsusergroups = (array) dunserialize($_G['cache']['plugin']['myrepeats']['usergroups']);
     if (in_array('', $myrepeatsusergroups)) {
         $myrepeatsusergroups = array();
     }
     $userlist = array();
     if (!in_array($_G['groupid'], $myrepeatsusergroups)) {
         if (!isset($_G['cookie']['myrepeat_rr'])) {
             $users = count(C::t('#myrepeats#myrepeats')->fetch_all_by_username($_G['username']));
             dsetcookie('myrepeat_rr', 'R' . $users, 86400);
         } else {
             $users = substr($_G['cookie']['myrepeat_rr'], 1);
         }
         if (!$users) {
             return '';
         }
     }
     $this->value['global_usernav_extra1'] = '<script>' . 'function showmyrepeats() {if(!$(\'myrepeats_menu\')) {' . 'menu=document.createElement(\'div\');menu.id=\'myrepeats_menu\';menu.style.display=\'none\';menu.className=\'p_pop\';' . '$(\'append_parent\').appendChild(menu);' . 'ajaxget(\'plugin.php?id=myrepeats:switch&list=yes\',\'myrepeats_menu\',\'ajaxwaitid\');}' . 'showMenu({\'ctrlid\':\'myrepeats\',\'duration\':2});}' . '</script>' . '<span class="pipe">|</span><a id="myrepeats" href="home.php?mod=spacecp&ac=plugin&id=myrepeats:memcp" class="showmenu cur1" onmouseover="delayShow(this, showmyrepeats)">' . lang('plugin/myrepeats', 'switch') . '</a>' . "\n";
 }
Esempio n. 30
0
 function init_cookie()
 {
     global $cookiever, $uid, $username;
     $cookiever = '2';
     if (!empty($_COOKIE['token'])) {
         list($cc, $uid, $username, $exptime, $password) = explode("\t", authcode($_COOKIE['token'], 'DECODE'));
         if (!$uid || $cc != $cookiever) {
             unset($uid, $username, $exptime);
             dsetcookie('token');
         } elseif ($exptime < TIMESTAMP) {
             $user = DB::fetch_first("SELECT * FROM member WHERE uid='{$uid}'");
             $_password = substr(md5($user['password']), 8, 8);
             if ($user && $password == $_password) {
                 $exptime = TIMESTAMP + 900;
                 dsetcookie('token', authcode("{$cookiever}\t{$uid}\t{$user[username]}\t{$exptime}\t{$password}", 'ENCODE'));
             } else {
                 unset($uid, $username, $exptime);
                 dsetcookie('token');
             }
         }
     } else {
         $uid = $username = '';
     }
 }