/**
 * Look up a quotereply link, and convert it to the necessary anchor
 * tag equivalent if necessary.
 * 
 * @param int $bid The board ID
 * @param string $bfold The board folder name
 * @param int $threadid The (unique) ID for this thread
 * @param int $threadglob The global ID for this thread
 * @param int $pulledvalue The parsed value (i.e. would be 2 for ">>2")
 * 
 * @return string The anchor link (or just ">>$pulledvalue" if it was invalid)
 */
function lookup_qr_link($bid, $bfold, $threadid, $threadglob, $pulledvalue)
{
    $db = new ThornPostDBI();
    // Default to not finding anything of use.
    $link = $link = ">>" . $pulledvalue;
    // This abstracts so much stuff for us.
    $postinfo = $db->getsinglepost($pulledvalue, $bid);
    if ($postinfo != null) {
        if ($postinfo['thread'] == 0) {
            // Just add an anchor tag and go
            if (THuserewrite) {
                $link = '<a href="' . THurl . $bfold . "/thread/" . $pulledvalue . '#' . $pulledvalue . '">&gt;&gt;' . $pulledvalue . "</a>";
            } else {
                $link = '<a href="' . THurl . 'drydock.php?b=' . $bfold . '&amp;i=' . $pulledvalue . '#' . $pulledvalue . '">&gt;&gt;' . $pulledvalue . "</a>";
            }
        } else {
            if ($postinfo['thread'] == $threadid) {
                if (THuserewrite) {
                    $link = "<a href=\"" . THurl . $bfold . "/thread/" . $threadglob . "#" . $pulledvalue . "\">&gt;&gt;" . $pulledvalue . "</a>";
                } else {
                    $link = "<a href=\"" . THurl . 'drydock.php?b=' . $bfold . '&amp;i=' . $threadglob . "#" . $pulledvalue . "\">&gt;&gt;" . $pulledvalue . "</a>";
                }
            } else {
                // We need to look up the global ID.
                $threadinfo = $db->gettinfo($postinfo['thread']);
                // Was it a valid lookup?
                if ($threadinfo != null) {
                    $threadop = $threadinfo['globalid'];
                    if (THuserewrite) {
                        $link = "<a href=\"" . THurl . $bfold . "/thread/" . $threadop . "#" . $pulledvalue . "\">&gt;&gt;" . $pulledvalue . "</a>";
                    } else {
                        $link = "<a href=\"" . THurl . 'drydock.php?b=' . $bfold . '&amp;i=' . $threadop . "#" . $pulledvalue . "\">&gt;&gt;" . $pulledvalue . "</a>";
                    }
                }
            }
        }
    }
    return $link;
}
Exemple #2
0
}
$db = new ThornPostDBI();
// Set some stuff up.
$board_id = $db->getboardnumber($board_folder);
$postid = intval($_GET['post']);
// SQL injection protection :]
$threadid = 0;
// set this up later once we get some post data
$ipstring = "";
// Make sure we retrieved a valid board id
if ($board_id == null) {
    THdie("That board does not exist!");
}
// $postarray will hold the assoc containing post data
$postarray = array();
$postarray = $db->getsinglepost($postid, $board_id);
// Make sure it exists
if ($postarray == null) {
    THdie("Post with global ID of " . $postid . " and board /" . $board_folder . "/ does not exist.");
}
// Make a string from the IP for easy use in Smarty
$ipstring = long2ip($postarray['ip']);
// If it's a thread, the thread global ID and post global ID will be one and the same.
// Otherwise, we need to look it up.
if ($postarray['thread'] == 0) {
    $threadid = $postarray['globalid'];
} else {
    $fetched_thread = $db->gettinfo($postarray['thread']);
    $threadid = $fetched_thread['globalid'];
}
// only bother if we're receiving POST data