/** * Display support topics from all contributions or of a specific type. * * @param string $type Contribution type's string identifier * @return \Symfony\Component\HttpFoundation\Response */ public function display_topics($type) { $type_id = $this->get_type_id($type); if ($type_id === false) { return $this->helper->error('NO_PAGE', 404); } if ($type == 'all') { // Mark all topics read if ($this->request->variable('mark', '') == 'topics') { $this->tracking->track(TITANIA_ALL_SUPPORT, self::ALL_SUPPORT); } // Mark all topics read $this->template->assign_var('U_MARK_TOPICS', $this->helper->route('phpbb.titania.support', array('type' => 'all', 'mark' => 'topics'))); } $this->display->assign_global_vars(); $u_all_support = $this->helper->route('phpbb.titania.support', array('type' => 'all')); $this->template->assign_var('U_ALL_SUPPORT', $u_all_support); // Generate the main breadcrumbs $this->display->generate_breadcrumbs(array('ALL_SUPPORT' => $u_all_support)); // Links to the support topic lists foreach ($this->types->get_all() as $id => $class) { $this->template->assign_block_vars('support_types', array('U_SUPPORT' => $this->helper->route('phpbb.titania.support', array('type' => $class->url)), 'TYPE_SUPPORT' => $class->langs)); } $data = \topics_overlord::display_forums_complete('all_support', false, array('contrib_type' => $type_id)); // Canonical URL $data['sort']->set_url($this->helper->route('phpbb.titania.support', array('type' => $type))); $this->template->assign_var('U_CANONICAL', $data['sort']->build_canonical()); return $this->helper->render('all_support.html', 'CUSTOMISATION_DATABASE'); }
/** * Display contributions from all contribution types. * * @return \Symfony\Component\HttpFoundation\Response */ public function redirect($path) { $rerouter = new rerouter(); $url_data = $rerouter->get_url_data($path); if (!empty($url_data)) { try { $redirect_url = $this->helper->route($url_data['route'], $url_data['params'], false); return new RedirectResponse($redirect_url, 301); } catch (\Exception $e) { } } return $this->helper->error('NO_PAGE_FOUND', 404); }
/** * Run AutoMOD Tests. * * @return \Symfony\Component\HttpFoundation\Response */ protected function automod() { if (!$this->contrib->type->automod_test) { return $this->helper->error('INVALID_TOOl'); } $this->package->ensure_extracted(); // Start up the machine $prevalidator = $this->contrib->type->get_prevalidator(); // Automod testing time $details = ''; $html_results = $bbcode_results = array(); $this->revision->load_phpbb_versions(); foreach ($this->revision->phpbb_versions as $row) { $version_string = $row['phpbb_version_branch'][0] . '.' . $row['phpbb_version_branch'][1] . '.' . $row['phpbb_version_revision']; $phpbb_path = $prevalidator->get_helper()->prepare_phpbb_test_directory($version_string); if ($phpbb_path === false) { continue; } $this->template->assign_vars(array('PHPBB_VERSION' => $version_string, 'TEST_ID' => $row['row_id'])); $html_result = $bbcode_result = ''; $prevalidator->run_automod_test($this->package, $phpbb_path, $details, $html_result, $bbcode_result); $bbcode_results[] = $bbcode_result; } $bbcode_results = $this->get_result_post('VALIDATION_AUTOMOD', implode("\n\n", $bbcode_results)); // Update the queue with the results $post = $this->queue->topic_reply($bbcode_results); $this->package->cleanup(); redirect($post->get_url()); }
/** * Display queue stats. * * @param string $contrib_type Contribution type URL value. * @return \Symfony\Component\HttpFoundation\Response */ public function display_stats($contrib_type) { $this->user->add_lang_ext('phpbb/titania', array('queue_stats', 'contributions')); $this->set_type($contrib_type); if (!$this->stats_supported()) { return $this->helper->error('NO_QUEUE_STATS'); } $this->stats->set_queue_type($this->type->id); if (!$this->generate_stats()) { return $this->helper->error('NO_QUEUE_STATS'); } $this->generate_history(); $this->display->assign_global_vars(); $page_title = $this->user->lang['QUEUE_STATS'] . ' - ' . $this->type->langs; $this->display->generate_breadcrumbs(array($page_title => $this->helper->route('phpbb.titania.queue_stats', array('contrib_type' => $this->type->url)))); return $this->helper->render('queue_stats_body.html', $page_title); }
/** * Delegates requested page to appropriate method. * * @param string $author Author's username clean value. * @param string $page Requested page. * * @return \Symfony\Component\HttpFoundation\Response */ public function base($author, $page) { $page = $page ?: 'details'; if (!in_array($page, array('details', 'contributions', 'support', 'create', 'manage'))) { return $this->helper->error('NO_PAGE', 404); } $author = urldecode($author); $this->load_author($author); $this->display->assign_global_vars(); $this->generate_navigation($page); $this->author->assign_details(); return $this->{$page}(); }
/** * Send file to browser * * Copy of send_file_to_browser() from functions_download.php * with some minor modifications to work correctly in Titania. * * @param array $attachment Attachment data. * @param string $filename Full path to the attachment file. * @param int $category Attachment category. * * @return \Symfony\Component\HttpFoundation\Response if error found. Otherwise method exits. */ protected function send_file_to_browser($attachment, $filename, $category) { if (!@file_exists($filename)) { return $this->helper->error('ERROR_NO_ATTACHMENT', 404); } // Correct the mime type - we force application/octetstream for all files, except images // Please do not change this, it is a security precaution if ($category != ATTACHMENT_CATEGORY_IMAGE || strpos($attachment['mimetype'], 'image') !== 0) { $attachment['mimetype'] = strpos(strtolower($this->user->browser), 'msie') !== false || strpos(strtolower($this->user->browser), 'opera') !== false ? 'application/octetstream' : 'application/octet-stream'; } if (@ob_get_length()) { @ob_end_clean(); } // Now send the File Contents to the Browser $size = @filesize($filename); // To correctly display further errors we need to make sure we are using the correct headers for both (unsetting content-length may not work) // Check if headers already sent or not able to get the file contents. if (headers_sent() || !@file_exists($filename) || !@is_readable($filename)) { // PHP track_errors setting On? if (!empty($php_errormsg)) { return $this->helper->error($this->user->lang['UNABLE_TO_DELIVER_FILE'] . '<br />' . $this->user->lang('TRACKED_PHP_ERROR', $php_errormsg), self::INTERNAL_SERVER_ERROR); } return $this->helper->error('UNABLE_TO_DELIVER_FILE', self::INTERNAL_SERVER_ERROR); } // Make sure the database record for the filesize is correct if ($size > 0 && $size != $attachment['filesize']) { // Update database record $sql = 'UPDATE ' . TITANIA_ATTACHMENTS_TABLE . ' SET filesize = ' . (int) $size . ' WHERE attachment_id = ' . (int) $attachment['attachment_id']; $this->db->sql_query($sql); } // Now the tricky part... let's dance header('Pragma: public'); // Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer. header('Content-Type: ' . $attachment['mimetype']); if (phpbb_is_greater_ie_version($this->user->browser, 7)) { header('X-Content-Type-Options: nosniff'); } if ($category == ATTACHMENT_CATEGORY_FLASH && request_var('view', 0) === 1) { // We use content-disposition: inline for flash files and view=1 to let it correctly play with flash player 10 - any other disposition will fail to play inline header('Content-Disposition: inline'); } else { if (empty($this->user->browser) || strpos(strtolower($this->user->browser), 'msie') !== false && !phpbb_is_greater_ie_version($this->user->browser, 7)) { header('Content-Disposition: attachment; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); if (empty($this->user->browser) || strpos(strtolower($this->user->browser), 'msie 6.0') !== false) { header('expires: -1'); } } else { header('Content-Disposition: ' . (strpos($attachment['mimetype'], 'image') === 0 ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); if (phpbb_is_greater_ie_version($this->user->browser, 7) && strpos($attachment['mimetype'], 'image') !== 0) { header('X-Download-Options: noopen'); } } } if ($size) { header("Content-Length: {$size}"); } // Close the db connection before sending the file etc. file_gc(false); if (!set_modified_headers($attachment['filetime'], $this->user->browser)) { // Try to deliver in chunks @set_time_limit(0); $fp = @fopen($filename, 'rb'); if ($fp !== false) { // Deliver file partially if requested if ($range = phpbb_http_byte_range($size)) { fseek($fp, $range['byte_pos_start']); send_status_line(206, 'Partial Content'); header('Content-Range: bytes ' . $range['byte_pos_start'] . '-' . $range['byte_pos_end'] . '/' . $range['bytes_total']); header('Content-Length: ' . $range['bytes_requested']); } while (!feof($fp)) { echo fread($fp, 8192); } fclose($fp); } else { @readfile($filename); } flush(); } exit; }