/** * Display board announcements * * @return null * @access public */ public function display_board_announcements() { // Do not continue if announcement has been disabled if (!$this->config['board_announcements_enable']) { return; } // Get board announcement data from the cache $board_announcement_data = $this->cache->get('_board_announcement_data'); if ($board_announcement_data === false) { // Get board announcement data from the config_text object $board_announcement_data = $this->config_text->get_array(array('announcement_text', 'announcement_uid', 'announcement_bitfield', 'announcement_options', 'announcement_bgcolor', 'announcement_timestamp')); // Cache board announcement data $this->cache->put('_board_announcement_data', $board_announcement_data); } // Get announcement cookie if one exists $cookie = $this->request->variable($this->config['cookie_name'] . '_baid', '', true, \phpbb\request\request_interface::COOKIE); // Do not continue if announcement has been dismissed if (!$this->user->data['board_announcements_status'] || $cookie == $board_announcement_data['announcement_timestamp']) { return; } // Prepare board announcement message for display $announcement_message = generate_text_for_display($board_announcement_data['announcement_text'], $board_announcement_data['announcement_uid'], $board_announcement_data['announcement_bitfield'], $board_announcement_data['announcement_options']); // Add board announcements language file $this->user->add_lang_ext('phpbb/boardannouncements', 'boardannouncements'); // Output board announcement to the template $this->template->assign_vars(array('S_BOARD_ANNOUNCEMENT' => true, 'S_BOARD_ANNOUNCEMENT_DISMISS' => (bool) $this->config['board_announcements_dismiss'], 'BOARD_ANNOUNCEMENT' => $announcement_message, 'BOARD_ANNOUNCEMENT_BGCOLOR' => $board_announcement_data['announcement_bgcolor'], 'U_BOARD_ANNOUNCEMENT_CLOSE' => $this->controller_helper->route('phpbb_boardannouncements_controller', array('hash' => generate_link_hash('close_boardannouncement'))))); }
/** * {@inheritdoc} */ public function run() { if (!$this->iohandler->get_input('submit_continue_file_update', false)) { // Handle merge conflicts $merge_conflicts = $this->installer_config->get('merge_conflict_list', array()); // Create archive for merge conflicts if (!empty($merge_conflicts)) { foreach ($merge_conflicts as $filename) { $this->file_updater->create_new_file($filename, base64_decode($this->cache->get('_file_' . md5($filename))), true); } // Render download box $this->iohandler->add_download_link('phpbb_installer_update_conflict_download', 'DOWNLOAD_CONFLICTS', 'DOWNLOAD_CONFLICTS_EXPLAIN'); } $this->file_updater->close(); // Render update file statuses $file_update_info = $this->installer_config->get('update_files', array()); $file_status = array('deleted' => !isset($file_update_info['delete']) ? array() : $file_update_info['delete'], 'new' => !isset($file_update_info['new']) ? array() : $file_update_info['new'], 'conflict' => $this->installer_config->get('merge_conflict_list', array()), 'modified' => !isset($file_update_info['update_with_diff']) ? array() : $file_update_info['update_with_diff'], 'not_modified' => !isset($file_update_info['update_without_diff']) ? array() : $file_update_info['update_without_diff']); $this->iohandler->render_update_file_status($file_status); // Add form to continue update $this->iohandler->add_user_form_group('UPDATE_CONTINUE_FILE_UPDATE', array('submit_continue_file_update' => array('label' => 'UPDATE_CONTINUE_FILE_UPDATE', 'type' => 'submit'))); // Show results to the user $this->iohandler->send_response(); throw new user_interaction_required_exception(); } else { // Remove archive $this->filesystem->remove($this->installer_config->get('update_file_conflict_archive', null)); $this->installer_config->set('update_file_conflict_archive', null); } }
/** * Constructor * * @param \phpbb\cache\driver_interface $cache * @param string $key Cache key * @param factory $factory * @param \phpbb\event\dispatcher_interface $dispatcher */ public function __construct(\phpbb\cache\driver\driver_interface $cache, $key, factory $factory, \phpbb\event\dispatcher_interface $dispatcher) { $parser = $cache->get($key); if (!$parser) { $objects = $factory->regenerate(); $parser = $objects['parser']; } $this->dispatcher = $dispatcher; $this->parser = $parser; $parser = $this; /** * Configure the parser service * * Can be used to: * - toggle features or BBCodes * - register variables or custom parsers in the s9e\TextFormatter parser * - configure the s9e\TextFormatter parser's runtime settings * * @event core.text_formatter_s9e_parser_setup * @var \phpbb\textformatter\s9e\parser parser This parser service * @since 3.2.0-a1 */ $vars = array('parser'); extract($dispatcher->trigger_event('core.text_formatter_s9e_parser_setup', compact($vars))); }
/** * @param int $menu_id * @return array */ private function _get_menu($menu_id) { if (($data = $this->cache->get('sitemaker_menus')) === false) { $data = $this->_get_all_menus(); $this->cache->put('sitemaker_menus', $data); } return isset($data[$menu_id]) ? $data[$menu_id] : array(); }
/** * Provide the class loader with a cache to store paths. If set to null, the * the class loader will resolve paths by checking for the existance of every * directory in the class name every time. * * @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface. */ public function set_cache(\phpbb\cache\driver\driver_interface $cache = null) { if ($cache) { $this->cached_paths = $cache->get('class_loader_' . str_replace('\\', '__', $this->namespace)); if ($this->cached_paths === false) { $this->cached_paths = array(); } } $this->cache = $cache; }
/** * 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')); }
/** * {@inheritdoc} */ public function display(array $bdata, $edit_mode = false) { if (($content = $this->cache->get('pt_block_data_' . $bdata['bid'])) === false) { $content = ''; if ($this->_find_birthday_users()) { $content = $this->ptemplate->render_view('blitze/sitemaker', 'blocks/birthday.html', 'birthday_block'); // we only check birthdays every hour, may make this an admin choice $this->cache->put('pt_block_data_' . $bdata['bid'], $content, 3600); } } return array('title' => 'BIRTHDAYS', 'content' => $content); }
/** * Executes the command cache:get. * * Display the information available about a cached value. * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return null */ protected function execute(InputInterface $input, OutputInterface $output) { $key = $input->getArgument('key'); if ($this->cache->_exists($key)) { $output->writeln('<info>' . $this->user->lang('VALUE') . $this->user->lang('COLON') . '</info>'); $value = $this->cache->get($key); if (is_array($value)) { $output->writeln(print_r($value, true), OutputInterface::OUTPUT_PLAIN); } else { $output->writeln($value, OutputInterface::OUTPUT_PLAIN); } } else { $output->writeln('<error>' . $this->user->lang('NICOFUMA_DEBUGTOOLS_CLI_CACHE_KEY_UNAVAILABLE', $key) . '</error>'); } }
public function newusers() { $howmany = $this->howmany(); $sql_where = $this->ignore_users(); $sql_and = !empty($sql_where) ? ' AND user_inactive_reason = 0' : ' WHERE user_inactive_reason = 0'; // newest registered users if (($newest_users = $this->cache->get('_top_five_newest_users')) === false) { $newest_users = array(); // grab most recent registered users $sql = 'SELECT user_id, username, user_colour, user_regdate FROM ' . USERS_TABLE . ' ' . $sql_where . ' ' . $sql_and . ' ORDER BY user_regdate DESC'; $result = $this->db->sql_query_limit($sql, $howmany); while ($row = $this->db->sql_fetchrow($result)) { $newest_users[$row['user_id']] = array('user_id' => $row['user_id'], 'username' => $row['username'], 'user_colour' => $row['user_colour'], 'user_regdate' => $row['user_regdate']); } $this->db->sql_freeresult($result); // cache this data for 5 minutes, this improves performance $this->cache->put('_top_five_newest_users', $newest_users, 300); } foreach ($newest_users as $row) { $username_string = $this->auth->acl_get('u_viewprofile') ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']); $this->template->assign_block_vars('top_five_newest', array('REG_DATE' => $this->user->format_date($row['user_regdate']), 'USERNAME_FULL' => $username_string)); } }
/** * Regenerate and cache a new parser and renderer * * @return array Associative array with at least two elements: "parser" and "renderer" */ public function regenerate() { $configurator = $this->get_configurator(); // Get the censor helper and remove the Censor plugin if applicable if (isset($configurator->Censor)) { $censor = $configurator->Censor->getHelper(); unset($configurator->Censor); unset($configurator->tags['censor:tag']); } $objects = $configurator->finalize(); $parser = $objects['parser']; $renderer = $objects['renderer']; // Cache the parser as-is $this->cache->put($this->cache_key_parser, $parser); // We need to cache the name of the renderer's generated class $renderer_data = array('class' => get_class($renderer)); if (isset($censor)) { $renderer_data['censor'] = $censor; } $this->cache->put($this->cache_key_renderer, $renderer_data); return array('parser' => $parser, 'renderer' => $renderer); }
/** * Remove modules cache file * * @param string $module_class Class of the module (acp, ucp, mcp etc...) */ public function remove_cache_file($module_class) { // Sanitise for future path use, it's escaped as appropriate for queries $cache_class = str_replace(array('.', '/', '\\'), '', basename($module_class)); $this->cache->destroy('_modules_' . $cache_class); $this->cache->destroy('sql', $this->modules_table); }
public function add(array &$forum_data, $forum_perm_from = 0) { $forum_data += array('parent_id' => $this->config['sitemaker_parent_forum_id']); $errors = admin::save($forum_data); if (!sizeof($errors)) { $forum_data['forum_id'] = (int) $forum_data['forum_id']; // Copy permissions? if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id']) { copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], false, false); phpbb_cache_moderators($this->db, $this->cache, $this->auth); } $this->auth->acl_clear_prefetch(); $this->cache->destroy('sql', FORUMS_TABLE); } return $errors; }
/** * Render the final page of the convertor */ public function finish() { $this->setup_navigation('finish'); $this->template->assign_vars(array('TITLE' => $this->language->lang('CONVERT_COMPLETE'), 'BODY' => $this->language->lang('CONVERT_COMPLETE_EXPLAIN'))); // If we reached this step (conversion completed) we want to purge the cache and log the user out. // This is for making sure the session get not screwed due to the 3.0.x users table being completely new. $this->cache->purge(); $this->installer_cache->purge(); require_once $this->phpbb_root_path . 'includes/constants.' . $this->php_ext; require_once $this->phpbb_root_path . 'includes/functions_convert.' . $this->php_ext; $sql = 'SELECT config_value FROM ' . $this->config_table . ' WHERE config_name = \'search_type\''; $result = $this->db->sql_query($sql); if ($this->db->sql_fetchfield('config_value') != 'fulltext_mysql') { $this->template->assign_vars(array('S_ERROR_BOX' => true, 'ERROR_TITLE' => $this->language->lang('SEARCH_INDEX_UNCONVERTED'), 'ERROR_MSG' => $this->language->lang('SEARCH_INDEX_UNCONVERTED_EXPLAIN'))); } $this->db->sql_freeresult($result); switch ($this->db->get_sql_layer()) { case 'sqlite': case 'sqlite3': $this->db->sql_query('DELETE FROM ' . $this->session_keys_table); $this->db->sql_query('DELETE FROM ' . $this->session_table); break; default: $this->db->sql_query('TRUNCATE TABLE ' . $this->session_keys_table); $this->db->sql_query('TRUNCATE TABLE ' . $this->session_table); break; } return $this->controller_helper->render('installer_convert.html', 'CONVERT_COMPLETE'); }
public function add(&$forum_data, $forum_perm_from = 0) { $forum_data += array('parent_id' => $this->config['sitemaker_parent_forum_id'], 'forum_type' => FORUM_POST, 'type_action' => '', 'forum_status' => ITEM_UNLOCKED, 'forum_parents' => '', 'forum_name' => '', 'forum_link' => '', 'forum_link_track' => false, 'forum_desc' => '', 'forum_desc_uid' => '', 'forum_desc_options' => 7, 'forum_desc_bitfield' => '', 'forum_rules' => '', 'forum_rules_uid' => '', 'forum_rules_options' => 7, 'forum_rules_bitfield' => '', 'forum_rules_link' => '', 'forum_image' => '', 'forum_style' => 0, 'display_subforum_list' => false, 'display_on_index' => false, 'forum_topics_per_page' => 0, 'enable_indexing' => true, 'enable_icons' => false, 'enable_prune' => false, 'enable_post_review' => true, 'enable_quick_reply' => false, 'prune_days' => 7, 'prune_viewed' => 7, 'prune_freq' => 1, 'prune_old_polls' => false, 'prune_announce' => false, 'prune_sticky' => false, 'show_active' => false, 'forum_password' => '', 'forum_password_confirm' => '', 'forum_password_unset' => false); $errors = $this->forum->update_forum_data($forum_data); if (!sizeof($errors)) { $forum_data['forum_id'] = (int) $forum_data['forum_id']; // Copy permissions? if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id']) { copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], false, false); phpbb_cache_moderators($this->db, $this->cache, $this->auth); } $this->auth->acl_clear_prefetch(); $this->cache->destroy('sql', FORUMS_TABLE); } return $errors; }
/** * 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; }
/** * {@inheritdoc} */ public function run() { $this->language->add_lang('migrator'); if (!isset($this->config['version_update_from'])) { $this->config->set('version_update_from', $this->config['version']); } $original_version = $this->config['version_update_from']; $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new installer_migrator_output_handler($this->iohandler), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem)); $this->migrator->create_migrations_table(); $migrations = $this->extension_manager->get_finder()->core_path('phpbb/db/migration/data/')->extension_directory('/migrations')->get_classes(); $this->migrator->set_migrations($migrations); $migration_step_count = $this->installer_config->get('database_update_migration_steps', -1); if ($migration_step_count < 0) { $migration_step_count = count($this->migrator->get_installable_migrations()) * 2; $this->installer_config->set('database_update_migration_steps', $migration_step_count); } $progress_count = $this->installer_config->get('database_update_count', 0); $restart_progress_bar = $progress_count === 0; // Only "restart" when the update runs for the first time $this->iohandler->set_task_count($migration_step_count, $restart_progress_bar); $this->installer_config->set_task_progress_count($migration_step_count); while (!$this->migrator->finished()) { try { $this->migrator->update(); $progress_count++; $last_run_migration = $this->migrator->get_last_run_migration(); if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed']) { // We skipped two step, so increment $progress_count by another one $progress_count++; } else { if ($last_run_migration['task'] === 'process_schema_step' && !$last_run_migration['state']['migration_schema_done'] || $last_run_migration['task'] === 'process_data_step' && !$last_run_migration['state']['migration_data_done']) { // We just run a step that wasn't counted yet so make it count $migration_step_count++; } } $this->iohandler->set_task_count($migration_step_count); $this->installer_config->set_task_progress_count($migration_step_count); $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); } catch (exception $e) { $msg = $e->getParameters(); array_unshift($msg, $e->getMessage()); $this->iohandler->add_error_message($msg); throw new user_interaction_required_exception(); } if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) { $this->installer_config->set('database_update_count', $progress_count); $this->installer_config->set('database_update_migration_steps', $migration_step_count); throw new resource_limit_reached_exception(); } } if ($original_version !== $this->config['version']) { $this->log->add('admin', isset($this->user->data['user_id']) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, array($original_version, $this->config['version'])); } $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); $this->config->delete('version_update_from'); $this->cache->purge(); $this->config->increment('assets_version', 1); }
/** * Delete a question * @param integer $question_id */ public function acp_delete_question($question_id) { $tables = array($this->table_sortables_questions, $this->table_sortables_answers); foreach ($tables as $table) { $sql = "DELETE FROM {$table}\n\t\t\t\tWHERE question_id = " . (int) $question_id; $this->db->sql_query($sql); } $this->cache->destroy('sql', $tables); }
/** * @param $bid * @param bool $change_user */ private function _save_settings($bid, $change_user) { if ($change_user && ($this->settings['rotation'] !== 'pageload' || $this->settings['qtype'] === 'featured')) { $settings = $this->settings; unset($settings['hash']); $sql_data = array('settings' => serialize($settings)); $this->db->sql_query('UPDATE ' . $this->blocks_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_data) . ' WHERE bid = ' . (int) $bid); $this->cache->put('pt_block_data_' . $bid, $this->settings); } }
/** * Get image from Cache or Piwik * * @param array $configText With datas from config_text * @param array $stats With datas for piwik * @return string Image as String * @access private */ private function getImage($configText, $stats) { $cacheName = $stats['module'] . '_' . $stats['action'] . '_' . $stats['period']; $image = $this->cache->get($cacheName); if ($image === false) { $image = $this->getPiwikImage($configText, $stats['module'], $stats['action'], $stats['graphType'], $stats['period']); $this->cache->put($cacheName, $image, $configText['piwik_cache_page']); } return $image; }
/** * {@inheritdoc} */ public function purge_notifications($notification_type_id) { $sql = 'DELETE FROM ' . $this->notifications_table . ' WHERE notification_type_id = ' . (int) $notification_type_id; $this->db->sql_query($sql); $sql = 'DELETE FROM ' . $this->notification_types_table . ' WHERE notification_type_id = ' . (int) $notification_type_id; $this->db->sql_query($sql); $this->cache->destroy('notification_type_ids'); }
/** * Run auto groups check against users for a given condition/type * Called in the ACP when adding/editing or via the Resync button * * @param int $autogroups_rule_id The id of the auto group rule * * @return null * @access public */ public function sync_autogroups($autogroups_rule_id) { // Purge cached rules table queries $this->cache->destroy('sql', $this->autogroups_rules_table); // Get the auto group type name used by the specified auto group rule $autogroups_type_name = $this->get_autogroups_type_name(0, $autogroups_rule_id); // If auto group type exists, run it if ($autogroups_type_name !== false) { $this->check_condition($autogroups_type_name, array('action' => 'sync')); } }
public function forumlist_display_rating($event) { $forum_rows = $event['forum_rows']; $this->helper->get_max_forum_thanks(); $forum_thanks_rating = array(); foreach ($forum_rows as $row) { $forum_thanks_rating[] = $row['forum_id']; } $this->cache->put('_forum_thanks_rating', $forum_thanks_rating); $this->helper->get_thanks_forum_number(); $this->cache->destroy('_forum_thanks_rating'); }
/** * Increments an integer config value directly in the database. * * Using this method instead of setting the new value directly avoids race * conditions and unlike set_atomic it cannot fail. * * @param string $key The configuration option's name * @param int $increment Amount to increment by * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached. */ function increment($key, $increment, $use_cache = true) { if (!isset($this->config[$key])) { $this->set($key, '0', $use_cache); } $sql_update = $this->db->cast_expr_to_string($this->db->cast_expr_to_bigint('config_value') . ' + ' . (int) $increment); $this->db->sql_query('UPDATE ' . $this->table . ' SET config_value = ' . $sql_update . "\n\t\t\tWHERE config_name = '" . $this->db->sql_escape($key) . "'"); if ($use_cache) { $this->cache->destroy('config'); } $this->config[$key] += $increment; }
/** * Constructor * * @param \phpbb\cache\driver\driver_interface $cache * @param string $cache_dir Path to the cache dir * @param string $key Cache key * @param factory $factory * @param \phpbb\event\dispatcher_interface $dispatcher */ public function __construct(\phpbb\cache\driver\driver_interface $cache, $cache_dir, $key, factory $factory, \phpbb\event\dispatcher_interface $dispatcher) { $renderer_data = $cache->get($key); if ($renderer_data) { $class = $renderer_data['class']; if (!class_exists($class, false)) { // Try to load the renderer class from its cache file $cache_file = $cache_dir . $class . '.php'; if (file_exists($cache_file)) { include $cache_file; } } if (class_exists($class, false)) { $renderer = new $class(); } if (isset($renderer_data['censor'])) { $censor = $renderer_data['censor']; } } if (!isset($renderer)) { $objects = $factory->regenerate(); $renderer = $objects['renderer']; } if (isset($censor)) { $this->censor = $censor; } $this->dispatcher = $dispatcher; $this->renderer = $renderer; $renderer = $this; /** * Configure the renderer service * * @event core.text_formatter_s9e_renderer_setup * @var \phpbb\textformatter\s9e\renderer renderer This renderer service * @since 3.2.0-a1 */ $vars = array('renderer'); extract($dispatcher->trigger_event('core.text_formatter_s9e_renderer_setup', compact($vars))); }
/** * Performs add|edit|del|clean|prune actions */ public function mchat_action($action, $sql_ary = null, $message_id = 0, $log_username = '') { switch ($action) { // User adds a message case 'add': $sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); $this->mchat_add_user_session(); break; // User edits a message // User edits a message case 'edit': $sql = 'UPDATE ' . $this->mchat_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE message_id = ' . (int) $message_id; $this->mchat_add_user_session(); $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EDITED_MCHAT', false, array($log_username)); break; // User deletes a message // User deletes a message case 'del': $sql = 'DELETE FROM ' . $this->mchat_table . ' WHERE message_id = ' . (int) $message_id; $this->mchat_add_user_session(); $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DELETED_MCHAT', false, array($log_username)); $this->cache->destroy('sql', $this->mchat_table); break; // Founder purges all messages // Founder purges all messages case 'clean': $sql = 'TRUNCATE TABLE ' . $this->mchat_table; $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED'); $this->cache->destroy('sql', $this->mchat_table); break; // User triggers messages to be pruned // User triggers messages to be pruned case 'prune': $sql = 'DELETE FROM ' . $this->mchat_table . ' WHERE message_id < ' . (int) $message_id; $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED'); $this->cache->destroy('sql', $this->mchat_table); break; default: return; } $result = $this->db->sql_query($sql); if ($result !== false) { switch ($action) { case 'add': if ($this->db->sql_nextid() == 1) { $this->cache->destroy('sql', $this->mchat_table); } break; } } }
/** * Remove page link location data for a page * This method usually need not be called outside of this class * * @param int $page_id Page identifier * @return page_interface $this object for chaining calls * @throws \phpbb\pages\exception\out_of_bounds * @access protected */ protected function remove_page_links($page_id) { // Throw an exception if page identifier is invalid if (!$this->page_id_exists($page_id)) { throw new \phpbb\pages\exception\out_of_bounds('page_id'); } // Delete the page's links from the database $sql = 'DELETE FROM ' . $this->pages_pages_links_table . ' WHERE page_id = ' . (int) $page_id; $this->db->sql_query($sql); // Destroy cached page links $this->cache->destroy('sql', $this->pages_pages_links_table); return $this; }
/** * Read the remote image and return it as local image */ public function image() { $img = $this->request->variable('img', '', true); $cache_file = '_imageproxy_' . $img; $data = $this->cache->get($cache_file); if ($data === false) { $headers = @get_headers($img, true); if ($headers[0] != 'HTTP/1.1 200 OK') { // 1x1px transparent png $data = array('header' => 'image/png', 'content' => 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABnRSTlMAAAAAAABupgeRAAAADElEQVQImWNgYGAAAAAEAAGjChXjAAAAAElFTkSuQmCC'); } else { // Create a HTTP header with user agent $options = array('http' => array('method' => "GET", 'header' => "Accept-language: en\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0\r\n")); $context = stream_context_create($options); // Get the remote image $data = array('header' => $headers['Content-Type'], 'content' => base64_encode(file_get_contents($img, false, $context))); } // Cache for 1 day $this->cache->put($cache_file, $data, 86400); } header('Content-type: ' . $data['header']); exit(base64_decode($data['content'])); }
/** * @return array */ private function _get_custom_blocks() { if (($cblocks = $this->cache->get('pt_cblocks')) === false) { $sql = 'SELECT * FROM ' . $this->cblocks_table; $result = $this->db->sql_query($sql); $cblocks = array(); while ($row = $this->db->sql_fetchrow($result)) { $cblocks[$row['block_id']] = $row; } $this->db->sql_freeresult($result); $this->cache->put('pt_cblocks', $cblocks); } return $cblocks; }
/** * Finds all hook files. * * @param bool $cache Whether the result should be cached * @return array An array of paths to found hook files */ public function find($cache = true) { if (!defined('DEBUG') && $cache && $this->cache) { $hook_files = $this->cache->get('_hooks'); if ($hook_files !== false) { return $hook_files; } } $hook_files = array(); // Now search for hooks... $dh = @opendir($this->phpbb_root_path . 'includes/hooks/'); if ($dh) { while (($file = readdir($dh)) !== false) { if (strpos($file, 'hook_') === 0 && substr($file, -strlen('.' . $this->php_ext)) === '.' . $this->php_ext) { $hook_files[] = substr($file, 0, -(strlen($this->php_ext) + 1)); } } closedir($dh); } if ($cache && $this->cache) { $this->cache->put('_hooks', $hook_files); } return $hook_files; }
/** * Obtain disallowed usernames */ function obtain_disallowed_usernames() { if (($usernames = $this->driver->get('_disallowed_usernames')) === false) { $sql = 'SELECT disallow_username FROM ' . DISALLOW_TABLE; $result = $this->db->sql_query($sql); $usernames = array(); while ($row = $this->db->sql_fetchrow($result)) { $usernames[] = str_replace('%', '.*?', preg_quote(utf8_clean_string($row['disallow_username']), '#')); } $this->db->sql_freeresult($result); $this->driver->put('_disallowed_usernames', $usernames); } return $usernames; }