function User($id = false) { if (!$id) { global $moderators, $administrators, $moderator, $administrator; if (!empty($_COOKIE['password'])) { $p = $_COOKIE['password']; DeleteCookie('password'); CreateCookie('Password', $p); } if (empty($_COOKIE['UID'])) { $this->CreateID(); $this->ID = $_SESSION['UID']; $this->Password = $_SESSION['Password']; } else { if (!empty($_COOKIE['Password'])) { // Log in those who have just began their session. if (!isset($_SESSION['IDActivated'])) { $this->Activate(); } $this->ID = $_SESSION['UID']; $this->Password = $_SESSION['Password']; $this->Load(); // ...and check for mod/admin privileges from the cache. if (is_array($moderators) && (!$this->isMod() || !$this->isAdmin())) { if (in_array($_SESSION['UID'], $moderators)) { $this->Flags |= PERMISSION_MOD; } else { if (in_array($_SESSION['UID'], $administrators)) { $this->Flags |= PERMISSION_SYSOP; } } $this->Save(); } if (ROOT_ADMIN == $_SESSION['UID']) { $this->Flags |= PERMISSION_SYSOP; } $_SESSION['Flags'] = 0; } } $this->ID = $_SESSION['UID']; $this->Password = $_SESSION['Password']; $this->LoadReadTopics(); $this->Level = $this->isAdmin() ? ADMIN_NAME : ($this->isMod() ? 'Moderator' : 'User'); $this->IgnoreList = fetch_ignore_list(); $this->LoadActions(); } else { $this->ID = $id; $this->Load(); } }
} } 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); if ($topics_mode) { $sql = "SELECT id, time, replies, visits, headline, body, last_post FROM {P}Topics ORDER BY id DESC LIMIT {$start_listing_at}, {$items_per_page}"; } else { $sql = "SELECT id, time, replies, visits, headline, body, last_post FROM {P}Topics ORDER BY last_post DESC LIMIT {$start_listing_at}, {$items_per_page}"; } $res = DB::Execute($sql); //$stmt->bind_result($topic_id, $topic_time, $topic_replies, $topic_visits, $topic_headline, $topic_body, $topic_last_post); // Print the {P}Topics we just fetched in a table. $table = new TablePrinter('tblBumps'); $order_name = $topics_mode ? 'Age' : 'Last bump'; $columns = array('Headline', 'Snippet', 'Replies', 'Visits', $order_name . ' ▼'); if ($_COOKIE['spoiler_mode'] != 1) {