Esempio n. 1
0
 /**
  * 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')))));
 }
Esempio n. 2
0
 /**
  * {@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);
     }
 }
Esempio n. 3
0
 /**
  * @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();
 }
 /**
  * {@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);
 }
Esempio n. 5
0
 /**
  * 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>');
     }
 }
Esempio n. 6
0
 /**
  * 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)));
 }
Esempio n. 7
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);
    }
Esempio n. 8
0
    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));
        }
    }
 /**
  * @param array $bdata
  * @return array
  */
 private function _get_settings(array $bdata)
 {
     $cached_settings = $this->cache->get('pt_block_data_' . $bdata['bid']);
     $settings = $cached_settings && $cached_settings['hash'] === $bdata['hash'] ? $cached_settings : $bdata['settings'];
     $settings['hash'] = $bdata['hash'];
     return $settings;
 }
Esempio n. 10
0
    /**
     * Get the condition type id from the name
     *
     * @param string $autogroups_type_name The name of the auto group type
     *
     * @return int The condition_type_id
     * @throws \RuntimeException
     */
    public function get_autogroups_type_id($autogroups_type_name)
    {
        // Get cached auto groups ids if they exist
        $autogroups_type_ids = $this->cache->get('_autogroups_type_ids');
        // Get auto groups ids from the db if no cache data exists, cache result
        if ($autogroups_type_ids === false) {
            $autogroups_type_ids = array();
            $sql = 'SELECT autogroups_type_id, autogroups_type_name
				FROM ' . $this->autogroups_types_table;
            $result = $this->db->sql_query($sql);
            while ($row = $this->db->sql_fetchrow($result)) {
                $autogroups_type_ids[$row['autogroups_type_name']] = (int) $row['autogroups_type_id'];
            }
            $this->db->sql_freeresult($result);
            $this->cache->put('_autogroups_type_ids', $autogroups_type_ids);
        }
        // Add auto group type name to db if it exists as service but is not in db, cache result
        if (!isset($autogroups_type_ids[$autogroups_type_name])) {
            if (!isset($this->autogroups_types[$autogroups_type_name])) {
                throw new \RuntimeException($this->user->lang('AUTOGROUPS_TYPE_NOT_EXIST', $autogroups_type_name));
            }
            $autogroups_type_ids[$autogroups_type_name] = $this->add_autogroups_type($autogroups_type_name);
            $this->cache->put('_autogroups_type_ids', $autogroups_type_ids);
        }
        return $autogroups_type_ids[$autogroups_type_name];
    }
Esempio n. 11
0
File: page.php Progetto: R3gi/pages
 /**
  * Get custom page link icons (pages_*.gif)
  * Added by the user to the core style/theme/images directores
  *
  * @return array Array of icon image paths
  * @access public
  */
 public function get_page_icons()
 {
     // For efficiency, found icons are cached
     if (($icons = $this->cache->get('_pages_icons')) === false) {
         $icons = $this->find('styles', 'pages_', '.gif');
         $this->cache->put('_pages_icons', $icons);
     }
     return $icons;
 }
Esempio n. 12
0
 /**
  * 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;
 }
Esempio n. 13
0
 /**
  * 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;
 }
Esempio n. 14
0
 /**
  * {@inheritdoc}
  *
  * Will remove old renderers from the cache dir but won't touch the current renderer
  */
 public function tidy()
 {
     // Get the name of current renderer
     $renderer_data = $this->cache->get($this->cache_key_renderer);
     $renderer_file = $renderer_data ? $renderer_data['class'] . '.php' : null;
     foreach (glob($this->cache_dir . 's9e_*') as $filename) {
         // Only remove the file if it's not the current renderer
         if (!$renderer_file || substr($filename, -strlen($renderer_file)) !== $renderer_file) {
             unlink($filename);
         }
     }
 }
Esempio n. 15
0
 /**
  * Gets the a global forum ID for global announcements
  *
  * @return bool True if proper ID was selected, false if not
  */
 protected function get_global_id()
 {
     if ($this->type == 'announcements' && $this->global_id < 1) {
         if (!empty($this->where_string) || ($row = $this->cache->get('_forum_id_first_forum_post')) === false) {
             $row = $this->get_first_forum_id();
         }
         if (empty($row)) {
             return false;
         }
         $this->global_id = $row['forum_id'];
     }
     return true;
 }
Esempio n. 16
0
 /**
  * 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']));
 }
Esempio n. 17
0
 /**
  * @return array|mixed
  */
 protected function _get_all_routes()
 {
     if (($all_routes = $this->cache->get('sitemaker_block_routes')) === false) {
         $route_mapper = $this->mapper_factory->create('blocks', 'routes');
         $collection = $route_mapper->find();
         $all_routes = array();
         foreach ($collection as $entity) {
             $route = $entity->get_route();
             $style = $entity->get_style();
             $all_routes[$style][$route] = $entity->to_array();
         }
         $this->cache->put('sitemaker_block_routes', $all_routes);
     }
     return $all_routes;
 }
Esempio n. 18
0
    /**
     * 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;
    }
Esempio n. 19
0
 /**
  * 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;
 }
Esempio n. 20
0
    /**
     * @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;
    }
Esempio n. 21
0
    public function get_thanks_forum_number()
    {
        if ($this->config['thanks_forum_reput_view']) {
            if ($forum_thanks_rating = $this->cache->get('_forum_thanks_rating')) {
                $sql = 'SELECT forum_id, COUNT(*) AS forum_thanks
					FROM ' . $this->thanks_table . "\n\t\t\t\t\tWHERE " . $this->db->sql_in_set('forum_id', $forum_thanks_rating) . '
					GROUP BY forum_id';
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $this->forum_thanks[$row['forum_id']] = $row['forum_thanks'];
                }
                $this->db->sql_freeresult($result);
            }
            return $this->forum_thanks;
        }
    }
Esempio n. 22
0
    function get_excluded_forums()
    {
        static $forum_ids;
        // Matches acp/acp_board.php
        $cache_name = 'feed_excluded_forum_ids';
        if (!isset($forum_ids) && ($forum_ids = $this->cache->get('_' . $cache_name)) === false) {
            $sql = 'SELECT forum_id
				FROM ' . FORUMS_TABLE . '
				WHERE ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '<> 0');
            $result = $this->db->sql_query($sql);
            $forum_ids = array();
            while ($forum_id = (int) $this->db->sql_fetchfield('forum_id')) {
                $forum_ids[$forum_id] = $forum_id;
            }
            $this->db->sql_freeresult($result);
            $this->cache->put('_' . $cache_name, $forum_ids);
        }
        return $forum_ids;
    }
Esempio n. 23
0
 /**
  * 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)));
 }
Esempio n. 24
0
 /**
  * Get the number of shares
  *
  * @param	string	$url		The URL to get the shares for
  * @return	array
  * @access private
  */
 private function get_share_count($url)
 {
     $cache_time = isset($this->config['socialbuttons_cachetime']) ? $this->config['socialbuttons_cachetime'] : 0;
     $multiplicator = isset($this->config['socialbuttons_multiplicator']) ? $this->config['socialbuttons_multiplicator'] : 1;
     $cachetime = (int) $cache_time * (int) $multiplicator;
     $cache_file = '_socialbuttons_' . $url;
     $shares = $this->cache->get($cache_file);
     // If cache is too old or we have no cache, query the platforms
     if ($shares === false) {
         $content = $querys = array();
         // Collect the querys
         if (isset($this->config['socialbuttons_facebook']) && $this->config['socialbuttons_facebook'] == 1) {
             $querys['facebook'] = 'https://www.facebook.com/plugins/like.php?&layout=box_count&href=' . $url;
         }
         if (isset($this->config['socialbuttons_twitter']) && $this->config['socialbuttons_twitter'] == 1) {
             $querys['twitter'] = 'http://opensharecount.com/count.json?url=' . $url;
         }
         if (isset($this->config['socialbuttons_google']) && $this->config['socialbuttons_twitter'] == 1) {
             $querys['google'] = 'https://plusone.google.com/_/+1/fastbutton?url=' . $url;
         }
         if (isset($this->config['socialbuttons_linkedin']) && $this->config['socialbuttons_twitter'] == 1) {
             $querys['linkedin'] = 'https://www.linkedin.com/countserv/count/share?format=json&url=' . $url;
         }
         // Do we have curl? We can query all platforms paralel what is mutch faster
         if (function_exists('curl_multi_init') && function_exists('curl_multi_exec')) {
             // Set curl options for each URL
             $mh = curl_multi_init();
             $handle = array();
             foreach ($querys as $platform => $query_url) {
                 $ch = curl_init();
                 curl_setopt($ch, CURLOPT_URL, $query_url);
                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 3);
                 curl_setopt($ch, CURLOPT_NOBODY, false);
                 curl_setopt($ch, CURLOPT_HEADER, false);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0');
                 curl_multi_add_handle($mh, $ch);
                 $handle[$platform] = $ch;
             }
             // Exec the query
             $running = 0;
             do {
                 curl_multi_exec($mh, $running);
             } while ($running > 0);
             // Get the resonse
             foreach ($handle as $platform => $ch) {
                 $handle = curl_multi_info_read($mh);
                 $content[$platform] = curl_multi_getcontent($ch);
                 curl_multi_remove_handle($mh, $handle['handle']);
             }
             curl_multi_close($mh);
         } else {
             //Set the useragent
             $options = array('http' => array('user_agent' => 'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0'));
             $context = stream_context_create($options);
             foreach ($querys as $platform => $query_url) {
                 $content[$platform] = file_get_contents($query_url, false, $context);
             }
         }
         // Get the number of shares from response
         $matches = array();
         preg_match('#<div id="aggregateCount" class="Oy">([0-9]+)</div>#s', $content['google'], $matches);
         $shares['google'] = isset($matches[1]) ? $matches[1] : 0;
         preg_match('#<span class="pluginCountTextDisconnected">([0-9]+)</span>#s', $content['facebook'], $matches);
         $shares['facebook'] = isset($matches[1]) ? $matches[1] : 0;
         $pageinfo = json_decode($content['twitter'], true);
         $shares['twitter'] = isset($pageinfo['count']) ? $pageinfo['count'] : 0;
         $pageinfo = json_decode($content['linkedin'], true);
         $shares['linkedin'] = isset($pageinfo['count']) ? $pageinfo['count'] : 0;
         // Write data to cache
         $this->cache->put($cache_file, $shares, $cachetime);
         return $shares;
     } else {
         // return data from cache
         return $shares;
     }
 }
Esempio n. 25
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $new_path = $this->update_helper->get_path_to_new_update_files();
     $file_update_info = $this->installer_config->get('update_files', array());
     $update_type_progress = $this->installer_config->get('file_updater_type_progress', '');
     $update_elem_progress = $this->installer_config->get('file_updater_elem_progress', '');
     $type_progress_found = false;
     $elem_progress_found = false;
     // Progress bar
     $task_count = 0;
     foreach ($file_update_info as $sub_array) {
         $task_count += count($sub_array);
     }
     // Everything is up to date, so just continue
     if ($task_count === 0) {
         return;
     }
     $progress_count = $this->installer_config->get('file_update_progress_count', 0);
     $this->iohandler->set_task_count($task_count, true);
     $this->iohandler->set_progress('UPDATE_UPDATING_FILES', 0);
     $this->file_updater = $this->get_file_updater();
     // File updater fallback logic
     try {
         // Update files
         foreach ($file_update_info as $type => $file_update_vector) {
             if (!$type_progress_found) {
                 if ($type === $update_type_progress || empty($update_elem_progress)) {
                     $type_progress_found = true;
                 } else {
                     continue;
                 }
             }
             foreach ($file_update_vector as $path) {
                 if (!$elem_progress_found) {
                     if ($path === $update_elem_progress || empty($update_elem_progress)) {
                         $elem_progress_found = true;
                     } else {
                         continue;
                     }
                 }
                 switch ($type) {
                     case 'delete':
                         $this->file_updater->delete_file($path);
                         break;
                     case 'new':
                         $this->file_updater->create_new_file($path, $new_path . $path);
                         break;
                     case 'update_without_diff':
                         $this->file_updater->update_file($path, $new_path . $path);
                         break;
                     case 'update_with_diff':
                         $this->file_updater->update_file($path, $this->cache->get('_file_' . md5($path)), true);
                         break;
                 }
                 // Save progress
                 $this->installer_config->set('file_updater_type_progress', $type);
                 $this->installer_config->set('file_updater_elem_progress', $path);
                 $progress_count++;
                 $this->iohandler->set_progress('UPDATE_UPDATING_FILES', $progress_count);
                 if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) {
                     // Request refresh
                     throw new resource_limit_reached_exception();
                 }
             }
         }
         $this->iohandler->finish_progress('UPDATE_UPDATING_FILES');
     } catch (runtime_exception $e) {
         if ($e instanceof resource_limit_reached_exception) {
             throw new resource_limit_reached_exception();
         }
         $current_method = $this->installer_config->get('file_update_method', '');
         // File updater failed, try to fallback to download file update mode
         if ($current_method !== 'compression') {
             $this->iohandler->add_warning_message(array('UPDATE_FILE_UPDATER_HAS_FAILED', $current_method, 'compression'));
             $this->installer_config->set('file_update_method', 'compression');
             // We only want a simple refresh here
             throw new resource_limit_reached_exception();
         } else {
             // Nowhere to fallback to :(
             // Due to the way the installer handles fatal errors, we need to throw a low level exception
             throw new runtime_exception('UPDATE_FILE_UPDATERS_HAVE_FAILED');
         }
     }
     $file_updater_method = $this->installer_config->get('file_update_method', '');
     if ($file_updater_method === 'compression' || $file_updater_method === 'ftp') {
         $this->file_updater->close();
     }
 }
Esempio n. 26
0
 /**
  * Fetching the user-list and putting the stuff into the template.
  */
 public function display()
 {
     $this->user->add_lang_ext('bb3mobi/washere', 'lang_wwh');
     if (!$this->prune()) {
         // Error while purging the list, database is missing :-O
         $this->user->add_lang_ext('bb3mobi/washere', 'info_acp_wwh');
         return;
     }
     /* Default count total or ids */
     $count = array('count_guests' => 0, 'count_bot' => 0, 'count_reg' => 0, 'count_hidden' => 0, 'count_total' => 0, 'ids_reg' => array(), 'ids_hidden' => array(), 'ids_bot' => array());
     $wwh_username_colour = $wwh_username = $wwh_username_full = $users_list = $bots_list = '';
     /* Load cache who_was_here */
     if (($view_state = $this->cache->get("_who_was_here")) === false) {
         $view_state = $this->view_state();
         $this->cache->put("_who_was_here", $view_state, 60 * $this->config['load_online_time']);
     }
     foreach ($view_state as $row) {
         $wwh_username_full = get_username_string($row['user_type'] == USER_IGNORE ? 'no_profile' : 'full', $row['user_id'], $row['username'], $row['user_colour']);
         $hover_time = $this->config['wwh_disp_time'] == '2' ? $this->user->lang['WHO_WAS_HERE_LATEST1'] . '&nbsp;' . $this->user->format_date($row['wwh_lastpage'], $this->config['wwh_disp_time_format']) . $this->user->lang['WHO_WAS_HERE_LATEST2'] : '';
         $hover_ip = $this->auth->acl_get('a_') && $this->config['wwh_disp_ip'] ? $this->user->lang['IP'] . ':&nbsp;' . $row['user_ip'] : '';
         $hover_info = $hover_time || $hover_ip ? ' title="' . $hover_time . ($hover_time && $hover_ip ? ' | ' : '') . $hover_ip . '"' : '';
         $disp_time = $this->config['wwh_disp_time'] == '1' ? '&nbsp;(' . $this->user->lang['WHO_WAS_HERE_LATEST1'] . '&nbsp;' . $this->user->format_date($row['wwh_lastpage'], $this->config['wwh_disp_time_format']) . $this->user->lang['WHO_WAS_HERE_LATEST2'] . ($hover_ip ? ' | ' . $hover_ip : '') . ')' : '';
         if ($row['viewonline'] || $row['user_type'] == USER_IGNORE) {
             if ($row['user_id'] != ANONYMOUS && ($this->config['wwh_disp_bots'] || $row['user_type'] != USER_IGNORE)) {
                 if ($this->config['wwh_disp_bots'] == 2 && $row['user_type'] == USER_IGNORE) {
                     $bots_list .= $this->user->lang['COMMA_SEPARATOR'] . '<span' . $hover_info . '>' . $wwh_username_full . '</span>' . $disp_time;
                 } else {
                     $users_list .= $this->user->lang['COMMA_SEPARATOR'] . '<span' . $hover_info . '>' . $wwh_username_full . '</span>' . $disp_time;
                 }
             }
         } else {
             if ($this->config['wwh_disp_hidden'] && $this->auth->acl_get('u_viewonline')) {
                 $users_list .= $this->user->lang['COMMA_SEPARATOR'] . '<em' . $hover_info . '>' . $wwh_username_full . '</em>' . $disp_time;
             }
         }
         // At the end let's count them =)
         if ($row['user_id'] == ANONYMOUS) {
             $count['count_guests']++;
         } else {
             if ($row['user_type'] == USER_IGNORE) {
                 $count['count_bot']++;
                 $count['ids_bot'][] = (int) $row['user_id'];
             } else {
                 if ($row['viewonline'] == 1) {
                     $count['count_reg']++;
                     $count['ids_reg'][] = (int) $row['user_id'];
                 } else {
                     $count['count_hidden']++;
                     $count['ids_hidden'][] = (int) $row['user_id'];
                 }
             }
         }
         $count['count_total']++;
     }
     $users_list = utf8_substr($users_list, utf8_strlen($this->user->lang['COMMA_SEPARATOR']));
     if ($users_list == '') {
         // User list is empty.
         $users_list = $this->user->lang['NO_ONLINE_USERS'];
     }
     if ($this->config['wwh_disp_bots'] == 2) {
         $bots_list = utf8_substr($bots_list, utf8_strlen($this->user->lang['COMMA_SEPARATOR']));
     }
     if (!$this->config['wwh_disp_bots']) {
         $count['count_total'] -= $count['count_bot'];
     }
     if (!$this->config['wwh_disp_guests']) {
         $count['count_total'] -= $count['count_guests'];
     }
     if (!$this->config['wwh_disp_hidden']) {
         $count['count_total'] -= $count['count_hidden'];
     }
     // Need to update the record?
     if ($this->config['wwh_record_ips'] < $count['count_total']) {
         $this->config->set('wwh_record_ips', $count['count_total'], true);
         $this->config->set('wwh_record_time', time(), true);
     }
     $this->template->assign_vars(array('WHO_WAS_HERE_LIST' => $this->user->lang['USERS'] . $this->user->lang['COLON'] . ' ' . $users_list, 'WHO_WAS_HERE_BOTS' => $bots_list ? $this->user->lang['G_BOTS'] . $this->user->lang['COLON'] . ' ' . $bots_list : '', 'WHO_WAS_HERE_TOTAL' => $this->get_total_users_string($count), 'WHO_WAS_HERE_EXP' => $this->get_explanation_string($this->config['wwh_version']), 'WHO_WAS_HERE_RECORD' => $this->get_record_string($this->config['wwh_record'], $this->config['wwh_version'])));
 }