/** * Display Social Media Buttons at topics page * * @param object $event The event object * @return null * @access public */ public function display_on_viewtopic($event) { $enabled_forums = isset($this->config['socialbuttons_enable_forums']) ? explode(',', $this->config['socialbuttons_enable_forums']) : array(); $enable_buttons = isset($this->config['socialbuttons_enable']) && $this->config['socialbuttons_enable'] || in_array($event['topic_data']['forum_id'], $enabled_forums); // Generate the full URL of the topic without session ID $use_seo_urls = isset($this->config['socialbuttons_use_seo_urls']) ? $this->config['socialbuttons_use_seo_urls'] : false; if ($use_seo_urls) { // we can not use $this->user->page['page'] because it fails on use of SEO extensions $page = $this->request->server('REQUEST_URI'); if (!$page) { // IIS $page = $this->request->server('HTTP_X_REWRITE_URL'); } $host = $this->request->server('HTTP_HOST'); $https = $this->request->server('HTTPS'); $url = ($https ? 'https://' : 'http://') . $host . '/' . $page; } else { $url = generate_board_url() . '/viewtopic.php?f=' . $event['topic_data']['forum_id'] . '&t=' . $event['topic_data']['topic_id']; } // Display the shares count if ($enable_buttons && isset($this->config['socialbuttons_showshares']) && $this->config['socialbuttons_showshares']) { $shares = $this->get_share_count($url); $this->template->assign_vars(array('S_SHOWSHARES' => true, 'SHARES_FACEBOOK' => isset($shares['facebook']) ? (int) $shares['facebook'] : 0, 'SHARES_TWITTER' => isset($shares['twitter']) ? (int) $shares['twitter'] : 0, 'SHARES_GOOGLE' => isset($shares['google']) ? (int) $shares['google'] : 0, 'SHARES_LINKEDIN' => isset($shares['linkedin']) ? (int) $shares['linkedin'] : 0)); } // Display the buttons and the OG meta tags $forums = isset($this->config['socialbuttons_enable_og_desc_forums']) ? explode(',', $this->config['socialbuttons_enable_og_desc_forums']) : array(); $position = isset($this->config['socialbuttons_position']) ? $this->config['socialbuttons_position'] : 2; $this->template->assign_vars(array('SOCIAL_MEDIA_CLASS' => 'socialmediabuttons' . (isset($this->config['socialbuttons_style']) ? $this->config['socialbuttons_style'] : 1), 'S_ENABLE_BUTTONS' => $enable_buttons, 'S_FACEBOOK' => isset($this->config['socialbuttons_facebook']) ? $this->config['socialbuttons_facebook'] : '', 'S_TWITTER' => isset($this->config['socialbuttons_twitter']) ? $this->config['socialbuttons_twitter'] : '', 'S_GOOGLE' => isset($this->config['socialbuttons_google']) ? $this->config['socialbuttons_google'] : '', 'S_LINKEDIN' => isset($this->config['socialbuttons_linkedin']) ? $this->config['socialbuttons_linkedin'] : '', 'S_SHOW_AT_TOP' => $position == 0 || $position == 1 ? true : false, 'S_SHOW_AT_BOTTOM' => $position == 0 || $position == 2 ? true : false, 'U_TOPICLINK' => urlencode($url), 'OG_URL' => $url, 'ENABLE_OG' => isset($this->config['socialbuttons_enable_og']) ? $this->config['socialbuttons_enable_og'] : '', 'OG_IMAGE' => isset($this->config['socialbuttons_og_image']) ? $this->config['socialbuttons_og_image'] : '', 'ENABLE_OG_TITLE' => isset($this->config['socialbuttons_enable_og_title']) ? $this->config['socialbuttons_enable_og_title'] : '', 'OG_TITLE' => $event['page_title'], 'ENABLE_OG_DESC' => isset($this->config['socialbuttons_enable_og_desc']) && $this->config['socialbuttons_enable_og_desc'] || in_array($event['topic_data']['forum_id'], $forums))); $this->user->add_lang_ext('tas2580/socialbuttons', 'common'); }
private function canEditFeedback($date_created, $from_user_id) { $time_diff = ($this->request->server('REQUEST_TIME') - $date_created) / 60; if ($from_user_id == $this->user->data['user_id'] && $time_diff < self::EDIT_TIME_LIMIT || $this->isEditMod()) { return true; } return false; }
/** * redirect_if_not_logged_in * This will redirect any not-logged in user to the login page * * @param $event * */ public function redirect_if_not_logged_in($event) { // Check to see if we are already logged in, if we are, bypass all this. if ($this->user->data['user_id'] == ANONYMOUS) { //The base filename for the login page. $base = "ucp.{$this->phpEx}"; //We use php self server variable since it's the most reliable way $current = $this->request->server('PHP_SELF'); //if we are on the page, then we can just return. if (strpos($current, $base) !== false) { return; } //generate the login url $login = append_sid($this->root_path . $base, 'mode=login'); redirect($login); } }
public function test_server_escaping() { $this->type_cast_helper->expects($this->once())->method('recursive_set_var')->with($this->anything(), '', true); $this->request->server('HTTP_SOMEVAR'); }
/** * Adds comment to comments table for the corresponding feedback. * * @param $feedback_id Feedback that comment is linked to * @param $short_comment * @param $long_comment * @param int $editor_id Editor of the comment if it has been edited, 0 if original unedited post * @return mixed */ private function addComment($feedback_id, $short_comment, $long_comment, $editor_id = 0) { $sql_ary = array('feedback_id' => (int) $feedback_id, 'short_comment' => $short_comment, 'long_comment' => $long_comment, 'date_created' => $this->request->server('REQUEST_TIME'), 'editor_user_id' => (int) $editor_id); return $this->db->sql_query('INSERT INTO ' . $this->tables['comments'] . ' ' . $this->db->sql_build_array('INSERT', $sql_ary)); }