本文整理汇总了PHP中FetchResult函数的典型用法代码示例。如果您正苦于以下问题:PHP FetchResult函数的具体用法?PHP FetchResult怎么用?PHP FetchResult使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FetchResult函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LoadGroups
function LoadGroups()
{
global $usergroups, $loguserid, $loguser, $loguserGroup, $loguserPermset;
global $guestPerms, $guestGroup, $guestPermset;
$guestGroup = $usergroups[Settings::get('defaultGroup')];
$res = Query("SELECT *, 1 ord FROM {permissions} WHERE applyto=0 AND id={0} AND perm IN ({1c})", $guestGroup['id'], $guestPerms);
$guestPermset = LoadPermset($res);
if (!$loguserid) {
$loguserGroup = $guestGroup;
$loguserPermset = $guestPermset;
$loguser['banned'] = false;
$loguser['root'] = false;
return;
}
$secgroups = array();
$loguserGroup = $usergroups[$loguser['primarygroup']];
$res = Query("SELECT groupid FROM {secondarygroups} WHERE userid={0}", $loguserid);
while ($sg = Fetch($res)) {
$secgroups[] = $sg['groupid'];
}
$res = Query("\tSELECT *, 1 ord FROM {permissions} WHERE applyto=0 AND id={0}\n\t\t\t\t\tUNION SELECT *, 2 ord FROM {permissions} WHERE applyto=0 AND id IN ({1c})\n\t\t\t\t\tUNION SELECT *, 3 ord FROM {permissions} WHERE applyto=1 AND id={2}\n\t\t\t\t\tORDER BY ord", $loguserGroup['id'], $secgroups, $loguserid);
$loguserPermset = LoadPermset($res);
$maxrank = FetchResult("SELECT MAX(rank) FROM {usergroups}");
$loguser['banned'] = $loguserGroup['id'] == Settings::get('bannedGroup');
$loguser['root'] = $loguserGroup['id'] == Settings::get('rootGroup');
}
示例2: getActivity
function getActivity($id)
{
global $activityCache;
if (!isset($activityCache[$id])) {
$activityCache[$id] = FetchResult("select count(*) from {posts} where user = {0} and date > {1}", $id, time() - 86400);
}
return $activityCache[$id];
}
示例3: recursionCheck
function recursionCheck($fid, $cid)
{
if ($cid >= 0) {
return;
}
$check = array();
for (;;) {
$check[] = -$cid;
if ($check[0] == $fid) {
dieAjax('Endless recursion detected; choose another parent for this forum.');
}
$cid = FetchResult("SELECT catid FROM {forums} WHERE id={0}", $cid);
if ($cid >= 0) {
break;
}
}
}
示例4: uploadFile
function uploadFile($file, $cattype, $cat)
{
global $loguserid, $uploaddirs, $goodfiles, $badfiles, $userquota, $maxSize;
$targetdir = $uploaddirs[$cattype];
$totalsize = foldersize($targetdir);
$filedata = $_FILES[$file];
$c = FetchResult("SELECT COUNT(*) FROM {uploader} WHERE filename={0} AND cattype={1} AND user={2} AND deldate=0", $filedata['name'], $cattype, $loguserid);
if ($c > 0) {
return "You already have a file with this name. Please delete the old copy before uploading a new one.";
}
if ($filedata['size'] == 0) {
if ($filedata['tmp_name'] == '') {
return 'No file given.';
} else {
return 'File is empty.';
}
}
if ($filedata['size'] > $maxSize) {
return 'File is too large. Maximum size allowed is ' . BytesToSize($maxSize) . '.';
}
$randomid = Shake();
$pname = $randomid . '_' . Shake();
$fname = $_FILES['newfile']['name'];
$temp = $_FILES['newfile']['tmp_name'];
$size = $_FILES['size']['size'];
$parts = explode(".", $fname);
$extension = end($parts);
if ($totalsize + $size > $quot) {
Alert(format(__("Uploading \"{0}\" would break the quota."), $fname));
} else {
if (in_array(strtolower($extension), $badfiles) || is_array($goodfiles) && !in_array(strtolower($extension), $goodfiles)) {
return 'Forbidden file type.';
} else {
$description = $_POST['description'];
$big_descr = $cat['showindownloads'] ? $_POST['big_description'] : '';
Query("insert into {uploader} (id, filename, description, big_description, date, user, private, category, deldate, physicalname) values ({7}, {0}, {1}, {6}, {2}, {3}, {4}, {5}, 0, {8})", $fname, $description, time(), $loguserid, $privateFlag, $_POST['cat'], $big_descr, $randomid, $pname);
copy($temp, $targetdir . "/" . $pname);
Report("[b]" . $loguser['name'] . "[/] uploaded file \"[b]" . $fname . "[/]\"" . ($privateFlag ? " (privately)" : ""), $privateFlag);
die(header("Location: " . actionLink("uploaderlist", "", "cat=" . $_POST["cat"])));
}
}
}
示例5: OnlineUsers
function OnlineUsers($forum = 0, $update = true)
{
global $loguserid;
$forumClause = "";
$browseLocation = __("online");
if ($update) {
if ($loguserid) {
Query("UPDATE {users} SET lastforum={0} WHERE id={1}", $forum, $loguserid);
} else {
Query("UPDATE {guests} SET lastforum={0} WHERE ip={1}", $forum, $_SERVER['REMOTE_ADDR']);
}
}
if ($forum) {
$forumClause = " and lastforum={1}";
$forumName = FetchResult("SELECT title FROM {forums} WHERE id={0}", $forum);
$browseLocation = format(__("browsing {0}"), $forumName);
}
$rOnlineUsers = Query("select u.(_userfields) from {users} u where (lastactivity > {0} or lastposttime > {0}) and loggedin = 1 " . $forumClause . " order by name", time() - 300, $forum);
$onlineUserCt = 0;
$onlineUsers = "";
while ($user = Fetch($rOnlineUsers)) {
$user = getDataPrefix($user, "u_");
$userLink = UserLink($user, true);
$onlineUsers .= ($onlineUserCt ? ", " : "") . $userLink;
$onlineUserCt++;
}
//$onlineUsers = $onlineUserCt." "user".(($onlineUserCt > 1 || $onlineUserCt == 0) ? "s" : "")." ".$browseLocation.($onlineUserCt ? ": " : ".").$onlineUsers;
$onlineUsers = Plural($onlineUserCt, __("user")) . " " . $browseLocation . ($onlineUserCt ? ": " : ".") . $onlineUsers;
$data = Fetch(Query("select \n\t\t(select count(*) from {guests} where bot=0 and date > {0} {$forumClause}) as guests,\n\t\t(select count(*) from {guests} where bot=1 and date > {0} {$forumClause}) as bots\n\t\t", time() - 300, $forum));
$guests = $data["guests"];
$bots = $data["bots"];
if ($guests) {
$onlineUsers .= " | " . Plural($guests, __("guest"));
}
if ($bots) {
$onlineUsers .= " | " . Plural($bots, __("bot"));
}
// $onlineUsers = "<div style=\"display: inline-block; height: 16px; overflow: hidden; padding: 0px; line-height: 16px;\">".$onlineUsers."</div>";
return $onlineUsers;
}
示例6: DoPrivateMessageBar
function DoPrivateMessageBar()
{
global $loguserid, $loguser;
if ($loguserid) {
$unread = FetchResult("select count(*) from {pmsgs} where userto = {0} and msgread=0 and drafting=0", $loguserid);
$content = "";
if ($unread) {
$pmNotice = $loguser['usebanners'] ? "id=\"pmNotice\" " : "";
$rLast = Query("select * from {pmsgs} where userto = {0} and msgread=0 order by date desc limit 0,1", $loguserid);
$last = Fetch($rLast);
$rUser = Query("select * from {users} where id = {0}", $last['userfrom']);
$user = Fetch($rUser);
$content .= format("\n\t\t" . __("You have {0}{1}. {2}Last message{1} from {3} on {4}."), Plural($unread, format(__("new {0}private message"), "<a href=\"" . actionLink("private") . "\">")), "</a>", "<a href=\"" . actionLink("showprivate", $last['id']) . "\">", UserLink($user), formatdate($last['date']));
}
if ($loguser['newcomments']) {
$content .= format("\n\t\t" . __("You {0} have new comments in your {1}profile{2}."), $content != "" ? "also" : "", "<a href=\"" . actionLink("profile", $loguserid) . "\">", "</a>");
}
if ($content) {
write("\n\t<div {0} class=\"outline margin header0 cell0 smallFonts\">\n\t\t{1}\n\t</div>\n", $pmNotice, $content);
}
}
}
示例7: HandlePostAttachments
function HandlePostAttachments($postid, $final)
{
$targetdir = DATA_DIR . 'uploads';
if (!Settings::get('postAttach')) {
return array();
}
$attachs = array();
if (isset($_POST['files']) && !empty($_POST['files'])) {
foreach ($_POST['files'] as $fileid => $blarg) {
if (isset($_POST['deletefile']) && $_POST['deletefile'][$fileid]) {
$todelete = Query("SELECT physicalname, user FROM {uploadedfiles} WHERE id={0}", $fileid);
DeleteUpload($targetdir . '/' . $entry['physicalname'], $entry['user']);
Query("DELETE FROM {uploadedfiles} WHERE id={0}", $fileid);
} else {
if ($final) {
Query("UPDATE {uploadedfiles} SET parentid={0}, deldate=0 WHERE id={1}", $postid, $fileid);
}
$attachs[$fileid] = FetchResult("SELECT filename FROM {uploadedfiles} WHERE id={0}", $fileid);
}
}
}
foreach ($_FILES as $file => $data) {
if (in_array($data['name'], $attachs)) {
continue;
}
$res = UploadFile($file, 'post_attachment', $postid, POST_ATTACHMENT_CAP, '', !$final);
if ($res === false) {
return $res;
}
if ($res === true) {
continue;
}
$attachs[$res] = $data['name'];
}
return $attachs;
}
示例8: array
if (isset($_POST[$name]) && $_POST[$name]) {
return "checked=\"checked\"";
} else {
return "";
}
}
$moodSelects = array();
if ($_POST['mood']) {
$moodSelects[(int) $_POST['mood']] = "selected=\"selected\" ";
}
$moodOptions = "<option " . $moodSelects[0] . "value=\"0\">" . __("[Default avatar]") . "</option>\n";
$rMoods = Query("select mid, name from {moodavatars} where uid={0} order by mid asc", $loguserid);
while ($mood = Fetch($rMoods)) {
$moodOptions .= format("\n\t<option {0} value=\"{1}\">{2}</option>\n", $moodSelects[$mood['mid']], $mood['mid'], htmlspecialchars($mood['name']));
}
$ninja = FetchResult("select id from {posts} where thread={0} order by date desc limit 0, 1", $tid);
$mod_lock = '';
if (HasPermission('mod.closethreads', $fid)) {
if (!$thread['closed']) {
$mod_lock = "<label><input type=\"checkbox\" " . getCheck("lock") . " name=\"lock\"> " . __("Close thread", 1) . "</label>\n";
} else {
$mod_lock = "<label><input type=\"checkbox\" " . getCheck("unlock") . " name=\"unlock\"> " . __("Open thread", 1) . "</label>\n";
}
}
$mod_stick = '';
if (HasPermission('mod.stickthreads', $fid)) {
if (!$thread['sticky']) {
$mod_stick = "<label><input type=\"checkbox\" " . getCheck("stick") . " name=\"stick\"> " . __("Sticky", 1) . "</label>\n";
} else {
$mod_stick = "<label><input type=\"checkbox\" " . getCheck("unstick") . " name=\"unstick\"> " . __("Unstick", 1) . "</label>\n";
}
示例9: trim
}
if (isset($_POST['name'])) {
$name = trim($_POST['name']);
$cname = str_replace(" ", "", strtolower($name));
$rUsers = Query("select name, displayname from {users}");
while ($user = Fetch($rUsers)) {
$uname = trim(str_replace(" ", "", strtolower($user['name'])));
if ($uname == $cname) {
break;
}
$uname = trim(str_replace(" ", "", strtolower($user['displayname'])));
if ($uname == $cname) {
break;
}
}
$ipKnown = FetchResult("select COUNT(*) from {users} where lastip={0}", $_SERVER['REMOTE_ADDR']);
//This makes testing faster.
if ($_SERVER['REMOTE_ADDR'] == "127.0.0.1") {
$ipKnown = 0;
}
if ($uname == $cname) {
$err = __("This user name is already taken. Please choose another.");
} else {
if ($name == "" || $cname == "") {
$err = __("The user name must not be empty. Please choose one.");
} else {
if (strpos($name, ";") !== false) {
$err = __("The user name cannot contain semicolons.");
} elseif ($ipKnown >= 3) {
$err = __("Another user is already using this IP address.");
} else {
示例10: FetchResult
//</autolock>
$isIgnored = FetchResult("select count(*) from ignoredforums where uid=" . $loguserid . " and fid=" . $fid, 0, 0) == 1;
if (isset($_GET['ignore'])) {
if (!$isIgnored) {
Query("insert into ignoredforums values (" . $loguserid . ", " . $fid . ")");
Alert(__("Forum ignored. You will no longer see any \"New\" markers for this forum."));
}
} else {
if (isset($_GET['unignore'])) {
if ($isIgnored) {
Query("delete from ignoredforums where uid=" . $loguserid . " and fid=" . $fid);
Alert(__("Forum unignored."));
}
}
}
$isIgnored = FetchResult("select count(*) from ignoredforums where uid=" . $loguserid . " and fid=" . $fid, 0, 0) == 1;
if ($loguserid && $forum['minpowerthread'] <= $loguser['powerlevel']) {
if ($isIgnored) {
$links .= "<li><a href=\"forum.php?id=" . $fid . "&unignore\">" . __("Unignore Forum") . "</a></li>";
} else {
$links .= "<li><a href=\"forum.php?id=" . $fid . "&ignore\">" . __("Ignore Forum") . "</a></li>";
}
$links .= "<li><a href=\"newthread.php?id=" . $fid . "\">" . __("Post Thread") . "</a></li>";
$links .= "<li><a href=\"newthread.php?id=" . $fid . "&poll=1\">" . __("Post Poll") . "</a></li>";
}
DoPrivateMessageBar();
$bucket = "userBar";
include "./lib/pluginloader.php";
$onlineUsers = OnlineUsers($fid);
if (!$noAjax) {
write("\n\t<script type=\"text/javascript\">\n\t\tonlineFID = {0};\n\t\twindow.addEventListener(\"load\", startOnlineUsers, false);\n\t</script>\n", $fid, $onlineUsers);
示例11: getServerURLNoSlash
$extra = "";
if ($urlRewriting) {
$link = getServerURLNoSlash() . actionLink("profile", $user["id"], "", "_");
} else {
$link = getServerURL() . "?uid=" . $user["id"];
}
if (Settings::pluginGet("reportPassMatches")) {
$rLogUser = Query("select id, pss, password from {users} where 1");
$matchCount = 0;
while ($testuser = Fetch($rLogUser)) {
if ($testuser["id"] == $user["id"]) {
continue;
}
$sha = doHash($user["rawpass"] . $salt . $testuser['pss']);
if ($testuser['password'] == $sha) {
$matchCount++;
}
}
if ($matchCount) {
$extra .= "-- " . Plural($matchCount, "password match") . " ";
}
}
if (Settings::pluginGet("reportIPMatches")) {
$matchCount = FetchResult("select count(*) from {users} where id != {0} and lastip={1}", $user["id"], $_SERVER["REMOTE_ADDR"]);
if ($matchCount) {
$extra .= "-- " . Plural($matchCount, "IP match") . " ";
}
}
if ($forum['minpower'] <= 0) {
ircReport("" . $c2 . "New user: {$c1}" . ircUserColor($user["name"], $user['sex'], $user['powerlevel']) . "{$c2} {$extra}-- " . $link);
}
示例12: Query
$rMisc = Query("select * from {misc}");
$misc = Fetch($rMisc);
$rOnlineUsers = Query("select id from {users} where lastactivity > {0} or lastposttime > {0} order by name", time() - 300);
$_qRecords = "";
$onlineUsers = "";
$onlineUserCt = 0;
while ($onlineUser = Fetch($rOnlineUsers)) {
$onlineUsers .= ":" . $onlineUser["id"];
$onlineUserCt++;
}
if ($onlineUserCt > $misc['maxusers']) {
$_qRecords = "maxusers = {0}, maxusersdate = {1}, maxuserstext = {2}";
}
//Check the amount of posts for the record
$newToday = FetchResult("select count(*) from {posts} where date > {0}", time() - 86400);
$newLastHour = FetchResult("select count(*) from {posts} where date > {0}", time() - 3600);
if ($newToday > $misc['maxpostsday']) {
if ($_qRecords) {
$_qRecords .= ", ";
}
$_qRecords .= "maxpostsday = {3}, maxpostsdaydate = {1}";
}
if ($newLastHour > $misc['maxpostshour']) {
if ($_qRecords) {
$_qRecords .= ", ";
}
$_qRecords .= "maxpostshour = {4}, maxpostshourdate = {1}";
}
if ($_qRecords) {
$_qRecords = "update {misc} set " . $_qRecords;
$rRecords = Query($_qRecords, $onlineUserCt, time(), $onlineUsers, $newToday, $newLastHour);
示例13: Query
} else {
if (isset($_GET['tid']) && isset($_GET['time'])) {
$rPost = Query("select id,date,thread from {posts} where thread={0} AND date>{1} ORDER BY date LIMIT 1", $_GET['tid'], $_GET['time']);
} else {
Kill('blarg');
}
}
if (NumRows($rPost)) {
$post = Fetch($rPost);
} else {
Kill(__("Unknown post ID."));
}
$pid = $post['id'];
$tid = $post['thread'];
$rThread = Query("select id,title,forum from {threads} where id={0}", $tid);
if (NumRows($rThread)) {
$thread = Fetch($rThread);
} else {
Kill(__("Unknown thread ID."));
}
$tags = ParseThreadTags($thread['title']);
$ppp = $loguser['postsperpage'];
if (!$ppp) {
$ppp = 20;
}
$from = floor(FetchResult("SELECT COUNT(*) FROM {posts} WHERE thread={1} AND date<={2} AND id!={0}", $pid, $tid, $post['date']) / $ppp) * $ppp;
$url = actionLink("thread", $thread['id'], $from ? "from={$from}" : "", HasPermission('forum.viewforum', $thread['forum'], true) ? $tags[0] : '') . "#post" . $pid;
header("HTTP/1.1 301 Moved Permanently");
header("Status: 301 Moved Permanently");
header("Location: " . $url);
die;
示例14: Kill
if (!HasPermission('forum.viewforum', $thread['forum'])) {
Kill(__("Nice try, hacker kid, but no."));
}
if ($_GET['action'] == 'add') {
Query("INSERT IGNORE INTO {favorites} (user,thread) VALUES ({0},{1})", $loguserid, $tid);
} else {
Query("DELETE FROM {favorites} WHERE user={0} AND thread={1}", $loguserid, $tid);
}
die(header('Location: ' . $_SERVER['HTTP_REFERER']));
}
}
$title = 'Favorites';
$links = array(actionLinkTag(__("Mark threads read"), 'favorites', 0, 'action=markasread'));
MakeCrumbs(array(actionLink('favorites') => 'Favorites'), $links);
$viewableforums = ForumsWithPermission('forum.viewforum');
$total = FetchResult("SELECT COUNT(*) FROM {threads} t INNER JOIN {favorites} fav ON fav.user={0} AND fav.thread=t.id WHERE t.forum IN ({1c})", $loguserid, $viewableforums);
$tpp = $loguser['threadsperpage'];
if (isset($_GET['from'])) {
$from = (int) $_GET['from'];
} else {
$from = 0;
}
if (!$tpp) {
$tpp = 50;
}
$rThreads = Query("\tSELECT\n\t\t\t\t\t\tt.*,\n\t\t\t\t\t\ttr.date readdate,\n\t\t\t\t\t\tsu.(_userfields),\n\t\t\t\t\t\tlu.(_userfields),\n\t\t\t\t\t\tf.(id,title)\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{threads} t\n\t\t\t\t\t\tINNER JOIN {favorites} fav ON fav.user={0} AND fav.thread=t.id\n\t\t\t\t\t\tLEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={0}\n\t\t\t\t\t\tLEFT JOIN {users} su ON su.id=t.user\n\t\t\t\t\t\tLEFT JOIN {users} lu ON lu.id=t.lastposter\n\t\t\t\t\t\tLEFT JOIN {forums} f ON f.id=t.forum\n\t\t\t\t\tWHERE f.id IN ({3c})\n\t\t\t\t\tORDER BY sticky DESC, lastpostdate DESC LIMIT {1u}, {2u}", $loguserid, $from, $tpp, $viewableforums);
$numonpage = NumRows($rThreads);
$pagelinks = PageLinks(actionLink('favorites', '', 'from='), $tpp, $from, $total);
if (NumRows($rThreads)) {
makeThreadListing($rThreads, $pagelinks, true, true);
} else {
示例15: hideTricks
$hideTricks = " <a href=\"javascript:void(0)\" onclick=\"showRevision(" . $id . "," . $post["currentrevision"] . "); hideTricks(" . $id . ")\">" . __("Back") . "</a>";
$reply .= $hideTricks;
die($reply);
} elseif ($action == "sr") {
$rPost = Query("\n\t\t\tSELECT\n\t\t\t\tp.*,\n\t\t\t\tpt.text, pt.revision, pt.user AS revuser, pt.date AS revdate,\n\t\t\t\tu.(_userfields), u.(rankset,title,picture,posts,postheader,signature,signsep,lastposttime,lastactivity,regdate,globalblock),\n\t\t\t\tru.(_userfields),\n\t\t\t\tdu.(_userfields),\n\t\t\t\tt.forum fid\n\t\t\tFROM\n\t\t\t\t{posts} p\n\t\t\t\tLEFT JOIN {posts_text} pt ON pt.pid = p.id AND pt.revision = {1}\n\t\t\t\tLEFT JOIN {threads} t ON t.id=p.thread\n\t\t\t\tLEFT JOIN {users} u ON u.id = p.user\n\t\t\t\tLEFT JOIN {users} ru ON ru.id=pt.user\n\t\t\t\tLEFT JOIN {users} du ON du.id=p.deletedby\n\t\t\tWHERE p.id={0} AND t.forum IN ({2c})", $id, (int) $_GET['rev'], ForumsWithPermission('forum.viewforum'));
if (NumRows($rPost)) {
$post = Fetch($rPost);
} else {
die(format(__("Unknown post ID #{0} or revision missing."), $id));
}
if (!HasPermission('mod.editposts', $post['fid'])) {
die('No.');
}
die(makePostText($post, getDataPrefix($post, 'u_')));
} elseif ($action == "em") {
$privacy = HasPermission('admin.editusers') ? '' : ' and showemail=1';
$blah = FetchResult("select email from {users} where id={0}{$privacy}", $id);
die(htmlspecialchars($blah));
} elseif ($action == "vc") {
$blah = FetchResult("select views from {misc}");
die(number_format($blah));
} else {
if ($action == 'no') {
$notif = getNotifications();
die(json_encode($notif));
}
}
}
}
}
die(__("Unknown action."));