/** * Executes the command cache:purge. * * Purge the cache (including permissions) and increment the asset_version number * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return null */ protected function execute(InputInterface $input, OutputInterface $output) { $this->config->increment('assets_version', 1); $this->cache->purge(); // Clear permissions $this->auth->acl_clear_prefetch(); phpbb_cache_moderators($this->db, $this->cache, $this->auth); $this->log->add('admin', ANONYMOUS, '', 'LOG_PURGE_CACHE', time(), array()); $output->writeln($this->user->lang('PURGE_CACHE_SUCCESS')); }
/** * GeoModerate settings * */ public function display_settings() { add_form_key(self::FORM_KEY); if ($this->request->is_set_post('submit')) { if (!check_form_key(self::FORM_KEY)) { trigger_error('FORM_INVALID'); } $this->save_settings(); $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'AKISMET_LOG_SETTING_CHANGED'); trigger_error($this->user->lang('ACP_AKISMET_SETTING_SAVED') . adm_back_link($this->u_action)); } $this->template->assign_vars(array('U_ACTION' => $this->u_action, 'GOTHICK_AKISMET_API_KEY' => $this->config['gothick_akismet_api_key'])); }
/** * {@inheritdoc} */ public function run() { $this->user->session_begin(); $this->user->setup('common'); if ($this->config['email_enable']) { include $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext; // functions_messenger.php uses config to determine language paths // Remove when able global $config; $config = $this->config; $messenger = new \messenger(false); $messenger->template('installed', $this->install_config->get('user_language', 'en')); $messenger->to($this->config['board_email'], $this->install_config->get('admin_name')); $messenger->anti_abuse_headers($this->config, $this->user); $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($this->install_config->get('admin_name')), 'PASSWORD' => htmlspecialchars_decode($this->install_config->get('admin_passwd')))); $messenger->send(NOTIFY_EMAIL); } // Login admin // Ugly but works $this->auth->login($this->install_config->get('admin_name'), $this->install_config->get('admin_passwd'), false, true, true); $this->iohandler->set_cookie($this->config['cookie_name'] . '_sid', $this->user->session_id); $this->iohandler->set_cookie($this->config['cookie_name'] . '_u', $this->user->cookie_data['u']); $this->iohandler->set_cookie($this->config['cookie_name'] . '_k', $this->user->cookie_data['k']); // Create log $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_INSTALL_INSTALLED', false, array($this->config['version'])); // Remove install_lock @unlink($this->phpbb_root_path . 'cache/install_lock'); }
function acp_page($id, &$module) { $captcha_vars = array(self::$CONFIG_SITEKEY => 'RECAPTCHA2_SITEKEY', self::$CONFIG_SECRETKEY => 'RECAPTCHA2_SECRETKEY'); $module->tpl_name = '@gothick_recaptcha2/captcha_recaptcha2_acp'; $module->page_title = 'ACP_VC_SETTINGS'; $form_key = 'acp_captcha'; add_form_key($form_key); if ($this->request->is_set_post('submit') && check_form_key($form_key)) { $captcha_vars = array_keys($captcha_vars); foreach ($captcha_vars as $captcha_var) { $value = $this->request->variable($captcha_var, ''); if ($value) { $this->config->set($captcha_var, $value); } } $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_CONFIG_VISUAL'); trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action)); } else { if ($this->request->is_set_post('submit')) { trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); } } foreach ($captcha_vars as $captcha_var => $template_var) { $var = $this->request->is_set_post($captcha_var) ? $this->request->variable($captcha_var, '') : (isset($this->config[$captcha_var]) ? $this->config[$captcha_var] : ''); $this->template->assign_var($template_var, $var); } $this->template->assign_vars(array('CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_service_name(), 'U_ACTION' => $module->u_action)); }
/** * {@inheritDoc} */ public function run() { // Remove old temporary file (perhaps failed uploads?) $last_valid_timestamp = time() - $this->max_file_age; try { $iterator = new \DirectoryIterator($this->plupload_upload_path); foreach ($iterator as $file) { if (strpos($file->getBasename(), $this->config['plupload_salt']) !== 0) { // Skip over any non-plupload files. continue; } if ($file->getMTime() < $last_valid_timestamp) { @unlink($file->getPathname()); } } } catch (\UnexpectedValueException $e) { $this->log->add('critical', $this->user->data['user_id'], $this->user->ip, 'LOG_PLUPLOAD_TIDY_FAILED', false, array($this->plupload_upload_path, $e->getMessage(), $e->getTraceAsString())); } $this->config->set('plupload_last_gc', time(), true); }
/** * Executes the command user:delete * * Deletes a user from the database. An option to delete the user's posts * is available, by default posts will be retained. * * @param InputInterface $input The input stream used to get the options * @param OutputInterface $output The output stream, used to print messages * * @return int 0 if all is well, 1 if any errors occurred */ protected function execute(InputInterface $input, OutputInterface $output) { $name = $input->getArgument('username'); $mode = $input->getOption('delete-posts') ? 'remove' : 'retain'; if ($name) { $io = new SymfonyStyle($input, $output); $user_id = $this->user_loader->load_user_by_username($name); $user_row = $this->user_loader->get_user($user_id); if ($user_row['user_id'] == ANONYMOUS) { $io->error($this->language->lang('NO_USER')); return 1; } if (!function_exists('user_delete')) { require $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext; } user_delete($mode, $user_row['user_id'], $user_row['username']); $this->log->add('admin', ANONYMOUS, '', 'LOG_USER_DELETED', false, array($user_row['username'])); $io->success($this->language->lang('USER_DELETED')); } return 0; }
/** * Handle the ACP page for adding/editing questions. Validate input, display errors and save to database. * * @param int $question_id * @param boolean $submit Determines if the editor should just be shown or that it should be validated/saved. */ protected function acp_add_or_edit_question($question_id = 0, $submit = false) { // Load question data if $question_id exists $question = array(); // Make code analyzer happy if ($question_id && !($question = $this->acp_get_question_data($question_id))) { // Display an error when question not found trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($this->acp_list_url)); } // Get possible question input data $question_input = $this->acp_get_question_input(); // When the form submitted if ($submit && check_form_key($this->acp_form_key)) { if (!$this->validate_input($question_input)) { $this->template->assign_vars(array('S_ERROR' => true)); } else { if ($question_id) { $this->acp_update_question($question_input, $question_id); } else { $this->acp_insert_question($question_input); } $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_CONFIG_VISUAL'); trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link($this->acp_list_url)); } } else { if ($submit) { trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($this->acp_list_url), E_USER_WARNING); } } // If no trigger_error has kicked in yet, display the question fields // Use the $question_input when the form is submitted and a validation error has occured or // when showing the editor for a new question ($question_input will return a set of blank fields) if ($submit || !$question_id) { $this->acp_page_display_editor($question_input); } else { // Use the database question data $this->acp_page_display_editor($question); } }
/** * Executes the command user:activate * * Activate (or deactivate) a user account * * @param InputInterface $input The input stream used to get the options * @param OutputInterface $output The output stream, used to print messages * * @return int 0 if all is well, 1 if any errors occurred */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $name = $input->getArgument('username'); $mode = $input->getOption('deactivate') ? 'deactivate' : 'activate'; $user_id = $this->user_loader->load_user_by_username($name); $user_row = $this->user_loader->get_user($user_id); if ($user_row['user_id'] == ANONYMOUS) { $io->error($this->language->lang('NO_USER')); return 1; } // Check if the user is already active (or inactive) if ($mode == 'activate' && $user_row['user_type'] != USER_INACTIVE) { $io->error($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE')); return 1; } else { if ($mode == 'deactivate' && $user_row['user_type'] == USER_INACTIVE) { $io->error($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE')); return 1; } } // Activate the user account if (!function_exists('user_active_flip')) { require $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext; } user_active_flip($mode, $user_row['user_id']); // Notify the user upon activation if ($mode == 'activate' && $this->config['require_activation'] == USER_ACTIVATION_ADMIN) { $this->send_notification($user_row, $input); } // Log and display the result $msg = $mode == 'activate' ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; $log = $mode == 'activate' ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; $this->log->add('admin', ANONYMOUS, '', $log, false, array($user_row['username'])); $this->log->add('user', ANONYMOUS, '', $log . '_USER', false, array('reportee_id' => $user_row['user_id'])); $io->success($this->language->lang($msg)); return 0; }
/** * {@inheritdoc} */ public function run() { $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); $install_extensions = $this->iohandler->get_input('install-extensions', array()); $all_available_extensions = $this->extension_manager->all_available(); $i = $this->install_config->get('install_extensions_index', 0); $available_extensions = array_slice($all_available_extensions, $i); // Install extensions foreach ($available_extensions as $ext_name => $ext_path) { if (!empty($install_extensions) && $install_extensions !== ['all'] && !in_array($ext_name, $install_extensions)) { continue; } try { $this->extension_manager->enable($ext_name); $extensions = $this->get_extensions(); if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); $this->iohandler->add_success_message(array('CLI_EXTENSION_ENABLE_SUCCESS', $ext_name)); } else { $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); } } catch (\Exception $e) { // Add fail log and continue $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); } $i++; // Stop execution if resource limit is reached if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { break; } } $this->install_config->set('install_extensions_index', $i); if ($i < sizeof($all_available_extensions)) { throw new resource_limit_reached_exception(); } }
/** * Moves topics to a new forum after they have been locked * * @param array $topic_data * @param string $action */ public function move_topics($topic_data, $action) { $first_topic_data = reset($topic_data); $is_enabled = (int) $first_topic_data[$action]; $to_forum_id = (int) $first_topic_data['move_topics_when_locked_to']; /** * This event allows you to perform additional actions before locked topics are moved. * * @event kasimi.movetopicswhenlocked.move_topics_before * @var array topic_data Array with general topic data * @var string action Who triggered the forums to be moved, one of move_topics_when_locked|move_topics_when_locked_solved * @var int is_enabled Whether or not the forum's ACP settings specify the topics to be moved * @var int to_forum_id The destination forum * @since 1.0.2 */ $vars = array('topic_data', 'action', 'is_enabled', 'to_forum_id'); extract($this->dispatcher->trigger_event('kasimi.movetopicswhenlocked.move_topics_before', compact($vars))); // Forum settings are set to not move the topics if (!$is_enabled || !$to_forum_id) { return; } $forum_id = (int) $first_topic_data['forum_id']; // The topics are already in the destination forum if ($forum_id == $to_forum_id) { return; } if (!function_exists('phpbb_get_forum_data')) { include $this->root_path . 'includes/functions_mcp.' . $this->php_ext; } $to_forum_data = phpbb_get_forum_data($to_forum_id, 'f_post'); // The destination forum does not exist if (empty($to_forum_data)) { return; } // The following code is taken from the mcp_move_topic() function in /includes/mpc/mcp_main.php $topics_moved = $topics_moved_unapproved = $topics_moved_softdeleted = 0; $posts_moved = $posts_moved_unapproved = $posts_moved_softdeleted = 0; foreach ($topic_data as $topic_id => $topic_info) { if ($topic_info['topic_visibility'] == ITEM_APPROVED) { $topics_moved++; } else { if ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE) { $topics_moved_unapproved++; } else { if ($topic_info['topic_visibility'] == ITEM_DELETED) { $topics_moved_softdeleted++; } } } $posts_moved += $topic_info['topic_posts_approved']; $posts_moved_unapproved += $topic_info['topic_posts_unapproved']; $posts_moved_softdeleted += $topic_info['topic_posts_softdeleted']; } $this->db->sql_transaction('begin'); if (!function_exists('move_topics')) { include $this->root_path . 'includes/functions_admin.' . $this->php_ext; } // Move topics, but do not resync yet move_topics(array_keys($topic_data), $to_forum_id, false); foreach ($topic_data as $topic_id => $row) { // We add the $to_forum_id twice, because 'forum_id' is updated // when the topic is moved again later. $this->log->add('mod', $this->user->data['user_id'], $this->user->ip, 'LOG_MOVED_LOCKED_TOPIC', false, array('forum_id' => (int) $to_forum_id, 'topic_id' => (int) $topic_id, $row['topic_title'], $row['forum_name'], $to_forum_data[$to_forum_id]['forum_name'])); } $sync_sql = array(); if ($posts_moved) { $sync_sql[$to_forum_id][] = 'forum_posts_approved = forum_posts_approved + ' . (int) $posts_moved; $sync_sql[$forum_id][] = 'forum_posts_approved = forum_posts_approved - ' . (int) $posts_moved; } if ($posts_moved_unapproved) { $sync_sql[$to_forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved + ' . (int) $posts_moved_unapproved; $sync_sql[$forum_id][] = 'forum_posts_unapproved = forum_posts_unapproved - ' . (int) $posts_moved_unapproved; } if ($posts_moved_softdeleted) { $sync_sql[$to_forum_id][] = 'forum_posts_softdeleted = forum_posts_softdeleted + ' . (int) $posts_moved_softdeleted; $sync_sql[$forum_id][] = 'forum_posts_softdeleted = forum_posts_softdeleted - ' . (int) $posts_moved_softdeleted; } if ($topics_moved) { $sync_sql[$to_forum_id][] = 'forum_topics_approved = forum_topics_approved + ' . (int) $topics_moved; if ($topics_moved > 0) { $sync_sql[$forum_id][] = 'forum_topics_approved = forum_topics_approved - ' . (int) $topics_moved; } } if ($topics_moved_unapproved) { $sync_sql[$to_forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved + ' . (int) $topics_moved_unapproved; $sync_sql[$forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved - ' . (int) $topics_moved_unapproved; } if ($topics_moved_softdeleted) { $sync_sql[$to_forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted + ' . (int) $topics_moved_softdeleted; $sync_sql[$forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted - ' . (int) $topics_moved_softdeleted; } foreach ($sync_sql as $forum_id_key => $array) { $sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . implode(', ', $array) . ' WHERE forum_id = ' . (int) $forum_id_key; $this->db->sql_query($sql); } $this->db->sql_transaction('commit'); sync('forum', 'forum_id', array($forum_id, $to_forum_id)); /** * This event allows you to perform additional actions after locked topics have been moved. * * @event kasimi.movetopicswhenlocked.move_topics_after * @var array topic_data Array with general topic data * @var string action Who triggered the forums to be moved, one of move_topics_when_locked|move_topics_when_locked_solved * @var int to_forum_id The destination forum * @var int topics_moved Number of moved topics * @var int topics_moved_unapproved Number of moved unapproved topics * @var int topics_moved_softdeleted Number of moved soft-deleted topics * @var int posts_moved Number of moved posts * @var int posts_moved_unapproved Number of moved unapproved posts * @var int posts_moved_softdeleted Number of moved soft-deleted posts * @since 1.0.2 */ $vars = array('topic_data', 'action', 'to_forum_id', 'topics_moved', 'topics_moved_unapproved', 'topics_moved_softdeleted', 'posts_moved', 'posts_moved_unapproved', 'posts_moved_softdeleted'); extract($this->dispatcher->trigger_event('kasimi.movetopicswhenlocked.move_topics_after', compact($vars))); unset($topic_data); }
/** * Display the options a user can configure for this extension * * @return null * @access public */ public function display_options() { add_form_key('acp_mchat'); $mchat_config = array('mchat_archive_limit' => array('default' => 25, 'validation' => array('num', false, 25, 50)), 'mchat_avatars' => array('default' => 1, 'validation' => array()), 'mchat_bbcode_disallowed' => array('default' => '', 'validation' => array('string', false, 0, 255)), 'mchat_custom_height' => array('default' => 350, 'validation' => array('num', false, 50, 1000)), 'mchat_custom_page' => array('default' => 1, 'validation' => array()), 'mchat_date' => array('default' => 'D M d, Y g:i a', 'validation' => array('string', false, 0, 255)), 'mchat_edit_delete_limit' => array('default' => 0, 'validation' => array()), 'mchat_flood_time' => array('default' => 0, 'validation' => array('num', false, 0, 30)), 'mchat_index_height' => array('default' => 250, 'validation' => array('num', false, 50, 1000)), 'mchat_live_updates' => array('default' => 1, 'validation' => array()), 'mchat_location' => array('default' => 0, 'validation' => array()), 'mchat_max_message_lngth' => array('default' => 500, 'validation' => array('num', false, 0, 500)), 'mchat_message_limit' => array('default' => 10, 'validation' => array('num', false, 10, 30)), 'mchat_message_num' => array('default' => 10, 'validation' => array('num', false, 10, 50)), 'mchat_message_top' => array('default' => 1, 'validation' => array()), 'mchat_new_posts_edit' => array('default' => 0, 'validation' => array()), 'mchat_new_posts_quote' => array('default' => 0, 'validation' => array()), 'mchat_new_posts_reply' => array('default' => 0, 'validation' => array()), 'mchat_new_posts_topic' => array('default' => 0, 'validation' => array()), 'mchat_on_index' => array('default' => 1, 'validation' => array()), 'mchat_override_min_post_chars' => array('default' => 0, 'validation' => array()), 'mchat_override_smilie_limit' => array('default' => 0, 'validation' => array()), 'mchat_pause_on_input' => array('default' => 0, 'validation' => array()), 'mchat_prune' => array('default' => 0, 'validation' => array()), 'mchat_prune_num' => array('default' => 0, 'validation' => array()), 'mchat_refresh' => array('default' => 10, 'validation' => array('num', false, 5, 60)), 'mchat_rules' => array('default' => '', 'validation' => array('string', false, 0, 255)), 'mchat_static_message' => array('default' => '', 'validation' => array('string', false, 0, 255)), 'mchat_stats_index' => array('default' => 0, 'validation' => array()), 'mchat_timeout' => array('default' => 0, 'validation' => array('num', false, 0, (int) $this->config['session_length'])), 'mchat_whois' => array('default' => 1, 'validation' => array()), 'mchat_whois_refresh' => array('default' => 60, 'validation' => array('num', false, 30, 300)), 'mchat_simple_msg' => array('default' => 0, 'validation' => array()), 'mchat_on_viewforum' => array('default' => 0, 'validation' => array()), 'mchat_on_viewtopic' => array('default' => 0, 'validation' => array())); if ($this->request->is_set_post('submit')) { if (!function_exists('validate_data')) { include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext; } $mchat_new_config = array(); $validation = array(); foreach ($mchat_config as $key => $value) { $mchat_new_config[$key] = $this->request->variable($key, $value['default'], is_string($value['default'])); if (!empty($value['validation'])) { $validation[$key] = $value['validation']; } } $error = validate_data($mchat_new_config, $validation); if (!check_form_key('acp_mchat')) { $error[] = 'FORM_INVALID'; } // Replace "error" strings with their real, localised form // The /e modifier is deprecated since PHP 5.5.0 //$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$this->user->lang('\\1'))) ? \$this->user->lang('\\1') : '\\1'", $error); foreach ($error as $i => $err) { $lang = $this->user->lang($err); if (!empty($lang)) { $error[$i] = $lang; } } if (empty($error)) { // Set the options the user configured foreach ($mchat_new_config as $config_name => $config_value) { $this->config->set($config_name, $config_value); } // Add an entry into the log table $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_CONFIG_UPDATE'); trigger_error($this->user->lang('MCHAT_CONFIG_SAVED') . adm_back_link($this->u_action)); } } $dateformat_options = ''; foreach ($this->user->lang['dateformats'] as $format => $null) { $dateformat_options .= '<option value="' . $format . '"' . ($format == $this->config['mchat_date'] ? ' selected="selected"' : '') . '>'; $dateformat_options .= $this->user->format_date(time(), $format, false) . (strpos($format, '|') !== false ? $this->user->lang('VARIANT_DATE_SEPARATOR') . $this->user->format_date(time(), $format, true) : ''); $dateformat_options .= '</option>'; } $s_custom = false; $dateformat_options .= '<option value="custom"'; if (!isset($this->user->lang['dateformats'][$this->config['mchat_date']])) { $dateformat_options .= ' selected="selected"'; $s_custom = true; } $dateformat_options .= '>' . $this->user->lang('MCHAT_CUSTOM_DATEFORMAT') . '</option>'; $template_variables = array(); foreach ($mchat_config as $key => $value) { $template_variables[strtoupper($key)] = $this->config[$key]; } $this->template->assign_vars(array_merge($template_variables, array('MCHAT_ERROR' => !empty($error) ? implode('<br />', $error) : '', 'MCHAT_VERSION' => $this->config['mchat_version'], 'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => sprintf($this->user->lang('MCHAT_BBCODES_DISALLOWED_EXPLAIN'), '<a href="' . append_sid("{$this->phpbb_root_path}adm/index.{$this->php_ext}", 'i=bbcodes', true, $this->user->session_id) . '">', '</a>'), 'L_MCHAT_TIMEOUT_EXPLAIN' => sprintf($this->user->lang('MCHAT_USER_TIMEOUT_EXPLAIN'), '<a href="' . append_sid("{$this->phpbb_root_path}adm/index.{$this->php_ext}", 'i=board&mode=load', true, $this->user->session_id) . '">', '</a>', $this->config['session_length']), 'S_MCHAT_DATEFORMAT_OPTIONS' => $dateformat_options, 'S_CUSTOM_DATEFORMAT' => $s_custom, 'U_ACTION' => $this->u_action))); // Version check $this->user->add_lang(array('install', 'acp/extensions', 'migrator')); $ext_name = 'dmzx/mchat'; $md_manager = new \phpbb\extension\metadata_manager($ext_name, $this->config, $this->phpbb_extension_manager, $this->template, $this->user, $this->phpbb_root_path); try { $this->metadata = $md_manager->get_metadata('all'); } catch (\phpbb\extension\exception $e) { trigger_error($e, E_USER_WARNING); } $md_manager->output_template_data(); try { $updates_available = $this->version_check($md_manager, $this->request->variable('versioncheck_force', false)); $this->template->assign_vars(array('S_UP_TO_DATE' => empty($updates_available), 'S_VERSIONCHECK' => true, 'UP_TO_DATE_MSG' => $this->user->lang(empty($updates_available) ? 'UP_TO_DATE' : 'NOT_UP_TO_DATE', $md_manager->get_metadata('display-name')))); foreach ($updates_available as $branch => $version_data) { $this->template->assign_block_vars('updates_available', $version_data); } } catch (\RuntimeException $e) { $this->template->assign_vars(array('S_VERSIONCHECK_STATUS' => $e->getCode(), 'VERSIONCHECK_FAIL_REASON' => $e->getMessage() !== $this->user->lang('VERSIONCHECK_FAIL') ? $e->getMessage() : '')); } }
/** * @param $report_id * @param \phpbb\log\log_interface $phpbb_logger * @param $user * @return bool Whether or not the report was closed successuflly */ public function deleteReport($report_id, \phpbb\log\log_interface $phpbb_logger, $user) { $report_id = (int) $report_id; $sql = 'DELETE FROM ' . $this->tables['reports'] . ' WHERE report_id=' . $report_id; if ($this->db->sql_query($sql)) { $phpbb_logger->add('mod', $user->data['user_id'], $user->ip, self::LOG_REPORT_DELETED, false); return true; } return false; }
/** * {@inheritdoc} */ public function run() { $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); $update_info = $this->install_config->get('update_info_unprocessed', []); $version_from = !empty($update_info) ? $update_info['version']['from'] : $this->config['version_update_from']; if (!empty($version_from)) { $update_extensions = $this->iohandler->get_input('update-extensions', []); // Create list of default extensions that need to be enabled in update $default_update_extensions = []; foreach (self::$default_extensions_update as $version => $extensions) { if ($this->update_helper->phpbb_version_compare($version_from, $version, '<=')) { $default_update_extensions = array_merge($default_update_extensions, $extensions); } } $all_available_extensions = $this->extension_manager->all_available(); $i = $this->install_config->get('update_extensions_index', 0); $available_extensions = array_slice($all_available_extensions, $i); // Update available extensions foreach ($available_extensions as $ext_name => $ext_path) { // Update extensions if: // 1) Extension is currently enabled // 2) Extension was implicitly defined as needing an update // 3) Extension was newly added as default phpBB extension in // this update and should be enabled by default. if ($this->extension_manager->is_enabled($ext_name) || in_array($ext_name, $update_extensions) || in_array($ext_name, $default_update_extensions)) { try { $extension_enabled = $this->extension_manager->is_enabled($ext_name); if ($extension_enabled) { $this->extension_manager->disable($ext_name); } $this->extension_manager->enable($ext_name); $extensions = $this->get_extensions(); if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_UPDATE', time(), array($ext_name)); $this->iohandler->add_success_message(array('CLI_EXTENSION_UPDATE_SUCCESS', $ext_name)); } else { $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name)); } // Disable extensions if it was disabled by the admin before if (!$extension_enabled && !in_array($ext_name, $default_update_extensions)) { $this->extension_manager->disable($ext_name); } } catch (\Exception $e) { // Add fail log and continue $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name)); } } $i++; // Stop execution if resource limit is reached if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { break; } } $this->install_config->set('update_extensions_index', $i); if ($i < sizeof($all_available_extensions)) { throw new resource_limit_reached_exception(); } } $this->config->delete('version_update_from'); $this->cache->purge(); $this->config->increment('assets_version', 1); }
/** * Event: core.mcp_lock_unlock_after */ public function mcp_lock_unlock_after($event) { if ($event['action'] == 'lock') { $topic_ids = $event['ids']; $topic_id = (int) current($topic_ids); $topic_data = $event['data']; $forum_id = (int) $topic_data[$topic_id]['forum_id']; $to_forum_id = (int) $topic_data[$topic_id]['move_topics_to']; $forum_data = phpbb_get_forum_data($to_forum_id); $to_forum_name = $forum_data[$to_forum_id]['forum_name']; $topics_moved = $topics_moved_unapproved = $topics_moved_softdeleted = 0; foreach ($topic_data as $topic_id => $topic_info) { if ($topic_info['topic_visibility'] == ITEM_APPROVED) { $topics_moved++; } else { if ($topic_info['topic_visibility'] == ITEM_UNAPPROVED || $topic_info['topic_visibility'] == ITEM_REAPPROVE) { $topics_moved_unapproved++; } else { if ($topic_info['topic_visibility'] == ITEM_DELETED) { $topics_moved_softdeleted++; } } } } $this->db->sql_transaction('begin'); // Move topics, but do not resync yet if (!function_exists('move_topics')) { include $this->root_path . 'includes/functions_admin.' . $this->php_ext; } move_topics($topic_ids, $to_forum_id, false); foreach ($topic_data as $topic_id => $row) { // We add the $to_forum_id twice, because 'forum_id' is updated // when the topic is moved again later. $this->log->add('mod', $this->user->data['user_id'], $this->user->ip, 'LOG_MOVED_LOCKED_TOPIC', false, array('forum_id' => $to_forum_id, 'topic_id' => $topic_id, $row['topic_title'], $row['forum_name'], $to_forum_name)); } unset($topic_data); $sync_sql = array(); if ($topics_moved) { $sync_sql[$to_forum_id][] = 'forum_topics_approved = forum_topics_approved + ' . (int) $topics_moved; if ($topics_moved > 0) { $sync_sql[$forum_id][] = 'forum_topics_approved = forum_topics_approved - ' . (int) $topics_moved; } } if ($topics_moved_unapproved) { $sync_sql[$to_forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved + ' . (int) $topics_moved_unapproved; $sync_sql[$forum_id][] = 'forum_topics_unapproved = forum_topics_unapproved - ' . (int) $topics_moved_unapproved; } if ($topics_moved_softdeleted) { $sync_sql[$to_forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted + ' . (int) $topics_moved_softdeleted; $sync_sql[$forum_id][] = 'forum_topics_softdeleted = forum_topics_softdeleted - ' . (int) $topics_moved_softdeleted; } foreach ($sync_sql as $forum_id_key => $array) { $sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . implode(', ', $array) . ' WHERE forum_id = ' . $forum_id_key; $this->db->sql_query($sql); } $this->db->sql_transaction('commit'); sync('forum', 'forum_id', array($forum_id, $to_forum_id)); } }