Example #1
0
$topic->Parse();
$topic->GetReplies();
Output::Assign('topic', $topic);
update_activity('topic', $_GET['id']);
$page_title = 'Topic: ' . htmlspecialchars($topic->Headline);
// Increment visit count.
if (!isset($_SESSION['visited_topics'][$_GET['id']]) && isset($_COOKIE['SID'])) {
    $_SESSION['visited_topics'][$_GET['id']] = 1;
    DB::Execute('UPDATE {P}Topics SET visits = visits + 1 WHERE id = ' . $_GET['id']);
}
// Set visited cookie...
$last_read_post = $User->Visited[$_GET['id']];
if ($last_read_post !== $topic->Replies) {
    // Build cookie.
    // Add the current topic:
    $User->Visited = array($_GET['id'] => $topic_replies) + $User->Visited;
    // Readd old topics.
    foreach ($User->Visited as $cur_topic_id => $num_replies) {
        // If the cookie is getting too long (4kb), stop.
        if (strlen($cookie_string) > 3900) {
            break;
        }
        $cookie_string .= 't' . $cur_topic_id . 'n' . $num_replies;
    }
    CreateCookie('topic_visits', $cookie_string);
}
Output::Assign('LastReadPost', $last_read_post);
// Output dummy form. (This is for JavaScript submissions to action.php.)
dummy_form();
echo Output::$tpl->Fetch('topic.tpl.php');
require 'includes/footer.php';
Example #2
0
 function CreateID()
 {
     $this->ID = uniqid('', true);
     // Maybe switch to UUIDs;  Easier to validate.
     $this->Password = $this->GenPass();
     $stmt = DB::Prepare('INSERT INTO {P}Users (uid, password, ip_address, first_seen) VALUES (?, ?, ?, UNIX_TIMESTAMP())');
     DB::Execute($stmt, array($this->ID, $this->Password, $_SERVER['REMOTE_ADDR']));
     $_SESSION['first_seen'] = $_SERVER['REQUEST_TIME'];
     $_SESSION['notice'] = 'Welcome to <strong>' . SITE_TITLE . '</strong>. An account has automatically been created and assigned to you. You don\'t have to register or log in to use the board. Please don\'t clear your cookies unless you have <a href="/dashboard">set a memorable name and password</a>.';
     //setcookie('UID', 	$this->ID, $_SERVER['REQUEST_TIME'] + 315569260, '/');
     //setcookie('password', 	$this->Password, $_SERVER['REQUEST_TIME'] + 315569260, '/');
     CreateCookie('UID', $this->ID);
     CreateCookie('Password', $this->Password);
     $_SESSION['UID'] = $this->ID;
 }