function GetNotifications()
{
    global $loguserid, $NotifFormat;
    $notifs = array();
    if (!$loguserid) {
        return $notifs;
    }
    // TODO do it better!
    $staffnotif = '';
    if (HasPermission('admin.viewstaffpms')) {
        $staffnotif = ' OR user=-1';
    }
    $ndata = Query("SELECT type,id,date,args FROM {notifications} WHERE user={0}{$staffnotif} ORDER BY date DESC", $loguserid);
    while ($n = Fetch($ndata)) {
        $ncb = $NotifFormat[$n['type']];
        if (function_exists($ncb)) {
            $ndesc = $ncb($n['id'], $n['args'] ? unserialize($n['args']) : null);
        } else {
            $ndesc = htmlspecialchars($n['type'] . ':' . $n['id']);
        }
        $ts = '<span class="nobr">';
        $te = '</span>';
        $ndesc = $ts . str_replace("\n", $te . '<br>' . $ts, $ndesc) . $te;
        $notifs[] = array('date' => $n['date'], 'formattedDate' => relativedate($n['date']), 'text' => $ndesc);
    }
    return $notifs;
}
Пример #2
0
function getWikiPage($id, $rev = 0)
{
    global $canedit, $canmod;
    $ptitle = $id;
    if (!$ptitle) {
        $ptitle = 'Main_page';
    } else {
        $ptitle = title2url($ptitle);
    }
    // so that we don't have for example 'Main page' and 'Main_page' being considered different pages
    if ($rev < 0) {
        $rev = 0;
    }
    $page = Query("SELECT p.*, pt.date, pt.user, pt.text FROM {wiki_pages} p LEFT JOIN {wiki_pages_text} pt ON pt.id=p.id AND pt.revision=" . ($rev > 0 ? 'LEAST(p.revision,{1})' : 'p.revision') . " WHERE p.id={0}", $ptitle, $rev);
    if (!NumRows($page)) {
        $page = array('id' => $ptitle, 'revision' => 0, 'flags' => 0, 'text' => '', 'new' => 1);
        header('HTTP/1.1 404 Not Found');
        header('Status: 404 Not Fount');
    } else {
        $page = Fetch($page);
    }
    $page['istalk'] = strtolower(substr($ptitle, 0, 5)) == 'talk:';
    $page['ismain'] = strtolower($ptitle) == 'main_page';
    $page['canedit'] = $canedit && (!($page['flags'] & WIKI_PFLAG_SPECIAL) || HasPermission('wiki.makepagesspecial'));
    return $page;
}
 public static function load()
 {
     self::$settingsArray = array();
     $rSettings = Query("select * from {settings}");
     while ($setting = Fetch($rSettings)) {
         self::$settingsArray[$setting['plugin']][$setting['name']] = $setting['value'];
     }
 }
Пример #4
0
function loadSmiliesOrdered()
{
    global $smiliesOrdered;
    $rSmilies = Query("select * from {smilies}");
    $smilies = array();
    while ($smiley = Fetch($rSmilies)) {
        $smiliesOrdered[] = $smiley;
    }
}
Пример #5
0
function loadBlockLayouts()
{
    global $blocklayouts, $loguserid;
    if (isset($blocklayouts)) {
        return;
    }
    $rBlocks = Query("select * from {blockedlayouts} where blockee = {0}", $loguserid);
    $blocklayouts = array();
    while ($block = Fetch($rBlocks)) {
        $blocklayouts[$block['user']] = 1;
    }
}
Пример #6
0
function MakeOptions($catid)
{
    $sel[$catid] = " selected=\"true\"";
    $qFora = "select id,name from categories";
    $rFora = Query($qFora);
    $result = "<select name=\"category\" size=\"1\">";
    while ($forum = Fetch($rFora)) {
        $result .= "<option value=\"" . $forum['id'] . "\"" . $sel[$forum['id']] . "\\>" . $forum['name'] . "</option>";
    }
    $result .= "</select>";
    return $result;
}
Пример #7
0
function isIPBanned($ip)
{
    $rIPBan = Query("select * from {ipbans} where instr({0}, ip)=1", $ip);
    while ($ipban = Fetch($rIPBan)) {
        // check if this IP ban is actually good
        // if the last character is a number, IPs have to match precisely
        if (ctype_alnum(substr($ipban['ip'], -1)) && $ip !== $ipban['ip']) {
            continue;
        }
        return $ipban;
    }
    return false;
}
Пример #8
0
function ircForumPrefix($forum)
{
    global $forumBoards;
    $prefix = '';
    if ($forum['board'] != '') {
        $prefix = $forumBoards[$forum['board']] . ' > ';
    }
    $parents = Query("SELECT title FROM {forums} WHERE l<{0} AND r>{1} ORDER BY l", $forum['l'], $forum['r']);
    while ($p = Fetch($parents)) {
        $prefix .= $p['title'] . ' > ';
    }
    return $prefix;
}
Пример #9
0
function loadSmilies()
{
    global $smilies, $smiliesReplaceOrig, $smiliesReplaceNew;
    $rSmilies = Query("select * from {smilies} order by length(code) desc");
    $smilies = array();
    while ($smiley = Fetch($rSmilies)) {
        $smilies[] = $smiley;
    }
    $smiliesReplaceOrig = $smiliesReplaceNew = array();
    for ($i = 0; $i < count($smilies); $i++) {
        $smiliesReplaceOrig[] = "/(?<!\\w)" . preg_quote($smilies[$i]['code'], "/") . "(?!\\w)/";
        $smiliesReplaceNew[] = "<img class=\"smiley\" alt=\"\" src=\"" . resourceLink("img/smilies/" . $smilies[$i]['image']) . "\" />";
    }
}
Пример #10
0
function CleanupUploads()
{
    $targetdir = DATA_DIR . 'uploads';
    $timebeforedel = time() - 604800;
    // one week
    $todelete = Query("SELECT physicalname, user, filename FROM {uploadedfiles} WHERE deldate!=0 AND deldate<{0}", $timebeforedel);
    if (NumRows($todelete)) {
        while ($entry = Fetch($todelete)) {
            Report("[b]{$entry['filename']}[/] deleted by auto-cleanup", false);
            DeleteUpload($targetdir . '/' . $entry['physicalname'], $entry['user']);
        }
        Query("DELETE FROM {uploadedfiles} WHERE deldate!=0 AND deldate<{0}", $timebeforedel);
    }
}
Пример #11
0
function isIPBanned($ip)
{
    $rIPBan = Query("select * from {ipbans} where instr({0}, ip)=1", $ip);
    $result = false;
    while ($ipban = Fetch($rIPBan)) {
        if (IPMatches($ip, $ipban['ip'])) {
            if ($ipban['whitelisted']) {
                return false;
            } else {
                $result = $ipban;
            }
        }
    }
    return $result;
}
Пример #12
0
function fixcoldata($table, $field, $key)
{
    echo "fixing data in {$table}.{$field}...";
    $data = Query("SELECT {$field},{$key} FROM {" . $table . "}");
    while ($row = Fetch($data)) {
        // data was UTF8 stored as latin1
        // then latin1->UTF8
        // resulting in double UTF8 encoding
        // to fix, convert back to latin1
        $blarg = $row[$field];
        $blarg = utf8_decode($blarg);
        Query("UPDATE {" . $table . "} SET {$field}={0} WHERE {$key}={1}", $blarg, $row[$key]);
    }
    echo " ok<br>";
}
Пример #13
0
/**
 * Show-rating function for cbv3 template
 *  
 */
function cbv3_show_rating($rating)
{
    $array = array();
    if (error()) {
        $array['err'] = error();
    }
    $array['rating'] = $rating;
    $rated_by = $rating['ratings'];
    $rating = $rating['rating'];
    $rating_full = $rating * 10;
    $likes = $rating_full * $rated_by / 100;
    $likes = round($likes + 0.49, 0);
    $dislikes = $rated_by - $likes;
    assign('rating', array('rating' => $rating, 'dislikes' => $dislikes, 'likes' => $likes, 'rated_by' => $rated_by, 'rating_perc' => $rating_full));
    $template = Fetch('blocks/rating.html');
    $array['template'] = $template;
    echo json_encode($array);
}
Пример #14
0
function doThreadPreview($tid)
{
    global $mobileLayout;
    if ($mobileLayout) {
        return;
    }
    $rPosts = Query("\n\t\tselect\n\t\t\t{posts}.id, {posts}.date, {posts}.num, {posts}.deleted, {posts}.options, {posts}.mood, {posts}.ip,\n\t\t\t{posts_text}.text, {posts_text}.text, {posts_text}.revision,\n\t\t\tu.(_userfields)\n\t\tfrom {posts}\n\t\tleft join {posts_text} on {posts_text}.pid = {posts}.id and {posts_text}.revision = {posts}.currentrevision\n\t\tleft join {users} u on u.id = {posts}.user\n\t\twhere thread={0} and deleted=0\n\t\torder by date desc limit 0, 20", $tid);
    if (NumRows($rPosts)) {
        $posts = "";
        while ($post = Fetch($rPosts)) {
            $cellClass = ($cellClass + 1) % 2;
            $poster = getDataPrefix($post, "u_");
            $nosm = $post['options'] & 2;
            $nobr = $post['options'] & 4;
            $posts .= Format("\n\t\t\t<tr>\n\t\t\t\t<td class=\"cell2\" style=\"width: 15%; vertical-align: top;\">\n\t\t\t\t\t{1}\n\t\t\t\t</td>\n\t\t\t\t<td class=\"cell{0}\">\n\t\t\t\t\t<button style=\"float: right;\" onclick=\"insertQuote({2});\">" . __("Quote") . "</button>\n\t\t\t\t\t<button style=\"float: right;\" onclick=\"insertChanLink({2});\">" . __("Link") . "</button>\n\t\t\t\t\t{3}\n\t\t\t\t</td>\n\t\t\t</tr>\n\t", $cellClass, UserLink($poster), $post['id'], CleanUpPost($post['text'], $poster['name'], $nosm));
        }
        Write("\n\t\t<table class=\"outline margin\">\n\t\t\t<tr class=\"header0\">\n\t\t\t\t<th colspan=\"2\">" . __("Thread review") . "</th>\n\t\t\t</tr>\n\t\t\t{0}\n\t\t</table>\n\t", $posts);
    }
}
Пример #15
0
function getBirthdaysText()
{
    $rBirthdays = Query("select u.birthday, u.(_userfields) from {users} u where birthday > 0 and powerlevel >= 0 order by name");
    $birthdays = array();
    while ($user = Fetch($rBirthdays)) {
        $b = $user['birthday'];
        if (gmdate("m-d", $b) == gmdate("m-d")) {
            $y = gmdate("Y") - gmdate("Y", $b);
            $birthdays[] = UserLink(getDataPrefix($user, "u_")) . " (" . $y . ")";
        }
    }
    if (count($birthdays)) {
        $birthdaysToday = implode(", ", $birthdays);
    }
    if ($birthdaysToday) {
        return "<br>" . __("Birthdays today:") . " " . $birthdaysToday;
    } else {
        return "";
    }
}
Пример #16
0
function doLogList($cond)
{
    $log_fields = array('user' => array('table' => 'users', 'key' => 'id', 'fields' => '_userfields'), 'user2' => array('table' => 'users', 'key' => 'id', 'fields' => '_userfields'), 'thread' => array('table' => 'threads', 'key' => 'id', 'fields' => 'id,title'), 'post' => array('table' => 'posts', 'key' => 'id', 'fields' => 'id'), 'forum' => array('table' => 'forums', 'key' => 'id', 'fields' => 'id,title'), 'forum2' => array('table' => 'forums', 'key' => 'id', 'fields' => 'id,title'), 'pm' => array('table' => 'pmsgs', 'key' => 'id', 'fields' => 'id'));
    $bucket = 'log_fields';
    include 'lib/pluginloader.php';
    $joinfields = '';
    $joinstatements = '';
    foreach ($log_fields as $field => $data) {
        $joinfields .= ", {$field}.({$data['fields']}) \n";
        $joinstatements .= "LEFT JOIN {{$data['table']}} AS {$field} ON l.{$field}!='0' AND {$field}.{$data['key']}=l.{$field} \n";
    }
    $logR = Query("\tSELECT \n\t\t\t\t\t\tl.*\n\t\t\t\t\t\t{$joinfields}\n\t\t\t\t\tFROM \n\t\t\t\t\t\t{log} l\n\t\t\t\t\t\t{$joinstatements}\n\t\t\t\t\tWHERE {$cond}\n\t\t\t\t\tORDER BY date DESC\n\t\t\t\t\tLIMIT 100");
    //TODO Paging
    while ($item = Fetch($logR)) {
        $event = formatEvent($item);
        $ip = formatIP($item["ip"]);
        $cellClass = ($cellClass + 1) % 2;
        $log .= "\n\t\t\t<tr>\n\t\t\t\t<td class=\"cell2\">\n\t\t\t\t\t" . str_replace(" ", "&nbsp;", TimeUnits(time() - $item['date'])) . "\n\t\t\t\t</td>\n\t\t\t\t<td class=\"cell{$cellClass}\">\n\t\t\t\t\t{$event}\n\t\t\t\t</td>\n\t\t\t\t<td class=\"cell{$cellClass}\">\n\t\t\t\t\t{$ip}\n\t\t\t\t</td>\n\t\t\t</tr>";
    }
    echo "\n\t\t<table class=\"outline margin\">\n\t\t\t<tr class=\"header1\">\n\t\t\t\t<th>\n\t\t\t\t\t" . __("Time") . "\n\t\t\t\t</th>\n\t\t\t\t<th>\n\t\t\t\t\t" . __("Event") . "\n\t\t\t\t</th>\n\t\t\t\t<th>\n\t\t\t\t\t" . __("IP") . "\n\t\t\t\t</th>\n\t\t\t</tr>\n\t\t\t{$log}\n\t\t</table>";
}
Пример #17
0
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;
}
Пример #18
0
function listGuests($rGuests, $noMsg)
{
    global $showIPs;
    if (!NumRows($rGuests)) {
        return "<tr class=\"cell0\"><td colspan=\"6\">{$noMsg}</td></tr>";
    }
    $i = 1;
    while ($guest = Fetch($rGuests)) {
        $cellClass = ($cellClass + 1) % 2;
        if ($guest['date']) {
            $lastUrl = "<a href=\"" . FilterURL($guest['lasturl']) . "\">" . FilterURL($guest['lasturl']) . "</a>";
        } else {
            $lastUrl = __("None");
        }
        $guestList .= "\n\t\t<tr class=\"cell{$cellClass}\">\n\t\t\t<td>{$i}</td>\n\t\t\t<td colspan=\"2\" title=\"" . htmlspecialchars($guest['useragent']) . "\">" . htmlspecialchars(substr($guest['useragent'], 0, 65)) . "</td>\n\t\t\t<td>" . cdate("d-m-y G:i:s", $guest['date']) . "</td>\n\t\t\t<td>{$lastUrl}</td>";
        if ($showIPs) {
            $guestList .= "<td>" . formatIP($guest['ip']) . "</td>";
        }
        $guestList .= "</tr>";
        $i++;
    }
    return $guestList;
}
Пример #19
0
function listGuests($rGuests)
{
    global $showIPs;
    $guestList = array();
    $i = 1;
    while ($guest = Fetch($rGuests)) {
        $gdata = array();
        $gdata['num'] = $i++;
        if ($showIPs) {
            $gdata['userAgent'] = '<span title="' . htmlspecialchars($guest['useragent']) . '">' . htmlspecialchars(substr($guest['useragent'], 0, 65)) . '</span>';
        }
        $gdata['lastView'] = cdate("d-m-y G:i:s", $guest['date']);
        if ($guest['date']) {
            $gdata['lastURL'] = "<a href=\"" . FilterURL($guest['lasturl']) . "\">" . FilterURL($guest['lasturl']) . "</a>";
        } else {
            $gdata['lastURL'] = __("None");
        }
        if ($showIPs) {
            $gdata['ip'] = formatIP($guest['ip']);
        }
        $guestList[] = $gdata;
    }
    return $guestList;
}
Пример #20
0
 $tidy = (int) function_exists('tidy_repair_string');
 if ($tidy) {
     print "available.<br />";
 } else {
     print "not available.<br />";
 }
 $shakeIt = false;
 if (!is_file("lib/salt.php")) {
     $shakeIt = true;
 }
 $miscStat = Query("show table status from " . $dbname . " like 'misc'");
 if (NumRows($miscStat) == 0) {
     $shakeIt = true;
 } else {
     $shakeIt = false;
     $misc = Fetch(Query("select * from misc"));
     if ($misc['version'] < 220) {
         $shakeIt = true;
         $sltf = @fopen("lib/salt.php", "w+") or Kill(format("Could not open \"lib/{0}.php\" for writing. This has been checked for earlier, so if you see this error now, something very strange is going on.", "salt"), "Mysterious filesystem permission error");
         fwrite($sltf, "<?php \$salt = \"sAltlOlscuZdSfjdSDhfjguvDigEnfjFjfjkDH\" ?>\n");
         fclose($sltf);
     }
 }
 if ($shakeIt) {
     print "Generating security salt&hellip;<br />";
     $cset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRQSTUVWXYZ0123456789";
     $salt = "";
     $chct = strlen($cset) - 1;
     while (strlen($salt) < 16) {
         $salt .= $cset[mt_rand(0, $chct)];
     }
Пример #21
0
     $pm['text'] = substr($pm['text'], strpos($pm['text'], "### -->") + 7);
 }
 if ($_POST['action'] == __("Send") || $_POST['action'] == __("Update Draft")) {
     $recipIDs = array();
     if ($_POST['to']) {
         $firstTo = -1;
         $recipients = explode(";", $_POST['to']);
         foreach ($recipients as $to) {
             $to = mysql_real_escape_string(trim(htmlentities($to)));
             if ($to == "") {
                 continue;
             }
             $qUser = "******" . $to . "' or displayname='" . $to . "'";
             $rUser = Query($qUser);
             if (NumRows($rUser)) {
                 $user = Fetch($rUser);
                 $id = $user['id'];
                 if ($firstTo == -1) {
                     $firstTo = $id;
                 }
                 if ($id == $loguserid) {
                     $errors .= __("You can't send private messages to yourself.") . "<br />";
                 } else {
                     if (!in_array($id, $recipIDs)) {
                         $recipIDs[] = $id;
                     }
                 }
             }
             $maxRecips = array(-1 => 1, 3, 3, 3, 10, 100, 1);
             $maxRecips = $maxRecips[$loguser['powerlevel']];
             //$maxRecips = ($loguser['powerlevel'] > 1) ? 5 : 1;
Пример #22
0
<?php

if (!defined('BLARG')) {
    die;
}
if (!$loguserGroup['root']) {
    die(header('Location: /?page=404'));
}
/*$toignore = array();
$ignoreforums = Query("SELECT id FROM {forums} WHERE ignoreposts=1");
while ($ig = Fetch($ignoreforums))
	$toignore[] = $ig['id'];

if (empty($toignore)) return;*/
// find all the users who posted in those forums
$posters = Query("SELECT u.id FROM {users} u");
while ($poster = Fetch($posters)) {
    // update the post numbers of all the user's posts
    Query("SET @pnum=0");
    Query("UPDATE {posts} p SET num=(@pnum:=@pnum+1) WHERE p.user={0} ORDER BY date", $poster['id']);
    // update the user's postcount
    Query("UPDATE {users} u SET u.posts=(SELECT MAX(p.num) FROM {posts} p WHERE p.user=u.id) WHERE u.id={0}", $poster['id']);
}
Пример #23
0
function getCategory($cat)
{
    if (!is_numeric($cat)) {
        Kill('Invalid category');
    }
    if ($cat >= 0) {
        $rCategory = Query("select * from {uploader_categories} where id={0}", $cat);
        if (NumRows($rCategory) == 0) {
            Kill("Invalid category");
        }
        $rcat = Fetch($rCategory);
    } else {
        if ($cat == -1) {
            $rcat = array("id" => -1, "name" => "Private files");
        } else {
            if ($cat == -2) {
                $rcat = array("id" => -2, "name" => "All private files");
            } else {
                Kill('Invalid category');
            }
        }
    }
    return $rcat;
}
Пример #24
0
if ($_GET["key"] != $loguser["token"]) {
    die("Nope!");
}
CheckPermission('user.voteposts');
$pid = (int) $_GET["id"];
$post = Fetch(Query("SELECT * FROM {posts} WHERE id = {0}", $pid));
if (!$post) {
    die("Unknown post");
}
if ($post["user"] == $loguserid) {
    die("Nope!");
}
$thread = Fetch(Query("SELECT * FROM {threads} WHERE id = {0}", $post["thread"]));
if (!$thread) {
    die("Unknown thread");
}
if (!HasPermission('forum.viewforum', $thread['forum'])) {
    die('Nice try hacker kid, but no.');
}
if ($thread["closed"]) {
    die(__("Thread is closed"));
}
$vote = Fetch(Query("SELECT * FROM {postplusones} WHERE post = {0} AND user = {1}", $pid, $loguserid));
if (!$vote) {
    Query("UPDATE {posts} SET postplusones = postplusones+1 WHERE id = {0} LIMIT 1", $pid);
    Query("UPDATE {users} SET postplusones = postplusones+1 WHERE id = {0} LIMIT 1", $post["user"]);
    Query("UPDATE {users} SET postplusonesgiven = postplusonesgiven+1 WHERE id = {0} LIMIT 1", $loguserid);
    Query("INSERT INTO {postplusones} (user, post) VALUES ({0}, {1})", $loguserid, $pid);
    $post["postplusones"]++;
}
echo formatPlusOnes($post["postplusones"]);
Пример #25
0
}
function getCheck($name)
{
    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\">&nbsp;" . __("Close thread", 1) . "</label>\n";
    } else {
        $mod_lock = "<label><input type=\"checkbox\" " . getCheck("unlock") . "  name=\"unlock\">&nbsp;" . __("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\">&nbsp;" . __("Sticky", 1) . "</label>\n";
Пример #26
0
<?php

if (!$loguser['root']) {
    Kill(__("You're not an administrator. There is nothing for you here."));
}
MakeCrumbs(array(actionLink("admin") => __("Admin"), actionLink("optimize") => __("Optimize tables")));
$rStats = Query("show table status");
while ($stat = Fetch($rStats)) {
    $tables[$stat['Name']] = $stat;
}
$tablelist = "";
$total = 0;
foreach ($tables as $table) {
    $cellClass = ($cellClass + 1) % 2;
    $overhead = $table['Data_free'];
    $total += $overhead;
    $status = __("OK");
    if ($overhead > 0) {
        Query("OPTIMIZE TABLE `{" . $table['Name'] . "}`");
        $status = "<strong>" . __("Optimized") . "</strong>";
    }
    $tablelist .= format("\n\t<tr class=\"cell{0}\">\n\t\t<td class=\"cell2\">{1}</td>\n\t\t<td>\n\t\t\t{2}\n\t\t</td>\n\t\t<td>\n\t\t\t{3}\n\t\t</td>\n\t\t<td>\n\t\t\t{4}\n\t\t</td>\n\t</tr>\n", $cellClass, $table['Name'], $table['Rows'], $overhead, $status);
}
write("\n<table class=\"outline margin\">\n\t<tr class=\"header0\">\n\t\t<th colspan=\"7\">\n\t\t\t" . __("Table Status") . "\n\t\t</th>\n\t</tr>\n\t<tr class=\"header1\">\n\t\t<th>\n\t\t\t" . __("Name") . "\n\t\t</th>\n\t\t<th>\n\t\t\t" . __("Rows") . "\n\t\t</th>\n\t\t<th>\n\t\t\t" . __("Overhead") . "\n\t\t</th>\n\t\t<th>\n\t\t\t" . __("Final Status") . "\n\t\t</th>\n\t</tr>\n\t{0}\n\t<tr class=\"header0\">\n\t\t<th colspan=\"7\" style=\"font-size: 130%;\">\n\t\t\t" . __("Excess trimmed: {1} bytes") . "\n\t\t</th>\n\t</tr>\n</table>\n\n", $tablelist, $total);
Пример #27
0
        $val = $_POST['exif'];
        if (empty($pid) || !$cbphoto->photo_exists($pid)) {
            $response = array('error' => lang('Photo does not exist'));
        }
        if (strtolower($val) != 'yes' || strtolower($val) != 'no') {
            $response = array('error' => lang('Invalid value provided'));
        }
        if ($db->update(tbl('photos'), array('view_exif'), array($val), " photo_id = '" . $pid . "' ")) {
            $response = array('success' => 'Exif privacy setting updated.');
        } else {
            $response = array('error' => 'Unable to update setting. Please try again');
        }
        echo json_encode($response);
        break;
    case "get_colors":
        $pid = mysql_clean($_POST['id']);
        $colors = get_photo_meta_value($pid, 'colors');
        if ($colors) {
            $colors = json_decode($colors, true);
            assign('colors', $colors);
            assign('photo', $cbphoto->get_photo($pid, true));
            $template = Fetch('/global/colors.html', STYLES_DIR);
            $response = array('success' => true, 'template' => $template);
        } else {
            $response = array('error' => 'No colors found for this photo.');
        }
        echo json_encode($response);
        break;
    default:
        exit(json_encode(array('err' => lang('Invalid request'))));
}
Пример #28
0
<?php

$viewableforums = ForumsWithPermission('forum.viewforum');
$tag = $_GET['tag'];
$tagcode = '"[' . $tag . ']"';
$forum = $_GET['fid'];
$cond = "WHERE MATCH (t.title) AGAINST ({0} IN BOOLEAN MODE)";
if ($forum) {
    $cond .= " AND t.forum = {1}";
}
$total = Fetch(Query("SELECT count(*) from threads t {$cond} AND t.forum IN ({2c})", $tag, $forum, $viewableforums));
$total = $total[0];
$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\tf.(title, id),\n\t\t\t\t\t\t" . ($loguserid ? "tr.date readdate," : '') . "\n\t\t\t\t\t\tsu.(_userfields),\n\t\t\t\t\t\tlu.(_userfields)\n\t\t\t\t\tFROM\n\t\t\t\t\t\tthreads t\n\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN threadsread tr ON tr.thread=t.id AND tr.id={2}" : '') . "\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\t{$cond} AND f.id IN ({5c})\n\t\t\t\t\tORDER BY sticky DESC, lastpostdate DESC LIMIT {3u}, {4u}", $tagcode, $forum, $loguserid, $from, $tpp, $viewableforums);
$pagelinks = PageLinks(actionLink("tagsearch", "", "tag={$tag}&fid={$forum}&from="), $tpp, $from, $total);
if (NumRows($rThreads)) {
    makeThreadListing($rThreads, $pagelinks, false, !$forum);
} else {
    Alert(format(__("Tag {0} was not found in any thread."), htmlspecialchars($tag)), __("No threads found."));
}
Пример #29
0
<?php

$ajaxPage = true;
$id = (int) $_GET["id"];
$rPost = Query("\n\t\tSELECT\n\t\t\tp.id, p.date, p.num, p.deleted, p.deletedby, p.reason, p.options, p.mood, p.ip,\n\t\t\tpt.text, pt.revision, pt.user AS revuser, pt.date AS revdate,\n\t\t\tu.(_userfields), u.(rankset,title,picture,posts,postheader,signature,signsep,lastposttime,lastactivity,regdate,globalblock),\n\t\t\tru.(_userfields),\n\t\t\tdu.(_userfields),\n\t\t\tf.id fid\n\t\tFROM\n\t\t\t{posts} p\n\t\t\tLEFT JOIN {posts_text} pt ON pt.pid = p.id AND pt.revision = p.currentrevision\n\t\t\tLEFT JOIN {users} u ON u.id = p.user\n\t\t\tLEFT JOIN {users} ru ON ru.id=pt.user\n\t\t\tLEFT JOIN {users} du ON du.id=p.deletedby\n\t\t\tLEFT JOIN {threads} t ON t.id=p.thread\n\t\t\tLEFT JOIN {forums} f ON f.id=t.forum\n\t\tWHERE p.id={0}", $id);
if (!NumRows($rPost)) {
    die(__("Unknown post ID."));
}
$post = Fetch($rPost);
if (!CanMod($loguserid, $post['fid']) && $loguserid != $post["u_id"]) {
    die(__("No."));
}
echo MakePost($post, $_GET['o'] ? POST_DELETED_SNOOP : POST_NORMAL, array('tid' => $post['thread'], 'fid' => $post['fid']));
Пример #30
0
<?php

if ($loguserid && isset($_GET['action']) && $_GET['action'] == "markallread") {
    Query("REPLACE INTO {threadsread} (id,thread,date) SELECT {0}, {threads}.id, {1} FROM {threads}", $loguserid, time());
    redirectAction("board");
}
$links = new PipeMenu();
if ($loguserid) {
    $links->add(new PipeMenuLinkEntry(__("Mark all forums read"), "board", 0, "action=markallread", "ok"));
}
makeLinks($links);
makeBreadcrumbs(new PipeMenu());
if (!$mobileLayout) {
    $statData = Fetch(Query("SELECT\n\t\t(SELECT COUNT(*) FROM {threads}) AS numThreads,\n\t\t(SELECT COUNT(*) FROM {posts}) AS numPosts,\n\t\t(SELECT COUNT(*) FROM {users}) AS numUsers,\n\t\t(select count(*) from {posts} where date > {0}) AS newToday,\n\t\t(select count(*) from {posts} where date > {1}) AS newLastHour,\n\t\t(select count(*) from {users} where lastposttime > {2}) AS numActive", time() - 86400, time() - 3600, time() - 2592000));
    $stats = Format(__("{0} and {1} total"), Plural($statData["numThreads"], __("thread")), Plural($statData["numPosts"], __("post")));
    $stats .= "<br />" . format(__("{0} today, {1} last hour"), Plural($statData["newToday"], __("new post")), $statData["newLastHour"]);
    $percent = $statData["numUsers"] ? ceil(100 / $statData["numUsers"] * $statData["numActive"]) : 0;
    $lastUser = Query("select u.(_userfields) from {users} u order by u.regdate desc limit 1");
    if (numRows($lastUser)) {
        $lastUser = getDataPrefix(Fetch($lastUser), "u_");
        $last = format(__("{0}, {1} active ({2}%)"), Plural($statData["numUsers"], __("registered user")), $statData["numActive"], $percent) . "<br />" . format(__("Newest: {0}"), UserLink($lastUser));
    } else {
        $last = __("No registered users") . "<br />&nbsp;";
    }
    write("\n\t\t<table class=\"outline margin width100\" style=\"overflow: auto;\">\n\t\t\t<tr class=\"cell2 center\" style=\"overflow: auto;\">\n\t\t\t<td>\n\t\t\t\t<div style=\"float: left; width: 25%;\">&nbsp;<br />&nbsp;</div>\n\t\t\t\t<div style=\"float: right; width: 25%;\">{1}</div>\n\t\t\t\t<div class=\"center\">\n\t\t\t\t\t{0}\n\t\t\t\t</div>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t", $stats, $last);
}
printRefreshCode();
makeForumListing(0);