public function main($id, $mode) { global $config, $request, $template, $user; $this->config = $config; $this->request = $request; $this->template = $template; $this->user = $user; // Add the common lang file $this->user->add_lang(array('acp/common')); // Add the board snowstormlights ACP lang file $this->user->add_lang_ext('prosk8er/snowstormlights', 'info_acp_snowstorm_lights'); // Load a template from adm/style for our ACP page $this->tpl_name = 'snowstorm_lights'; // Set the page title for our ACP page $this->page_title = $user->lang['ACP_SNOWSTORM_LIGHTS']; // Define the name of the form for use as a form key $form_key = 'acp_snowstorm_lights'; add_form_key($form_key); // If form is submitted or previewed if ($this->request->is_set_post('submit')) { // Test if form key is valid if (!check_form_key($form_key)) { trigger_error('FORM_INVALID'); } // Store the config enable/disable state $scl_enabled = $this->request->variable('scl_enabled', 0); $this->config->set('scl_enabled', $scl_enabled); $snow_enabled = $request->variable('snow_enabled', 0); $this->config->set('snow_enabled', $snow_enabled); // Output message to user for the update trigger_error($this->user->lang('SNOWSTORM_LIGHTS_SAVED') . adm_back_link($this->u_action)); } // Output data to the template $this->template->assign_vars(array('SCL_ENABLED' => isset($this->config['scl_enabled']) ? $this->config['scl_enabled'] : '', 'SNOW_ENABLED' => isset($this->config['snow_enabled']) ? $this->config['snow_enabled'] : '', 'U_ACTION' => $this->u_action)); }
public function main($id, $mode) { global $config, $request, $template, $user; $this->config = $config; $this->request = $request; $this->template = $template; $this->user = $user; $this->user->add_lang('acp/common'); $this->user->add_lang_ext('phpbbmodders/holidayflare', 'holidayflare_acp'); $this->tpl_name = 'acp_holidayflare'; $this->page_title = $this->user->lang('ACP_HOLIDAYFLARE'); $form_key = 'acp_holidayflare'; add_form_key($form_key); if ($this->request->is_set_post('submit')) { if (!check_form_key($form_key)) { trigger_error($user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); } /* XMAS Start */ $enable_xmas = $this->request->variable('enable_xmas', 0); $this->config->set('enable_xmas', $enable_xmas); /* XMAS Stop */ /* Valentine Start */ $enable_valentine = $this->request->variable('enable_valentine', 0); $this->config->set('enable_valentine', $enable_valentine); /* Valentine Stop */ trigger_error($this->user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action)); } $this->template->assign_vars(array('S_ENABLE_XMAS' => isset($this->config['enable_xmas']) ? $this->config['enable_xmas'] : '', 'S_ENABLE_VALENTINE' => isset($this->config['enable_valentine']) ? $this->config['enable_valentine'] : '', 'U_ACTION' => $this->u_action)); }
/** * Tries to acquire the lock by updating * the configuration variable in the database. * * As a lock may only be held by one process at a time, lock * acquisition may fail if another process is holding the lock * or if another process obtained the lock but never released it. * Locks are forcibly released after a timeout of 1 hour. * * @return bool true if lock was acquired * false otherwise */ public function acquire() { if ($this->locked) { return false; } if (!isset($this->config[$this->config_name])) { $this->config->set($this->config_name, '0', false); } $lock_value = $this->config[$this->config_name]; // make sure lock cannot be acquired by multiple processes if ($lock_value) { // if the other process is running more than an hour already we have to assume it // aborted without cleaning the lock $time = explode(' ', $lock_value); $time = $time[0]; if ($time + 3600 >= time()) { return false; } } $this->unique_id = time() . ' ' . unique_id(); // try to update the config value, if it was already modified by another // process we failed to acquire the lock. $this->locked = $this->config->set_atomic($this->config_name, $lock_value, $this->unique_id, false); return $this->locked; }
/** * Run the cronjob. */ public function run() { $time = strtotime('- ' . $this->config['ajaxshoutbox_prune_days'] . ' days'); $sql = 'SELECT * FROM ' . $this->table . ' WHERE post_time <= ' . $time; $result = $this->db->sql_query($sql); $canpush = $this->push->canPush(); $delete = array(); while ($row = $this->db->sql_fetchrow($result)) { if ($canpush) { if ($this->push->delete($row['shout_id']) !== false) { $delete[] = $row['shout_id']; } } else { $delete[] = $row['shout_id']; } } $this->db->sql_freeresult(); if (sizeof($delete)) { $sql = 'DELETE FROM ' . $this->table . ' WHERE ' . $this->db->sql_in_set('shout_id', $delete); $this->db->sql_query($sql); $uuid = $this->user->data['user_id']; if (!$uuid) { $uuid = ANONYMOUS; } $this->log->add('admin', $uuid, $this->user->ip, 'LOG_AJAX_SHOUTBOX_PRUNED', time(), array(sizeof($delete))); } $this->config->set('shoutbox_prune_gc', time(), false); }
/** * Update an existing config setting. * * @param string $config_name The name of the config setting you would * like to update * @param mixed $config_value The value of the config setting * @return null * @throws \phpbb\db\migration\exception */ public function update($config_name, $config_value) { if (!isset($this->config[$config_name])) { throw new \phpbb\db\migration\exception('CONFIG_NOT_EXIST', $config_name); } $this->config->set($config_name, $config_value); }
/** * Run this cronjob * @see \phpbb\cron\task\task::run() */ public function run() { $now = time(); // Extensions $available_updates = $this->version_checker->check_ext_versions(); // phpBB $phpbb_update = $this->version_checker->check_phpbb_version(); if (is_array($available_updates) && is_array($phpbb_update)) { $available_updates = array_merge($available_updates, $phpbb_update); } else { if (is_array($phpbb_update)) { //TODO: Store errors, this shouldn't happen, even with no updates there should be an array $available_updates = $phpbb_update; } else { // phpBB Version check failed //TODO: Store errors and if they happen too often in a row, create a new notification. } } if (is_array($available_updates)) { foreach ($available_updates as $extname => $data) { $notify_data = array('name' => $extname, 'version' => $data['new'], 'old_version' => $data['current']); $notification_type = $extname === 'phpbb' ? 'phpbb_update' : 'ext_update'; $this->notification_manager->add_notifications('gn36.versionchecknotifier.notification.type.' . $notification_type, $notify_data); } } $this->config->set('versionchecknotifier_last_gc', $now, true); }
/** * Runs this cron task. * * @return null */ public function run() { $sql = 'UPDATE ' . RATING_TABLE . ' SET `top_hits_before` = `top_hits`, `top_hosts_before` = `top_hosts`, `top_in_before` = `top_in`, `top_out_before` = `top_out`, `top_hits` = 0, `top_hosts` = 0, `top_in` = 0, `top_out` = 0 WHERE `top_id` BETWEEN 1 AND 100000 AND top_hosts > 1'; $this->db->sql_query($sql); $this->db->sql_query('TRUNCATE TABLE ' . RATING_CLICK_TABLE); $this->db->sql_query('TRUNCATE TABLE ' . RATING_HITS_TABLE); $this->db->sql_query('TRUNCATE TABLE ' . RATING_ONLINE_TABLE); $this->db->sql_query('OPTIMIZE TABLE ' . RATING_TABLE); $this->db->sql_query('OPTIMIZE TABLE ' . RATING_CLICK_TABLE); $this->db->sql_query('OPTIMIZE TABLE ' . RATING_HITS_TABLE); $this->db->sql_query('OPTIMIZE TABLE ' . RATING_ONLINE_TABLE); //$this->config->set('rating_platforms_active', 0); $timestamp = time(); $timezone = new \DateTimeZone($this->config['board_timezone']); $time = $this->user->get_timestamp_from_format('Y-m-d H:i:s', date('Y', $timestamp) . '-' . date('m', $timestamp) . '-' . date('d', $timestamp) . ' 00:00:00', $timezone); $this->config->set('top_rating_last_gc', $time); }
/** * @param string $list_name whitelist or blacklist * @param string $u_action phpbb acp-u_action */ private function manage_list($u_action, $list_name) { $list_name_upper = strtoupper($list_name); // Define the name of the form for use as a form key $form_name = 'topictags'; add_form_key($form_name); $errors = array(); if ($this->request->is_set_post('submit')) { if (!check_form_key($form_name)) { trigger_error('FORM_INVALID'); } $this->config->set(prefixes::CONFIG . '_' . $list_name . '_enabled', $this->request->variable(prefixes::CONFIG . '_' . $list_name . '_enabled', 0)); $list = rawurldecode(base64_decode($this->request->variable(prefixes::CONFIG . '_' . $list_name, ''))); if (!empty($list)) { $list = json_decode($list, true); $tags = array(); for ($i = 0, $size = sizeof($list); $i < $size; $i++) { $tags[] = $list[$i]['text']; } $list = json_encode($tags); } // store the list $this->config_text->set(prefixes::CONFIG . '_' . $list_name, $list); trigger_error($this->user->lang('TOPICTAGS_' . $list_name_upper . '_SAVED') . adm_back_link($u_action)); } // display $list = $this->config_text->get(prefixes::CONFIG . '_' . $list_name); $list = base64_encode(rawurlencode($list)); $this->template->assign_vars(array('TOPICTAGS_VERSION' => $this->user->lang('TOPICTAGS_INSTALLED', $this->config[prefixes::CONFIG . '_version']), 'TOPICTAGS_' . $list_name_upper . '_ENABLED' => $this->config[prefixes::CONFIG . '_' . $list_name . '_enabled'], 'TOPICTAGS_' . $list_name_upper => $list, 'S_RH_TOPICTAGS_INCLUDE_NG_TAGS_INPUT' => true, 'S_RH_TOPICTAGS_INCLUDE_CSS' => true, 'TOPICTAGS_CONVERT_SPACE_TO_MINUS' => $this->config[prefixes::CONFIG . '_convert_space_to_minus'] ? 'true' : 'false', 'S_ERROR' => sizeof($errors) ? true : false, 'ERROR_MSG' => implode('<br />', $errors), 'U_ACTION' => $u_action)); }
/** * Runs this cron task. * * @return null */ public function run() { $this->config->set('sitemaker_blocks_cleanup_last_gc', time()); $routes = $this->clean_styles(); $this->clean_routes($routes); $this->clean_blocks(); $this->clean_custom_blocks(); }
/** * Run cron task */ public function run() { require $this->ext_root_path . 'common.' . $this->php_ext; $this->config->set('titania_last_cleanup', time(), true); $revisions = $this->get_incomplete_revisions(); $this->delete_revisions(array_keys($revisions)); $attachments = array_merge($this->get_orphan_attachments(), $this->get_revision_attachments($revisions)); $this->delete_attachments($attachments); }
/** * Set the options a user can configure * * @return null * @access protected */ protected function set_options() { $this->config->set('userranks_enable', $this->request->variable('userranks_enable', 0)); $this->config->set('userranks_header_link', $this->request->variable('userranks_header_link', 0)); $this->config->set('userranks_ignore_bots', $this->request->variable('userranks_ignore_bots', 0)); $this->config->set('userranks_members', $this->request->variable('userranks_members', 0)); $this->config->set('userranks_members_admin', $this->request->variable('userranks_members_admin', 0)); $this->config->set('userranks_special', $this->request->variable('userranks_special', 0)); $this->config->set('userranks_special_admin', $this->request->variable('userranks_special_admin', 0)); }
/** * Return unique id * * @param string $extra Additional entropy * * @return string Unique id */ public function unique_id($extra = 'c') { static $dss_seeded = false; $val = $this->config['rand_seed'] . microtime(); $val = md5($val); $this->config['rand_seed'] = md5($this->config['rand_seed'] . $val . $extra); if ($dss_seeded !== true && $this->config['rand_seed_last_update'] < time() - rand(1, 10)) { $this->config->set('rand_seed_last_update', time(), true); $this->config->set('rand_seed', $this->config['rand_seed'], true); $dss_seeded = true; } return substr($val, 4, 16); }
/** * Main ACP module * * @param int $id * @param string $mode * @access public */ public function main($id, $mode) { $this->tpl_name = 'acp_topic_preview'; $this->page_title = $this->user->lang('TOPIC_PREVIEW'); $form_key = 'acp_topic_preview'; add_form_key($form_key); if ($this->request->is_set_post('submit')) { if (!check_form_key($form_key)) { trigger_error($this->user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); } $this->config->set('topic_preview_limit', abs($this->request->variable('topic_preview_limit', 0))); // abs() no negative values $this->config->set('topic_preview_width', abs($this->request->variable('topic_preview_width', 0))); // abs() no negative values $this->config->set('topic_preview_delay', abs($this->request->variable('topic_preview_delay', 0))); // abs() no negative values $this->config->set('topic_preview_drift', $this->request->variable('topic_preview_drift', 0)); $this->config->set('topic_preview_avatars', $this->request->variable('topic_preview_avatars', 0)); $this->config->set('topic_preview_last_post', $this->request->variable('topic_preview_last_post', 0)); $this->config->set('topic_preview_strip_bbcodes', $this->request->variable('topic_preview_strip_bbcodes', '')); $styles = $this->get_styles(); foreach ($styles as $row) { $this->set_style_theme($row['style_id'], $this->request->variable('style_' . $row['style_id'], '')); } trigger_error($this->user->lang('CONFIG_UPDATED') . adm_back_link($this->u_action)); } $styles = $this->get_styles(); foreach ($styles as $row) { $this->template->assign_block_vars('styles', array('STYLE_ID' => $row['style_id'], 'STYLE_THEME' => $this->user->lang('TOPIC_PREVIEW_THEME', $row['style_name']), 'STYLE_THEME_EXPLAIN' => $this->user->lang('TOPIC_PREVIEW_THEME_EXPLAIN', $row['style_name']), 'THEME_OPTIONS' => $this->theme_options($row['topic_preview_theme']))); } $this->template->assign_vars(array('TOPIC_PREVIEW_LIMIT' => $this->config['topic_preview_limit'], 'TOPIC_PREVIEW_WIDTH' => $this->config['topic_preview_width'], 'TOPIC_PREVIEW_DELAY' => $this->config['topic_preview_delay'], 'TOPIC_PREVIEW_DRIFT' => $this->config['topic_preview_drift'], 'S_TOPIC_PREVIEW_AVATARS' => $this->config['topic_preview_avatars'], 'S_TOPIC_PREVIEW_LAST_POST' => $this->config['topic_preview_last_post'], 'TOPIC_PREVIEW_STRIP' => $this->config['topic_preview_strip_bbcodes'], 'U_ACTION' => $this->u_action)); }
function main($id, $mode) { global $phpbb_container, $user, $template, $config, $request; $this->phpbb_container = $phpbb_container; $this->user = $user; $this->template = $template; $this->config = $config; $this->request = $request; $this->log = $this->phpbb_container->get('log'); $this->tpl_name = 'acp_codebox_plus'; $this->page_title = $this->user->lang('CODEBOX_PLUS_TITLE'); add_form_key('o0johntam0o/acp_codebox_plus'); if ($this->request->is_set_post('submit')) { if (!check_form_key('o0johntam0o/acp_codebox_plus')) { trigger_error('FORM_INVALID'); } $this->config->set('codebox_plus_syntax_highlighting', $request->variable('codebox_plus_syntax_highlighting', 0)); $this->config->set('codebox_plus_expanded', $request->variable('codebox_plus_expanded', 0)); $this->config->set('codebox_plus_download', $request->variable('codebox_plus_download', 0)); $this->config->set('codebox_plus_login_required', $request->variable('codebox_plus_login_required', 0)); $this->config->set('codebox_plus_prevent_bots', $request->variable('codebox_plus_prevent_bots', 0)); $this->config->set('codebox_plus_captcha', $request->variable('codebox_plus_captcha', 0)); $this->config->set('codebox_plus_max_attempt', $request->variable('codebox_plus_max_attempt', 0)); $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'CODEBOX_PLUS_LOG_MSG'); trigger_error($this->user->lang('CODEBOX_PLUS_SAVED') . adm_back_link($this->u_action)); } $this->template->assign_vars(array('U_ACTION' => $this->u_action, 'S_CODEBOX_PLUS_VERSION' => isset($this->config['codebox_plus_version']) ? $this->config['codebox_plus_version'] : 0, 'S_CODEBOX_PLUS_SYNTAX_HIGHLIGHTING' => isset($this->config['codebox_plus_syntax_highlighting']) ? $this->config['codebox_plus_syntax_highlighting'] : 0, 'S_CODEBOX_PLUS_EXPANDED' => isset($this->config['codebox_plus_expanded']) ? $this->config['codebox_plus_expanded'] : 0, 'S_CODEBOX_PLUS_DOWNLOAD' => isset($this->config['codebox_plus_download']) ? $this->config['codebox_plus_download'] : 0, 'S_CODEBOX_PLUS_LOGIN_REQUIRED' => isset($this->config['codebox_plus_login_required']) ? $this->config['codebox_plus_login_required'] : 0, 'S_CODEBOX_PLUS_PREVENT_BOTS' => isset($this->config['codebox_plus_prevent_bots']) ? $this->config['codebox_plus_prevent_bots'] : 0, 'S_CODEBOX_PLUS_CAPTCHA' => isset($this->config['codebox_plus_captcha']) ? $this->config['codebox_plus_captcha'] : 0, 'S_CODEBOX_PLUS_MAX_ATTEMPT' => isset($this->config['codebox_plus_max_attempt']) ? $this->config['codebox_plus_max_attempt'] : 0)); }
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)); } } }
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)); } } }
/** * Perform table SQL query and return any messages * * @param string $query should either be OPTIMIZE TABLE, REPAIR TABLE, or CHECK TABLE * @param string $tables comma delineated string of all tables to be processed * @param int $disable_board the users option to disable the board during run time * @return string $message any errors or status information * @access protected */ protected function table_maintenance($query, $tables, $disable_board = 0) { // Disable the board if admin selected this option if ($disable_board) { $this->config->set('board_disable', 1); } $message = ''; $result = $this->db->sql_query($query . ' ' . $this->db->sql_escape($tables)); while ($row = $this->db->sql_fetchrow($result)) { // Build a message only for optimize/repair errors, or if check table is run if (in_array(strtolower($row['Msg_type']), array('error', 'info', 'note', 'warning')) || $query == 'CHECK TABLE') { $message .= '<br />' . substr($row['Table'], strpos($row['Table'], '.') + 1) . ' ... ' . $row['Msg_type'] . ': ' . $row['Msg_text']; } } $this->db->sql_freeresult($result); // Enable the board again if admin selected this option if ($disable_board) { $this->config->set('board_disable', 0); } // Clear cache to ensure board is re-enabled for all users $this->cache->purge(); // Let's add an extra line break if there are messages, it looks better $message = !empty($message) ? '<br />' . $message : ''; return $message; }
protected function setUp() { global $config, $phpbb_root_path, $phpEx; $config = new \phpbb\config\config(array()); $this->config = $config; $this->config->set('remote_upload_verify', 0); $this->request = $this->getMock('\\phpbb\\request\\request'); $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper(); $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $phpbb_root_path, new \phpbb\mimetype\guesser(array('mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser())))); $this->factory = new \phpbb\files\factory($this->container); $this->path = __DIR__ . '/fixture/'; $this->phpbb_root_path = $phpbb_root_path; }
/** * Validate config vars and update config table if needed * * @return null */ public function process() { $submit = $this->request->is_set_post('submit') ? true : false; $this->new_config = $this->config; $cfg_array = $this->request->is_set('config') ? $this->request->variable('config', array('' => ''), true) : $this->new_config; $error = array(); // We validate the complete config if whished validate_config_vars($this->display_vars['vars'], $cfg_array, $error); // Do not write values if there is an error if (sizeof($error)) { $submit = false; } // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($this->display_vars['vars'] as $config_name => $null) { if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) { continue; } $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; if ($submit) { $this->config->set($config_name, $config_value); } } if ($submit) { $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'DIR_CONFIG_SETTINGS'); trigger_error($this->user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } $this->template->assign_vars(array('L_TITLE' => $this->user->lang[$this->display_vars['title']], 'L_TITLE_EXPLAIN' => $this->user->lang[$this->display_vars['title'] . '_EXPLAIN'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action)); }
/** * {@inheritdoc} */ public function install($module_id) { $this->config->set('board3_pay_acc_' . $module_id, '*****@*****.**'); $this->config->set('board3_pay_custom_' . $module_id, true); $this->config->set('board3_pay_default_' . $module_id, 'EUR'); return true; }
/** * Get unique id for all indexes. * * @return string */ protected function get_id() { if (!$this->config['fulltext_sphinx_id']) { $this->config->set('fulltext_sphinx_id', unique_id()); } return $this->config['fulltext_sphinx_id']; }
/** * Store selected forums * * @param string $key Key name * * @return null * @access public */ public function store_selected_forums($key) { // Get selected extensions $values = $this->request->variable($key, array(0 => '')); $news = implode(',', $values); $this->config->set($key, $news); }
/** * Saves the selected poll options to the topic * * @param array $sql_data The array of data to be inserted in the database, modified here * @return void */ public function save_config_for_polls(&$sql_data) { $options = $this->get_possible_options(); // Gather the options we should set foreach ($options as $option => $default_val) { if (strpos($option, 'wolfsblvt_poll_end_') !== false) { continue; // already processed } else { $sql_data[TOPICS_TABLE]['sql'][$option] = $this->request->variable($option, $default_val); } } // Check if this change affects the next run for notifications if ($this->config['wolfsblvt.advancedpolls.activate_notifications']) { $hidden_poll = isset($sql_data[TOPICS_TABLE]['sql']['wolfsblvt_poll_votes_hide']) && $sql_data[TOPICS_TABLE]['sql']['wolfsblvt_poll_votes_hide'] ? true : false; if ($hidden_poll && $sql_data[TOPICS_TABLE]['sql']['poll_start'] > 0 && $sql_data[TOPICS_TABLE]['sql']['poll_length'] > 0) { $last_run = $this->config['wolfsblvt.advancedpolls.pollend_last_gc']; $next_run_delay = $this->config['wolfsblvt.advancedpolls.pollend_gc']; $poll_end = $sql_data[TOPICS_TABLE]['sql']['poll_start'] + $sql_data[TOPICS_TABLE]['sql']['poll_length']; if ($poll_end > $last_run && (!$next_run_delay || $last_run > $poll_end - $next_run_delay)) { $this->config->set('wolfsblvt.advancedpolls.pollend_gc', $poll_end - $last_run); } } } }
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)); }
/** * Store selected filetypes * * @param string $key Key name * @param int $module_id Module ID * * @return null */ public function store_filetypes($key, $module_id) { // Get selected extensions $values = $this->request->variable($key, array(0 => '')); $filetypes = implode(',', $values); $this->config->set('board3_attachments_filetype_' . $module_id, $filetypes); }
/** * Set the options a user can configure * * @return null * @access protected */ protected function set_options() { $this->config->set('copy_topic_count_override', $this->request->variable('copy_topic_count_override', '0')); $this->config->set('copy_topic_enable', $this->copy_enabled); $this->config->set('copy_topic_from_forum', $this->from_forum); $this->config->set('copy_topic_to_forum', $this->to_forum); }
/** * Delete all notifications older than a certain time * * @param int $timestamp Unix timestamp to delete all notifications that were created before * @param bool $only_read True (default) to only prune read notifications */ public function prune_notifications($timestamp, $only_read = true) { $sql = 'DELETE FROM ' . $this->notifications_table . ' WHERE notification_time < ' . (int) $timestamp . ($only_read ? ' AND notification_read = 1' : ''); $this->db->sql_query($sql); $this->config->set('read_notification_last_gc', time(), false); }
/** * Abstracted method to do the submit part of the acp. Checks values, saves them * and displays the message. * If error happens, Error is shown and config not saved. (so this method quits and returns false. * * @param array $display_vars The display vars for this acp site * @param array $special_functions Assoziative Array with config values where special functions should run on submit instead of simply save the config value. Array should contain 'config_value' => function ($this) { function code here }, or 'config_value' => null if no function should run. * @return bool Submit valid or not. */ protected function do_submit_stuff($display_vars, $special_functions = []) { $this->new_config = $this->config; $cfg_array = $this->request->is_set('config') ? $this->request->variable('config', ['' => ''], true) : $this->new_config; $error = isset($error) ? $error : []; validate_config_vars($display_vars['vars'], $cfg_array, $error); if (!check_form_key($this->form_key)) { $error[] = $this->user->lang['FORM_INVALID']; } // Do not write values if there is an error if (sizeof($error)) { $submit = false; return false; } // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $null) { // We want to skip that, or run the function. (We do this before checking if there is a request value set for it, // cause maybe we want to run a function anyway, based on whatever. We can check stuff manually inside this function) if (is_array($special_functions) && array_key_exists($config_name, $special_functions)) { $func = $special_functions[$config_name]; if (isset($func) && is_callable($func)) { $func(); } continue; } if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) { continue; } // Sets the config value $this->new_config[$config_name] = $cfg_array[$config_name]; $this->config->set($config_name, $cfg_array[$config_name]); } return true; }
/** * Deletes the users from the list, whose visit is to old. */ public function prune() { $timestamp = time(); if ($this->config['wwh_version']) { /* OLD function $prune_timestamp = gmmktime(0, 0, 0, gmdate('m', $timestamp), gmdate('d', $timestamp), gmdate('Y', $timestamp)); $prune_timestamp -= ($this->config['board_timezone'] * 3600); $prune_timestamp -= ($this->config['board_dst'] * 3600);*/ // Correct Time Zone. https://www.phpbb.com/community/viewtopic.php?f=456&t=2297986&start=30#p14022491 $timezone = new \DateTimeZone($this->config['board_timezone']); $prune_timestamp = $this->user->get_timestamp_from_format('Y-m-d H:i:s', date('Y', $timestamp) . '-' . date('m', $timestamp) . '-' . date('d', $timestamp) . ' 00:00:00', $timezone); $prune_timestamp = $prune_timestamp < $timestamp - 86400 ? $prune_timestamp + 86400 : ($prune_timestamp > $timestamp ? $prune_timestamp - 86400 : $prune_timestamp); } else { $prune_timestamp = $timestamp - (3600 * $this->config['wwh_del_time_h'] + 60 * $this->config['wwh_del_time_m'] + $this->config['wwh_del_time_s']); } if (!isset($this->config['wwh_last_clean']) || $this->config['wwh_last_clean'] != $prune_timestamp || !$this->config['wwh_version']) { $this->db->sql_return_on_error(true); $sql = 'DELETE FROM ' . WWH_TABLE . ' WHERE wwh_lastpage <= ' . $prune_timestamp; $result = $this->db->sql_query($sql); $this->db->sql_return_on_error(false); if ((bool) $result === false) { // database does not exist yet... return false; } if ($this->config['wwh_version']) { $this->config->set('wwh_last_clean', $prune_timestamp); } } // Purging was not needed or done succesfully... return true; }
/** * {@inheritdoc} */ public function install($module_id) { $this->config->set('board3_max_topics_' . $module_id, 10); $this->config->set('board3_recent_title_limit_' . $module_id, 100); $this->config->set('board3_recent_forum_' . $module_id, ''); $this->config->set('board3_recent_exclude_forums_' . $module_id, 1); return true; }