/** * Assign the details for the attention object * * @param bool $return True to return the data, false to display it */ public function assign_details($return = false) { $output = array('ATTENTION_ID' => $this->attention_id, 'ATTENTION_TYPE' => $this->attention_type, 'ATTENTION_TIME' => phpbb::$user->format_date($this->attention_time), 'ATTENTION_POST_TIME' => phpbb::$user->format_date($this->attention_post_time), 'ATTENTION_CLOSE_TIME' => $this->attention_close_time ? phpbb::$user->format_date($this->attention_close_time) : '', 'ATTENTION_TITLE' => $this->attention_title, 'ATTENTION_REASON' => $this->get_reason_string(), 'ATTENTION_DESCRIPTION' => $this->attention_description, 'U_VIEW_ATTENTION' => $this->get_url(), 'U_VIEW_DETAILS' => titania_url::append_url(titania_url::$current_page_url, array('a' => $this->attention_id)), 'S_CLOSED' => $this->attention_close_time ? true : false, 'S_UNAPPROVED' => $this->attention_type == TITANIA_ATTENTION_UNAPPROVED ? true : false, 'S_REPORTED' => $this->attention_type == TITANIA_ATTENTION_REPORTED ? true : false); if ($return) { return $output; } phpbb::$template->assign_vars($output); }
function run_tool() { $section = request_var('section', 0); $start = request_var('start', 0); $limit = titania::$config->search_backend == 'solr' ? 1000 : 100; $total = 0; $sync = new titania_sync(); switch ($section) { case 0: titania_search::truncate(); $display_message = 'Truncating Search'; break; case 1: $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE; phpbb::$db->sql_query($sql); $total = phpbb::$db->sql_fetchfield('cnt'); phpbb::$db->sql_freeresult(); $sync->contribs('index', false, $start, $limit); $display_message = 'Indexing Contributions'; break; case 2: $sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE; phpbb::$db->sql_query($sql); $total = phpbb::$db->sql_fetchfield('cnt'); phpbb::$db->sql_freeresult(); $sync->posts('index', $start, $limit); $display_message = 'Indexing Posts'; break; case 3: $sql = 'SELECT COUNT(faq_id) AS cnt FROM ' . TITANIA_CONTRIB_FAQ_TABLE; phpbb::$db->sql_query($sql); $total = phpbb::$db->sql_fetchfield('cnt'); phpbb::$db->sql_freeresult(); $sync->faqs('index', $start, $limit); $display_message = 'Indexing FAQ'; break; case 4: trigger_back('Done!'); break; } if ($start + $limit >= $total) { // Move to the next step meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'reindex', 'section' => $section + 1, 'submit' => 1, 'hash' => generate_link_hash('manage')))); } else { // Move to the next step meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'reindex', 'section' => $section, 'start' => $start + $limit, 'submit' => 1, 'hash' => generate_link_hash('manage')))); } trigger_error($display_message . ' - section ' . $section . ' of 3 - ' . ($start + $limit < $total ? 'part ' . ($start + $limit) . ' of ' . $total : 'Done')); }
/** * Shorten the amount of code required for some places * * @param mixed $object_type * @param mixed $object_id * @param mixed $url */ public static function handle_subscriptions($object_type, $object_id, $url) { if (!phpbb::$user->data['is_registered']) { // Cannot currently handle non-registered users return; } $subscribe = request_var('subscribe', ''); if ($subscribe == 'subscribe' && check_link_hash(request_var('hash', ''), 'subscribe')) { titania_subscriptions::subscribe($object_type, $object_id); } else { if ($subscribe == 'unsubscribe' && check_link_hash(request_var('hash', ''), 'unsubscribe')) { titania_subscriptions::unsubscribe($object_type, $object_id); } } if (titania_subscriptions::is_subscribed($object_type, $object_id)) { phpbb::$template->assign_vars(array('IS_SUBSCRIBED' => true, 'U_SUBSCRIBE' => titania_url::append_url($url, array('subscribe' => 'unsubscribe', 'hash' => generate_link_hash('unsubscribe'))))); } else { phpbb::$template->assign_vars(array('U_SUBSCRIBE' => titania_url::append_url($url, array('subscribe' => 'subscribe', 'hash' => generate_link_hash('subscribe'))))); } }
function main($id, $mode) { global $phpbb_root_path; define('PHPBB_INCLUDED', true); define('USE_PHPBB_TEMPLATE', true); define('IN_TITANIA', true); if (!defined('PHP_EXT')) { define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); } require TITANIA_ROOT . 'common.' . PHP_EXT; // Need a few hacks to be used from within phpBB titania_url::decode_url(titania::$config->phpbb_script_path); titania::$hook->register(array('titania_url', 'build_url'), 'titania_outside_build_url', 'standalone'); titania::$hook->register(array('titania_url', 'append_url'), 'titania_outside_build_url', 'standalone'); titania::$hook->register(array('titania', 'page_header'), 'titania_outside_page_header', 'standalone'); titania::$hook->register(array('titania', 'page_footer'), 'titania_outside_page_footer', 'standalone'); titania::$hook->register('titania_generate_text_for_display', 'titania_outside_generate_text_for_display', 'standalone'); titania::add_lang('manage'); $this->p_master->assign_tpl_vars(phpbb::append_sid('mcp')); phpbb::$template->assign_vars(array('L_TITLE' => phpbb::$user->lang['ATTENTION'], 'L_EXPLAIN' => '')); include TITANIA_ROOT . 'manage/attention.' . PHP_EXT; }
if (!$thumbnail) { // Update download count $sql = 'UPDATE ' . TITANIA_ATTACHMENTS_TABLE . ' SET download_count = download_count + 1 WHERE attachment_id = ' . $attachment['attachment_id']; phpbb::$db->sql_query($sql); // Update download count for the contrib object as well if ($attachment['object_type'] == TITANIA_CONTRIB) { $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . ' SET contrib_downloads = contrib_downloads + 1 WHERE contrib_id = ' . $attachment['object_id']; phpbb::$db->sql_query($sql); } } if (!$thumbnail && $mode === 'view' && strpos($attachment['mimetype'], 'image') === 0 && (strpos(strtolower(phpbb::$user->browser), 'msie') !== false && strpos(strtolower(phpbb::$user->browser), 'msie 8.0') === false)) { wrap_img_in_html(titania_url::build_url('download', array('id' => $attachment['attachment_id'])), $attachment['real_filename']); file_gc(); } else { send_file_to_browser($attachment, titania::$config->upload_path); file_gc(); } /** * Wraps an url into a simple html page. Used to display attachments in IE. * this is a workaround for now; might be moved to template system later * direct any complaints to 1 Microsoft Way, Redmond */ function wrap_img_in_html($src, $title) { echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">'; echo '<html>'; echo '<head>';
if (sizeof($authed) == 1) { $queue_type = $authed[0]; } else { foreach ($authed as $type_id) { $sql = 'SELECT COUNT(topic_id) AS cnt FROM ' . TITANIA_TOPICS_TABLE . ' WHERE topic_type = ' . TITANIA_QUEUE_DISCUSSION . ' AND topic_category = ' . (int) $type_id; phpbb::$db->sql_query($sql); $cnt = phpbb::$db->sql_fetchfield('cnt'); phpbb::$db->sql_freeresult(); phpbb::$template->assign_block_vars('categories', array('U_VIEW_CATEGORY' => titania_url::append_url($base_url, array('queue' => titania_types::$types[$type_id]->url)), 'CATEGORY_NAME' => titania_types::$types[$type_id]->lang, 'CATEGORY_CONTRIBS' => $cnt)); } phpbb::$template->assign_vars(array('S_QUEUE_LIST' => true)); titania::page_header('QUEUE_DISCUSSION'); titania::page_footer(true, 'manage/queue.html'); } } } else { if (!titania_types::$types[$queue_type]->acl_get('queue_discussion')) { titania::needs_auth(); } } // Add the queue type to the base url $base_url = titania_url::append_url($base_url, array('queue' => titania_types::$types[$queue_type]->url)); // Add to Breadcrumbs titania::generate_breadcrumbs(array(titania_types::$types[$queue_type]->lang => $base_url)); topics_overlord::display_forums_complete('queue_discussion', false, array('topic_category' => $queue_type)); // Mark all topics read phpbb::$template->assign_var('U_MARK_TOPICS', titania_url::append_url($base_url, array('mark' => 'topics'))); titania::page_header('QUEUE_DISCUSSION'); titania::page_footer(true, 'manage/queue_discussion.html');
/** * Get profile url * * @param string $page The page we are on (Ex: faq/support/details) * * @return string */ public function get_url($page = '') { if ($page) { return titania_url::build_url(users_overlord::get_user($this->user_id, '_unbuilt_titania_profile') . '/' . $page); } return users_overlord::get_user($this->user_id, '_titania_profile'); }
if (users_overlord::get_user($row['user_id'], 'user_id') != $row['user_id']) { continue; } if ($row['active']) { $active_coauthors[] = users_overlord::get_user($row['user_id'], 'username'); } else { $nonactive_coauthors[] = users_overlord::get_user($row['user_id'], 'username'); } } $active_coauthors = implode("\n", $active_coauthors); $nonactive_coauthors = implode("\n", $nonactive_coauthors); } } // Generate some stuff generate_category_select($contrib_categories); titania::$contrib->assign_details(); $message->display(); foreach ($status_list as $status => $row) { phpbb::$template->assign_block_vars('status_select', array('S_SELECTED' => $status == titania::$contrib->contrib_status ? true : false, 'VALUE' => $status, 'NAME' => phpbb::$user->lang[$row])); } // ColorizeIt if (strlen(titania::$config->colorizeit) && titania_types::$types[titania::$contrib->contrib_type]->acl_get('colorizeit')) { $clr_testsample = ''; if (titania::$contrib->has_colorizeit(true) || is_array(titania::$contrib->clr_sample)) { $clr_testsample = 'http://' . titania::$config->colorizeit_url . '/testsample.html?sub=' . titania::$config->colorizeit . '&sample=' . urlencode(titania_url::build_url('download', array('id' => titania::$contrib->clr_sample['attachment_id']))); } phpbb::$template->assign_vars(array('MANAGE_COLORIZEIT' => titania::$config->colorizeit, 'CLR_SCREENSHOTS' => $clr_sample->parse_uploader('posting/attachments/simple.html'), 'CLR_COLORS' => htmlspecialchars(titania::$contrib->contrib_clr_colors), 'U_TESTSAMPLE' => $clr_testsample)); } phpbb::$template->assign_vars(array('S_POST_ACTION' => titania::$contrib->get_url('manage'), 'S_EDIT_SUBJECT' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate') ? true : false, 'S_DELETE_CONTRIBUTION' => phpbb::$auth->acl_get('u_titania_admin') ? true : false, 'S_IS_OWNER' => titania::$contrib->is_author ? true : false, 'S_IS_MODERATOR' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate') ? true : false, 'S_CAN_EDIT_STYLE_DEMO' => titania::$config->can_modify_style_demo_url || titania_types::$types[TITANIA_TYPE_STYLE]->acl_get('moderate') || titania::$contrib->contrib_type != TITANIA_TYPE_STYLE ? true : false, 'S_CAN_EDIT_CONTRIB' => phpbb::$auth->acl_get('u_titania_contrib_submit') ? true : false, 'CONTRIB_PERMALINK' => $permalink, 'SCREENSHOT_UPLOADER' => phpbb::$auth->acl_get('u_titania_contrib_submit') ? $screenshot->parse_uploader('posting/attachments/simple.html') : false, 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $active_coauthors, 'NONACTIVE_COAUTHORS' => $nonactive_coauthors, 'S_TRANSLATION_TYPE_ID' => defined('TITANIA_TYPE_TRANSLATION') ? TITANIA_TYPE_TRANSLATION : 0)); titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['MANAGE_CONTRIBUTION']); titania::page_footer(true, 'contributions/contribution_manage.html');
/** * Download URL */ public function get_url() { return titania_url::build_url('download', array('id' => $this->attachment_id)); }
/** * Assign details * * A little different from those in other classes, this one only returns the info ready for output */ public function assign_details($output_text = true) { $details = array('POST_ID' => $this->post_id, 'TOPIC_ID' => $this->topic_id, 'POST_TYPE' => $this->post_type, 'POST_ACCESS' => $this->post_access, 'POST_LOCKED' => $this->post_locked, 'POST_ATTACHMENT' => $this->post_attachment, 'POST_USER_ID' => $this->post_user_id, 'POST_IP' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_ip : false, 'POST_TIME' => phpbb::$user->format_date($this->post_time), 'POST_EDIT_REASON' => censor_text($this->post_edit_reason), 'POST_SUBJECT' => censor_text($this->post_subject), 'POST_TEXT' => $output_text ? $this->generate_text_for_display() : '', 'EDITED_MESSAGE' => $this->post_edited ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], users_overlord::get_user($this->post_edit_user, '_full'), phpbb::$user->format_date($this->post_edited)) : '', 'DELETED_MESSAGE' => $this->post_deleted != 0 ? sprintf(phpbb::$user->lang['DELETED_MESSAGE'], users_overlord::get_user($this->post_delete_user, '_full'), phpbb::$user->format_date($this->post_deleted), $this->get_url('undelete')) : '', 'U_VIEW' => $this->get_url(), 'U_EDIT' => $this->acl_get('edit') ? $this->get_url('edit') : '', 'U_QUICKEDIT' => $this->acl_get('edit') ? $this->get_url('quick_edit') : '', 'U_DELETE' => $this->acl_get('delete') && (!$this->post_deleted || phpbb::$auth->acl_get('u_titania_post_hard_delete')) ? $this->get_url('delete') : '', 'U_REPORT' => phpbb::$user->data['is_registered'] ? $this->get_url('report') : '', 'U_WARN' => false, 'U_INFO' => phpbb::$auth->acl_gets('u_titania_mod_author_mod', 'u_titania_mod_contrib_mod', 'u_titania_mod_faq_mod', 'u_titania_mod_post_mod') || sizeof(titania_types::find_authed('moderate')) ? titania_url::build_url('manage/attention', array('type' => TITANIA_POST, 'id' => $this->post_id)) : '', 'U_QUOTE' => $this->acl_get('post') ? $this->get_url('quote') : '', 'S_UNREAD_POST' => $this->unread ? true : false, 'S_POST_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_approved : true, 'S_POST_REPORTED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_reported : false, 'S_POST_DELETED' => $this->post_deleted != 0 ? true : false, 'S_ACCESS_TEAMS' => $this->post_access == TITANIA_ACCESS_TEAMS ? true : false, 'S_ACCESS_AUTHORS' => $this->post_access == TITANIA_ACCESS_AUTHORS ? true : false); // Hooks titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $details, $this); return $details; }
/** * Get rating string * * @return string The rating string ready for output */ public function get_rating_string() { $can_rate = !$this->cannot_rate && phpbb::$user->data['is_registered'] && phpbb::$auth->acl_get('u_titania_rate') && !$this->rating_id ? true : false; $rate_url = titania_url::build_url('rate', array('type' => $this->rating_type, 'id' => $this->rating_object_id)); // If it has not had any ratings yet, give it 1/2 the max for the rating if ($this->rating_count == 0) { $this->rating = round(titania::$config->max_rating / 2, 1); } phpbb::$template->set_filenames(array('rate' => 'common/rate.html')); phpbb::$template->assign_vars(array('OBJECT_ID' => $this->rating_object_id, 'OBJECT_RATING' => round($this->rating), 'RATE_URL' => $rate_url, 'S_HAS_RATED' => $this->rating_id ? true : false, 'S_CAN_RATE' => $can_rate, 'UA_GREY_STAR_SRC' => titania::$theme_path . '/images/star_grey.gif', 'UA_GREEN_STAR_SRC' => titania::$theme_path . '/images/star_green.gif', 'UA_RED_STAR_SRC' => titania::$theme_path . '/images/star_red.gif', 'UA_ORANGE_STAR_SRC' => titania::$theme_path . '/images/star_orange.gif', 'UA_REMOVE_STAR_SRC' => titania::$theme_path . '/images/star_remove.gif', 'UA_MAX_RATING' => titania::$config->max_rating)); // reset the stars block phpbb::$template->destroy_block_vars('stars'); for ($i = 1; $i <= titania::$config->max_rating; $i++) { $rating = !$can_rate ? $this->rating : ($this->rating_value ? $this->rating_value : $i); phpbb::$template->assign_block_vars('stars', array('ALT' => $rating . '/' . titania::$config->max_rating, 'ID' => $i, 'RATE_URL' => titania_url::append_url($rate_url, array('value' => $i)))); } return phpbb::$template->assign_display('rate', '', true); }
/** * Build the left "tool" navigation for every page * This is based upon the active tool */ function gen_left_nav() { global $template, $user; // Grep the correct category $tool_list = $this->plugin_list; // Run through the tools and collect all info we need $tpl_data = array(); foreach ($tool_list as $tool) { $class = $this->load_tool($tool); // Can this tool be used? if (method_exists($class, 'tool_active')) { if ($class->tool_active() !== true) { continue; } } // Get the info if (method_exists($class, 'info')) { $info = $class->info(); } else { // For us lazy people $info = array('NAME' => isset($user->lang[strtoupper($tool)]) ? $user->lang[strtoupper($tool)] : strtoupper($tool)); } $tpl_data[$tool] = $info['NAME']; } // Sort the data based on the tool name. This way we'll keep the menu sorted correctly for translations asort($tpl_data); // Now go ahead and build the template foreach ($tpl_data as $tool => $name) { $_s_active = $tool == $this->tool_id ? true : false; // Assign to the template $template->assign_block_vars('tools', array('L_TITLE' => $name, 'TOOL' => $tool, 'S_SELECTED' => $_s_active, 'U_TITLE' => titania_url::build_url('manage/administration', array('t' => $tool)))); } }
$new_tag = request_var('id', 0); if (!isset($tags[$new_tag])) { trigger_error('NO_TAG'); } $queue->move($new_tag); } else { // Generate the list of tags we can move it to $extra = '<select name="id">'; foreach ($tags as $tag_id => $row) { $extra .= '<option value="' . $tag_id . '">' . (isset(phpbb::$user->lang[$row['tag_field_name']]) ? phpbb::$user->lang[$row['tag_field_name']] : $row['tag_field_name']) . '</option>'; } $extra .= '</select>'; phpbb::$template->assign_var('CONFIRM_EXTRA', $extra); titania::confirm_box(false, 'MOVE_QUEUE'); } redirect(titania_url::append_url($base_url, array('q' => $queue->queue_id))); break; } // Display the main queue item $data = queue_overlord::display_queue_item($queue_id); // Handle replying/editing/etc $posting_helper = new titania_posting(); $posting_helper->act('manage/queue_post.html'); // Display the posts in the queue (after the posting helper acts) posts_overlord::display_topic_complete($data['topic']); titania::page_header(queue_overlord::$queue[$queue_id]['topic_subject']); } else { // Subscriptions titania_subscriptions::handle_subscriptions(TITANIA_QUEUE, $queue_type, titania_url::$current_page_url); queue_overlord::display_queue($queue_type, $tag); queue_overlord::display_categories($queue_type, $tag);
/** * Display "forum" like section for support/tracker/etc * * @param string $type The type (support, review, queue, tracker, author_support, author_tracker) author_ for displaying posts from the areas the given author is involved in (either an author/co-author) * @param object|boolean $object The object (for contrib related (support, review, queue, tracker) and author_ modes) * @param object|boolean $sort The sort object (includes/tools/sort.php) * @param array $options Some special options * @param string $contrib_type The type of the support topic list */ public static function display_forums($type, $object = false, $sort = false, $options = array()) { if ($sort === false) { // Setup the sort tool $sort = self::build_sort(); } $sort->request(); $topic_ids = array(); $switch_on_sticky = true; // Display the extra block after stickies end? Not used when not sorting with stickies first $sql_ary = array('SELECT' => 't.*, u.username as topic_first_post_username, u.user_colour as topic_first_post_user_colour, ul.username as topic_last_post_username, ul.user_colour as topic_last_post_user_colour', 'FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'WHERE' => self::sql_permissions('t.', false, true), 'ORDER_BY' => 't.topic_sticky DESC, ' . $sort->get_order_by()); $sql_ary['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 't.topic_first_post_user_id = u.user_id'); $sql_ary['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'ul'), 'ON' => 't.topic_last_post_user_id = ul.user_id'); titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id'); // Setup the contribution/topic we will use for parsing the output (before the switch so we are able to do type specific things for it) $topic = new titania_topic(); $contrib = new titania_contribution(); // type specific things switch ($type) { case 'tracker': $page_url = $object->get_url('tracker'); $sql_ary['WHERE'] .= ' AND t.parent_id = ' . (int) $object->contrib_id; $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_TRACKER; if (isset($options['category'])) { $sql_ary['WHERE'] .= ' AND t.topic_category = ' . (int) $options['category']; } break; case 'queue': $page_url = titania_url::build_url('manage/queue'); $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_QUEUE; break; case 'queue_discussion': $page_url = titania_url::build_url('manage/queue_discussion', array('queue' => titania_types::$types[$options['topic_category']]->url)); $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_QUEUE_DISCUSSION; // Only display those in which the users are authed $authed = titania_types::find_authed('queue_discussion'); if (!sizeof($authed)) { return compact('sort'); } if (isset($options['topic_category'])) { if (!in_array((int) $options['topic_category'], $authed)) { return compact('sort'); } $sql_ary['WHERE'] .= ' AND t.topic_category = ' . (int) $options['topic_category']; } else { $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.topic_category', $authed); } // Additional tracking for all queue discussion topics titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true); // Additional tracking for marking items as read in each contribution titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tst'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true); break; case 'author_support': $page_url = $object->get_url('support'); $contrib_ids = titania::$cache->get_author_contribs($object->user_id, true); $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.parent_id', array_map('intval', $contrib_ids)); // We also display the queue discussion topic between validators and authors in the support area $sql_ary['WHERE'] .= ' AND (t.topic_type = ' . TITANIA_SUPPORT . ' OR t.topic_type = ' . TITANIA_QUEUE_DISCUSSION . ')'; // Additional tracking for marking items as read in each contribution titania_tracking::get_tracks(TITANIA_SUPPORT, $contrib_ids); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true); // Additional tracking for all support topics titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0, 'type_match' => true); // Track the queue discussion too if applicable if (titania_types::find_authed('queue_discussion')) { titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true); } // Try to grab the category/contrib name $sql_ary['SELECT'] .= ', contrib.contrib_name, contrib.contrib_name_clean, contrib.contrib_id, contrib.contrib_type'; $sql_ary['LEFT_JOIN'] = array_merge(isset($sql_ary['LEFT_JOIN']) ? $sql_ary['LEFT_JOIN'] : array(), array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'contrib'), 'ON' => 'contrib.contrib_id = t.parent_id'))); // Do not order stickies first $sql_ary['ORDER_BY'] = $sort->get_order_by(); $switch_on_sticky = false; break; case 'author_tracker': $page_url = $object->get_url('tracker'); $contrib_ids = titania::$cache->get_author_contribs($object->user_id); $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.parent_id', array_map('intval', $contrib_ids)); $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_TRACKER; break; case 'all_support': // Try to grab the category/contrib name $sql_ary['SELECT'] .= ', contrib.contrib_name, contrib.contrib_name_clean, contrib.contrib_id, contrib.contrib_type'; $sql_ary['LEFT_JOIN'] = array_merge(isset($sql_ary['LEFT_JOIN']) ? $sql_ary['LEFT_JOIN'] : array(), array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'contrib'), 'ON' => 'contrib.contrib_id = t.parent_id'))); if (isset(titania_types::$types[$options['contrib_type']])) { $page_url = titania_url::build_url('support/' . titania_types::$types[$options['contrib_type']]->url); $sql_ary['WHERE'] .= ' AND contrib.contrib_type = ' . $options['contrib_type']; } else { $page_url = titania_url::build_url('support/all'); } // Additional tracking field (to allow marking all support/discussion as read) $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_SUPPORT; // Additional tracking for all support topics titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0); // Do not order stickies first $sql_ary['ORDER_BY'] = $sort->get_order_by(); $switch_on_sticky = false; break; case 'support': default: $page_url = $object->get_url('support'); $sql_ary['WHERE'] .= ' AND t.parent_id = ' . (int) $object->contrib_id; // We also display the queue discussion topic between validators and authors in the support area if ($object->is_author || $object->is_active_coauthor || titania_types::$types[$object->contrib_type]->acl_get('queue_discussion')) { $sql_ary['WHERE'] .= ' AND (t.topic_type = ' . TITANIA_SUPPORT . ' OR t.topic_type = ' . TITANIA_QUEUE_DISCUSSION . ')'; } else { $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_SUPPORT; } // Additional tracking for marking items as read in each contribution titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, $object->contrib_id, 'tst'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true); // Additional tracking for all support topics titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg'); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0); // Track the queue discussion too if applicable if (titania_types::$types[$object->contrib_type]->acl_get('queue_discussion')) { titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true); } break; } // Main SQL Query $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); // Handle pagination if (!$sort->sql_count($sql_ary, 't.topic_id')) { // No results...no need to query more... return compact('sort'); } $sort->build_pagination($page_url); $last_was_sticky = false; // Get the data $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start); while ($row = phpbb::$db->sql_fetchrow($result)) { // Store the tracking info we grabbed from the DB titania_tracking::store_from_db($row); self::$topics[$row['topic_id']] = $row; $topic->__set_array($row); $contrib->__set_array($row); phpbb::$template->assign_block_vars('topics', array_merge($topic->assign_details(), array('S_TOPIC_TYPE_SWITCH' => $switch_on_sticky && $last_was_sticky && !$topic->topic_sticky ? true : false, 'CONTRIB_TYPE' => isset($row['contrib_type']) && $row['contrib_type'] ? titania_types::$types[$row['contrib_type']]->lang : '', 'TOPIC_CONTRIB_NAME' => isset($row['contrib_name']) && $row['contrib_name'] ? censor_text($row['contrib_name']) : '', 'U_VIEW_TOPIC_CONTRIB' => isset($row['contrib_type']) && $row['contrib_type'] ? $contrib->get_url() : '', 'U_VIEW_TOPIC_CONTRIB_SUPPORT' => isset($row['contrib_type']) && $row['contrib_type'] ? $contrib->get_url('support') : ''))); $last_was_sticky = $topic->topic_sticky; } phpbb::$db->sql_freeresult($result); unset($topic); return compact('sort'); }
$attention_count = phpbb::$db->sql_fetchfield('cnt'); phpbb::$db->sql_freeresult(); /** * Menu Array * * 'filename' => array( * 'title' => 'nav menu title', * 'url' => $page_url, * 'auth' => ($can_see_page) ? true : false, // Not required, always true if missing * ), */ $nav_ary = array('attention' => array('title' => 'ATTENTION', 'url' => titania_url::build_url('manage/attention'), 'auth' => !phpbb::$auth->acl_gets('u_titania_mod_author_mod', 'u_titania_mod_contrib_mod', 'u_titania_mod_faq_mod', 'u_titania_mod_post_mod') && !sizeof(titania_types::find_authed('moderate')) ? false : true, 'count' => $attention_count), 'queue' => array('title' => 'VALIDATION_QUEUE', 'url' => titania_url::build_url('manage/queue'), 'auth' => sizeof(titania_types::find_authed('view')) && titania::$config->use_queue ? true : false), 'queue_discussion' => array('title' => 'QUEUE_DISCUSSION', 'url' => titania_url::build_url('manage/queue_discussion'), 'auth' => sizeof(titania_types::find_authed('queue_discussion')) && titania::$config->use_queue ? true : false), 'administration' => array('title' => 'ADMINISTRATION', 'url' => titania_url::build_url('manage/administration'), 'auth' => phpbb::$auth->acl_get('u_titania_admin') ? true : false, 'match' => array('categories')), 'categories' => array('title' => 'MANAGE_CATEGORIES', 'url' => titania_url::build_url('manage/categories'), 'auth' => phpbb::$auth->acl_get('u_titania_admin') ? true : false, 'display' => false)); // Display nav menu titania::generate_nav($nav_ary, $page, 'attention'); // Generate the main breadcrumbs titania::generate_breadcrumbs(array(phpbb::$user->lang['MANAGE'] => titania_url::build_url('manage'))); if ($page) { titania::generate_breadcrumbs(array($nav_ary[$page]['title'] => $nav_ary[$page]['url'])); } // And now to load the appropriate page... switch ($page) { case 'queue': case 'queue_discussion': case 'attention': case 'administration': case 'categories': include TITANIA_ROOT . 'manage/' . $page . '.' . PHP_EXT; break; default: include TITANIA_ROOT . 'manage/queue.' . PHP_EXT; exit;
/*$close = (isset($_POST['close'])) ? true : false; $id_list = request_var('id_list', array(0)); if ($close && sizeof($id_list)) { $attention_object = new titania_attention; foreach ($id_list as $attention_id) { $attention_object->attention_id = $attention_id; $attention_object->load(); } }*/ switch ($type) { case 'reported': $type = TITANIA_ATTENTION_REPORTED; break; case 'unapproved': $type = TITANIA_ATTENTION_UNAPPROVED; break; default: $type = false; break; } $options = array('attention_type' => $type, 'display_closed' => $closed, 'only_closed' => !$open && $closed ? true : false); attention_overlord::display_attention_list($options); phpbb::$template->assign_vars(array('S_ACTION' => titania_url::build_url('manage/attention'), 'S_OPEN_CHECKED' => $open, 'S_CLOSED_CHECKED' => $closed)); // Subscriptions titania_subscriptions::handle_subscriptions(TITANIA_ATTENTION, 0, titania_url::build_url('manage/attention')); titania::page_header('ATTENTION'); titania::page_footer(true, 'manage/attention.html'); }
private function common_delete($post_id, $undelete = false) { titania::add_lang('posting'); phpbb::$user->add_lang('posting'); // Load the stuff we need $post_object = $this->load_post($post_id); // Check permissions if (!$undelete && !$post_object->acl_get('delete') || $undelete && !$post_object->acl_get('undelete')) { titania::needs_auth(); } if (titania::confirm_box(true)) { if (!$undelete) { $redirect_post_id = false; // Delete the post if (isset($_POST['hard_delete']) || $post_object->post_deleted) { if (!phpbb::$auth->acl_get('u_titania_post_hard_delete')) { titania::needs_auth(); } $post_object->hard_delete(); // Try to redirect to the next or previous post $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id); if ($redirect_post_id) { redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id))); } redirect(titania_url::build_url($post_object->topic->topic_url)); } else { $post_object->soft_delete(); if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) { // They can see the post, redirect back to it redirect($post_object->get_url()); } else { // They cannot see the post, try to redirect to the next or previous post $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id); if ($redirect_post_id) { redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id))); } } } redirect($post_object->topic->get_url()); } else { $post_object->undelete(); redirect($post_object->get_url()); } } else { phpbb::$template->assign_var('S_HARD_DELETE', !$undelete && !$post_object->post_deleted && phpbb::$auth->acl_get('u_titania_post_hard_delete') ? true : false); titania::confirm_box(false, !$undelete ? 'DELETE_POST' : 'UNDELETE_POST', '', array(), 'posting/delete_confirm.html'); } redirect($post_object->get_url()); }
$error[] = sprintf(phpbb::$user->lang['COULD_NOT_FIND_USERS'], implode(', ', array_merge($missing_active, $missing_nonactive))); } if (array_intersect($active_coauthors_list, $nonactive_coauthors_list)) { $error[] = sprintf(phpbb::$user->lang['DUPLICATE_AUTHORS'], implode(', ', array_keys(array_intersect($active_coauthors_list, $nonactive_coauthors_list)))); } if (isset($active_coauthors_list[phpbb::$user->data['username']]) || isset($nonactive_coauthors_list[phpbb::$user->data['username']])) { $error[] = phpbb::$user->lang['CANNOT_ADD_SELF_COAUTHOR']; } if ($contrib_demo && !preg_match('#^http[s]?://(.*?\\.)*?[a-z0-9\\-]+\\.[a-z]{2,4}#i', $contrib_demo)) { $error[] = phpbb::$user->lang['WRONG_DATA_WEBSITE']; } if (!sizeof($error)) { titania::$contrib->submit(); // Submit screenshots $screenshot->object_id = titania::$contrib->contrib_id; $screenshot->submit(); titania::$contrib->set_coauthors($active_coauthors_list, $nonactive_coauthors_list, true); // Create relations titania::$contrib->put_contrib_in_categories($contrib_categories); redirect(titania::$contrib->get_url('revision')); } } } // Generate some stuff generate_type_select(titania::$contrib->contrib_type); generate_category_select($contrib_categories); titania::$contrib->assign_details(); $message->display(); $template->assign_vars(array('S_POST_ACTION' => titania_url::build_url('author/' . htmlspecialchars_decode(phpbb::$user->data['username_clean']) . '/create'), 'S_CREATE' => true, 'S_STYLE' => TITANIA_TYPE_STYLE, 'S_CAN_EDIT_STYLE_DEMO' => titania::$config->can_modify_style_demo_url || titania_types::$types[TITANIA_TYPE_STYLE]->acl_get('moderate') ? true : false, 'SCREENSHOT_UPLOADER' => $screenshot->parse_uploader('posting/attachments/simple.html'), 'CONTRIB_PERMALINK' => utf8_normalize_nfc(request_var('permalink', '', true)), 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $active_coauthors, 'NONACTIVE_COAUTHORS' => $nonactive_coauthors, 'S_TRANSLATION_TYPE_ID' => defined('TITANIA_TYPE_TRANSLATION') ? TITANIA_TYPE_TRANSLATION : 0)); titania::page_header('CREATE_CONTRIBUTION'); titania::page_footer(true, 'contributions/contribution_manage.html');
titania::$contrib->change_permalink($permalink); } } // Submit the changes titania::$contrib->submit(); // Set the coauthors titania::$contrib->set_coauthors($active_coauthors_list, $nonactive_coauthors_list, true); // Create relations titania::$contrib->put_contrib_in_categories($contrib_categories); // Update the release topic titania::$contrib->update_release_topic(); if ($change_owner == '') { redirect(titania::$contrib->get_url()); } else { $s_hidden_fields = array('submit' => true, 'change_owner' => $change_owner, 'change_owner_id' => $change_owner_id); titania::confirm_box(false, sprintf(phpbb::$user->lang['CONTRIB_CONFIRM_OWNER_CHANGE'], '<a href="' . phpbb::append_sid('memberlist', 'mode=viewprofile&u=' . $change_owner_id) . '">' . $change_owner . '</a>'), titania_url::append_url(titania_url::$current_page), $s_hidden_fields); } } } else { $sql = 'SELECT category_id FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . ' WHERE contrib_id = ' . titania::$contrib->contrib_id; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $contrib_categories[] = $row['category_id']; } phpbb::$db->sql_freeresult($result); $active_coauthors = $nonactive_coauthors = array(); foreach (titania::$contrib->coauthors as $row) { // User does not exist anymore... if (users_overlord::get_user($row['user_id'], 'user_id') != $row['user_id']) {
public function posts($mode, $start = false, $limit = false) { switch ($mode) { case 'index': $data = array(); $post = new titania_post(); $sql = 'SELECT p.*, t.topic_id, t.topic_type, t.topic_subject_clean, t.parent_id FROM ' . TITANIA_POSTS_TABLE . ' p, ' . TITANIA_TOPICS_TABLE . ' t WHERE t.topic_id = p.topic_id ORDER BY p.post_id ASC'; if ($start === false || $limit === false) { $result = phpbb::$db->sql_query($sql); } else { $result = phpbb::$db->sql_query_limit($sql, (int) $limit, (int) $start); } while ($row = phpbb::$db->sql_fetchrow($result)) { $post->__set_array($row); $post->topic->__set_array($row); $data[] = array('object_type' => $post->post_type, 'object_id' => $post->post_id, 'parent_id' => $post->topic->parent_id, 'title' => $post->post_subject, 'text' => $post->post_text, 'text_uid' => $post->post_text_uid, 'text_bitfield' => $post->post_text_bitfield, 'text_options' => $post->post_text_options, 'author' => $post->post_user_id, 'date' => $post->post_time, 'url' => titania_url::unbuild_url($post->get_url()), 'approved' => $post->post_approved, 'access_level' => $post->post_access); } phpbb::$db->sql_freeresult($result); titania_search::mass_index($data); break; } }
function phpbb_com_titania_post_edit($hook, &$post_object) { if (defined('IN_TITANIA_CONVERT') || !$post_object->phpbb_post_id) { return; } $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, $post_object->post_type); if (!$forum_id) { return; } titania::_include('functions_posting', 'phpbb_posting'); $post_text = $post_object->post_text; titania_decode_message($post_text, $post_object->post_text_uid); $post_text .= "\n\n" . titania_url::remove_sid($post_object->get_url()); $options = array('post_id' => $post_object->phpbb_post_id, 'topic_title' => $post_object->post_subject, 'post_text' => $post_text); phpbb_posting('edit', $options); }
function main($id, $mode) { global $phpbb_root_path; define('PHPBB_INCLUDED', true); define('USE_PHPBB_TEMPLATE', true); define('IN_TITANIA', true); if (!defined('PHP_EXT')) { define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); } require TITANIA_ROOT . 'common.' . PHP_EXT; // Need a few hacks to be used from within phpBB titania_url::decode_url(titania::$config->phpbb_script_path); titania::$hook->register(array('titania_url', 'build_url'), 'titania_outside_build_url', 'standalone'); titania::$hook->register(array('titania_url', 'append_url'), 'titania_outside_build_url', 'standalone'); titania::$hook->register(array('titania', 'page_header'), 'titania_outside_page_header', 'standalone'); titania::$hook->register(array('titania', 'page_footer'), 'titania_outside_page_footer', 'standalone'); $this->p_master->assign_tpl_vars(phpbb::append_sid('ucp')); // Include some files titania::_include('functions_display', 'titania_topic_folder_img'); // Setup the sort tool $sort = new titania_sort(); $sort->default_limit = phpbb::$config['topics_per_page']; $sort->request(); // Start initial var setup $url = $this->u_action; add_form_key('ucp_front_subscription'); // User wants to unsubscribe? if (isset($_POST['unsubscribe'])) { if (check_form_key('ucp_front_subscription')) { $sections = request_var('sections', array(0 => array(0 => 0))); $items = request_var('items', array(0 => array(0 => 0))); $subscriptions = $sections + $items; if (sizeof($subscriptions)) { foreach ($subscriptions as $type => $type_id) { $object_ids = array_keys($type_id); foreach ($object_ids as $object_id) { $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . ' WHERE watch_user_id = ' . phpbb::$user->data['user_id'] . ' AND watch_object_type = ' . $type . ' AND watch_object_id = ' . $object_id; phpbb::$db->sql_query($sql); } } } else { $msg = phpbb::$user->lang['NO_SUBSCRIPTIONS_SELECTED']; } } else { $msg = phpbb::$user->lang['FORM_INVALID']; } if (isset($msg)) { meta_refresh(3, $url); $message = $msg . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>'); trigger_error($message); } } switch ($mode) { case 'subscription_items': $array_items = array(TITANIA_CONTRIB, TITANIA_TOPIC); // We prepare pagination stuff $sql = 'SELECT COUNT(*) AS subscription_count FROM ' . TITANIA_WATCH_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . ' AND watch_user_id = ' . phpbb::$user->data['user_id']; phpbb::$db->sql_query($sql); $subscription_count = phpbb::$db->sql_fetchfield('subscription_count'); phpbb::$db->sql_freeresult(); $sort->total = $subscription_count; $sort->build_pagination($url); $sql_ary = array('SELECT' => '*, CASE w.watch_object_type WHEN ' . TITANIA_CONTRIB . ' THEN c.contrib_last_update WHEN ' . TITANIA_TOPIC . ' THEN t.topic_last_post_time END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_CONTRIB . ') AND c.contrib_id = w.watch_object_id'), array('FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'ON' => 'w.watch_object_type = ' . TITANIA_TOPIC . ' AND t.topic_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . ' AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC'); // Additional tracking for support topics titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id'); titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tsa'); titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tsc'); titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt'); // Tracking for contributions titania_tracking::get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id', 'tc'); $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); // Get the data $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start); $user_ids = $rows = array(); while ($row = phpbb::$db->sql_fetchrow($result)) { $rows[] = $row; titania_tracking::store_from_db($row); if ($row['watch_object_type'] == TITANIA_TOPIC) { $user_ids[] = $row['topic_first_post_user_id']; $user_ids[] = $row['topic_last_post_user_id']; } else { if ($row['watch_object_type'] == TITANIA_CONTRIB) { $user_ids[] = $row['contrib_user_id']; } } } phpbb::$db->sql_freeresult($result); // Get user data users_overlord::load_users($user_ids); foreach ($rows as $row) { $folder_img = $folder_alt = ''; if ($row['watch_object_type'] == TITANIA_TOPIC) { if (!$row['topic_id']) { // Topic was deleted $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . ' WHERE watch_object_type = ' . (int) $row['watch_object_type'] . ' AND watch_object_id = ' . (int) $row['watch_object_id']; phpbb::$db->sql_query($sql); continue; } $topic = new titania_topic(); $topic->__set_array($row); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0); $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true); $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true); $tpl_block = 'items'; $subscription_target = ''; if ($row['topic_type'] == TITANIA_QUEUE_DISCUSSION) { $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE_VALIDATION']; } if ($row['topic_type'] == TITANIA_QUEUE) { $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE']; } if ($row['topic_type'] == TITANIA_SUPPORT) { $subscription_target = phpbb::$user->lang['SUBSCRIPTION_SUPPORT_TOPIC']; } // Tracking check $last_read_mark = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id, true); $last_read_mark = max($last_read_mark, titania_tracking::find_last_read_mark($topic->additional_unread_fields, $topic->topic_type, $topic->parent_id)); $topic->unread = $topic->topic_last_post_time > $last_read_mark ? true : false; // Get the folder image $topic->topic_folder_img($folder_img, $folder_alt); $vars = array('LAST_POST_IMG' => phpbb::$user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['topic_first_post_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['topic_id'], 'SUBSCRIPTION_LAST_AUTHOR_FULL' => users_overlord::get_user($row['topic_last_post_user_id'], '_full'), 'SUBSCRIPTION_LAST_TIME' => phpbb::$user->format_date($row['topic_last_post_time']), 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['topic_time']), 'SUBSCRIPTION_TARGET' => $subscription_target, 'SUBSCRIPTION_TITLE' => censor_text($row['topic_subject']), 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $topic->get_url(), 'U_VIEW_LAST_POST' => titania_url::append_url($topic->get_url(), array('p' => $topic->topic_last_post_id, '#p' => $topic->topic_last_post_id)), 'S_ACCESS_TEAMS' => $row['topic_access'] == TITANIA_ACCESS_TEAMS || $row['topic_type'] == TITANIA_QUEUE ? true : false, 'S_ACCESS_AUTHORS' => $row['topic_access'] == TITANIA_ACCESS_AUTHORS ? true : false, 'S_TOPIC' => true); } else { if ($row['watch_object_type'] == TITANIA_CONTRIB) { $tpl_block = 'items'; $contrib = new titania_contribution(); $contrib->__set_array($row); titania_topic_folder_img($folder_img, $folder_alt, 0, titania_tracking::is_unread(TITANIA_CONTRIB, $contrib->contrib_id, $contrib->contrib_last_update)); $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_CONTRIB_TYPE' => titania_types::$types[$contrib->contrib_type]->lang, 'SUBSCRIPTION_DOWNLOADS' => $row['contrib_downloads'], 'SUBSCRIPTION_ID' => $row['contrib_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_CONTRIB'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'SUBSCRIPTION_VIEWS' => $row['contrib_views'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url(), 'S_CONTRIB' => true); } } phpbb::$template->assign_block_vars($tpl_block, array_merge($vars, array('FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height')))); } break; case 'subscription_sections': $array_items = array(TITANIA_SUPPORT, TITANIA_QUEUE, TITANIA_ATTENTION); // We prepare pagination stuff $sql = 'SELECT COUNT(*) AS subscription_count FROM ' . TITANIA_WATCH_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . ' AND watch_user_id = ' . phpbb::$user->data['user_id']; phpbb::$db->sql_query($sql); $subscription_count = phpbb::$db->sql_fetchfield('subscription_count'); phpbb::$db->sql_freeresult(); $sort->total = $subscription_count; $sort->build_pagination($url); $sql_ary = array('SELECT' => '*, CASE w.watch_object_type WHEN ' . TITANIA_SUPPORT . ' THEN c.contrib_last_update END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_SUPPORT . ') AND c.contrib_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . ' AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC'); $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); // Get the data $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start); $user_ids = array(); while ($row = phpbb::$db->sql_fetchrow($result)) { $rows[] = $row; $user_ids[] = $row['contrib_user_id']; } phpbb::$db->sql_freeresult($result); // Get user data users_overlord::load_users($user_ids); if (isset($rows)) { foreach ($rows as $row) { if ($row['watch_object_type'] == TITANIA_SUPPORT) { $tpl_block = 'sections'; $contrib = new titania_contribution(); $contrib->__set_array($row); $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_SUPPORT'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url('support')); } else { if ($row['watch_object_type'] == TITANIA_ATTENTION) { $tpl_block = 'sections'; $vars = array('SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_ATTENTION'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_ATTENTION' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::build_url('manage/attention')); } else { if ($row['watch_object_type'] == TITANIA_QUEUE) { $tpl_block = 'sections'; $queue_id = $row['watch_object_id']; // Setup the base url we will use $base_url = titania_url::build_url('manage/queue'); $vars = array('SUBSCRIPTION_ID' => $queue_id, 'SUBSCRIPTION_TARGET' => titania_types::$types[$queue_id]->lang, 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_QUEUE'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_QUEUE' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::append_url($base_url, array('queue' => titania_types::$types[$queue_id]->url))); } } } phpbb::$template->assign_block_vars($tpl_block, $vars); } } break; } phpbb::$template->assign_vars(array('S_ACTION' => $url, 'TITANIA_THEME_PATH' => titania::$absolute_path . 'styles/' . titania::$config->style . '/theme/')); titania::page_header(phpbb::$user->lang['SUBSCRIPTION_TITANIA']); titania::page_footer(true, 'manage/' . $mode . '.html'); }
phpbb::$user->add_lang('viewforum'); if ($topic_id) { // Subscriptions titania_subscriptions::handle_subscriptions(TITANIA_TOPIC, $topic_id, $topic->get_url()); // Check access level if ($topic->topic_access < titania::$access_level || $topic->topic_type == TITANIA_QUEUE_DISCUSSION && !titania::$contrib->is_author && !titania::$contrib->is_active_coauthor && !titania_types::$types[titania::$contrib->contrib_type]->acl_get('queue_discussion')) { titania::needs_auth(); } posts_overlord::display_topic_complete($topic); titania::page_header(censor_text($topic->topic_subject) . ' - ' . titania::$contrib->contrib_name); if (phpbb::$auth->acl_get('u_titania_post')) { phpbb::$template->assign_var('U_POST_REPLY', titania_url::append_url($topic->get_url(), array('action' => 'reply'))); } // Canonical URL phpbb::$template->assign_var('U_CANONICAL', $topic->get_url()); } else { // Subscriptions titania_subscriptions::handle_subscriptions(TITANIA_SUPPORT, titania::$contrib->contrib_id, titania::$contrib->get_url('support')); // Mark all topics read if (request_var('mark', '') == 'topics') { titania_tracking::track(TITANIA_SUPPORT, titania::$contrib->contrib_id); } $data = topics_overlord::display_forums_complete('support', titania::$contrib); titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['CONTRIB_SUPPORT']); if (phpbb::$auth->acl_get('u_titania_topic') && titania::$config->support_in_titania) { phpbb::$template->assign_var('U_POST_TOPIC', titania_url::append_url(titania::$contrib->get_url('support'), array('action' => 'post'))); } $data['sort']->set_url(titania::$contrib->get_url('support')); phpbb::$template->assign_vars(array('U_MARK_TOPICS' => titania_url::append_url(titania::$contrib->get_url('support'), array('mark' => 'topics')), 'U_CANONICAL' => $data['sort']->build_canonical(), 'S_DISPLAY_SEARCHBOX' => true, 'S_SEARCHBOX_ACTION' => titania_url::build_url('search', array('type' => TITANIA_SUPPORT, 'contrib' => titania::$contrib->contrib_id)))); } titania::page_footer(true, 'contributions/contribution_support.html');
/** * General attachment parsing * From phpBB (includes/functions_content.php) * * @param string &$message The message * @param string $tpl The template file to use * @param bool $preview true if previewing from the posting page * @param string|bool $template_block If not false we will output the parsed attachments to this template block * * @return array the parsed attachments */ public function parse_attachments(&$message, $tpl = 'common/attachment.html', $preview = false, $template_block = false) { if (!sizeof($this->attachments)) { return array(); } phpbb::$user->add_lang('viewtopic'); $compiled_attachments = array(); if ($tpl !== false && !isset(phpbb::$template->filename['titania_attachment_tpl'])) { phpbb::$template->set_filenames(array('titania_attachment_tpl' => $tpl)); } // Sort correctly if (phpbb::$config['display_order']) { // Ascending sort krsort($this->attachments); } else { // Descending sort ksort($this->attachments); } foreach ($this->attachments as $attachment_id => $attachment) { if (!sizeof($attachment)) { continue; } // We need to reset/empty the _file block var, because this function might be called more than once phpbb::$template->destroy_block_vars('_file'); $block_array = array(); // Some basics... $attachment['extension'] = strtolower(trim($attachment['extension'])); $filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/' . utf8_basename($attachment['physical_filename']); $thumbnail_filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/thumb_' . utf8_basename($attachment['physical_filename']); $filesize = get_formatted_filesize($attachment['filesize'], false); if ($preview) { $comment = bbcode_nl2br(censor_text(utf8_normalize_nfc(request_var('attachment_comment_' . $attachment_id, (string) $attachment['attachment_comment'], true)))); } else { $comment = bbcode_nl2br(censor_text($attachment['attachment_comment'])); } $block_array += array('FILESIZE' => $filesize['value'], 'SIZE_LANG' => $filesize['unit'], 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), 'COMMENT' => $comment); $l_downloaded_viewed = $download_link = ''; $display_cat = strpos($attachment['mimetype'], 'image') === 0 ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE; // @todo Probably should add support for more types... if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) { if ($attachment['thumbnail']) { $display_cat = ATTACHMENT_CATEGORY_THUMB; } else { if (phpbb::$config['img_display_inlined']) { if (phpbb::$config['img_link_width'] || phpbb::$config['img_link_height']) { $dimension = @getimagesize($filename); // If the dimensions could not be determined or the image being 0x0 we display it as a link for safety purposes if ($dimension === false || empty($dimension[0]) || empty($dimension[1])) { $display_cat = ATTACHMENT_CATEGORY_NONE; } else { $display_cat = $dimension[0] <= phpbb::$config['img_link_width'] && $dimension[1] <= phpbb::$config['img_link_height'] ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE; } } } else { $display_cat = ATTACHMENT_CATEGORY_NONE; } } } // Make some descisions based on user options being set. if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !phpbb::$user->optionget('viewimg')) { $display_cat = ATTACHMENT_CATEGORY_NONE; } if ($display_cat == ATTACHMENT_CATEGORY_FLASH && !phpbb::$user->optionget('viewflash')) { $display_cat = ATTACHMENT_CATEGORY_NONE; } $download_link = titania_url::build_url('download', array('id' => $attachment['attachment_id'])); switch ($display_cat) { // Images case ATTACHMENT_CATEGORY_IMAGE: $l_downloaded_viewed = 'VIEWED_COUNT'; $download_link = titania_url::append_url($download_link, array('mode' => 'view')); $block_array += array('S_IMAGE' => true, 'U_INLINE_LINK' => titania_url::append_url($download_link, array('mode' => 'view'))); break; // Images, but display Thumbnail // Images, but display Thumbnail case ATTACHMENT_CATEGORY_THUMB: $l_downloaded_viewed = 'VIEWED_COUNT'; $download_link = titania_url::append_url($download_link, array('mode' => 'view')); $block_array += array('S_THUMBNAIL' => true, 'THUMB_IMAGE' => titania_url::append_url($download_link, array('mode' => 'view', 'thumb' => 1))); break; // Windows Media Streams // Windows Media Streams case ATTACHMENT_CATEGORY_WM: $l_downloaded_viewed = 'VIEWED_COUNT'; // Giving the filename directly because within the wm object all variables are in local context making it impossible // to validate against a valid session (all params can differ) // $download_link = $filename; $block_array += array('ATTACH_ID' => $attachment['attachment_id'], 'S_WM_FILE' => true); break; // Real Media Streams // Real Media Streams case ATTACHMENT_CATEGORY_RM: case ATTACHMENT_CATEGORY_QUICKTIME: $l_downloaded_viewed = 'VIEWED_COUNT'; $block_array += array('S_RM_FILE' => $display_cat == ATTACHMENT_CATEGORY_RM ? true : false, 'S_QUICKTIME_FILE' => $display_cat == ATTACHMENT_CATEGORY_QUICKTIME ? true : false, 'ATTACH_ID' => $attachment['attachment_id']); break; // Macromedia Flash Files // Macromedia Flash Files case ATTACHMENT_CATEGORY_FLASH: list($width, $height) = @getimagesize($filename); $l_downloaded_viewed = 'VIEWED_COUNT'; $block_array += array('S_FLASH_FILE' => true, 'WIDTH' => $width, 'HEIGHT' => $height, 'U_VIEW_LINK' => titania_url::append_url($download_link, array('view' => 1))); break; default: $l_downloaded_viewed = 'DOWNLOAD_COUNT'; $block_array += array('S_FILE' => true); break; } $l_download_count = !isset($attachment['download_count']) || $attachment['download_count'] == 0 ? phpbb::$user->lang[$l_downloaded_viewed . '_NONE'] : ($attachment['download_count'] == 1 ? sprintf(phpbb::$user->lang[$l_downloaded_viewed], $attachment['download_count']) : sprintf(phpbb::$user->lang[$l_downloaded_viewed . 'S'], $attachment['download_count'])); $block_array += array('U_DOWNLOAD_LINK' => $download_link, 'L_DOWNLOAD_COUNT' => $l_download_count); // If a template block is specified, output to that also if ($template_block) { phpbb::$template->assign_block_vars($template_block, $block_array); } if ($tpl !== false) { phpbb::$template->assign_block_vars('_file', $block_array); $compiled_attachments[] = phpbb::$template->assign_display('titania_attachment_tpl'); } } $tpl_size = sizeof($compiled_attachments); $unset_tpl = array(); // For inline attachments if ($message) { preg_match_all('#<!\\-\\- ia([0-9]+) \\-\\->(.*?)<!\\-\\- ia\\1 \\-\\->#', $message, $matches, PREG_PATTERN_ORDER); $replace = array(); foreach ($matches[0] as $num => $capture) { // Flip index if we are displaying the reverse way $index = phpbb::$config['display_order'] ? $tpl_size - ($matches[1][$num] + 1) : $matches[1][$num]; $replace['from'][] = $matches[0][$num]; $replace['to'][] = isset($compiled_attachments[$index]) ? $compiled_attachments[$index] : sprintf(phpbb::$user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]); $unset_tpl[] = $index; } if (isset($replace['from'])) { $message = str_replace($replace['from'], $replace['to'], $message); } $unset_tpl = array_unique($unset_tpl); // Needed to let not display the inlined attachments at the end of the post again foreach ($unset_tpl as $index) { unset($compiled_attachments[$index]); } } return $compiled_attachments; }
/** * Run the tool */ function run_tool() { // Define some vars that we'll need $start = request_var('start', 0); $limit = 100; // Create topic if it does not exist? $create_topic = true; titania::_include('functions_posting', 'phpbb_posting'); titania::add_lang('contributions'); $types = array(); foreach (titania_types::$types as $id => $class) { if ($class->forum_robot && $class->forum_database) { $types[] = $id; } } if (!sizeof($types)) { trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE'); } $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE . ' WHERE ' . phpbb::$db->sql_in_set('contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . ' AND ' . phpbb::$db->sql_in_set('contrib_type', $types); phpbb::$db->sql_query($sql); $total = phpbb::$db->sql_fetchfield('cnt'); phpbb::$db->sql_freeresult(); // Grab our batch $sql_ary = array('SELECT' => 'c.contrib_id, c.contrib_user_id, c.contrib_type, c.contrib_name, c.contrib_name_clean, c.contrib_desc, c.contrib_desc_uid, c.contrib_release_topic_id, t.topic_first_post_id, u.user_id, u.username, u.username_clean, u.user_colour', 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c', USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 't.topic_id = c.contrib_release_topic_id')), 'GROUP_BY' => 'c.contrib_id', 'WHERE' => phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . ' AND u.user_id = c.contrib_user_id AND ' . phpbb::$db->sql_in_set('contrib_type', $types), 'ORDER_BY' => 'c.contrib_id DESC'); $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary); $result = phpbb::$db->sql_query_limit($sql, $limit, $start); while ($row = phpbb::$db->sql_fetchrow($result)) { // Grab the revisions $revisions = array(); $sql = 'SELECT r.revision_id, r.attachment_id, r.revision_version, a.real_filename, a.filesize FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_ATTACHMENTS_TABLE . ' a WHERE r.contrib_id = ' . $row['contrib_id'] . ' AND r.revision_status = ' . TITANIA_REVISION_APPROVED . ' AND a.attachment_id = r.attachment_id'; $rev_result = phpbb::$db->sql_query($sql); while ($rev_row = phpbb::$db->sql_fetchrow($rev_result)) { $revisions[$rev_row['revision_version']] = $rev_row; } phpbb::$db->sql_freeresult($rev_result); // Sort the revisions by their version, put the newest one in $revision uksort($revisions, 'reverse_version_compare'); if (!sizeof($revisions)) { continue; } $revision = array_shift($revisions); users_overlord::$users[$row['user_id']] = $row; $contrib = new titania_contribution(); $contrib->__set_array($row); $contrib->download = $row; // Update the release topic $contrib->update_release_topic(); } phpbb::$db->sql_freeresult($result); if ($start + $limit >= $total) { trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE'); } else { meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'update_release_topics', 'start' => $start + $limit, 'submit' => 1, 'hash' => generate_link_hash('manage')))); trigger_error(phpbb::$user->lang('UPDATE_RELEASE_TOPICS_PROGRESS', $start + $limit, $total)); } }
function trigger_back($message) { $message = isset(phpbb::$user->lang[$message]) ? phpbb::$user->lang[$message] : $message; $message .= '<br /><br /><a href="' . titania_url::build_url('manage/categories') . '">' . phpbb::$user->lang['BACK'] . '</a>'; trigger_error($message); }
/** * Decode the url to build the current page/current page url */ public static function decode_url($script_path) { $url = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); // Store the current page self::$current_page = substr($url, 0, strrpos($url, '/') + 1); self::$current_page = self::$current_page[0] == '/' ? substr(self::$current_page, 1) : self::$current_page; self::$current_page = str_replace($script_path, '', self::$root_url) . self::$current_page; // Build the full current page url self::$current_page_url = self::build_url(self::$current_page, self::$params); }
/** * Generate login box or verify password */ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true) { self::_include('captcha/captcha_factory', 'phpbb_captcha_factory'); self::$user->add_lang('ucp'); $err = ''; // Make sure user->setup() has been called if (empty(self::$user->lang)) { self::$user->setup(); } // Print out error if user tries to authenticate as an administrator without having the privileges... if ($admin && !self::$auth->acl_get('a_')) { // Not authd // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions if (self::$user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } trigger_error('NO_AUTH_ADMIN'); } if (isset($_POST['login'])) { // Get credential if ($admin) { $credential = request_var('credential', ''); if (strspn($credential, 'abcdef0123456789') !== strlen($credential) || strlen($credential) != 32) { if (self::$user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } trigger_error('NO_AUTH_ADMIN'); } $password = request_var('password_' . $credential, '', true); } else { $password = request_var('password', '', true); } $username = request_var('username', '', true); $autologin = !empty($_POST['autologin']) ? true : false; $viewonline = !empty($_POST['viewonline']) ? 0 : 1; $admin = $admin ? 1 : 0; $viewonline = $admin ? self::$user->data['session_viewonline'] : $viewonline; // Check if the supplied username is equal to the one stored within the database if re-authenticating if ($admin && utf8_clean_string(self::$username) != utf8_clean_string(self::$user->data['username'])) { // We log the attempt to use a different username... add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); trigger_error('NO_AUTH_ADMIN_USER_DIFFER'); } // If authentication is successful we redirect user to previous page $result = self::$auth->login($username, $password, $autologin, $viewonline, $admin); // If admin authentication and login, we will log if it was a success or not... // We also break the operation on the first non-success login - it could be argued that the user already knows if ($admin) { if ($result['status'] == LOGIN_SUCCESS) { add_log('admin', 'LOG_ADMIN_AUTH_SUCCESS'); } else { // Only log the failed attempt if a real user tried to. // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions if (self::$user->data['is_registered']) { add_log('admin', 'LOG_ADMIN_AUTH_FAIL'); } } } // The result parameter is always an array, holding the relevant information... if ($result['status'] == LOGIN_SUCCESS) { $redirect = request_var('redirect', ''); if ($redirect) { $redirect = titania_url::unbuild_url($redirect); $base = $append = false; titania_url::split_base_params($base, $append, $redirect); redirect(titania_url::build_url($base, $append)); } else { redirect(titania_url::build_url(titania_url::$current_page, titania_url::$params)); } } // Something failed, determine what... if ($result['status'] == LOGIN_BREAK) { trigger_error($result['error_msg']); } // Special cases... determine switch ($result['status']) { case LOGIN_ERROR_ATTEMPTS: $captcha = phpbb_captcha_factory::get_instance(self::$config['captcha_plugin']); $captcha->init(CONFIRM_LOGIN); // $captcha->reset(); // Parse the captcha template self::reset_template(); self::$template->set_filenames(array('captcha' => $captcha->get_template())); // Correct confirm image link self::$template->assign_var('CONFIRM_IMAGE_LINK', self::append_sid('ucp', 'mode=confirm&confirm_id=' . $captcha->confirm_id . '&type=' . $captcha->type)); self::$template->assign_display('captcha', 'CAPTCHA', false); titania::set_custom_template(); $err = self::$user->lang[$result['error_msg']]; break; case LOGIN_ERROR_PASSWORD_CONVERT: $err = sprintf(self::$user->lang[$result['error_msg']], self::$config['email_enable'] ? '<a href="' . self::append_sid('ucp', 'mode=sendpassword') . '">' : '', self::$config['email_enable'] ? '</a>' : '', self::$config['board_contact'] ? '<a href="mailto:' . htmlspecialchars(self::$config['board_contact']) . '">' : '', self::$config['board_contact'] ? '</a>' : ''); break; // Username, password, etc... // Username, password, etc... default: $err = self::$user->lang[$result['error_msg']]; // Assign admin contact to some error messages if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') { $err = !self::$config['board_contact'] ? sprintf(self::$user->lang[$result['error_msg']], '', '') : sprintf(self::$user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars(self::$config['board_contact']) . '">', '</a>'); } break; } } // Assign credential for username/password pair $credential = $admin ? md5(unique_id()) : false; $s_hidden_fields = array('sid' => self::$user->session_id); if ($redirect) { $s_hidden_fields['redirect'] = $redirect; } if ($admin) { $s_hidden_fields['credential'] = $credential; } $s_hidden_fields = build_hidden_fields($s_hidden_fields); titania::page_header('LOGIN'); self::$template->assign_vars(array('LOGIN_ERROR' => $err, 'LOGIN_EXPLAIN' => $l_explain, 'U_SEND_PASSWORD' => self::$config['email_enable'] ? self::append_sid('ucp', 'mode=sendpassword') : '', 'U_RESEND_ACTIVATION' => self::$config['require_activation'] == USER_ACTIVATION_SELF && self::$config['email_enable'] ? self::append_sid('ucp', 'mode=resend_act') : '', 'U_TERMS_USE' => self::append_sid('ucp', 'mode=terms'), 'U_PRIVACY' => self::append_sid('ucp', 'mode=privacy'), 'S_DISPLAY_FULL_LOGIN' => $s_display ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, 'USERNAME' => $admin ? self::$user->data['username'] : '', 'USERNAME_CREDENTIAL' => 'username', 'PASSWORD_CREDENTIAL' => $admin ? 'password_' . $credential : 'password')); titania::page_footer(true, 'login_body.html'); }
/** * Generate pagination (similar to phpBB's generate_pagination function, only with some minor tweaks to work in this class better and use proper URLs) * * @param <string> $base_url * @param <int|bool> $num_items Bool false to use $this->total * @param <int|bool> $per_page Bool false to use $this->limit * @param <int|bool> $start_item Bool false to use $this->start * @param <bool> $add_prevnext_text * @return <string> */ public function generate_pagination($base_url, $num_items = false, $per_page = false, $start_item = false, $add_prevnext_text = true) { $num_items = $num_items === false ? $this->total : $num_items; $per_page = $per_page === false ? $this->limit : $per_page; $start_item = $start_item === false ? $this->start : $start_item; $seperator = '<span class="page-sep">' . phpbb::$user->lang['COMMA_SEPARATOR'] . '</span>'; $total_pages = ceil($num_items / $per_page); $on_page = floor($start_item / $per_page) + 1; $page_string = ''; if (!$num_items) { return false; } if ($total_pages > 1) { $page_string = $on_page == 1 ? '<strong>1</strong>' : '<a href="' . $base_url . '">1</a>'; if ($total_pages > 5) { $start_cnt = min(max(1, $on_page - 4), $total_pages - 5); $end_cnt = max(min($total_pages, $on_page + 4), 6); $page_string .= $start_cnt > 1 ? ' ... ' : $seperator; for ($i = $start_cnt + 1; $i < $end_cnt; $i++) { $page_string .= $i == $on_page ? '<strong>' . $i . '</strong>' : '<a href="' . titania_url::append_url($base_url, array($this->start_name => ($i - 1) * $per_page)) . '">' . $i . '</a>'; if ($i < $end_cnt - 1) { $page_string .= $seperator; } } $page_string .= $end_cnt < $total_pages ? ' ... ' : $seperator; } else { $page_string .= $seperator; for ($i = 2; $i < $total_pages; $i++) { $page_string .= $i == $on_page ? '<strong>' . $i . '</strong>' : '<a href="' . titania_url::append_url($base_url, array($this->start_name => ($i - 1) * $per_page)) . '">' . $i . '</a>'; if ($i < $total_pages) { $page_string .= $seperator; } } } $page_string .= $on_page == $total_pages ? '<strong>' . $total_pages . '</strong>' : '<a href="' . titania_url::append_url($base_url, array($this->start_name => ($total_pages - 1) * $per_page)) . '">' . $total_pages . '</a>'; if ($add_prevnext_text) { if ($on_page == 2) { $page_string = '<a href="' . $base_url . '">' . phpbb::$user->lang['PREVIOUS'] . '</a> ' . $page_string; } else { if ($on_page != 1) { $page_string = '<a href="' . titania_url::append_url($base_url, array($this->start_name => ($on_page - 2) * $per_page)) . '">' . phpbb::$user->lang['PREVIOUS'] . '</a> ' . $page_string; } } if ($on_page != $total_pages) { $page_string .= ' <a href="' . titania_url::append_url($base_url, array($this->start_name => $on_page * $per_page)) . '">' . phpbb::$user->lang['NEXT'] . '</a>'; } } } if ($num_items == 1) { $total_results = isset(phpbb::$user->lang[$this->result_lang . '_ONE']) ? phpbb::$user->lang[$this->result_lang . '_ONE'] : phpbb::$user->lang['TOTAL_RESULTS_ONE']; } else { $total_results = isset(phpbb::$user->lang[$this->result_lang]) ? sprintf(phpbb::$user->lang[$this->result_lang], $num_items) : sprintf(phpbb::$user->lang['TOTAL_RESULTS'], $num_items); } phpbb::$template->assign_vars(array($this->template_vars['PER_PAGE'] => $per_page, $this->template_vars['ON_PAGE'] => $on_page, $this->template_vars['PREVIOUS_PAGE'] => $on_page == 2 ? $base_url : ($on_page == 1 ? '' : titania_url::append_url($base_url, array($this->start_name => ($on_page - 2) * $per_page))), $this->template_vars['NEXT_PAGE'] => $on_page == $total_pages ? '' : titania_url::append_url($base_url, array($this->start_name => $on_page * $per_page)), $this->template_vars['TOTAL_PAGES'] => $total_pages, $this->template_vars['TOTAL_ITEMS'] => $num_items, $this->template_vars['TOTAL_RESULTS'] => $total_results)); return $page_string; }
{ $url_params = substr($url_base, (strrpos($url_base, '/') + 1)); $url_base = substr($url_base, 0, (strrpos($url_base, '/') + 1)); } phpbb::$template->assign_block_vars('searchresults', array( 'TOPIC_TITLE' => censor_text($document->title), 'TOPIC_AUTHOR_FULL' => users_overlord::get_user($document->author, '_full'), 'FIRST_POST_TIME' => phpbb::$user->format_date($document->date), 'U_VIEW_TOPIC' => titania_url::build_url($url_base, $url_params), 'S_TOPIC_REPORTED' => ($document->reported) ? true : false, //'S_TOPIC_UNAPPROVED' => (!$document->approved) ? true : false, )); } break; default : */ foreach ($results['documents'] as $document) { $url_base = $url_params = ''; titania_url::split_base_params($url_base, $url_params, $document->url); phpbb::$template->assign_block_vars('searchresults', array('POST_SUBJECT' => censor_text($document->title), 'MESSAGE' => titania_generate_text_for_display($document->text, $document->text_uid, $document->text_bitfield, $document->text_options), 'POST_AUTHOR_FULL' => $document->author ? users_overlord::get_user($document->author, '_full') : false, 'POST_DATE' => $document->date ? phpbb::$user->format_date($document->date) : false, 'U_VIEW_POST' => titania_url::build_url($url_base, $url_params), 'S_POST_REPORTED' => $document->reported ? true : false)); } /* break; }*/ $sort->build_pagination(titania_url::$current_page, titania_url::$params); titania::page_header('SEARCH'); phpbb::$template->assign_vars(array('SEARCH_WORDS' => $keywords, 'SEARCH_MATCHES' => $sort->total == 1 ? sprintf(phpbb::$user->lang['FOUND_SEARCH_MATCH'], $sort->total) : sprintf(phpbb::$user->lang['FOUND_SEARCH_MATCHES'], $sort->total), 'U_SEARCH_WORDS' => titania_url::build_url(titania_url::$current_page, titania_url::$params), 'U_SEARCH' => titania_url::build_url($mode == 'find-contribution' ? 'find-contribution' : 'search'), 'S_IN_SEARCH' => true, 'S_SEARCH_ACTION' => titania_url::$current_page_url)); titania::page_footer(true, 'search_results.html');