public function add_page_header_links($event)
    {
        if (!empty($this->config['allow_visits_counter'])) {
            $this->language->add_lang('common', 'dmzx/counter');
            $sql = 'SELECT COUNT(*) AS visits_counter
				FROM ' . $this->visits_counter_table . '
				WHERE ' . $this->db->sql_in_set('uvc_ip', $this->user->ip);
            $result = $this->db->sql_query($sql);
            $visits_counter = (int) $this->db->sql_fetchfield('visits_counter');
            $this->db->sql_freeresult($result);
            $visits = $this->config['visits_counter'];
            if ($visits_counter == 0) {
                $sql_ary = array('uvc_ip' => $this->user->ip, 'uvc_timestamp' => time());
                $sql = 'INSERT INTO ' . $this->visits_counter_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
                $this->db->sql_query($sql);
                $this->config->increment('visits_counter', 1, true);
            } else {
                $sql_ary = array('uvc_timestamp' => time());
                $sql = 'UPDATE ' . $this->visits_counter_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE ' . $this->db->sql_in_set('uvc_ip', $this->user->ip);
                $this->db->sql_query($sql);
            }
            $timestamp = time() - 3600 * 24;
            $sql_ary = array($timestamp);
            $sql = 'DELETE FROM ' . $this->visits_counter_table . '
				WHERE uvc_timestamp < ' . $timestamp;
            $this->db->sql_query($sql);
            $sql = 'SELECT COUNT(*) AS num_del
				FROM ' . $this->visits_counter_table . ' ';
            $result = $this->db->sql_query($sql);
            $visitsok = (int) $this->db->sql_fetchfield('num_del');
            $this->template->assign_vars(array('UNIQUE_VISITS_COUNTER' => $this->language->lang('UNIQUE_VISITS_COUNTER', $visitsok)));
        }
    }
 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));
 }
예제 #3
0
 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));
 }
 /**
  * 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);
 }
 /**
  * @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));
 }
예제 #6
0
 /**
  * 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);
 }
예제 #7
0
    /**
     * 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);
    }
 /**
  * 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();
 }
예제 #9
0
 /**
  * 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);
 }
예제 #10
0
 /**
  * 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));
 }
예제 #11
0
 /**
  * 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'));
 }
예제 #12
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);
 }
 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));
 }
예제 #14
0
 /**
  * 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));
 }
예제 #15
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));
         }
     }
 }
예제 #16
0
 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));
         }
     }
 }
예제 #17
0
 /**
  * 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'];
 }
예제 #18
0
 /**
  * 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);
 }
예제 #19
0
파일: config.php 프로젝트: phpbb/phpbb-core
 /**
  * Remove an existing config setting.
  *
  * @param string $config_name The name of the config setting you would
  * 	like to remove
  * @return null
  */
 public function remove($config_name)
 {
     if (!isset($this->config[$config_name])) {
         return;
     }
     $this->config->delete($config_name);
 }
예제 #20
0
 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;
 }
예제 #21
0
파일: upload_test.php 프로젝트: phpbb/phpbb
 /**
  * @dataProvider data_image_upload
  */
 public function test_image_upload($is_image, $plupload_active, $config_data, $expected)
 {
     $filespec = $this->getMock('\\phpbb\\files\\filespec', array('init_error', 'is_image', 'move_file', 'is_uploaded'), array($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, $this->mimetype_guesser, $this->plupload));
     foreach ($config_data as $key => $value) {
         $this->config[$key] = $value;
     }
     $filespec->set_upload_namespace($this->files_upload);
     $filespec->expects($this->any())->method('init_error')->willReturn(false);
     $filespec->expects($this->any())->method('is_image')->willReturn($is_image);
     $filespec->expects($this->any())->method('is_uploaded')->willReturn(true);
     $filespec->expects($this->any())->method('move_file')->willReturn(false);
     $this->container->set('files.filespec', $filespec);
     $factory_mock = $this->getMockBuilder('\\phpbb\\files\\factory')->disableOriginalConstructor()->getMock();
     $factory_mock->expects($this->any())->method('get')->willReturn($filespec);
     $this->container->set('files.types.local', new \phpbb\files\types\local($factory_mock, $this->language, $this->php_ini, $this->request));
     $plupload = $this->getMockBuilder('\\phpbb\\plupload\\plupload')->disableOriginalConstructor()->getMock();
     $plupload->expects($this->any())->method('is_active')->willReturn($plupload_active);
     if ($plupload_active) {
         $plupload->expects($this->once())->method('emit_error')->with(104, 'ATTACHED_IMAGE_NOT_IMAGE')->willReturn(false);
     }
     $this->upload = new \phpbb\attachment\upload($this->auth, $this->cache, $this->config, $this->files_upload, $this->language, $this->mimetype_guesser, $this->phpbb_dispatcher, $plupload, $this->user, $this->phpbb_root_path);
     $filedata = $this->upload->upload('foobar', 1, true, '', false, array('realname' => 'foobar.jpg', 'type' => 'jpg', 'size' => 100));
     foreach ($expected as $key => $entry) {
         $this->assertEquals($entry, $filedata[$key]);
     }
     // Reset config data
     foreach ($config_data as $key => $value) {
         $this->config->delete($key);
     }
 }
예제 #22
0
 /**
  * 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;
 }
 /**
  * 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);
 }
예제 #24
0
 /**
  * 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);
 }
예제 #25
0
    /**
     * Creates a configuration container with a default set of values
     *
     * @param \phpbb\db\driver\driver_interface    $db    Database connection
     * @param \phpbb\cache\driver\driver_interface $cache Cache instance
     * @param string                       $table Configuration table name
     */
    public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, $table)
    {
        $this->db = $db;
        $this->cache = $cache;
        $this->table = $table;
        if (($config = $cache->get('config')) !== false) {
            $sql = 'SELECT config_name, config_value
				FROM ' . $this->table . '
				WHERE is_dynamic = 1';
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                $config[$row['config_name']] = $row['config_value'];
            }
            $this->db->sql_freeresult($result);
        } else {
            $config = $cached_config = array();
            $sql = 'SELECT config_name, config_value, is_dynamic
				FROM ' . $this->table;
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                if (!$row['is_dynamic']) {
                    $cached_config[$row['config_name']] = $row['config_value'];
                }
                $config[$row['config_name']] = $row['config_value'];
            }
            $this->db->sql_freeresult($result);
            $cache->put('config', $cached_config);
        }
        parent::__construct($config);
    }
예제 #26
0
 /**
  * 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));
 }
예제 #27
0
 /**
  * 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);
             }
         }
     }
 }
예제 #28
0
    /**
     * 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);
    }
예제 #29
0
 /**
  * {@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;
 }
예제 #30
0
 /**
  * Releases the lock.
  *
  * The lock must have been previously obtained, that is, acquire() call
  * was issued and returned true.
  *
  * Note: Attempting to release a lock that is already released,
  * that is, calling release() multiple times, is harmless.
  *
  * @return null
  */
 public function release()
 {
     if ($this->locked) {
         $this->config->set_atomic($this->config_name, $this->unique_id, '0', false);
         $this->locked = false;
     }
 }