public function increase($tids, $fieldarr) { $tids = dintval((array) $tids, true); $sql = array(); $num = 0; $allowkey = array('replies', 'lastposter', 'lastpost'); foreach ($fieldarr as $key => $value) { if (in_array($key, $allowkey)) { if (is_array($value)) { $sql[] = DB::field($key, $value[0]); } else { $value = dintval($value); $sql[] = "`{$key}`=`{$key}`+'{$value}'"; } } else { unset($fieldarr[$key]); } } if ($getsetarr) { return $sql; } if (!empty($sql)) { $cmd = "UPDATE "; $num = DB::query($cmd . DB::table($this->_table) . " SET " . implode(',', $sql) . " WHERE tid IN (" . dimplode($tids) . ")", 'UNBUFFERED'); $this->increase_cache($tids, $fieldarr); } return $num; }
public function repair_htmlmade($ids) { if ($ids = dintval($ids, true)) { return DB::update($this->_table, array('htmlmade' => 0), DB::field($this->_pk, $ids)); } return false; }
public function fetch_all_will_birthday_by_uid($uids) { $birthlist = array(); if (!empty($uids)) { $uids = explode(',', (string) $uids); $uids = dimplode(dintval($uids, true)); list($s_month, $s_day) = explode('-', dgmdate(TIMESTAMP - 3600 * 24 * 3, 'n-j')); list($n_month, $n_day) = explode('-', dgmdate(TIMESTAMP, 'n-j')); list($e_month, $e_day) = explode('-', dgmdate(TIMESTAMP + 3600 * 24 * 7, 'n-j')); if ($e_month == $s_month) { $wheresql = "sf.birthmonth='{$s_month}' AND sf.birthday>='{$s_day}' AND sf.birthday<='{$e_day}'"; } else { $wheresql = "(sf.birthmonth='{$s_month}' AND sf.birthday>='{$s_day}') OR (sf.birthmonth='{$e_month}' AND sf.birthday<='{$e_day}' AND sf.birthday>'0')"; } $query = DB::query("SELECT sf.uid,sf.birthyear,sf.birthmonth,sf.birthday,s.username\n\t\t\t\tFROM " . DB::table('common_member_profile') . " sf\n\t\t\t\tLEFT JOIN " . DB::table('common_member') . " s USING(uid)\n\t\t\t\tWHERE (sf.uid IN ({$uids})) AND ({$wheresql})"); while ($value = DB::fetch($query)) { $value['istoday'] = 0; if ($value['birthmonth'] == $n_month && $value['birthday'] == $n_day) { $value['istoday'] = 1; } $key = sprintf("%02d", $value['birthmonth']) . sprintf("%02d", $value['birthday']); $birthlist[$key][] = $value; ksort($birthlist); } } return $birthlist; }
public function update_by_id_username($id, $data, $username, $adminid = 1) { if (($id = dintval($id, true)) && $data && is_array($data)) { $adminid = dintval($adminid); DB::update($this->_table, $data, DB::field($this->_pk, $id) . " AND ('{$adminid}'=1 OR " . DB::field('author', $username) . ')', true); } }
public function fetch_all_by_uid_dateline($uids, $findex = true, $start = 0, $limit = 5) { if (!($uids = dintval($uids, true))) { return null; } return DB::fetch_all('SELECT * FROM %t ' . ($findex ? 'USE INDEX(dateline)' : '') . ' WHERE uid IN (%n) ORDER BY dateline desc %i', array($this->_table, $uids, DB::limit($start, $limit))); }
public function delete_by_uid($uids) { $uids = dintval((array) $uids, true); if (!empty($uids)) { return DB::delete($this->_table, DB::field('uid', $uids)); } return 0; }
public function delete_by_tid($tids) { $tids = dintval($tids, true); if ($tids) { return DB::delete($this->_table, DB::field('tid', $tids)); } return 0; }
public function delete_by_dateline($dateline) { $dateline = dintval($dateline); if ($dateline) { return DB::delete($this->_table, DB::field('dateline', $dateline, '<')); } return 0; }
public function update_by_groupid($groupid, $data) { $groupid = is_array($groupid) ? array_map('intval', (array) $groupid) : dintval($groupid); if ($groupid && $data && is_array($data)) { return DB::update($this->_table, $data, DB::field('groupid', $groupid)); } return 0; }
public function delete_by_uid_or_fuid($uids) { $uids = dintval($uids, true); if (!$uids) { return null; } DB::delete($this->_table, DB::field('uid', $uids) . ' OR ' . DB::field('fuid', $uids)); }
public function fetch_all_hotarticle($wheresql, $dateline) { if (!empty($wheresql) && ($wheresql = (string) $wheresql) && ($dateline = dintval($dateline))) { return DB::fetch_all("SELECT at.* FROM " . DB::table($this->_table) . " ac, " . DB::table('portal_article_title') . " at WHERE {$wheresql} AND at.dateline>'{$dateline}' AND ac.aid=at.aid ORDER BY ac.viewnum DESC LIMIT 10"); } else { return array(); } }
public function delete_by_menuid($menutype, $ids) { $ids = dintval($ids, is_array($ids) ? true : false); if ($ids) { return DB::delete($this->_table, DB::field('menuid', $ids) . ' AND ' . DB::field('type', $menutype)); } return 0; }
public function delete_by_uid($uids) { $uids = dintval($uids, is_array($uids) ? true : false); if ($uids) { return DB::delete($this->_table, DB::field('uid', $uids)); } return 0; }
public function fetch_all_by_upid($upid, $order = null, $sort = 'DESC') { $upid = is_array($upid) ? array_map('intval', (array) $upid) : dintval($upid); if ($upid !== null) { $ordersql = $order !== null && !empty($order) ? ' ORDER BY ' . DB::order($order, $sort) : ''; return DB::fetch_all('SELECT * FROM %t WHERE ' . DB::field('upid', $upid) . " {$ordersql}", array($this->_table), $this->_pk); } return array(); }
public function delete_by_id_fid($id, $fid) { $id = dintval($id, is_array($id) ? true : false); $fid = dintval($fid, is_array($fid) ? true : false); if (is_array($id) && empty($id) || is_array($fid) && empty($fid)) { return 0; } return DB::delete($this->_table, DB::field('id', $id) . ' AND ' . DB::field('fid', $fid)); }
public function delete_by_appid_touid($appid, $touid) { $touid = dintval($touid, true); $appid = dintval($appid, true); if ($touid && $appid) { return DB::delete($this->_table, DB::field('appid', $appid) . ' AND ' . DB::field('touid', $touid)); } return 0; }
public function fetch_all_by_id_idtype($id, $idtype) { $id = dintval($id, is_array($id) ? true : false); $parameter = array($this->_table, $id, $idtype); $wherearr = array(); $wherearr[] = is_array($id) ? 'id IN(%n)' : 'id=%d'; $wherearr[] = 'idtype=%s'; $wheresql = ' WHERE '.implode(' AND ', $wherearr); return DB::fetch_all("SELECT * FROM %t $wheresql ", $parameter); }
public function delete_by_uid_fuid($uid, $fuid) { $uid = dintval($uid, true); $fuid = dintval($fuid, true); if ($uid) { return DB::delete($this->_table, DB::field('uid', $uid) . ' AND ' . DB::field('fuid', $fuid)); } return 0; }
public function delete_by_cid_ctid($cids, $ctid = 0) { if (!$cids) { return false; } if ($ctid != 0) { $ctidsql = ' AND ctid=\'' . dintval($ctid) . '\''; } return DB::query("DELETE FROM %t WHERE cid IN (%n) {$ctidsql}", array($this->_table, $cids)); }
public function delete_expiration($ssid = 0) { if ($ssid) { $ssid = dintval($ssid); DB::delete($this->_table, "ssid='{$ssid}'"); } DB::delete($this->_table, TIMESTAMP . "-dateline>600"); DB::delete($this->_table, "verified>4"); DB::delete($this->_table, "succeed>1"); }
public function optimizer() { $adminfile = defined(ADMINSCRIPT) ? ADMINSCRIPT : 'admin.php'; if ($_GET['optimizefid']) { $url = '?action=forums&operation=edit&fid=' . dintval($_GET['optimizefid']); } else { $url = '?action=forums'; } dheader('Location: ' . $_G['siteurl'] . $adminfile . $url); }
public function delete($val, $unbuffered = false) { if ($val = dintval($val, true)) { $this->_pre_cache_key = 'blockstylecache_'; $this->_cache_ttl = getglobal('setting/memory/diyblock/ttl'); $this->_allowmem = getglobal('setting/memory/diyblock/enable') && memory('check'); return parent::delete($val, $unbuffered); } return false; }
public function count_by_uid($uid) { $uid = dintval($uid, is_array($uid) ? true : false); if (!empty($uid)) { $parameter = array($this->_table, $uid); $where = is_array($uid) ? 'uid IN(%n)' : 'uid=%d'; return DB::result_first("SELECT COUNT(*) FROM %t WHERE {$where}", $parameter); } return 0; }
function variable($variables = array()) { global $_G; if (in_array('mobileoem', $_G['setting']['plugins']['available'])) { $check = C::t('#mobileoem#mobileoem_member')->fetch($_G['uid']); } $globals = array('cookiepre' => $_G['config']['cookie']['cookiepre'], 'auth' => $_G['cookie']['auth'], 'saltkey' => $_G['cookie']['saltkey'], 'member_uid' => $_G['member']['uid'], 'member_username' => $_G['member']['username'], 'groupid' => $_G['groupid'], 'formhash' => FORMHASH, 'ismoderator' => $_G['forum']['ismoderator'], 'readaccess' => $_G['group']['readaccess'], 'notice' => array('newpush' => $check['newpush'] ? 1 : 0, 'newpm' => dintval($_G['member']['newpm']), 'newprompt' => dintval($_G['member']['newprompt'] - $_G['member']['category_num']['mypost'] >= 0 ? $_G['member']['newprompt'] - $_G['member']['category_num']['mypost'] : 0), 'newmypost' => dintval($_G['member']['category_num']['mypost']))); if (!empty($_GET['submodule']) == 'checkpost') { $apifile = 'source/plugin/mobile/api/' . $_GET['version'] . '/sub_checkpost.php'; if (file_exists($apifile)) { require_once $apifile; $globals = $globals + mobile_api_sub::getvariable(); } } $xml = array('Version' => $_GET['version'], 'Charset' => strtoupper($_G['charset']), 'Variables' => array_merge($globals, $variables)); if (!empty($_G['messageparam'])) { $message_result = lang('plugin/mobile', $_G['messageparam'][0], $_G['messageparam'][2]); if ($message_result == $_G['messageparam'][0]) { $vars = explode(':', $_G['messageparam'][0]); if (count($vars) == 2) { $message_result = lang('plugin/' . $vars[0], $vars[1], $_G['messageparam'][2]); $_G['messageparam'][0] = $vars[1]; } else { $message_result = lang('message', $_G['messageparam'][0], $_G['messageparam'][2]); } } $message_result = strip_tags($message_result); if (defined('IS_WEBVIEW') && IS_WEBVIEW && in_array('mobileoem', $_G['setting']['plugins']['available'])) { include_once DISCUZ_ROOT . './source/plugin/mobileoem/discuzcode.func.php'; include mobileoem_template('common/showmessage'); if (!empty($_GET['debug'])) { exit; } $content = ob_get_contents(); ob_end_clean(); $xml['Variables']['datatype'] = -1; $xml['Variables']['webview_page'] = $content; return $xml; } if ($_G['messageparam'][4]) { $_G['messageparam'][0] = "custom"; } if ($_G['messageparam'][3]['login'] && !$_G['uid']) { $_G['messageparam'][0] .= '//' . $_G['messageparam'][3]['login']; } $xml['Message'] = array("messageval" => $_G['messageparam'][0], "messagestr" => $message_result); if ($_GET['mobilemessage']) { $return = mobile_core::json($xml); header("HTTP/1.1 301 Moved Permanently"); header("Location:discuz://" . rawurlencode($_G['messageparam'][0]) . "//" . rawurlencode(diconv($message_result, $_G['charset'], "utf-8")) . ($return ? "//" . rawurlencode($return) : '')); exit; } } return $xml; }
public function delete($val, $unbuffered = false, $uid = 0) { $val = dintval($val, is_array($val) ? true : false); if ($val) { if ($uid) { $uid = dintval($uid, is_array($uid) ? true : false); } return DB::delete($this->_table, DB::field($this->_pk, $val) . ($uid ? ' AND ' . DB::field('uid', $uid) : ''), null, $unbuffered); } return !$unbuffered ? 0 : false; }
public function insert_batch($inserts) { $sql = array(); foreach ($inserts as $value) { $value['aid'] = dintval($value['aid']); $sql[] = "('{$value['aid']}', '" . addslashes($value['content']) . "', '{$value['pageorder']}', '{$value['dateline']}', '{$value['id']}', '{$value['idtype']}')"; } if ($sql) { DB::query('INSERT INTO ' . DB::table($this->_table) . "(`aid`, `content`, `pageorder`, `dateline`, `id`, `idtype`) VALUES " . implode(', ', $sql)); } }
public function insert_batch($targettplname, $tpldirectory, $bids) { if ($targettplname && ($bids = dintval($bids, true))) { $values = array(); foreach ($bids as $bid) { if ($bid) { $values[] = "('{$targettplname}','{$tpldirectory}', '{$bid}')"; } } DB::query("INSERT INTO " . DB::table($this->_table) . " (targettplname, tpldirectory, bid) VALUES " . implode(',', $values)); } }
public function delete_by_uid($uid, $verifytype = null) { if ($uid) { $addsql = ''; if ($verifytype !== null) { $verifytype = dintval($verifytype, is_array($verifytype) ? true : false); $addsql = ' AND ' . DB::field('verifytype', $verifytype); } return DB::fetch_first('DELETE FROM %t WHERE ' . (is_array($uid) ? 'uid IN(%n)' : 'uid=%d') . $addsql, array($this->_table, $uid)); } return false; }
public function fetch_all_by_rid($rid = 0) { $parameter = array($this->_table); $wherearr = array(); if ($rid) { $rid = dintval($rid, true); $parameter[] = $rid; $wherearr[] = is_array($rid) ? 'rid IN(%n)' : 'rid=%d'; } $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE ' . implode(' AND ', $wherearr) : ''; return DB::fetch_all("SELECT * FROM %t {$wheresql} ORDER BY rid DESC", $parameter, $this->_pk); }
public function insert_batch($inserts) { $sql = array(); foreach ($inserts as $value) { if ($value['aid'] = dintval($value['aid'])) { $sql[] = "('{$value['aid']}', '" . addslashes($value['content']) . "')"; } } if ($sql) { DB::query('INSERT INTO ' . DB::table($this->_table) . "(`aid`, `content`) VALUES " . implode(', ', $sql)); } }