Beispiel #1
0
function todos_request($config, $uri)
{
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'GET':
            find_activity($config);
            break;
        case 'POST':
            //create
            create_activity($config);
            break;
        case 'PUT':
            //update
            update_activity($config, $uri[3]);
            break;
        case 'DELETE':
            delete_activity($config, $uri[3]);
            break;
        case 'HEAD':
        case 'OPTION':
        default:
            error_activity();
            break;
    }
}
Beispiel #2
0
<?php

require 'includes/header.php';
force_id();
update_activity('dashboard');
Output::Assign('sidebar', $sidebar);
Output::$tpl->display('dashhead.tpl.php');
$page_title = $User->Level . ' Dashboard';
// Get our user's settings from the database.
// Done by User class now
if ($_POST['form_sent']) {
    $name = POST::GetEString('memorable_name', true);
    $pass = POST::GetEString('memorable_password', true);
    $pass2 = POST::GetEString('memorable_password2', true);
    $email = POST::GetEString('email', true);
    $theme = POST::GetEString('theme', true, 'atbbs');
    $flag_topics = POST::GetInt('topics_mode') == 1;
    $flag_ostrich = POST::GetInt('ostrich_mode') == 1;
    $flag_spoiler = POST::GetInt('spoiler_mode') == 1;
    $snippet_len = POST::GetInt('snippet_length');
    // Make some specific validations ...
    if (!empty($_POST['form']['memorable_name']) && $_POST['form']['memorable_name'] != $user_config['memorable_name']) {
        // Check if the name is already being used.
        $res = DB::Execute('SELECT 1 FROM {P}UserSettings WHERE LOWER(usrName) = LOWER(' . DB::Q($_POST['form']['memorable_name']) . ')');
        if ($res->RecordCount() > 0) {
            add_error('The memorable name "' . htmlspecialchars($_POST['memorable_name']) . '" is already being used.');
        }
    }
    if ($pass != $pass2) {
        add_error(' Both password fields must match.');
    }
Beispiel #3
0
<?php

require 'includes/header.php';
update_activity('failed_postings');
$page_title = 'Failed postings';
Output::Assign('sidebar', $sidebar);
Output::$tpl->display('dashhead.tpl.php');
$items_per_page = ITEMS_PER_PAGE;
$res = DB::Execute('SELECT time, uid, reason, headline, body FROM {P}FailedPostings ORDER BY time DESC LIMIT ' . $items_per_page);
$table = new TablePrinter('tblFail');
$columns = array('Error message', 'Poster', 'Age ▼');
if (isPowerUser()) {
    array_splice($columns, 1, 1);
}
$table->DefineColumns($columns, 'Error message');
while (list($fail_time, $fail_uid, $fail_reason, $fail_headline, $fail_body) = $res->FetchRow()) {
    if (strlen($fail_body) > 600) {
        $fail_body = substr($fail_body, 0, 600) . ' …';
    }
    $tooltip = '';
    if (empty($fail_headline)) {
        $tooltip = $fail_body;
    } else {
        if (!empty($fail_body)) {
            $tooltip = 'Headline: ' . $fail_headline . ' Body: ' . $fail_body;
        }
    }
    $fail_reasons = unserialize($fail_reason);
    $error_message = '<ul class="error_message';
    if (!empty($tooltip)) {
        $error_message .= ' help';
Beispiel #4
0
<?php

require 'includes/header.php';
update_activity('restore_id');
Output::Assign('sidebar', $sidebar);
Output::$tpl->display('dashhead.tpl.php');
$page_title = 'Restore ID';
$onload_javascript = 'focusId(\'memorable_name\')';
// If an ID card was uploaded...
if (isset($_POST['do_upload'])) {
    list($uid, $password) = file($_FILES['id_card']['tmp_name'], FILE_IGNORE_NEW_LINES);
} else {
    if (!empty($_POST['UID']) && !empty($_POST['password'])) {
        $uid = $_POST['UID'];
        $password = $_POST['password'];
    } else {
        if (!empty($_GET['UID']) && !empty($_GET['password'])) {
            $uid = $_GET['UID'];
            $password = $_GET['password'];
        } else {
            if (!empty($_POST['memorable_name'])) {
                $sql = DB::Prepare('SELECT u.uid,u.password FROM {P}UserSettings as s INNER JOIN {P}Users as u WHERE s.usrID=u.uid AND LOWER(s.usrName) = LOWER(?) AND usrPasshash = SHA1(CONCAT(s.usrID,?))');
                $res = DB::Execute($sql, array($_POST['memorable_name'], $_POST['memorable_password']));
                if ($res->RecordCount() == 0) {
                    add_error('Your memorable information was incorrect.');
                } else {
                    list($uid, $password) = $res->FetchRow();
                }
            }
        }
    }
Beispiel #5
0
<?php

require 'includes/header.php';
update_activity('stuff');
$page_title = 'Stuff';
Output::Assign('sidebar', $sidebar);
Output::$tpl->display('dashhead.tpl.php');
?>
	<h1>Your Dashboard</h1>
	<p>
		Welcome to the ATBBS Dashboard.  Here, you will find an assload of
		tools to help you manage your account, personalize the board, and,
		if you have sufficient permissions, administrate the board.
	</p>
	<h2>You In A Nutshell</h2>
<?php 
$mytopics = DB::GetOne("SELECT COUNT(*) FROM {P}Topics WHERE author='{$User->ID}'");
$myreplies = DB::GetOne("SELECT COUNT(*) FROM {P}Replies WHERE author='{$User->ID}'");
$topics = DB::GetOne("SELECT COUNT(*) FROM {P}Topics");
$replies = DB::GetOne("SELECT COUNT(*) FROM {P}Replies");
?>
	<p>You are <span style="font-weight:bold;" title="Your ID"><code><?php 
echo $User->ID;
?>
</code></span>, <?php 
echo an($User->Level);
?>
 <b><?php 
echo strtolower($User->Level);
?>
</b> who has been around since <b><?php 
Beispiel #6
0
             $SCION->status = BUTTON_DISP;
             //		break 1;
         //		break 1;
         case BUTTON_DISP:
             button_send($SCION, $HTML);
             echo $HTML;
             $SCION->status = STATE::CHANGE;
             break 2;
         case STATE::CHANGE:
             if (isset($_GET["reset"])) {
                 $_STATE->goback(1);
                 //go back to log_list
                 break 3;
             }
             if (isset($_POST["actupd"])) {
                 update_activity($SCION);
             } else {
                 new_hours($SCION);
                 //msgStatus='-' says to "reset", ie. goback(1), so set that state's totals:
                 $temp = STATE_pull($_STATE->thread, 1);
                 total_hours($temp);
                 //re-calculate for all projects
                 $temp->replace();
             }
             echo $SCION->msgStatus;
             break 2;
         default:
             throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): error");
     }
 }
 //while & switch
Beispiel #7
0
<?php

require 'includes/header.php';
update_activity('folks', 1);
$res = DB::Execute('SELECT a.action_name, a.action_id, a.uid, a.time, t.headline FROM {P}Activity as a LEFT OUTER JOIN {P}Topics as t ON a.action_id = t.id WHERE a.time > ' . intval($_SERVER['REQUEST_TIME']) . ' - 960 ORDER BY time DESC');
$count = $res->RecordCount();
$page_title = 'Folks online (' . $count . ')';
$table = new table();
$columns = array('Doing', 'Poster', 'Last sign of life ▼');
$table->define_columns($columns, 'Doing');
$table->add_td_class('Poster', 'minimal');
$table->add_td_class('Last sign of life ▼', 'minimal');
$i = 0;
// Array key based off
$actions = array('advertise' => 'Inquiring about advertising.', 'statistics' => 'Looking at board statistics.', 'hot_topics' => 'Looking at the hottest topics.', 'bulletins' => 'Reading latest bulletins.', 'bulletins_old' => 'Reading latest bulletins.', 'folks' => 'Looking at what other people are doing.', 'topics' => 'Looking at older topics.', 'dashboard' => 'Modifying their dashboard', 'latest_replies' => 'Looking at latest replies.', 'latest_bumps' => 'Checking out latest bumps.', 'latest_topics' => 'Checking out latest topics.', 'search' => 'Searching for a topic.', 'stuff' => 'Looking at stuff.', 'history' => 'Looking at post history.', 'failed_postings' => 'Looking at post failures.', 'watchlist' => 'Checking out their watchlist.', 'restore_id' => 'Logging in.', 'new_topic' => 'Creating a new topic.', 'nonexistent_topic' => 'Trying to look at a non-existant topic.', 'topic' => "Reading in topic: <strong><a href=\"/topic/{$action_id}\">{$headline}</a></strong>", 'replying' => "Replying to topic: <strong><a href=\"/topic/{$action_id}\">{$headline}</a></strong>", 'topic_trivia' => "Reading <a href=\"/trivia_for_topic/{$action_id}\">trivia for topic</a>: <strong><a href=\"/topic/{$action_id}\">{$headline}</a></strong>", 'banned' => 'Being banned.');
while (list($action, $action_id, $uid, $age, $headline) = $res->FetchRow()) {
    // Maximum amount of actions to be shown (100 by default)
    if (++$i == 100) {
        break;
    }
    if ($uid == $_SESSION['UID']) {
        $uid = 'You!';
    } else {
        if (isPowerUser()) {
            $uid = '<a href="/profile/' . $uid . '">' . $uid . '</a>';
        } else {
            $uid = '?';
        }
    }
    $bump = calculate_age($age, $_SERVER['REQUEST_TIME']);
    $headline = htmlspecialchars($headline);
Beispiel #8
0
     case "ST":
         //subtask
         log_list($SCION, $SCION->row);
         $record = reset($SCION->records);
         $SCION->task_id = $record["task_id"];
         $SCION->path[] = SUBTASK_DISP;
         break;
     case "AC":
         //account
         $SCION->path[] = ACCOUNT_DISP;
         break;
     case "AT":
         //activity
         if (isset($_GET["actupd"])) {
             //a direct update
             update_activity($SCION, $response);
             echo $response;
             break 3;
             //break out of here and the SCION state gate
         }
         log_list($SCION, $SCION->row);
         $record = reset($SCION->records);
         $SCION->subtask_id = $record["subtask_id"];
         $SCION->path[] = ACTIVITY_DISP;
         break;
     default:
         throw_the_bum_out(NULL, "Evicted(" . __LINE__ . "): invalid agent " . $SCION->agent, true);
 }
 $SCION->path[] = BUTTON_DISP;
 $response .= "document.getElementById('BN_" . $SCION->row . "')";
 $response .= ".innerHTML = \"<button type='button' name='btnReset' onclick='Reset()'>Cancel</button>\";\n";
      * 
      * So when we created the list of fields per each array item, 
      * each field came from an index in the Activities array.
      *
      * Now we appended the index number to each of the fields
      * in all of the forms. For example, old_activity would be
      * labelled as 'old_activity0' for element index 0.
      *
      * The index is set as the button's value, so it's stored in
      * $_POST['editBusinessActivities']. We ake the index and append
      * it to all of our fields. And we gud now.
      *
      * I'm sorry.
      */
     $i = $_POST['editBusinessActivities'];
     $result = update_activity($name, $_POST['old_activity' . $i], $_POST['old_scheduledTime' . $i], $_POST['activity' . $i], $_POST['scheduledTime' . $i], $_POST['discount' . $i], $_POST['interestType' . $i]);
     /* Commit to save changes... */
     OCICommit($db_conn);
 } else {
     if (array_key_exists('deleteBusinessActivities', $_POST)) {
         $i = $_POST['deleteBusinessActivities'];
         $result = delete_activity($name, $_POST['old_activity' . $i], $_POST['old_scheduledTime' . $i]);
         /* Commit to save changes... */
         OCICommit($db_conn);
     } else {
         if (array_key_exists('newBusinessActivity', $_POST)) {
             insert_activity($name, $_POST['activity'], $_POST['scheduledTime'], $_POST['discount'], $_POST['interestType']);
             /* Commit to save changes... */
             OCICommit($db_conn);
         }
     }
Beispiel #10
0
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
require 'includes/header.php';
force_id();
update_activity('statistics');
Output::Assign('sidebar', $sidebar);
Output::$tpl->display('dashhead.tpl.php');
$page_title = 'Statistics';
$uid = DB::Q($_SESSION['UID']);
$num_topics = DB::GetOne('SELECT count(*) FROM {P}Topics');
$num_replies = DB::GetOne('SELECT count(*) FROM {P}Replies');
$replies_per_topic = round($num_replies / $num_topics);
$num_bans = DB::GetOne('SELECT count(*) FROM {P}UIDBans');
$your_topics = DB::GetOne("SELECT count(*) FROM {P}Topics WHERE author = {$uid}");
$your_replies = DB::GetOne("SELECT count(*) FROM {P}Replies WHERE author = {$uid}");
$your_posts = $your_topics + $your_replies;
$num_ip_bans = DB::GetOne('SELECT count(*) FROM {P}IPBans');
$total_posts = $num_topics + $num_replies;
$days_since_start = floor(($_SERVER['REQUEST_TIME'] - SITE_FOUNDED) / 86400);
$posts_per_day = $days_since_start > 0 ? round($total_posts / $days_since_start) : 0;
Beispiel #11
0
<?php

require 'includes/header.php';
update_activity('date_and_time');
Output::Assign('sidebar', $sidebar);
Output::$tpl->display('dashhead.tpl.php');
$page_title = 'Date and time';
// Date and time plugin for AnotherTalk, written by Anonlolxta, Kimmo sucks
$day = date('l');
$dayn = date('jS');
$month = date('F');
$year = date('Y');
$week = date('W');
$dayz = date('z');
$dayy = 365 + date('L');
$percent = round($dayz * 100 / $dayy);
$miltime = date('G:i');
$civtime = date('g:i A');
$intform = date('Y-m-d H:i:s');
?>

<p>Today is <strong><?php 
echo $day;
?>
</strong> the <strong><?php 
echo $dayn;
?>
</strong> of <strong><?php 
echo $month;
?>
</strong> in the year <strong><?php 
Beispiel #12
0
<?php

require('includes/header.php');
//DB::ToggleDebug();
if(!isPowerUser()) 
	Output::HardError("You are not wise enough.");

Output::Assign('sidebar',$sidebar);
Output::$tpl->display('dashhead.tpl.php');

switch(Path::FetchIndex(0))
{
	case 'powerusers':
		update_activity('admins');

		if(!$User->isAdmin()) 
			Output::HardError('You are not wise enough.');

		if($_POST['form_sent'] && check_token())
		{
			//var_dump($_POST); exit;
			$lvl=$User->getMACLevel();
			if(!empty($_POST['add_sysop']))
			{
				if($lvl<999) die('No.');
				DB::Execute('UPDATE {P}UserSettings SET usrFlags=usrFlags|'.PERMISSION_SYSOP.' WHERE usrID='.DB::Q($_POST['add_sysop']));
				$_SESSION['notice'].='<li>'.$_POST['add_sysop'].' added as a '.ADMIN_NAME.'.</li>';
			}
			if(!empty($_POST['add_mod']))
			{
				if($lvl<100) die('No.');
Beispiel #13
0
<?php

require 'includes/header.php';
update_activity('history');
force_id();
if (!ctype_digit($_GET['p']) || $_GET['p'] < 2) {
    $current_page = 1;
    $page_title = 'Your latest post history';
} else {
    $current_page = $_GET['p'];
    $page_title = 'Your post history, page #' . number_format($current_page);
}
$items_per_page = ITEMS_PER_PAGE;
$start_listing_at = $items_per_page * ($current_page - 1);
/* TOPICS */
$res = DB::Execute('SELECT id, time, replies, visits, headline FROM {P}Topics WHERE author = ? ORDER BY id DESC LIMIT ?, ?', array($_SESSION['UID'], $start_listing_at, $items_per_page));
$topics = new TablePrinter('tblTopics');
$columns = array('Headline', 'Replies', 'Visits', 'Age ▼');
$topics->DefineColumns($columns, 'Headline');
$topics->SetTDClass('Headline', 'topic_headline');
while (list($topic_id, $topic_time, $topic_replies, $topic_visits, $topic_headline) = $res->FetchRow()) {
    $values = array('<a href="/topic/' . $topic_id . '">' . htmlspecialchars($topic_headline) . '</a>', replies($topic_id, $topic_replies), format_number($topic_visits), '<span class="help" title="' . format_date($topic_time) . '">' . calculate_age($topic_time) . '</span>');
    $topics->Row($values);
}
$num_topics_fetched = $topics->num_rows_fetched;
echo $topics->Output('topics');
/* REPLIES */
$res = DB::Execute('SELECT replies.id, replies.parent_id, replies.time, replies.body, topics.headline, topics.time FROM {P}Replies as replies INNER JOIN {P}Topics as topics ON replies.parent_id = topics.id WHERE replies.author = ? ORDER BY id DESC LIMIT ?, ?', array($_SESSION['UID'], $start_listing_at, $items_per_page));
$replies = new TablePrinter('tblReplies');
$columns = array('Reply snippet', 'Topic', 'Age ▼');
$replies->DefineColumns($columns, 'Topic');
Beispiel #14
0
<?php

require 'includes/header.php';
update_activity('search');
$page_title = 'Search';
$onload_javascript = 'focusId(\'phrase\'); init();';
if (!empty($_POST['phrase'])) {
    if ($_POST['deep_search']) {
        $redirect_to = DOMAIN . 'deep_search/' . urlencode($_POST['phrase']);
    } else {
        $redirect_to = DOMAIN . 'quick_search/' . urlencode($_POST['phrase']);
    }
    header('Location: ' . $redirect_to);
    exit;
}
?>

<p>The "quick" option searches only topic headlines, while the "deep" option searches both headlines and bodies.</p>

<form action="" method="post">
	<div class="row">
		<input id="phrase" name="phrase" type="text" size="80" maxlength="255" value="<?php 
echo htmlspecialchars($_GET['q']);
?>
" class="inline" />
		<input type="submit" value="Quick" class="inline" />
		<input type="submit" value="Deep" name="deep_search" class="inline" />
	</div>
</form>

<?php 
/**
 * called by cli/cron_daily.php
 */
function cron_daily() {

	while (!cron_lock()) {
		echo "Waiting for lock ...\n";
		sleep(5);
	}

	update_supporters_cache();
	revoke_not_enough_proponents();
	cancel_not_admitted();
	clear_issues();
	update_activity();

	cron_unlock();
}
Beispiel #16
0
     $body = new Template("templates/tasks/activity.edit.tmpl.php");
     $body->set('rewardmethods', $rewardmethods);
     $body->set('activitytypes', $activitytypes);
     $body->set('yesno', $yesno);
     $body->set('zoneids', $zoneids);
     $vars = activity_info();
     if ($vars) {
         foreach ($vars as $key => $value) {
             $body->set($key, $value);
         }
     }
     break;
 case 7:
     // Update activities
     check_authorization();
     update_activity();
     $tskid = $_POST['taskid'];
     header("Location: index.php?editor=tasks&tskid={$tskid}");
     exit;
 case 8:
     // Delete activity
     check_authorization();
     delete_activity();
     $tskid = $_GET['tskid'];
     header("Location: index.php?editor=tasks&tskid={$tskid}");
     exit;
 case 9:
     // Get activity ID
     check_authorization();
     $body = new Template("templates/tasks/activity.add.tmpl.php");
     $body->set('tskid', $_GET['tskid']);
Beispiel #17
0
    $res = DB::Execute($sql);
    if (!$res) {
        $page_title = 'Non-existent topic';
        add_error('There is no such topic. It may have been deleted.', true);
    }
    list($replying_to, $topic_author, $topic_replies) = $res->fields;
    update_activity('replying', $_GET['reply']);
    $page_title = 'New reply in topic: <a href="/topic/' . htmlspecialchars($_GET['reply']) . '">' . htmlspecialchars($replying_to) . '</a>';
    $n = DB::GetOne(sprintf('SELECT COUNT(*) FROM {P}Watchlists WHERE uid =\'%s\'AND topic_id = %d', $_SESSION['UID'], $_GET['reply']));
    if ($n > 0) {
        $watching_topic = true;
    }
} else {
    $reply = false;
    $onload_javascript = 'focusId(\'headline\'); init();';
    update_activity('new_topic');
    $page_title = 'New topic';
    if (!empty($_POST['headline'])) {
        $page_title .= ': ' . htmlspecialchars(Post::GetEString('headline'));
    }
}
// If we're trying to edit and it's not disabled in the configuration ...
if (ALLOW_EDIT && ctype_digit($_GET['edit'])) {
    $editing = true;
    if ($reply) {
        $sql = 'SELECT author, name, time, body, flags FROM {P}Replies WHERE id = %d';
    } else {
        $sql = 'SELECT author, name, time, body, flags, headline FROM {P}Topics WHERE id = %d';
    }
    $res = DB::Execute(sprintf($sql, $_GET['edit']));
    if ($res->RecordCount() == 0) {
Beispiel #18
0
}
// Are we on the first page?
if ($_GET['p'] < 2 || !ctype_digit($_GET['p'])) {
    $current_page = 1;
    if ($topics_mode) {
        update_activity('latest_topics');
        $page_title = 'Latest Topics';
        $last_seen = $_COOKIE['last_topic'];
    } else {
        update_activity('latest_bumps');
        $page_title = 'Latest bumps';
        $last_seen = $_COOKIE['last_bump'];
    }
} else {
    $current_page = $_GET['p'];
    update_activity('topics', $current_page);
    $page_title = 'Topics, page #' . number_format($current_page);
}
// Update the last_bump and last_topic cookies. These control
// both the last seen marker and the exclamation mark in main menu.
if ($_COOKIE['last_bump'] <= $last_actions['last_bump']) {
    setcookie('last_bump', $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'] + 315569260, '/');
}
if ($_COOKIE['last_topic'] <= $last_actions['last_topic']) {
    setcookie('last_topic', $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'] + 315569260, '/');
}
// If ostrich mode is enabled, fetch a list of blacklisted phrases.
$ignored_phrases = fetch_ignore_list();
// Fetch the {P}Topics appropriate to this page.
$items_per_page = ITEMS_PER_PAGE;
$start_listing_at = $items_per_page * ($current_page - 1);
Beispiel #19
0
<?php

require 'includes/header.php';
update_activity('back_up_id');
Output::Assign('sidebar', $sidebar);
Output::$tpl->fetch('dashhead.tpl.php');
force_id();
$page_title = 'Back up ID';
if ($_GET['action'] === 'generate_id_card') {
    header('Content-type: text/plain');
    header('Content-Disposition: attachment; filename="ATBBS_ID.crd"');
    echo $_SESSION['UID'] . "\n" . $_COOKIE['Password'];
    exit;
} else {
    ?>

	<table>
		<tr>
			<th class="minimal">Your unique ID</th>
			<td><code><?php 
    echo $User->ID;
    ?>
</code></td>
		</tr>
		<tr>
			<th class="minimal">Your password</th>
			<td><code><?php 
    echo $_COOKIE['Password'];
    ?>
</code></td>
		</tr>
Beispiel #20
0
<?php

require 'includes/header.php';
// Validate / fetch topic info.
if (!ctype_digit($_GET['id'])) {
    add_error('Invalid ID.', true);
}
$topic = new Topic(intval($_GET['id']));
$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;
Beispiel #21
0
<?php

require 'includes/header.php';
force_id();
update_activity('watchlist');
$page_title = 'Your watchlist';
if (is_array($_POST['rejects'])) {
    $sql = 'DELETE FROM watchlists WHERE ';
    $i = 0;
    foreach ($_POST['rejects'] as $reject_id) {
        if ($i > 0) {
            $sql .= ' OR ';
        }
        $sql .= '(uid = \'' . $User->UID . '\' AND topic_id = ' . intval($reject_id) . ')';
    }
    DB::Execute($sql);
    $_SESSION['notice'] = 'Selected topics unwatched.';
}
echo '<form name="fuck_off" action="" method="post">';
$topics = new TablePrinter('watchlist');
$topic_column = '<script type="text/javascript"> document.write(\'<input type="checkbox" name="master_checkbox" class="inline" onclick="checkOrUncheckAllCheckboxes()" title="Check/uncheck all" /> \');</script>Topic';
$columns = array($topic_column, 'Replies', 'Visits', 'Age', 'Last Post');
$db_columns = array('t.headline', 't.replies', 't.visits', 't.time', 'last_post');
$topics->DefaultSorting('last_post', SORT_DESC, $db_columns);
$topics->DefineColumns($columns, $topic_column);
$topics->SetTDClass($topic_column, 'topic_headline');
DB::ToggleDebug();
$res = DB::Execute('SELECT w.topic_id, t.headline, t.replies, t.visits, t.time, last_post FROM {P}Watchlists as w INNER JOIN {P}Topics as t ON w.topic_id = t.id WHERE w.uid = \'' . $User->ID . '\' ' . $topics->GetOrderSQL());
DB::ToggleDebug();
while (list($topic_id, $topic_headline, $topic_replies, $topic_visits, $topic_time, $last_post) = $res->FetchRow()) {
    $values = array('<input type="checkbox" name="rejects[]" value="' . $topic_id . '" class="inline" /> <a href="/topic/' . $topic_id . '">' . htmlspecialchars($topic_headline) . '</a>', replies($topic_id, $topic_replies), format_number($topic_visits), '<span class="help" title="' . format_date($topic_time) . '">' . calculate_age($topic_time) . '</span>', '<span class="help" title="' . format_date($last_post) . '">' . calculate_age($last_post) . '</span>');
Beispiel #22
0
<?php

require 'includes/header.php';
if (!ctype_digit($_GET['id'])) {
    add_error('Invalid ID.', true);
}
$stmt = DB::Prepare('SELECT headline, visits, replies, author FROM {P}Topics WHERE id = ?');
$stmt = DB::Execute($stmt, array($_GET['id']));
if ($stmt->RecordCount() < 1) {
    $page_title = 'Non-existent topic';
    add_error('There is no such topic. It may have been deleted.', true);
}
list($topic_headline, $topic_visits, $topic_replies, $topic_author) = $stmt->FetchRow();
update_activity('topic_trivia', $_GET['id']);
$page_title = 'Trivia for topic: <a href="/topic/' . $_GET['id'] . '">' . htmlspecialchars($topic_headline) . '</a>';
$statistics = array();
$topic_watchers = DB::GetOne("SELECT count(*) FROM {P}Watchlists WHERE topic_id = " . DB::Q($_GET['id']));
$topic_readers = DB::GetOne("SELECT count(*) FROM {P}Activity WHERE action_name = 'topic' AND action_id = " . DB::Q($_GET['id']));
$topic_writers = DB::GetOne("SELECT count(*) FROM {P}Activity WHERE action_name = 'replying' AND action_id = " . DB::Q($_GET['id']));
$topic_participants = DB::GetOne("SELECT count(DISTINCT author) FROM {P}Replies WHERE parent_id = " . DB::Q($_GET['id']) . " AND author != " . DB::Q($topic_author));
// Alternatively, we could select the most recent poster_number. I'm not sure which method would be fastest.
?>

<table>
	<tr>
		<th class="minimal">Total visits</th>
		<td><?php 
echo format_number($topic_visits);
?>
</td>
	</tr>
Beispiel #23
0
<?php

require 'includes/header.php';
// Check if we're on a specific page.
if (!ctype_digit($_GET['p']) || $_GET['p'] < 2) {
    $current_page = 1;
    $page_title = 'Latest replies';
    update_activity('latest_replies');
} else {
    $current_page = $_GET['p'];
    $page_title = 'Replies, page #' . number_format($current_page);
    update_activity('replies', $current_page);
}
// Print out the appropriate replies.
$items_per_page = ITEMS_PER_PAGE;
$start_listing_replies_at = $items_per_page * ($current_page - 1);
$sql = 'SELECT {P}Replies.id, {P}Replies.parent_id, {P}Replies.time, {P}Replies.body, {P}Topics.headline, {P}Topics.time FROM {P}Replies INNER JOIN {P}Topics ON {P}Replies.parent_id = {P}Topics.id ORDER BY id DESC LIMIT %d, %d';
$sql = sprintf($sql, $start_listing_replies_at, $items_per_page);
$res = DB::Execute($sql);
$replies = new TablePrinter('tblReplies');
$columns = array('Snippet', 'Topic', 'Age ▼');
$replies->DefineColumns($columns, 'Topic');
$replies->SetTDClass('Topic', 'topic_headline');
$replies->SetTDClass('Snippet', 'snippet');
if ($res) {
    while (list($reply_id, $parent_id, $reply_time, $reply_body, $topic_headline, $topic_time) = $res->FetchRow()) {
        $values = array('<a href="/topic/' . $parent_id . '#reply_' . $reply_id . '">' . snippet($reply_body) . '</a>', '<a href="/topic/' . $parent_id . '">' . htmlspecialchars($topic_headline) . '</a> <span class="help unimportant" title="' . format_date($topic_time) . '">(' . calculate_age($topic_time) . ' old)</span>', '<span class="help" title="' . format_date($reply_time) . '">' . calculate_age($reply_time) . '</span>');
        $replies->Row($values);
    }
}
$num_replies_fetched = $replies->num_rows_fetched;