/** * 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'); }
public function avatar_explain($event) { $mode = $this->request->variable('mode', ''); if ($mode == 'avatar') { $this->resize->avatar_explain(); } }
public function get_bookmarks($ext_mode = '', $forums = array()) { define('POSTS_BOOKMARKS_TABLE', $this->table_prefix . 'posts_bookmarks'); $start = $this->request->variable('start', 0); $sql = 'SELECT COUNT(post_id) as posts_count FROM ' . POSTS_BOOKMARKS_TABLE . ' WHERE user_id = ' . $this->user->data['user_id']; $result = $this->db->sql_query($sql); $posts_count = (int) $this->db->sql_fetchfield('posts_count'); $this->db->sql_freeresult($result); $sql_where = $sql_fields = ''; if ($ext_mode != 'find') { $sql_where = 'LEFT JOIN ' . USERS_TABLE . ' u ON (p.poster_id = u.user_id)'; $sql_fields = ', p.post_time, u.user_id, u.username, u.user_colour'; } $pagination_url = append_sid("{$this->phpbb_root_path}postbookmark", "mode=find"); $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $posts_count, $this->config['topics_per_page'], $start); $sql = 'SELECT b.post_id AS b_post_id, b.user_id, b.bookmark_time, b.bookmark_desc, p.post_id, p.forum_id, p.topic_id, p.poster_id, p.post_subject, t.topic_title ' . $sql_fields . ' FROM ' . POSTS_BOOKMARKS_TABLE . ' b LEFT JOIN ' . POSTS_TABLE . ' p ON( b.post_id = p.post_id) LEFT JOIN ' . TOPICS_TABLE . ' t ON( t.topic_id = p.topic_id) ' . $sql_where . ' WHERE b.user_id = ' . $this->user->data['user_id'] . ' ORDER BY b.bookmark_time ASC'; $result = $this->db->sql_query_limit($sql, $this->config['topics_per_page'], $start); while ($row = $this->db->sql_fetchrow($result)) { $topic_author = $sql_where ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : ''; $post_time = $sql_where ? $this->user->format_date($row['post_time']) : ''; // Send vars to template $this->template->assign_block_vars('postrow', array('POST_ID' => $row['b_post_id'], 'POST_TIME' => $post_time, 'BOOKMARK_TIME' => $this->user->format_date($row['bookmark_time']), 'BOOKMARK_DESC' => $row['bookmark_desc'], 'TOPIC_AUTHOR' => $topic_author, 'POST_TITLE' => $row['post_subject'] ? $row['post_subject'] : $row['topic_title'], 'U_VIEW_POST' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "p=" . $row['post_id'] . "#p" . $row['post_id'] . ""), 'S_DELETED_TOPIC' => !$row['topic_id'] ? true : false, 'S_DELETED_POST' => !$row['post_id'] ? true : false, 'U_POST_BOOKMARK' => '[url=' . generate_board_url() . '/viewtopic.' . $this->php_ext . '?p=' . $row['post_id'] . '#p' . $row['post_id'] . ']' . ($row['post_subject'] ? $row['post_subject'] : $row['topic_title']) . '[/url]')); } $this->db->sql_freeresult($result); $this->template->assign_vars(array('TOTAL_BOOKMARKS' => $this->user->lang('TOTAL_BOOKMARKS', (int) $posts_count), 'PAGE_NUMBER' => $this->pagination->on_page($posts_count, $this->config['topics_per_page'], $start))); }
/** * {@inheritdoc} */ public function get_template_side($module_id) { $style_count = 0; $style_select = ''; $sql = 'SELECT style_id, style_name FROM ' . STYLES_TABLE . ' WHERE style_active = 1 ORDER BY LOWER(style_name) ASC'; $result = $this->db->sql_query($sql, 3600); while ($row = $this->db->sql_fetchrow($result)) { $style = $this->request->variable('style', 0); if (!empty($style)) { $url = str_replace('style=' . $style, 'style=' . $row['style_id'], $this->modules_helper->route('board3_portal_controller')); } else { $url = $this->modules_helper->route('board3_portal_controller') . '?style=' . $row['style_id']; } ++$style_count; $style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $this->user->style['style_id'] ? ' selected="selected"' : '') . '>' . utf8_htmlspecialchars($row['style_name']) . '</option>'; } $this->db->sql_freeresult($result); if (strlen($style_select)) { $this->template->assign_var('STYLE_SELECT', $style_select); } // Assign specific vars $this->template->assign_vars(array('S_STYLE_OPTIONS' => $this->config['override_user_style'] || $style_count < 2 ? '' : $style_select)); return 'stylechanger_side.html'; }
public function memberlist_modify_query($event) { $sql_from = $event['sql_from']; $sql_where = $event['sql_where']; $user_from = $this->request->variable('user_from', '', true); $user_id = $this->request->variable('user_id', ''); $this->template->assign_vars(array('USER_FROM' => $user_from, 'USER_ID' => (int) $user_id)); if ($user_from) { $sql_from .= ', ' . PROFILE_FIELDS_DATA_TABLE . ' pf '; $pieces = explode(' ', $user_from); $sql_where .= ' AND (pf.pf_phpbb_location COLLATE utf8_general_ci '; $sql_where .= $this->db->sql_like_expression(str_replace('*', $this->db->get_any_char(), $pieces[0])); for ($i = 1; $i < sizeof($pieces); $i++) { $sql_where .= ' OR pf.pf_phpbb_location COLLATE utf8_general_ci '; $sql_where .= $this->db->sql_like_expression(str_replace('*', $this->db->get_any_char(), $pieces[$i])); } $sql_where .= ') AND u.user_id = pf.user_id'; $event['sql_where'] = $sql_where; $event['sql_from'] = $sql_from; } if ((int) $user_id) { $sql_where .= ' AND u.user_id = ' . $user_id . ''; $event['sql_where'] = $sql_where; } }
/** * Run tool. * * @return \Symfony\Component\HttpFoundation\Response */ public function run_tool() { $type = $this->request->variable('type', 'queue'); $start = $this->request->variable('start', 0); $continue_start = null; switch ($type) { case 'queue': $continue_start = $this->sync_queue_topics($start); if ($continue_start === null) { $type = 'contrib'; $continue_start = 0; } break; case 'contrib': $continue_start = $this->sync_contrib_topics($start); break; } if ($continue_start !== null) { $params = array('tool' => 'rebuild_topic_urls', 'type' => $type, 'submit' => 1, 'hash' => generate_link_hash('manage'), 'start' => $continue_start); meta_refresh(2, $this->controller_helper->route('phpbb.titania.administration.tool', $params)); } $msg = $continue_start !== null ? 'PLEASE_WAIT_FOR_TOOL' : 'DONE'; $this->template->assign_vars(array('MESSAGE_TEXT' => $this->user->lang($msg), 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'))); return $this->controller_helper->render('message_body.html', $msg); }
/** * Event: core.viewforum_get_topic_ids_data */ public function viewforum_get_topic_ids_data($event) { $custom_sorting = array('by' => $this->user->data['user_topic_sortby_type'], 'order' => $this->user->data['user_topic_sortby_dir']); // Forum-specific sorting if ($event['forum_data']['sort_topics_by'] != $this->default_sort_by) { $custom_sorting = array('by' => $event['forum_data']['sort_topics_by'], 'order' => $event['forum_data']['sort_topics_order']); } else { if ($this->user->data['is_registered'] && !$this->user->data['is_bot'] && $this->config['kasimi.sorttopics.ucp_enabled'] && $this->user->data['sort_topics_by_created_time']) { $custom_sorting['by'] = 'c'; } } // Temporary sorting if the user used the options at the bottom of viewforum if ($this->request->is_set('sk')) { $custom_sorting['by'] = $this->request->variable('sk', ''); } if ($this->request->is_set('sd')) { $custom_sorting['order'] = $this->request->variable('sd', ''); } $this->inject_created_time_select_option('S_SELECT_SORT_KEY', $custom_sorting['by'], 'S_SELECT_SORT_DIR', $custom_sorting['order']); // Bail out if we don't need to adjust sorting if ($custom_sorting['by'] == $this->sort_key && $custom_sorting['order'] == $this->sort_dir) { return; } // This forum requires custom topic sorting, let's get our hands dirty $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => array('t.topic_last_post_time', 't.topic_last_post_id'), 'c' => array('t.topic_time', 't.topic_id'), 'r' => $this->auth->acl_get('m_approve', $event['forum_data']['forum_id']) ? 't.topic_posts_approved + t.topic_posts_unapproved + t.topic_posts_softdeleted' : 't.topic_posts_approved', 's' => 't.topic_title', 'v' => 't.topic_views'); $sort_sql = $sort_by_sql[$custom_sorting['by']]; $direction = $custom_sorting['order'] == 'd' ? 'DESC' : 'ASC'; $sql_sort_order = (is_array($sort_sql) ? implode(' ' . $direction . ', ', $sort_sql) : $sort_sql) . ' ' . $direction; $sql_ary = $event['sql_ary']; $store_reverse = $event['store_reverse']; $sql_ary['ORDER_BY'] = 't.topic_type ' . (!$store_reverse ? 'DESC' : 'ASC') . ', ' . $sql_sort_order; $event['sql_sort_order'] = $sql_sort_order; $event['sql_ary'] = $sql_ary; }
/** * {@inheritdoc} */ public function perform_auth_login() { if (!$this->service_provider instanceof \OAuth\OAuth2\Service\Evesso) { throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } $this->service_provider->requestAccessToken($this->request->variable('code', '')); $result = json_decode($this->service_provider->request('verify'), true); return $result['CharacterID']; }
protected function _force_get_route($route_data, $has_blocks = false) { $route_mapper = $this->mapper_factory->create('blocks', 'routes'); if (($route = $route_mapper->load($route_data)) === null) { $route_data['ext_name'] = $this->request->variable('ext', ''); $route_data['has_blocks'] = $has_blocks; $entity = $route_mapper->create_entity($route_data); $route = $route_mapper->save($entity); } return $route; }
/** * @param int $block_id * @return array */ public function save($block_id) { $content = $this->request->variable('content', '', true); $cblocks = $this->_get_custom_blocks(); $sql_data = array('block_id' => $block_id, 'block_content' => $content, 'bbcode_bitfield' => '', 'bbcode_options' => 7, 'bbcode_uid' => ''); generate_text_for_storage($sql_data['block_content'], $sql_data['bbcode_uid'], $sql_data['bbcode_bitfield'], $sql_data['bbcode_options'], true, true, true); $sql = !isset($cblocks[$block_id]) ? 'INSERT INTO ' . $this->cblocks_table . ' ' . $this->db->sql_build_array('INSERT', $sql_data) : 'UPDATE ' . $this->cblocks_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_data) . ' WHERE block_id = ' . (int) $block_id; $this->db->sql_query($sql); $this->cache->destroy('pt_cblocks'); return array('id' => $block_id, 'content' => $this->_get_content($sql_data), 'callback' => 'previewCustomBlock'); }
/** * {@inheritdoc} */ public function perform_auth_login() { if (!$this->service_provider instanceof \OAuth\OAuth2\Service\Facebook) { throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request, get the token $this->service_provider->requestAccessToken($this->request->variable('code', '')); // Send a request with it $result = json_decode($this->service_provider->request('/me'), true); // Return the unique identifier return $result['id']; }
public function acp_manage_forums_update_data_after($event) { $status = $this->request->variable('rh_topictags_enabled', 0); $prune = $this->request->variable('rh_topictags_prune', 0); if (!$status && $prune) { $data = $event->get_data(); $forum_id = (int) $data['forum_data']['forum_id']; $this->tags_manager->delete_tags_from_tagdisabled_forums(array($forum_id)); $this->tags_manager->delete_unused_tags(); } $this->tags_manager->calc_count_tags(); }
/** * {@inheritdoc} */ public function perform_auth_login() { if (!$this->service_provider instanceof \OAuth\OAuth2\Service\BattleNetUS) { throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request from battlenet, get the token $this->service_provider->requestAccessToken($this->request->variable('code', '')); // Send a request with it $result = json_decode($this->service_provider->request('account/user'), true); // Return the unique identifier returned from battlenet return $result['battletag']; }
public function pm_warning($event) { // There is no suitable event - read the data from the submit: $address_list = $this->request->variable('address_list', array('' => array(0 => ''))); // This has the drawback of not knowing about new users currently being added // We therefore will have to check the added recipients list for known usernames as well :/ // This also has the drawback of still showing the warning even if the user is currently deleted. // So let's remove the deleted user from the list as well: $delete = $this->request->variable('remove_u', array(0 => '')); foreach ($delete as $key => $value) { if (isset($address_list['u'][$key])) { unset($address_list['u'][$key]); } } //Wenn PN an Teammitglied gesendet werden soll, Hinweismeldung anzeigen //TODO: Etwas besseres als Referenz nehmen als "phpBB.de-Team" im Gruppennamen. if (!empty($address_list['u'])) { $sql = "SELECT u.user_id, ut.username\n\t\t\t\tFROM " . USER_GROUP_TABLE . " u\n\t\t\t\tLEFT JOIN " . GROUPS_TABLE . " g ON g.group_id = u.group_id\n\t\t\t\tLEFT JOIN " . USERS_TABLE . " ut ON u.user_id = ut.user_id\n\t\t\t\tWHERE g.group_name = 'phpBB.de-Team' OR g.group_name = 'phpBB Deutschland e. V.' "; $result = $this->db->sql_query($sql, 3600); $team_user_ids = array(); $team_user_names = array(); while ($row = $this->db->sql_fetchrow($result)) { $team_user_ids[] = $row['user_id']; $team_user_names[$row['user_id']] = $row['username']; } if (count(array_intersect(array_keys($address_list['u']), $team_user_ids)) > 0) { $this->template->assign_var('S_PN_TO_TEAM_MEMBER', true); return; } // This is only necessary, if we didn't find a member yet. $new_recipients = explode("\n", $this->request->variable('username_list', '', true)); if (sizeof($team_user_names) < sizeof($new_recipients)) { $new_recipients = array_map('trim', $new_recipients); foreach ($team_user_names as $username) { if (in_array($username, $new_recipients)) { $this->template->assign_var('S_PN_TO_TEAM_MEMBER', true); return; } } } else { foreach ($new_recipients as $username) { if (in_array(trim($username), $team_user_names)) { $this->template->assign_var('S_PN_TO_TEAM_MEMBER', true); return; } } } } }
public function acp_board_config($event) { $mode = $event['mode']; if ($mode == 'post') { $new_config = array('legend_newtopic' => 'ACP_NEWTOPIC', 'newtopic_forum' => array('lang' => 'ACP_NEWTOPIC_FORUM', 'validate' => 'string', 'type' => 'custom', 'function' => array($this, 'select_forums'), 'explain' => true), 'newtopic_button' => array('lang' => 'ACP_NEWTOPIC_BUTTON', 'validate' => 'string', 'type' => 'text:25:40', 'explain' => false)); $search_slice = 'max_post_img_height'; $display_vars = $event['display_vars']; $display_vars['vars'] = phpbb_insert_config_array($display_vars['vars'], $new_config, array('after' => $search_slice)); $event['display_vars'] = array('title' => $display_vars['title'], 'vars' => $display_vars['vars']); if ($event['submit']) { $values = $this->request->variable('newtopic_forum', array(0 => '')); $this->config->set('newtopic_forum', implode(',', $values)); } } }
/** * Run requested tool. * * @param string $tool Tool. * @param int $id Revision id. * * @return \Symfony\Component\HttpFoundation\Response */ public function run_tool($tool, $id) { if (!in_array($tool, array('automod', 'mpv', 'epv'))) { return $this->helper->error('INVALID_TOOL', 404); } // Check the hash first to avoid unnecessary queries. if (!check_link_hash($this->request->variable('hash', ''), 'queue_tool')) { return $this->helper->error('PAGE_REQUEST_INVALID'); } $this->load_objects($id); if (!$this->contrib->type->acl_get('view')) { return $this->helper->needs_auth(); } return $this->{$tool}(); }
/** * The main script, orchestrating all steps of the process */ public function generate_menu() { // When the event is dispatched from posting.php, the forum_id is not passed, // so its better to use request->variable instead of $event['item_id'] $current_id = $this->request->variable('f', 0); $list = $this->get_forum_list(false, false, true, false); $parents = $this->get_crumb_parents($list, $current_id); $list = $this->mark_current($list, $current_id, $parents); $tree = $this->build_tree($list); $html = $this->build_output($tree); unset($list, $tree); if (!empty($html)) { $this->template->assign_vars(array('BREADCRUMB_MENU' => $html)); } }
/** * {@inheritdoc} */ public function perform_auth_login() { if (!$this->service_provider instanceof \OAuth\OAuth1\Service\Twitter) { throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } $storage = $this->service_provider->getStorage(); $token = $storage->retrieveAccessToken('Twitter'); $tokensecret = $token->getRequestTokenSecret(); // This was a callback request from twitter, get the token $this->service_provider->requestAccessToken($this->request->variable('oauth_token', ''), $this->request->variable('oauth_verifier', ''), $tokensecret); // Send a request with it $result = json_decode($this->service_provider->request('account/verify_credentials.json'), true); // Return the unique identifier returned from twitter return $result['id']; }
public function acp_board_config($event) { if ($event['mode'] == 'post') { $this->user->add_lang_ext('bb3mobi/vkRepost', 'info_acp_repost_vk'); $display_vars = $event['display_vars']; $new_config = array('legend4' => 'VK_REPOST', 'vk_api_id' => array('lang' => 'VK_API_ID', 'validate' => 'string', 'type' => 'text:30:200', 'explain' => true), 'vk_token' => array('lang' => 'VK_TOKEN', 'validate' => 'string', 'type' => 'custom', 'function' => array($this, 'token_link'), 'explain' => true), 'vk_repost_group' => array('lang' => 'VK_REPOST_GROUP', 'validate' => 'string', 'type' => 'text:15:100', 'explain' => true), 'vk_repost_forum' => array('lang' => 'VK_REPOST_FORUMS', 'validate' => 'string', 'type' => 'custom', 'function' => array($this, 'select_forums'), 'explain' => true), 'vk_repost_admin' => array('lang' => 'VK_REPOST_ADMIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'vk_repost_text' => array('lang' => 'VK_REPOST_TEXT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'vk_repost_lenght' => array('lang' => 'VK_REPOST_LENGHT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => false), 'vk_repost_url' => array('lang' => 'VK_REPOST_URL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true)); $display_vars = $event['display_vars']; $display_vars['vars'] = phpbb_insert_config_array($display_vars['vars'], $new_config, array('after' => 'max_post_img_height')); $event['display_vars'] = array('title' => $display_vars['title'], 'vars' => $display_vars['vars']); if ($event['submit']) { $values = $this->request->variable('vk_repost_forum', array(0 => '')); $this->config->set('vk_repost_forum', implode(',', $values)); } } }
/** * Event: core.acp_manage_forums_request_data * * @param Event $event */ public function acp_manage_forums_request_data($event) { $lock_options = array('move_topics_when_locked' => $this->request->variable('move_topics_when_locked', 0), 'move_topics_when_locked_solved' => $this->request->variable('move_topics_when_locked_solved', 0), 'move_topics_when_locked_to' => $this->request->variable('move_topics_when_locked_to', 0)); $event['forum_data'] = array_merge($event['forum_data'], $lock_options); // Apply this forum's preferences to all sub-forums if ($event['action'] == 'edit' && $this->request->variable('move_topics_when_locked_subforums', 0)) { $subforum_ids = $this->get_subforum_ids($event['forum_data']['forum_id']); if (!empty($subforum_ids)) { $sql_ary = 'UPDATE ' . FORUMS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $lock_options) . ' WHERE ' . $this->db->sql_in_set('forum_id', $subforum_ids); $this->db->sql_query($sql_ary); } } }
/** * Plupload allows for chunking so we must check for that and assemble * the whole file first before performing any checks on it. * * @param string $form_name The name of the file element in the upload form * * @return array|null null if there are no chunks to piece together * otherwise array containing the path to the * pieced-together file and its size */ public function handle_upload($form_name) { $chunks_expected = $this->request->variable('chunks', 0); // If chunking is disabled or we are not using plupload, just return // and handle the file as usual if ($chunks_expected < 2) { return; } $file_name = $this->request->variable('name', ''); $chunk = $this->request->variable('chunk', 0); $this->user->add_lang('plupload'); $this->prepare_temporary_directory(); $file_path = $this->temporary_filepath($file_name); $this->integrate_uploaded_file($form_name, $chunk, $file_path); // If we are done with all the chunks, strip the .part suffix and then // handle the resulting file as normal, otherwise die and await the // next chunk. if ($chunk == $chunks_expected - 1) { rename("{$file_path}.part", $file_path); // Reset upload directories to defaults once completed $this->set_default_directories(); // Need to modify some of the $_FILES values to reflect the new file return array('tmp_name' => $file_path, 'name' => $this->request->variable('real_filename', ''), 'size' => filesize($file_path), 'type' => $this->mimetype_guesser->guess($file_path, $file_name)); } else { $json_response = new \phpbb\json_response(); $json_response->send(array('jsonrpc' => '2.0', 'id' => 'id', 'result' => null)); } }
/** * Display new contribution page. * * @return \Symfony\Component\HttpFoundation\Response */ protected function create() { if (!$this->is_owner && !$this->auth->acl_get('u_titania_contrib_submit')) { return $this->helper->needs_auth(); } $this->user->add_lang_ext('phpbb/titania', 'contributions'); $contrib = new \titania_contribution(); $contrib->contrib_user_id = $this->user->data['user_id']; $contrib->author = $this->author; $contrib->get_options(); // Set some main vars up $message = $this->setup_message($contrib); $submit = $this->request->is_set_post('submit'); $preview = $this->request->is_set_post('preview'); $error = array(); $settings = array('type' => $this->request->variable('contrib_type', 0), 'permalink' => $this->request->variable('permalink', '', true), 'categories' => $this->request->variable('contrib_category', array(0)), 'coauthors' => array('active' => $this->request->variable('active_coauthors', '', true), 'nonactive' => $this->request->variable('nonactive_coauthors', '', true)), 'custom' => $this->request->variable('custom_fields', array('' => ''), true)); if ($preview || $submit) { $contrib->post_data($message); $contrib->__set_array(array('contrib_type' => $settings['type'], 'contrib_name_clean' => $settings['permalink'], 'contrib_visible' => 1)); } if ($preview) { $message->preview(); } else { if ($submit) { $authors = $contrib->get_authors_from_usernames(array('active_coauthors' => $settings['coauthors']['active'], 'nonactive_coauthors' => $settings['coauthors']['nonactive'])); $authors['author'] = array($this->user->data['username'] => $this->user->data['user_id']); $error = $contrib->validate($settings['categories'], $authors, $settings['custom']); if (($form_key_error = $message->validate_form_key()) !== false) { $error[] = $form_key_error; } if (empty($error)) { $contrib->set_type($contrib->contrib_type); $contrib->set_custom_fields($settings['custom']); $contrib->contrib_categories = implode(',', $settings['categories']); $contrib->contrib_creation_time = time(); $contrib->submit(); $contrib->set_coauthors($authors['active_coauthors'], $authors['nonactive_coauthors'], true); // Create relations $contrib->put_contrib_in_categories($settings['categories']); if ($this->ext_config->support_in_titania) { $active_authors = array_merge($authors['author'], $authors['active_coauthors']); foreach ($active_authors as $author) { $this->subscriptions->subscribe(TITANIA_SUPPORT, $contrib->contrib_id, $author); } } redirect($contrib->get_url('revision')); } } } // Generate some stuff $this->display->generate_type_select($contrib->contrib_type); $this->display->generate_category_select($settings['categories']); $contrib->assign_details(); $message->display(); foreach ($this->types->get_all() as $type) { $this->display->generate_custom_fields($type->contribution_fields, $settings['custom'], $type->id); } $this->template->assign_vars(array('S_POST_ACTION' => $this->author->get_url('create'), 'S_CREATE' => true, 'S_CAN_EDIT_CONTRIB' => $this->auth->acl_get('u_titania_contrib_submit'), 'CONTRIB_PERMALINK' => $settings['permalink'], 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $settings['coauthors']['active'], 'NONACTIVE_COAUTHORS' => $settings['coauthors']['nonactive'])); return $this->helper->render('contributions/contribution_manage.html', 'NEW_CONTRIBUTION'); }
/** * Event: rfd.api.pre_update_topic * * Validate trader_type being passed in * * @param phpbbEvent $event */ public function rfd_api_pre_update_topic(phpbbEvent $event) { $data = $event->get_data(); $topic_id = $data['topic_id']; $forum_id = $data['forum_id']; $errors = $data['errors']; $type = $this->request->variable('trader_type', '', false, \phpbb\request\request_interface::POST); // if trader_type is not set, set it to the current trader_type if (!isset($type)) { $type = $this->manager->getTopicType($topic_id); $type = $this->manager->validateForumType($forum_id, $type, false); } else { if ($this->manager->getForumStatus($forum_id)) { $type = $this->manager->validateForumType($forum_id, $type, true); } } // Expose error if trader_type is not supported by the forum if (is_null($type)) { $errors[] = 'This forum does not support that trader type'; $data['errors'] = $errors; $event->set_data($data); } else { // Overwrite the request so that submit_post_end listener can handle trader_type $this->request->overwrite('prefixfield', $type, \phpbb\request\request_interface::POST); } }
/** * Delete module * * @param int|string $id Module ID of the acp_portal module * @param string $mode Mode of the acp_portal module * @param string $action Current action of the acp_portal module * @param int $module_id ID of the module that should be deleted */ public function module_delete($id, $mode, $action, $module_id) { $module_data = $this->get_move_module_data($module_id); if ($module_data !== false) { $module_classname = $this->request->variable('module_classname', ''); $this->get_module($module_data['module_classname']); if (confirm_box(true)) { $this->module->uninstall($module_data['module_id'], $this->db); $sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE . ' WHERE module_id = ' . (int) $module_id; $this->db->sql_query($sql); $sql = 'UPDATE ' . PORTAL_MODULES_TABLE . ' SET module_order = module_order - 1 WHERE module_column = ' . (int) $module_data['module_column'] . ' AND module_order > ' . (int) $module_data['module_order']; $this->db->sql_query($sql); $this->cache->purge(); // make sure we don't get errors after re-adding a module // Handle ajax request $this->handle_ajax_request(array('success' => true, 'MESSAGE_TITLE' => $this->user->lang['INFORMATION'], 'MESSAGE_TEXT' => $this->user->lang['SUCCESS_DELETE'])); trigger_error($this->user->lang['SUCCESS_DELETE'] . adm_back_link($this->u_action)); } else { if ($this->module->get_language()) { $this->controller_helper->load_module_language($this->module); } $confirm_text = isset($this->user->lang[$module_data['module_name']]) ? sprintf($this->user->lang['DELETE_MODULE_CONFIRM'], $this->user->lang[$module_data['module_name']]) : sprintf($this->user->lang['DELETE_MODULE_CONFIRM'], utf8_normalize_nfc($module_data['module_name'])); confirm_box(false, $confirm_text, build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => $action, 'module_id' => $module_id, 'module_classname' => $module_classname))); } } $this->cache->destroy('sql', PORTAL_MODULES_TABLE); }
/** * Handle upload. */ protected function handle_upload() { $upload = $this->request->file($this->form_name); if ($upload['name'] != 'none' && trim($upload['name'])) { // Try uploading the file. $this->upload_file(); // Store for easier access $this->errors = array_merge($this->errors, $this->filedata['error']); // If we had no problems we can submit the data to the database. if (empty($this->filedata['error'])) { $order_id = $this->set_custom_order ? $this->operator->get_max_custom_index() + 1 : 0; $data = array('attachment_id' => 0, 'physical_filename' => $this->filedata['physical_filename'], 'attachment_directory' => $this->filedata['attachment_directory'], 'real_filename' => $this->filedata['real_filename'], 'extension' => $this->filedata['extension'], 'mimetype' => $this->filedata['mimetype'], 'filesize' => $this->filedata['filesize'], 'filetime' => $this->filedata['filetime'], 'hash' => $this->filedata['md5_checksum'], 'attachment_order' => $order_id, 'attachment_comment' => $this->request->variable('filecomment', '', true), 'object_type' => $this->object_type, 'object_id' => $this->object_id); $attachment = $this->operator->get_new_entity($data); // Create thumbnail $has_thumbnail = $is_preview = false; if ($this->filedata['is_image']) { $has_thumbnail = $attachment->create_thumbnail($this->max_thumbnail_width, $this->max_thumbnail_width === false ? false : 0); // set first screenshot as preview image when it is uploaded $is_preview = !$this->operator->get_count(); } $attachment->__set_array(array('thumbnail' => $has_thumbnail, 'is_preview' => $is_preview)); $attachment->submit(); // Store in operator $this->operator->set($attachment); $this->uploaded = $attachment->get_id(); } } // We do not want to upload it again if this function is called again. $this->request->overwrite($this->form_name, null, request_interface::FILES); }
/** * @param array $cfg_array * @param array $df_settings */ private function _get_multi_select(array &$cfg_array, array $df_settings) { $multi_select = utf8_normalize_nfc($this->request->variable('config', array('' => array('' => '')), true)); $multi_select = array_filter($multi_select); foreach ($multi_select as $field => $settings) { $cfg_array[$field] = !empty($settings) ? $settings : $df_settings[$field]['default']; } }
public function main() { $topic_id = $this->request->variable('t', 0); $post_id = $this->request->variable('p', 0); $forum_id = $this->request->variable('f', 0); $mode = $this->request->variable('mode', ''); $book_submit = $this->request->variable('book', false); $viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic." . $this->php_ext . "", "f={$forum_id}&t={$topic_id}"); $return_link = '<br /><br />' . sprintf($this->user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>'); $body = 'add_bookmark'; if ($mode == 'delete') { $sql = 'DELETE FROM ' . $this->postbookmark_table . "\n\t\t\t\tWHERE user_id = {$this->user->data['user_id']}\n\t\t\t\t\tAND post_id = {$post_id}"; $this->db->sql_query($sql); $message = $this->user->lang['POST_BOOKMARK_REMOVED']; $this->helper->output_response($message, $return_link, $viewtopic_url); } else { if ($mode == 'find') { $body = 'find_bookmark'; $this->helper->get_bookmarks($mode); } else { $bookmark_desc = $this->request->variable('bookmark_desc', '', true); if ($book_submit) { $sql = 'INSERT INTO ' . $this->postbookmark_table . ' ' . $this->db->sql_build_array('INSERT', array('user_id' => $this->user->data['user_id'], 'post_id' => $post_id, 'topic_id' => $topic_id, 'bookmark_time' => time(), 'bookmark_desc' => $bookmark_desc)); $this->db->sql_query($sql); $message = $this->user->lang['POST_BOOKMARK_ADDED']; $this->helper->output_response($message, $return_link, $viewtopic_url); } } } $this->template->assign_vars(array('U_POST_ACTION' => append_sid("{$this->phpbb_root_path}postbookmark", "f={$forum_id}&t={$topic_id}&p={$post_id}&mode={$mode}"))); page_header($this->user->lang['POST_BOOKMARK_ADD']); $this->template->set_filenames(array('body' => $body . '.html')); page_footer(); return new Response('', 200); }
protected function toggle_edit_mode() { $edit_mode = $this->request->variable($this->config['cookie_name'] . '_sm_edit_mode', false, false, \phpbb\request\request_interface::COOKIE); if ($this->request->is_set('edit_mode')) { $edit_mode = $this->request->variable('edit_mode', false); $this->user->set_cookie('sm_edit_mode', $edit_mode, 0); } return $edit_mode; }
public function modify_viewtopic_postrow($event) { $view = $this->request->variable('view', ''); $row = $event['row']; $post_row = $event['post_row']; $post_time = $row['post_created'] ?: $row['post_time']; $post_row['POST_DATE'] = $this->user->format_date($post_time, false, $view == 'print' ? true : false); $event['post_row'] = $post_row; }
/** * @param int $user_id * @param bool $admin * @param bool $auto_login * @param bool $viewonline * @param string $class * @return \Symfony\Component\HttpFoundation\Response * @throws http_exception */ public function submit($user_id, $admin, $auto_login, $viewonline, $class) { $this->user->add_lang_ext('paul999/tfa', 'common'); if (!check_form_key('tfa_login_page')) { throw new http_exception(403, 'FORM_INVALID'); } if (empty($this->user->data['tfa_random']) || $user_id != $this->user->data['tfa_uid']) { throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG'); } $random = $this->request->variable('random', ''); if ($this->user->data['tfa_random'] !== $random || strlen($random) !== 40) { throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG'); } $sql_ary = array('tfa_random' => '', 'tfa_uid' => 0); $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\tWHERE\n\t\t\t\tsession_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND\n\t\t\t\tsession_user_id = '" . (int) $this->user->data['user_id']; $this->db->sql_query($sql); if (empty($class)) { throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG'); } $module = $this->session_helper->findModule($class); if ($module == null) { throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG'); } $redirect = $this->request->variable('redirect', "{$this->root_path}/index.{$this->php_ext}"); try { if (!$module->login($user_id)) { $this->template->assign_var('S_ERROR', $this->user->lang('TFA_INCORRECT_KEY')); $this->session_helper->generate_page($user_id, $admin, $auto_login, $viewonline, $redirect); } } catch (http_exception $ex) { if ($ex->getStatusCode() == 400) { $this->template->assign_var('S_ERROR', $ex->getMessage()); $this->session_helper->generate_page($user_id, $admin, $auto_login, $viewonline, $redirect); } } $old_session_id = $this->user->session_id; if ($admin) { $cookie_expire = time() - 31536000; $this->user->set_cookie('u', '', $cookie_expire); $this->user->set_cookie('sid', '', $cookie_expire); } $result = $this->user->session_create($user_id, $admin, $auto_login, $viewonline); // Successful session creation if ($result === true) { // If admin re-authentication we remove the old session entry because a new one has been created... if ($admin) { // the login array is used because the user ids do not differ for re-authentication $sql = 'DELETE FROM ' . SESSIONS_TABLE . "\n\t\t\t\t\tWHERE session_id = '" . $this->db->sql_escape($old_session_id) . "'\n\t\t\t\t\tAND session_user_id = " . (int) $user_id; $this->db->sql_query($sql); redirect(append_sid("{$this->root_path}adm/index.{$this->php_ext}", false, true, $this->user->data['session_id'])); } redirect(append_sid($redirect, false, true, $this->user->data['session_id'])); } throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG'); }