function post() { global $_G; if ($_GET['onsubmit'] && check()) { $arr = array(); $arr['title'] = trim_html($_GET['title'], 1); $arr['fid'] = intval($_GET['fid']); $value = $_GET['postdb']; $arr['value'] = serialize($value); $url = ''; if ($_GET['id']) { $id = intval($_GET['id']); DB::update(__CLASS__, $arr, "id=" . $id); $url = '&id=' . $id; $msg = '修改'; } else { $msg = '添加'; $arr['dateline'] = TIMESTAMP; $arr['count'] = 0; $arr['updatetime'] = 0; $arr['count'] = 0; DB::insert(__CLASS__, $arr, true); } cpmsg($msg . '成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url); } elseif ($_GET['id']) { $id = intval($_GET['id']); $rs = DB::fetch_first("SELECT * FROM " . DB::table('fetch') . " WHERE id = " . $id); $fetch = dunserialize($rs['value']); $fetch = array_merge($fetch, $rs); //dump($fetch); } $cates = (include libfile('config/taobao_cate')); $this->add(array('cates' => $cates, 'fetch' => $fetch)); $this->show(); }
function run($cronid = 0) { global $_G; $timestamp = TIMESTAMP; $cron = DB::fetch_first("SELECT * FROM " . DB::table('common_cron') . "\n\t\t\t\tWHERE " . ($cronid ? "cronid='{$cronid}'" : "available>'0' AND nextrun<='{$timestamp}'") . "\n\t\t\t\tORDER BY nextrun LIMIT 1"); $processname = 'DZ_CRON_' . (empty($cron) ? 'CHECKER' : $cron['cronid']); if ($cronid && !empty($cron)) { discuz_process::unlock($processname); } if (discuz_process::islocked($processname, 600)) { return false; } if ($cron) { $cron['filename'] = str_replace(array('..', '/', '\\'), '', $cron['filename']); $cronfile = DISCUZ_ROOT . './source/include/cron/' . $cron['filename']; $cron['minute'] = explode("\t", $cron['minute']); discuz_cron::setnextime($cron); @set_time_limit(1000); @ignore_user_abort(TRUE); if (!@(include $cronfile)) { return false; } } discuz_cron::nextcron(); discuz_process::unlock($processname); return true; }
function delete($value, $key = "id") { global $_G; if (!$value) { return array('status' => 'error', 'msg' => '要删除的图片值不能为空'); } $value = addslashes($value); $key = addslashes($key); $rs = DB::fetch_first("SELECT * FROM " . DB::table('images') . " WHERE {$key} = '{$value}'"); if (!$rs['id']) { return array('status' => 'error', 'msg' => '图片不存在,或不是通过后台上传的,如果图片连接失效,您可手动清空图片内容', 'a' => 'readonly'); } if ($rs['location'] == 1) { if ($_G[adminid] != 1 && $_G[uid] != $rs[uid]) { return array('status' => 'error', 'msg' => '您无法删除非自己上传的图片', 'a' => 'readonly'); } DB::delete('images', "id=" . $rs[id]); @unlink(ROOT_PATH . $rs[img_url]); return array('status' => 'success', 'msg' => '删除成功,请提交表单保存', 'a' => 'del'); } $response = $imgService->deleteUZImgById($rs['img_id']); if ($response->isSuccess()) { DB::delete('images', "id=" . $rs[id]); return array('status' => 'success', 'msg' => '删除成功,请提交表单保存', 'a' => 'del'); } else { return array('status' => 'error', 'msg' => '图片删除失败' . $response->getErrorMsg()); } }
public function fetch_by_aid_page($aid, $page = 1) { if (($page = dintval($page)) < 1) { $page = 1; } return $aid ? DB::fetch_first('SELECT * FROM %t WHERE aid=%d ORDER BY pageorder' . DB::LIMIT($page - 1, 1), array($this->_table, $aid)) : false; }
public function fetch_userinfo($uid, $fid) { if (empty($uid) || empty($fid)) { return array(); } return DB::fetch_first("SELECT * FROM %t WHERE fid=%d AND uid=%d", array($this->_table, $fid, $uid)); }
function fastpick_info($id = '', $field = '*', $table = 'fastpick') { global $_G; $id = $id ? $id : $_GET['id']; $id = intval($id); return DB::fetch_first("SELECT {$field} FROM " . DB::table('strayer_' . $table) . " WHERE id='{$id}'"); }
function account_bind_info($uid, $key = null, $cache = 1) { static $S_account_bind_info = null; $uid = is_numeric($uid) ? $uid : 0; if ($uid < 1) { return false; } if (!$cache || !isset($S_account_bind_info[$uid])) { $memberfields = array(); if ($uid === MEMBER_ID) { $memberfields = $GLOBALS['_J']['member']; } if (!isset($memberfields['account_bind_info'])) { $memberfields = DB::fetch_first("SELECT `uid`, `account_bind_info` FROM " . DB::table('memberfields') . " WHERE `uid`='{$uid}' "); } if ($memberfields['account_bind_info']) { $memberfields['account_bind_info'] = unserialize(base64_decode($memberfields['account_bind_info'])); } else { return false; } $S_account_bind_info[$uid] = $memberfields['account_bind_info']; } if (is_null($key)) { return $S_account_bind_info[$uid]; } else { if (is_null($S_account_bind_info[$uid][$key])) { return false; } else { return $S_account_bind_info[$uid][$key]; } } }
function global_header_mobile() { global $_G, $show_message; function dsu_signtz() { dheader('Location: plugin.php?id=dsu_paulsign:sign&mobile=yes'); } $var = $_G['cache']['plugin']['dsu_paulsign']; if (defined('IN_dsu_paulsign') || $show_message || defined('IN_dsu_paulsc') || !$_G['uid'] || !$var['ifopen'] || !$var['wap_sign']) { return ''; } $tdtime = gmmktime(0, 0, 0, dgmdate($_G['timestamp'], 'n', $var['tos']), dgmdate($_G['timestamp'], 'j', $var['tos']), dgmdate($_G['timestamp'], 'Y', $var['tos'])) - $var['tos'] * 3600; $allowmem = memory('check'); if ($var['ftopen'] && in_array($_G['groupid'], unserialize($var['tzgroupid'])) && !in_array($_G['uid'], explode(",", $var['ban'])) && in_array($_G['groupid'], unserialize($var['groups']))) { if ($allowmem && $var['mcacheopen']) { $signtime = memory('get', 'dsu_pualsign_' . $_G['uid']); } if (!$signtime) { $qiandaodb = DB::fetch_first("SELECT time FROM " . DB::table('dsu_paulsign') . " WHERE uid='{$_G['uid']}'"); $signtime = $qiandaodb['time']; $htime = dgmdate($_G['timestamp'], 'H', $var['tos']); if ($qiandaodb) { if ($allowmem && $var['mcacheopen']) { memory('set', 'dsu_pualsign_' . $_G['uid'], $qiandaodb['time'], 86400); } if ($qiandaodb['time'] < $tdtime) { if ($var['timeopen']) { if (!($htime < $var['stime']) && !($htime > $var['ftime'])) { return dsu_signtz(); } } else { return dsu_signtz(); } } } else { $ttps = DB::fetch_first("SELECT posts FROM " . DB::table('common_member_count') . " WHERE uid='{$_G['uid']}'"); if ($var['mintdpost'] <= $ttps['posts']) { if ($var['timeopen']) { if (!($htime < $var['stime']) && !($htime > $var['ftime'])) { return dsu_signtz(); } } else { return dsu_signtz(); } } } } else { if ($signtime < $tdtime) { if ($var['timeopen']) { if (!($htime < $var['stime']) && !($htime > $var['ftime'])) { return dsu_signtz(); } } else { return dsu_signtz(); } } } } return '<a href="plugin.php?id=dsu_paulsign:sign">' . lang('plugin/dsu_paulsign', 'name') . '</a>'; }
public function insert($tid, $uid) { if (!DB::fetch_first('SELECT * FROM %t WHERE tid=%d AND uid=%d', array($this->_table, $tid, $uid))) { DB::insert($this->_table, array('tid' => $tid, 'uid' => $uid)); DB::query("UPDATE %t SET hidden=hidden+1 WHERE tid=%d", array('forum_thread', $tid)); } }
function updatersscache($num) { global $_G; $processname = 'portal_rss_cache'; if (discuz_process::islocked($processname, 600)) { return false; } DB::query("DELETE FROM " . DB::table('portal_rsscache') . ""); require_once libfile('function/post'); foreach ($_G['cache']['portalcategory'] as $catid => $catarray) { $query = DB::query("SELECT aid, username, author, dateline, title, summary\r\n\t\t\tFROM " . DB::table('portal_article_title') . "\r\n\t\t\tWHERE catid='{$catid}' AND status=0\r\n\t\t\tORDER BY aid DESC LIMIT {$num}"); $catarray['catname'] = addslashes($catarray['catname']); while ($article = DB::fetch($query)) { $article['author'] = $article['author'] != '' ? addslashes($article['author']) : ($article['username'] ? addslashes($article['username']) : 'Anonymous'); $article['title'] = addslashes($article['title']); $articleattach = DB::fetch_first("SELECT * FROM " . DB::table('portal_attachment') . " WHERE aid='" . $article['aid'] . "' AND isimage=1"); $attachdata = ''; if (!empty($articleattach)) { $attachdata = "\t" . $articleattach['remote'] . "\t" . $articleattach['attachment'] . "\t" . $articleattach['filesize']; } $article['description'] = addslashes(messagecutstr($article['summary'], 250 - strlen($attachdata)) . $attachdata); DB::query("REPLACE INTO " . DB::table('portal_rsscache') . " (lastupdate, catid, aid, dateline, catname, author, subject, description)\r\n\t\t\t\tVALUES ('{$_G['timestamp']}', '{$catid}', '{$article['aid']}', '{$article['dateline']}', '{$catarray['catname']}', '{$article['author']}', '{$article['title']}', '{$article['description']}')"); } } discuz_process::unlock($processname); return true; }
public function init($bz, $isguest = 0) { global $_G; $bzarr = explode(':', $bz); $id = trim($bzarr[1]); if (!($root = DB::fetch_first("select access_id,bucket,cloudname,bz,access_key,uid from " . DB::table(self::T) . " where id='{$id}'"))) { return array('error' => 'need authorize to ' . $bzarr[0]); } if (!$isguest && $root['uid'] > 0 && $root['uid'] != $_G['uid']) { return array('error' => 'need authorize to JSS'); } $access_id = authcode($root['access_id'], 'DECODE', $root['bz']); if (empty($access_id)) { $access_id = $root['access_id']; } $access_key = authcode($root['access_key'], 'DECODE', $root['bz']); if ($root['cloudname']) { $this->_rootname = $root['cloudname']; } else { $this->_rootname .= ':' . ($root['bucket'] ? $root['bucket'] : cutstr($access_id, 4, $dot = '')); } $this->bucket = $root['bucket']; try { return new JingdongStorageService($access_id, $access_key); } catch (Exception $e) { return array('error' => $e->getMessage()); } }
function send() { $to_user = jfilter($this->Post['to_user'], 'txt'); $member = DB::fetch_first("SELECT `nickname` FROM " . DB::table("members") . " WHERE `nickname`='{$to_user}'"); if (empty($member)) { Mobile::error("No User", 300); } $this->Post['message'] = jpost('message', 'txt'); $to_user = $member['nickname']; $data = array('to_user' => $to_user, 'message' => trim($this->Post['message'])); $ret = $this->MyPmLogic->pmSend($data); if ($ret == 0) { Mobile::success("Success"); } else { if ($ret == 1) { Mobile::error("Content not emtpy", 420); } else { if ($ret == 2) { Mobile::error("Content not emtpy", 321); } else { if (ret == 3) { Mobile::error("Content not emtpy", 321); } } } } Mobile::error("Unkonw error", 250); }
function viewthread_sidetop_output($a) { //var_dump($a); global $_G, $postlist; if ($a["template"] == "viewthread") { $aid = $_G['forum_thread']['authorid']; $return = array(); $tid = $_G['tid']; if ($postlist && $aid) { foreach ($postlist as $value) { if ($value['first']) { $amu_query = DB::fetch_first("SELECT * FROM " . DB::table("plugin_dsuampper") . " WHERE uid= '{$aid}'"); if ($amu_query) { $today = $this->vars['today']; $lasttime = dgmdate($query['lasttime'], 'Ymd', $this->vars['offset']); } if (!$amu_query['addup'] || $today != $lasttime) { $addup = $amu_query['addup'] ? $amu_query['addup'] : 0; $return[0] = '<dl class="pil cl"><dt><a href="plugin.php?id=dsu_amupper:list" target="_blank" class="xi2">' . lang('plugin/dsu_amupper', 'vw') . '</a></dt><dd>' . $addup . '</dd></dl>'; } if ($amu_query && $today == $lasttime) { $addup = $amu_query['addup'] ? $amu_query['addup'] : 0; $return[0] = '<dl class="pil cl"><dt><a href="plugin.php?id=dsu_amupper:list" target="_blank" class="xi2">' . lang('plugin/dsu_amupper', 'vw') . '</a></dt><dd><b>' . $addup . '</b></dd></dl>'; } } } } } else { $return = array(); } return $return; }
public function fetch_by_id($id) { $value = self::fetch($id); $cloud = DB::fetch_first("select * from " . DB::table('connect') . " where bz='{$value['bz']}'"); $data = array('id' => $value['id'], 'fid' => md5($cloud['bz'] . ':' . $value['id'] . ':' . $cloud['root']), 'pfid' => 0, 'fname' => $value['cloudname'], 'ficon' => 'dzz/images/default/system/' . $cloud['bz'] . '.png', 'bz' => $cloud['bz'] . ':' . $value['id'] . ':', 'path' => $cloud['bz'] . ':' . $value['id'] . ':' . $cloud['root'], 'type' => 'ftp', 'fsperm' => perm_FolderSPerm::flagPower($cloud['bz']), 'perm' => perm_binPerm::getGroupPower('all'), 'flag' => $cloud['bz'], 'iconview' => 1, 'disp' => '0'); return $data; }
function usesubmit() { global $_G; if (empty($_G['gp_pid'])) { showmessage(lang('magic/repent', 'repent_info_nonexistence')); } $_G['tid'] = $_G['gp_ptid']; $post = getpostinfo($_G['gp_pid'], 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid', 'p.replycredit', 't.status as thread_status')); $this->_check($post); require_once libfile('function/post'); require_once libfile('function/delete'); if ($post['first']) { if ($have_replycredit = DB::fetch_first("SELECT * FROM " . DB::table('forum_replycredit') . " WHERE tid ='{$post['tid']}' LIMIT 1")) { if ($replycredit = DB::result_first("SELECT replycredit FROM " . DB::table('forum_thread') . " WHERE tid = '{$post['tid']}'")) { updatemembercount($post['authorid'], array($_G['setting']['creditstransextra'][10] => $replycredit)); } DB::delete('forum_replycredit', "tid = '{$post['tid']}'"); DB::delete('common_credit_log', "operation IN ('RCT', 'RCA', 'RCB') AND relatedid IN({$post['tid']})"); } deletethread(array($post['tid'])); updateforumcount($post['fid']); } else { if ($post['replycredit'] > 0) { updatemembercount($post['authorid'], array($_G['setting']['creditstransextra'][10] => -$post['replycredit'])); DB::delete('common_credit_log', "uid = '{$post['authorid']}' AND operation = 'RCA' AND relatedid IN({$post['tid']})"); } deletepost(array($_G['gp_pid'])); updatethreadcount($post['tid']); } usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_G['tid']); showmessage(lang('magic/repent', 'repent_succeed'), $post['first'] ? 'forum.php?mod=forumdisplay&fid=' . $post['fid'] : dreferer(), array(), array('showdialog' => 1, 'locationtime' => true)); }
function checkfield() { global $_G; $fields = lang('task/profile', 'profile_fields'); loadcache('profilesetting'); $fieldsql = array(); foreach ($fields as $k => $v) { $nk = explode('.', $k); if (isset($_G['cache']['profilesetting'][$nk[1]])) { $fieldsnew[$nk[1]] = $v; $fieldsql[] = $k; } } if ($fieldsql) { $result = DB::fetch_first("SELECT " . implode(',', $fieldsql) . " FROM " . DB::table('common_member') . " m LEFT JOIN " . DB::table('common_member_profile') . " mp ON m.uid=mp.uid WHERE m.uid='{$_G['uid']}'"); $none = array(); foreach ($result as $k => $v) { if (!trim($v)) { $none[] = $fieldsnew[$k]; } } $csc = intval((count($fields) - count($none)) / count($fields) * 100); return array($none, $csc); } else { return true; } }
function usesubmit() { global $_G; $id = intval($_G['gp_id']); if (empty($id)) { showmessage(lang('magic/namepost', 'namepost_info_nonexistence')); } $idtype = !empty($_G['gp_idtype']) ? htmlspecialchars($_G['gp_idtype']) : ''; if (!in_array($idtype, array('pid', 'cid'))) { showmessage(lang('magic/namepost', 'namepost_use_error')); } if ($idtype == 'pid') { $_G['tid'] = intval($_G['gp_ptid']); $post = getpostinfo($id, 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid', 'p.dateline', 'p.anonymous')); $this->_check($post); $authorid = $post['authorid']; $author = $post['anonymous'] ? '' : 1; } elseif ($idtype == 'cid') { $comment = DB::fetch_first("SELECT * FROM " . DB::table('home_comment') . " WHERE cid='{$id}'"); $authorid = $comment['authorid']; $author = $comment['author']; } if ($author) { showmessage('magicuse_bad_object'); } $member = DB::fetch_first("SELECT username, groupid FROM " . DB::table('common_member') . " WHERE uid='{$authorid}'"); if (!checkmagicperm($this->parameters['targetgroups'], $member['groupid'])) { showmessage(lang('magic/namepost', 'namepost_info_user_noperm')); } $author = daddslashes($member['username']); usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, $idtype, $id); showmessage(lang('magic/namepost', 'magic_namepost_succeed'), 'javascript:;', array('uid' => $authorid, 'username' => $author, 'avatar' => 1)); }
function getdata($style, $parameter) { $advid = 0; if (!empty($parameter['title'])) { $parameter['title'] = addslashes($parameter['title']); $adv = DB::fetch_first('SELECT * FROM ' . DB::table('common_advertisement_custom') . " WHERE name='{$parameter['title']}'"); if (empty($adv)) { $advid = DB::insert('common_advertisement_custom', array('name' => $parameter['title']), 1); } else { $advid = $adv['id']; } } elseif (!empty($parameter['adv'])) { $parameter['adv'] = addslashes($parameter['adv']); $adv = DB::fetch_first('SELECT * FROM ' . DB::table('common_advertisement_custom') . " WHERE name='{$parameter['adv']}'"); $advid = intval($adv['id']); } else { $return = 'Empty Ads'; } if ($advid) { $flag = false; if (getglobal('inajax')) { $flag = true; setglobal('inajax', 0); } $return = adshow('custom_' . $advid); if ($flag) { setglobal('inajax', 1); } } return array('html' => $return, 'data' => null); }
function viewthread_top_output() { global $_G; $ofids = unserialize($_G['cache']['plugin']['dsu_paulissue']['ofid']); if (!in_array($_G['fid'], $ofids)) { return ''; } $tdb = DB::fetch_first("SELECT paulissue_status,paulissue_hide,displayorder FROM " . DB::table('forum_thread') . " WHERE tid='{$_G['tid']}'"); if ($tdb['paulissue_hide']) { $another = '<span><a href="javascript:;" onclick="showWindow(\'dsu_paulissue\', \'plugin.php?id=dsu_paulissue:dsu_paulissue&formhash=' . FORMHASH . '&to=4&tid=' . $_G['tid'] . '\')">' . lang('plugin/dsu_paulissue', 'xszt') . '</a></span>'; } else { $another = '<span><a href="javascript:;" onclick="showWindow(\'dsu_paulissue\', \'plugin.php?id=dsu_paulissue:dsu_paulissue&formhash=' . FORMHASH . '&to=3&tid=' . $_G['tid'] . '\')">' . lang('plugin/dsu_paulissue', 'yczt') . '</a></span>'; } if (in_array($tdb['displayorder'], array('1', '2', '3'))) { return ''; } elseif ($_G['forum']['ismoderator']) { if ($tdb['paulissue_status'] == '0') { return '<link rel="stylesheet" type="text/css" href="source/plugin/dsu_paulissue/images/style.css" /><div class="fast_mini" id="fast_mini"><div><h2>' . lang('plugin/dsu_paulissue', 'glcz') . '</h2><span><a href="javascript:;" onclick="showWindow(\'dsu_paulissue\', \'plugin.php?id=dsu_paulissue:dsu_paulissue&formhash=' . FORMHASH . '&to=1&tid=' . $_G['tid'] . '\')">' . lang('plugin/dsu_paulissue', 'wtjjz') . '</a></span><span><a href="javascript:;" onclick="showWindow(\'dsu_paulissue\', \'plugin.php?id=dsu_paulissue:dsu_paulissue&formhash=' . FORMHASH . '&to=2&tid=' . $_G['tid'] . '\')">' . lang('plugin/dsu_paulissue', 'wtyjj') . '</a></span>' . $another . '</div></div>'; } elseif ($tdb['paulissue_status'] == '1') { return '<link rel="stylesheet" type="text/css" href="source/plugin/dsu_paulissue/images/style.css" /><div class="fast_mini" id="fast_mini"><div><h2>' . lang('plugin/dsu_paulissue', 'glcz') . '</h2><span><a href="javascript:;" onclick="showWindow(\'dsu_paulissue\', \'plugin.php?id=dsu_paulissue:dsu_paulissue&formhash=' . FORMHASH . '&to=2&tid=' . $_G['tid'] . '\')">' . lang('plugin/dsu_paulissue', 'wtyjj') . '</a></span>' . $another . '</div></div>'; } elseif ($tdb['paulissue_status'] == '2') { return '<link rel="stylesheet" type="text/css" href="source/plugin/dsu_paulissue/images/style.css" /><div class="fast_mini" id="fast_mini"><div><h2>' . lang('plugin/dsu_paulissue', 'glcz') . '</h2>' . $another . '</div></div>'; } } elseif ($_G['forum_thread']['authorid'] == $_G['uid']) { if (in_array($tdb['paulissue_status'], array('0', '1'))) { return '<link rel="stylesheet" type="text/css" href="source/plugin/dsu_paulissue/images/style.css" /><div class="fast_mini" id="fast_mini"><div><h2>' . lang('plugin/dsu_paulissue', 'twcz') . '</h2><span><a href="javascript:;" onclick="showWindow(\'dsu_paulissue\', \'plugin.php?id=dsu_paulissue:dsu_paulissue&formhash=' . FORMHASH . '&to=2&tid=' . $_G['tid'] . '\')">' . lang('plugin/dsu_paulissue', 'wtyjj') . '</a></span></div></div>'; } else { return ''; } } else { return ''; } }
function usesubmit() { global $_G; if (empty($_G['gp_username'])) { showmessage(lang('magic/checkonline', 'checkonline_info_nonexistence')); } $member = getuserinfo($_G['gp_username'], array('uid', 'groupid')); $this->_check($member['groupid']); $online = DB::fetch_first("SELECT action, lastactivity, invisible FROM " . DB::table('common_session') . " WHERE uid='{$member['uid']}'"); usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'uid', $member['uid']); if ($member['uid'] != $_G['uid']) { notification_add($member['uid'], 'magic', lang('magic/checkonline', 'checkonline_notification'), array('magicname' => $this->magic['name']), 1); } if ($online) { $time = dgmdate($online['lastactivity'], 'u'); if ($online['invisible']) { showmessage(lang('magic/checkonline', 'checkonline_hidden_message'), '', array('username' => stripslashes($_G['gp_username']), 'time' => $time), array('showdialog' => 1)); } else { showmessage(lang('magic/checkonline', 'checkonline_online_message'), '', array('username' => stripslashes($_G['gp_username']), 'time' => $time), array('showdialog' => 1)); } } else { showmessage(lang('magic/checkonline', 'checkonline_offline_message'), '', array('username' => stripslashes($_G['gp_username'])), array('showdialog' => 1)); } }
function get4Tip($sina_uid, $index = null, $default = null) { if ($this->info === null) { $sql = 'SELECT `profile` FROM ' . DB::table('xwb_bind_info') . ' WHERE sina_uid=' . $sina_uid; $this->info = DB::fetch_first($sql); } if (empty($this->info['profile'])) { if ($default !== null) { return $default; } return array(); } $object = @json_decode(preg_replace('#(?<=[,\\{\\[])\\s*("\\w+"):(\\d{6,})(?=\\s*[,\\]\\}])#si', '${1}:"${2}"', $this->info['profile']), true); if (!$object) { if ($default !== null) { return $default; } return array(); } if ($index) { if (isset($object[$index])) { return $object[$index]; } if ($default !== null) { return $default; } } return $object; }
public function fetch_by_id_idtype($id) { if (!$id) { return null; } return DB::fetch_first('SELECT * FROM %t WHERE %i', array($this->_table, DB::field('blogid', $id))); }
public function fetch_by_id_idtype($id, $idtype, $uid = 0) { if ($uid) { $uidsql = ' AND ' . DB::field('uid', $uid); } return DB::fetch_first("SELECT * FROM %t WHERE id=%d AND idtype=%s {$uidsql}", array($this->_table, $id, $idtype)); }
function userapp_update() { global $_G; if (!empty($_G['gp_id']) && is_numeric($_G['gp_id'])) { $applist = array(); $userapp = DB::fetch_first("SELECT appid FROM " . DB::table('home_userapp_plying') . " WHERE uid='{$_G['uid']}'"); if (!empty($userapp['appid'])) { $applist = explode(',', $userapp['appid']); if (!empty($applist)) { $applist = array_diff($applist, array('')); $key = array_search($_G['gp_id'], $applist); if ($key !== false) { unset($applist[$key]); } array_unshift($applist, $_G['gp_id']); while (count($applist) > $this->num) { array_pop($applist); } } } if (empty($applist)) { $applist = array($_G['gp_id']); } if (!empty($applist)) { $appstr = implode(',', $applist); DB::insert('home_userapp_plying', array('uid' => $_G['uid'], 'appid' => daddslashes($appstr)), false, true); } } }
function usesubmit() { global $_G; $info = array('credits' => intval($_POST['credits']), 'percredit' => intval($_POST['percredit']), 'credittype' => $_G['gp_credittype'], 'left' => intval($_POST['credits']), 'magicid' => intval($this->magic['magicid']), 'receiver' => array()); if ($info['credits'] < 1) { showmessage(lang('magic/gift', 'gift_bad_credits_input')); } if ($info['percredit'] < 1 || $info['percredit'] > $info['credits']) { showmessage(lang('magic/gift', 'gift_bad_percredit_input')); } $member = array(); if (preg_match('/^extcredits[1-8]$/', $info['credittype'])) { $member = DB::fetch_first('SELECT * FROM ' . DB::table('common_member_count') . " WHERE uid = '{$_G['uid']}'"); if ($member[$info['credittype']] < $info['credits']) { showmessage(lang('magic/gift', 'gift_credits_out_of_own')); } $extcredits = str_replace('extcredits', '', $info['credittype']); updatemembercount($_G['uid'], array($extcredits => -$info['credits']), 1, 'BGC', $this->magic['magicid']); } else { showmessage(lang('magic/gift', 'gift_bad_credittype_input')); } DB::update('common_member_field_home', array('magicgift' => addslashes(serialize($info))), array('uid' => $_G['uid'])); usemagic($this->magic['magicid'], $this->magic['num']); updatemagiclog($this->magic['magicid'], '2', '1', '0', '0', 'uid', $_G['uid']); showmessage(lang('magic/gift', 'gift_succeed'), dreferer(), array(), array('showdialog' => 1, 'locationtime' => true)); }
function build_cache_heats() { global $_G; $data = array(); if ($_G['setting']['indexhot']['status']) { require_once libfile('function/post'); $_G['setting']['indexhot'] = array('status' => 1, 'limit' => intval($_G['setting']['indexhot']['limit'] ? $_G['setting']['indexhot']['limit'] : 10), 'days' => intval($_G['setting']['indexhot']['days'] ? $_G['setting']['indexhot']['days'] : 7), 'expiration' => intval($_G['setting']['indexhot']['expiration'] ? $_G['setting']['indexhot']['expiration'] : 900), 'messagecut' => intval($_G['setting']['indexhot']['messagecut'] ? $_G['setting']['indexhot']['messagecut'] : 200)); $heatdateline = TIMESTAMP - 86400 * $_G['setting']['indexhot']['days']; $query = DB::query("SELECT t.tid,t.posttableid,t.views,t.dateline,t.replies,t.author,t.authorid,t.subject,t.price\r\n\t\t\tFROM " . DB::table('forum_thread') . " t\r\n\t\t\tWHERE t.dateline>'{$heatdateline}' AND t.heats>'0' AND t.displayorder>='0' ORDER BY t.heats DESC LIMIT " . $_G['setting']['indexhot']['limit'] * 2); $messageitems = 2; $limit = $_G['setting']['indexhot']['limit']; while ($heat = DB::fetch($query)) { $posttable = $heat['posttableid'] ? "forum_post_{$heat['posttableid']}" : 'forum_post'; $post = DB::fetch_first("SELECT p.pid, p.message FROM " . DB::table($posttable) . " p WHERE p.tid='{$heat['tid']}' AND p.first='1'"); $heat = array_merge($heat, (array) $post); if ($limit == 0) { break; } if ($messageitems > 0) { $heat['message'] = !$heat['price'] ? messagecutstr($heat['message'], $_G['setting']['indexhot']['messagecut']) : ''; $data['message'][$heat['tid']] = $heat; } else { unset($heat['message']); $data['subject'][$heat['tid']] = $heat; } $messageitems--; $limit--; } $data['expiration'] = TIMESTAMP + $_G['setting']['indexhot']['expiration']; } save_syscache('heats', $data); }
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 update_goods($arr, $aid, $posttime) { global $_G; if (!$arr[num_iid]) { return false; } if (!$aid || !$posttime) { $goods = DB::fetch_first("SELECT aid,posttime,sum FROM " . DB::table('goods') . " WHERE num_iid ='" . $arr[num_iid] . "' "); $aid = $goods[aid]; $posttime = $goods[posttime]; } if ($aid > 0) { $data = array(); foreach ($_G['setting']['filter_field'] as $k => $v) { if (isset($arr[$v])) { $data[$v] = $arr[$v]; } } //肯定是没有获取成功 if ($arr[sum] == 0 && $arr[num] == 0) { return false; } //只更新10天前的商品,一般上线时间是5天,可能5天后卖家没有修改价格.. if ($data[yh_price] && $posttime + 864000 > TIMESTAMP) { unset($data[yh_price]); } if ($data) { $data[dateline] = TIMESTAMP; $rt = top('goods', 'update', $data, $aid); return $rt; } } return false; }
function register_header() { global $_G; $inputemail = 'gp_' . $this->regemail['email']; $_G['gp_email'] = $_G[$inputemail]; if ($_POST) { $_G['gp_activationauth'] = strip_tags(str_replace(" ", "+", $_G['gp_activationauth'])); $activationinfo = authcode($_G['gp_activationauth'], $operation = 'DECODE'); $activationinfoname = preg_replace("/\\s.+/i", "", $activationinfo); if ($activationinfoname) { loaducenter(); if ($data = uc_get_user($activationinfoname)) { list($uid, $username, $email) = $data; } $_G['gp_email'] = getEmail(strip_tags($email)); } else { $_G['gp_email'] = getEmail(strip_tags($_G['gp_email'])); } $_G['gp_rid'] = strip_tags($_G['gp_rid']); if (!$_G['gp_rid']) { showmessage('dsu_amufzc:1', ''); } if (!$_G['gp_email']) { showmessage('dsu_amufzc:5', ''); } $amutb = DB::table("plugin_dsuamfzc"); $query = DB::fetch_first("SELECT * FROM {$amutb} WHERE rid = '" . $_G['gp_rid'] . "'"); if (!$query || $query['yes'] == '1') { showmessage('dsu_amufzc:2', ''); } if ($_G['gp_email'] != $query['email']) { showmessage('dsu_amufzc:11', ''); } } }
function run($pid = 0) { global $_G; $timestamp = TIMESTAMP; save_syscache('pick_run', TIMESTAMP + 300); $cron = DB::fetch_first("SELECT lastrun,nextrun,pid,cron_minute,cron_hour,cron_day,cron_weekday FROM " . DB::table('strayer_picker') . " WHERE is_auto_pick>'0' AND nextrun<='{$timestamp}' ORDER BY nextrun LIMIT 1"); if ($cron['cron_day'] == 0) { $cron['cron_day'] = -1; } $processname = 'PICK_CRON_' . (empty($pid) ? 'CHECKER' : $cron['pid']); if ($pid && !empty($cron)) { discuz_process::unlock($processname); } if (discuz_process::islocked($processname, 600)) { return false; } if ($cron['pid']) { require_once PICK_DIR . '/lib/pick.class.php'; $cron['cron_minute'] = explode(",", $cron['cron_minute']); pick_cron::setnextime($cron); @set_time_limit(1000); @ignore_user_abort(TRUE); $pick = new pick($cron['pid'], 1); $pick->run_start(); } pick_cron::nextcron(); discuz_process::unlock($processname); return true; }