aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/develop/repair_bots.php8
-rw-r--r--phpBB/includes/acm/acm_file.php6
-rw-r--r--phpBB/includes/auth/auth_apache.php8
-rw-r--r--phpBB/includes/auth/auth_db.php2
-rw-r--r--phpBB/includes/auth/auth_ldap.php4
-rw-r--r--phpBB/includes/classes/acl.php30
-rw-r--r--phpBB/includes/classes/session.php12
-rw-r--r--phpBB/includes/classes/template_compile.php2
-rw-r--r--phpBB/includes/classes/user.php2
-rw-r--r--phpBB/includes/constants.php16
-rw-r--r--phpBB/includes/functions.php1109
-rw-r--r--phpBB/includes/functions_admin.php10
-rw-r--r--phpBB/includes/functions_compress.php10
-rw-r--r--phpBB/includes/functions_convert.php14
-rw-r--r--phpBB/includes/functions_messenger.php4
-rw-r--r--phpBB/includes/functions_posting.php6
-rw-r--r--phpBB/includes/functions_privmsgs.php4
-rw-r--r--phpBB/includes/functions_upload.php18
-rw-r--r--phpBB/includes/functions_user.php26
-rw-r--r--phpBB/index.php2
-rw-r--r--phpBB/install/index.php6
-rw-r--r--phpBB/install/install_install.php8
-rw-r--r--phpBB/memberlist.php16
-rw-r--r--phpBB/modules/acp/acp_attachments.php2
-rw-r--r--phpBB/modules/acp/acp_bots.php2
-rw-r--r--phpBB/modules/acp/acp_email.php4
-rw-r--r--phpBB/modules/acp/acp_groups.php10
-rw-r--r--phpBB/modules/acp/acp_inactive.php2
-rw-r--r--phpBB/modules/acp/acp_main.php6
-rw-r--r--phpBB/modules/acp/acp_permission_roles.php12
-rw-r--r--phpBB/modules/acp/acp_permissions.php94
-rw-r--r--phpBB/modules/acp/acp_prune.php2
-rw-r--r--phpBB/modules/acp/acp_users.php66
-rw-r--r--phpBB/modules/acp/auth.php58
-rw-r--r--phpBB/modules/mcp/mcp_warn.php2
-rw-r--r--phpBB/modules/ucp/ucp_activate.php2
-rw-r--r--phpBB/modules/ucp/ucp_groups.php2
-rw-r--r--phpBB/modules/ucp/ucp_pm_compose.php2
-rw-r--r--phpBB/modules/ucp/ucp_profile.php4
-rw-r--r--phpBB/modules/ucp/ucp_register.php6
-rw-r--r--phpBB/modules/ucp/ucp_remind.php4
-rw-r--r--phpBB/modules/ucp/ucp_resend.php6
-rw-r--r--phpBB/modules/ucp/ucp_zebra.php4
-rw-r--r--phpBB/plugins/bootstrap.php550
-rw-r--r--phpBB/search.php2
-rw-r--r--phpBB/viewonline.php4
46 files changed, 694 insertions, 1475 deletions
diff --git a/phpBB/develop/repair_bots.php b/phpBB/develop/repair_bots.php
index 21c6652243..6d3e57da57 100644
--- a/phpBB/develop/repair_bots.php
+++ b/phpBB/develop/repair_bots.php
@@ -2,7 +2,7 @@
/**
* Rebuild BOTS
*
-* You should make a backup from your whole database. Things can and will go wrong.
+* You should make a backup from your whole database. Things can and will go wrong.
* This will only work if no BOTs were added.
*
*/
@@ -74,9 +74,9 @@ $bots = array(
'Yahoo [Bot]' => array('Yahoo! Slurp', ''),
'YahooSeeker [Bot]' => array('YahooSeeker/', ''),
);
-
+
$bot_ids = array();
-user_get_id_name($bot_ids, array_keys($bots), USER_IGNORE);
+user_get_id_name($bot_ids, array_keys($bots), phpbb::USER_IGNORE);
foreach($bot_ids as $bot)
{
user_delete('remove', $bot);
@@ -119,7 +119,7 @@ function add_bots($bots)
foreach ($bots as $bot_name => $bot_ary)
{
$user_row = array(
- 'user_type' => USER_IGNORE,
+ 'user_type' => phpbb::USER_IGNORE,
'group_id' => $group_id,
'username' => $bot_name,
'user_regdate' => time(),
diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php
index e0e99d4153..23183d1865 100644
--- a/phpBB/includes/acm/acm_file.php
+++ b/phpBB/includes/acm/acm_file.php
@@ -89,7 +89,7 @@ class acm
include(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT);
}
- phpbb_chmod($this->cache_dir . 'data_global.' . PHP_EXT, CHMOD_WRITE);
+ phpbb_chmod($this->cache_dir . 'data_global.' . PHP_EXT, phpbb::CHMOD_WRITE);
}
else
{
@@ -192,7 +192,7 @@ class acm
include(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT);
}
- phpbb_chmod($this->cache_dir . "data{$var_name}." . PHP_EXT, CHMOD_WRITE);
+ phpbb_chmod($this->cache_dir . "data{$var_name}." . PHP_EXT, phpbb::CHMOD_WRITE);
}
}
else
@@ -407,7 +407,7 @@ class acm
include(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT);
}
- phpbb_chmod($filename, CHMOD_WRITE);
+ phpbb_chmod($filename, phpbb::CHMOD_WRITE);
$query_result = $query_id;
}
diff --git a/phpBB/includes/auth/auth_apache.php b/phpBB/includes/auth/auth_apache.php
index d23b27a7dd..9ff10ccf7d 100644
--- a/phpBB/includes/auth/auth_apache.php
+++ b/phpBB/includes/auth/auth_apache.php
@@ -96,7 +96,7 @@ function login_apache(&$username, &$password)
if ($row)
{
// User inactive...
- if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE)
+ if ($row['user_type'] == phpbb::USER_INACTIVE || $row['user_type'] == phpbb::USER_IGNORE)
{
return array(
'status' => LOGIN_ERROR_ACTIVE,
@@ -104,7 +104,7 @@ function login_apache(&$username, &$password)
'user_row' => $row,
);
}
-
+
// Successful login...
return array(
'status' => LOGIN_SUCCESS,
@@ -160,7 +160,7 @@ function autologin_apache()
if ($row)
{
- return ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE) ? array() : $row;
+ return ($row['user_type'] == phpbb::USER_INACTIVE || $row['user_type'] == phpbb::USER_IGNORE) ? array() : $row;
}
if (!function_exists('user_add'))
@@ -213,7 +213,7 @@ function user_row_apache($username, $password)
'user_password' => phpbb_hash($password),
'user_email' => '',
'group_id' => (int) $row['group_id'],
- 'user_type' => USER_NORMAL,
+ 'user_type' => phpbb::USER_NORMAL,
'user_ip' => $user->ip,
);
}
diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php
index 82750936f1..670b16c4e3 100644
--- a/phpBB/includes/auth/auth_db.php
+++ b/phpBB/includes/auth/auth_db.php
@@ -180,7 +180,7 @@ function login_db(&$username, &$password)
}
// User inactive...
- if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE)
+ if ($row['user_type'] == phpbb::USER_INACTIVE || $row['user_type'] == phpbb::USER_IGNORE)
{
return array(
'status' => LOGIN_ERROR_ACTIVE,
diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php
index 3163153997..797d3c1cbb 100644
--- a/phpBB/includes/auth/auth_ldap.php
+++ b/phpBB/includes/auth/auth_ldap.php
@@ -187,7 +187,7 @@ function login_ldap(&$username, &$password)
unset($ldap_result);
// User inactive...
- if ($row['user_type'] == USER_INACTIVE || $row['user_type'] == USER_IGNORE)
+ if ($row['user_type'] == phpbb::USER_INACTIVE || $row['user_type'] == phpbb::USER_IGNORE)
{
return array(
'status' => LOGIN_ERROR_ACTIVE,
@@ -225,7 +225,7 @@ function login_ldap(&$username, &$password)
'user_password' => phpbb_hash($password),
'user_email' => (!empty($config['ldap_email'])) ? $ldap_result[0][$config['ldap_email']][0] : '',
'group_id' => (int) $row['group_id'],
- 'user_type' => USER_NORMAL,
+ 'user_type' => phpbb::USER_NORMAL,
'user_ip' => $user->ip,
);
diff --git a/phpBB/includes/classes/acl.php b/phpBB/includes/classes/acl.php
index e7fa0f2674..226bb8be23 100644
--- a/phpBB/includes/classes/acl.php
+++ b/phpBB/includes/classes/acl.php
@@ -382,13 +382,13 @@ class auth
// Key 0 in $hold_ary are global options, all others are forum_ids
// If this user is founder we're going to force fill the admin options ...
- if ($userdata['user_type'] == USER_FOUNDER)
+ if ($userdata['user_type'] == phpbb::USER_FOUNDER)
{
foreach ($this->acl_options['global'] as $opt => $id)
{
if (strpos($opt, 'a_') === 0)
{
- $hold_ary[0][$this->acl_options['id'][$opt]] = ACL_YES;
+ $hold_ary[0][$this->acl_options['id'][$opt]] = phpbb::ACL_YES;
}
}
}
@@ -437,14 +437,14 @@ class auth
// If one option is allowed, the global permission for this option has to be allowed too
// example: if the user has the a_ permission this means he has one or more a_* permissions
- if ($auth_ary[$this->acl_options['id'][$opt]] == ACL_YES && (!isset($bitstring[$this->acl_options[$ary_key][$option_key]]) || $bitstring[$this->acl_options[$ary_key][$option_key]] == ACL_NEVER))
+ if ($auth_ary[$this->acl_options['id'][$opt]] == phpbb::ACL_YES && (!isset($bitstring[$this->acl_options[$ary_key][$option_key]]) || $bitstring[$this->acl_options[$ary_key][$option_key]] == phpbb::ACL_NEVER))
{
- $bitstring[$this->acl_options[$ary_key][$option_key]] = ACL_YES;
+ $bitstring[$this->acl_options[$ary_key][$option_key]] = phpbb::ACL_YES;
}
}
else
{
- $bitstring[$id] = ACL_NEVER;
+ $bitstring[$id] = phpbb::ACL_NEVER;
}
}
@@ -637,22 +637,22 @@ class auth
$option = ($sql_opts_select) ? $row['auth_option'] : $this->acl_options['option'][$row['auth_option_id']];
// @todo: use the ref technique to reduce opcode generation
- if (!isset($hold_ary[$row['user_id']][$row['forum_id']][$option]) || (isset($hold_ary[$row['user_id']][$row['forum_id']][$option]) && $hold_ary[$row['user_id']][$row['forum_id']][$option] != ACL_NEVER))
+ if (!isset($hold_ary[$row['user_id']][$row['forum_id']][$option]) || (isset($hold_ary[$row['user_id']][$row['forum_id']][$option]) && $hold_ary[$row['user_id']][$row['forum_id']][$option] != phpbb::ACL_NEVER))
{
$hold_ary[$row['user_id']][$row['forum_id']][$option] = $row['auth_setting'];
// If we detect ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again)
- if ($row['auth_setting'] == ACL_NEVER)
+ if ($row['auth_setting'] == phpbb::ACL_NEVER)
{
$flag = substr($option, 0, strpos($option, '_') + 1);
- if (isset($hold_ary[$row['user_id']][$row['forum_id']][$flag]) && $hold_ary[$row['user_id']][$row['forum_id']][$flag] == ACL_YES)
+ if (isset($hold_ary[$row['user_id']][$row['forum_id']][$flag]) && $hold_ary[$row['user_id']][$row['forum_id']][$flag] == phpbb::ACL_YES)
{
unset($hold_ary[$row['user_id']][$row['forum_id']][$flag]);
-/* if (in_array(ACL_YES, $hold_ary[$row['user_id']][$row['forum_id']]))
+/* if (in_array(phpbb::ACL_YES, $hold_ary[$row['user_id']][$row['forum_id']]))
{
- $hold_ary[$row['user_id']][$row['forum_id']][$flag] = ACL_YES;
+ $hold_ary[$row['user_id']][$row['forum_id']][$flag] = phpbb::ACL_YES;
}
*/
}
@@ -856,24 +856,24 @@ class auth
*/
private function _set_group_hold_ary(&$hold_ary, $option_id, $setting)
{
- if (!isset($hold_ary[$option_id]) || (isset($hold_ary[$option_id]) && $hold_ary[$option_id] != ACL_NEVER))
+ if (!isset($hold_ary[$option_id]) || (isset($hold_ary[$option_id]) && $hold_ary[$option_id] != phpbb::ACL_NEVER))
{
$hold_ary[$option_id] = $setting;
// If we detect ACL_NEVER, we will unset the flag option (within building the bitstring it is correctly set again)
- if ($setting == ACL_NEVER)
+ if ($setting == phpbb::ACL_NEVER)
{
$flag = substr($this->acl_options['option'][$option_id], 0, strpos($this->acl_options['option'][$option_id], '_') + 1);
$flag = (int) $this->acl_options['id'][$flag];
- if (isset($hold_ary[$flag]) && $hold_ary[$flag] == ACL_YES)
+ if (isset($hold_ary[$flag]) && $hold_ary[$flag] == phpbb::ACL_YES)
{
unset($hold_ary[$flag]);
/* This is uncommented, because i suspect this being slightly wrong due to mixed permission classes being possible
- if (in_array(ACL_YES, $hold_ary))
+ if (in_array(phpbb::ACL_YES, $hold_ary))
{
- $hold_ary[$flag] = ACL_YES;
+ $hold_ary[$flag] = phpbb::ACL_YES;
}*/
}
}
diff --git a/phpBB/includes/classes/session.php b/phpBB/includes/classes/session.php
index 5a42fdaac2..4c953d9605 100644
--- a/phpBB/includes/classes/session.php
+++ b/phpBB/includes/classes/session.php
@@ -89,9 +89,9 @@ abstract class phpbb_session
// Set auth to false (only valid for an user object)
$this->auth = false;
- // Some system/server variables, directly generated by phpbb_system methods. Used like an array.
+ // Some system/server variables, directly generated by phpbb_system_info methods. Used like an array.
// We use the phpbb:: one, because it could've been modified and being a completely different class
- $this->system = &phpbb::$instances['system'];
+ $this->system =& phpbb::$instances['server-vars'];
}
/**
@@ -223,7 +223,7 @@ abstract class phpbb_session
$sql = 'SELECT u.*
FROM ' . USERS_TABLE . ' u, ' . SESSIONS_KEYS_TABLE . ' k
WHERE u.user_id = ' . (int) $this->cookie_data['u'] . '
- AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ")
+ AND u.user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ")
AND k.user_id = u.user_id
AND k.key_id = '" . phpbb::$db->sql_escape(md5($this->cookie_data['k'])) . "'";
$result = phpbb::$db->sql_query($sql);
@@ -240,7 +240,7 @@ abstract class phpbb_session
$sql = 'SELECT *
FROM ' . USERS_TABLE . '
WHERE user_id = ' . (int) $this->cookie_data['u'] . '
- AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
+ AND user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
$result = phpbb::$db->sql_query($sql);
$this->data = phpbb::$db->sql_fetchrow($result);
phpbb::$db->sql_freeresult($result);
@@ -351,7 +351,7 @@ abstract class phpbb_session
// session exists in which case session_id will also be set
// Is user banned? Are they excluded? Won't return on ban, exists within method
- if ($this->data['user_type'] != USER_FOUNDER)
+ if ($this->data['user_type'] != phpbb::USER_FOUNDER)
{
if (!phpbb::$config['forwarded_for_check'])
{
@@ -1092,7 +1092,7 @@ abstract class phpbb_session
phpbb::$db->sql_query($sql);
}
- $this->is_registered = ($this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == USER_NORMAL || $this->data['user_type'] == USER_FOUNDER)) ? true : false;
+ $this->is_registered = ($this->data['user_id'] != ANONYMOUS && ($this->data['user_type'] == phpbb::USER_NORMAL || $this->data['user_type'] == phpbb::USER_FOUNDER)) ? true : false;
$this->is_bot = (!$this->is_registered && $this->data['user_id'] != ANONYMOUS) ? true : false;
$this->data['user_lang'] = basename($this->data['user_lang']);
diff --git a/phpBB/includes/classes/template_compile.php b/phpBB/includes/classes/template_compile.php
index 471ca5eca3..0ad6021e44 100644
--- a/phpBB/includes/classes/template_compile.php
+++ b/phpBB/includes/classes/template_compile.php
@@ -833,7 +833,7 @@ class template_compile
@flock($destination_handle, LOCK_UN);
@fclose($destination_handle);
- phpbb_chmod($filename, CHMOD_WRITE);
+ phpbb_chmod($filename, phpbb::CHMOD_WRITE);
clearstatcache();
diff --git a/phpBB/includes/classes/user.php b/phpBB/includes/classes/user.php
index 067d97e8cb..af425f2299 100644
--- a/phpBB/includes/classes/user.php
+++ b/phpBB/includes/classes/user.php
@@ -29,7 +29,7 @@ class phpbb_user extends phpbb_session
/**
* @var array required phpBB objects
*/
- public $phpbb_required = array('config', 'acl', 'db', 'template', 'security', 'system', 'acm', 'api:user');
+ public $phpbb_required = array('config', 'acl', 'db', 'template', 'security', 'server-vars', 'acm', 'api:user');
/**
* @var array Optional phpBB objects
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index e4221db8bb..c62e50d481 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -42,21 +42,11 @@ define('AVATAR_UPLOAD', 1);
define('AVATAR_REMOTE', 2);
define('AVATAR_GALLERY', 3);
-define('USER_NORMAL', 0);
-define('USER_INACTIVE', 1);
-define('USER_IGNORE', 2);
-define('USER_FOUNDER', 3);
-
define('INACTIVE_REGISTER', 1);
define('INACTIVE_PROFILE', 2);
define('INACTIVE_MANUAL', 3);
define('INACTIVE_REMIND', 4);
-// ACL
-define('ACL_NEVER', 0);
-define('ACL_YES', 1);
-define('ACL_NO', -1);
-
// Login error codes
define('LOGIN_CONTINUE', 1);
define('LOGIN_BREAK', 2);
@@ -179,12 +169,6 @@ define('REFERER_VALIDATE_NONE', 0);
define('REFERER_VALIDATE_HOST', 1);
define('REFERER_VALIDATE_PATH', 2);
-// phpbb_chmod() permissions
-@define('CHMOD_ALL', 7);
-@define('CHMOD_READ', 4);
-@define('CHMOD_WRITE', 2);
-@define('CHMOD_EXECUTE', 1);
-
// Additional constants
define('VOTE_CONVERTED', 127);
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index b8ca86bc07..512c05bf4a 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -19,102 +19,21 @@ if (!defined('IN_PHPBB'))
// Common global functions
/**
-* Replacement for a superglobal (like $_GET or $_POST) which calls
-* trigger_error on any operation, overloads the [] operator using SPL.
-* @package phpBB3
-*/
-class deactivated_super_global implements ArrayAccess, Countable, IteratorAggregate
-{
- /**
- * Holds the error message
- */
- private $message;
-
- /**
- * Constructor generates an error message fitting the super global to be
- * used within the other functions.
- *
- * @param string $name Name of the super global this is a replacement for - e.g. '_GET'
- */
- public function __construct($name)
- {
- $this->message = 'Illegal use of $' . $name . '. You must use the request class or request_var() to access input data. Found in %s on line %d. This error message was generated';
- }
-
- /**
- * Calls trigger_error with the file and line number the super global was used in
- */
- private function error()
- {
- $file = '';
- $line = 0;
-
- $backtrace = debug_backtrace();
- if (isset($backtrace[1]))
- {
- $file = $backtrace[1]['file'];
- $line = $backtrace[1]['line'];
- }
- trigger_error(sprintf($this->message, $file, $line), E_USER_ERROR);
- }
-
- /**
- * Part of the ArrayAccess implementation, will always result in a FATAL error
- */
- public function offsetExists($offset)
- {
- $this->error();
- }
-
- /**
- * Part of the ArrayAccess implementation, will always result in a FATAL error
- */
- public function offsetGet($offset)
- {
- $this->error();
- }
-
- /**
- * Part of the ArrayAccess implementation, will always result in a FATAL error
- */
- public function offsetSet($offset, $value)
- {
- $this->error();
- }
-
- /**
- * Part of the ArrayAccess implementation, will always result in a FATAL error
- */
- public function offsetUnset($offset)
- {
- $this->error();
- }
-
- /**
- * Part of the Countable implementation, will always result in a FATAL error
- */
- public function count()
- {
- $this->error();
- }
-
- /**
- * Part of the Traversable/IteratorAggregate implementation, will always result in a FATAL error
- */
- public function getIterator()
- {
- $this->error();
- }
-}
-
-/**
-* Wrapper function of phpbb_request::variable which exists for backwards
-* compatability.
-* See {@link phpbb_request::variable phpbb_request::variable} for documentation of this
-* function's use.
-* @param bool $cookie This param is mapped to phpbb_request::COOKIE as the last
-* param for phpbb_request::variable for backwards
-* compatability reasons.
+* Wrapper function of phpbb_request::variable which exists for backwards compatability.
+* See {@link phpbb_request::variable phpbb_request::variable} for documentation of this function's use.
+*
+* @param string|array $var_name The form variable's name from which data shall be retrieved.
+* If the value is an array this may be an array of indizes which will give
+* direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a")
+* then specifying array("var", 1) as the name will return "a".
+* @param mixed $default A default value that is returned if the variable was not set.
+* This function will always return a value of the same type as the default.
+* @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters
+* Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
+* @param bool $cookie This param is mapped to phpbb_request::COOKIE as the last param for phpbb_request::variable for backwards compatability reasons.
+*
+* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
+* the same as that of $default. If the variable is not set $default is returned.
*/
function request_var($var_name, $default, $multibyte = false, $cookie = false)
{
@@ -122,69 +41,39 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
}
/**
-* Set config value. Creates missing config entry.
+* Set config value.
+* Creates missing config entry if update did not succeed and phpbb::$config for this entry empty.
+*
+* @param string $config_name The configuration keys name
+* @param string $config_value The configuration value
+* @param bool $is_dynamic True if the configuration entry is not cached
*/
function set_config($config_name, $config_value, $is_dynamic = false)
{
- global $db, $cache, $config;
-
$sql = 'UPDATE ' . CONFIG_TABLE . "
- SET config_value = '" . $db->sql_escape($config_value) . "'
- WHERE config_name = '" . $db->sql_escape($config_name) . "'";
- $db->sql_query($sql);
+ SET config_value = '" . phpbb::$db->sql_escape($config_value) . "'
+ WHERE config_name = '" . phpbb::$db->sql_escape($config_name) . "'";
+ phpbb::$db->sql_query($sql);
- if (!$db->sql_affectedrows() && !isset($config[$config_name]))
+ if (!phpbb::$db->sql_affectedrows() && !isset(phpbb::$config[$config_name]))
{
- $sql = 'INSERT INTO ' . CONFIG_TABLE . ' ' . $db->sql_build_array('INSERT', array(
- 'config_name' => $config_name,
- 'config_value' => $config_value,
- 'is_dynamic' => ($is_dynamic) ? 1 : 0));
- $db->sql_query($sql);
+ $sql = 'INSERT INTO ' . CONFIG_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
+ 'config_name' => (string) $config_name,
+ 'config_value' => (string) $config_value,
+ 'is_dynamic' => (int) $is_dynamic,
+ ));
+ phpbb::$db->sql_query($sql);
}
- $config[$config_name] = $config_value;
+ phpbb::$config[$config_name] = $config_value;
if (!$is_dynamic)
{
- $cache->destroy('config');
+ phpbb::$acm->destroy('#config');
}
}
/**
-* Generates an alphanumeric random string of given length
-*/
-function gen_rand_string($num_chars = 8)
-{
- $rand_str = unique_id();
- $rand_str = str_replace('0', 'Z', strtoupper(base_convert($rand_str, 16, 35)));
-
- return substr($rand_str, 0, $num_chars);
-}
-
-/**
-* Return unique id
-* @param string $extra additional entropy
-*/
-function unique_id($extra = 'c')
-{
- static $dss_seeded = false;
- global $config;
-
- $val = $config['rand_seed'] . microtime();
- $val = md5($val);
- $config['rand_seed'] = md5($config['rand_seed'] . $val . $extra);
-
- if ($dss_seeded !== true && ($config['rand_seed_last_update'] < time() - rand(1,10)))
- {
- set_config('rand_seed', $config['rand_seed'], true);
- set_config('rand_seed_last_update', time(), true);
- $dss_seeded = true;
- }
-
- return substr($val, 4, 16);
-}
-
-/**
* Return formatted string for filesizes
*/
function get_formatted_filesize($bytes, $add_size_lang = true)
@@ -240,200 +129,6 @@ function still_on_time($extra_time = 15)
}
/**
-*
-* @version Version 0.1 / $Id$
-*
-* Portable PHP password hashing framework.
-*
-* Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
-* the public domain.
-*
-* There's absolutely no warranty.
-*
-* The homepage URL for this framework is:
-*
-* http://www.openwall.com/phpass/
-*
-* Please be sure to update the Version line if you edit this file in any way.
-* It is suggested that you leave the main version number intact, but indicate
-* your project name (after the slash) and add your own revision information.
-*
-* Please do not change the "private" password hashing method implemented in
-* here, thereby making your hashes incompatible. However, if you must, please
-* change the hash type identifier (the "$P$") to something different.
-*
-* Obviously, since this code is in the public domain, the above are not
-* requirements (there can be none), but merely suggestions.
-*
-*
-* Hash the password
-*/
-function phpbb_hash($password)
-{
- $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
-
- $random_state = unique_id();
- $random = '';
- $count = 6;
-
- if (($fh = @fopen('/dev/urandom', 'rb')))
- {
- $random = fread($fh, $count);
- fclose($fh);
- }
-
- if (strlen($random) < $count)
- {
- $random = '';
-
- for ($i = 0; $i < $count; $i += 16)
- {
- $random_state = md5(unique_id() . $random_state);
- $random .= pack('H*', md5($random_state));
- }
- $random = substr($random, 0, $count);
- }
-
- $hash = _hash_crypt_private($password, _hash_gensalt_private($random, $itoa64), $itoa64);
-
- if (strlen($hash) == 34)
- {
- return $hash;
- }
-
- return md5($password);
-}
-
-/**
-* Check for correct password
-*
-* @param string $password The password in plain text
-* @param string $hash The stored password hash
-*
-* @return bool Returns true if the password is correct, false if not.
-*/
-function phpbb_check_hash($password, $hash)
-{
- $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
- if (strlen($hash) == 34)
- {
- return (_hash_crypt_private($password, $hash, $itoa64) === $hash) ? true : false;
- }
-
- return (md5($password) === $hash) ? true : false;
-}
-
-/**
-* Generate salt for hash generation
-*/
-function _hash_gensalt_private($input, &$itoa64, $iteration_count_log2 = 6)
-{
- if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31)
- {
- $iteration_count_log2 = 8;
- }
-
- $output = '$H$';
- $output .= $itoa64[min($iteration_count_log2 + 5, 30)];
- $output .= _hash_encode64($input, 6, $itoa64);
-
- return $output;
-}
-
-/**
-* Encode hash
-*/
-function _hash_encode64($input, $count, &$itoa64)
-{
- $output = '';
- $i = 0;
-
- do
- {
- $value = ord($input[$i++]);
- $output .= $itoa64[$value & 0x3f];
-
- if ($i < $count)
- {
- $value |= ord($input[$i]) << 8;
- }
-
- $output .= $itoa64[($value >> 6) & 0x3f];
-
- if ($i++ >= $count)
- {
- break;
- }
-
- if ($i < $count)
- {
- $value |= ord($input[$i]) << 16;
- }
-
- $output .= $itoa64[($value >> 12) & 0x3f];
-
- if ($i++ >= $count)
- {
- break;
- }
-
- $output .= $itoa64[($value >> 18) & 0x3f];
- }
- while ($i < $count);
-
- return $output;
-}
-
-/**
-* The crypt function/replacement
-*/
-function _hash_crypt_private($password, $setting, &$itoa64)
-{
- $output = '*';
-
- // Check for correct hash
- if (substr($setting, 0, 3) != '$H$')
- {
- return $output;
- }
-
- $count_log2 = strpos($itoa64, $setting[3]);
-
- if ($count_log2 < 7 || $count_log2 > 30)
- {
- return $output;
- }
-
- $count = 1 << $count_log2;
- $salt = substr($setting, 4, 8);
-
- if (strlen($salt) != 8)
- {
- return $output;
- }
-
- /**
- * We're kind of forced to use MD5 here since it's the only
- * cryptographic primitive available in all versions of PHP
- * currently in use. To implement our own low-level crypto
- * in PHP would result in much worse performance and
- * consequently in lower iteration counts and hashes that are
- * quicker to crack (by non-PHP code).
- */
- $hash = md5($salt . $password, true);
- do
- {
- $hash = md5($hash . $password, true);
- }
- while (--$count);
-
- $output = substr($setting, 0, 12);
- $output .= _hash_encode64($hash, 16, $itoa64);
-
- return $output;
-}
-
-/**
* Global function for chmodding directories and files for internal use
* This function determines owner and group whom the file belongs to and user and group of PHP and then set safest possible file permissions.
* The function determines owner and group from common.php file and sets the same to the provided file. Permissions are mapped to the group, user always has rw(x) permission.
@@ -442,10 +137,10 @@ function _hash_crypt_private($password, $setting, &$itoa64)
*
* Supported constants representing bit fields are:
*
-* CHMOD_ALL - all permissions (7)
-* CHMOD_READ - read permission (4)
-* CHMOD_WRITE - write permission (2)
-* CHMOD_EXECUTE - execute permission (1)
+* phpbb::CHMOD_ALL - all permissions (7)
+* phpbb::CHMOD_READ - read permission (4)
+* phpbb::CHMOD_WRITE - write permission (2)
+* phpbb::CHMOD_EXECUTE - execute permission (1)
*
* NOTE: The function uses POSIX extension and fileowner()/filegroup() functions. If any of them is disabled, this function tries to build proper permissions, by calling is_readable() and is_writable() functions.
*
@@ -455,7 +150,7 @@ function _hash_crypt_private($password, $setting, &$itoa64)
*
* @author faw, phpBB Group
*/
-function phpbb_chmod($filename, $perms = CHMOD_READ)
+function phpbb_chmod($filename, $perms = phpbb::CHMOD_READ)
{
// Return if the file no longer exists.
if (!file_exists($filename))
@@ -522,15 +217,15 @@ function phpbb_chmod($filename, $perms = CHMOD_READ)
}
// Owner always has read/write permission
- $owner = CHMOD_READ | CHMOD_WRITE;
+ $owner = phpbb::CHMOD_READ | phpbb::CHMOD_WRITE;
if (is_dir($filename))
{
- $owner |= CHMOD_EXECUTE;
+ $owner |= phpbb::CHMOD_EXECUTE;
// Only add execute bit to the permission if the dir needs to be readable
- if ($perms & CHMOD_READ)
+ if ($perms & phpbb::CHMOD_READ)
{
- $perms |= CHMOD_EXECUTE;
+ $perms |= phpbb::CHMOD_EXECUTE;
}
}
@@ -555,7 +250,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ)
clearstatcache();
- if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))))
+ if (!is_null($php) || ((!($perms & phpbb::CHMOD_READ) || is_readable($filename)) && (!($perms & phpbb::CHMOD_WRITE) || is_writable($filename))))
{
break;
}
@@ -565,7 +260,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ)
clearstatcache();
- if (!is_null($php) || ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))))
+ if (!is_null($php) || ((!($perms & phpbb::CHMOD_READ) || is_readable($filename)) && (!($perms & phpbb::CHMOD_WRITE) || is_writable($filename))))
{
break;
}
@@ -578,211 +273,6 @@ function phpbb_chmod($filename, $perms = CHMOD_READ)
return $result;
}
-/*
-* Checks if a path ($path) is absolute or relative
-*
-* @param string $path Path to check absoluteness of
-* @return boolean
-*/
-function is_absolute($path)
-{
- return ($path[0] == '/' || (DIRECTORY_SEPARATOR == '\\' && preg_match('#^[a-z]:/#i', $path))) ? true : false;
-}
-
-/**
-* @author Chris Smith <chris@project-minerva.org>
-* @copyright 2006 Project Minerva Team
-* @param string $path The path which we should attempt to resolve.
-* @return mixed
-*/
-function phpbb_own_realpath($path)
-{
- // Now to perform funky shizzle
-
- // Switch to use UNIX slashes
- $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
- $path_prefix = '';
-
- // Determine what sort of path we have
- if (is_absolute($path))
- {
- $absolute = true;
-
- if ($path[0] == '/')
- {
- // Absolute path, *NIX style
- $path_prefix = '';
- }
- else
- {
- // Absolute path, Windows style
- // Remove the drive letter and colon
- $path_prefix = $path[0] . ':';
- $path = substr($path, 2);
- }
- }
- else
- {
- // Relative Path
- // Prepend the current working directory
- if (function_exists('getcwd'))
- {
- // This is the best method, hopefully it is enabled!
- $path = str_replace(DIRECTORY_SEPARATOR, '/', getcwd()) . '/' . $path;
- $absolute = true;
- if (preg_match('#^[a-z]:#i', $path))
- {
- $path_prefix = $path[0] . ':';
- $path = substr($path, 2);
- }
- else
- {
- $path_prefix = '';
- }
- }
- else if (isset($_SERVER['SCRIPT_FILENAME']) && !empty($_SERVER['SCRIPT_FILENAME']))
- {
- // Warning: If chdir() has been used this will lie!
- // Warning: This has some problems sometime (CLI can create them easily)
- $path = str_replace(DIRECTORY_SEPARATOR, '/', dirname($_SERVER['SCRIPT_FILENAME'])) . '/' . $path;
- $absolute = true;
- $path_prefix = '';
- }
- else
- {
- // We have no way of getting the absolute path, just run on using relative ones.
- $absolute = false;
- $path_prefix = '.';
- }
- }
-
- // Remove any repeated slashes
- $path = preg_replace('#/{2,}#', '/', $path);
-
- // Remove the slashes from the start and end of the path
- $path = trim($path, '/');
-
- // Break the string into little bits for us to nibble on
- $bits = explode('/', $path);
-
- // Remove any . in the path, renumber array for the loop below
- $bits = array_values(array_diff($bits, array('.')));
-
- // Lets get looping, run over and resolve any .. (up directory)
- for ($i = 0, $max = sizeof($bits); $i < $max; $i++)
- {
- // @todo Optimise
- if ($bits[$i] == '..' )
- {
- if (isset($bits[$i - 1]))
- {
- if ($bits[$i - 1] != '..')
- {
- // We found a .. and we are able to traverse upwards, lets do it!
- unset($bits[$i]);
- unset($bits[$i - 1]);
- $i -= 2;
- $max -= 2;
- $bits = array_values($bits);
- }
- }
- else if ($absolute) // ie. !isset($bits[$i - 1]) && $absolute
- {
- // We have an absolute path trying to descend above the root of the filesystem
- // ... Error!
- return false;
- }
- }
- }
-
- // Prepend the path prefix
- array_unshift($bits, $path_prefix);
-
- $resolved = '';
-
- $max = sizeof($bits) - 1;
-
- // Check if we are able to resolve symlinks, Windows cannot.
- $symlink_resolve = (function_exists('readlink')) ? true : false;
-
- foreach ($bits as $i => $bit)
- {
- if (@is_dir("$resolved/$bit") || ($i == $max && @is_file("$resolved/$bit")))
- {
- // Path Exists
- if ($symlink_resolve && is_link("$resolved/$bit") && ($link = readlink("$resolved/$bit")))
- {
- // Resolved a symlink.
- $resolved = $link . (($i == $max) ? '' : '/');
- continue;
- }
- }
- else
- {
- // Something doesn't exist here!
- // This is correct realpath() behaviour but sadly open_basedir and safe_mode make this problematic
- // return false;
- }
- $resolved .= $bit . (($i == $max) ? '' : '/');
- }
-
- // @todo If the file exists fine and open_basedir only has one path we should be able to prepend it
- // because we must be inside that basedir, the question is where...
- // @internal The slash in is_dir() gets around an open_basedir restriction
- if (!@file_exists($resolved) || (!is_dir($resolved . '/') && !is_file($resolved)))
- {
- return false;
- }
-
- // Put the slashes back to the native operating systems slashes
- $resolved = str_replace('/', DIRECTORY_SEPARATOR, $resolved);
-
- // Check for DIRECTORY_SEPARATOR at the end (and remove it!)
- if (substr($resolved, -1) == DIRECTORY_SEPARATOR)
- {
- return substr($resolved, 0, -1);
- }
-
- return $resolved; // We got here, in the end!
-}
-
-if (!function_exists('realpath'))
-{
- /**
- * A wrapper for realpath
- * @ignore
- */
- function phpbb_realpath($path)
- {
- return phpbb_own_realpath($path);
- }
-}
-else
-{
- /**
- * A wrapper for realpath
- */
- function phpbb_realpath($path)
- {
- $realpath = realpath($path);
-
- // Strangely there are provider not disabling realpath but returning strange values. :o
- // We at least try to cope with them.
- if ($realpath === $path || $realpath === false)
- {
- return phpbb_own_realpath($path);
- }
-
- // Check for DIRECTORY_SEPARATOR at the end (and remove it!)
- if (substr($realpath, -1) == DIRECTORY_SEPARATOR)
- {
- $realpath = substr($realpath, 0, -1);
- }
-
- return $realpath;
- }
-}
-
// functions used for building option fields
/**
@@ -1668,498 +1158,10 @@ function on_page($num_items, $per_page, $start)
return sprintf($user->lang['PAGE_OF'], $on_page, max(ceil($num_items / $per_page), 1));
}
-// Server functions (building urls, redirecting...)
-
-/**
-* Append session id to url.
-* This function supports hooks.
-*
-* @param string $url The url the session id needs to be appended to (can have params)
-* @param mixed $params String or array of additional url parameters
-* @param bool $is_amp Is url using &amp; (true) or & (false)
-* @param string $session_id Possibility to use a custom session id instead of the global one
-*
-* Examples:
-* <code>
-* append_sid(PHPBB_ROOT_PATH . 'viewtopic.' . PHP_EXT . '?t=1&amp;f=2');
-* append_sid(PHPBB_ROOT_PATH . 'viewtopic.' . PHP_EXT, 't=1&amp;f=2');
-* append_sid('viewtopic', 't=1&amp;f=2'); // short notation of the above example
-* append_sid('viewtopic', 't=1&f=2', false);
-* append_sid('viewtopic', array('t' => 1, 'f' => 2));
-* </code>
-*
-*/
-function append_sid($url, $params = false, $is_amp = true, $session_id = false)
-{
- global $_SID, $_EXTRA_URL, $phpbb_hook;
- static $parsed_urls = array();
-
- // The following code is used to make sure such calls like append_sid('viewtopic') (ommitting phpbb_root_path and php_ext) work as intended
- if (isset($parsed_urls[$url]))
- {
- // Set an url like 'viewtopic' to PHPBB_ROOT_PATH . 'viewtopic.' . PHP_EXT
- $url = $parsed_urls[$url];
- }
- else
- {
- // If we detect an url without root path and extension, and also not a relative or absolute path, we add it and put it to the parsed urls
- if (strpos($url, '.' . PHP_EXT) === false && $url[0] != '.' && $url[0] != '/')
- {
- $parsed_urls[$url] = $url = PHPBB_ROOT_PATH . $url . '.' . PHP_EXT;
- }
- }
-
- if (empty($params))
- {
- $params = false;
- }
-
- // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropiatly.
- // They could mimick most of what is within this function
- if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id))
- {
- if ($phpbb_hook->hook_return(__FUNCTION__))
- {
- return $phpbb_hook->hook_return_result(__FUNCTION__);
- }
- }
-
- $params_is_array = is_array($params);
-
- // Get anchor
- $anchor = '';
- if (strpos($url, '#') !== false)
- {
- list($url, $anchor) = explode('#', $url, 2);
- $anchor = '#' . $anchor;
- }
- else if (!$params_is_array && strpos($params, '#') !== false)
- {
- list($params, $anchor) = explode('#', $params, 2);
- $anchor = '#' . $anchor;
- }
-
- // Handle really simple cases quickly
- if ($_SID == '' && $session_id === false && empty($_EXTRA_URL) && !$params_is_array && !$anchor)
- {
- if ($params === false)
- {
- return $url;
- }
-
- $url_delim = (strpos($url, '?') === false) ? '?' : (($is_amp) ? '&amp;' : '&');
- return $url . ($params !== false ? $url_delim. $params : '');
- }
-
- // Assign sid if session id is not specified
- if ($session_id === false)
- {
- $session_id = $_SID;
- }
-
- $amp_delim = ($is_amp) ? '&amp;' : '&';
- $url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim;
-
- // Appending custom url parameter?
- $append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : '';
-
- // Use the short variant if possible ;)
- if ($params === false)
- {
- // Append session id
- if (!$session_id)
- {
- return $url . (($append_url) ? $url_delim . $append_url : '') . $anchor;
- }
- else
- {
- return $url . (($append_url) ? $url_delim . $append_url . $amp_delim : $url_delim) . 'sid=' . $session_id . $anchor;
- }
- }
-
- // Build string if parameters are specified as array
- if (is_array($params))
- {
- $output = array();
-
- foreach ($params as $key => $item)
- {
- if ($item === NULL)
- {
- continue;
- }
-
- if ($key == '#')
- {
- $anchor = '#' . $item;
- continue;
- }
-
- $output[] = $key . '=' . $item;
- }
-
- $params = implode($amp_delim, $output);
- }
-
- // Append session id and parameters (even if they are empty)
- // If parameters are empty, the developer can still append his/her parameters without caring about the delimiter
- return $url . (($append_url) ? $url_delim . $append_url . $amp_delim : $url_delim) . $params . ((!$session_id) ? '' : $amp_delim . 'sid=' . $session_id) . $anchor;
-}
-
-/**
-* Generate board url (example: http://www.example.com/phpBB)
-* @param bool $without_script_path if set to true the script path gets not appended (example: http://www.example.com)
-*/
-function generate_board_url($without_script_path = false)
-{
- global $config, $user;
-
- $server_name = $user->host;
- $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
-
- // Forcing server vars is the only way to specify/override the protocol
- if ($config['force_server_vars'] || !$server_name)
- {
- $server_protocol = ($config['server_protocol']) ? $config['server_protocol'] : (($config['cookie_secure']) ? 'https://' : 'http://');
- $server_name = $config['server_name'];
- $server_port = (int) $config['server_port'];
- $script_path = $config['script_path'];
-
- $url = $server_protocol . $server_name;
- $cookie_secure = $config['cookie_secure'];
- }
- else
- {
- // Do not rely on cookie_secure, users seem to think that it means a secured cookie instead of an encrypted connection
- $cookie_secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
- $url = (($cookie_secure) ? 'https://' : 'http://') . $server_name;
-
- $script_path = $user->page['root_script_path'];
- }
-
- if ($server_port && (($cookie_secure && $server_port <> 443) || (!$cookie_secure && $server_port <> 80)))
- {
- // HTTP HOST can carry a port number (we fetch $user->host, but for old versions this may be true)
- if (strpos($server_name, ':') === false)
- {
- $url .= ':' . $server_port;
- }
- }
-
- if (!$without_script_path)
- {
- $url .= $script_path;
- }
-
- // Strip / from the end
- if (substr($url, -1, 1) == '/')
- {
- $url = substr($url, 0, -1);
- }
-
- return $url;
-}
-
-/**
-* Redirects the user to another page then exits the script nicely
-* This function is intended for urls within the board. It's not meant to redirect to cross-domains.
-*
-* @param string $url The url to redirect to
-* @param bool $return If true, do not redirect but return the sanitized URL. Default is no return.
-* @param bool $disable_cd_check If true, redirect() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false.
-*/
-function redirect($url, $return = false, $disable_cd_check = false)
-{
- global $db, $cache, $config, $user;
-
- if (empty($user->lang))
- {
- $user->add_lang('common');
- }
-
- if (!$return)
- {
- garbage_collection();
- }
-
- // Make sure no &amp;'s are in, this will break the redirect
- $url = str_replace('&amp;', '&', $url);
-
- // Determine which type of redirect we need to handle...
- $url_parts = parse_url($url);
-
- if ($url_parts === false)
- {
- // Malformed url, redirect to current page...
- $url = generate_board_url() . '/' . $user->page['page'];
- }
- else if (!empty($url_parts['scheme']) && !empty($url_parts['host']))
- {
- // Attention: only able to redirect within the same domain if $disable_cd_check is false (yourdomain.com -> www.yourdomain.com will not work)
- if (!$disable_cd_check && $url_parts['host'] !== $user->host)
- {
- $url = generate_board_url();
- }
- }
- else if ($url[0] == '/')
- {
- // Absolute uri, prepend direct url...
- $url = generate_board_url(true) . $url;
- }
- else
- {
- // Relative uri
- $pathinfo = pathinfo($url);
-
- // Is the uri pointing to the current directory?
- if ($pathinfo['dirname'] == '.')
- {
- $url = str_replace('./', '', $url);
-
- // Strip / from the beginning
- if ($url && substr($url, 0, 1) == '/')
- {
- $url = substr($url, 1);
- }
-
- if ($user->page['page_dir'])
- {
- $url = generate_board_url() . '/' . $user->page['page_dir'] . '/' . $url;
- }
- else
- {
- $url = generate_board_url() . '/' . $url;
- }
- }
- else
- {
- // Used ./ before, but PHPBB_ROOT_PATH is working better with urls within another root path
- $root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath(PHPBB_ROOT_PATH)));
- $page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($pathinfo['dirname'])));
- $intersection = array_intersect_assoc($root_dirs, $page_dirs);
-
- $root_dirs = array_diff_assoc($root_dirs, $intersection);
- $page_dirs = array_diff_assoc($page_dirs, $intersection);
-
- $dir = str_repeat('../', sizeof($root_dirs)) . implode('/', $page_dirs);
-
- // Strip / from the end
- if ($dir && substr($dir, -1, 1) == '/')
- {
- $dir = substr($dir, 0, -1);
- }
-
- // Strip / from the beginning
- if ($dir && substr($dir, 0, 1) == '/')
- {
- $dir = substr($dir, 1);
- }
-
- $url = str_replace($pathinfo['dirname'] . '/', '', $url);
-
- // Strip / from the beginning
- if (substr($url, 0, 1) == '/')
- {
- $url = substr($url, 1);
- }
-
- $url = (!empty($dir) ? $dir . '/' : '') . $url;
- $url = generate_board_url() . '/' . $url;
- }
- }
-
- // Make sure no linebreaks are there... to prevent http response splitting for PHP < 4.4.2
- if (strpos(urldecode($url), "\n") !== false || strpos(urldecode($url), "\r") !== false || strpos($url, ';') !== false)
- {
- trigger_error('Tried to redirect to potentially insecure url.', E_USER_ERROR);
- }
-
- // Now, also check the protocol and for a valid url the last time...
- $allowed_protocols = array('http', 'https', 'ftp', 'ftps');
- $url_parts = parse_url($url);
-
- if ($url_parts === false || empty($url_parts['scheme']) || !in_array($url_parts['scheme'], $allowed_protocols))
- {
- trigger_error('Tried to redirect to potentially insecure url.', E_USER_ERROR);
- }
-
- if ($return)
- {
- return $url;
- }
-
- // Redirect via an HTML form for PITA webservers
- if (@preg_match('#Microsoft|WebSTAR|Xitami#', getenv('SERVER_SOFTWARE')))
- {
- header('Refresh: 0; URL=' . $url);
-
- echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
- echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="' . $user->lang['DIRECTION'] . '" lang="' . $user->lang['USER_LANG'] . '" xml:lang="' . $user->lang['USER_LANG'] . '">';
- echo '<head>';
- echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
- echo '<meta http-equiv="refresh" content="0; url=' . str_replace('&', '&amp;', $url) . '" />';
- echo '<title>' . $user->lang['REDIRECT'] . '</title>';
- echo '</head>';
- echo '<body>';
- echo '<div style="text-align: center;">' . sprintf($user->lang['URL_REDIRECT'], '<a href="' . str_replace('&', '&amp;', $url) . '">', '</a>') . '</div>';
- echo '</body>';
- echo '</html>';
-
- exit;
- }
-
- // Behave as per HTTP/1.1 spec for others
- header('Location: ' . $url);
- exit;
-}
-
-/**
-* Re-Apply session id after page reloads
-*/
-function reapply_sid($url)
-{
- if ($url === 'index.' . PHP_EXT)
- {
- return append_sid('index.' . PHP_EXT);
- }
- else if ($url === PHPBB_ROOT_PATH . 'index.' . PHP_EXT)
- {
- return append_sid('index');
- }
-
- // Remove previously added sid
- if (strpos($url, '?sid=') !== false)
- {
- $url = preg_replace('/(\?)sid=[a-z0-9]+(&amp;|&)?/', '\1', $url);
- }
- else if (strpos($url, '&sid=') !== false)
- {
- $url = preg_replace('/&sid=[a-z0-9]+(&)?/', '\1', $url);
- }
- else if (strpos($url, '&amp;sid=') !== false)
- {
- $url = preg_replace('/&amp;sid=[a-z0-9]+(&amp;)?/', '\1', $url);
- }
-
- return append_sid($url);
-}
-
-/**
-* Returns url from the session/current page with an re-appended SID with optionally stripping vars from the url
-*/
-function build_url($strip_vars = false)
-{
- global $user;
-
- // Append SID
- $redirect = append_sid($user->page['page'], false, false);
-
- // Add delimiter if not there...
- if (strpos($redirect, '?') === false)
- {
- $redirect .= '?';
- }
-
- // Strip vars...
- if ($strip_vars !== false && strpos($redirect, '?') !== false)
- {
- if (!is_array($strip_vars))
- {
- $strip_vars = array($strip_vars);
- }
-
- $query = $_query = array();
-
- $args = substr($redirect, strpos($redirect, '?') + 1);
- $args = ($args) ? explode('&', $args) : array();
- $redirect = substr($redirect, 0, strpos($redirect, '?'));
-
- foreach ($args as $argument)
- {
- $arguments = explode('=', $argument);
- $key = $arguments[0];
- unset($arguments[0]);
-
- $query[$key] = implode('=', $arguments);
- }
-
- // Strip the vars off
- foreach ($strip_vars as $strip)
- {
- if (isset($query[$strip]))
- {
- unset($query[$strip]);
- }
- }
-
- // Glue the remaining parts together... already urlencoded
- foreach ($query as $key => $value)
- {
- $_query[] = $key . '=' . $value;
- }
- $query = implode('&', $_query);
-
- $redirect .= ($query) ? '?' . $query : '';
- }
-
- return PHPBB_ROOT_PATH . str_replace('&', '&amp;', $redirect);
-}
-
-/**
-* Meta refresh assignment
-* Adds META template variable with meta http tag.
-*
-* @param int $time Time in seconds for meta refresh tag
-* @param string $url URL to redirect to. The url will go through redirect() first before the template variable is assigned
-* @param bool $disable_cd_check If true, meta_refresh() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false.
-*/
-function meta_refresh($time, $url, $disable_cd_check = false)
-{
- global $template;
-
- $url = redirect($url, true, $disable_cd_check);
- $url = str_replace('&', '&amp;', $url);
-
- // For XHTML compatibility we change back & to &amp;
- $template->assign_vars(array(
- 'META' => '<meta http-equiv="refresh" content="' . $time . ';url=' . $url . '" />')
- );
-
- return $url;
-}
//Form validation
-/**
-* Add a secret hash for use in links/GET requests
-* @param string $link_name The name of the link; has to match the name used in check_link_hash, otherwise no restrictions apply
-* @return string the hash
-
-*/
-function generate_link_hash($link_name)
-{
- global $user;
-
- if (!isset($user->data["hash_$link_name"]))
- {
- $user->data["hash_$link_name"] = substr(sha1($user->data['user_form_salt'] . $link_name), 0, 8);
- }
-
- return $user->data["hash_$link_name"];
-}
-
-
-/**
-* checks a link hash - for GET requests
-* @param string $token the submitted token
-* @param string $link_name The name of the link
-* @return boolean true if all is fine
-*/
-function check_link_hash($token, $link_name)
-{
- return $token === generate_link_hash($link_name);
-}
/**
* Add a secret token to the form (requires the S_FORM_TOKEN template variable)
@@ -2446,7 +1448,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
$redirect = reapply_sid($redirect);
// Special case... the user is effectively banned, but we allow founders to login
- if (defined('IN_CHECK_BAN') && $result['user_row']['user_type'] != USER_FOUNDER)
+ if (defined('IN_CHECK_BAN') && $result['user_row']['user_type'] != phpbb::USER_FOUNDER)
{
return;
}
@@ -3341,7 +2343,7 @@ function page_header($page_title = '', $display_online_list = true)
if (($row['session_viewonline']) || $auth->acl_get('u_viewonline'))
{
- $user_online_link = get_username_string(($row['user_type'] <> USER_IGNORE) ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']);
+ $user_online_link = get_username_string(($row['user_type'] <> phpbb::USER_IGNORE) ? 'full' : 'no_profile', $row['user_id'], $row['username'], $row['user_colour']);
$online_userlist .= ($online_userlist != '') ? ', ' . $user_online_link : $user_online_link;
}
}
@@ -3716,23 +2718,4 @@ function exit_handler()
exit;
}
-/**
-* Handler for init calls in phpBB. This function is called in user::setup();
-* This function supports hooks.
-*/
-function phpbb_user_session_handler()
-{
- global $phpbb_hook;
-
- if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__))
- {
- if ($phpbb_hook->hook_return(__FUNCTION__))
- {
- return $phpbb_hook->hook_return_result(__FUNCTION__);
- }
- }
-
- return;
-}
-
?> \ No newline at end of file
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index ec018a4cf1..89c6a21468 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -2163,8 +2163,8 @@ function cache_moderators()
),
'WHERE' => '(o.auth_option_id = a.auth_option_id OR o.auth_option_id = r.auth_option_id)
- AND ((a.auth_setting = ' . ACL_NEVER . ' AND r.auth_setting IS NULL)
- OR r.auth_setting = ' . ACL_NEVER . ')
+ AND ((a.auth_setting = ' . phpbb::ACL_NEVER . ' AND r.auth_setting IS NULL)
+ OR r.auth_setting = ' . phpbb::ACL_NEVER . ')
AND a.group_id = ug.group_id
AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . "
AND ug.user_pending = 0
@@ -2256,7 +2256,7 @@ function cache_moderators()
foreach ($auth_ary as $auth_option => $setting)
{
// Make sure at least one ACL_YES option is set...
- if ($setting == ACL_YES)
+ if ($setting == phpbb::ACL_YES)
{
$flag = true;
break;
@@ -2633,7 +2633,7 @@ function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $li
$sql = 'SELECT COUNT(user_id) AS user_count
FROM ' . USERS_TABLE . '
- WHERE user_type = ' . USER_INACTIVE .
+ WHERE user_type = ' . phpbb::USER_INACTIVE .
(($limit_days) ? " AND user_inactive_time >= $limit_days" : '');
$result = $db->sql_query($sql);
$user_count = (int) $db->sql_fetchfield('user_count');
@@ -2646,7 +2646,7 @@ function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $li
$sql = 'SELECT user_id, username, user_regdate, user_lastvisit, user_inactive_time, user_inactive_reason
FROM ' . USERS_TABLE . '
- WHERE user_type = ' . USER_INACTIVE .
+ WHERE user_type = ' . phpbb::USER_INACTIVE .
(($limit_days) ? " AND user_inactive_time >= $limit_days" : '') . "
ORDER BY $sort_by";
$result = $db->sql_query_limit($sql, $limit, $offset);
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index eb25270738..dd3ea9bbf0 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -226,7 +226,7 @@ class compress_zip extends compress
{
trigger_error("Could not create directory $folder");
}
- phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
+ phpbb_chmod($str, phpbb::CHMOD_READ | phpbb::CHMOD_WRITE);
}
}
}
@@ -255,7 +255,7 @@ class compress_zip extends compress
{
trigger_error("Could not create directory $folder");
}
- phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
+ phpbb_chmod($str, phpbb::CHMOD_READ | phpbb::CHMOD_WRITE);
}
}
}
@@ -540,7 +540,7 @@ class compress_tar extends compress
{
trigger_error("Could not create directory $folder");
}
- phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
+ phpbb_chmod($str, phpbb::CHMOD_READ | phpbb::CHMOD_WRITE);
}
}
}
@@ -567,7 +567,7 @@ class compress_tar extends compress
{
trigger_error("Could not create directory $folder");
}
- phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE);
+ phpbb_chmod($str, phpbb::CHMOD_READ | phpbb::CHMOD_WRITE);
}
}
@@ -576,7 +576,7 @@ class compress_tar extends compress
{
trigger_error("Couldn't create file $filename");
}
- phpbb_chmod($target_filename, CHMOD_READ);
+ phpbb_chmod($target_filename, phpbb::CHMOD_READ | phpbb::CHMOD_WRITE);
// Grab the file contents
fwrite($fp, ($filesize) ? $fzread($this->fp, ($filesize + 511) &~ 511) : '', $filesize);
diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php
index 181a32fab2..66875f0e69 100644
--- a/phpBB/includes/functions_convert.php
+++ b/phpBB/includes/functions_convert.php
@@ -157,7 +157,7 @@ function auto_id($pad = 0)
*/
function set_user_type($user_active)
{
- return ($user_active) ? USER_NORMAL : USER_INACTIVE;
+ return ($user_active) ? phpbb::USER_NORMAL : phpbb::USER_INACTIVE;
}
/**
@@ -1461,7 +1461,7 @@ function compare_table($tables, $tablename, &$prefixes)
* @param mixed $forum_id forum ids (array|int|0) -> 0 == all forums
* @param mixed $ug_id [int] user_id|group_id : [string] usergroup name
* @param mixed $acl_list [string] acl entry : [array] acl entries : [string] role entry
-* @param int $setting ACL_YES|ACL_NO|ACL_NEVER
+* @param int $setting phpbb::ACL_YES|ACL_NO|ACL_NEVER
*/
function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting = ACL_NO)
{
@@ -1850,7 +1850,7 @@ function add_bots()
foreach ($bots as $bot_name => $bot_ary)
{
$user_row = array(
- 'user_type' => USER_IGNORE,
+ 'user_type' => phpbb::USER_IGNORE,
'group_id' => $group_id,
'username' => $bot_name,
'user_regdate' => time(),
@@ -1890,7 +1890,7 @@ function update_dynamic_config()
// Get latest username
$sql = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . '
- WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
+ WHERE user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
if (!empty($config['increment_user_id']))
{
@@ -1934,7 +1934,7 @@ function update_dynamic_config()
$sql = 'SELECT COUNT(user_id) AS stat
FROM ' . USERS_TABLE . '
- WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
+ WHERE user_type IN (' . phpbb::USER_NORMAL . ',' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -2056,11 +2056,11 @@ function fix_empty_primary_groups()
// Set group ids for users not already having it
$sql = 'UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('registered') . '
- WHERE group_id = 0 AND user_type = ' . USER_INACTIVE;
+ WHERE group_id = 0 AND user_type = ' . phpbb::USER_INACTIVE;
$db->sql_query($sql);
$sql = 'UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('registered') . '
- WHERE group_id = 0 AND user_type = ' . USER_NORMAL;
+ WHERE group_id = 0 AND user_type = ' . phpbb::USER_NORMAL;
$db->sql_query($sql);
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET group_id = ' . get_group_id('guests') . ' WHERE user_id = ' . ANONYMOUS);
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 95d293c04d..ed9f25744b 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -706,7 +706,7 @@ class queue
@flock($fp, LOCK_UN);
fclose($fp);
- phpbb_chmod($this->cache_file, CHMOD_WRITE);
+ phpbb_chmod($this->cache_file, phpbb::CHMOD_WRITE);
}
}
@@ -747,7 +747,7 @@ class queue
@flock($fp, LOCK_UN);
fclose($fp);
- phpbb_chmod($this->cache_file, CHMOD_WRITE);
+ phpbb_chmod($this->cache_file, phpbb::CHMOD_WRITE);
}
}
}
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index c7749539ae..40d075a52c 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -731,7 +731,7 @@ function create_thumbnail($source, $destination, $mimetype)
return false;
}
- phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE);
+ phpbb_chmod($destination, phpbb::CHMOD_READ | phpbb::CHMOD_WRITE);
return true;
}
@@ -1142,7 +1142,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . "
AND w.user_id NOT IN ($sql_ignore_users)
AND w.notify_status = 0
- AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
+ AND u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')
AND u.user_id = w.user_id';
$result = $db->sql_query($sql);
@@ -1175,7 +1175,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
WHERE fw.forum_id = $forum_id
AND fw.user_id NOT IN ($sql_ignore_users)
AND fw.notify_status = 0
- AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
+ AND u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')
AND u.user_id = fw.user_id';
$result = $db->sql_query($sql);
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index c67266e9c5..ad77981ead 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1144,7 +1144,7 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
$sql = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $u) . '
- AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
+ AND user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -1348,7 +1348,7 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
WHERE ' . $db->sql_in_set('ug.group_id', array_keys($data['address_list']['g'])) . '
AND ug.user_pending = 0
AND u.user_id = ug.user_id
- AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')' .
+ AND u.user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')' .
$sql_allow_pm;
$result = $db->sql_query($sql);
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index c79c0808af..dc2f399dcd 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -121,9 +121,9 @@ class filespec
case 'avatar':
$this->extension = strtolower($this->extension);
$this->realname = $prefix . $user_id . '.' . $this->extension;
-
+
break;
-
+
case 'unique_ext':
default:
$this->realname = $prefix . md5(unique_id()) . '.' . $this->extension;
@@ -228,8 +228,8 @@ class filespec
{
return @filesize($filename);
}
-
-
+
+
/**
* Check the first 256 bytes for forbidden content
*/
@@ -239,7 +239,7 @@ class filespec
{
return true;
}
-
+
$fp = @fopen($this->filename, 'rb');
if ($fp !== false)
@@ -276,7 +276,7 @@ class filespec
return false;
}
- $chmod = ($chmod === false) ? CHMOD_READ | CHMOD_WRITE : $chmod;
+ $chmod = ($chmod === false) ? phpbb::CHMOD_READ | phpbb::CHMOD_WRITE : $chmod;
// We need to trust the admin in specifying valid upload directories and an attacker not being able to overwrite it...
$this->destination_path = PHPBB_ROOT_PATH . $destination;
@@ -419,7 +419,7 @@ class filespec
{
$size_lang = ($this->upload->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->upload->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES'] );
$max_filesize = get_formatted_filesize($this->upload->max_filesize, false);
-
+
$this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang);
return false;
@@ -531,7 +531,7 @@ class fileupload
$this->max_filesize = (int) $max_filesize;
}
}
-
+
/**
* Set disallowed strings
*/
@@ -875,7 +875,7 @@ class fileupload
{
$file->error[] = sprintf($user->lang[$this->error_prefix . 'DISALLOWED_EXTENSION'], $file->get('extension'));
}
-
+
// MIME Sniffing
if (!$this->valid_content($file))
{
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 8a72e775c5..c9eafc3d90 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -91,7 +91,7 @@ function update_last_username()
// Get latest username
$sql = 'SELECT user_id, username, user_colour
FROM ' . USERS_TABLE . '
- WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
+ WHERE user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')
ORDER BY user_id DESC';
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
@@ -276,7 +276,7 @@ function user_add($user_row, $cp_data = false)
group_set_user_default($user_row['group_id'], array($user_id), false);
// set the newest user and adjust the user count if the user is a normal user and no activation mail is sent
- if ($user_row['user_type'] == USER_NORMAL)
+ if ($user_row['user_type'] == phpbb::USER_NORMAL)
{
set_config('newest_user_id', $user_id, true);
set_config('newest_username', $user_row['username'], true);
@@ -390,7 +390,7 @@ function user_delete($mode, $user_id, $post_username = false)
}
// If the user is inactive and newly registered we assume no posts from this user being there...
- if ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_REGISTER && !$user_row['user_posts'])
+ if ($user_row['user_type'] == phpbb::USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_REGISTER && !$user_row['user_posts'])
{
}
else
@@ -566,7 +566,7 @@ function user_delete($mode, $user_id, $post_username = false)
}
// Decrement number of users if this user is active
- if ($user_row['user_type'] != USER_INACTIVE && $user_row['user_type'] != USER_IGNORE)
+ if ($user_row['user_type'] != phpbb::USER_INACTIVE && $user_row['user_type'] != phpbb::USER_IGNORE)
{
set_config('num_users', $config['num_users'] - 1, true);
}
@@ -605,14 +605,14 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
{
$sql_ary = array();
- if ($row['user_type'] == USER_IGNORE || $row['user_type'] == USER_FOUNDER ||
- ($mode == 'activate' && $row['user_type'] != USER_INACTIVE) ||
- ($mode == 'deactivate' && $row['user_type'] == USER_INACTIVE))
+ if ($row['user_type'] == phpbb::USER_IGNORE || $row['user_type'] == phpbb::USER_FOUNDER ||
+ ($mode == 'activate' && $row['user_type'] != phpbb::USER_INACTIVE) ||
+ ($mode == 'deactivate' && $row['user_type'] == phpbb::USER_INACTIVE))
{
continue;
}
- if ($row['user_type'] == USER_INACTIVE)
+ if ($row['user_type'] == phpbb::USER_INACTIVE)
{
$activated++;
}
@@ -625,9 +625,9 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
}
$sql_ary += array(
- 'user_type' => ($row['user_type'] == USER_NORMAL) ? USER_INACTIVE : USER_NORMAL,
- 'user_inactive_time' => ($row['user_type'] == USER_NORMAL) ? time() : 0,
- 'user_inactive_reason' => ($row['user_type'] == USER_NORMAL) ? $reason : 0,
+ 'user_type' => ($row['user_type'] == phpbb::USER_NORMAL) ? phpbb::USER_INACTIVE : phpbb::USER_NORMAL,
+ 'user_inactive_time' => ($row['user_type'] == phpbb::USER_NORMAL) ? time() : 0,
+ 'user_inactive_reason' => ($row['user_type'] == phpbb::USER_NORMAL) ? $reason : 0,
);
$sql_statements[$row['user_id']] = $sql_ary;
@@ -720,7 +720,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
// Create a list of founder...
$sql = 'SELECT user_id, user_email, username_clean
FROM ' . USERS_TABLE . '
- WHERE user_type = ' . USER_FOUNDER;
+ WHERE user_type = ' . phpbb::USER_FOUNDER;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -3244,7 +3244,7 @@ function group_update_listings($group_id)
break 3;
}
- if ($setting != ACL_YES)
+ if ($setting != phpbb::ACL_YES)
{
continue;
}
diff --git a/phpBB/index.php b/phpBB/index.php
index dc13d367d0..1d0758df4c 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -87,7 +87,7 @@ if ($config['load_birthdays'] && $config['allow_birthdays'])
$sql = 'SELECT user_id, username, user_colour, user_birthday
FROM ' . USERS_TABLE . "
WHERE user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
- AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
+ AND user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index a68cdab988..f918a01786 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -232,12 +232,6 @@ include(PHPBB_ROOT_PATH . 'language/' . $language . '/posting.' . PHP_EXT);
// usually we would need every single constant here - and it would be consistent. For 3.0.x, use a dirty hack... :(
-// Define needed constants
-define('CHMOD_ALL', 7);
-define('CHMOD_READ', 4);
-define('CHMOD_WRITE', 2);
-define('CHMOD_EXECUTE', 1);
-
$mode = request_var('mode', 'overview');
$sub = request_var('sub', '');
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index f0d5d70d3e..7e93f008f6 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -458,13 +458,13 @@ class install_install extends module
if (!file_exists(PHPBB_ROOT_PATH . $dir))
{
@mkdir(PHPBB_ROOT_PATH . $dir, 0777);
- phpbb_chmod(PHPBB_ROOT_PATH . $dir, CHMOD_READ | CHMOD_WRITE);
+ phpbb_chmod(PHPBB_ROOT_PATH . $dir, phpbb::CHMOD_READ | phpbb::CHMOD_WRITE);
}
// Now really check
if (file_exists(PHPBB_ROOT_PATH . $dir) && is_dir(PHPBB_ROOT_PATH . $dir))
{
- phpbb_chmod(PHPBB_ROOT_PATH . $dir, CHMOD_READ | CHMOD_WRITE);
+ phpbb_chmod(PHPBB_ROOT_PATH . $dir, phpbb::CHMOD_READ | phpbb::CHMOD_WRITE);
$exists = true;
}
@@ -950,7 +950,7 @@ class install_install extends module
if ($written)
{
// We may revert back to chmod() if we see problems with users not able to change their config.php file directly
- phpbb_chmod(PHPBB_ROOT_PATH . 'config.' . PHP_EXT, CHMOD_READ);
+ phpbb_chmod(PHPBB_ROOT_PATH . 'config.' . PHP_EXT, phpbb::CHMOD_READ | phpbb::CHMOD_WRITE);
}
}
@@ -1871,7 +1871,7 @@ class install_install extends module
foreach ($this->bot_list as $bot_name => $bot_ary)
{
$user_row = array(
- 'user_type' => USER_IGNORE,
+ 'user_type' => phpbb::USER_IGNORE,
'group_id' => $group_id,
'username' => $bot_name,
'user_regdate' => time(),
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index 396ac2c132..46c4734b6f 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -309,7 +309,7 @@ switch ($mode)
$sql = "SELECT user_id, username, user_email, user_lang, $sql_field
FROM " . USERS_TABLE . "
WHERE user_id = $user_id
- AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
+ AND user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -416,13 +416,13 @@ switch ($mode)
// a_user admins and founder are able to view inactive users and bots to be able to manage them more easily
// Normal users are able to see at least users having only changed their profile settings but not yet reactivated.
- if (!$auth->acl_get('a_user') && $user->data['user_type'] != USER_FOUNDER)
+ if (!$auth->acl_get('a_user') && $user->data['user_type'] != phpbb::USER_FOUNDER)
{
- if ($member['user_type'] == USER_IGNORE)
+ if ($member['user_type'] == phpbb::USER_IGNORE)
{
trigger_error('NO_USER');
}
- else if ($member['user_type'] == USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE)
+ else if ($member['user_type'] == phpbb::USER_INACTIVE && $member['user_inactive_reason'] != INACTIVE_PROFILE)
{
trigger_error('NO_USER');
}
@@ -595,7 +595,7 @@ switch ($mode)
}
// Inactive reason/account?
- if ($member['user_type'] == USER_INACTIVE)
+ if ($member['user_type'] == phpbb::USER_INACTIVE)
{
$user->add_lang('acp/common');
@@ -672,7 +672,7 @@ switch ($mode)
$sql = 'SELECT username, user_email, user_allow_viewemail, user_lang, user_jabber, user_notify_type
FROM ' . USERS_TABLE . "
WHERE user_id = $user_id
- AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
+ AND user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
@@ -1189,7 +1189,7 @@ switch ($mode)
{
$sql = 'SELECT COUNT(u.user_id) AS total_users
FROM ' . USERS_TABLE . " u$sql_from
- WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
+ WHERE u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ")
$sql_where";
$result = $db->sql_query($sql);
$total_users = (int) $db->sql_fetchfield('total_users');
@@ -1352,7 +1352,7 @@ switch ($mode)
$sql = "SELECT u.user_id
FROM " . USERS_TABLE . " u
$sql_from
- WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")
+ WHERE u.user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ")
$sql_where
ORDER BY $order_by";
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
diff --git a/phpBB/modules/acp/acp_attachments.php b/phpBB/modules/acp/acp_attachments.php
index 3a456b18ca..6b827a91fb 100644
--- a/phpBB/modules/acp/acp_attachments.php
+++ b/phpBB/modules/acp/acp_attachments.php
@@ -1201,7 +1201,7 @@ class acp_attachments
if (!file_exists(PHPBB_ROOT_PATH . $upload_dir))
{
@mkdir(PHPBB_ROOT_PATH . $upload_dir, 0777);
- phpbb_chmod(PHPBB_ROOT_PATH . $upload_dir, CHMOD_READ | CHMOD_WRITE);
+ phpbb_chmod(PHPBB_ROOT_PATH . $upload_dir, phpbb::CHMOD_READ | phpbb::CHMOD_WRITE);
}
}
diff --git a/phpBB/modules/acp/acp_bots.php b/phpBB/modules/acp/acp_bots.php
index f067bcc32b..b1a0f3f7cd 100644
--- a/phpBB/modules/acp/acp_bots.php
+++ b/phpBB/modules/acp/acp_bots.php
@@ -222,7 +222,7 @@ class acp_bots
$user_id = user_add(array(
- 'user_type' => (int) USER_IGNORE,
+ 'user_type' => (int) phpbb::USER_IGNORE,
'group_id' => (int) $group_row['group_id'],
'username' => (string) $bot_row['bot_name'],
'user_regdate' => time(),
diff --git a/phpBB/modules/acp/acp_email.php b/phpBB/modules/acp/acp_email.php
index 25ce68c75a..c516c77f6c 100644
--- a/phpBB/modules/acp/acp_email.php
+++ b/phpBB/modules/acp/acp_email.php
@@ -87,7 +87,7 @@ class acp_email
AND ug.user_pending = 0
AND u.user_id = ug.user_id
AND u.user_allow_massemail = 1
- AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
+ AND u.user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')
ORDER BY u.user_lang, u.user_notify_type';
}
else
@@ -95,7 +95,7 @@ class acp_email
$sql = 'SELECT username, username_clean, user_email, user_jabber, user_notify_type, user_lang
FROM ' . USERS_TABLE . '
WHERE user_allow_massemail = 1
- AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')
+ AND user_type IN (' . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')
ORDER BY user_lang, user_notify_type';
}
}
diff --git a/phpBB/modules/acp/acp_groups.php b/phpBB/modules/acp/acp_groups.php
index 5af7578665..f01ca2290c 100644
--- a/phpBB/modules/acp/acp_groups.php
+++ b/phpBB/modules/acp/acp_groups.php
@@ -67,7 +67,7 @@ class acp_groups
}
// Check if the user is allowed to manage this group if set to founder only.
- if ($user->data['user_type'] != USER_FOUNDER && $group_row['group_founder_manage'])
+ if ($user->data['user_type'] != phpbb::USER_FOUNDER && $group_row['group_founder_manage'])
{
trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -310,7 +310,7 @@ class acp_groups
'founder_manage' => 0,
);
- if ($user->data['user_type'] == USER_FOUNDER)
+ if ($user->data['user_type'] == phpbb::USER_FOUNDER)
{
$submit_ary['founder_manage'] = phpbb_request::is_set('group_founder_manage') ? 1 : 0;
}
@@ -426,7 +426,7 @@ class acp_groups
$db->sql_freeresult($result);
// Check the group if non-founder
- if ($check_row && ($user->data['user_type'] == USER_FOUNDER || $check_row['group_founder_manage'] == 0))
+ if ($check_row && ($user->data['user_type'] == phpbb::USER_FOUNDER || $check_row['group_founder_manage'] == 0))
{
// From the mysql documentation:
// Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
@@ -549,7 +549,7 @@ class acp_groups
'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false,
'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false,
'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false,
- 'S_USER_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
+ 'S_USER_FOUNDER' => ($user->data['user_type'] == phpbb::USER_FOUNDER) ? true : false,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name,
@@ -568,7 +568,7 @@ class acp_groups
'S_DESC_SMILIES_CHECKED'=> $group_desc_data['allow_smilies'],
'S_RANK_OPTIONS' => $rank_options,
- 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)),
+ 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == phpbb::USER_FOUNDER) ? false : 0)),
'AVATAR' => $avatar_img,
'AVATAR_IMAGE' => $avatar_img,
'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'],
diff --git a/phpBB/modules/acp/acp_inactive.php b/phpBB/modules/acp/acp_inactive.php
index 369dc38d78..d1feaf4901 100644
--- a/phpBB/modules/acp/acp_inactive.php
+++ b/phpBB/modules/acp/acp_inactive.php
@@ -82,7 +82,7 @@ class acp_inactive
$sql = 'SELECT user_id, username, user_email, user_lang
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $mark) . '
- AND user_type = ' . USER_INACTIVE;
+ AND user_type = ' . phpbb::USER_INACTIVE;
$result = $db->sql_query($sql);
$inactive_users = array();
diff --git a/phpBB/modules/acp/acp_main.php b/phpBB/modules/acp/acp_main.php
index c79625ee39..5e7e998f34 100644
--- a/phpBB/modules/acp/acp_main.php
+++ b/phpBB/modules/acp/acp_main.php
@@ -149,7 +149,7 @@ class acp_main
$sql = 'SELECT COUNT(user_id) AS stat
FROM ' . USERS_TABLE . '
- WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
+ WHERE user_type IN (' . phpbb::USER_NORMAL . ',' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query($sql);
set_config('num_users', (int) $db->sql_fetchfield('stat'), true);
$db->sql_freeresult($result);
@@ -323,7 +323,7 @@ class acp_main
break;
case 'purge_cache':
- if ((int) $user->data['user_type'] !== USER_FOUNDER)
+ if ((int) $user->data['user_type'] !== phpbb::USER_FOUNDER)
{
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -440,7 +440,7 @@ class acp_main
'U_INACTIVE_USERS' => append_sid(PHPBB_ADMIN_PATH . 'index.' . PHP_EXT, 'i=inactive&amp;mode=list'),
'S_ACTION_OPTIONS' => ($auth->acl_get('a_board')) ? true : false,
- 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
+ 'S_FOUNDER' => ($user->data['user_type'] == phpbb::USER_FOUNDER) ? true : false,
)
);
diff --git a/phpBB/modules/acp/acp_permission_roles.php b/phpBB/modules/acp/acp_permission_roles.php
index 90ed532874..00bdcedcc6 100644
--- a/phpBB/modules/acp/acp_permission_roles.php
+++ b/phpBB/modules/acp/acp_permission_roles.php
@@ -262,7 +262,7 @@ class acp_permission_roles
$auth_options = array();
while ($row = $db->sql_fetchrow($result))
{
- $auth_options[$row['auth_option']] = ACL_NO;
+ $auth_options[$row['auth_option']] = phpbb::ACL_NO;
}
$db->sql_freeresult($result);
}
@@ -329,7 +329,7 @@ class acp_permission_roles
{
if (!isset($auth_options[$row['auth_option']]))
{
- $auth_options[$row['auth_option']] = ACL_NO;
+ $auth_options[$row['auth_option']] = phpbb::ACL_NO;
}
}
$db->sql_freeresult($result);
@@ -482,9 +482,9 @@ class acp_permission_roles
foreach ($cat_array['permissions'] as $permission => $allowed)
{
$template->assign_block_vars('auth.mask', array(
- 'S_YES' => ($allowed == ACL_YES) ? true : false,
- 'S_NEVER' => ($allowed == ACL_NEVER) ? true : false,
- 'S_NO' => ($allowed == ACL_NO) ? true : false,
+ 'S_YES' => ($allowed == phpbb::ACL_YES) ? true : false,
+ 'S_NEVER' => ($allowed == phpbb::ACL_NEVER) ? true : false,
+ 'S_NO' => ($allowed == phpbb::ACL_NO) ? true : false,
'FIELD_NAME' => $permission,
'PERMISSION' => $user->lang['acl_' . $permission]['lang'])
@@ -511,7 +511,7 @@ class acp_permission_roles
$auth_settings = array();
while ($row = $db->sql_fetchrow($result))
{
- $auth_settings[$row['auth_option']] = ACL_NO;
+ $auth_settings[$row['auth_option']] = phpbb::ACL_NO;
}
$db->sql_freeresult($result);
diff --git a/phpBB/modules/acp/acp_permissions.php b/phpBB/modules/acp/acp_permissions.php
index 51785a386c..9b3d966ebd 100644
--- a/phpBB/modules/acp/acp_permissions.php
+++ b/phpBB/modules/acp/acp_permissions.php
@@ -368,7 +368,7 @@ class acp_permissions
$template->assign_vars(array(
'S_SELECT_GROUP' => true,
- 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)))
+ 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == phpbb::USER_FOUNDER) ? false : 0)))
);
break;
@@ -414,7 +414,7 @@ class acp_permissions
'S_SELECT_USERGROUP_VIEW' => ($victim == 'usergroup_view') ? true : false,
'S_DEFINED_USER_OPTIONS' => $items['user_ids_options'],
'S_DEFINED_GROUP_OPTIONS' => $items['group_ids_options'],
- 'S_ADD_GROUP_OPTIONS' => group_select_options(false, $items['group_ids'], (($user->data['user_type'] == USER_FOUNDER) ? false : 0)),
+ 'S_ADD_GROUP_OPTIONS' => group_select_options(false, $items['group_ids'], (($user->data['user_type'] == phpbb::USER_FOUNDER) ? false : 0)),
'U_FIND_USERNAME' => append_sid('memberlist', 'mode=searchuser&amp;form=add_user&amp;field=username&amp;select_single=true'),
));
@@ -481,7 +481,7 @@ class acp_permissions
'S_SETTING_PERMISSIONS' => true)
);
- $hold_ary = $auth_admin->get_mask('set', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NO);
+ $hold_ary = $auth_admin->get_mask('set', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, phpbb::ACL_NO);
$auth_admin->display_mask('set', $permission_type, $hold_ary, ((sizeof($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false));
}
else
@@ -490,7 +490,7 @@ class acp_permissions
'S_VIEWING_PERMISSIONS' => true)
);
- $hold_ary = $auth_admin->get_mask('view', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NEVER);
+ $hold_ary = $auth_admin->get_mask('view', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, phpbb::ACL_NEVER);
$auth_admin->display_mask('view', $permission_type, $hold_ary, ((sizeof($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false));
}
}
@@ -782,7 +782,7 @@ class acp_permissions
// We need to add any ACL_NO setting from auth_settings to compare correctly
foreach ($auth_settings as $option => $setting)
{
- if ($setting == ACL_NO)
+ if ($setting == phpbb::ACL_NO)
{
$test_auth_settings[$option] = $setting;
}
@@ -949,13 +949,13 @@ class acp_permissions
while ($row = $db->sql_fetchrow($result))
{
$groups[$row['group_id']] = array(
- 'auth_setting' => ACL_NO,
+ 'auth_setting' => phpbb::ACL_NO,
'group_name' => ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']
);
}
$db->sql_freeresult($result);
- $total = ACL_NO;
+ $total = phpbb::ACL_NO;
$add_key = (($forum_id) ? '_LOCAL' : '');
if (sizeof($groups))
@@ -973,18 +973,18 @@ class acp_permissions
{
switch ($row['auth_setting'])
{
- case ACL_NO:
+ case phpbb::ACL_NO:
$information = $user->lang['TRACE_GROUP_NO' . $add_key];
break;
- case ACL_YES:
- $information = ($total == ACL_YES) ? $user->lang['TRACE_GROUP_YES_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_GROUP_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_YES_TOTAL_NO' . $add_key]);
- $total = ($total == ACL_NO) ? ACL_YES : $total;
+ case phpbb::ACL_YES:
+ $information = ($total == phpbb::ACL_YES) ? $user->lang['TRACE_GROUP_YES_TOTAL_YES' . $add_key] : (($total == phpbb::ACL_NEVER) ? $user->lang['TRACE_GROUP_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_YES_TOTAL_NO' . $add_key]);
+ $total = ($total == phpbb::ACL_NO) ? phpbb::ACL_YES : $total;
break;
- case ACL_NEVER:
- $information = ($total == ACL_YES) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_NEVER_TOTAL_NO' . $add_key]);
- $total = ACL_NEVER;
+ case phpbb::ACL_NEVER:
+ $information = ($total == phpbb::ACL_YES) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_YES' . $add_key] : (($total == phpbb::ACL_NEVER) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_NEVER_TOTAL_NO' . $add_key]);
+ $total = phpbb::ACL_NEVER;
break;
}
@@ -992,35 +992,35 @@ class acp_permissions
'WHO' => $row['group_name'],
'INFORMATION' => $information,
- 'S_SETTING_NO' => ($row['auth_setting'] == ACL_NO) ? true : false,
- 'S_SETTING_YES' => ($row['auth_setting'] == ACL_YES) ? true : false,
- 'S_SETTING_NEVER' => ($row['auth_setting'] == ACL_NEVER) ? true : false,
- 'S_TOTAL_NO' => ($total == ACL_NO) ? true : false,
- 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false,
- 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false)
+ 'S_SETTING_NO' => ($row['auth_setting'] == phpbb::ACL_NO) ? true : false,
+ 'S_SETTING_YES' => ($row['auth_setting'] == phpbb::ACL_YES) ? true : false,
+ 'S_SETTING_NEVER' => ($row['auth_setting'] == phpbb::ACL_NEVER) ? true : false,
+ 'S_TOTAL_NO' => ($total == phpbb::ACL_NO) ? true : false,
+ 'S_TOTAL_YES' => ($total == phpbb::ACL_YES) ? true : false,
+ 'S_TOTAL_NEVER' => ($total == phpbb::ACL_NEVER) ? true : false)
);
}
}
// Get user specific permission... globally or for this forum
$hold_ary = $auth->acl_user_raw_data($user_id, $permission, $forum_id);
- $auth_setting = (!sizeof($hold_ary)) ? ACL_NO : $hold_ary[$user_id][$forum_id][$permission];
+ $auth_setting = (!sizeof($hold_ary)) ? phpbb::ACL_NO : $hold_ary[$user_id][$forum_id][$permission];
switch ($auth_setting)
{
- case ACL_NO:
- $information = ($total == ACL_NO) ? $user->lang['TRACE_USER_NO_TOTAL_NO' . $add_key] : $user->lang['TRACE_USER_KEPT' . $add_key];
- $total = ($total == ACL_NO) ? ACL_NEVER : $total;
+ case phpbb::ACL_NO:
+ $information = ($total == phpbb::ACL_NO) ? $user->lang['TRACE_USER_NO_TOTAL_NO' . $add_key] : $user->lang['TRACE_USER_KEPT' . $add_key];
+ $total = ($total == phpbb::ACL_NO) ? phpbb::ACL_NEVER : $total;
break;
- case ACL_YES:
- $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_YES_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_USER_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_YES_TOTAL_NO' . $add_key]);
- $total = ($total == ACL_NO) ? ACL_YES : $total;
+ case phpbb::ACL_YES:
+ $information = ($total == phpbb::ACL_YES) ? $user->lang['TRACE_USER_YES_TOTAL_YES' . $add_key] : (($total == phpbb::ACL_NEVER) ? $user->lang['TRACE_USER_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_YES_TOTAL_NO' . $add_key]);
+ $total = ($total == phpbb::ACL_NO) ? phpbb::ACL_YES : $total;
break;
- case ACL_NEVER:
- $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_NEVER_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_USER_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_NEVER_TOTAL_NO' . $add_key]);
- $total = ACL_NEVER;
+ case phpbb::ACL_NEVER:
+ $information = ($total == phpbb::ACL_YES) ? $user->lang['TRACE_USER_NEVER_TOTAL_YES' . $add_key] : (($total == phpbb::ACL_NEVER) ? $user->lang['TRACE_USER_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_NEVER_TOTAL_NO' . $add_key]);
+ $total = phpbb::ACL_NEVER;
break;
}
@@ -1028,12 +1028,12 @@ class acp_permissions
'WHO' => $userdata['username'],
'INFORMATION' => $information,
- 'S_SETTING_NO' => ($auth_setting == ACL_NO) ? true : false,
- 'S_SETTING_YES' => ($auth_setting == ACL_YES) ? true : false,
- 'S_SETTING_NEVER' => ($auth_setting == ACL_NEVER) ? true : false,
+ 'S_SETTING_NO' => ($auth_setting == phpbb::ACL_NO) ? true : false,
+ 'S_SETTING_YES' => ($auth_setting == phpbb::ACL_YES) ? true : false,
+ 'S_SETTING_NEVER' => ($auth_setting == phpbb::ACL_NEVER) ? true : false,
'S_TOTAL_NO' => false,
- 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false,
- 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false)
+ 'S_TOTAL_YES' => ($total == phpbb::ACL_YES) ? true : false,
+ 'S_TOTAL_NEVER' => ($total == phpbb::ACL_NEVER) ? true : false)
);
if ($forum_id != 0 && isset($auth->acl_options['global'][$permission]))
@@ -1051,8 +1051,8 @@ class acp_permissions
if ($auth_setting)
{
- $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_YES'] : $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_NEVER'];
- $total = ACL_YES;
+ $information = ($total == phpbb::ACL_YES) ? $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_YES'] : $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_NEVER'];
+ $total = phpbb::ACL_YES;
}
else
{
@@ -1070,35 +1070,35 @@ class acp_permissions
'S_SETTING_YES' => $auth_setting,
'S_SETTING_NEVER' => !$auth_setting,
'S_TOTAL_NO' => false,
- 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false,
- 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false)
+ 'S_TOTAL_YES' => ($total == phpbb::ACL_YES) ? true : false,
+ 'S_TOTAL_NEVER' => ($total == phpbb::ACL_NEVER) ? true : false)
);
}
}
// Take founder status into account, overwriting the default values
- if ($userdata['user_type'] == USER_FOUNDER && strpos($permission, 'a_') === 0)
+ if ($userdata['user_type'] == phpbb::USER_FOUNDER && strpos($permission, 'a_') === 0)
{
$template->assign_block_vars('trace', array(
'WHO' => $userdata['username'],
'INFORMATION' => $user->lang['TRACE_USER_FOUNDER'],
- 'S_SETTING_NO' => ($auth_setting == ACL_NO) ? true : false,
- 'S_SETTING_YES' => ($auth_setting == ACL_YES) ? true : false,
- 'S_SETTING_NEVER' => ($auth_setting == ACL_NEVER) ? true : false,
+ 'S_SETTING_NO' => ($auth_setting == phpbb::ACL_NO) ? true : false,
+ 'S_SETTING_YES' => ($auth_setting == phpbb::ACL_YES) ? true : false,
+ 'S_SETTING_NEVER' => ($auth_setting == phpbb::ACL_NEVER) ? true : false,
'S_TOTAL_NO' => false,
'S_TOTAL_YES' => true,
'S_TOTAL_NEVER' => false)
);
- $total = ACL_YES;
+ $total = phpbb::ACL_YES;
}
// Total value...
$template->assign_vars(array(
- 'S_RESULT_NO' => ($total == ACL_NO) ? true : false,
- 'S_RESULT_YES' => ($total == ACL_YES) ? true : false,
- 'S_RESULT_NEVER' => ($total == ACL_NEVER) ? true : false,
+ 'S_RESULT_NO' => ($total == phpbb::ACL_NO) ? true : false,
+ 'S_RESULT_YES' => ($total == phpbb::ACL_YES) ? true : false,
+ 'S_RESULT_NEVER' => ($total == phpbb::ACL_NEVER) ? true : false,
));
}
diff --git a/phpBB/modules/acp/acp_prune.php b/phpBB/modules/acp/acp_prune.php
index 42c3c139f4..91d9a371c0 100644
--- a/phpBB/modules/acp/acp_prune.php
+++ b/phpBB/modules/acp/acp_prune.php
@@ -436,7 +436,7 @@ class acp_prune
$sql = 'SELECT user_id, username
FROM ' . USERS_TABLE . '
WHERE user_id <> ' . ANONYMOUS . '
- AND user_type <> ' . USER_FOUNDER . "
+ AND user_type <> ' . phpbb::USER_FOUNDER . "
$where_sql";
$result = $db->sql_query($sql);
diff --git a/phpBB/modules/acp/acp_users.php b/phpBB/modules/acp/acp_users.php
index 721c31f3cf..ab48f3b186 100644
--- a/phpBB/modules/acp/acp_users.php
+++ b/phpBB/modules/acp/acp_users.php
@@ -152,7 +152,7 @@ class acp_users
);
// Prevent normal users/admins change/view founders if they are not a founder by themselves
- if ($user->data['user_type'] != USER_FOUNDER && $user_row['user_type'] == USER_FOUNDER)
+ if ($user->data['user_type'] != phpbb::USER_FOUNDER && $user_row['user_type'] == phpbb::USER_FOUNDER)
{
trigger_error($user->lang['NOT_MANAGE_FOUNDER'] . adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -172,7 +172,7 @@ class acp_users
if ($submit)
{
// You can't delete the founder
- if ($delete && $user_row['user_type'] != USER_FOUNDER)
+ if ($delete && $user_row['user_type'] != phpbb::USER_FOUNDER)
{
if (!$auth->acl_get('a_userdel'))
{
@@ -223,7 +223,7 @@ class acp_users
trigger_error($user->lang['CANNOT_BAN_YOURSELF'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
- if ($user_row['user_type'] == USER_FOUNDER)
+ if ($user_row['user_type'] == phpbb::USER_FOUNDER)
{
trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
@@ -290,12 +290,12 @@ class acp_users
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
- if ($user_row['user_type'] == USER_FOUNDER)
+ if ($user_row['user_type'] == phpbb::USER_FOUNDER)
{
trigger_error($user->lang['CANNOT_FORCE_REACT_FOUNDER'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
- if ($user_row['user_type'] == USER_IGNORE)
+ if ($user_row['user_type'] == phpbb::USER_IGNORE)
{
trigger_error($user->lang['CANNOT_FORCE_REACT_BOT'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
@@ -310,9 +310,9 @@ class acp_users
$key_len = 54 - (strlen($server_url));
$key_len = ($key_len > 6) ? $key_len : 6;
$user_actkey = substr($user_actkey, 0, $key_len);
- $email_template = ($user_row['user_type'] == USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive';
+ $email_template = ($user_row['user_type'] == phpbb::USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive';
- if ($user_row['user_type'] == USER_NORMAL)
+ if ($user_row['user_type'] == phpbb::USER_NORMAL)
{
user_active_flip('deactivate', $user_id, INACTIVE_REMIND);
@@ -372,20 +372,20 @@ class acp_users
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
- if ($user_row['user_type'] == USER_FOUNDER)
+ if ($user_row['user_type'] == phpbb::USER_FOUNDER)
{
trigger_error($user->lang['CANNOT_DEACTIVATE_FOUNDER'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
- if ($user_row['user_type'] == USER_IGNORE)
+ if ($user_row['user_type'] == phpbb::USER_IGNORE)
{
trigger_error($user->lang['CANNOT_DEACTIVATE_BOT'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
user_active_flip('flip', $user_id);
- $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED';
- $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE';
+ $message = ($user_row['user_type'] == phpbb::USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED';
+ $log = ($user_row['user_type'] == phpbb::USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE';
add_log('admin', $log, $user_row['username']);
add_log('user', $user_id, $log . '_USER');
@@ -654,7 +654,7 @@ class acp_users
// Handle registration info updates
$data = array(
'username' => utf8_normalize_nfc(request_var('user', $user_row['username'], true)),
- 'user_founder' => request_var('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0),
+ 'user_founder' => request_var('user_founder', ($user_row['user_type'] == phpbb::USER_FOUNDER) ? 1 : 0),
'email' => strtolower(request_var('user_email', $user_row['user_email'])),
'email_confirm' => strtolower(request_var('email_confirm', '')),
'new_password' => request_var('new_password', '', true),
@@ -718,33 +718,33 @@ class acp_users
{
$sql_ary = array();
- if ($user_row['user_type'] != USER_FOUNDER || $user->data['user_type'] == USER_FOUNDER)
+ if ($user_row['user_type'] != phpbb::USER_FOUNDER || $user->data['user_type'] == phpbb::USER_FOUNDER)
{
// Only allow founders updating the founder status...
- if ($user->data['user_type'] == USER_FOUNDER)
+ if ($user->data['user_type'] == phpbb::USER_FOUNDER)
{
// Setting a normal member to be a founder
- if ($data['user_founder'] && $user_row['user_type'] != USER_FOUNDER)
+ if ($data['user_founder'] && $user_row['user_type'] != phpbb::USER_FOUNDER)
{
// Make sure the user is not setting an Inactive or ignored user to be a founder
- if ($user_row['user_type'] == USER_IGNORE)
+ if ($user_row['user_type'] == phpbb::USER_IGNORE)
{
trigger_error($user->lang['CANNOT_SET_FOUNDER_IGNORED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
- if ($user_row['user_type'] == USER_INACTIVE)
+ if ($user_row['user_type'] == phpbb::USER_INACTIVE)
{
trigger_error($user->lang['CANNOT_SET_FOUNDER_INACTIVE'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
- $sql_ary['user_type'] = USER_FOUNDER;
+ $sql_ary['user_type'] = phpbb::USER_FOUNDER;
}
- else if (!$data['user_founder'] && $user_row['user_type'] == USER_FOUNDER)
+ else if (!$data['user_founder'] && $user_row['user_type'] == phpbb::USER_FOUNDER)
{
// Check if at least one founder is present
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
- WHERE user_type = ' . USER_FOUNDER . '
+ WHERE user_type = ' . phpbb::USER_FOUNDER . '
AND user_id <> ' . $user_id;
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
@@ -752,7 +752,7 @@ class acp_users
if ($row)
{
- $sql_ary['user_type'] = USER_NORMAL;
+ $sql_ary['user_type'] = phpbb::USER_NORMAL;
}
else
{
@@ -825,19 +825,19 @@ class acp_users
{
$quick_tool_ary = array();
- if ($user_row['user_type'] != USER_FOUNDER)
+ if ($user_row['user_type'] != phpbb::USER_FOUNDER)
{
$quick_tool_ary += array('banuser' => 'BAN_USER', 'banemail' => 'BAN_EMAIL', 'banip' => 'BAN_IP');
}
- if ($user_row['user_type'] != USER_FOUNDER && $user_row['user_type'] != USER_IGNORE)
+ if ($user_row['user_type'] != phpbb::USER_FOUNDER && $user_row['user_type'] != phpbb::USER_IGNORE)
{
- $quick_tool_ary += array('active' => (($user_row['user_type'] == USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE'));
+ $quick_tool_ary += array('active' => (($user_row['user_type'] == phpbb::USER_INACTIVE) ? 'ACTIVATE' : 'DEACTIVATE'));
}
$quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH');
- if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE))
+ if ($config['email_enable'] && ($user_row['user_type'] == phpbb::USER_NORMAL || $user_row['user_type'] == phpbb::USER_INACTIVE))
{
$quick_tool_ary['reactivate'] = 'FORCE';
}
@@ -866,7 +866,7 @@ class acp_users
$last_visit = (!empty($user_row['session_time'])) ? $user_row['session_time'] : $user_row['user_lastvisit'];
$inactive_reason = '';
- if ($user_row['user_type'] == USER_INACTIVE)
+ if ($user_row['user_type'] == phpbb::USER_INACTIVE)
{
$inactive_reason = $user->lang['INACTIVE_REASON_UNKNOWN'];
@@ -903,14 +903,14 @@ class acp_users
'L_NAME_CHARS_EXPLAIN' => sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']),
'L_CHANGE_PASSWORD_EXPLAIN' => sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),
'L_POSTS_IN_QUEUE' => $user->lang('NUM_POSTS_IN_QUEUE', $user_row['posts_in_queue']),
- 'S_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
+ 'S_FOUNDER' => ($user->data['user_type'] == phpbb::USER_FOUNDER) ? true : false,
'S_OVERVIEW' => true,
'S_USER_IP' => ($user_row['user_ip']) ? true : false,
- 'S_USER_FOUNDER' => ($user_row['user_type'] == USER_FOUNDER) ? true : false,
+ 'S_USER_FOUNDER' => ($user_row['user_type'] == phpbb::USER_FOUNDER) ? true : false,
'S_ACTION_OPTIONS' => $s_action_options,
'S_OWN_ACCOUNT' => ($user_id == $user->data['user_id']) ? true : false,
- 'S_USER_INACTIVE' => ($user_row['user_type'] == USER_INACTIVE) ? true : false,
+ 'S_USER_INACTIVE' => ($user_row['user_type'] == phpbb::USER_INACTIVE) ? true : false,
'U_SHOW_IP' => $this->u_action . "&amp;u=$user_id&amp;ip=" . (($ip == 'ip') ? 'hostname' : 'ip'),
'U_WHOIS' => $this->u_action . "&amp;action=whois&amp;user_ip={$user_row['user_ip']}",
@@ -1801,7 +1801,7 @@ class acp_users
$founder_manage = (int) $db->sql_fetchfield('group_founder_manage');
$db->sql_freeresult($result);
- if ($user->data['user_type'] != USER_FOUNDER && $founder_manage)
+ if ($user->data['user_type'] != phpbb::USER_FOUNDER && $founder_manage)
{
trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
}
@@ -1921,7 +1921,7 @@ class acp_users
}
// Do not display those groups not allowed to be managed
- if ($user->data['user_type'] != USER_FOUNDER && $row['group_founder_manage'])
+ if ($user->data['user_type'] != phpbb::USER_FOUNDER && $row['group_founder_manage'])
{
continue;
}
@@ -1992,7 +1992,7 @@ class acp_users
while ($row = $db->sql_fetchrow($result))
{
- $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', ACL_NEVER);
+ $hold_ary = $auth_admin->get_mask('view', $user_id, false, false, $row['auth_option'], 'global', phpbb::ACL_NEVER);
$auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', false, false);
}
$db->sql_freeresult($result);
@@ -2010,7 +2010,7 @@ class acp_users
while ($row = $db->sql_fetchrow($result))
{
- $hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', ACL_NEVER);
+ $hold_ary = $auth_admin->get_mask('view', $user_id, false, $forum_id, $row['auth_option'], 'local', phpbb::ACL_NEVER);
$auth_admin->display_mask('view', $row['auth_option'], $hold_ary, 'user', true, false);
}
$db->sql_freeresult($result);
diff --git a/phpBB/modules/acp/auth.php b/phpBB/modules/acp/auth.php
index 0fd78981a9..ee4e45a08d 100644
--- a/phpBB/modules/acp/auth.php
+++ b/phpBB/modules/acp/auth.php
@@ -58,7 +58,7 @@ class auth_admin extends auth
$cache->put('_acl_options', $this->acl_options);
}
}
-
+
/**
* Get permission mask
* This function only supports getting permissions of one type (for example a_)
@@ -69,9 +69,9 @@ class auth_admin extends auth
* @param mixed $forum_id forum_ids to search for. Defining a forum id also means getting local settings
* @param string $auth_option the auth_option defines the permission setting to look for (a_ for example)
* @param local|global $scope the scope defines the permission scope. If local, a forum_id is additionally required
- * @param ACL_NEVER|ACL_NO|ACL_YES $acl_fill defines the mode those permissions not set are getting filled with
+ * @param phpbb::ACL_NEVER|phpbb::ACL_NO|phpbb::ACL_YES $acl_fill defines the mode those permissions not set are getting filled with
*/
- public function get_mask($mode, $user_id = false, $group_id = false, $forum_id = false, $auth_option = false, $scope = false, $acl_fill = ACL_NEVER)
+ public function get_mask($mode, $user_id = false, $group_id = false, $forum_id = false, $auth_option = false, $scope = false, $acl_fill = phpbb::ACL_NEVER)
{
global $db, $user;
@@ -140,7 +140,7 @@ class auth_admin extends auth
$auth2 = &$auth;
}
-
+
$hold_ary[$userdata['user_id']] = array();
foreach ($forum_ids as $f_id)
{
@@ -345,7 +345,7 @@ class auth_admin extends auth
// Build js roles array (role data assignments)
$s_role_js_array = '';
-
+
if (sizeof($roles))
{
$s_role_js_array = array();
@@ -797,7 +797,7 @@ class auth_admin extends auth
reset($auth);
$flag = key($auth);
$flag = substr($flag, 0, strpos($flag, '_') + 1);
-
+
// This ID (the any-flag) is set if one or more permissions are true...
$any_option_id = (int) $this->acl_options['id'][$flag];
@@ -846,9 +846,9 @@ class auth_admin extends auth
// Ok, include the any-flag if one or more auth options are set to yes...
foreach ($auth as $auth_option => $setting)
{
- if ($setting == ACL_YES && (!isset($auth[$flag]) || $auth[$flag] == ACL_NEVER))
+ if ($setting == phpbb::ACL_YES && (!isset($auth[$flag]) || $auth[$flag] == phpbb::ACL_NEVER))
{
- $auth[$flag] = ACL_YES;
+ $auth[$flag] = phpbb::ACL_YES;
}
}
@@ -876,7 +876,7 @@ class auth_admin extends auth
{
$auth_option_id = (int) $this->acl_options['id'][$auth_option];
- if ($setting != ACL_NO)
+ if ($setting != phpbb::ACL_NO)
{
foreach ($ug_id as $id)
{
@@ -911,7 +911,7 @@ class auth_admin extends auth
reset($auth);
$flag = key($auth);
$flag = substr($flag, 0, strpos($flag, '_') + 1);
-
+
// Remove any-flag from auth ary
if (isset($auth[$flag]))
{
@@ -921,9 +921,9 @@ class auth_admin extends auth
// Re-set any flag...
foreach ($auth as $auth_option => $setting)
{
- if ($setting == ACL_YES && (!isset($auth[$flag]) || $auth[$flag] == ACL_NEVER))
+ if ($setting == phpbb::ACL_YES && (!isset($auth[$flag]) || $auth[$flag] == phpbb::ACL_NEVER))
{
- $auth[$flag] = ACL_YES;
+ $auth[$flag] = phpbb::ACL_YES;
}
}
@@ -932,7 +932,7 @@ class auth_admin extends auth
{
$auth_option_id = (int) $this->acl_options['id'][$auth_option];
- if ($setting != ACL_NO)
+ if ($setting != phpbb::ACL_NO)
{
$sql_ary[] = array(
'role_id' => (int) $role_id,
@@ -948,7 +948,7 @@ class auth_admin extends auth
$sql_ary[] = array(
'role_id' => (int) $role_id,
'auth_option_id' => (int) $this->acl_options['id'][$flag],
- 'auth_setting' => ACL_NEVER
+ 'auth_setting' => phpbb::ACL_NEVER
);
}
@@ -1004,7 +1004,7 @@ class auth_admin extends auth
while ($row = $db->sql_fetchrow($result))
{
$option_id_ary[] = $row['auth_option_id'];
- $auth_id_ary[$row['auth_option']] = ACL_NO;
+ $auth_id_ary[$row['auth_option']] = phpbb::ACL_NO;
}
$db->sql_freeresult($result);
@@ -1062,7 +1062,7 @@ class auth_admin extends auth
{
$where_sql[] = $db->sql_in_set('auth_option_id', array_map('intval', $option_id_ary));
}
-
+
$sql = "DELETE FROM $table
WHERE " . implode(' AND ', $where_sql);
$db->sql_query($sql);
@@ -1085,7 +1085,7 @@ class auth_admin extends auth
'S_YES' => ($cat_array['S_YES'] && !$cat_array['S_NEVER'] && !$cat_array['S_NO']) ? true : false,
'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false,
'S_NO' => ($cat_array['S_NO'] && !$cat_array['S_NEVER'] && !$cat_array['S_YES']) ? true : false,
-
+
'CAT_NAME' => $user->lang['permission_cat'][$cat])
);
@@ -1110,8 +1110,8 @@ class auth_admin extends auth
if ($s_view)
{
$template->assign_block_vars($tpl_cat . '.' . $tpl_mask, array(
- 'S_YES' => ($allowed == ACL_YES) ? true : false,
- 'S_NEVER' => ($allowed == ACL_NEVER) ? true : false,
+ 'S_YES' => ($allowed == phpbb::ACL_YES) ? true : false,
+ 'S_NEVER' => ($allowed == phpbb::ACL_NEVER) ? true : false,
'UG_ID' => $ug_id,
'FORUM_ID' => $forum_id,
@@ -1127,9 +1127,9 @@ class auth_admin extends auth
else
{
$template->assign_block_vars($tpl_cat . '.' . $tpl_mask, array(
- 'S_YES' => ($allowed == ACL_YES) ? true : false,
- 'S_NEVER' => ($allowed == ACL_NEVER) ? true : false,
- 'S_NO' => ($allowed == ACL_NO) ? true : false,
+ 'S_YES' => ($allowed == phpbb::ACL_YES) ? true : false,
+ 'S_NEVER' => ($allowed == phpbb::ACL_NEVER) ? true : false,
+ 'S_NO' => ($allowed == phpbb::ACL_NO) ? true : false,
'UG_ID' => $ug_id,
'FORUM_ID' => $forum_id,
@@ -1174,9 +1174,9 @@ class auth_admin extends auth
'lang' => '{ acl_' . $permission . ' }'
);
}
-
+
$cat = $user->lang['acl_' . $permission]['cat'];
-
+
// Build our categories array
if (!isset($categories[$cat]))
{
@@ -1199,9 +1199,9 @@ class auth_admin extends auth
);
}
- $content_array[$forum_id][$cat]['S_YES'] |= ($auth_setting == ACL_YES) ? true : false;
- $content_array[$forum_id][$cat]['S_NEVER'] |= ($auth_setting == ACL_NEVER) ? true : false;
- $content_array[$forum_id][$cat]['S_NO'] |= ($auth_setting == ACL_NO) ? true : false;
+ $content_array[$forum_id][$cat]['S_YES'] |= ($auth_setting == phpbb::ACL_YES) ? true : false;
+ $content_array[$forum_id][$cat]['S_NEVER'] |= ($auth_setting == phpbb::ACL_NEVER) ? true : false;
+ $content_array[$forum_id][$cat]['S_NO'] |= ($auth_setting == phpbb::ACL_NO) ? true : false;
$content_array[$forum_id][$cat]['permissions'][$permission] = $auth_setting;
}
@@ -1233,12 +1233,12 @@ class auth_admin extends auth
{
if (strpos($opt, 'a_') === 0)
{
- $hold_ary[0][$this->acl_options['id'][$opt]] = ACL_NEVER;
+ $hold_ary[0][$this->acl_options['id'][$opt]] = phpbb::ACL_NEVER;
}
}
// Force a_switchperm to be allowed
- $hold_ary[0][$this->acl_options['id']['a_switchperm']] = ACL_YES;
+ $hold_ary[0][$this->acl_options['id']['a_switchperm']] = phpbb::ACL_YES;
$user_permissions = $this->build_bitstring($hold_ary);
diff --git a/phpBB/modules/mcp/mcp_warn.php b/phpBB/modules/mcp/mcp_warn.php
index 40753def41..959b90079c 100644
--- a/phpBB/modules/mcp/mcp_warn.php
+++ b/phpBB/modules/mcp/mcp_warn.php
@@ -212,7 +212,7 @@ class mcp_warn
}
// There is no point issuing a warning to ignored users (ie anonymous and bots)
- if ($user_row['user_type'] == USER_IGNORE)
+ if ($user_row['user_type'] == phpbb::USER_IGNORE)
{
trigger_error('CANNOT_WARN_ANONYMOUS');
}
diff --git a/phpBB/modules/ucp/ucp_activate.php b/phpBB/modules/ucp/ucp_activate.php
index 594e346310..bc4618f5fd 100644
--- a/phpBB/modules/ucp/ucp_activate.php
+++ b/phpBB/modules/ucp/ucp_activate.php
@@ -44,7 +44,7 @@ class ucp_activate
trigger_error('NO_USER');
}
- if ($user_row['user_type'] <> USER_INACTIVE && !$user_row['user_newpasswd'])
+ if ($user_row['user_type'] <> phpbb::USER_INACTIVE && !$user_row['user_newpasswd'])
{
meta_refresh(3, append_sid('index'));
trigger_error('ALREADY_ACTIVATED');
diff --git a/phpBB/modules/ucp/ucp_groups.php b/phpBB/modules/ucp/ucp_groups.php
index 0c4a5dca31..67e6fdb9ea 100644
--- a/phpBB/modules/ucp/ucp_groups.php
+++ b/phpBB/modules/ucp/ucp_groups.php
@@ -429,7 +429,7 @@ class ucp_groups
}
// Check if the user is allowed to manage this group if set to founder only.
- if ($user->data['user_type'] != USER_FOUNDER && $group_row['group_founder_manage'])
+ if ($user->data['user_type'] != phpbb::USER_FOUNDER && $group_row['group_founder_manage'])
{
trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . $return_page, E_USER_WARNING);
}
diff --git a/phpBB/modules/ucp/ucp_pm_compose.php b/phpBB/modules/ucp/ucp_pm_compose.php
index ac9a4076cb..d81f5287eb 100644
--- a/phpBB/modules/ucp/ucp_pm_compose.php
+++ b/phpBB/modules/ucp/ucp_pm_compose.php
@@ -1147,7 +1147,7 @@ function handle_message_list_actions(&$address_list, &$error, $remove_u, $remove
if (sizeof($usernames))
{
$user_id_ary = array();
- user_get_id_name($user_id_ary, $usernames, array(USER_NORMAL, USER_FOUNDER, USER_INACTIVE));
+ user_get_id_name($user_id_ary, $usernames, array(phpbb::USER_NORMAL, phpbb::USER_FOUNDER, phpbb::USER_INACTIVE));
// If there are users not existing, we will at least print a notice...
if (!sizeof($user_id_ary))
diff --git a/phpBB/modules/ucp/ucp_profile.php b/phpBB/modules/ucp/ucp_profile.php
index 626fb8023d..cdae16b6f4 100644
--- a/phpBB/modules/ucp/ucp_profile.php
+++ b/phpBB/modules/ucp/ucp_profile.php
@@ -133,7 +133,7 @@ class ucp_profile
$message = 'PROFILE_UPDATED';
- if ($config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN))
+ if ($config['email_enable'] && $data['email'] != $user->data['user_email'] && $user->data['user_type'] != phpbb::USER_FOUNDER && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN))
{
$message = ($config['require_activation'] == USER_ACTIVATION_SELF) ? 'ACCOUNT_EMAIL_CHANGED' : 'ACCOUNT_EMAIL_CHANGED_ADMIN';
@@ -172,7 +172,7 @@ class ucp_profile
$admin_ary = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array();
// Also include founders
- $where_sql = ' WHERE user_type = ' . USER_FOUNDER;
+ $where_sql = ' WHERE user_type = ' . phpbb::USER_FOUNDER;
if (sizeof($admin_ary))
{
diff --git a/phpBB/modules/ucp/ucp_register.php b/phpBB/modules/ucp/ucp_register.php
index b9ba1246ea..55f75bd9fb 100644
--- a/phpBB/modules/ucp/ucp_register.php
+++ b/phpBB/modules/ucp/ucp_register.php
@@ -277,13 +277,13 @@ class ucp_register
$key_len = ($key_len < 6) ? 6 : $key_len;
$user_actkey = substr($user_actkey, 0, $key_len);
- $user_type = USER_INACTIVE;
+ $user_type = phpbb::USER_INACTIVE;
$user_inactive_reason = INACTIVE_REGISTER;
$user_inactive_time = time();
}
else
{
- $user_type = USER_NORMAL;
+ $user_type = phpbb::USER_NORMAL;
$user_actkey = '';
$user_inactive_reason = 0;
$user_inactive_time = 0;
@@ -375,7 +375,7 @@ class ucp_register
$admin_ary = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array();
// Also include founders
- $where_sql = ' WHERE user_type = ' . USER_FOUNDER;
+ $where_sql = ' WHERE user_type = ' . phpbb::USER_FOUNDER;
if (sizeof($admin_ary))
{
diff --git a/phpBB/modules/ucp/ucp_remind.php b/phpBB/modules/ucp/ucp_remind.php
index db4b3c8fcc..550051ae18 100644
--- a/phpBB/modules/ucp/ucp_remind.php
+++ b/phpBB/modules/ucp/ucp_remind.php
@@ -48,12 +48,12 @@ class ucp_remind
trigger_error('NO_EMAIL_USER');
}
- if ($user_row['user_type'] == USER_IGNORE)
+ if ($user_row['user_type'] == phpbb::USER_IGNORE)
{
trigger_error('NO_USER');
}
- if ($user_row['user_type'] == USER_INACTIVE)
+ if ($user_row['user_type'] == phpbb::USER_INACTIVE)
{
if ($user_row['user_inactive_reason'] == INACTIVE_MANUAL)
{
diff --git a/phpBB/modules/ucp/ucp_resend.php b/phpBB/modules/ucp/ucp_resend.php
index fef6decf4a..38b333a5a4 100644
--- a/phpBB/modules/ucp/ucp_resend.php
+++ b/phpBB/modules/ucp/ucp_resend.php
@@ -55,17 +55,17 @@ class ucp_resend
trigger_error('NO_EMAIL_USER');
}
- if ($user_row['user_type'] == USER_IGNORE)
+ if ($user_row['user_type'] == phpbb::USER_IGNORE)
{
trigger_error('NO_USER');
}
- if (!$user_row['user_actkey'] && $user_row['user_type'] != USER_INACTIVE)
+ if (!$user_row['user_actkey'] && $user_row['user_type'] != phpbb::USER_INACTIVE)
{
trigger_error('ACCOUNT_ALREADY_ACTIVATED');
}
- if (!$user_row['user_actkey'] || ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_MANUAL))
+ if (!$user_row['user_actkey'] || ($user_row['user_type'] == phpbb::USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_MANUAL))
{
trigger_error('ACCOUNT_DEACTIVATED');
}
diff --git a/phpBB/modules/ucp/ucp_zebra.php b/phpBB/modules/ucp/ucp_zebra.php
index 6ba168a53c..a928e9985a 100644
--- a/phpBB/modules/ucp/ucp_zebra.php
+++ b/phpBB/modules/ucp/ucp_zebra.php
@@ -114,13 +114,13 @@ class ucp_zebra
$sql = 'SELECT user_id, user_type
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('username_clean', $data['add']) . '
- AND user_type <> ' . USER_INACTIVE;
+ AND user_type <> ' . phpbb::USER_INACTIVE;
$result = $db->sql_query($sql);
$user_id_ary = array();
while ($row = $db->sql_fetchrow($result))
{
- if ($row['user_id'] != ANONYMOUS && $row['user_type'] != USER_IGNORE)
+ if ($row['user_id'] != ANONYMOUS && $row['user_type'] != phpbb::USER_IGNORE)
{
$user_id_ary[] = $row['user_id'];
}
diff --git a/phpBB/plugins/bootstrap.php b/phpBB/plugins/bootstrap.php
index 7db4eec96c..c3c3d4817d 100644
--- a/phpBB/plugins/bootstrap.php
+++ b/phpBB/plugins/bootstrap.php
@@ -1,249 +1,507 @@
<?php
/**
*
-* @package phpBB3
+* @package plugins
* @version $Id$
-* @copyright (c) 2007 phpBB Group
+* @copyright (c) 2008 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
-* @ignore
+* Class used by plugins/modules/etc. for installation/uninstallation
*/
-if (!defined('IN_PHPBB'))
+class phpbb_install
{
- exit;
+ public function install() {}
+ public function uninstall() {}
}
/**
-* phpBB Hook Class
-* @package phpBB3
+* Main class handling plugins/hooks
*/
-class phpbb_hook
+class phpbb_plugins
{
- /**
- * Registered hooks
- */
- var $hooks = array();
+ public $phpbb_required = array();
+ public $phpbb_optional = array();
- /**
- * Results returned by functions called
- */
- var $hook_result = array();
+ public $plugin_path = false;
+ public $plugins = array();
- /**
- * internal pointer
- */
- var $current_hook = NULL;
+ private $hooks = array();
+ private $current_plugin = false;
/**
- * Initialize hook class.
*
- * @param array $valid_hooks array containing the hookable functions/methods
+ * @return
+ * @param string $plugin_path
*/
- function __construct($valid_hooks)
+ public function init($plugin_path)
{
- foreach ($valid_hooks as $_null => $method)
- {
- $this->add_hook($method);
- }
+ $this->plugin_path = $plugin_path;
+ $this->plugins = array();
- if (function_exists('phpbb_hook_register'))
+ // search for plugin files
+ if ($dh = @opendir($this->plugin_path))
{
- phpbb_hook_register($this);
+ while (($file = readdir($dh)) !== false)
+ {
+ // If is directory and a PHP file with the same name as the directory within this dir?
+ if ($file[0] != '.' && is_readable($this->plugin_path . $file) && is_dir($this->plugin_path . $file) && file_exists($this->plugin_path . $file . '/' . $file . '.' . PHP_EXT))
+ {
+ $this->add_plugin($file);
+ }
+ }
+ closedir($dh);
}
}
/**
- * Register function/method to be called within hook
- * This function is normally called by the modification/application to attach/register the functions.
*
- * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
- * @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition
- * @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain.
+ * @return
+ * @param string $phpbb_name
*/
- function register($definition, $hook, $mode = 'normal')
+ public function add_plugin($phpbb_name)
{
- $class = (!is_array($definition)) ? '__global' : $definition[0];
- $function = (!is_array($definition)) ? $definition : $definition[1];
-
- // Method able to be hooked?
- if (isset($this->hooks[$class][$function]))
+ if (!file_exists($this->plugin_path . $phpbb_name . '/' . $phpbb_name . '.' . PHP_EXT))
{
- switch ($mode)
- {
- case 'standalone':
- if (!isset($this->hooks[$class][$function]['standalone']))
- {
- $this->hooks[$class][$function] = array('standalone' => $hook);
- }
- else
- {
- trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE);
- }
- break;
+ return false;
+ }
- case 'first':
- case 'last':
- $this->hooks[$class][$function][$mode][] = $hook;
- break;
+ // Include desired plugin
+ require_once $this->plugin_path . $phpbb_name . '/' . $phpbb_name . '.' . PHP_EXT;
- case 'normal':
- default:
- $this->hooks[$class][$function]['normal'][] = $hook;
- break;
- }
- }
+ // Create new setup for this plugin
+ $this->plugins[$phpbb_name] = new phpbb_plugin_structure($phpbb_name);
+ $this->current_plugin = $this->plugins[$phpbb_name];
+
+ // Setup plugin
+ $this->current_plugin->setup->setup_plugin($this);
}
- /**
- * Calling all functions/methods attached to a specified hook.
- * Called by the function allowing hooks...
- *
- * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
- * @return bool False if no hook got executed, true otherwise
- */
- function call_hook($definition)
+ public function setup()
{
- $class = (!is_array($definition)) ? '__global' : $definition[0];
- $function = (!is_array($definition)) ? $definition : $definition[1];
+ if (empty($this->plugins))
+ {
+ return false;
+ }
- if (!empty($this->hooks[$class][$function]))
+ foreach ($this->plugins as $name => $plugin)
{
- // Developer tries to call a hooked function within the hooked function...
- if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function)
+ // Add includes
+ foreach ($plugin->includes as $file)
{
- return false;
+ include_once $this->plugin_path . $name . '/' . $file . '.' . PHP_EXT;
}
- // Call the hook with the arguments attached and store result
- $arguments = func_get_args();
- $this->current_hook = array('class' => $class, 'function' => $function);
- $arguments[0] = &$this;
-
- // Call the hook chain...
- if (isset($this->hooks[$class][$function]['standalone']))
- {
- $this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments);
- }
- else
+ // Setup objects
+ foreach ($plugin->objects as $key => $class)
{
- foreach (array('first', 'normal', 'last') as $mode)
+ $object = new $class();
+
+ if (!property_exists($object, 'phpbb_plugin') && !property_exists($object, 'class_plugin'))
+ {
+ trigger_error('Class ' . get_class($object) . ' does not define public $phpbb_plugin and public $class_plugin.', E_USER_ERROR);
+ }
+
+ if (property_exists($object, 'phpbb_plugin') && !empty($object->phpbb_plugin))
{
- if (!isset($this->hooks[$class][$function][$mode]))
+ // Is the plugin the mod author wants to influence pluggable?
+ if (!is_subclass_of(phpbb::get_instance($object->phpbb_plugin), 'phpbb_plugin_support'))
{
- continue;
+ trigger_error('The phpBB Class ' . get_class(phpbb::get_instance($object->phpbb_plugin)) . ' defined in ' . get_class($object) . ' is not pluggable.', E_USER_ERROR);
}
- foreach ($this->hooks[$class][$function][$mode] as $hook)
+ $instance = phpbb::get_instance($object->phpbb_plugin);
+ }
+ else
+ {
+ $instance = ${$object->object_plugin};
+
+ if (!is_subclass_of($instance, 'phpbb_plugin_support'))
{
- $this->hook_result[$class][$function] = call_user_func_array($hook, $arguments);
+ trigger_error('The Class ' . get_class($instance) . ' defined in ' . get_class($object) . ' is not pluggable.', E_USER_ERROR);
}
}
+
+ // Setup/Register plugin...
+ $object->setup_plugin($instance);
+// $plugin->objects[$key] = $object;
+ }
+
+ // Now setup the functions... this is a special case...
+ foreach ($plugin->functions as $params)
+ {
+ $function = array_shift($params);
+ $hook = array_shift($params);
+ $mode = (!empty($params)) ? array_shift($params) : phpbb::FUNCTION_INJECT;
+ $action = (!empty($params)) ? array_shift($params) : 'default';
+
+ // Check if the function is already overridden.
+ if ($mode == phpbb::FUNCTION_OVERRIDE && isset($this->hooks[$function][$mode]))
+ {
+ trigger_error('Function ' . $function . ' is already overwriten by ' . $this->hooks[$function][$mode] . '.', E_USER_ERROR);
+ }
+
+ if ($mode == phpbb::FUNCTION_OVERRIDE)
+ {
+ $this->hooks[$function][$mode] = $hook;
+ }
+ else
+ {
+ $this->hooks[$function][$mode][$action][] = $hook;
+ }
}
- $this->current_hook = NULL;
- return true;
+ // Call init method?
+ if (method_exists($plugin->setup, 'init'))
+ {
+ $plugin->setup->init();
+ }
}
+ }
+
+ public function register_includes()
+ {
+ $arguments = func_get_args();
+ $this->current_plugin->includes = $arguments;
+ }
+
+ public function register_plugins()
+ {
+ $arguments = func_get_args();
+ $this->current_plugin->objects = $arguments;
+ }
+
+ public function register_function()
+ {
+ $arguments = func_get_args();
+ $this->current_plugin->functions[] = $arguments;
+ }
+
+ public function function_override($function)
+ {
+ return isset($this->hooks[$function][phpbb::FUNCTION_OVERRIDE]);
+ }
+
+ public function function_inject($function, $action = 'default')
+ {
+ return isset($this->hooks[$function][phpbb::FUNCTION_INJECT][$action]);
+ }
+
+ public function call_override()
+ {
+ $arguments = func_get_args();
+ $function = array_shift($arguments);
- $this->current_hook = NULL;
- return false;
+ return call_user_func_array($this->hooks[$function][phpbb::FUNCTION_OVERRIDE], $arguments);
}
/**
- * Get result from previously called functions/methods for the same hook
+ * Call injected function.
+ *
+ * Arguments are layed out in the following way:
+ * action: The action:
+ * 'default': If $action is default, then the hook is called in the beginning, original parameter passed by reference
+ * 'return': If $action is return, then the hook is called at the end and the result will be returned. The hook expects the $result as the first parameter, all other parameters passed by name
+ * If $action is not default and not return it could be a custom string. Please refer to the plugin documentation to determine possible combinations. Parameters are passed by reference.
*
- * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
- * @return mixed False if nothing returned if there is no result, else array('result' => ... )
+ * @param string $function Original function name this method is called from
+ * @param array $arguments Arguments
*/
- function previous_hook_result($definition)
+ public function call_inject($function, $arguments)
{
- $class = (!is_array($definition)) ? '__global' : $definition[0];
- $function = (!is_array($definition)) ? $definition : $definition[1];
+ $result = NULL;
- if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
+ if (!is_array($arguments))
{
- return array('result' => $this->hook_result[$class][$function]);
+ $action = $arguments;
+ $arguments = array();
}
+ else
+ {
+ $action = array_shift($arguments);
+ }
+
+ // Return action... handle like override
+ if ($action == 'return')
+ {
+ $result = array_shift($arguments);
+
+ foreach ($this->hooks[$function][phpbb::FUNCTION_INJECT][$action] as $key => $hook)
+ {
+ $args = array_merge(array($result), $arguments);
+ $result = call_user_func_array($hook, $args);
+ }
- return false;
+ return $result;
+ }
+
+ foreach ($this->hooks[$function][phpbb::FUNCTION_INJECT][$action] as $key => $hook)
+ {
+ call_user_func_array($hook, $arguments);
+ }
}
+}
+
+// Object used to hold plugin information. Per plugin one instance
+class phpbb_plugin_structure
+{
+ public $phpbb_name;
+ public $name;
+ public $description;
+ public $author;
+ public $version;
+
+ public $includes = array();
+ public $objects = array();
+ public $functions = array();
/**
- * Check if the called functions/methods returned something.
*
- * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
- * @return bool True if results are there, false if not
+ * @return
+ * @param string $phpbb_name
*/
- function hook_return($definition)
+ public function __construct($phpbb_name)
+ {
+ $this->phpbb_name = $phpbb_name;
+
+ $class = 'phpbb_' . $phpbb_name . '_info';
+ $this->setup = new $class();
+
+ foreach (array('name', 'description', 'author', 'version') as $required_property)
+ {
+ $this->$required_property = $this->setup->$required_property;
+ }
+ }
+}
+
+interface phpbb_plugin_info
+{
+ public function setup_plugin(phpbb_plugins $object);
+}
+
+interface phpbb_plugin_setup
+{
+ function setup_plugin(phpbb_plugin_support $object);
+}
+
+
+abstract class phpbb_plugin_support
+{
+ private $plugin_methods;
+ private $plugin_attributes;
+
+ public function register_method($name, $method, $object, $mode = phpbb::PLUGIN_ADD, $action = 'default')
{
- $class = (!is_array($definition)) ? '__global' : $definition[0];
- $function = (!is_array($definition)) ? $definition : $definition[1];
+ // Method reachable by:
+ // For plugin_add: plugin_methods[method] = object
+ // For plugin_override: plugin_methods[name][mode][method] = object
+ // For plugin_inject: plugin_methods[name][mode][action][method] = object
+
+ // Set to PLUGIN_ADD if method does not exist
+ if ($name === false || !method_exists($this, $name))
+ {
+ $mode = phpbb::PLUGIN_ADD;
+ }
- if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
+ // But if it exists and we try to add one, then print out an error
+ if ($mode == phpbb::PLUGIN_ADD && (method_exists($this, $method) || isset($this->plugin_methods[$method])))
{
- return true;
+ trigger_error('Method ' . $method. ' in class ' . get_class($object) . ' is not able to be added, because it conflicts with the existing method ' . $method . ' in ' . get_class($this) . '.', E_USER_ERROR);
}
- return false;
+ // Check if the same method name is already used for $name for overriding the method.
+ if ($mode == phpbb::PLUGIN_OVERRIDE && isset($this->plugin_methods[$name][$mode][$method]))
+ {
+ trigger_error('Method ' . $method . ' in class ' . get_class($object) . ' is not able to override . ' . $name . ' in ' . get_class($this) . ', because it is already overridden in ' . get_class($this->plugin_methods[$name][$mode][$method]) . '.', E_USER_ERROR);
+ }
+
+ // Check if another method is already defined...
+ if ($mode == phpbb::PLUGIN_INJECT && isset($this->plugin_methods[$name][$mode][$action][$method]))
+ {
+ trigger_error('Method ' . $method . ' in class ' . get_class($object) . ' for ' . $name . ' is already defined in class ' . get_class($this->plugin_methods[$name][$mode][$action][$method]), E_USER_ERROR);
+ }
+
+ if (($function_signature = $this->valid_parameter($object, $method, $mode, $action)) !== true)
+ {
+ trigger_error('Method ' . $method . ' in class ' . get_class($object) . ' has invalid function signature. Please use: ' . $function_signature, E_USER_ERROR);
+ }
+
+ if ($mode == phpbb::PLUGIN_ADD)
+ {
+ $this->plugin_methods[$method] = $object;
+ }
+ else if ($mode == phpbb::PLUGIN_OVERRIDE)
+ {
+ $this->plugin_methods[$name][$mode][$method] = $object;
+ }
+ else
+ {
+ $this->plugin_methods[$name][$mode][$action][$method] = $object;
+ }
}
- /**
- * Give actual result from called functions/methods back.
- *
- * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
- * @return mixed The result
- */
- function hook_return_result($definition)
+ public function register_attribute($name, $object)
{
- $class = (!is_array($definition)) ? '__global' : $definition[0];
- $function = (!is_array($definition)) ? $definition : $definition[1];
+ if (property_exists($this, $name))
+ {
+ unset($this->$name);
+ }
- if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
+ if (isset($this->plugin_attributes[$name]))
{
- $result = $this->hook_result[$class][$function];
- unset($this->hook_result[$class][$function]);
- return $result;
+ trigger_error('Attribute ' . $name . ' in class ' . get_class($object) . ' already defined in class ' . get_class($this->plugin_attributes[$name]), E_USER_ERROR);
}
- return;
+ $this->plugin_attributes[$name] = $object;
+ }
+
+ protected function method_override($name)
+ {
+ return isset($this->plugin_methods[$name][phpbb::PLUGIN_OVERRIDE]);
+ }
+
+ protected function method_inject($name, $action = 'default')
+ {
+ return isset($this->plugin_methods[$name][phpbb::PLUGIN_INJECT][$action]);
+ }
+
+ public function call_override()
+ {
+ $arguments = func_get_args();
+ $name = array_shift($arguments);
+
+ list($method, $object) = each($this->plugin_methods[$name][phpbb::PLUGIN_OVERRIDE]);
+ return call_user_func_array(array($object, $method), array_merge(array($this), $arguments));
}
/**
- * Add new function to the allowed hooks.
+ * Call injected method.
+ *
+ * Arguments are layed out in the following way:
+ * action: The action:
+ * 'default': If $action is default, then the plugin is called in the beginning, original parameter passed by reference
+ * 'return': If $action is return, then the plugin is called at the end and the result will be returned. The plugin expects the $result as the first parameter, all other parameters passed by name
+ * If $action is not default and not return it could be a custom string. Please refer to the plugin documentation to determine possible combinations. Parameters are passed by reference.
*
- * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
+ * @param string $name Original method name this method is called from
+ * @param array $arguments Arguments
*/
- function add_hook($definition)
+ public function call_inject($name, $arguments)
{
- if (!is_array($definition))
+ $result = NULL;
+
+ if (!is_array($arguments))
+ {
+ $action = $arguments;
+ $arguments = array();
+ }
+ else
{
- $definition = array('__global', $definition);
+ $action = array_shift($arguments);
}
- $this->hooks[$definition[0]][$definition[1]] = array();
+ // Return action... handle like override
+ if ($action == 'return')
+ {
+ $result = array_shift($arguments);
+
+ foreach ($this->plugin_methods[$name][phpbb::PLUGIN_INJECT][$action] as $method => $object)
+ {
+ $args = array_merge(array($this, $result), $arguments);
+ $result = call_user_func_array(array($object, $method), $args);
+ }
+
+ return $result;
+ }
+
+ foreach ($this->plugin_methods[$name][phpbb::PLUGIN_INJECT][$action] as $method => $object)
+ {
+ call_user_func_array(array($object, $method), array_merge(array($this), $arguments));
+ }
}
- /**
- * Remove function from the allowed hooks.
- *
- * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
- */
- function remove_hook($definition)
+ // Getter/Setter
+ public function __get($name)
+ {
+ return $this->plugin_attributes[$name]->$name;
+ }
+
+ public function __set($name, $value)
+ {
+ return $this->plugin_attributes[$name]->$name = $value;
+ }
+
+ public function __isset($name)
+ {
+ return isset($this->plugin_attributes[$name]->$name);
+ }
+
+ public function __unset($name)
{
- $class = (!is_array($definition)) ? '__global' : $definition[0];
- $function = (!is_array($definition)) ? $definition : $definition[1];
+ unset($this->plugin_attributes[$name]->$name);
+ }
- if (isset($this->hooks[$class][$function]))
+ public function __call($name, $arguments)
+ {
+ array_unshift($arguments, $this);
+ return call_user_func_array(array($this->plugin_methods[$name], $name), $arguments);
+ }
+
+ private function valid_parameter($object, $method, $mode, $action)
+ {
+ // We cache the results... no worry. These checks are quite resource intensive, but will hopefully educate and guide developers
+
+ // Check for correct first parameter. This must be an instance of phpbb_$phpbb_plugin
+ $instance_of = 'phpbb_' . $object->phpbb_plugin;
+
+ // Define the required function layout
+ $function_layout = 'public function ' . $method . '(' . $instance_of . ' $object';
+
+ // Result for PLUGIN_INJECT and action == 'return'
+ if ($mode == phpbb::PLUGIN_INJECT && $action == 'return')
{
- unset($this->hooks[$class][$function]);
+ $function_layout .= ', $result';
+ }
+
+ $function_layout .= ', [...]) { [...] }';
+
+ $reflection = new ReflectionMethod($object, $method);
+ $parameters = $reflection->getParameters();
+ $first_param = array_shift($parameters);
+
+ // Try to get class
+ if (empty($first_param))
+ {
+ return $function_layout;
+ }
- if (isset($this->hook_result[$class][$function]))
+ try
+ {
+ $first_param->getClass()->name;
+ }
+ catch (Exception $e)
+ {
+ return $function_layout;
+ }
+
+ if ($first_param->getClass()->name !== $instance_of || $first_param->getName() !== 'object')
+ {
+ return $function_layout;
+ }
+
+ if ($mode == phpbb::PLUGIN_INJECT && $action == 'return')
+ {
+ $first_param = array_shift($parameters);
+
+ if (empty($first_param) || $first_param->getName() !== 'result' || $first_param->isOptional())
{
- unset($this->hook_result[$class][$function]);
+ return $function_layout;
}
}
+
+ return true;
}
}
diff --git a/phpBB/search.php b/phpBB/search.php
index 3d01643d72..a1804673c8 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -113,7 +113,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . "
WHERE $sql_where
- AND user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
+ AND user_type IN (" . phpbb::USER_NORMAL . ', ' . phpbb::USER_FOUNDER . ')';
$result = $db->sql_query_limit($sql, 100);
while ($row = $db->sql_fetchrow($result))
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php
index 960eee4b65..2606bf8aa9 100644
--- a/phpBB/viewonline.php
+++ b/phpBB/viewonline.php
@@ -139,7 +139,7 @@ while ($row = $db->sql_fetchrow($result))
$view_online = $s_user_hidden = false;
$user_colour = ($row['user_colour']) ? ' style="color:#' . $row['user_colour'] . '" class="username-coloured"' : '';
- $username_full = ($row['user_type'] != USER_IGNORE) ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : '<span' . $user_colour . '>' . $row['username'] . '</span>';
+ $username_full = ($row['user_type'] != phpbb::USER_IGNORE) ? get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) : '<span' . $user_colour . '>' . $row['username'] . '</span>';
if (!$row['session_viewonline'])
{
@@ -330,7 +330,7 @@ while ($row = $db->sql_fetchrow($result))
'USER_IP' => ($auth->acl_get('a_')) ? (($mode == 'lookup' && $session_id == $row['session_id']) ? gethostbyaddr($row['session_ip']) : $row['session_ip']) : '',
'USER_BROWSER' => ($auth->acl_get('a_user')) ? $row['session_browser'] : '',
- 'U_USER_PROFILE' => ($row['user_type'] != USER_IGNORE) ? get_username_string('profile', $row['user_id'], '') : '',
+ 'U_USER_PROFILE' => ($row['user_type'] != phpbb::USER_IGNORE) ? get_username_string('profile', $row['user_id'], '') : '',
'U_USER_IP' => append_sid('viewonline', 'mode=lookup' . (($mode != 'lookup' || $row['session_id'] != $session_id) ? '&amp;s=' . $row['session_id'] : '') . "&amp;sg=$show_guests&amp;start=$start&amp;sk=$sort_key&amp;sd=$sort_dir"),
'U_WHOIS' => append_sid('viewonline', 'mode=whois&amp;s=' . $row['session_id']),
'U_FORUM_LOCATION' => $location_url,