/** * Check if the current session is secure. * * @return bool */ private function is_ssl() { $secure = $this->request->server('HTTPS'); if (!empty($secure)) { return 'on' === strtolower($secure) || '1' == $secure; } else { if ('443' == $this->request->server('SERVER_PORT')) { return true; } } return false; }
private function browser() { if (!($user_agent = $this->request->header('User-Agent'))) { $user_agent = $this->request->server('HTTP_USER_AGENT'); } preg_match("/(MSIE|Firefox|iPhone|Android|BlackBerry|WindowsPhone|Symbian|Chrome|Netscape|Konqueror|SeaMonkey|K-Meleon|iPod|Opera Mini|Camino|Minefield|Iceweasel|Maxthon|Version)(?:\\/| )([0-9.]+)/", $user_agent, $browser_info); list(, $browser, $version) = $browser_info; if ($browser == 'Opera Mini') { return 'Opera Mini ' . $version; } if (preg_match("/(Opera|OPR)(?:\\/| )([0-9.]+)/i", $user_agent, $opera)) { return 'Opera ' . ($opera[2] != '9.80' ? $opera[2] : substr($user_agent, -5)); } if (preg_match("/Nokia([0-9.]+)/i", $user_agent, $nokia)) { return 'Nokia ' . $nokia[1]; } if ($browser == 'MSIE') { preg_match("/(Maxthon|Avant Browser|MyIE2)/i", $user_agent, $ie); if ($ie) { return $ie[1] . ' based on IE ' . $version; } return 'IE ' . $version; } if ($browser == 'Firefox') { preg_match("/(Flock|Navigator|Epiphany)\\/([0-9.]+)/", $user_agent, $ff); if ($ff) { return $ff[1] . ' ' . $ff[2]; } } if ($browser == 'Version') { return 'Safari ' . $version; } if (!$browser && strpos($user_agent, 'Gecko')) { return 'Browser based on Gecko'; } if (!$browser) { $mobile_browser = ''; $browser_ary = array('Alcatel, Sony Ericsson, Motorola, Panasonic, Philips, Samsung, Sanyo, Sharp, Sony, Ericsson, j2me, midp, wap, pda, series60, vodafone, mobile, phone, up.browser, up.link, xiino/i'); foreach ($browser_ary as $mobile_browser) { if (stripos($user_agent, $mobile_browser) !== false) { $version = $mobile_browser; break; } } $browser = 'Browser'; } return $browser . ' ' . $version; }
/** * Returns whether the current HTTP request is a multipart request. * * @return bool */ public function is_multipart() { $content_type = $this->request->server('CONTENT_TYPE'); return strpos($content_type, 'multipart') === 0; }
/** * {@inheritdoc} */ public function get_server_variable($name, $default = '') { return $this->request->server($name, $default); }
public function recent() { $http_ajax = $this->request->server('HTTP_X_REQUESTED_WITH') == "XMLHttpRequest" ? true : false; $crawl = $this->request->variable('mode', ''); $this->template->assign_vars(array('L_RECENT_TITLE' => $this->config['recent_title'], 'L_RECENT_POSTS_NAME' => $this->config['recent_posts_name'], 'S_RECENT_MARQUE' => $this->config['recent_show_marque'] && $crawl ? true : false)); $http_headers = array('Content-type' => 'text/html; charset=UTF-8', 'Cache-Control' => 'private, no-cache="set-cookie", pre-check=0, post-check=0, max-age=0', 'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT', 'Pragma' => 'no-cache'); foreach ($http_headers as $hname => $hval) { header((string) $hname . ': ' . (string) $hval); } // // Building URL // $board_path = generate_board_url(); $viewtopic_url = $board_path . '/viewtopic.' . $this->php_ext; $forum = $this->request->variable('forum', 0); if ($forum || !$this->config['recent_ignore_forums'] && $this->config['recent_only_forums']) { if ($forum) { $sql_forums = ' AND t.forum_id = "' . $this->db->sql_escape($forum) . '" '; } else { $sql_forums = ' AND t.forum_id IN(' . $this->config['recent_only_forums'] . ') '; } } else { // Fetching forums that should not be displayed $forums = implode(',', array_keys($this->auth->acl_getf('!f_read', true))); if ($this->config['recent_only_forums'] && !empty($forums)) { $cfg_ignore_forums = $this->config['recent_only_forums'] . ',' . $forums; } else { if (!empty($forums)) { $cfg_ignore_forums = $forums; } else { $cfg_ignore_forums = $this->config['recent_only_forums'] ? $this->config['recent_only_forums'] : ''; } } // Building sql for forums that should not be displayed $sql_forums = $cfg_ignore_forums ? ' AND t.forum_id NOT IN(' . $cfg_ignore_forums . ') ' : ''; } // Fetching topics of public forums $sql = 'SELECT t.*, p.post_id, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.post_attachment FROM ' . TOPICS_TABLE . ' AS t, ' . POSTS_TABLE . ' AS p, ' . FORUMS_TABLE . " AS f\n\t\t\tWHERE t.forum_id = f.forum_id\n\t\t\t\t{$sql_forums}\n\t\t\t\tAND p.post_id = t.topic_first_post_id\n\t\t\t\tAND t.topic_moved_id = 0\n\t\t\tORDER BY t.topic_last_post_id DESC"; $result = $this->db->sql_query_limit($sql, $this->config['recent_nm_topics']); if (!($recent_topics = $this->db->sql_fetchrowset($result))) { trigger_error('NO_FORUM'); } // // BEGIN ATTACHMENT DATA // if ($this->config['recent_show_first_post'] && $this->config['recent_show_attachments'] && !$crawl) { $attach_list = $update_count = array(); foreach ($recent_topics as $post_attachment) { if ($post_attachment['post_attachment'] && $this->config['allow_attachments']) { $attach_list[] = $post_attachment['post_id']; if ($post_attachment['topic_posts_approved']) { $has_attachments = true; } } } // Pull attachment data if (sizeof($attach_list)) { if ($this->auth->acl_get('u_download')) { $sql_attach = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' WHERE ' . $this->db->sql_in_set('post_msg_id', $attach_list) . ' AND in_message = 0 ORDER BY filetime DESC, post_msg_id ASC'; $result_attach = $this->db->sql_query($sql_attach); while ($row_attach = $this->db->sql_fetchrow($result_attach)) { $attachments[$row_attach['post_msg_id']][] = $row_attach; } $this->db->sql_freeresult($result_attach); } else { $display_notice = true; } } } // // END ATTACHMENT DATA // foreach ($recent_topics as $row) { $topic_title = censor_text($row['topic_title']); if (!$this->config['recent_show_first_post'] && utf8_strlen($topic_title) > $this->config['recent_max_topic_length']) { $topic_title = utf8_substr($topic_title, 0, $this->config['recent_max_topic_length']) . '…'; } // Replies if ($this->config['recent_show_replies']) { global $phpbb_container; $phpbb_content_visibility = $phpbb_container->get('content.visibility'); $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1; } $this->template->assign_block_vars('topicrow', array('U_TOPIC' => $viewtopic_url . '?t=' . $row['topic_id'], 'U_LAST_POST' => $viewtopic_url . '?p=' . $row['topic_last_post_id'] . '#' . $row['topic_last_post_id'], 'TOPIC_TITLE' => $topic_title, 'TOPIC_REPLIES' => isset($replies) ? $replies : '', 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'FIRST_POST_TIME' => $this->user->format_date($row['topic_time']), 'LAST_POST_TIME' => $this->user->format_date($row['topic_last_post_time']), 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']))); if ($this->config['recent_show_first_post'] && !$crawl) { $message = $row['post_text']; if (utf8_strlen($message) > $this->config['recent_max_topic_length']) { //strip_bbcode($message); //$message = utf8_substr($message, 0, $this->config['recent_max_topic_length']) . '…'; $message = $this->text_substr($message, $this->config['recent_max_topic_length']) . '…'; } // Parse the message and subject $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true); if (!$http_ajax) { $message = str_replace(array("\r\n", "\r", "\n"), ' ', $message); $message = addslashes($message); $message = $this->strip_selected_tags($message, array('dl', 'dt', 'dd')); } $message = str_replace('./', $board_path . '/', $message); $this->template->assign_block_vars('topicrow.first_post_text', array('TOPIC_FIRST_POST_TEXT' => $message, 'S_HAS_ATTACHMENTS' => $this->config['recent_show_attachments'] && !empty($attachments[$row['post_id']]) ? true : false)); // Display not already displayed Attachments for this post, we already parsed them. ;) if ($this->config['recent_show_attachments'] && !empty($attachments[$row['post_id']])) { // Parse attachments parse_attachments($row['forum_id'], $message, $attachments[$row['post_id']], $update_count); foreach ($attachments[$row['post_id']] as $attachment) { if (!$http_ajax) { $attachment = str_replace(array("\r\n", "\r", "\n"), ' ', $attachment); $attachment = $this->strip_selected_tags($attachment, array('span', 'dt', 'dd')); } $attachment = str_replace('"./', '"' . $board_path . '/', $attachment); $this->template->assign_block_vars('topicrow.first_post_text.attachment', array('DISPLAY_ATTACHMENT' => $attachment)); } } } } $this->db->sql_freeresult($result); // // Load template // $this->template->set_filenames(array('body' => $http_ajax ? '@bb3mobi_recent_topics/recent_ajax_body.html' : '@bb3mobi_recent_topics/recent_body.html')); // // Output // $this->template->display('body'); garbage_collection(); exit_handler(); }