aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
ModeNameSize
d---------auth159logstatsplain
d---------avatar72logstatsplain
d---------cache72logstatsplain
d---------captcha273logstatsplain
-rw-r--r--class_loader.php4411logstatsplain
-rw-r--r--composer.json600logstatsplain
d---------config111logstatsplain
-rw-r--r--config_php_file.php3968logstatsplain
d---------console77logstatsplain
-rw-r--r--content_visibility.php21499logstatsplain
d---------controller159logstatsplain
d---------cron70logstatsplain
-rw-r--r--datetime.php5143logstatsplain
d---------db195logstatsplain
d---------di225logstatsplain
-rw-r--r--error_collector.php1058logstatsplain
d---------event455logstatsplain
d---------extension255logstatsplain
d---------feed514logstatsplain
-rw-r--r--filesystem.php1022logstatsplain
-rw-r--r--finder.php15178logstatsplain
d---------groupposition174logstatsplain
d---------hook38logstatsplain
-rw-r--r--json_response.php698logstatsplain
d---------lock71logstatsplain
d---------log116logstatsplain
d---------message200logstatsplain
d---------mimetype228logstatsplain
d---------notification144logstatsplain
-rw-r--r--pagination.php14721logstatsplain
d---------passwords110logstatsplain
-rw-r--r--path_helper.php11925logstatsplain
-rw-r--r--permissions.php13660logstatsplain
d---------php35logstatsplain
d---------plupload40logstatsplain
d---------profilefields113logstatsplain
-rw-r--r--recursive_dot_prefix_filter_iterator.php742logstatsplain
d---------request250logstatsplain
d---------search295logstatsplain
-rw-r--r--session.php49685logstatsplain
-rw-r--r--symfony_request.php1516logstatsplain
d---------template183logstatsplain
d---------tree134logstatsplain
-rw-r--r--user.php27099logstatsplain
-rw-r--r--user_loader.php6940logstatsplain
-rw-r--r--version_helper.php7425logstatsplain
-rw-r--r--viewonline_helper.php1068logstatsplain
40'>740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

namespace phpbb;

/**
* Base user class
*
* This is the overarching class which contains (through session extend)
* all methods utilised for user functionality during a session.
*/
class user extends \phpbb\session
{
	var $lang = array();
	var $help = array();
	var $style = array();
	var $date_format;

	/**
	* DateTimeZone object holding the timezone of the user
	*/
	public $timezone;

	var $lang_name = false;
	var $lang_id = false;
	var $lang_path;
	var $img_lang;
	var $img_array = array();

	// Able to add new options (up to id 31)
	var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17);

	/**
	* Constructor to set the lang path
	*/
	function __construct()
	{
		global $phpbb_root_path;

		$this->lang_path = $phpbb_root_path . 'language/';
	}

	/**
	* Function to set custom language path (able to use directory outside of phpBB)
	*
	* @param string $lang_path New language path used.
	* @access public
	*/
	function set_custom_lang_path($lang_path)
	{
		$this->lang_path = $lang_path;

		if (substr($this->lang_path, -1) != '/')
		{
			$this->lang_path .= '/';
		}
	}

	/**
	* Setup basic user-specific items (style, language, ...)
	*/
	function setup($lang_set = false, $style_id = false)
	{
		global $db, $request, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
		global $phpbb_dispatcher;

		if ($this->data['user_id'] != ANONYMOUS)
		{
			$user_lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']);
			$user_date_format = $this->data['user_dateformat'];
			$user_timezone = $this->data['user_timezone'];
		}
		else
		{
			$lang_override = $request->variable('language', '');
			if ($lang_override)
			{
				$this->set_cookie('lang', $lang_override, 0, false);
			}
			else
			{
				$lang_override = $request->variable($config['cookie_name'] . '_lang', '', true, \phpbb\request\request_interface::COOKIE);
			}
			if ($lang_override)
			{
				$use_lang = basename($lang_override);
				$user_lang_name = (file_exists($this->lang_path . $use_lang . "/common.$phpEx")) ? $use_lang : basename($config['default_lang']);
				$this->data['user_lang'] = $user_lang_name;
			}
			else
			{
				$user_lang_name = basename($config['default_lang']);
			}
			$user_date_format = $config['default_dateformat'];
			$user_timezone = $config['board_timezone'];

			/**
			* If a guest user is surfing, we try to guess his/her language first by obtaining the browser language
			* If re-enabled we need to make sure only those languages installed are checked
			* Commented out so we do not loose the code.

			if ($request->header('Accept-Language'))
			{
				$accept_lang_ary = explode(',', $request->header('Accept-Language'));

				foreach ($accept_lang_ary as $accept_lang)
				{
					// Set correct format ... guess full xx_YY form
					$accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2));
					$accept_lang = basename($accept_lang);

					if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx"))
					{
						$user_lang_name = $config['default_lang'] = $accept_lang;
						break;
					}
					else
					{
						// No match on xx_YY so try xx
						$accept_lang = substr($accept_lang, 0, 2);
						$accept_lang = basename($accept_lang);

						if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx"))
						{
							$user_lang_name = $config['default_lang'] = $accept_lang;
							break;
						}
					}
				}
			}
			*/
		}

		$user_data = $this->data;
		$lang_set_ext = array();

		/**
		* Event to load language files and modify user data on every page
		*
		* @event core.user_setup
		* @var	array	user_data			Array with user's data row
		* @var	string	user_lang_name		Basename of the user's langauge
		* @var	string	user_date_format	User's date/time format
		* @var	string	user_timezone		User's timezone, should be one of
		*							http://www.php.net/manual/en/timezones.php
		* @var	mixed	lang_set			String or array of language files
		* @var	array	lang_set_ext		Array containing entries of format
		* 					array(
		* 						'ext_name' => (string) [extension name],
		* 						'lang_set' => (string|array) [language files],
		* 					)
		* 					For performance reasons, only load translations
		* 					that are absolutely needed globally using this
		* 					event. Use local events otherwise.
		* @var	mixed	style_id			Style we are going to display
		* @since 3.1.0-a1
		*/
		$vars = array(
			'user_data',
			'user_lang_name',
			'user_date_format',
			'user_timezone',
			'lang_set',
			'lang_set_ext',
			'style_id',
		);
		extract($phpbb_dispatcher->trigger_event('core.user_setup', compact($vars)));

		$this->data = $user_data;
		$this->lang_name = $user_lang_name;
		$this->date_format = $user_date_format;

		try
		{
			$this->timezone = new \DateTimeZone($user_timezone);
		}
		catch (\Exception $e)
		{
			// If the timezone the user has selected is invalid, we fall back to UTC.
			$this->timezone = new \DateTimeZone('UTC');
		}

		// We include common language file here to not load it every time a custom language file is included
		$lang = &$this->lang;

		// Do not suppress error if in DEBUG mode
		$include_result = (defined('DEBUG')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx");

		if ($include_result === false)
		{
			die('Language file ' . $this->lang_path . $this->lang_name . "/common.$phpEx" . " couldn't be opened.");
		}

		$this->add_lang($lang_set);
		unset($lang_set);

		foreach ($lang_set_ext as $ext_lang_pair)
		{
			$this->add_lang_ext($ext_lang_pair['ext_name'], $ext_lang_pair['lang_set']);
		}
		unset($lang_set_ext);

		$style_request = $request->variable('style', 0);
		if ($style_request && (!$config['override_user_style'] || $auth->acl_get('a_styles')) && !defined('ADMIN_START'))
		{
			global $SID, $_EXTRA_URL;

			$style_id = $style_request;
			$SID .= '&amp;style=' . $style_id;
			$_EXTRA_URL = array('style=' . $style_id);
		}
		else
		{
			// Set up style
			$style_id = ($style_id) ? $style_id : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']);
		}

		$sql = 'SELECT *
			FROM ' . STYLES_TABLE . " s
			WHERE s.style_id = $style_id";
		$result = $db->sql_query($sql, 3600);
		$this->style = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);

		// Fallback to user's standard style
		if (!$this->style && $style_id != $this->data['user_style'])
		{
			$style_id = $this->data['user_style'];

			$sql = 'SELECT *
				FROM ' . STYLES_TABLE . " s
				WHERE s.style_id = $style_id";
			$result = $db->sql_query($sql, 3600);
			$this->style = $db->sql_fetchrow($result);
			$db->sql_freeresult($result);
		}

		// User has wrong style
		if (!$this->style && $style_id == $this->data['user_style'])
		{
			$style_id = $this->data['user_style'] = $config['default_style'];

			$sql = 'UPDATE ' . USERS_TABLE . "
				SET user_style = $style_id
				WHERE user_id = {$this->data['user_id']}";
			$db->sql_query($sql);

			$sql = 'SELECT *
				FROM ' . STYLES_TABLE . " s
				WHERE s.style_id = $style_id";
			$result = $db->sql_query($sql, 3600);
			$this->style = $db->sql_fetchrow($result);
			$db->sql_freeresult($result);
		}

		if (!$this->style)
		{
			trigger_error('NO_STYLE_DATA', E_USER_ERROR);
		}

		// Now parse the cfg file and cache it
		$parsed_items = $cache->obtain_cfg_items($this->style);

		$check_for = array(
			'pagination_sep'    => (string) ', '
		);

		foreach ($check_for as $key => $default_value)
		{
			$this->style[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value;
			settype($this->style[$key], gettype($default_value));

			if (is_string($default_value))
			{
				$this->style[$key] = htmlspecialchars($this->style[$key]);
			}
		}

		$template->set_style();

		$this->img_lang = $this->lang_name;

		// Call phpbb_user_session_handler() in case external application want to "bend" some variables or replace classes...
		// After calling it we continue script execution...
		phpbb_user_session_handler();

		// If this function got called from the error handler we are finished here.
		if (defined('IN_ERROR_HANDLER'))
		{
			return;
		}

		// Disable board if the install/ directory is still present
		// For the brave development army we do not care about this, else we need to comment out this everytime we develop locally
		if (!defined('DEBUG') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install'))
		{
			// Adjust the message slightly according to the permissions
			if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))
			{
				$message = 'REMOVE_INSTALL';
			}
			else
			{
				$message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
			}
			trigger_error($message);
		}

		// Is board disabled and user not an admin or moderator?