Exemple #1
0
function makePost($post, $type, $params = array())
{
    global $loguser, $loguserid, $usergroups, $isBot, $blocklayouts;
    $poster = getDataPrefix($post, 'u_');
    $post['userlink'] = UserLink($poster);
    LoadBlockLayouts();
    $pltype = Settings::get('postLayoutType');
    $isBlocked = $poster['globalblock'] || $loguser['blocklayouts'] || $post['options'] & 1 || isset($blocklayouts[$poster['id']]);
    $post['type'] = $type;
    $post['formattedDate'] = formatdate($post['date']);
    if (!HasPermission('admin.viewips')) {
        $post['ip'] = '';
    } else {
        $post['ip'] = htmlspecialchars($post['ip']);
    }
    // TODO IP formatting?
    if ($post['deleted'] && $type == POST_NORMAL) {
        $post['deluserlink'] = UserLink(getDataPrefix($post, 'du_'));
        $post['delreason'] = htmlspecialchars($post['reason']);
        $links = array();
        if (HasPermission('mod.deleteposts', $params['fid'])) {
            $links['undelete'] = actionLinkTag(__("Undelete"), "editpost", $post['id'], "delete=2&key=" . $loguser['token']);
            $links['view'] = "<a href=\"#\" onclick=\"replacePost(" . $post['id'] . ",true); return false;\">" . __("View") . "</a>";
        }
        $post['links'] = $links;
        RenderTemplate('postbox_deleted', array('post' => $post));
        return;
    }
    $links = array();
    if ($type != POST_SAMPLE) {
        $forum = $params['fid'];
        $thread = $params['tid'];
        $notclosed = !$post['closed'] || HasPermission('mod.closethreads', $forum);
        $extraLinks = array();
        if (!$isBot) {
            if ($type == POST_DELETED_SNOOP) {
                if ($notclosed && HasPermission('mod.deleteposts', $forum)) {
                    $links['undelete'] = actionLinkTag(__("Undelete"), "editpost", $post['id'], "delete=2&key=" . $loguser['token']);
                }
                $links['close'] = "<a href=\"#\" onclick=\"replacePost(" . $post['id'] . ",false); return false;\">" . __("Close") . "</a>";
            } else {
                if ($type == POST_NORMAL) {
                    if ($notclosed) {
                        if ($loguserid && HasPermission('forum.postreplies', $forum) && !$params['noreplylinks']) {
                            $links['quote'] = actionLinkTag(__("Quote"), "newreply", $thread, "quote=" . $post['id']);
                        }
                        $editrights = 0;
                        if ($poster['id'] == $loguserid && HasPermission('user.editownposts') || HasPermission('mod.editposts', $forum)) {
                            $links['edit'] = actionLinkTag(__("Edit"), "editpost", $post['id']);
                            $editrights++;
                        }
                        if ($poster['id'] == $loguserid && HasPermission('user.deleteownposts') || HasPermission('mod.deleteposts', $forum)) {
                            if ($post['id'] != $post['firstpostid']) {
                                $link = htmlspecialchars(actionLink('editpost', $post['id'], 'delete=1&key=' . $loguser['token']));
                                $onclick = HasPermission('mod.deleteposts', $forum) ? " onclick=\"deletePost(this);return false;\"" : ' onclick="if(!confirm(\'Really delete this post?\'))return false;"';
                                $links['delete'] = "<a href=\"{$link}\"{$onclick}>" . __('Delete') . "</a>";
                            }
                            $editrights++;
                        }
                        if ($editrights < 2 && HasPermission('user.reportposts')) {
                            $links['report'] = actionLinkTag(__('Report'), 'reportpost', $post['id']);
                        }
                    }
                    // plugins should add to $extraLinks
                    $bucket = "topbar";
                    include __DIR__ . "/pluginloader.php";
                }
            }
            $links['extra'] = $extraLinks;
        }
        //Threadlinks for listpost.php
        if ($params['threadlink']) {
            $thread = array();
            $thread['id'] = $post['thread'];
            $thread['title'] = $post['threadname'];
            $thread['forum'] = $post['fid'];
            $post['threadlink'] = makeThreadLink($thread);
        } else {
            $post['threadlink'] = '';
        }
        //Revisions
        if ($post['revision']) {
            $ru_link = UserLink(getDataPrefix($post, "ru_"));
            $revdetail = ' ' . format(__('by {0} on {1}'), $ru_link, formatdate($post['revdate']));
            if (HasPermission('mod.editposts', $forum)) {
                $post['revdetail'] = "<a href=\"javascript:void(0);\" onclick=\"showRevisions(" . $post['id'] . ")\">" . Format(__('rev. {0}'), $post['revision']) . "</a>" . $revdetail;
            } else {
                $post['revdetail'] = Format(__('rev. {0}'), $post['revision']) . $revdetail;
            }
        }
        //</revisions>
    }
    $post['links'] = $links;
    // POST SIDEBAR
    $sidebar = array();
    // quit abusing custom syndromes you unoriginal fuckers
    $poster['title'] = preg_replace('@Affected by \'?.*?Syndrome\'?@si', '', $poster['title']);
    $sidebar['rank'] = GetRank($poster['rankset'], $poster['posts']);
    if ($poster['title']) {
        $sidebar['title'] = strip_tags(CleanUpPost($poster['title'], '', true), '<b><strong><i><em><span><s><del><img><a><br/><br><small>');
    } else {
        $sidebar['title'] = htmlspecialchars($usergroups[$poster['primarygroup']]['title']);
    }
    $sidebar['syndrome'] = GetSyndrome(getActivity($poster['id']));
    if ($post['mood'] > 0) {
        if (file_exists(DATA_DIR . "avatars/" . $poster['id'] . "_" . $post['mood'])) {
            $sidebar['avatar'] = "<img src=\"" . DATA_URL . "avatars/" . $poster['id'] . "_" . $post['mood'] . "\" alt=\"\">";
        }
    } else {
        if ($poster['picture']) {
            $pic = str_replace('$root/', DATA_URL, $poster['picture']);
            $sidebar['avatar'] = "<img src=\"" . htmlspecialchars($pic) . "\" alt=\"\">";
        }
    }
    $lastpost = $poster['lastposttime'] ? timeunits(time() - $poster['lastposttime']) : "none";
    $lastview = timeunits(time() - $poster['lastactivity']);
    if (!$post['num']) {
        $sidebar['posts'] = $poster['posts'];
    } else {
        $sidebar['posts'] = $post['num'] . '/' . $poster['posts'];
    }
    $sidebar['since'] = cdate($loguser['dateformat'], $poster['regdate']);
    $sidebar['lastpost'] = $lastpost;
    $sidebar['lastview'] = $lastview;
    if ($poster['lastactivity'] > time() - 300) {
        $sidebar['isonline'] = __("User is <strong>online</strong>");
    }
    $sidebarExtra = array();
    $bucket = "sidebar";
    include __DIR__ . "/pluginloader.php";
    $sidebar['extra'] = $sidebarExtra;
    $post['sidebar'] = $sidebar;
    // OTHER STUFF
    $post['haslayout'] = false;
    $post['fulllayout'] = false;
    if (!$isBlocked) {
        $poster['postheader'] = $pltype ? trim($poster['postheader']) : '';
        $poster['signature'] = trim($poster['signature']);
        $post['haslayout'] = $poster['postheader'] ? 1 : 0;
        $post['fulllayout'] = $poster['fulllayout'] && $post['haslayout'] && $pltype == 2;
        if (!$post['haslayout'] && $poster['signature']) {
            $poster['signature'] = '<div class="signature">' . $poster['signature'] . '</div>';
        }
    } else {
        $poster['postheader'] = '';
        $poster['signature'] = '';
    }
    $post['contents'] = makePostText($post, $poster);
    //PRINT THE POST!
    RenderTemplate('postbox', array('post' => $post));
}
Exemple #2
0
function makePost($post, $type, $params = array())
{
    global $loguser, $loguserid, $blocklayouts, $dataDir, $dataUrl, $mobileLayout;
    $sideBarStuff = "";
    $poster = getDataPrefix($post, "u_");
    LoadBlockLayouts();
    $isBlocked = $poster['globalblock'] || $loguser['blocklayouts'] || $post['options'] & 1 || isset($blocklayouts[$poster['id']]);
    $links = makePostLinks($post, $type, $params);
    if ($post['deleted'] && $type == POST_NORMAL) {
        $meta = format(__("Posted on {0}"), formatdate($post['date']));
        $meta .= __(', deleted');
        if ($post['deletedby']) {
            $db_link = UserLink(getDataPrefix($post, "du_"));
            $meta .= __(' by ') . $db_link;
            if ($post['reason']) {
                $meta .= ': ' . htmlspecialchars($post['reason']);
            }
        }
        if ($mobileLayout) {
            $links->setClass("toolbarMenu");
            echo "\n\t\t\t\t<table class=\"outline margin mobile-postBox\" id=\"post{$post['id']}\">\n\t\t\t\t\t<tr class=\"header0 mobile-postHeader\">\n\t\t\t\t\t\t<th>\n\t\t\t\t\t\t\t{$anchor}\n\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t<div class=\"mobile-userAvatarBox\">\n\t\t\t\t\t\t\t\t\t\t\t{$picture}\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td class=\"mobile-postInfoCell\" style=\"width: 99%; overflow: hidden;\">\n\t\t\t\t\t\t\t\t\t\t<div style=\"position: relative; height: 40px; top: 0; left: 0;\">\n\t\t\t\t\t\t\t\t\t\t\t<div style=\"position: absolute; top: 0; left: 0;\">\n\t\t\t\t\t\t\t\t\t\t\t\t" . userLink($poster) . "<br />\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"date\">{$meta}</span>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t<span style=\"text-align:left; display: none;\" id=\"dyna_{$post['id']}\">\n\t\t\t\t\t\t\t\t\t\t\t&nbsp;\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t" . $links->build(2) . "\n\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</th>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t";
        } else {
            echo "\n\t\t\t\t<table class=\"post margin deletedpost\" id=\"post{$post['id']}\">\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class=\"side userlink\">\n\t\t\t\t\t\t\t" . userLink($poster) . "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"smallFonts meta right\">\n\t\t\t\t\t\t\t<div style=\"float:left\">\n\t\t\t\t\t\t\t\t{$meta}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t" . $links->build() . "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>";
        }
        return;
    }
    if ($type == POST_SAMPLE) {
        $meta = $params['metatext'] ? $params['metatext'] : __("Sample post");
    } else {
        $forum = $params['fid'];
        $thread = $params['tid'];
        $canMod = CanMod($loguserid, $forum);
        $canReply = ($canMod || !$post['closed'] && $loguser['powerlevel'] > -1) && $loguserid;
        if ($type == POST_PM) {
            $message = __("Sent on {0}");
        } else {
            $message = __("Posted on {0}");
        }
        $meta = format($message, formatdate($post['date']));
        //Threadlinks for listpost.php
        if ($params['threadlink']) {
            $thread = array();
            $thread["id"] = $post["thread"];
            $thread["title"] = $post["threadname"];
            $meta .= " " . __("in") . " " . makeThreadLink($thread);
        }
        //Revisions
        if ($post['revision']) {
            if ($post['revuser']) {
                $ru_link = UserLink(getDataPrefix($post, "ru_"));
                $revdetail = " " . format(__("by {0} on {1}"), $ru_link, formatdate($post['revdate']));
            } else {
                $revdetail = '';
            }
            if ($canMod) {
                $meta .= " (<a href=\"javascript:void(0);\" onclick=\"showRevisions(" . $post['id'] . ")\">" . format(__("rev. {0}"), $post['revision']) . "</a>" . $revdetail . ")";
            } else {
                $meta .= " (" . format(__("rev. {0}"), $post['revision']) . $revdetail . ")";
            }
        }
        //</revisions>
    }
    // POST SIDEBAR
    $sideBarStuff .= GetRank($poster["rankset"], $poster["posts"]);
    if ($sideBarStuff) {
        $sideBarStuff .= "<br />";
    }
    if ($poster['title']) {
        $sideBarStuff .= strip_tags(CleanUpPost($poster['title'], "", true), "<b><strong><i><em><span><s><del><img><a><br/><br><small>") . "<br />";
    } else {
        $levelRanks = array(-1 => __("Banned"), 0 => "", 1 => __("Local mod"), 2 => __("Full mod"), 3 => __("Administrator"));
        $sideBarStuff .= $levelRanks[$poster['powerlevel']] . "<br />";
    }
    $sideBarStuff .= GetSyndrome(getActivity($poster["id"]));
    $pictureUrl = "";
    if ($post['mood'] > 0) {
        if (file_exists("{$dataDir}avatars/" . $poster['id'] . "_" . $post['mood'])) {
            $pictureUrl = "{$dataUrl}avatars/" . $poster['id'] . "_" . $post['mood'];
        }
    } else {
        if ($poster["picture"] == "#INTERNAL#") {
            $pictureUrl = "{$dataUrl}avatars/" . $poster['id'];
        } else {
            if ($poster["picture"]) {
                $pictureUrl = $poster["picture"];
            }
        }
    }
    if ($pictureUrl) {
        $sideBarStuff .= "<img src=\"" . htmlspecialchars($pictureUrl) . "\" alt=\"\" />";
    }
    $lastpost = $poster['lastposttime'] ? timeunits(time() - $poster['lastposttime']) : "none";
    $lastview = timeunits(time() - $poster['lastactivity']);
    $sideBarStuff .= "<br />\n" . __("Karma:") . " " . $poster['karma'];
    if (!$params['forcepostnum'] && ($type == POST_PM || $type == POST_SAMPLE)) {
        $sideBarStuff .= "<br />\n" . __("Posts:") . " " . $poster['posts'];
    } else {
        $sideBarStuff .= "<br />\n" . __("Posts:") . " " . $post['num'] . "/" . $poster['posts'];
    }
    $sideBarStuff .= "<br />\n" . __("Since:") . " " . cdate($loguser['dateformat'], $poster['regdate']) . "<br />";
    $bucket = "sidebar";
    include "./lib/pluginloader.php";
    if (Settings::get("showExtraSidebar")) {
        $sideBarStuff .= "<br />\n" . __("Last post:") . " " . $lastpost;
        $sideBarStuff .= "<br />\n" . __("Last view:") . " " . $lastview;
        if ($poster['lastactivity'] > time() - 300) {
            $sideBarStuff .= "<br />\n" . __("User is <strong>online</strong>");
        }
    }
    // OTHER STUFF
    if ($type == POST_NORMAL) {
        $anchor = "<a name=\"" . $post['id'] . "\"></a>";
    }
    if (!$isBlocked) {
        $pTable = "table" . $poster['id'];
        $row1 = "row" . $poster['id'] . "_1";
        $row2 = "row" . $poster['id'] . "_2";
        $topBar1 = "topbar" . $poster['id'] . "_1";
        $topBar2 = "topbar" . $poster['id'] . "_2";
        $sideBar = "sidebar" . $poster['id'];
        $mainBar = "mainbar" . $poster['id'];
    }
    $postText = makePostText($post);
    //PRINT THE POST!
    if ($mobileLayout) {
        $links->setClass("toolbarMenu");
        if ($pictureUrl) {
            $picture = "<img src=\"" . htmlspecialchars($pictureUrl) . "\" alt=\"\" style=\"max-width: 40px; max-height: 40px;\"/>";
        } else {
            $picture = "";
        }
        echo "\n\t\t\t\t<table class=\"outline margin mobile-postBox\" id=\"post{$post['id']}\">\n\t\t\t\t<tr class=\"header0 mobile-postHeader\">\n\t\t\t\t\t<th>\n\t\t\t\t\t\t{$anchor}\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<div class=\"mobile-userAvatarBox\">\n\t\t\t\t\t\t\t\t\t\t{$picture}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td class=\"mobile-postInfoCell\" style=\"width: 99%; overflow: hidden;\">\n\t\t\t\t\t\t\t\t\t<div style=\"position: relative; height: 40px; top: 0; left: 0;\">\n\t\t\t\t\t\t\t\t\t\t<div style=\"position: absolute; top: 0; left: 0;\">\n\t\t\t\t\t\t\t\t\t\t\t" . userLink($poster) . "<br />\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"date\">{$meta}</span>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<span style=\"text-align:left; display: none;\" id=\"dyna_{$post['id']}\">\n\t\t\t\t\t\t\t\t\t\t&nbsp;\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t" . $links->build(2) . "\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=\"3\" class=\"cell0 mobile-postBox\">\n\t\t\t\t\t\t{$postText}\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t";
    } else {
        echo "\n\t\t\t<table class=\"post margin {$pTable}\" id=\"post{$post['id']}\">\n\t\t\t\t<tr class=\"{$row1}\">\n\t\t\t\t\t<td class=\"side userlink {$topBar1}\">\n\t\t\t\t\t\t{$anchor}\n\t\t\t\t\t\t" . UserLink($poster) . "\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class=\"meta right {$topBar2}\">\n\t\t\t\t\t\t<div style=\"float: left;\" id=\"meta_{$post['id']}\">\n\t\t\t\t\t\t\t{$meta}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div style=\"float: left; text-align:left; display: none;\" id=\"dyna_{$post['id']}\">\n\t\t\t\t\t\t\tHi.\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t" . $links->build() . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr class=\"" . $row2 . "\">\n\t\t\t\t\t<td class=\"side {$sideBar}\">\n\t\t\t\t\t\t<div class=\"smallFonts\">\n\t\t\t\t\t\t\t{$sideBarStuff}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class=\"post {$mainBar}\" id=\"post_{$post['id']}\">\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t{$postText}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>";
    }
}
                 $reply .= "<br />";
             }
             $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));
             }
         }
     }
 }
Exemple #4
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\tFROM\n\t\t\t{posts} p\n\t\t\tLEFT JOIN {posts_text} pt ON pt.pid = p.id AND pt.revision = {1}\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\tWHERE p.id={0}", $id, (int) $_GET['rev']);
if (NumRows($rPost)) {
    $post = Fetch($rPost);
} else {
    die(format(__("Unknown post ID #{0} or revision missing."), $id));
}
$qThread = "select forum from {threads} where id={0}";
$rThread = Query($qThread, $post['thread']);
$thread = Fetch($rThread);
$qForum = "select minpower from {forums} where id={0}";
$rForum = Query($qForum, $thread['forum']);
$forum = Fetch($rForum);
if ($forum['minpower'] > $loguser['powerlevel']) {
    die(__("No."));
}
echo makePostText($post);