mirror of
https://github.com/phpbb/phpbb.git
synced 2025-10-17 17:56:25 +02:00
remove global and change $user-> to phpbb::$user->
git-svn-id: file:///svn/phpbb/trunk@9334 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @package acm
|
||||
* @version $Id$
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
* @copyright (c) 2009 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -17,32 +17,35 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* ACM APC Based Caching
|
||||
* ACM File Based Caching
|
||||
* @package acm
|
||||
*/
|
||||
class acm
|
||||
{
|
||||
private $vars = array();
|
||||
private $is_modified = false;
|
||||
var $vars = array();
|
||||
var $is_modified = false;
|
||||
|
||||
public $sql_rowset = array();
|
||||
public $cache_dir = '';
|
||||
var $sql_rowset = array();
|
||||
var $sql_row_pointer = array();
|
||||
var $cache_dir = '';
|
||||
|
||||
/**
|
||||
* Set cache path
|
||||
*/
|
||||
function __construct()
|
||||
function acm()
|
||||
{
|
||||
$this->cache_dir = PHPBB_ROOT_PATH . 'cache/';
|
||||
$this->cache_dir = $phpbb_root_path . 'cache/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load global cache
|
||||
*/
|
||||
private function load()
|
||||
function load()
|
||||
{
|
||||
// grab the global cache
|
||||
if ($this->vars = apc_fetch('global'))
|
||||
$this->vars = apc_fetch('global');
|
||||
|
||||
if ($this->vars !== false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -53,20 +56,22 @@ class acm
|
||||
/**
|
||||
* Unload cache object
|
||||
*/
|
||||
public function unload()
|
||||
function unload()
|
||||
{
|
||||
$this->save();
|
||||
unset($this->vars);
|
||||
unset($this->sql_rowset);
|
||||
unset($this->sql_row_pointer);
|
||||
|
||||
$this->vars = array();
|
||||
$this->sql_rowset = array();
|
||||
$this->sql_row_pointer = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save modified objects
|
||||
*/
|
||||
private function save()
|
||||
function save()
|
||||
{
|
||||
if (!$this->is_modified)
|
||||
{
|
||||
@@ -81,7 +86,7 @@ class acm
|
||||
/**
|
||||
* Tidy cache
|
||||
*/
|
||||
public function tidy()
|
||||
function tidy()
|
||||
{
|
||||
// cache has auto GC, no need to have any code here :)
|
||||
|
||||
@@ -91,28 +96,29 @@ class acm
|
||||
/**
|
||||
* Get saved cache object
|
||||
*/
|
||||
public function get($var_name)
|
||||
function get($var_name)
|
||||
{
|
||||
if ($var_name[0] === '_')
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
if (!$this->_exists($var_name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return apc_fetch($var_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sizeof($this->vars))
|
||||
{
|
||||
$this->load();
|
||||
}
|
||||
return (isset($this->vars[$var_name])) ? $this->vars[$var_name] : false;
|
||||
return ($this->_exists($var_name)) ? $this->vars[$var_name] : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put data into cache
|
||||
*/
|
||||
public function put($var_name, $var, $ttl = 31536000)
|
||||
function put($var_name, $var, $ttl = 31536000)
|
||||
{
|
||||
if ($var_name[0] === '_')
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
apc_store($var_name, $var, $ttl);
|
||||
}
|
||||
@@ -126,7 +132,7 @@ class acm
|
||||
/**
|
||||
* Purge cache data
|
||||
*/
|
||||
public function purge()
|
||||
function purge()
|
||||
{
|
||||
// Purge all phpbb cache files
|
||||
$dir = @opendir($this->cache_dir);
|
||||
@@ -143,7 +149,7 @@ class acm
|
||||
continue;
|
||||
}
|
||||
|
||||
@unlink($this->cache_dir . $entry);
|
||||
$this->remove_file($this->cache_dir . $entry);
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
@@ -151,10 +157,11 @@ class acm
|
||||
|
||||
unset($this->vars);
|
||||
unset($this->sql_rowset);
|
||||
unset($this->sql_row_pointer);
|
||||
|
||||
$this->vars = array();
|
||||
$this->var_expires = array();
|
||||
$this->sql_rowset = array();
|
||||
$this->sql_row_pointer = array();
|
||||
|
||||
$this->is_modified = false;
|
||||
}
|
||||
@@ -162,9 +169,9 @@ class acm
|
||||
/**
|
||||
* Destroy cache data
|
||||
*/
|
||||
public function destroy($var_name, $table = '')
|
||||
function destroy($var_name, $table = '')
|
||||
{
|
||||
if ($var_name === 'sql' && !empty($table))
|
||||
if ($var_name == 'sql' && !empty($table))
|
||||
{
|
||||
if (!is_array($table))
|
||||
{
|
||||
@@ -175,6 +182,7 @@ class acm
|
||||
{
|
||||
// gives us the md5s that we want
|
||||
$temp = apc_fetch('sql_' . $table_name);
|
||||
|
||||
if ($temp === false)
|
||||
{
|
||||
continue;
|
||||
@@ -193,7 +201,12 @@ class acm
|
||||
return;
|
||||
}
|
||||
|
||||
if ($var_name[0] === '_')
|
||||
if (!$this->_exists($var_name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
apc_delete($var_name);
|
||||
}
|
||||
@@ -207,10 +220,30 @@ class acm
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given cache entry exist
|
||||
*/
|
||||
function _exists($var_name)
|
||||
{
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sizeof($this->vars))
|
||||
{
|
||||
$this->load();
|
||||
}
|
||||
|
||||
return isset($this->vars[$var_name]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load cached sql query
|
||||
*/
|
||||
public function sql_load($query)
|
||||
function sql_load($query)
|
||||
{
|
||||
// Remove extra spaces and tabs
|
||||
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
||||
@@ -224,6 +257,7 @@ class acm
|
||||
}
|
||||
|
||||
$this->sql_rowset[$query_id] = $temp;
|
||||
$this->sql_row_pointer[$query_id] = 0;
|
||||
|
||||
return $query_id;
|
||||
}
|
||||
@@ -231,25 +265,15 @@ class acm
|
||||
/**
|
||||
* Save sql query
|
||||
*/
|
||||
public function sql_save($query, &$query_result, $ttl)
|
||||
function sql_save($query, &$query_result, $ttl)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Remove extra spaces and tabs
|
||||
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
||||
|
||||
// determine which tables this query belongs to:
|
||||
|
||||
// grab all the FROM tables, avoid getting a LEFT JOIN
|
||||
preg_match('/FROM \(?(\w+(?: (?!LEFT JOIN)\w+)?(?:, ?\w+(?: (?!LEFT JOIN)\w+)?)*)\)?/', $query, $regs);
|
||||
// determine which tables this query belongs to
|
||||
preg_match('/FROM \\(?(\\w+(?: \\w+)?(?:, ?\\w+(?: \\w+)?)*)\\)?/', $query, $regs);
|
||||
$tables = array_map('trim', explode(',', $regs[1]));
|
||||
|
||||
// now get the LEFT JOIN
|
||||
preg_match_all('/LEFT JOIN\s+(\w+)(?: \w+)?/', $query, $result, PREG_PATTERN_ORDER);
|
||||
$tables = array_merge($tables, $result[1]);
|
||||
|
||||
$query_hash = md5($query);
|
||||
|
||||
foreach ($tables as $table_name)
|
||||
{
|
||||
if (($pos = strpos($table_name, ' ')) !== false)
|
||||
@@ -262,13 +286,14 @@ class acm
|
||||
{
|
||||
$temp = array();
|
||||
}
|
||||
$temp[$query_hash] = true;
|
||||
$temp[md5($query)] = true;
|
||||
apc_store('sql_' . $table_name, $temp, $ttl);
|
||||
}
|
||||
|
||||
// store them in the right place
|
||||
$query_id = sizeof($this->sql_rowset);
|
||||
$this->sql_rowset[$query_id] = array();
|
||||
$this->sql_row_pointer[$query_id] = 0;
|
||||
|
||||
while ($row = $db->sql_fetchrow($query_result))
|
||||
{
|
||||
@@ -276,35 +301,63 @@ class acm
|
||||
}
|
||||
$db->sql_freeresult($query_result);
|
||||
|
||||
apc_store('sql_' . $query_hash, $this->sql_rowset[$query_id], $ttl);
|
||||
apc_store('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl);
|
||||
|
||||
$query_result = $query_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ceck if a given sql query exist in cache
|
||||
*/
|
||||
function sql_exists($query_id)
|
||||
{
|
||||
return isset($this->sql_rowset[$query_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch row from cache (database)
|
||||
*/
|
||||
public function sql_fetchrow($query_id)
|
||||
function sql_fetchrow($query_id)
|
||||
{
|
||||
list(, $row) = each($this->sql_rowset[$query_id]);
|
||||
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
|
||||
}
|
||||
|
||||
return ($row !== NULL) ? $row : false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a field from the current row of a cached database result (database)
|
||||
*/
|
||||
public function sql_fetchfield($query_id, $field)
|
||||
function sql_fetchfield($query_id, $field)
|
||||
{
|
||||
$row = current($this->sql_rowset[$query_id]);
|
||||
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field] : false;
|
||||
}
|
||||
|
||||
return ($row !== false && isset($row[$field])) ? $row[$field] : false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek a specific row in an a cached database result (database)
|
||||
*/
|
||||
function sql_rowseek($rownum, $query_id)
|
||||
{
|
||||
if ($rownum >= sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->sql_row_pointer[$query_id] = $rownum;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free memory used for a cached database result (database)
|
||||
*/
|
||||
public function sql_freeresult($query_id)
|
||||
function sql_freeresult($query_id)
|
||||
{
|
||||
if (!isset($this->sql_rowset[$query_id]))
|
||||
{
|
||||
@@ -312,9 +365,24 @@ class acm
|
||||
}
|
||||
|
||||
unset($this->sql_rowset[$query_id]);
|
||||
unset($this->sql_row_pointer[$query_id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes/unlinks file
|
||||
*/
|
||||
function remove_file($filename, $check = false)
|
||||
{
|
||||
if ($check && !@is_writable($this->cache_dir))
|
||||
{
|
||||
// E_USER_ERROR - not using language entry - intended.
|
||||
trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR);
|
||||
}
|
||||
|
||||
return @unlink($filename);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,72 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @package acm
|
||||
* @version $Id$
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACM eAccelerator Based Caching
|
||||
* ACM Memcache Based Caching
|
||||
* @package acm
|
||||
*/
|
||||
class acm
|
||||
{
|
||||
private $vars = array();
|
||||
private $is_modified = false;
|
||||
var $vars = array();
|
||||
var $is_modified = false;
|
||||
|
||||
public $sql_rowset = array();
|
||||
public $cache_dir = '';
|
||||
var $sql_rowset = array();
|
||||
var $sql_row_pointer = array();
|
||||
var $cache_dir = '';
|
||||
|
||||
/**
|
||||
* Set cache path
|
||||
*/
|
||||
function __construct()
|
||||
function acm()
|
||||
{
|
||||
$this->cache_dir = PHPBB_ROOT_PATH . 'cache/';
|
||||
$this->cache_dir = $phpbb_root_path . 'cache/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load global cache
|
||||
*/
|
||||
private function load()
|
||||
function load()
|
||||
{
|
||||
// grab the global cache
|
||||
if ($this->vars = eaccelerator_get('global'))
|
||||
$temp = eaccelerator_get('global');
|
||||
|
||||
if ($temp !== null)
|
||||
{
|
||||
return true;
|
||||
$this->vars = $temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload cache object
|
||||
*/
|
||||
public function unload()
|
||||
function unload()
|
||||
{
|
||||
$this->save();
|
||||
unset($this->vars);
|
||||
unset($this->sql_rowset);
|
||||
|
||||
$this->vars = array();
|
||||
$this->sql_rowset = array();
|
||||
unset($this->sql_row_pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save modified objects
|
||||
*/
|
||||
private function save()
|
||||
function save()
|
||||
{
|
||||
if (!$this->is_modified)
|
||||
{
|
||||
@@ -81,7 +78,7 @@ class acm
|
||||
/**
|
||||
* Tidy cache
|
||||
*/
|
||||
public function tidy()
|
||||
function tidy()
|
||||
{
|
||||
eaccelerator_gc();
|
||||
|
||||
@@ -91,9 +88,9 @@ class acm
|
||||
/**
|
||||
* Get saved cache object
|
||||
*/
|
||||
public function get($var_name)
|
||||
function get($var_name)
|
||||
{
|
||||
if ($var_name[0] === '_')
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
$temp = eaccelerator_get($var_name);
|
||||
|
||||
@@ -119,9 +116,9 @@ class acm
|
||||
/**
|
||||
* Put data into cache
|
||||
*/
|
||||
public function put($var_name, $var, $ttl = 31536000)
|
||||
function put($var_name, $var, $ttl = 31536000)
|
||||
{
|
||||
if ($var_name[0] === '_')
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
eaccelerator_put($var_name, $var, $ttl);
|
||||
}
|
||||
@@ -135,7 +132,7 @@ class acm
|
||||
/**
|
||||
* Purge cache data
|
||||
*/
|
||||
public function purge()
|
||||
function purge()
|
||||
{
|
||||
// Purge all phpbb cache files
|
||||
$dir = @opendir($this->cache_dir);
|
||||
@@ -163,10 +160,7 @@ class acm
|
||||
|
||||
unset($this->vars);
|
||||
unset($this->sql_rowset);
|
||||
|
||||
$this->vars = array();
|
||||
$this->var_expires = array();
|
||||
$this->sql_rowset = array();
|
||||
unset($this->sql_row_pointer);
|
||||
|
||||
$this->is_modified = false;
|
||||
}
|
||||
@@ -174,9 +168,9 @@ class acm
|
||||
/**
|
||||
* Destroy cache data
|
||||
*/
|
||||
public function destroy($var_name, $table = '')
|
||||
function destroy($var_name, $table = '')
|
||||
{
|
||||
if ($var_name === 'sql' && !empty($table))
|
||||
if ($var_name == 'sql' && !empty($table))
|
||||
{
|
||||
if (!is_array($table))
|
||||
{
|
||||
@@ -209,7 +203,7 @@ class acm
|
||||
return;
|
||||
}
|
||||
|
||||
if ($var_name[0] === '_')
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
eaccelerator_rm($var_name);
|
||||
}
|
||||
@@ -226,7 +220,7 @@ class acm
|
||||
/**
|
||||
* Load cached sql query
|
||||
*/
|
||||
public function sql_load($query)
|
||||
function sql_load($query)
|
||||
{
|
||||
// Remove extra spaces and tabs
|
||||
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
||||
@@ -241,31 +235,23 @@ class acm
|
||||
|
||||
$this->sql_rowset[$query_id] = $temp;
|
||||
|
||||
$this->sql_row_pointer[$query_id] = 0;
|
||||
|
||||
return $query_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save sql query
|
||||
*/
|
||||
public function sql_save($query, &$query_result, $ttl)
|
||||
function sql_save($query, &$query_result, $ttl)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Remove extra spaces and tabs
|
||||
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
||||
|
||||
// determine which tables this query belongs to:
|
||||
|
||||
// grab all the FROM tables, avoid getting a LEFT JOIN
|
||||
preg_match('/FROM \(?(\w+(?: (?!LEFT JOIN)\w+)?(?:, ?\w+(?: (?!LEFT JOIN)\w+)?)*)\)?/', $query, $regs);
|
||||
// determine which tables this query belongs to
|
||||
preg_match('/FROM \\(?(\\w+(?: \\w+)?(?:, ?\\w+(?: \\w+)?)*)\\)?/', $query, $regs);
|
||||
$tables = array_map('trim', explode(',', $regs[1]));
|
||||
|
||||
// now get the LEFT JOIN
|
||||
preg_match_all('/LEFT JOIN\s+(\w+)(?: \w+)?/', $query, $result, PREG_PATTERN_ORDER);
|
||||
$tables = array_merge($tables, $result[1]);
|
||||
|
||||
$query_hash = md5($query);
|
||||
|
||||
foreach ($tables as $table_name)
|
||||
{
|
||||
if (($pos = strpos($table_name, ' ')) !== false)
|
||||
@@ -278,13 +264,14 @@ class acm
|
||||
{
|
||||
$temp = array();
|
||||
}
|
||||
$temp[$query_hash] = true;
|
||||
$temp[md5($query)] = true;
|
||||
eaccelerator_put('sql_' . $table_name, $temp, $ttl);
|
||||
}
|
||||
|
||||
// store them in the right place
|
||||
$query_id = sizeof($this->sql_rowset);
|
||||
$this->sql_rowset[$query_id] = array();
|
||||
$this->sql_row_pointer[$query_id] = 0;
|
||||
|
||||
while ($row = $db->sql_fetchrow($query_result))
|
||||
{
|
||||
@@ -292,35 +279,63 @@ class acm
|
||||
}
|
||||
$db->sql_freeresult($query_result);
|
||||
|
||||
eaccelerator_put('sql_' . $query_hash, $this->sql_rowset[$query_id], $ttl);
|
||||
eaccelerator_put('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl);
|
||||
|
||||
$query_result = $query_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ceck if a given sql query exist in cache
|
||||
*/
|
||||
function sql_exists($query_id)
|
||||
{
|
||||
return isset($this->sql_rowset[$query_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch row from cache (database)
|
||||
*/
|
||||
public function sql_fetchrow($query_id)
|
||||
function sql_fetchrow($query_id)
|
||||
{
|
||||
list(, $row) = each($this->sql_rowset[$query_id]);
|
||||
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
|
||||
}
|
||||
|
||||
return ($row !== NULL) ? $row : false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a field from the current row of a cached database result (database)
|
||||
*/
|
||||
public function sql_fetchfield($query_id, $field)
|
||||
function sql_fetchfield($query_id, $field)
|
||||
{
|
||||
$row = current($this->sql_rowset[$query_id]);
|
||||
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field] : false;
|
||||
}
|
||||
|
||||
return ($row !== false && isset($row[$field])) ? $row[$field] : false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek a specific row in an a cached database result (database)
|
||||
*/
|
||||
function sql_rowseek($rownum, $query_id)
|
||||
{
|
||||
if ($rownum >= sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->sql_row_pointer[$query_id] = $rownum;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free memory used for a cached database result (database)
|
||||
*/
|
||||
public function sql_freeresult($query_id)
|
||||
function sql_freeresult($query_id)
|
||||
{
|
||||
if (!isset($this->sql_rowset[$query_id]))
|
||||
{
|
||||
@@ -328,6 +343,7 @@ class acm
|
||||
}
|
||||
|
||||
unset($this->sql_rowset[$query_id]);
|
||||
unset($this->sql_row_pointer[$query_id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @package acm
|
||||
* @version $Id$
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -17,33 +17,38 @@ if (!defined('IN_PHPBB'))
|
||||
}
|
||||
|
||||
/**
|
||||
* ACM Memcache Based Caching
|
||||
* ACM File Based Caching
|
||||
* @package acm
|
||||
*/
|
||||
class acm
|
||||
{
|
||||
private $vars = array();
|
||||
private $is_modified = false;
|
||||
var $vars = array();
|
||||
var $is_modified = false;
|
||||
|
||||
public $sql_rowset = array();
|
||||
public $cache_dir = '';
|
||||
private $memcache;
|
||||
var $sql_rowset = array();
|
||||
var $sql_row_pointer = array();
|
||||
var $cache_dir = '';
|
||||
|
||||
var $memcache;
|
||||
|
||||
/**
|
||||
* Set cache path
|
||||
*/
|
||||
function __construct()
|
||||
function acm()
|
||||
{
|
||||
$this->cache_dir = $phpbb_root_path . 'cache/';
|
||||
$this->memcache = memcache_connect('localhost', 11211);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load global cache
|
||||
*/
|
||||
private function load()
|
||||
function load()
|
||||
{
|
||||
// grab the global cache
|
||||
if ($this->vars = memcache_get($this->memcache, 'global'))
|
||||
$this->vars = memcache_get($this->memcache, 'global');
|
||||
|
||||
if ($this->vars !== false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -54,20 +59,22 @@ class acm
|
||||
/**
|
||||
* Unload cache object
|
||||
*/
|
||||
public function unload()
|
||||
function unload()
|
||||
{
|
||||
$this->save();
|
||||
unset($this->vars);
|
||||
unset($this->sql_rowset);
|
||||
unset($this->sql_row_pointer);
|
||||
|
||||
$this->vars = array();
|
||||
$this->sql_rowset = array();
|
||||
$this->sql_row_pointer = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save modified objects
|
||||
*/
|
||||
private function save()
|
||||
function save()
|
||||
{
|
||||
if (!$this->is_modified)
|
||||
{
|
||||
@@ -82,7 +89,7 @@ class acm
|
||||
/**
|
||||
* Tidy cache
|
||||
*/
|
||||
public function tidy()
|
||||
function tidy()
|
||||
{
|
||||
// cache has auto GC, no need to have any code here :)
|
||||
|
||||
@@ -92,28 +99,29 @@ class acm
|
||||
/**
|
||||
* Get saved cache object
|
||||
*/
|
||||
public function get($var_name)
|
||||
function get($var_name)
|
||||
{
|
||||
if ($var_name[0] === '_')
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
if (!$this->_exists($var_name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return memcache_get($this->memcache, $var_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sizeof($this->vars))
|
||||
{
|
||||
$this->load();
|
||||
}
|
||||
return (isset($this->vars[$var_name])) ? $this->vars[$var_name] : false;
|
||||
return ($this->_exists($var_name)) ? $this->vars[$var_name] : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put data into cache
|
||||
*/
|
||||
public function put($var_name, $var, $ttl = 31536000)
|
||||
function put($var_name, $var, $ttl = 2592000)
|
||||
{
|
||||
if ($var_name[0] === '_')
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
memcache_set($this->memcache, $var_name, $var, 0, $ttl);
|
||||
}
|
||||
@@ -127,7 +135,7 @@ class acm
|
||||
/**
|
||||
* Purge cache data
|
||||
*/
|
||||
public function purge()
|
||||
function purge()
|
||||
{
|
||||
// Purge all phpbb cache files
|
||||
$dir = @opendir($this->cache_dir);
|
||||
@@ -144,7 +152,7 @@ class acm
|
||||
continue;
|
||||
}
|
||||
|
||||
@unlink($this->cache_dir . $entry);
|
||||
$this->remove_file($this->cache_dir . $entry);
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
@@ -152,20 +160,22 @@ class acm
|
||||
|
||||
unset($this->vars);
|
||||
unset($this->sql_rowset);
|
||||
unset($this->sql_row_pointer);
|
||||
|
||||
$this->vars = array();
|
||||
$this->var_expires = array();
|
||||
$this->sql_rowset = array();
|
||||
$this->sql_row_pointer = array();
|
||||
|
||||
$this->is_modified = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destroy cache data
|
||||
*/
|
||||
public function destroy($var_name, $table = '')
|
||||
function destroy($var_name, $table = '')
|
||||
{
|
||||
if ($var_name === 'sql' && !empty($table))
|
||||
if ($var_name == 'sql' && !empty($table))
|
||||
{
|
||||
if (!is_array($table))
|
||||
{
|
||||
@@ -176,6 +186,7 @@ class acm
|
||||
{
|
||||
// gives us the md5s that we want
|
||||
$temp = memcache_get($this->memcache, 'sql_' . $table_name);
|
||||
|
||||
if ($temp === false)
|
||||
{
|
||||
continue;
|
||||
@@ -194,7 +205,12 @@ class acm
|
||||
return;
|
||||
}
|
||||
|
||||
if ($var_name[0] === '_')
|
||||
if (!$this->_exists($var_name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
memcache_delete($this->memcache, $var_name);
|
||||
}
|
||||
@@ -208,10 +224,30 @@ class acm
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given cache entry exist
|
||||
*/
|
||||
function _exists($var_name)
|
||||
{
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sizeof($this->vars))
|
||||
{
|
||||
$this->load();
|
||||
}
|
||||
|
||||
return isset($this->vars[$var_name]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load cached sql query
|
||||
*/
|
||||
public function sql_load($query)
|
||||
function sql_load($query)
|
||||
{
|
||||
// Remove extra spaces and tabs
|
||||
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
||||
@@ -225,7 +261,7 @@ class acm
|
||||
}
|
||||
|
||||
$this->sql_rowset[$query_id] = $temp;
|
||||
|
||||
$this->sql_row_pointer[$query_id] = 0;
|
||||
|
||||
return $query_id;
|
||||
}
|
||||
@@ -233,25 +269,15 @@ class acm
|
||||
/**
|
||||
* Save sql query
|
||||
*/
|
||||
public function sql_save($query, &$query_result, $ttl)
|
||||
function sql_save($query, &$query_result, $ttl)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Remove extra spaces and tabs
|
||||
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
||||
|
||||
// determine which tables this query belongs to:
|
||||
|
||||
// grab all the FROM tables, avoid getting a LEFT JOIN
|
||||
preg_match('/FROM \(?(\w+(?: (?!LEFT JOIN)\w+)?(?:, ?\w+(?: (?!LEFT JOIN)\w+)?)*)\)?/', $query, $regs);
|
||||
// determine which tables this query belongs to
|
||||
preg_match('/FROM \\(?(\\w+(?: \\w+)?(?:, ?\\w+(?: \\w+)?)*)\\)?/', $query, $regs);
|
||||
$tables = array_map('trim', explode(',', $regs[1]));
|
||||
|
||||
// now get the LEFT JOIN
|
||||
preg_match_all('/LEFT JOIN\s+(\w+)(?: \w+)?/', $query, $result, PREG_PATTERN_ORDER);
|
||||
$tables = array_merge($tables, $result[1]);
|
||||
|
||||
$query_hash = md5($query);
|
||||
|
||||
foreach ($tables as $table_name)
|
||||
{
|
||||
if (($pos = strpos($table_name, ' ')) !== false)
|
||||
@@ -264,13 +290,14 @@ class acm
|
||||
{
|
||||
$temp = array();
|
||||
}
|
||||
$temp[$query_hash] = true;
|
||||
$temp[md5($query)] = true;
|
||||
memcache_set($this->memcache, 'sql_' . $table_name, $temp, 0, $ttl);
|
||||
}
|
||||
|
||||
// store them in the right place
|
||||
$query_id = sizeof($this->sql_rowset);
|
||||
$this->sql_rowset[$query_id] = array();
|
||||
$this->sql_row_pointer[$query_id] = 0;
|
||||
|
||||
while ($row = $db->sql_fetchrow($query_result))
|
||||
{
|
||||
@@ -278,35 +305,63 @@ class acm
|
||||
}
|
||||
$db->sql_freeresult($query_result);
|
||||
|
||||
memcache_set($this->memcache, 'sql_' . $query_hash, $this->sql_rowset[$query_id], 0, $ttl);
|
||||
memcache_set($this->memcache, 'sql_' . md5($query), $this->sql_rowset[$query_id], 0, $ttl);
|
||||
|
||||
$query_result = $query_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ceck if a given sql query exist in cache
|
||||
*/
|
||||
function sql_exists($query_id)
|
||||
{
|
||||
return isset($this->sql_rowset[$query_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch row from cache (database)
|
||||
*/
|
||||
public function sql_fetchrow($query_id)
|
||||
function sql_fetchrow($query_id)
|
||||
{
|
||||
list(, $row) = each($this->sql_rowset[$query_id]);
|
||||
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
|
||||
}
|
||||
|
||||
return ($row !== NULL) ? $row : false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a field from the current row of a cached database result (database)
|
||||
*/
|
||||
public function sql_fetchfield($query_id, $field)
|
||||
function sql_fetchfield($query_id, $field)
|
||||
{
|
||||
$row = current($this->sql_rowset[$query_id]);
|
||||
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field] : false;
|
||||
}
|
||||
|
||||
return ($row !== false && isset($row[$field])) ? $row[$field] : false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek a specific row in an a cached database result (database)
|
||||
*/
|
||||
function sql_rowseek($rownum, $query_id)
|
||||
{
|
||||
if ($rownum >= sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->sql_row_pointer[$query_id] = $rownum;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free memory used for a cached database result (database)
|
||||
*/
|
||||
public function sql_freeresult($query_id)
|
||||
function sql_freeresult($query_id)
|
||||
{
|
||||
if (!isset($this->sql_rowset[$query_id]))
|
||||
{
|
||||
@@ -314,9 +369,24 @@ class acm
|
||||
}
|
||||
|
||||
unset($this->sql_rowset[$query_id]);
|
||||
unset($this->sql_row_pointer[$query_id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes/unlinks file
|
||||
*/
|
||||
function remove_file($filename, $check = false)
|
||||
{
|
||||
if ($check && !@is_writable($this->cache_dir))
|
||||
{
|
||||
// E_USER_ERROR - not using language entry - intended.
|
||||
trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR);
|
||||
}
|
||||
|
||||
return @unlink($filename);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,45 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @package acm
|
||||
* @version $Id$
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
* @copyright (c) 2005 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACM XCache Based Caching
|
||||
* @package acm
|
||||
*/
|
||||
class acm
|
||||
{
|
||||
private $vars = array();
|
||||
private $is_modified = false;
|
||||
var $vars = array();
|
||||
var $is_modified = false;
|
||||
|
||||
public $sql_rowset = array();
|
||||
public $cache_dir = '';
|
||||
var $sql_rowset = array();
|
||||
var $sql_row_pointer = array();
|
||||
var $cache_dir = '';
|
||||
|
||||
/**
|
||||
* Set cache path
|
||||
*/
|
||||
function __construct()
|
||||
function acm()
|
||||
{
|
||||
$this->cache_dir = PHPBB_ROOT_PATH . 'cache/';
|
||||
$this->cache_dir = $phpbb_root_path . 'cache/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load global cache
|
||||
*/
|
||||
private function load()
|
||||
function load()
|
||||
{
|
||||
// grab the global cache
|
||||
if (xcache_isset('global'))
|
||||
@@ -54,20 +47,18 @@ class acm
|
||||
/**
|
||||
* Unload cache object
|
||||
*/
|
||||
public function unload()
|
||||
function unload()
|
||||
{
|
||||
$this->save();
|
||||
unset($this->vars);
|
||||
unset($this->sql_rowset);
|
||||
|
||||
$this->vars = array();
|
||||
$this->sql_rowset = array();
|
||||
unset($this->sql_row_pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save modified objects
|
||||
*/
|
||||
private function save()
|
||||
function save()
|
||||
{
|
||||
if (!$this->is_modified)
|
||||
{
|
||||
@@ -82,7 +73,7 @@ class acm
|
||||
/**
|
||||
* Tidy cache
|
||||
*/
|
||||
public function tidy()
|
||||
function tidy()
|
||||
{
|
||||
// cache has auto GC, no need to have any code here :)
|
||||
|
||||
@@ -92,9 +83,9 @@ class acm
|
||||
/**
|
||||
* Get saved cache object
|
||||
*/
|
||||
public function get($var_name)
|
||||
function get($var_name)
|
||||
{
|
||||
if ($var_name[0] === '_')
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
return (xcache_isset($var_name)) ? xcache_get($var_name) : false;
|
||||
}
|
||||
@@ -111,9 +102,9 @@ class acm
|
||||
/**
|
||||
* Put data into cache
|
||||
*/
|
||||
public function put($var_name, $var, $ttl = 31536000)
|
||||
function put($var_name, $var, $ttl = 31536000)
|
||||
{
|
||||
if ($var_name[0] === '_')
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
xcache_set($var_name, $var, $ttl);
|
||||
}
|
||||
@@ -127,7 +118,7 @@ class acm
|
||||
/**
|
||||
* Purge cache data
|
||||
*/
|
||||
public function purge()
|
||||
function purge()
|
||||
{
|
||||
// Purge all phpbb cache files
|
||||
$dir = @opendir($this->cache_dir);
|
||||
@@ -156,10 +147,7 @@ class acm
|
||||
|
||||
unset($this->vars);
|
||||
unset($this->sql_rowset);
|
||||
|
||||
$this->vars = array();
|
||||
$this->var_expires = array();
|
||||
$this->sql_rowset = array();
|
||||
unset($this->sql_row_pointer);
|
||||
|
||||
$this->is_modified = false;
|
||||
}
|
||||
@@ -167,9 +155,9 @@ class acm
|
||||
/**
|
||||
* Destroy cache data
|
||||
*/
|
||||
public function destroy($var_name, $table = '')
|
||||
function destroy($var_name, $table = '')
|
||||
{
|
||||
if ($var_name === 'sql' && !empty($table))
|
||||
if ($var_name == 'sql' && !empty($table))
|
||||
{
|
||||
if (!is_array($table))
|
||||
{
|
||||
@@ -198,7 +186,7 @@ class acm
|
||||
return;
|
||||
}
|
||||
|
||||
if ($var_name[0] === '_')
|
||||
if ($var_name[0] == '_')
|
||||
{
|
||||
xcache_unset($var_name);
|
||||
}
|
||||
@@ -215,21 +203,20 @@ class acm
|
||||
/**
|
||||
* Load cached sql query
|
||||
*/
|
||||
public function sql_load($query)
|
||||
function sql_load($query)
|
||||
{
|
||||
// Remove extra spaces and tabs
|
||||
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
||||
$query_id = sizeof($this->sql_rowset);
|
||||
|
||||
$query_hash = md5($query);
|
||||
|
||||
if (!xcache_isset('sql_' . $query_hash))
|
||||
if (!xcache_isset('sql_' . md5($query)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->sql_rowset[$query_id] = xcache_get('sql_' . $query_hash);
|
||||
$this->sql_rowset[$query_id] = xcache_get('sql_' . md5($query));
|
||||
|
||||
$this->sql_row_pointer[$query_id] = 0;
|
||||
|
||||
return $query_id;
|
||||
}
|
||||
@@ -237,25 +224,15 @@ class acm
|
||||
/**
|
||||
* Save sql query
|
||||
*/
|
||||
public function sql_save($query, &$query_result, $ttl)
|
||||
function sql_save($query, &$query_result, $ttl)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Remove extra spaces and tabs
|
||||
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
|
||||
|
||||
// determine which tables this query belongs to:
|
||||
|
||||
// grab all the FROM tables, avoid getting a LEFT JOIN
|
||||
preg_match('/FROM \(?(\w+(?: (?!LEFT JOIN)\w+)?(?:, ?\w+(?: (?!LEFT JOIN)\w+)?)*)\)?/', $query, $regs);
|
||||
// determine which tables this query belongs to
|
||||
preg_match('/FROM \\(?(\\w+(?: \\w+)?(?:, ?\\w+(?: \\w+)?)*)\\)?/', $query, $regs);
|
||||
$tables = array_map('trim', explode(',', $regs[1]));
|
||||
|
||||
// now get the LEFT JOIN
|
||||
preg_match_all('/LEFT JOIN\s+(\w+)(?: \w+)?/', $query, $result, PREG_PATTERN_ORDER);
|
||||
$tables = array_merge($tables, $result[1]);
|
||||
|
||||
$query_hash = md5($query);
|
||||
|
||||
foreach ($tables as $table_name)
|
||||
{
|
||||
if (($pos = strpos($table_name, ' ')) !== false)
|
||||
@@ -271,13 +248,14 @@ class acm
|
||||
{
|
||||
$temp = array();
|
||||
}
|
||||
$temp[$query_hash] = true;
|
||||
$temp[md5($query)] = true;
|
||||
xcache_set('sql_' . $table_name, $temp, $ttl);
|
||||
}
|
||||
|
||||
// store them in the right place
|
||||
$query_id = sizeof($this->sql_rowset);
|
||||
$this->sql_rowset[$query_id] = array();
|
||||
$this->sql_row_pointer[$query_id] = 0;
|
||||
|
||||
while ($row = $db->sql_fetchrow($query_result))
|
||||
{
|
||||
@@ -285,35 +263,63 @@ class acm
|
||||
}
|
||||
$db->sql_freeresult($query_result);
|
||||
|
||||
xcache_set('sql_' . $query_hash, $this->sql_rowset[$query_id], $ttl);
|
||||
xcache_set('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl);
|
||||
|
||||
$query_result = $query_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ceck if a given sql query exist in cache
|
||||
*/
|
||||
function sql_exists($query_id)
|
||||
{
|
||||
return isset($this->sql_rowset[$query_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch row from cache (database)
|
||||
*/
|
||||
public function sql_fetchrow($query_id)
|
||||
function sql_fetchrow($query_id)
|
||||
{
|
||||
list(, $row) = each($this->sql_rowset[$query_id]);
|
||||
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]++];
|
||||
}
|
||||
|
||||
return ($row !== NULL) ? $row : false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a field from the current row of a cached database result (database)
|
||||
*/
|
||||
public function sql_fetchfield($query_id, $field)
|
||||
function sql_fetchfield($query_id, $field)
|
||||
{
|
||||
$row = current($this->sql_rowset[$query_id]);
|
||||
if ($this->sql_row_pointer[$query_id] < sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return (isset($this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field])) ? $this->sql_rowset[$query_id][$this->sql_row_pointer[$query_id]][$field] : false;
|
||||
}
|
||||
|
||||
return ($row !== false && isset($row[$field])) ? $row[$field] : false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek a specific row in an a cached database result (database)
|
||||
*/
|
||||
function sql_rowseek($rownum, $query_id)
|
||||
{
|
||||
if ($rownum >= sizeof($this->sql_rowset[$query_id]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->sql_row_pointer[$query_id] = $rownum;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free memory used for a cached database result (database)
|
||||
*/
|
||||
public function sql_freeresult($query_id)
|
||||
function sql_freeresult($query_id)
|
||||
{
|
||||
if (!isset($this->sql_rowset[$query_id]))
|
||||
{
|
||||
@@ -321,6 +327,7 @@ class acm
|
||||
}
|
||||
|
||||
unset($this->sql_rowset[$query_id]);
|
||||
unset($this->sql_row_pointer[$query_id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -28,11 +28,9 @@ if (!defined('IN_PHPBB'))
|
||||
*/
|
||||
function init_apache()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!isset($_SERVER['PHP_AUTH_USER']) || $user->data['username'] !== $_SERVER['PHP_AUTH_USER'])
|
||||
if (!isset($_SERVER['PHP_AUTH_USER']) || phpbb::$user->data['username'] !== $_SERVER['PHP_AUTH_USER'])
|
||||
{
|
||||
return $user->lang['APACHE_SETUP_BEFORE_USE'];
|
||||
return phpbb::$user->lang['APACHE_SETUP_BEFORE_USE'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -42,8 +40,6 @@ function init_apache()
|
||||
*/
|
||||
function login_apache(&$username, &$password)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// do not allow empty password
|
||||
if (!$password)
|
||||
{
|
||||
@@ -136,8 +132,6 @@ function login_apache(&$username, &$password)
|
||||
*/
|
||||
function autologin_apache()
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!isset($_SERVER['PHP_AUTH_USER']))
|
||||
{
|
||||
return array();
|
||||
@@ -192,7 +186,6 @@ function autologin_apache()
|
||||
*/
|
||||
function user_row_apache($username, $password)
|
||||
{
|
||||
global $db, $user;
|
||||
// first retrieve default group id
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
@@ -214,7 +207,7 @@ function user_row_apache($username, $password)
|
||||
'user_email' => '',
|
||||
'group_id' => (int) $row['group_id'],
|
||||
'user_type' => phpbb::USER_NORMAL,
|
||||
'user_ip' => $user->ip,
|
||||
'user_ip' => phpbb::$user->ip,
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -27,11 +27,9 @@ if (!defined('IN_PHPBB'))
|
||||
*/
|
||||
function init_ldap()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!@extension_loaded('ldap'))
|
||||
{
|
||||
return $user->lang['LDAP_NO_LDAP_EXTENSION'];
|
||||
return phpbb::$user->lang['LDAP_NO_LDAP_EXTENSION'];
|
||||
}
|
||||
|
||||
phpbb::$config['ldap_port'] = (int) phpbb::$config['ldap_port'];
|
||||
@@ -46,7 +44,7 @@ function init_ldap()
|
||||
|
||||
if (!$ldap)
|
||||
{
|
||||
return $user->lang['LDAP_NO_SERVER_CONNECTION'];
|
||||
return phpbb::$user->lang['LDAP_NO_SERVER_CONNECTION'];
|
||||
}
|
||||
|
||||
@ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
@@ -56,7 +54,7 @@ function init_ldap()
|
||||
{
|
||||
if (!@ldap_bind($ldap, htmlspecialchars_decode(phpbb::$config['ldap_user']), htmlspecialchars_decode(phpbb::$config['ldap_password'])))
|
||||
{
|
||||
return $user->lang['LDAP_INCORRECT_USER_PASSWORD'];
|
||||
return phpbb::$user->lang['LDAP_INCORRECT_USER_PASSWORD'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +62,7 @@ function init_ldap()
|
||||
$search = @ldap_search(
|
||||
$ldap,
|
||||
phpbb::$config['ldap_base_dn'],
|
||||
ldap_user_filter($user->data['username']),
|
||||
ldap_user_filter(phpbb::$user->data['username']),
|
||||
(empty(phpbb::$config['ldap_email'])) ? array(phpbb::$config['ldap_uid']) : array(phpbb::$config['ldap_uid'], phpbb::$config['ldap_email']),
|
||||
0,
|
||||
1
|
||||
@@ -72,7 +70,7 @@ function init_ldap()
|
||||
|
||||
if ($search === false)
|
||||
{
|
||||
return $user->lang['LDAP_NO_SERVER_CONNECTION'];
|
||||
return phpbb::$user->lang['LDAP_NO_SERVER_CONNECTION'];
|
||||
}
|
||||
|
||||
$result = @ldap_get_entries($ldap, $search);
|
||||
@@ -82,12 +80,12 @@ function init_ldap()
|
||||
|
||||
if (!is_array($result) || sizeof($result) < 2)
|
||||
{
|
||||
return sprintf($user->lang['LDAP_NO_IDENTITY'], $user->data['username']);
|
||||
return sprintf(phpbb::$user->lang['LDAP_NO_IDENTITY'], phpbb::$user->data['username']);
|
||||
}
|
||||
|
||||
if (!empty(phpbb::$config['ldap_email']) && !isset($result[0][phpbb::$config['ldap_email']]))
|
||||
{
|
||||
return $user->lang['LDAP_NO_EMAIL'];
|
||||
return phpbb::$user->lang['LDAP_NO_EMAIL'];
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -98,8 +96,6 @@ function init_ldap()
|
||||
*/
|
||||
function login_ldap(&$username, &$password)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
// do not allow empty password
|
||||
if (!$password)
|
||||
{
|
||||
@@ -154,7 +150,7 @@ function login_ldap(&$username, &$password)
|
||||
{
|
||||
if (!@ldap_bind($ldap, phpbb::$config['ldap_user'], htmlspecialchars_decode(phpbb::$config['ldap_password'])))
|
||||
{
|
||||
return $user->lang['LDAP_NO_SERVER_CONNECTION'];
|
||||
return phpbb::$user->lang['LDAP_NO_SERVER_CONNECTION'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +222,7 @@ function login_ldap(&$username, &$password)
|
||||
'user_email' => (!empty(phpbb::$config['ldap_email'])) ? $ldap_result[0][phpbb::$config['ldap_email']][0] : '',
|
||||
'group_id' => (int) $row['group_id'],
|
||||
'user_type' => phpbb::USER_NORMAL,
|
||||
'user_ip' => $user->ip,
|
||||
'user_ip' => phpbb::$user->ip,
|
||||
);
|
||||
|
||||
unset($ldap_result);
|
||||
@@ -293,40 +289,38 @@ function ldap_escape($string)
|
||||
*/
|
||||
function acp_ldap(&$new)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$tpl = '
|
||||
|
||||
<dl>
|
||||
<dt><label for="ldap_server">' . $user->lang['LDAP_SERVER'] . ':</label><br /><span>' . $user->lang['LDAP_SERVER_EXPLAIN'] . '</span></dt>
|
||||
<dt><label for="ldap_server">' . phpbb::$user->lang['LDAP_SERVER'] . ':</label><br /><span>' . phpbb::$user->lang['LDAP_SERVER_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_server" size="40" name="config[ldap_server]" value="' . $new['ldap_server'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_port">' . $user->lang['LDAP_PORT'] . ':</label><br /><span>' . $user->lang['LDAP_PORT_EXPLAIN'] . '</span></dt>
|
||||
<dt><label for="ldap_port">' . phpbb::$user->lang['LDAP_PORT'] . ':</label><br /><span>' . phpbb::$user->lang['LDAP_PORT_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_port" size="40" name="config[ldap_port]" value="' . $new['ldap_port'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_dn">' . $user->lang['LDAP_DN'] . ':</label><br /><span>' . $user->lang['LDAP_DN_EXPLAIN'] . '</span></dt>
|
||||
<dt><label for="ldap_dn">' . phpbb::$user->lang['LDAP_DN'] . ':</label><br /><span>' . phpbb::$user->lang['LDAP_DN_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_dn" size="40" name="config[ldap_base_dn]" value="' . $new['ldap_base_dn'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_uid">' . $user->lang['LDAP_UID'] . ':</label><br /><span>' . $user->lang['LDAP_UID_EXPLAIN'] . '</span></dt>
|
||||
<dt><label for="ldap_uid">' . phpbb::$user->lang['LDAP_UID'] . ':</label><br /><span>' . phpbb::$user->lang['LDAP_UID_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_uid" size="40" name="config[ldap_uid]" value="' . $new['ldap_uid'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_user_filter">' . $user->lang['LDAP_USER_FILTER'] . ':</label><br /><span>' . $user->lang['LDAP_USER_FILTER_EXPLAIN'] . '</span></dt>
|
||||
<dt><label for="ldap_user_filter">' . phpbb::$user->lang['LDAP_USER_FILTER'] . ':</label><br /><span>' . phpbb::$user->lang['LDAP_USER_FILTER_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_user_filter" size="40" name="config[ldap_user_filter]" value="' . $new['ldap_user_filter'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_email">' . $user->lang['LDAP_EMAIL'] . ':</label><br /><span>' . $user->lang['LDAP_EMAIL_EXPLAIN'] . '</span></dt>
|
||||
<dt><label for="ldap_email">' . phpbb::$user->lang['LDAP_EMAIL'] . ':</label><br /><span>' . phpbb::$user->lang['LDAP_EMAIL_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_email" size="40" name="config[ldap_email]" value="' . $new['ldap_email'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_user">' . $user->lang['LDAP_USER'] . ':</label><br /><span>' . $user->lang['LDAP_USER_EXPLAIN'] . '</span></dt>
|
||||
<dt><label for="ldap_user">' . phpbb::$user->lang['LDAP_USER'] . ':</label><br /><span>' . phpbb::$user->lang['LDAP_USER_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="text" id="ldap_user" size="40" name="config[ldap_user]" value="' . $new['ldap_user'] . '" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="ldap_password">' . $user->lang['LDAP_PASSWORD'] . ':</label><br /><span>' . $user->lang['LDAP_PASSWORD_EXPLAIN'] . '</span></dt>
|
||||
<dt><label for="ldap_password">' . phpbb::$user->lang['LDAP_PASSWORD'] . ':</label><br /><span>' . phpbb::$user->lang['LDAP_PASSWORD_EXPLAIN'] . '</span></dt>
|
||||
<dd><input type="password" id="ldap_password" size="40" name="config[ldap_password]" value="' . $new['ldap_password'] . '" /></dd>
|
||||
</dl>
|
||||
';
|
||||
|
@@ -128,12 +128,10 @@ class bbcode
|
||||
*/
|
||||
function bbcode_cache_init()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (empty($this->template_filename))
|
||||
{
|
||||
$this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']);
|
||||
$this->template_filename = PHPBB_ROOT_PATH . 'styles/' . $user->theme['template_path'] . '/template/bbcode.html';
|
||||
$this->template_bitfield = new bitfield(phpbb::$user->theme['bbcode_bitfield']);
|
||||
$this->template_filename = PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['template_path'] . '/template/bbcode.html';
|
||||
|
||||
if (!@file_exists($this->template_filename))
|
||||
{
|
||||
@@ -163,8 +161,6 @@ class bbcode
|
||||
|
||||
if (sizeof($sql))
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . BBCODES_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('bbcode_id', $sql);
|
||||
@@ -225,7 +221,7 @@ class bbcode
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if ($user->optionget('viewimg'))
|
||||
if (phpbb::$user->optionget('viewimg'))
|
||||
{
|
||||
$this->bbcode_cache[$bbcode_id] = array(
|
||||
'preg' => array(
|
||||
@@ -304,7 +300,7 @@ class bbcode
|
||||
break;
|
||||
|
||||
case 11:
|
||||
if ($user->optionget('viewflash'))
|
||||
if (phpbb::$user->optionget('viewflash'))
|
||||
{
|
||||
$this->bbcode_cache[$bbcode_id] = array(
|
||||
'preg' => array(
|
||||
@@ -365,7 +361,7 @@ class bbcode
|
||||
}
|
||||
|
||||
// Replace {L_*} lang strings
|
||||
$bbcode_tpl = preg_replace('/{L_([A-Z_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $bbcode_tpl);
|
||||
$bbcode_tpl = preg_replace('/{L_([A-Z_]+)}/e', "phpbb::\$user->lang('\$1')", $bbcode_tpl);
|
||||
|
||||
if (!empty($rowset[$bbcode_id]['second_pass_replace']))
|
||||
{
|
||||
@@ -398,8 +394,6 @@ class bbcode
|
||||
static $bbcode_hardtpl = array();
|
||||
if (empty($bbcode_hardtpl))
|
||||
{
|
||||
global $user;
|
||||
|
||||
$bbcode_hardtpl = array(
|
||||
'b_open' => '<span style="font-weight: bold">',
|
||||
'b_close' => '</span>',
|
||||
@@ -407,7 +401,7 @@ class bbcode
|
||||
'i_close' => '</span>',
|
||||
'u_open' => '<span style="text-decoration: underline">',
|
||||
'u_close' => '</span>',
|
||||
'img' => '<img src="$1" alt="' . $user->lang['IMAGE'] . '" />',
|
||||
'img' => '<img src="$1" alt="' . phpbb::$user->lang['IMAGE'] . '" />',
|
||||
'size' => '<span style="font-size: $1%; line-height: normal">$2</span>',
|
||||
'color' => '<span style="color: $1">$2</span>',
|
||||
'email' => '<a href="mailto:$1">$2</a>'
|
||||
@@ -457,8 +451,6 @@ class bbcode
|
||||
*/
|
||||
function bbcode_tpl_replace($tpl_name, $tpl)
|
||||
{
|
||||
global $user;
|
||||
|
||||
static $replacements = array(
|
||||
'quote_username_open' => array('{USERNAME}' => '$1'),
|
||||
'color' => array('{COLOR}' => '$1', '{TEXT}' => '$2'),
|
||||
@@ -469,7 +461,7 @@ class bbcode
|
||||
'email' => array('{EMAIL}' => '$1', '{DESCRIPTION}' => '$2')
|
||||
);
|
||||
|
||||
$tpl = preg_replace('/{L_([A-Z_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $tpl);
|
||||
$tpl = preg_replace('/{L_([A-Z_]+)}/e', "phpbb::\$user->lang('\$1')", $tpl);
|
||||
|
||||
if (!empty($replacements[$tpl_name]))
|
||||
{
|
||||
|
@@ -32,8 +32,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
|
||||
function init($type)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
// read input
|
||||
$this->confirm_id = request_var('confirm_id', '');
|
||||
$this->confirm_code = request_var('confirm_code', '');
|
||||
@@ -48,8 +46,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
|
||||
function execute_demo()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$this->code = gen_rand_string(mt_rand(5, 8));
|
||||
$this->seed = hexdec(substr(unique_id(), 4, 10));
|
||||
|
||||
@@ -76,8 +72,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
|
||||
function get_template()
|
||||
{
|
||||
global $user, $template;
|
||||
|
||||
$template->set_filenames(array(
|
||||
'captcha' => 'captcha_default.html')
|
||||
);
|
||||
@@ -92,8 +86,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
|
||||
function get_demo_template($id)
|
||||
{
|
||||
global $user, $template;
|
||||
|
||||
$template->set_filenames(array(
|
||||
'captcha_demo' => 'captcha_default_acp_demo.html')
|
||||
);
|
||||
@@ -121,8 +113,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
|
||||
static function garbage_collect($type)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = 'SELECT DISTINCT c.session_id
|
||||
FROM ' . CONFIRM_TABLE . ' c
|
||||
LEFT JOIN ' . SESSIONS_TABLE . ' s ON (c.session_id = s.session_id)
|
||||
@@ -161,13 +151,11 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
|
||||
function validate()
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$this->confirm_code = request_var('confirm_code', '');
|
||||
|
||||
if (!$this->confirm_id)
|
||||
{
|
||||
$error = $user->lang['CONFIRM_CODE_WRONG'];
|
||||
$error = phpbb::$user->lang['CONFIRM_CODE_WRONG'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -178,7 +166,7 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = $user->lang['CONFIRM_CODE_WRONG'];
|
||||
$error = phpbb::$user->lang['CONFIRM_CODE_WRONG'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,10 +188,8 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
*/
|
||||
protected function generate_code()
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$this->code = gen_rand_string(mt_rand(5, 8));
|
||||
$this->confirm_id = md5(unique_id($user->ip));
|
||||
$this->confirm_id = md5(unique_id(phpbb::$user->ip));
|
||||
$this->seed = hexdec(substr(unique_id(), 4, 10));
|
||||
$this->solved = false;
|
||||
// compute $seed % 0x7fffffff
|
||||
@@ -211,7 +197,7 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
|
||||
$sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array(
|
||||
'confirm_id' => (string) $this->confirm_id,
|
||||
'session_id' => (string) $user->session_id,
|
||||
'session_id' => (string) phpbb::$user->session_id,
|
||||
'confirm_type' => (int) $this->type,
|
||||
'code' => (string) $this->code,
|
||||
'seed' => (int) $this->seed)
|
||||
@@ -224,11 +210,10 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
*/
|
||||
protected function load_code()
|
||||
{
|
||||
global $db, $user;
|
||||
$sql = 'SELECT code, seed
|
||||
FROM ' . CONFIRM_TABLE . "
|
||||
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
|
||||
AND session_id = '" . $db->sql_escape($user->session_id) . "'
|
||||
AND session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'
|
||||
AND confirm_type = " . $this->type;
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
@@ -245,8 +230,6 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
|
||||
protected function check_code()
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (empty($this->code))
|
||||
{
|
||||
if (!$this->load_code())
|
||||
@@ -259,22 +242,18 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
|
||||
protected function delete_code()
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$sql = 'DELETE FROM ' . CONFIRM_TABLE . "
|
||||
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
|
||||
AND session_id = '" . $db->sql_escape($user->session_id) . "'
|
||||
AND session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'
|
||||
AND confirm_type = " . $this->type;
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
function get_attempt_count()
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$sql = 'SELECT COUNT(session_id) AS attempts
|
||||
FROM ' . CONFIRM_TABLE . "
|
||||
WHERE session_id = '" . $db->sql_escape($user->session_id) . "'
|
||||
WHERE session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'
|
||||
AND confirm_type = " . $this->type;
|
||||
$result = $db->sql_query($sql);
|
||||
$attempts = (int) $db->sql_fetchfield('attempts');
|
||||
@@ -286,10 +265,8 @@ abstract class phpbb_default_captcha implements phpbb_captcha_plugin
|
||||
|
||||
function reset()
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$sql = 'DELETE FROM ' . CONFIRM_TABLE . "
|
||||
WHERE session_id = '" . $db->sql_escape($user->session_id) . "'
|
||||
WHERE session_id = '" . $db->sql_escape(phpbb::$user->session_id) . "'
|
||||
AND confirm_type = " . (int) $this->type;
|
||||
$db->sql_query($sql);
|
||||
|
||||
|
@@ -50,8 +50,6 @@ class phpbb_captcha_gd extends phpbb_default_captcha implements phpbb_captcha_pl
|
||||
|
||||
function acp_page($id, &$module)
|
||||
{
|
||||
global $db, $template, $user;
|
||||
|
||||
$captcha_vars = array(
|
||||
'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID',
|
||||
'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID',
|
||||
@@ -77,11 +75,11 @@ class phpbb_captcha_gd extends phpbb_default_captcha implements phpbb_captcha_pl
|
||||
set_config($captcha_var, $value);
|
||||
}
|
||||
}
|
||||
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
|
||||
trigger_error(phpbb::$user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
|
||||
}
|
||||
else if ($submit)
|
||||
{
|
||||
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
|
||||
trigger_error(phpbb::$user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -50,9 +50,7 @@ class phpbb_captcha_gd_wave extends phpbb_default_captcha implements phpbb_captc
|
||||
|
||||
function acp_page($id, &$module)
|
||||
{
|
||||
global $db, $template, $user;
|
||||
|
||||
trigger_error($user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action));
|
||||
trigger_error(phpbb::$user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -37,8 +37,6 @@ class phpbb_captcha_nogd extends phpbb_default_captcha implements phpbb_captcha_
|
||||
|
||||
static function get_name()
|
||||
{
|
||||
global $user;
|
||||
|
||||
return 'CAPTCHA_NO_GD';
|
||||
}
|
||||
|
||||
@@ -50,9 +48,7 @@ class phpbb_captcha_nogd extends phpbb_default_captcha implements phpbb_captcha_
|
||||
|
||||
function acp_page($id, &$module)
|
||||
{
|
||||
global $user;
|
||||
|
||||
trigger_error($user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action));
|
||||
trigger_error(phpbb::$user->lang['CAPTCHA_NO_OPTIONS'] . adm_back_link($module->u_action));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
*
|
||||
* @package VC
|
||||
* @version $Id: constants.php 8818 2008-09-04 14:06:43Z acydburn $
|
||||
* @version $Id$
|
||||
* @copyright (c) 2006 2008 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
@@ -28,9 +28,7 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
|
||||
|
||||
function init($type)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$user->add_lang('recaptcha');
|
||||
phpbb::$user->add_lang('recaptcha');
|
||||
parent::init($type);
|
||||
|
||||
$this->challenge = request_var('recaptcha_challenge_field', '');
|
||||
@@ -44,8 +42,7 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
|
||||
|
||||
static function is_available()
|
||||
{
|
||||
global $user;
|
||||
$user->add_lang('recaptcha');
|
||||
phpbb::$user->add_lang('recaptcha');
|
||||
return (isset(phpbb::$config['recaptcha_pubkey']) && !empty(phpbb::$config['recaptcha_pubkey']));
|
||||
}
|
||||
|
||||
@@ -61,8 +58,6 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
|
||||
|
||||
function acp_page($id, &$module)
|
||||
{
|
||||
global $db, $template, $user;
|
||||
|
||||
$captcha_vars = array(
|
||||
'recaptcha_pubkey' => 'RECAPTCHA_PUBKEY',
|
||||
'recaptcha_privkey' => 'RECAPTCHA_PRIVKEY',
|
||||
@@ -86,11 +81,11 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
|
||||
set_config($captcha_var, $value);
|
||||
}
|
||||
}
|
||||
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
|
||||
trigger_error(phpbb::$user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
|
||||
}
|
||||
else if ($submit)
|
||||
{
|
||||
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
|
||||
trigger_error(phpbb::$user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -122,8 +117,6 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
|
||||
|
||||
function get_template()
|
||||
{
|
||||
global $user, $template;
|
||||
|
||||
$template->set_filenames(array(
|
||||
'captcha' => 'captcha_recaptcha.html')
|
||||
);
|
||||
@@ -260,17 +253,15 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
|
||||
*/
|
||||
protected function recaptcha_check_answer($extra_params = array())
|
||||
{
|
||||
global $user;
|
||||
|
||||
// discard spam submissions
|
||||
if ($this->challenge == null || strlen($this->challenge) == 0 || $this->response == null || strlen($this->response) == 0)
|
||||
{
|
||||
return $user->lang['RECAPTCHA_INCORRECT'];
|
||||
return phpbb::$user->lang['RECAPTCHA_INCORRECT'];
|
||||
}
|
||||
|
||||
$response = $this->_recaptcha_http_post(self::recaptcha_verify_server, '/verify', array(
|
||||
'privatekey' => phpbb::$config['recaptcha_privkey'],
|
||||
'remoteip' => $user->ip,
|
||||
'remoteip' => phpbb::$user->ip,
|
||||
'challenge' => $this->challenge,
|
||||
'response' => $this->response,
|
||||
) + $extra_params
|
||||
@@ -287,7 +278,7 @@ class phpbb_recaptcha extends phpbb_default_captcha implements phpbb_captcha_plu
|
||||
{
|
||||
if ($answers[1] === 'incorrect-captcha-sol')
|
||||
{
|
||||
return $user->lang['RECAPTCHA_INCORRECT'];
|
||||
return phpbb::$user->lang['RECAPTCHA_INCORRECT'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -57,21 +57,6 @@ abstract class phpbb_session
|
||||
*/
|
||||
public $system = NULL;
|
||||
|
||||
/**
|
||||
* @var bool Is true if the user is a logged in registered user
|
||||
*/
|
||||
public $is_registered = false;
|
||||
|
||||
/**
|
||||
* @var bool Is true if the user is logged in and a search engine/bot
|
||||
*/
|
||||
public $is_bot = false;
|
||||
|
||||
/**
|
||||
* @var bool Is true if user is founder
|
||||
*/
|
||||
public $is_founder = false;
|
||||
|
||||
/**
|
||||
* @var array Extra url parameter to append to every URL in phpBB
|
||||
*/
|
||||
@@ -304,6 +289,7 @@ abstract class phpbb_session
|
||||
else
|
||||
{
|
||||
$this->is_registered = true;
|
||||
$this->is_guest = false;
|
||||
$this->is_founder = $this->data['user_type'] == phpbb::USER_FOUNDER;
|
||||
}
|
||||
|
||||
@@ -824,6 +810,7 @@ abstract class phpbb_session
|
||||
{
|
||||
$this->setup('ucp');
|
||||
$this->is_registered = $this->is_bot = $this->is_founder = false;
|
||||
$this->is_guest = true;
|
||||
|
||||
// Set as a precaution to allow login_box() handling this case correctly as well as this function not being executed again.
|
||||
define('IN_CHECK_BAN', 1);
|
||||
@@ -1113,6 +1100,7 @@ abstract class phpbb_session
|
||||
$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->is_founder = $this->data['user_type'] == phpbb::USER_FOUNDER;
|
||||
$this->is_guest = (!$this->is_registered && $this->data['user_id'] == ANONYMOUS) ? true : false;
|
||||
$this->data['user_lang'] = basename($this->data['user_lang']);
|
||||
|
||||
return true;
|
||||
|
@@ -16,6 +16,16 @@ if (!defined('IN_PHPBB'))
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo
|
||||
* IMG_ for image substitution?
|
||||
* {IMG_[key]:[alt]:[type]}
|
||||
* {IMG_ICON_CONTACT:CONTACT:full} -> phpbb::$user->img('icon_contact', 'CONTACT', 'full');
|
||||
*
|
||||
* More in-depth...
|
||||
* yadayada
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base Template class.
|
||||
* @package phpBB3
|
||||
|
@@ -91,6 +91,26 @@ class phpbb_user extends phpbb_session
|
||||
*/
|
||||
public $img_array = array();
|
||||
|
||||
/**
|
||||
* @var bool Is true if the user is a logged in registered user
|
||||
*/
|
||||
public $is_registered = false;
|
||||
|
||||
/**
|
||||
* @var bool Is true if the user is logged in and a search engine/bot
|
||||
*/
|
||||
public $is_bot = false;
|
||||
|
||||
/**
|
||||
* @var bool Is true if user is founder
|
||||
*/
|
||||
public $is_founder = false;
|
||||
|
||||
/**
|
||||
* @var bool Is true if user is anonymous/guest
|
||||
*/
|
||||
public $is_guest = true;
|
||||
|
||||
/**
|
||||
* Ablility to add new option (id 7). Enabled user options is stored in $data['user_options'].
|
||||
* @var array user options defining their possibilities to view flash, images, etc. User options only supports set/unset (true/false)
|
||||
@@ -539,7 +559,7 @@ class phpbb_user extends phpbb_session
|
||||
|
||||
// Does the user need to change their password? If so, redirect to the
|
||||
// ucp profile reg_details page ... of course do not redirect if we're already in the ucp
|
||||
if (!defined('IN_ADMIN') && !defined('ADMIN_START') && phpbb::$config['chg_passforce'] && $this->data['is_registered'] && phpbb::$acl->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - (phpbb::$config['chg_passforce'] * 86400))
|
||||
if (!defined('IN_ADMIN') && !defined('ADMIN_START') && phpbb::$config['chg_passforce'] && $this->is_registered && phpbb::$acl->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - (phpbb::$config['chg_passforce'] * 86400))
|
||||
{
|
||||
if (strpos($this->page['query_string'], 'mode=reg_details') === false && $this->page['page_name'] != 'ucp.' . PHP_EXT)
|
||||
{
|
||||
|
@@ -430,7 +430,7 @@ class phpbb_url extends phpbb_plugin_support
|
||||
|
||||
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)
|
||||
// HTTP HOST can carry a port number (we fetch $user->system['host'], but for old versions this may be true)
|
||||
if (strpos($server_name, ':') === false)
|
||||
{
|
||||
$url .= ':' . $server_port;
|
||||
|
@@ -439,8 +439,6 @@ class diff3 extends diff
|
||||
*/
|
||||
function merged_output($label1 = 'CURRENT_FILE', $label2 = 'NEW_FILE', $label_sep = 'DIFF_SEP_EXPLAIN', $get_conflicts = false, $merge_new = false)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ($get_conflicts)
|
||||
{
|
||||
foreach ($this->_edits as $edit)
|
||||
@@ -454,9 +452,9 @@ class diff3 extends diff
|
||||
return $this->_conflicting_blocks;
|
||||
}
|
||||
|
||||
$label1 = (!empty($user->lang[$label1])) ? $user->lang[$label1] : $label1;
|
||||
$label2 = (!empty($user->lang[$label2])) ? $user->lang[$label2] : $label2;
|
||||
$label_sep = (!empty($user->lang[$label_sep])) ? $user->lang[$label_sep] : $label_sep;
|
||||
$label1 = (!empty(phpbb::$user->lang[$label1])) ? phpbb::$user->lang[$label1] : $label1;
|
||||
$label2 = (!empty(phpbb::$user->lang[$label2])) ? phpbb::$user->lang[$label2] : $label2;
|
||||
$label_sep = (!empty(phpbb::$user->lang[$label_sep])) ? phpbb::$user->lang[$label_sep] : $label_sep;
|
||||
|
||||
$lines = array();
|
||||
|
||||
|
@@ -598,15 +598,13 @@ class diff_renderer_side_by_side extends diff_renderer
|
||||
*/
|
||||
function get_diff_content($diff)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$output = '';
|
||||
$output .= '<table cellspacing="0" class="hrdiff">
|
||||
<caption>
|
||||
<span class="unmodified"> </span> ' . $user->lang['LINE_UNMODIFIED'] . '
|
||||
<span class="added"> </span> ' . $user->lang['LINE_ADDED'] . '
|
||||
<span class="modified"> </span> ' . $user->lang['LINE_MODIFIED'] . '
|
||||
<span class="removed"> </span> ' . $user->lang['LINE_REMOVED'] . '
|
||||
<span class="unmodified"> </span> ' . phpbb::$user->lang['LINE_UNMODIFIED'] . '
|
||||
<span class="added"> </span> ' . phpbb::$user->lang['LINE_ADDED'] . '
|
||||
<span class="modified"> </span> ' . phpbb::$user->lang['LINE_MODIFIED'] . '
|
||||
<span class="removed"> </span> ' . phpbb::$user->lang['LINE_REMOVED'] . '
|
||||
</caption>
|
||||
<tbody>
|
||||
';
|
||||
@@ -616,14 +614,14 @@ class diff_renderer_side_by_side extends diff_renderer
|
||||
// Is the diff empty?
|
||||
if (!sizeof($this->lines))
|
||||
{
|
||||
$output .= '<tr><th colspan="2">' . $user->lang['NO_VISIBLE_CHANGES'] . '</th></tr>';
|
||||
$output .= '<tr><th colspan="2">' . phpbb::$user->lang['NO_VISIBLE_CHANGES'] . '</th></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Iterate through every header block of changes
|
||||
foreach ($this->lines as $header)
|
||||
{
|
||||
$output .= '<tr><th>' . $user->lang['LINE'] . ' ' . $header['oldline'] . '</th><th>' . $user->lang['LINE'] . ' ' . $header['newline'] . '</th></tr>';
|
||||
$output .= '<tr><th>' . phpbb::$user->lang['LINE'] . ' ' . $header['oldline'] . '</th><th>' . phpbb::$user->lang['LINE'] . ' ' . $header['newline'] . '</th></tr>';
|
||||
|
||||
// Each header block consists of a number of changes (add, remove, change).
|
||||
$current_context = '';
|
||||
|
@@ -34,51 +34,51 @@ class formatted_text
|
||||
* @var string
|
||||
*/
|
||||
private $meta;
|
||||
|
||||
|
||||
/**
|
||||
* Formatting options as bit flag.
|
||||
*
|
||||
*
|
||||
* @see bbcode_parser
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $flags;
|
||||
|
||||
|
||||
/**
|
||||
* Compiled $text. For dispaly.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $compiled;
|
||||
|
||||
|
||||
/**
|
||||
* Set to true if text, meta or flags have been changed, false otherwise.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $changed;
|
||||
|
||||
|
||||
/**
|
||||
* DB table to update
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $update_table = '';
|
||||
|
||||
|
||||
/**
|
||||
* Column in $update_table to update.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $update_column = '';
|
||||
|
||||
|
||||
/**
|
||||
* Where clause for auto update.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $update_where = '';
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
@@ -110,12 +110,12 @@ class formatted_text
|
||||
$this->to_db($this->update_table, $this->update_column, $this->update_where);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convieniently initialize a formatted_text object from
|
||||
* a database result set. The array must contain the following indexes:
|
||||
* $column, {$column}_meta and {$column}_flags
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param array $data
|
||||
* @param string $column
|
||||
@@ -125,7 +125,7 @@ class formatted_text
|
||||
{
|
||||
return new formatted_text($data[$column], $data[$column . '_meta'], (int) $data[$column . '_flags']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the $text formatted, ready to be displayed on a webpage.
|
||||
*
|
||||
@@ -148,9 +148,8 @@ class formatted_text
|
||||
*/
|
||||
public function to_db($table, $column, $where = '1')
|
||||
{
|
||||
global $db;
|
||||
$this->changed = false;
|
||||
|
||||
|
||||
$sql = 'UPDATE ' . $table . ' SET ' . $db->sql_build_query('UPDATE', $this->to_db_data($column))
|
||||
. ' WHERE ' . $where;
|
||||
return (bool) $db->sql_query($sql);
|
||||
@@ -182,7 +181,7 @@ class formatted_text
|
||||
$this->update_column = $column;
|
||||
$this->update_where = $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets $meta if not set.
|
||||
*/
|
||||
@@ -196,7 +195,7 @@ class formatted_text
|
||||
$parser = new phpbb_bbcode_parser;
|
||||
$this->meta = $parser->first_pass($this->text);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets $compiled if not set.
|
||||
*/
|
||||
@@ -243,7 +242,7 @@ class formatted_text
|
||||
$this->compiled = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current text.
|
||||
*
|
||||
@@ -253,7 +252,7 @@ class formatted_text
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current(!!) metadata.
|
||||
*
|
||||
@@ -263,7 +262,7 @@ class formatted_text
|
||||
{
|
||||
return $this->meta;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current flags.
|
||||
*
|
||||
@@ -273,7 +272,7 @@ class formatted_text
|
||||
{
|
||||
return $this->flags;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if $this is equal to $other.
|
||||
* Objects are only equal if $text and $flags are equal.
|
||||
|
@@ -16,8 +16,6 @@ if (!defined('IN_PHPBB'))
|
||||
exit;
|
||||
}
|
||||
|
||||
// Common global functions
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -75,6 +73,7 @@ function set_config($config_name, $config_value, $is_dynamic = false)
|
||||
|
||||
/**
|
||||
* Return formatted string for filesizes
|
||||
* @todo move those functions to a helper class?
|
||||
*/
|
||||
function get_formatted_filesize($bytes, $add_size_lang = true)
|
||||
{
|
||||
@@ -96,6 +95,7 @@ function get_formatted_filesize($bytes, $add_size_lang = true)
|
||||
* at the beginning of the script in which it's used.
|
||||
* @return bool Either true if the maximum execution time is nearly reached, or false
|
||||
* if some time is still left.
|
||||
* @todo helper?
|
||||
*/
|
||||
function still_on_time($extra_time = 15)
|
||||
{
|
||||
@@ -126,11 +126,11 @@ function still_on_time($extra_time = 15)
|
||||
return (ceil($current_time - $start_time) < $max_execution_time) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @todo add to security, but do not use the current hash mechanism
|
||||
*/
|
||||
/*
|
||||
@todo should use our hashing instead of a "custom" one
|
||||
@@ -151,6 +151,7 @@ function still_on_time($extra_time = 15)
|
||||
* @param string $token the submitted token
|
||||
* @param string $link_name The name of the link
|
||||
* @return boolean true if all is fine
|
||||
* @todo add to security
|
||||
*/
|
||||
|
||||
function check_link_hash($token, $link_name)
|
||||
@@ -162,6 +163,7 @@ function still_on_time($extra_time = 15)
|
||||
|
||||
/**
|
||||
* Pick a language, any language ...
|
||||
* @todo integrated into form builder?
|
||||
*/
|
||||
function language_select($default = '')
|
||||
{
|
||||
@@ -183,6 +185,7 @@ function language_select($default = '')
|
||||
|
||||
/**
|
||||
* Pick a template/theme combo,
|
||||
* @todo integrated into form builder?
|
||||
*/
|
||||
function style_select($default = '', $all = false)
|
||||
{
|
||||
@@ -206,6 +209,7 @@ function style_select($default = '', $all = false)
|
||||
|
||||
/**
|
||||
* Pick a timezone
|
||||
* @todo integrated into form builder?
|
||||
*/
|
||||
function tz_select($default = '', $truncate = false)
|
||||
{
|
||||
@@ -231,13 +235,12 @@ function tz_select($default = '', $truncate = false)
|
||||
return $tz_select;
|
||||
}
|
||||
|
||||
// Functions handling topic/post tracking/marking
|
||||
|
||||
/**
|
||||
* Marks a topic/forum as read
|
||||
* Marks a topic as posted to
|
||||
*
|
||||
* @param int $user_id can only be used with $mode == 'post'
|
||||
* @todo add to a tracking class used by forum/topic/post API, except for the marking features
|
||||
*/
|
||||
function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0)
|
||||
{
|
||||
@@ -495,6 +498,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
||||
|
||||
/**
|
||||
* Get topic tracking info by using already fetched info
|
||||
* @todo add to a tracking class used by forum/topic/post API
|
||||
*/
|
||||
function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $global_announce_list = false)
|
||||
{
|
||||
@@ -571,6 +575,7 @@ function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time, $
|
||||
|
||||
/**
|
||||
* Get topic tracking info from db (for cookie based tracking only this function is used)
|
||||
* @todo add to a tracking class used by forum/topic/post API
|
||||
*/
|
||||
function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_list = false)
|
||||
{
|
||||
@@ -703,6 +708,7 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis
|
||||
* @param int $mark_time_forum false if the mark time needs to be obtained, else the last users forum mark time
|
||||
*
|
||||
* @return true if complete forum got marked read, else false.
|
||||
* @todo add to a tracking class used by forum/topic/post API
|
||||
*/
|
||||
function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false)
|
||||
{
|
||||
@@ -803,6 +809,7 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti
|
||||
|
||||
/**
|
||||
* Transform an array into a serialized format
|
||||
* @todo add to a tracking class used by forum/topic/post API
|
||||
*/
|
||||
function tracking_serialize($input)
|
||||
{
|
||||
@@ -823,6 +830,7 @@ function tracking_serialize($input)
|
||||
|
||||
/**
|
||||
* Transform a serialized array into an actual array
|
||||
* @todo add to a tracking class used by forum/topic/post API
|
||||
*/
|
||||
function tracking_unserialize($string, $max_depth = 3)
|
||||
{
|
||||
@@ -927,11 +935,10 @@ function tracking_unserialize($string, $max_depth = 3)
|
||||
/**
|
||||
* Pagination routine, generates page number sequence
|
||||
* tpl_prefix is for using different pagination blocks at one page
|
||||
* @todo $pagination = phpbb_api::new('pagination')
|
||||
*/
|
||||
function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = false, $tpl_prefix = '')
|
||||
{
|
||||
global $template;
|
||||
|
||||
// Make sure $per_page is a valid value
|
||||
$per_page = ($per_page <= 0) ? 1 : $per_page;
|
||||
|
||||
@@ -1010,11 +1017,10 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
|
||||
|
||||
/**
|
||||
* Return current page (pagination)
|
||||
* @todo $pagination = phpbb_api::new('pagination')
|
||||
*/
|
||||
function on_page($num_items, $per_page, $start)
|
||||
{
|
||||
global $template;
|
||||
|
||||
// Make sure $per_page is a valid value
|
||||
$per_page = ($per_page <= 0) ? 1 : $per_page;
|
||||
|
||||
@@ -1035,11 +1041,10 @@ function on_page($num_items, $per_page, $start)
|
||||
/**
|
||||
* Add a secret token to the form (requires the S_FORM_TOKEN template variable)
|
||||
* @param string $form_name The name of the form; has to match the name used in check_form_key, otherwise no restrictions apply
|
||||
* @todo add to form builder
|
||||
*/
|
||||
function add_form_key($form_name)
|
||||
{
|
||||
global $template;
|
||||
|
||||
$now = time();
|
||||
$token_sid = (phpbb::$user->data['user_id'] == ANONYMOUS && !empty(phpbb::$config['form_token_sid_guests'])) ? phpbb::$user->session_id : '';
|
||||
$token = sha1($now . phpbb::$user->data['user_form_salt'] . $form_name . $token_sid);
|
||||
@@ -1060,6 +1065,7 @@ function add_form_key($form_name)
|
||||
* @param int $timespan The maximum acceptable age for a submitted form in seconds. Defaults to the config setting.
|
||||
* @param string $return_page The address for the return link
|
||||
* @param bool $trigger If true, the function will triger an error when encountering an invalid form
|
||||
* @todo add to form builder
|
||||
*/
|
||||
function check_form_key($form_name, $timespan = false, $return_page = '', $trigger = false)
|
||||
{
|
||||
@@ -1112,8 +1118,6 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
|
||||
*/
|
||||
function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '')
|
||||
{
|
||||
global $template;
|
||||
|
||||
if (phpbb_request::is_set_post('cancel'))
|
||||
{
|
||||
return false;
|
||||
@@ -1415,8 +1419,6 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
|
||||
*/
|
||||
function login_forum_box($forum_data)
|
||||
{
|
||||
global $template;
|
||||
|
||||
$password = request_var('password', '', true);
|
||||
|
||||
$sql = 'SELECT forum_id
|
||||
@@ -1491,6 +1493,7 @@ function login_forum_box($forum_data)
|
||||
|
||||
/**
|
||||
* Little helper for the build_hidden_fields function
|
||||
* @todo helper class or form builder ;)
|
||||
*/
|
||||
function _build_hidden_fields($key, $value, $specialchar, $stripslashes)
|
||||
{
|
||||
@@ -1525,6 +1528,7 @@ function _build_hidden_fields($key, $value, $specialchar, $stripslashes)
|
||||
* @param bool $stripslashes if true, keys and values get stripslashed
|
||||
*
|
||||
* @return string the hidden fields
|
||||
* @todo helper class or form builder?
|
||||
*/
|
||||
function build_hidden_fields($field_ary, $specialchar = false, $stripslashes = false)
|
||||
{
|
||||
@@ -1591,6 +1595,7 @@ function parse_cfg_file($filename, $lines = false)
|
||||
|
||||
/**
|
||||
* Add log event
|
||||
* @todo phpbb::$log
|
||||
*/
|
||||
function add_log()
|
||||
{
|
||||
@@ -1647,6 +1652,7 @@ function add_log()
|
||||
|
||||
/**
|
||||
* Return a nicely formatted backtrace (parts from the php manual by diz at ysagoon dot com)
|
||||
* @todo helper?
|
||||
*/
|
||||
function get_backtrace()
|
||||
{
|
||||
@@ -1713,6 +1719,7 @@ function get_backtrace()
|
||||
* This function returns a regular expression pattern for commonly used expressions
|
||||
* Use with / as delimiter for email mode and # for url modes
|
||||
* mode can be: email|bbcode_htm|url|url_inline|www_url|www_url_inline|relative_url|relative_url_inline|ipv4|ipv6
|
||||
* @todo helper?
|
||||
*/
|
||||
function get_preg_expression($mode)
|
||||
{
|
||||
@@ -1773,6 +1780,7 @@ function get_preg_expression($mode)
|
||||
* ones as specified in the length paramater.
|
||||
* If length is zero, then an empty string is returned.
|
||||
* If length is greater than 3 the complete IP will be returned
|
||||
* @todo helper?
|
||||
*/
|
||||
function short_ipv6($ip, $length)
|
||||
{
|
||||
@@ -2367,7 +2375,7 @@ function page_header($page_title = '', $display_online_list = true)
|
||||
'T_ICONS_PATH' => PHPBB_ROOT_PATH . phpbb::$config['icons_path'] . '/',
|
||||
'T_RANKS_PATH' => PHPBB_ROOT_PATH . phpbb::$config['ranks_path'] . '/',
|
||||
'T_UPLOAD_PATH' => PHPBB_ROOT_PATH . phpbb::$config['upload_path'] . '/',
|
||||
'T_STYLESHEET_LINK' => (!phpbb::$user->theme['theme_storedb']) ? PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['theme_path'] . '/theme/stylesheet.css' : phpbb::$url->get(PHPBB_ROOT_PATH . 'style.' . PHP_EXT . '?id=' . phpbb::$user->theme['style_id'] . '&lang=' . phpbb::$user->data['user_lang']), //PHPBB_ROOT_PATH . "store/{$user->theme['theme_id']}_{$user->theme['imageset_id']}_{$user->lang_name}.css"
|
||||
'T_STYLESHEET_LINK' => (!phpbb::$user->theme['theme_storedb']) ? PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['theme_path'] . '/theme/stylesheet.css' : phpbb::$url->get(PHPBB_ROOT_PATH . 'style.' . PHP_EXT . '?id=' . phpbb::$user->theme['style_id'] . '&lang=' . phpbb::$user->data['user_lang']), //PHPBB_ROOT_PATH . "store/{phpbb::$user->theme['theme_id']}_{phpbb::$user->theme['imageset_id']}_{phpbb::$user->lang_name}.css"
|
||||
'T_STYLESHEET_NAME' => phpbb::$user->theme['theme_name'],
|
||||
|
||||
'SITE_LOGO_IMG' => phpbb::$user->img('site_logo'),
|
||||
|
@@ -20,8 +20,6 @@ if (!defined('IN_PHPBB'))
|
||||
* Recalculate Binary Tree
|
||||
function recalc_btree($sql_id, $sql_table, $module_class = '')
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!$sql_id || !$sql_table)
|
||||
{
|
||||
return;
|
||||
@@ -112,8 +110,6 @@ function recalc_btree($sql_id, $sql_table, $module_class = '')
|
||||
*/
|
||||
function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false, $return_array = false)
|
||||
{
|
||||
global $db, $user, $auth;
|
||||
|
||||
$acl = ($ignore_acl) ? '' : (($only_acl_post) ? 'f_post' : array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'));
|
||||
|
||||
// This query is identical to the jumpbox one
|
||||
@@ -194,9 +190,7 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
|
||||
*/
|
||||
function size_select_options($size_compare)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$size_types_text = array($user->lang['BYTES'], $user->lang['KIB'], $user->lang['MIB']);
|
||||
$size_types_text = array(phpbb::$user->lang['BYTES'], phpbb::$user->lang['KIB'], phpbb::$user->lang['MIB']);
|
||||
$size_types = array('b', 'kb', 'mb');
|
||||
|
||||
$s_size_options = '';
|
||||
@@ -221,8 +215,6 @@ function size_select_options($size_compare)
|
||||
*/
|
||||
function group_select_options($group_id, $exclude_ids = false, $manage_founder = false)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$exclude_sql = ($exclude_ids !== false && sizeof($exclude_ids)) ? 'WHERE ' . $db->sql_in_set('group_id', array_map('intval', $exclude_ids), true) : '';
|
||||
$sql_and = (!phpbb::$config['coppa_enable']) ? (($exclude_sql) ? ' AND ' : ' WHERE ') . "group_name <> 'REGISTERED_COPPA'" : '';
|
||||
$sql_founder = ($manage_founder !== false) ? (($exclude_sql || $sql_and) ? ' AND ' : ' WHERE ') . 'group_founder_manage = ' . (int) $manage_founder : '';
|
||||
@@ -239,7 +231,7 @@ function group_select_options($group_id, $exclude_ids = false, $manage_founder =
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$selected = ($row['group_id'] == $group_id) ? ' selected="selected"' : '';
|
||||
$s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '"' . $selected . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
|
||||
$s_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '"' . $selected . '>' . (($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
@@ -251,7 +243,6 @@ function group_select_options($group_id, $exclude_ids = false, $manage_founder =
|
||||
*/
|
||||
function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only = false, $no_cache = false)
|
||||
{
|
||||
global $db, $auth;
|
||||
static $forum_rows;
|
||||
|
||||
if (!isset($forum_rows))
|
||||
@@ -314,8 +305,6 @@ function get_forum_list($acl_list = 'f_list', $id_only = true, $postable_only =
|
||||
*/
|
||||
function get_forum_branch($forum_id, $type = 'all', $order = 'descending', $include_forum = true)
|
||||
{
|
||||
global $db;
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'parents':
|
||||
@@ -407,8 +396,6 @@ function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png')
|
||||
*/
|
||||
function move_topics($topic_ids, $forum_id, $auto_sync = true)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (empty($topic_ids))
|
||||
{
|
||||
return;
|
||||
@@ -462,8 +449,6 @@ function move_topics($topic_ids, $forum_id, $auto_sync = true)
|
||||
*/
|
||||
function move_posts($post_ids, $topic_id, $auto_sync = true)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!is_array($post_ids))
|
||||
{
|
||||
$post_ids = array($post_ids);
|
||||
@@ -525,8 +510,6 @@ function move_posts($post_ids, $topic_id, $auto_sync = true)
|
||||
*/
|
||||
function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_sync = true, $call_delete_posts = true)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$approved_topics = 0;
|
||||
$forum_ids = $topic_ids = array();
|
||||
|
||||
@@ -630,8 +613,6 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
|
||||
*/
|
||||
function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = true, $post_count_sync = true, $call_delete_topics = true)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if ($where_type === 'range')
|
||||
{
|
||||
$where_clause = $where_ids;
|
||||
@@ -797,8 +778,6 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
|
||||
*/
|
||||
function delete_attachments($mode, $ids, $resync = true)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (is_array($ids) && sizeof($ids))
|
||||
{
|
||||
$ids = array_unique($ids);
|
||||
@@ -1014,8 +993,6 @@ function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = true)
|
||||
*/
|
||||
function update_posted_info(&$topic_ids)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (empty($topic_ids) || !phpbb::$config['load_db_track'])
|
||||
{
|
||||
return;
|
||||
@@ -1065,8 +1042,6 @@ function update_posted_info(&$topic_ids)
|
||||
*/
|
||||
function phpbb_unlink($filename, $mode = 'file', $entry_removed = false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Because of copying topics or modifications a physical filename could be assigned more than once. If so, do not remove the file itself.
|
||||
$sql = 'SELECT COUNT(attach_id) AS num_entries
|
||||
FROM ' . ATTACHMENTS_TABLE . "
|
||||
@@ -1108,8 +1083,6 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false)
|
||||
*/
|
||||
function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sync_extra = false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (is_array($where_ids))
|
||||
{
|
||||
$where_ids = array_unique($where_ids);
|
||||
@@ -1975,8 +1948,6 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
*/
|
||||
function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync = true)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!is_array($forum_id))
|
||||
{
|
||||
$forum_id = array($forum_id);
|
||||
@@ -2050,8 +2021,6 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync
|
||||
*/
|
||||
function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_freq)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = 'SELECT forum_name
|
||||
FROM ' . FORUMS_TABLE . "
|
||||
WHERE forum_id = $forum_id";
|
||||
@@ -2118,8 +2087,6 @@ function remove_comments(&$output)
|
||||
*/
|
||||
function cache_moderators()
|
||||
{
|
||||
global $db, $auth;
|
||||
|
||||
// Remove cached sql results
|
||||
phpbb::$acm->destroy_sql(MODERATOR_CACHE_TABLE);
|
||||
|
||||
@@ -2516,8 +2483,6 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
|
||||
*/
|
||||
function update_foes($group_id = false, $user_id = false)
|
||||
{
|
||||
global $db, $auth;
|
||||
|
||||
// update foes for some user
|
||||
if (is_array($user_id) && sizeof($user_id))
|
||||
{
|
||||
@@ -2680,8 +2645,6 @@ function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $li
|
||||
*/
|
||||
function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $limit_days = 0, $sort_by = 'user_warnings DESC')
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sql = 'SELECT user_id, username, user_colour, user_warnings, user_last_warning
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_warnings > 0
|
||||
@@ -2835,8 +2798,6 @@ function get_database_size()
|
||||
*/
|
||||
function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 10)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ($fsock = @fsockopen($host, $port, $errno, $errstr, $timeout))
|
||||
{
|
||||
@fputs($fsock, "GET $directory/$filename HTTP/1.1\r\n");
|
||||
@@ -2861,7 +2822,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port
|
||||
}
|
||||
else if (stripos($line, '404 not found') !== false)
|
||||
{
|
||||
$errstr = $user->lang['FILE_NOT_FOUND'] . ': ' . $filename;
|
||||
$errstr = phpbb::$user->lang['FILE_NOT_FOUND'] . ': ' . $filename;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2877,7 +2838,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port
|
||||
}
|
||||
else
|
||||
{
|
||||
$errstr = $user->lang['FSOCK_DISABLED'];
|
||||
$errstr = phpbb::$user->lang['FSOCK_DISABLED'];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2894,8 +2855,6 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port
|
||||
*/
|
||||
function tidy_warnings()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$expire_date = time() - (phpbb::$config['warnings_expire_days'] * 86400);
|
||||
$warning_list = $user_list = array();
|
||||
|
||||
@@ -2936,8 +2895,6 @@ function tidy_warnings()
|
||||
*/
|
||||
function tidy_database()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Here we check permission consistency
|
||||
|
||||
// Sometimes, it can happen permission tables having forums listed which do not exist
|
||||
@@ -2969,17 +2926,15 @@ function tidy_database()
|
||||
*/
|
||||
function add_permission_language()
|
||||
{
|
||||
global $user;
|
||||
|
||||
// First of all, our own file. We need to include it as the first file because it presets all relevant variables.
|
||||
$user->add_lang('acp/permissions_phpbb');
|
||||
phpbb::$user->add_lang('acp/permissions_phpbb');
|
||||
|
||||
$files_to_add = array();
|
||||
|
||||
// Now search in acp and mods folder for permissions_ files.
|
||||
foreach (array('acp/', 'mods/') as $path)
|
||||
{
|
||||
$dh = @opendir($user->lang_path . $user->lang_name . '/' . $path);
|
||||
$dh = @opendir(phpbb::$user->lang_path . phpbb::$user->lang_name . '/' . $path);
|
||||
|
||||
if ($dh)
|
||||
{
|
||||
@@ -2999,7 +2954,7 @@ function add_permission_language()
|
||||
return false;
|
||||
}
|
||||
|
||||
$user->add_lang($files_to_add);
|
||||
phpbb::$user->add_lang($files_to_add);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,7 @@ if (!defined('IN_PHPBB'))
|
||||
|
||||
/**
|
||||
* Generate sort selection fields
|
||||
* @todo phpbb_api::new('sort')
|
||||
*/
|
||||
function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir, &$u_sort_param, $def_st = false, $def_sk = false, $def_sd = false)
|
||||
{
|
||||
|
@@ -489,8 +489,6 @@ function generate_forum_rules(&$forum_data)
|
||||
return;
|
||||
}
|
||||
|
||||
global $template;
|
||||
|
||||
if ($forum_data['forum_rules'])
|
||||
{
|
||||
$forum_data['forum_rules'] = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']);
|
||||
@@ -509,8 +507,6 @@ function generate_forum_rules(&$forum_data)
|
||||
*/
|
||||
function generate_forum_nav(&$forum_data)
|
||||
{
|
||||
global $db, $user, $template, $auth;
|
||||
|
||||
if (!$auth->acl_get('f_list', $forum_data['forum_id']))
|
||||
{
|
||||
return;
|
||||
@@ -566,8 +562,6 @@ function generate_forum_nav(&$forum_data)
|
||||
*/
|
||||
function get_forum_parents(&$forum_data)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$forum_parents = array();
|
||||
|
||||
if ($forum_data['parent_id'] > 0)
|
||||
@@ -608,8 +602,6 @@ function get_forum_parents(&$forum_data)
|
||||
*/
|
||||
function topic_generate_pagination($replies, $url)
|
||||
{
|
||||
global $user;
|
||||
|
||||
// Make sure $per_page is a valid value
|
||||
$per_page = (phpbb::$config['posts_per_page'] <= 0) ? 1 : phpbb::$config['posts_per_page'];
|
||||
|
||||
@@ -632,7 +624,7 @@ function topic_generate_pagination($replies, $url)
|
||||
}
|
||||
else if ($times < $total_pages)
|
||||
{
|
||||
$pagination .= '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
|
||||
$pagination .= '<span class="page-sep">' . phpbb::$user->lang['COMMA_SEPARATOR'] . '</span>';
|
||||
}
|
||||
$times++;
|
||||
}
|
||||
@@ -733,20 +725,18 @@ function get_moderators(&$forum_moderators, $forum_id = false)
|
||||
*/
|
||||
function gen_forum_auth_level($mode, $forum_id, $forum_status)
|
||||
{
|
||||
global $template, $auth, $user;
|
||||
|
||||
$locked = ($forum_status == ITEM_LOCKED && !$auth->acl_get('m_edit', $forum_id)) ? true : false;
|
||||
|
||||
$rules = array(
|
||||
($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'],
|
||||
($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'],
|
||||
($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'],
|
||||
($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'],
|
||||
($auth->acl_get('f_post', $forum_id) && !$locked) ? phpbb::$user->lang['RULES_POST_CAN'] : phpbb::$user->lang['RULES_POST_CANNOT'],
|
||||
($auth->acl_get('f_reply', $forum_id) && !$locked) ? phpbb::$user->lang['RULES_REPLY_CAN'] : phpbb::$user->lang['RULES_REPLY_CANNOT'],
|
||||
(phpbb::$user->is_registered && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? phpbb::$user->lang['RULES_EDIT_CAN'] : phpbb::$user->lang['RULES_EDIT_CANNOT'],
|
||||
(phpbb::$user->is_registered && $auth->acl_gets('f_delete', 'm_delete', $forum_id) && !$locked) ? phpbb::$user->lang['RULES_DELETE_CAN'] : phpbb::$user->lang['RULES_DELETE_CANNOT'],
|
||||
);
|
||||
|
||||
if (phpbb::$config['allow_attachments'])
|
||||
{
|
||||
$rules[] = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && !$locked) ? $user->lang['RULES_ATTACH_CAN'] : $user->lang['RULES_ATTACH_CANNOT'];
|
||||
$rules[] = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && !$locked) ? phpbb::$user->lang['RULES_ATTACH_CAN'] : phpbb::$user->lang['RULES_ATTACH_CANNOT'];
|
||||
}
|
||||
|
||||
foreach ($rules as $rule)
|
||||
@@ -762,13 +752,11 @@ function gen_forum_auth_level($mode, $forum_id, $forum_status)
|
||||
*/
|
||||
function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$folder_alt, &$topic_type)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$folder = $folder_new = '';
|
||||
|
||||
if ($topic_row['topic_status'] == ITEM_MOVED)
|
||||
{
|
||||
$topic_type = $user->lang['VIEW_TOPIC_MOVED'];
|
||||
$topic_type = phpbb::$user->lang['VIEW_TOPIC_MOVED'];
|
||||
$folder_img = 'topic_moved';
|
||||
$folder_alt = 'TOPIC_MOVED';
|
||||
}
|
||||
@@ -777,19 +765,19 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
|
||||
switch ($topic_row['topic_type'])
|
||||
{
|
||||
case POST_GLOBAL:
|
||||
$topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
|
||||
$topic_type = phpbb::$user->lang['VIEW_TOPIC_GLOBAL'];
|
||||
$folder = 'global_read';
|
||||
$folder_new = 'global_unread';
|
||||
break;
|
||||
|
||||
case POST_ANNOUNCE:
|
||||
$topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT'];
|
||||
$topic_type = phpbb::$user->lang['VIEW_TOPIC_ANNOUNCEMENT'];
|
||||
$folder = 'announce_read';
|
||||
$folder_new = 'announce_unread';
|
||||
break;
|
||||
|
||||
case POST_STICKY:
|
||||
$topic_type = $user->lang['VIEW_TOPIC_STICKY'];
|
||||
$topic_type = phpbb::$user->lang['VIEW_TOPIC_STICKY'];
|
||||
$folder = 'sticky_read';
|
||||
$folder_new = 'sticky_unread';
|
||||
break;
|
||||
@@ -810,7 +798,7 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
|
||||
|
||||
if ($topic_row['topic_status'] == ITEM_LOCKED)
|
||||
{
|
||||
$topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
|
||||
$topic_type = phpbb::$user->lang['VIEW_TOPIC_LOCKED'];
|
||||
$folder .= '_locked';
|
||||
$folder_new .= '_locked';
|
||||
}
|
||||
@@ -828,7 +816,7 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
|
||||
|
||||
if ($topic_row['poll_start'] && $topic_row['topic_status'] != ITEM_MOVED)
|
||||
{
|
||||
$topic_type = $user->lang['VIEW_TOPIC_POLL'];
|
||||
$topic_type = phpbb::$user->lang['VIEW_TOPIC_POLL'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -838,8 +826,6 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
|
||||
*/
|
||||
function display_custom_bbcodes()
|
||||
{
|
||||
global $db, $template;
|
||||
|
||||
// Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
|
||||
$num_predefined_bbcodes = 22;
|
||||
|
||||
@@ -870,8 +856,6 @@ function display_custom_bbcodes()
|
||||
*/
|
||||
function display_reasons($reason_id = 0)
|
||||
{
|
||||
global $db, $user, $template;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . REPORTS_REASONS_TABLE . '
|
||||
ORDER BY reason_order ASC';
|
||||
@@ -880,10 +864,10 @@ function display_reasons($reason_id = 0)
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
|
||||
if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
|
||||
if (isset(phpbb::$user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset(phpbb::$user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
|
||||
{
|
||||
$row['reason_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])];
|
||||
$row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])];
|
||||
$row['reason_description'] = phpbb::$user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])];
|
||||
$row['reason_title'] = phpbb::$user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])];
|
||||
}
|
||||
|
||||
$template->assign_block_vars('reason', array(
|
||||
@@ -901,8 +885,6 @@ function display_reasons($reason_id = 0)
|
||||
*/
|
||||
function display_user_activity(&$userdata)
|
||||
{
|
||||
global $auth, $template, $db, $user;
|
||||
|
||||
// Do not display user activity for users having more than 5000 posts...
|
||||
if ($userdata['user_posts'] > 5000)
|
||||
{
|
||||
@@ -990,14 +972,14 @@ function display_user_activity(&$userdata)
|
||||
$active_t_pct = ($userdata['user_posts']) ? ($active_t_count / $userdata['user_posts']) * 100 : 0;
|
||||
}
|
||||
|
||||
$l_active_pct = ($userdata['user_id'] != ANONYMOUS && $userdata['user_id'] == $user->data['user_id']) ? $user->lang['POST_PCT_ACTIVE_OWN'] : $user->lang['POST_PCT_ACTIVE'];
|
||||
$l_active_pct = ($userdata['user_id'] != ANONYMOUS && $userdata['user_id'] == phpbb::$user->data['user_id']) ? phpbb::$user->lang['POST_PCT_ACTIVE_OWN'] : phpbb::$user->lang['POST_PCT_ACTIVE'];
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ACTIVE_FORUM' => $active_f_name,
|
||||
'ACTIVE_FORUM_POSTS' => ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
|
||||
'ACTIVE_FORUM_POSTS' => ($active_f_count == 1) ? sprintf(phpbb::$user->lang['USER_POST'], 1) : sprintf(phpbb::$user->lang['USER_POSTS'], $active_f_count),
|
||||
'ACTIVE_FORUM_PCT' => sprintf($l_active_pct, $active_f_pct),
|
||||
'ACTIVE_TOPIC' => censor_text($active_t_name),
|
||||
'ACTIVE_TOPIC_POSTS' => ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
|
||||
'ACTIVE_TOPIC_POSTS' => ($active_t_count == 1) ? sprintf(phpbb::$user->lang['USER_POST'], 1) : sprintf(phpbb::$user->lang['USER_POSTS'], $active_t_count),
|
||||
'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct),
|
||||
'U_ACTIVE_FORUM' => phpbb::$url->append_sid('viewforum', 'f=' . $active_f_id),
|
||||
'U_ACTIVE_TOPIC' => phpbb::$url->append_sid('viewtopic', 't=' . $active_t_id),
|
||||
@@ -1010,12 +992,12 @@ function display_user_activity(&$userdata)
|
||||
*/
|
||||
function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0)
|
||||
{
|
||||
global $template, $db, $user, $start;
|
||||
global $start;
|
||||
|
||||
$table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE;
|
||||
$where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id';
|
||||
$match_id = ($mode == 'forum') ? $forum_id : $topic_id;
|
||||
$u_url = "uid={$user->data['user_id']}";
|
||||
$u_url = 'uid=' . phpbb::$user->data['user_id'];
|
||||
$u_url .= ($mode == 'forum') ? '&f' : '&f=' . $forum_id . '&t';
|
||||
|
||||
// Is user watching this thread?
|
||||
@@ -1044,7 +1026,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
|
||||
if ($uid != $user_id)
|
||||
{
|
||||
$redirect_url = phpbb::$url->append_sid("view$mode", "$u_url=$match_id&start=$start");
|
||||
$message = $user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
||||
$message = phpbb::$user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
if (phpbb_request::variable('unwatch', '', false, phpbb_request::GET) == $mode)
|
||||
@@ -1061,7 +1043,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
|
||||
|
||||
meta_refresh(3, $redirect_url);
|
||||
|
||||
$message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
||||
$message = phpbb::$user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
||||
trigger_error($message);
|
||||
}
|
||||
else
|
||||
@@ -1092,11 +1074,11 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
|
||||
$sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
|
||||
VALUES ($user_id, $match_id, 0)";
|
||||
$db->sql_query($sql);
|
||||
$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
||||
$message = phpbb::$user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $user->lang['ERR_WATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
||||
$message = phpbb::$user->lang['ERR_WATCHING'] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
||||
}
|
||||
|
||||
meta_refresh(3, $redirect_url);
|
||||
@@ -1125,7 +1107,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
|
||||
if ($can_watch)
|
||||
{
|
||||
$s_watching['link'] = phpbb::$url->append_sid("view$mode", "$u_url=$match_id&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start&hash=" . generate_link_hash("{$mode}_$match_id"));
|
||||
$s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
|
||||
$s_watching['title'] = phpbb::$user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
|
||||
$s_watching['is_watching'] = $is_watching;
|
||||
}
|
||||
|
||||
@@ -1189,8 +1171,6 @@ function get_user_rank($user_id, $user_rank, $user_posts, &$rank_title, &$rank_i
|
||||
*/
|
||||
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR')
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (empty($avatar) || !$avatar_type)
|
||||
{
|
||||
return '';
|
||||
@@ -1210,7 +1190,7 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $
|
||||
}
|
||||
|
||||
$avatar_img .= $avatar;
|
||||
return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
|
||||
return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty(phpbb::$user->lang[$alt])) ? phpbb::$user->lang[$alt] : $alt) . '" />';
|
||||
}
|
||||
|
||||
?>
|
@@ -194,8 +194,6 @@ class messenger
|
||||
*/
|
||||
function send($method = NOTIFY_EMAIL, $break = false)
|
||||
{
|
||||
global $user;
|
||||
|
||||
// We add some standard variables we always use, no need to specify them always
|
||||
$this->vars['U_BOARD'] = (!isset($this->vars['U_BOARD'])) ? generate_board_url() : $this->vars['U_BOARD'];
|
||||
$this->vars['EMAIL_SIG'] = (!isset($this->vars['EMAIL_SIG'])) ? str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode(phpbb::$config['board_email_sig'])) : $this->vars['EMAIL_SIG'];
|
||||
@@ -213,12 +211,12 @@ class messenger
|
||||
$match = array();
|
||||
if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match))
|
||||
{
|
||||
$this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : $user->lang['NO_EMAIL_SUBJECT']);
|
||||
$this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : phpbb::$user->lang['NO_EMAIL_SUBJECT']);
|
||||
$drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->subject = (($this->subject != '') ? $this->subject : $user->lang['NO_EMAIL_SUBJECT']);
|
||||
$this->subject = (($this->subject != '') ? $this->subject : phpbb::$user->lang['NO_EMAIL_SUBJECT']);
|
||||
}
|
||||
|
||||
if ($drop_header)
|
||||
@@ -256,12 +254,10 @@ class messenger
|
||||
*/
|
||||
public static function error($type, $msg)
|
||||
{
|
||||
global $user;
|
||||
|
||||
// Session doesn't exist, create it
|
||||
if (!isset($user->session_id) || $user->session_id === '')
|
||||
if (!isset(phpbb::$user->session_id) || phpbb::$user->session_id === '')
|
||||
{
|
||||
$user->session_begin();
|
||||
phpbb::$user->session_begin();
|
||||
}
|
||||
|
||||
$calling_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
|
||||
@@ -344,8 +340,6 @@ class messenger
|
||||
*/
|
||||
private function msg_email()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (empty(phpbb::$config['email_enable']))
|
||||
{
|
||||
return false;
|
||||
@@ -432,8 +426,6 @@ class messenger
|
||||
*/
|
||||
private function msg_jabber()
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
if (empty(phpbb::$config['jab_enable']) || empty(phpbb::$config['jab_host']) || empty(phpbb::$config['jab_username']) || empty(phpbb::$config['jab_password']))
|
||||
{
|
||||
return false;
|
||||
@@ -469,13 +461,13 @@ class messenger
|
||||
|
||||
if (!$this->jabber->connect())
|
||||
{
|
||||
self::error('JABBER', $user->lang['ERR_JAB_CONNECT'] . '<br />' . $this->jabber->get_log());
|
||||
self::error('JABBER', phpbb::$user->lang['ERR_JAB_CONNECT'] . '<br />' . $this->jabber->get_log());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->jabber->login())
|
||||
{
|
||||
self::error('JABBER', $user->lang['ERR_JAB_AUTH'] . '<br />' . $this->jabber->get_log());
|
||||
self::error('JABBER', phpbb::$user->lang['ERR_JAB_AUTH'] . '<br />' . $this->jabber->get_log());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -543,8 +535,6 @@ class queue
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
set_config('last_queue_run', time(), true);
|
||||
|
||||
// Delete stale lock file
|
||||
@@ -606,13 +596,13 @@ class queue
|
||||
|
||||
if (!$this->jabber->connect())
|
||||
{
|
||||
messenger::error('JABBER', $user->lang['ERR_JAB_CONNECT']);
|
||||
messenger::error('JABBER', phpbb::$user->lang['ERR_JAB_CONNECT']);
|
||||
continue 2;
|
||||
}
|
||||
|
||||
if (!$this->jabber->login())
|
||||
{
|
||||
messenger::error('JABBER', $user->lang['ERR_JAB_AUTH']);
|
||||
messenger::error('JABBER', phpbb::$user->lang['ERR_JAB_AUTH']);
|
||||
continue 2;
|
||||
}
|
||||
|
||||
@@ -747,8 +737,6 @@ class queue
|
||||
*/
|
||||
function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
|
||||
{
|
||||
global $user;
|
||||
|
||||
// Fix any bare linefeeds in the message to make it RFC821 Compliant.
|
||||
$message = preg_replace("#(?<!\r)\n#si", "\r\n", $message);
|
||||
|
||||
@@ -783,13 +771,13 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
|
||||
|
||||
if (trim($subject) == '')
|
||||
{
|
||||
$err_msg = (isset($user->lang['NO_EMAIL_SUBJECT'])) ? $user->lang['NO_EMAIL_SUBJECT'] : 'No email subject specified';
|
||||
$err_msg = (isset(phpbb::$user->lang['NO_EMAIL_SUBJECT'])) ? phpbb::$user->lang['NO_EMAIL_SUBJECT'] : 'No email subject specified';
|
||||
return false;
|
||||
}
|
||||
|
||||
if (trim($message) == '')
|
||||
{
|
||||
$err_msg = (isset($user->lang['NO_EMAIL_MESSAGE'])) ? $user->lang['NO_EMAIL_MESSAGE'] : 'Email message was blank';
|
||||
$err_msg = (isset(phpbb::$user->lang['NO_EMAIL_MESSAGE'])) ? phpbb::$user->lang['NO_EMAIL_MESSAGE'] : 'Email message was blank';
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -841,7 +829,7 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
|
||||
$errstr = utf8_convert_message($errstr);
|
||||
}
|
||||
|
||||
$err_msg = (isset($user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr";
|
||||
$err_msg = (isset(phpbb::$user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf(phpbb::$user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr";
|
||||
$err_msg .= ($error_contents) ? '<br /><br />' . htmlspecialchars($error_contents) : '';
|
||||
return false;
|
||||
}
|
||||
@@ -903,9 +891,9 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
|
||||
// We try to send messages even if a few people do not seem to have valid email addresses, but if no one has, we have to exit here.
|
||||
if (!$rcpt)
|
||||
{
|
||||
$user->session_begin();
|
||||
phpbb::$user->session_begin();
|
||||
$err_msg .= '<br /><br />';
|
||||
$err_msg .= (isset($user->lang['INVALID_EMAIL_LOG'])) ? sprintf($user->lang['INVALID_EMAIL_LOG'], htmlspecialchars($mail_to_address)) : '<strong>' . htmlspecialchars($mail_to_address) . '</strong> possibly an invalid email address?';
|
||||
$err_msg .= (isset(phpbb::$user->lang['INVALID_EMAIL_LOG'])) ? sprintf(phpbb::$user->lang['INVALID_EMAIL_LOG'], htmlspecialchars($mail_to_address)) : '<strong>' . htmlspecialchars($mail_to_address) . '</strong> possibly an invalid email address?';
|
||||
$smtp->close_session($err_msg);
|
||||
return false;
|
||||
}
|
||||
@@ -1006,8 +994,6 @@ class smtp_class
|
||||
*/
|
||||
public function server_parse($response, $line)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$this->server_response = '';
|
||||
$this->responses = array();
|
||||
$this->numeric_response_code = 0;
|
||||
@@ -1016,7 +1002,7 @@ class smtp_class
|
||||
{
|
||||
if (!($this->server_response = fgets($this->socket, 256)))
|
||||
{
|
||||
return (isset($user->lang['NO_EMAIL_RESPONSE_CODE'])) ? $user->lang['NO_EMAIL_RESPONSE_CODE'] : 'Could not get mail server response codes';
|
||||
return (isset(phpbb::$user->lang['NO_EMAIL_RESPONSE_CODE'])) ? phpbb::$user->lang['NO_EMAIL_RESPONSE_CODE'] : 'Could not get mail server response codes';
|
||||
}
|
||||
$this->responses[] = substr(rtrim($this->server_response), 4);
|
||||
$this->numeric_response_code = (int) substr($this->server_response, 0, 3);
|
||||
@@ -1027,7 +1013,7 @@ class smtp_class
|
||||
if (!(substr($this->server_response, 0, 3) == $response))
|
||||
{
|
||||
$this->numeric_response_code = (int) substr($this->server_response, 0, 3);
|
||||
return (isset($user->lang['EMAIL_SMTP_ERROR_RESPONSE'])) ? sprintf($user->lang['EMAIL_SMTP_ERROR_RESPONSE'], $line, $this->server_response) : "Ran into problems sending Mail at <strong>Line $line</strong>. Response: $this->server_response";
|
||||
return (isset(phpbb::$user->lang['EMAIL_SMTP_ERROR_RESPONSE'])) ? sprintf(phpbb::$user->lang['EMAIL_SMTP_ERROR_RESPONSE'], $line, $this->server_response) : "Ran into problems sending Mail at <strong>Line $line</strong>. Response: $this->server_response";
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1052,10 +1038,8 @@ class smtp_class
|
||||
*/
|
||||
public function log_into_server($hostname, $username, $password, $default_auth_method)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$err_msg = '';
|
||||
$local_host = (function_exists('php_uname')) ? php_uname('n') : $user->host;
|
||||
$local_host = (function_exists('php_uname')) ? php_uname('n') : phpbb::$user->system['host'];
|
||||
|
||||
// If we are authenticating through pop-before-smtp, we
|
||||
// have to login ones before we get authenticated
|
||||
@@ -1083,7 +1067,7 @@ class smtp_class
|
||||
$errstr = utf8_convert_message($errstr);
|
||||
}
|
||||
|
||||
$err_msg = (isset($user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr";
|
||||
$err_msg = (isset(phpbb::$user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf(phpbb::$user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr";
|
||||
return $err_msg;
|
||||
}
|
||||
|
||||
@@ -1129,7 +1113,7 @@ class smtp_class
|
||||
|
||||
if (!isset($this->commands['AUTH']))
|
||||
{
|
||||
return (isset($user->lang['SMTP_NO_AUTH_SUPPORT'])) ? $user->lang['SMTP_NO_AUTH_SUPPORT'] : 'SMTP server does not support authentication';
|
||||
return (isset(phpbb::$user->lang['SMTP_NO_AUTH_SUPPORT'])) ? phpbb::$user->lang['SMTP_NO_AUTH_SUPPORT'] : 'SMTP server does not support authentication';
|
||||
}
|
||||
|
||||
// Get best authentication method
|
||||
@@ -1157,7 +1141,7 @@ class smtp_class
|
||||
|
||||
if (!$method)
|
||||
{
|
||||
return (isset($user->lang['NO_SUPPORTED_AUTH_METHODS'])) ? $user->lang['NO_SUPPORTED_AUTH_METHODS'] : 'No supported authentication methods';
|
||||
return (isset(phpbb::$user->lang['NO_SUPPORTED_AUTH_METHODS'])) ? phpbb::$user->lang['NO_SUPPORTED_AUTH_METHODS'] : 'No supported authentication methods';
|
||||
}
|
||||
|
||||
$method = strtolower(str_replace('-', '_', $method));
|
||||
@@ -1169,8 +1153,6 @@ class smtp_class
|
||||
*/
|
||||
private function pop_before_smtp($hostname, $username, $password)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!$this->socket = @fsockopen($hostname, 110, $errno, $errstr, 10))
|
||||
{
|
||||
if ($errstr)
|
||||
@@ -1178,7 +1160,7 @@ class smtp_class
|
||||
$errstr = utf8_convert_message($errstr);
|
||||
}
|
||||
|
||||
return (isset($user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr";
|
||||
return (isset(phpbb::$user->lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf(phpbb::$user->lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not connect to smtp host : $errno : $errstr";
|
||||
}
|
||||
|
||||
$this->server_send("USER $username", true);
|
||||
@@ -1278,8 +1260,6 @@ class smtp_class
|
||||
*/
|
||||
private function digest_md5($username, $password)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$this->server_send('AUTH DIGEST-MD5');
|
||||
if ($err_msg = $this->server_parse('334', __LINE__))
|
||||
{
|
||||
@@ -1328,7 +1308,7 @@ class smtp_class
|
||||
// Realm
|
||||
if (empty($tokens['realm']))
|
||||
{
|
||||
$tokens['realm'] = (function_exists('php_uname')) ? php_uname('n') : $user->host;
|
||||
$tokens['realm'] = (function_exists('php_uname')) ? php_uname('n') : phpbb::$user->system['host'];
|
||||
}
|
||||
|
||||
// Maxbuf
|
||||
@@ -1363,7 +1343,7 @@ class smtp_class
|
||||
}
|
||||
else
|
||||
{
|
||||
return (isset($user->lang['INVALID_DIGEST_CHALLENGE'])) ? $user->lang['INVALID_DIGEST_CHALLENGE'] : 'Invalid digest challenge';
|
||||
return (isset(phpbb::$user->lang['INVALID_DIGEST_CHALLENGE'])) ? phpbb::$user->lang['INVALID_DIGEST_CHALLENGE'] : 'Invalid digest challenge';
|
||||
}
|
||||
|
||||
$base64_method_digest_md5 = base64_encode($input_string);
|
||||
|
@@ -21,8 +21,6 @@ if (!defined('IN_PHPBB'))
|
||||
*/
|
||||
function generate_smilies($mode, $forum_id)
|
||||
{
|
||||
global $auth, $db, $user, $template;
|
||||
|
||||
if ($mode == 'window')
|
||||
{
|
||||
if ($forum_id)
|
||||
@@ -34,14 +32,14 @@ function generate_smilies($mode, $forum_id)
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$user->setup('posting', (int) $row['forum_style']);
|
||||
phpbb::$user->setup('posting', (int) $row['forum_style']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$user->setup('posting');
|
||||
phpbb::$user->setup('posting');
|
||||
}
|
||||
|
||||
page_header($user->lang['SMILIES']);
|
||||
page_header(phpbb::$user->lang['SMILIES']);
|
||||
|
||||
$template->set_filenames(array(
|
||||
'body' => 'posting_smilies.html')
|
||||
@@ -120,8 +118,6 @@ function generate_smilies($mode, $forum_id)
|
||||
*/
|
||||
function update_post_information($type, $ids, $return_update_sql = false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (empty($ids))
|
||||
{
|
||||
return;
|
||||
@@ -245,8 +241,6 @@ function update_post_information($type, $ids, $return_update_sql = false)
|
||||
*/
|
||||
function posting_gen_topic_icons($mode, $icon_id)
|
||||
{
|
||||
global $template;
|
||||
|
||||
// Grab icons
|
||||
$icons = phpbb_cache::obtain_icons();
|
||||
|
||||
@@ -284,7 +278,7 @@ function posting_gen_topic_icons($mode, $icon_id)
|
||||
*/
|
||||
function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
|
||||
{
|
||||
global $auth, $user, $template, $topic_type;
|
||||
global $topic_type;
|
||||
|
||||
$toggle = false;
|
||||
|
||||
@@ -308,7 +302,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
|
||||
$topic_type_array[] = array(
|
||||
'VALUE' => $topic_value['const'],
|
||||
'S_CHECKED' => ($cur_topic_type == $topic_value['const'] || ($forum_id == 0 && $topic_value['const'] == POST_GLOBAL)) ? ' checked="checked"' : '',
|
||||
'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']]
|
||||
'L_TOPIC_TYPE' => phpbb::$user->lang[$topic_value['lang']]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -318,7 +312,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
|
||||
$topic_type_array = array_merge(array(0 => array(
|
||||
'VALUE' => POST_NORMAL,
|
||||
'S_CHECKED' => ($topic_type == POST_NORMAL) ? ' checked="checked"' : '',
|
||||
'L_TOPIC_TYPE' => $user->lang['POST_NORMAL'])),
|
||||
'L_TOPIC_TYPE' => phpbb::$user->lang['POST_NORMAL'])),
|
||||
|
||||
$topic_type_array
|
||||
);
|
||||
@@ -347,8 +341,6 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
|
||||
*/
|
||||
function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false)
|
||||
{
|
||||
global $auth, $user, $db;
|
||||
|
||||
$filedata = array(
|
||||
'error' => array()
|
||||
);
|
||||
@@ -372,7 +364,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
|
||||
|
||||
if (!$filedata['post_attach'])
|
||||
{
|
||||
$filedata['error'][] = $user->lang['NO_UPLOAD_FORM_FOUND'];
|
||||
$filedata['error'][] = phpbb::$user->lang['NO_UPLOAD_FORM_FOUND'];
|
||||
return $filedata;
|
||||
}
|
||||
|
||||
@@ -396,7 +388,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
|
||||
|
||||
// If this error occurs a user tried to exploit an IE Bug by renaming extensions
|
||||
// Since the image category is displaying content inline we need to catch this.
|
||||
trigger_error($user->lang['ATTACHED_IMAGE_NOT_IMAGE']);
|
||||
trigger_error(phpbb::$user->lang['ATTACHED_IMAGE_NOT_IMAGE']);
|
||||
}
|
||||
|
||||
// Do we have to create a thumbnail?
|
||||
@@ -423,7 +415,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
|
||||
$file->upload->set_max_filesize($allowed_filesize);
|
||||
}
|
||||
|
||||
$file->clean_filename('unique', $user->data['user_id'] . '_');
|
||||
$file->clean_filename('unique', phpbb::$user->data['user_id'] . '_');
|
||||
|
||||
// Are we uploading an image *and* this image being within the image category? Only then perform additional image checks.
|
||||
$no_image = ($cat_id == ATTACHMENT_CATEGORY_IMAGE) ? false : true;
|
||||
@@ -451,7 +443,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
|
||||
{
|
||||
if (phpbb::$config['upload_dir_size'] + $file->get('filesize') > phpbb::$config['attachment_quota'])
|
||||
{
|
||||
$filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
|
||||
$filedata['error'][] = phpbb::$user->lang['ATTACH_QUOTA_REACHED'];
|
||||
$filedata['post_attach'] = false;
|
||||
|
||||
$file->remove();
|
||||
@@ -465,7 +457,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
|
||||
{
|
||||
if ($free_space <= $file->get('filesize'))
|
||||
{
|
||||
$filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED'];
|
||||
$filedata['error'][] = phpbb::$user->lang['ATTACH_QUOTA_REACHED'];
|
||||
$filedata['post_attach'] = false;
|
||||
|
||||
$file->remove();
|
||||
@@ -737,8 +729,6 @@ function create_thumbnail($source, $destination, $mimetype)
|
||||
*/
|
||||
function posting_gen_inline_attachments(&$attachment_data)
|
||||
{
|
||||
global $template;
|
||||
|
||||
if (sizeof($attachment_data))
|
||||
{
|
||||
$s_inline_attachment_options = '';
|
||||
@@ -761,8 +751,6 @@ function posting_gen_inline_attachments(&$attachment_data)
|
||||
*/
|
||||
function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true)
|
||||
{
|
||||
global $template, $user, $auth;
|
||||
|
||||
// Some default template variables
|
||||
$template->assign_vars(array(
|
||||
'S_SHOW_ATTACH_BOX' => $show_attach_box,
|
||||
@@ -786,7 +774,7 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a
|
||||
$hidden .= '<input type="hidden" name="attachment_data[' . $count . '][' . $key . ']" value="' . $value . '" />';
|
||||
}
|
||||
|
||||
$download_link = append_sid('download/file', 'mode=view&id=' . (int) $attach_row['attach_id'], true, ($attach_row['is_orphan']) ? $user->session_id : false);
|
||||
$download_link = append_sid('download/file', 'mode=view&id=' . (int) $attach_row['attach_id'], true, ($attach_row['is_orphan']) ? phpbb::$user->session_id : false);
|
||||
|
||||
$template->assign_block_vars('attach_row', array(
|
||||
'FILENAME' => basename($attach_row['real_filename']),
|
||||
@@ -814,8 +802,6 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a
|
||||
*/
|
||||
function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
|
||||
{
|
||||
global $user, $db, $template, $auth;
|
||||
|
||||
$topic_ids = $forum_ids = $draft_rows = array();
|
||||
|
||||
// Load those drafts not connected to forums/topics
|
||||
@@ -834,7 +820,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
|
||||
$sql = 'SELECT d.*, f.forum_id, f.forum_name
|
||||
FROM ' . DRAFTS_TABLE . ' d
|
||||
LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = d.forum_id)
|
||||
WHERE d.user_id = ' . $user->data['user_id'] . "
|
||||
WHERE d.user_id = ' . phpbb::$user->data['user_id'] . "
|
||||
$sql_and
|
||||
ORDER BY d.save_time DESC";
|
||||
$result = $db->sql_query($sql);
|
||||
@@ -909,7 +895,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
|
||||
|
||||
$template->assign_block_vars('draftrow', array(
|
||||
'DRAFT_ID' => $draft['draft_id'],
|
||||
'DATE' => $user->format_date($draft['save_time']),
|
||||
'DATE' => phpbb::$user->format_date($draft['save_time']),
|
||||
'DRAFT_SUBJECT' => $draft['draft_subject'],
|
||||
|
||||
'TITLE' => $title,
|
||||
@@ -928,7 +914,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
|
||||
*/
|
||||
function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true)
|
||||
{
|
||||
global $user, $auth, $db, $template, $bbcode;
|
||||
global $bbcode;
|
||||
|
||||
// Go ahead and pull all data for this topic
|
||||
$sql = 'SELECT p.post_id
|
||||
@@ -1061,13 +1047,13 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
|
||||
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
|
||||
|
||||
'POST_SUBJECT' => $post_subject,
|
||||
'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']),
|
||||
'POST_DATE' => $user->format_date($row['post_time']),
|
||||
'MINI_POST_IMG' => phpbb::$user->img('icon_post_target', 'POST'),
|
||||
'POST_DATE' => phpbb::$user->format_date($row['post_time']),
|
||||
'MESSAGE' => $message,
|
||||
'DECODED_MESSAGE' => $decoded_message,
|
||||
'POST_ID' => $row['post_id'],
|
||||
'U_MINI_POST' => append_sid('viewtopic', 'p=' . $row['post_id']) . '#p' . $row['post_id'],
|
||||
'U_MCP_DETAILS' => ($auth->acl_get('m_info', $forum_id)) ? append_sid('mcp', 'i=main&mode=post_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '',
|
||||
'U_MCP_DETAILS' => ($auth->acl_get('m_info', $forum_id)) ? append_sid('mcp', 'i=main&mode=post_details&f=' . $forum_id . '&p=' . $row['post_id'], true, phpbb::$user->session_id) : '',
|
||||
'POSTER_QUOTE' => ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) ? addslashes(get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '')
|
||||
);
|
||||
|
||||
@@ -1087,7 +1073,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
|
||||
|
||||
if ($mode == 'topic_review')
|
||||
{
|
||||
$template->assign_var('QUOTE_IMG', $user->img('icon_post_quote', $user->lang['REPLY_WITH_QUOTE']));
|
||||
$template->assign_var('QUOTE_IMG', phpbb::$user->img('icon_post_quote', 'REPLY_WITH_QUOTE'));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1098,8 +1084,6 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
|
||||
*/
|
||||
function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id)
|
||||
{
|
||||
global $db, $user, $auth;
|
||||
|
||||
$topic_notification = ($mode == 'reply' || $mode == 'quote') ? true : false;
|
||||
$forum_notification = ($mode == 'post') ? true : false;
|
||||
|
||||
@@ -1123,7 +1107,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
|
||||
AND ban_exclude <> 1';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$sql_ignore_users = ANONYMOUS . ', ' . $user->data['user_id'];
|
||||
$sql_ignore_users = ANONYMOUS . ', ' . phpbb::$user->data['user_id'];
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$sql_ignore_users .= ', ' . (int) $row['ban_userid'];
|
||||
@@ -1325,8 +1309,6 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
|
||||
*/
|
||||
function delete_post($forum_id, $topic_id, $post_id, &$data)
|
||||
{
|
||||
global $db, $user, $auth;
|
||||
|
||||
// Specify our post mode
|
||||
$post_mode = 'delete';
|
||||
if (($data['topic_first_post_id'] === $data['topic_last_post_id']) && $data['topic_replies_real'] == 0)
|
||||
@@ -1546,8 +1528,6 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
|
||||
*/
|
||||
function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true)
|
||||
{
|
||||
global $db, $auth, $user, $template;
|
||||
|
||||
// We do not handle erasing posts here
|
||||
if ($mode == 'delete')
|
||||
{
|
||||
@@ -1578,7 +1558,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
|
||||
// Collect some basic information about which tables and which rows to update/insert
|
||||
$sql_data = $topic_row = array();
|
||||
$poster_id = ($mode == 'edit') ? $data['poster_id'] : (int) $user->data['user_id'];
|
||||
$poster_id = ($mode == 'edit') ? $data['poster_id'] : (int) phpbb::$user->data['user_id'];
|
||||
|
||||
// Retrieve some additional information if not present
|
||||
if ($mode == 'edit' && (!isset($data['post_approved']) || !isset($data['topic_approved']) || $data['post_approved'] === false || $data['topic_approved'] === false))
|
||||
@@ -1599,7 +1579,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
$post_approval = 1;
|
||||
|
||||
// Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected.
|
||||
if (((phpbb::$config['enable_queue_trigger'] && $user->data['user_posts'] < phpbb::$config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id']))
|
||||
if (((phpbb::$config['enable_queue_trigger'] && phpbb::$user->data['user_posts'] < phpbb::$config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id']))
|
||||
{
|
||||
$post_approval = 0;
|
||||
}
|
||||
@@ -1614,16 +1594,16 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
case 'reply':
|
||||
$sql_data[POSTS_TABLE]['sql'] = array(
|
||||
'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
|
||||
'poster_id' => (int) $user->data['user_id'],
|
||||
'poster_id' => (int) phpbb::$user->data['user_id'],
|
||||
'icon_id' => $data['icon_id'],
|
||||
'poster_ip' => $user->ip,
|
||||
'poster_ip' => phpbb::$user->ip,
|
||||
'post_time' => $current_time,
|
||||
'post_approved' => $post_approval,
|
||||
'enable_bbcode' => $data['enable_bbcode'],
|
||||
'enable_smilies' => $data['enable_smilies'],
|
||||
'enable_magic_url' => $data['enable_urls'],
|
||||
'enable_sig' => $data['enable_sig'],
|
||||
'post_username' => (!$user->data['is_registered']) ? $username : '',
|
||||
'post_username' => (!phpbb::$user->is_registered) ? $username : '',
|
||||
'post_subject' => $subject,
|
||||
'post_text' => $data['message'],
|
||||
'post_checksum' => $data['message_md5'],
|
||||
@@ -1669,10 +1649,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
|
||||
// If the person editing this post is different to the one having posted then we will add a log entry stating the edit
|
||||
// Could be simplified by only adding to the log if the edit is not tracked - but this may confuse admins/mods
|
||||
if ($user->data['user_id'] != $poster_id)
|
||||
if (phpbb::$user->data['user_id'] != $poster_id)
|
||||
{
|
||||
$log_subject = ($subject) ? $subject : $data['topic_title'];
|
||||
add_log('mod', $data['forum_id'], $data['topic_id'], 'LOG_POST_EDITED', $log_subject, (!empty($username)) ? $username : $user->lang['GUEST']);
|
||||
add_log('mod', $data['forum_id'], $data['topic_id'], 'LOG_POST_EDITED', $log_subject, (!empty($username)) ? $username : phpbb::$user->lang['GUEST']);
|
||||
}
|
||||
|
||||
if (!isset($sql_data[POSTS_TABLE]['sql']))
|
||||
@@ -1714,14 +1694,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
{
|
||||
case 'post':
|
||||
$sql_data[TOPICS_TABLE]['sql'] = array(
|
||||
'topic_poster' => (int) $user->data['user_id'],
|
||||
'topic_poster' => (int) phpbb::$user->data['user_id'],
|
||||
'topic_time' => $current_time,
|
||||
'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'],
|
||||
'icon_id' => $data['icon_id'],
|
||||
'topic_approved' => $post_approval,
|
||||
'topic_title' => $subject,
|
||||
'topic_first_poster_name' => (!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : ''),
|
||||
'topic_first_poster_colour' => $user->data['user_colour'],
|
||||
'topic_first_poster_name' => (!phpbb::$user->is_registered && $username) ? $username : ((!phpbb::$user->is_guest) ? phpbb::$user->data['username'] : ''),
|
||||
'topic_first_poster_colour' => phpbb::$user->data['user_colour'],
|
||||
'topic_type' => $topic_type,
|
||||
'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0,
|
||||
'topic_attachment' => (!empty($data['attachment_data'])) ? 1 : 0,
|
||||
@@ -1868,9 +1848,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
'topic_first_post_id' => $data['post_id'],
|
||||
'topic_last_post_id' => $data['post_id'],
|
||||
'topic_last_post_time' => $current_time,
|
||||
'topic_last_poster_id' => (int) $user->data['user_id'],
|
||||
'topic_last_poster_name' => (!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : ''),
|
||||
'topic_last_poster_colour' => $user->data['user_colour'],
|
||||
'topic_last_poster_id' => (int) phpbb::$user->data['user_id'],
|
||||
'topic_last_poster_name' => (!phpbb::$user->is_registered && $username) ? $username : ((!phpbb::$user->is_guest) ? phpbb::$user->data['username'] : ''),
|
||||
'topic_last_poster_colour' => phpbb::$user->data['user_colour'],
|
||||
'topic_last_post_subject' => (string) $subject,
|
||||
);
|
||||
}
|
||||
@@ -2033,7 +2013,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . '
|
||||
AND is_orphan = 1
|
||||
AND poster_id = ' . $user->data['user_id'];
|
||||
AND poster_id = ' . phpbb::$user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$orphan_rows = array();
|
||||
@@ -2082,7 +2062,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . '
|
||||
WHERE attach_id = ' . $attach_row['attach_id'] . '
|
||||
AND is_orphan = 1
|
||||
AND poster_id = ' . $user->data['user_id'];
|
||||
AND poster_id = ' . phpbb::$user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
@@ -2110,9 +2090,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data['post_id'];
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'";
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . $current_time;
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $user->data['user_id'];
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape((!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : '')) . "'";
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape($user->data['user_colour']) . "'";
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) phpbb::$user->data['user_id'];
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape((!phpbb::$user->is_registered && $username) ? $username : ((!phpbb::$user->is_guest) ? phpbb::$user->data['username'] : '')) . "'";
|
||||
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_colour = '" . $db->sql_escape(phpbb::$user->data['user_colour']) . "'";
|
||||
}
|
||||
else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || ($post_mode == 'edit_first_post' && !$data['topic_replies']))
|
||||
{
|
||||
@@ -2268,9 +2248,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
if ($post_mode == 'reply')
|
||||
{
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_id = ' . (int) $data['post_id'];
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_id = ' . (int) $user->data['user_id'];
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape((!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : '')) . "'";
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_colour = '" . (($user->data['user_id'] != ANONYMOUS) ? $db->sql_escape($user->data['user_colour']) : '') . "'";
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_poster_id = ' . (int) phpbb::$user->data['user_id'];
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape((!phpbb::$user->is_registered && $username) ? $username : ((!phpbb::$user->is_guest) ? phpbb::$user->data['username'] : '')) . "'";
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_colour = '" . ((!phpbb::$user->is_guest) ? $db->sql_escape(phpbb::$user->data['user_colour']) : '') . "'";
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'";
|
||||
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_last_post_time = ' . (int) $current_time;
|
||||
}
|
||||
@@ -2362,7 +2342,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
{
|
||||
$sql = 'DELETE FROM ' . DRAFTS_TABLE . "
|
||||
WHERE draft_id = $draft_id
|
||||
AND user_id = {$user->data['user_id']}";
|
||||
AND user_id = " . phpbb::$user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
@@ -2394,18 +2374,18 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
}
|
||||
|
||||
// Topic Notification, do not change if moderator is changing other users posts...
|
||||
if ($user->data['user_id'] == $poster_id)
|
||||
if (phpbb::$user->data['user_id'] == $poster_id)
|
||||
{
|
||||
if (!$data['notify_set'] && $data['notify'])
|
||||
{
|
||||
$sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id)
|
||||
VALUES (' . $user->data['user_id'] . ', ' . $data['topic_id'] . ')';
|
||||
VALUES (' . phpbb::$user->data['user_id'] . ', ' . $data['topic_id'] . ')';
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
else if ($data['notify_set'] && !$data['notify'])
|
||||
{
|
||||
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . '
|
||||
WHERE user_id = ' . $user->data['user_id'] . '
|
||||
WHERE user_id = ' . phpbb::$user->data['user_id'] . '
|
||||
AND topic_id = ' . $data['topic_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
@@ -2422,22 +2402,22 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||
markread('topic', $data['forum_id'], $data['topic_id'], time());
|
||||
|
||||
//
|
||||
if (phpbb::$config['load_db_lastread'] && $user->data['is_registered'])
|
||||
if (phpbb::$config['load_db_lastread'] && phpbb::$user->is_registered)
|
||||
{
|
||||
$sql = 'SELECT mark_time
|
||||
FROM ' . FORUMS_TRACK_TABLE . '
|
||||
WHERE user_id = ' . $user->data['user_id'] . '
|
||||
WHERE user_id = ' . phpbb::$user->data['user_id'] . '
|
||||
AND forum_id = ' . $data['forum_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
$f_mark_time = (int) $db->sql_fetchfield('mark_time');
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
else if (phpbb::$config['load_anon_lastread'] || $user->data['is_registered'])
|
||||
else if (phpbb::$config['load_anon_lastread'] || phpbb::$user->is_registered)
|
||||
{
|
||||
$f_mark_time = false;
|
||||
}
|
||||
|
||||
if ((phpbb::$config['load_db_lastread'] && $user->data['is_registered']) || phpbb::$config['load_anon_lastread'] || $user->data['is_registered'])
|
||||
if ((phpbb::$config['load_db_lastread'] && phpbb::$user->is_registered) || phpbb::$config['load_anon_lastread'] || phpbb::$user->is_registered)
|
||||
{
|
||||
// Update forum info
|
||||
$sql = 'SELECT forum_last_post_time
|
||||
|
@@ -115,8 +115,6 @@ $global_rule_conditions = array(
|
||||
*/
|
||||
function get_folder($user_id, $folder_id = false)
|
||||
{
|
||||
global $db, $user, $template;
|
||||
|
||||
$folder = array();
|
||||
|
||||
// Get folder information
|
||||
@@ -155,7 +153,7 @@ function get_folder($user_id, $folder_id = false)
|
||||
$num_unread[PRIVMSGS_OUTBOX] = $num_messages[PRIVMSGS_OUTBOX];
|
||||
|
||||
$folder[PRIVMSGS_INBOX] = array(
|
||||
'folder_name' => $user->lang['PM_INBOX'],
|
||||
'folder_name' => phpbb::$user->lang['PM_INBOX'],
|
||||
'num_messages' => $num_messages[PRIVMSGS_INBOX],
|
||||
'unread_messages' => $num_unread[PRIVMSGS_INBOX]
|
||||
);
|
||||
@@ -177,13 +175,13 @@ function get_folder($user_id, $folder_id = false)
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$folder[PRIVMSGS_OUTBOX] = array(
|
||||
'folder_name' => $user->lang['PM_OUTBOX'],
|
||||
'folder_name' => phpbb::$user->lang['PM_OUTBOX'],
|
||||
'num_messages' => $num_messages[PRIVMSGS_OUTBOX],
|
||||
'unread_messages' => $num_unread[PRIVMSGS_OUTBOX]
|
||||
);
|
||||
|
||||
$folder[PRIVMSGS_SENTBOX] = array(
|
||||
'folder_name' => $user->lang['PM_SENTBOX'],
|
||||
'folder_name' => phpbb::$user->lang['PM_SENTBOX'],
|
||||
'num_messages' => $num_messages[PRIVMSGS_SENTBOX],
|
||||
'unread_messages' => $num_unread[PRIVMSGS_SENTBOX]
|
||||
);
|
||||
@@ -221,19 +219,17 @@ function get_folder($user_id, $folder_id = false)
|
||||
*/
|
||||
function clean_sentbox($num_sentbox_messages)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
// Check Message Limit
|
||||
if ($user->data['message_limit'] && $num_sentbox_messages > $user->data['message_limit'])
|
||||
if (phpbb::$user->data['message_limit'] && $num_sentbox_messages > phpbb::$user->data['message_limit'])
|
||||
{
|
||||
// Delete old messages
|
||||
$sql = 'SELECT t.msg_id
|
||||
FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p
|
||||
WHERE t.msg_id = p.msg_id
|
||||
AND t.user_id = ' . $user->data['user_id'] . '
|
||||
AND t.user_id = ' . phpbb::$user->data['user_id'] . '
|
||||
AND t.folder_id = ' . PRIVMSGS_SENTBOX . '
|
||||
ORDER BY p.message_time ASC';
|
||||
$result = $db->sql_query_limit($sql, ($num_sentbox_messages - $user->data['message_limit']));
|
||||
$result = $db->sql_query_limit($sql, ($num_sentbox_messages - phpbb::$user->data['message_limit']));
|
||||
|
||||
$delete_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
@@ -241,7 +237,7 @@ function clean_sentbox($num_sentbox_messages)
|
||||
$delete_ids[] = $row['msg_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
delete_pm($user->data['user_id'], $delete_ids, PRIVMSGS_SENTBOX);
|
||||
delete_pm(phpbb::$user->data['user_id'], $delete_ids, PRIVMSGS_SENTBOX);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,8 +246,6 @@ function clean_sentbox($num_sentbox_messages)
|
||||
*/
|
||||
function check_rule(&$rules, &$rule_row, &$message_row, $user_id)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!isset($rules[$rule_row['rule_check']][$rule_row['rule_connection']]))
|
||||
{
|
||||
return false;
|
||||
@@ -287,8 +281,6 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id)
|
||||
break;
|
||||
|
||||
case ACTION_DELETE_MESSAGE:
|
||||
global $db, $auth;
|
||||
|
||||
// Check for admins/mods - users are not allowed to remove those messages...
|
||||
// We do the check here to make sure the data we use is consistent
|
||||
$sql = 'SELECT user_id, user_type, user_permissions
|
||||
@@ -321,16 +313,14 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id)
|
||||
*/
|
||||
function update_pm_counts()
|
||||
{
|
||||
global $user, $db;
|
||||
|
||||
// Update unread count
|
||||
$sql = 'SELECT COUNT(msg_id) as num_messages
|
||||
FROM ' . PRIVMSGS_TO_TABLE . '
|
||||
WHERE pm_unread = 1
|
||||
AND folder_id <> ' . PRIVMSGS_OUTBOX . '
|
||||
AND user_id = ' . $user->data['user_id'];
|
||||
AND user_id = ' . phpbb::$user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
$user->data['user_unread_privmsg'] = (int) $db->sql_fetchfield('num_messages');
|
||||
phpbb::$user->data['user_unread_privmsg'] = (int) $db->sql_fetchfield('num_messages');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Update new pm count
|
||||
@@ -338,24 +328,24 @@ function update_pm_counts()
|
||||
FROM ' . PRIVMSGS_TO_TABLE . '
|
||||
WHERE pm_new = 1
|
||||
AND folder_id IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
|
||||
AND user_id = ' . $user->data['user_id'];
|
||||
AND user_id = ' . phpbb::$user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
$user->data['user_new_privmsg'] = (int) $db->sql_fetchfield('num_messages');
|
||||
phpbb::$user->data['user_new_privmsg'] = (int) $db->sql_fetchfield('num_messages');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$db->sql_query('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
|
||||
'user_unread_privmsg' => (int) $user->data['user_unread_privmsg'],
|
||||
'user_new_privmsg' => (int) $user->data['user_new_privmsg'],
|
||||
)) . ' WHERE user_id = ' . $user->data['user_id']);
|
||||
'user_unread_privmsg' => (int) phpbb::$user->data['user_unread_privmsg'],
|
||||
'user_new_privmsg' => (int) phpbb::$user->data['user_new_privmsg'],
|
||||
)) . ' WHERE user_id = ' . phpbb::$user->data['user_id']);
|
||||
|
||||
// Ok, here we need to repair something, other boxes than privmsgs_no_box and privmsgs_hold_box should not carry the pm_new flag.
|
||||
if (!$user->data['user_new_privmsg'])
|
||||
if (!phpbb::$user->data['user_new_privmsg'])
|
||||
{
|
||||
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
|
||||
SET pm_new = 0
|
||||
WHERE pm_new = 1
|
||||
AND folder_id NOT IN (' . PRIVMSGS_NO_BOX . ', ' . PRIVMSGS_HOLD_BOX . ')
|
||||
AND user_id = ' . $user->data['user_id'];
|
||||
AND user_id = ' . phpbb::$user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
@@ -365,15 +355,13 @@ function update_pm_counts()
|
||||
*/
|
||||
function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
if (!$user->data['user_new_privmsg'])
|
||||
if (!phpbb::$user->data['user_new_privmsg'])
|
||||
{
|
||||
return array('not_moved' => 0, 'removed' => 0);
|
||||
}
|
||||
|
||||
$user_message_rules = (int) $user->data['user_message_rules'];
|
||||
$user_id = (int) $user->data['user_id'];
|
||||
$user_message_rules = (int) phpbb::$user->data['user_message_rules'];
|
||||
$user_id = (int) phpbb::$user->data['user_id'];
|
||||
|
||||
$action_ary = $move_into_folder = array();
|
||||
$num_removed = 0;
|
||||
@@ -444,7 +432,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
|
||||
'bcc' => explode(':', $row['bcc_address']),
|
||||
'friend' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['friend'] : 0,
|
||||
'foe' => (isset($zebra[$row['author_id']])) ? $zebra[$row['author_id']]['foe'] : 0,
|
||||
'user_in_group' => array($user->data['group_id']),
|
||||
'user_in_group' => array(phpbb::$user->data['group_id']),
|
||||
'author_in_group' => array())
|
||||
);
|
||||
|
||||
@@ -588,7 +576,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
|
||||
if (sizeof($move_into_folder))
|
||||
{
|
||||
// Determine Full Folder Action - we need the move to folder id later eventually
|
||||
$full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? (phpbb::$config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder'];
|
||||
$full_folder_action = (phpbb::$user->data['user_full_folder'] == FULL_FOLDER_NONE) ? (phpbb::$config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : phpbb::$user->data['user_full_folder'];
|
||||
|
||||
$sql_folder = array_keys($move_into_folder);
|
||||
if ($full_folder_action >= 0)
|
||||
@@ -630,12 +618,12 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
|
||||
|
||||
// Check Message Limit - we calculate with the complete array, most of the time it is one message
|
||||
// But we are making sure that the other way around works too (more messages in queue than allowed to be stored)
|
||||
if ($user->data['message_limit'] && $folder[$folder_id] && ($folder[$folder_id] + sizeof($msg_ary)) > $user->data['message_limit'])
|
||||
if (phpbb::$user->data['message_limit'] && $folder[$folder_id] && ($folder[$folder_id] + sizeof($msg_ary)) > phpbb::$user->data['message_limit'])
|
||||
{
|
||||
$full_folder_action = ($user->data['user_full_folder'] == FULL_FOLDER_NONE) ? (phpbb::$config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : $user->data['user_full_folder'];
|
||||
$full_folder_action = (phpbb::$user->data['user_full_folder'] == FULL_FOLDER_NONE) ? (phpbb::$config['full_folder_action'] - (FULL_FOLDER_NONE*(-1))) : phpbb::$user->data['user_full_folder'];
|
||||
|
||||
// If destination folder itself is full...
|
||||
if ($full_folder_action >= 0 && ($folder[$full_folder_action] + sizeof($msg_ary)) > $user->data['message_limit'])
|
||||
if ($full_folder_action >= 0 && ($folder[$full_folder_action] + sizeof($msg_ary)) > phpbb::$user->data['message_limit'])
|
||||
{
|
||||
$full_folder_action = phpbb::$config['full_folder_action'] - (FULL_FOLDER_NONE*(-1));
|
||||
}
|
||||
@@ -653,7 +641,7 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
|
||||
WHERE user_id = $user_id
|
||||
AND folder_id = $dest_folder
|
||||
ORDER BY msg_id ASC";
|
||||
$result = $db->sql_query_limit($sql, (($folder[$dest_folder] + sizeof($msg_ary)) - $user->data['message_limit']));
|
||||
$result = $db->sql_query_limit($sql, (($folder[$dest_folder] + sizeof($msg_ary)) - phpbb::$user->data['message_limit']));
|
||||
|
||||
$delete_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
@@ -729,8 +717,6 @@ function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
|
||||
*/
|
||||
function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_folder_id)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$num_moved = 0;
|
||||
|
||||
if (!is_array($move_msg_ids))
|
||||
@@ -759,8 +745,8 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
|
||||
|
||||
if ($message_limit && $row['pm_count'] + sizeof($move_msg_ids) > $message_limit)
|
||||
{
|
||||
$message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $row['folder_name']) . '<br /><br />';
|
||||
$message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid('ucp', 'i=pm&folder=' . $row['folder_id']) . '">', '</a>', $row['folder_name']);
|
||||
$message = sprintf(phpbb::$user->lang['NOT_ENOUGH_SPACE_FOLDER'], $row['folder_name']) . '<br /><br />';
|
||||
$message .= sprintf(phpbb::$user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid('ucp', 'i=pm&folder=' . $row['folder_id']) . '">', '</a>', $row['folder_name']);
|
||||
trigger_error($message);
|
||||
}
|
||||
}
|
||||
@@ -776,8 +762,8 @@ function move_pm($user_id, $message_limit, $move_msg_ids, $dest_folder, $cur_fol
|
||||
|
||||
if ($message_limit && $num_messages + sizeof($move_msg_ids) > $message_limit)
|
||||
{
|
||||
$message = sprintf($user->lang['NOT_ENOUGH_SPACE_FOLDER'], $user->lang['PM_INBOX']) . '<br /><br />';
|
||||
$message .= sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid('ucp', 'i=pm&folder=inbox') . '">', '</a>', $user->lang['PM_INBOX']);
|
||||
$message = sprintf(phpbb::$user->lang['NOT_ENOUGH_SPACE_FOLDER'], phpbb::$user->lang['PM_INBOX']) . '<br /><br />';
|
||||
$message .= sprintf(phpbb::$user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid('ucp', 'i=pm&folder=inbox') . '">', '</a>', phpbb::$user->lang['PM_INBOX']);
|
||||
trigger_error($message);
|
||||
}
|
||||
}
|
||||
@@ -830,8 +816,6 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)
|
||||
return;
|
||||
}
|
||||
|
||||
global $db, $user;
|
||||
|
||||
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . "
|
||||
SET pm_unread = 0
|
||||
WHERE msg_id = $msg_id
|
||||
@@ -844,19 +828,19 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)
|
||||
WHERE user_id = $user_id";
|
||||
$db->sql_query($sql);
|
||||
|
||||
if ($user->data['user_id'] == $user_id)
|
||||
if (phpbb::$user->data['user_id'] == $user_id)
|
||||
{
|
||||
$user->data['user_unread_privmsg']--;
|
||||
phpbb::$user->data['user_unread_privmsg']--;
|
||||
|
||||
// Try to cope with previous wrong conversions...
|
||||
if ($user->data['user_unread_privmsg'] < 0)
|
||||
if (phpbb::$user->data['user_unread_privmsg'] < 0)
|
||||
{
|
||||
$sql = 'UPDATE ' . USERS_TABLE . "
|
||||
SET user_unread_privmsg = 0
|
||||
WHERE user_id = $user_id";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$user->data['user_unread_privmsg'] = 0;
|
||||
phpbb::$user->data['user_unread_privmsg'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -866,8 +850,6 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)
|
||||
*/
|
||||
function handle_mark_actions($user_id, $mark_action)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$msg_ids = request_var('marked_msg_id', array(0));
|
||||
$cur_folder_id = request_var('cur_folder_id', PRIVMSGS_NO_BOX);
|
||||
$confirm = phpbb_request::is_set_post('confirm');
|
||||
@@ -900,7 +882,7 @@ function handle_mark_actions($user_id, $mark_action)
|
||||
$redirect = append_sid('ucp', 'i=pm&folder=' . $cur_folder_id);
|
||||
|
||||
meta_refresh(3, $redirect);
|
||||
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $redirect . '">', '</a>'));
|
||||
trigger_error(phpbb::$user->lang[$success_msg] . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_FOLDER'], '<a href="' . $redirect . '">', '</a>'));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -928,8 +910,6 @@ function handle_mark_actions($user_id, $mark_action)
|
||||
*/
|
||||
function delete_pm($user_id, $msg_ids, $folder_id)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$user_id = (int) $user_id;
|
||||
$folder_id = (int) $folder_id;
|
||||
|
||||
@@ -1036,8 +1016,8 @@ function delete_pm($user_id, $msg_ids, $folder_id)
|
||||
|
||||
$db->sql_query('UPDATE ' . USERS_TABLE . " SET $set_sql WHERE user_id = $user_id");
|
||||
|
||||
$user->data['user_new_privmsg'] -= $num_new;
|
||||
$user->data['user_unread_privmsg'] -= $num_unread;
|
||||
phpbb::$user->data['user_new_privmsg'] -= $num_new;
|
||||
phpbb::$user->data['user_unread_privmsg'] -= $num_unread;
|
||||
}
|
||||
|
||||
// Now we have to check which messages we can delete completely
|
||||
@@ -1079,8 +1059,6 @@ function delete_pm($user_id, $msg_ids, $folder_id)
|
||||
*/
|
||||
function rebuild_header($check_ary)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$address = array();
|
||||
|
||||
foreach ($check_ary as $check_type => $address_field)
|
||||
@@ -1115,8 +1093,6 @@ function rebuild_header($check_ary)
|
||||
*/
|
||||
function write_pm_addresses($check_ary, $author_id, $plaintext = false)
|
||||
{
|
||||
global $db, $user, $template;
|
||||
|
||||
$addresses = array();
|
||||
|
||||
foreach ($check_ary as $check_type => $address_field)
|
||||
@@ -1149,7 +1125,7 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
|
||||
if ($check_type == 'to' || $author_id == phpbb::$user->data['user_id'] || $row['user_id'] == phpbb::$user->data['user_id'])
|
||||
{
|
||||
if ($plaintext)
|
||||
{
|
||||
@@ -1175,9 +1151,9 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
|
||||
if ($check_type == 'to' || $author_id == phpbb::$user->data['user_id'] || $row['user_id'] == phpbb::$user->data['user_id'])
|
||||
{
|
||||
$address[] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
|
||||
$address[] = ($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name'];
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
@@ -1195,9 +1171,9 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
|
||||
{
|
||||
if (!isset($address['group'][$row['group_id']]))
|
||||
{
|
||||
if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
|
||||
if ($check_type == 'to' || $author_id == phpbb::$user->data['user_id'] || $row['user_id'] == phpbb::$user->data['user_id'])
|
||||
{
|
||||
$row['group_name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
|
||||
$row['group_name'] = ($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name'];
|
||||
$address['group'][$row['group_id']] = array('name' => $row['group_name'], 'colour' => $row['group_colour']);
|
||||
}
|
||||
}
|
||||
@@ -1258,8 +1234,6 @@ function write_pm_addresses($check_ary, $author_id, $plaintext = false)
|
||||
*/
|
||||
function get_folder_status($folder_id, $folder)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
if (isset($folder[$folder_id]))
|
||||
{
|
||||
$folder = $folder[$folder_id];
|
||||
@@ -1272,12 +1246,12 @@ function get_folder_status($folder_id, $folder)
|
||||
$return = array(
|
||||
'folder_name' => $folder['folder_name'],
|
||||
'cur' => $folder['num_messages'],
|
||||
'remaining' => ($user->data['message_limit']) ? $user->data['message_limit'] - $folder['num_messages'] : 0,
|
||||
'max' => $user->data['message_limit'],
|
||||
'percent' => ($user->data['message_limit']) ? (($user->data['message_limit'] > 0) ? round(($folder['num_messages'] / $user->data['message_limit']) * 100) : 100) : 0,
|
||||
'remaining' => (phpbb::$user->data['message_limit']) ? phpbb::$user->data['message_limit'] - $folder['num_messages'] : 0,
|
||||
'max' => phpbb::$user->data['message_limit'],
|
||||
'percent' => (phpbb::$user->data['message_limit']) ? ((phpbb::$user->data['message_limit'] > 0) ? round(($folder['num_messages'] / phpbb::$user->data['message_limit']) * 100) : 100) : 0,
|
||||
);
|
||||
|
||||
$return['message'] = sprintf($user->lang['FOLDER_STATUS_MSG'], $return['percent'], $return['cur'], $return['max']);
|
||||
$return['message'] = sprintf(phpbb::$user->lang['FOLDER_STATUS_MSG'], $return['percent'], $return['cur'], $return['max']);
|
||||
|
||||
return $return;
|
||||
}
|
||||
@@ -1291,8 +1265,6 @@ function get_folder_status($folder_id, $folder)
|
||||
*/
|
||||
function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||
{
|
||||
global $db, $auth, $template, $user;
|
||||
|
||||
// We do not handle erasing pms here
|
||||
if ($mode == 'delete')
|
||||
{
|
||||
@@ -1513,7 +1485,7 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||
WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan_rows)) . '
|
||||
AND in_message = 1
|
||||
AND is_orphan = 1
|
||||
AND poster_id = ' . $user->data['user_id'];
|
||||
AND poster_id = ' . phpbb::$user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$orphan_rows = array();
|
||||
@@ -1562,7 +1534,7 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||
$sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $attach_sql) . '
|
||||
WHERE attach_id = ' . $attach_row['attach_id'] . '
|
||||
AND is_orphan = 1
|
||||
AND poster_id = ' . $user->data['user_id'];
|
||||
AND poster_id = ' . phpbb::$user->data['user_id'];
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
@@ -1600,11 +1572,9 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||
*/
|
||||
function pm_notification($mode, $author, $recipients, $subject, $message)
|
||||
{
|
||||
global $db, $user, $auth;
|
||||
|
||||
$subject = censor_text($subject);
|
||||
|
||||
unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]);
|
||||
unset($recipients[ANONYMOUS], $recipients[phpbb::$user->data['user_id']]);
|
||||
|
||||
if (!sizeof($recipients))
|
||||
{
|
||||
@@ -1687,7 +1657,7 @@ function pm_notification($mode, $author, $recipients, $subject, $message)
|
||||
*/
|
||||
function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode = false)
|
||||
{
|
||||
global $db, $user, $template, $auth, $bbcode;
|
||||
global $bbcode;
|
||||
|
||||
// Get History Messages (could be newer)
|
||||
$sql = 'SELECT t.*, p.*, u.*
|
||||
@@ -1724,11 +1694,11 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
|
||||
{
|
||||
$folder_id = (int) $row['folder_id'];
|
||||
|
||||
$row['folder'][] = (isset($folder[$folder_id])) ? '<a href="' . $folder_url . $folder_id . '">' . $folder[$folder_id]['folder_name'] . '</a>' : $user->lang['UNKNOWN_FOLDER'];
|
||||
$row['folder'][] = (isset($folder[$folder_id])) ? '<a href="' . $folder_url . $folder_id . '">' . $folder[$folder_id]['folder_name'] . '</a>' : phpbb::$user->lang['UNKNOWN_FOLDER'];
|
||||
|
||||
if (isset($rowset[$row['msg_id']]))
|
||||
{
|
||||
$rowset[$row['msg_id']]['folder'][] = (isset($folder[$folder_id])) ? '<a href="' . $folder_url . $folder_id . '">' . $folder[$folder_id]['folder_name'] . '</a>' : $user->lang['UNKNOWN_FOLDER'];
|
||||
$rowset[$row['msg_id']]['folder'][] = (isset($folder[$folder_id])) ? '<a href="' . $folder_url . $folder_id . '">' . $folder[$folder_id]['folder_name'] . '</a>' : phpbb::$user->lang['UNKNOWN_FOLDER'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1773,7 +1743,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
|
||||
|
||||
$decoded_message = false;
|
||||
|
||||
if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id'])
|
||||
if ($in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != phpbb::$user->data['user_id'])
|
||||
{
|
||||
$decoded_message = $message;
|
||||
decode_message($decoded_message, $row['bbcode_uid']);
|
||||
@@ -1806,7 +1776,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
|
||||
'U_MESSAGE_AUTHOR' => get_username_string('profile', $author_id, $row['username'], $row['user_colour'], $row['username']),
|
||||
|
||||
'SUBJECT' => $subject,
|
||||
'SENT_DATE' => $user->format_date($row['message_time']),
|
||||
'SENT_DATE' => phpbb::$user->format_date($row['message_time']),
|
||||
'MESSAGE' => $message,
|
||||
'FOLDER' => implode(', ', $row['folder']),
|
||||
'DECODED_MESSAGE' => $decoded_message,
|
||||
@@ -1817,15 +1787,15 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
|
||||
|
||||
'MSG_ID' => $row['msg_id'],
|
||||
'U_VIEW_MESSAGE' => "$url&f=$folder_id&p=" . $row['msg_id'],
|
||||
'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != $user->data['user_id']) ? "$url&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '',
|
||||
'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $row['msg_id'] : '')
|
||||
'U_QUOTE' => (!$in_post_mode && $auth->acl_get('u_sendpm') && $author_id != ANONYMOUS && $author_id != phpbb::$user->data['user_id']) ? "$url&mode=compose&action=quote&f=" . $folder_id . "&p=" . $row['msg_id'] : '',
|
||||
'U_POST_REPLY_PM' => ($author_id != phpbb::$user->data['user_id'] && $author_id != ANONYMOUS && $auth->acl_get('u_sendpm')) ? "$url&mode=compose&action=reply&f=$folder_id&p=" . $row['msg_id'] : '')
|
||||
);
|
||||
unset($rowset[$id]);
|
||||
$prev_id = $id;
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'QUOTE_IMG' => $user->img('icon_post_quote', $user->lang['REPLY_WITH_QUOTE']),
|
||||
'QUOTE_IMG' => phpbb::$user->img('icon_post_quote', 'REPLY_WITH_QUOTE'),
|
||||
'HISTORY_TITLE' => $title,
|
||||
|
||||
'U_VIEW_NEXT_HISTORY' => ($next_history_pm) ? "$url&p=" . $next_history_pm : '',
|
||||
@@ -1841,19 +1811,17 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
|
||||
*/
|
||||
function set_user_message_limit()
|
||||
{
|
||||
global $user, $db;
|
||||
|
||||
// Get maximum about from user memberships - if it is 0, there is no limit set and we use the maximum value within the config.
|
||||
$sql = 'SELECT MAX(g.group_message_limit) as max_message_limit
|
||||
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
|
||||
WHERE ug.user_id = ' . $user->data['user_id'] . '
|
||||
WHERE ug.user_id = ' . phpbb::$user->data['user_id'] . '
|
||||
AND ug.user_pending = 0
|
||||
AND ug.group_id = g.group_id';
|
||||
$result = $db->sql_query($sql);
|
||||
$message_limit = (int) $db->sql_fetchfield('max_message_limit');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$user->data['message_limit'] = (!$message_limit) ? phpbb::$config['pm_max_msgs'] : $message_limit;
|
||||
phpbb::$user->data['message_limit'] = (!$message_limit) ? phpbb::$config['pm_max_msgs'] : $message_limit;
|
||||
}
|
||||
|
||||
?>
|
@@ -33,8 +33,6 @@ class custom_profile
|
||||
*/
|
||||
public function generate_profile_fields($mode, $lang_id)
|
||||
{
|
||||
global $db, $template, $auth;
|
||||
|
||||
$sql_where = '';
|
||||
switch ($mode)
|
||||
{
|
||||
@@ -202,14 +200,12 @@ class custom_profile
|
||||
*/
|
||||
private function build_cache()
|
||||
{
|
||||
global $db, $user, $auth;
|
||||
|
||||
$this->profile_cache = array();
|
||||
|
||||
// Display hidden/no_view fields for admin/moderator
|
||||
$sql = 'SELECT l.*, f.*
|
||||
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
|
||||
WHERE l.lang_id = ' . $user->get_iso_lang_id() . '
|
||||
WHERE l.lang_id = ' . phpbb::$user->get_iso_lang_id() . '
|
||||
AND f.field_active = 1 ' .
|
||||
((!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) ? ' AND f.field_hide = 0 ' : '') . '
|
||||
AND f.field_no_view = 0
|
||||
@@ -229,8 +225,6 @@ class custom_profile
|
||||
*/
|
||||
private function get_option_lang($field_id, $lang_id, $field_type, $preview)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if ($preview)
|
||||
{
|
||||
$lang_options = (!is_array($this->vars['lang_options'])) ? explode("\n", $this->vars['lang_options']) : $this->vars['lang_options'];
|
||||
@@ -266,8 +260,6 @@ class custom_profile
|
||||
*/
|
||||
public function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
|
||||
{
|
||||
global $auth, $db, $user;
|
||||
|
||||
$sql_where = '';
|
||||
switch ($mode)
|
||||
{
|
||||
@@ -311,32 +303,32 @@ class custom_profile
|
||||
{
|
||||
case 'FIELD_INVALID_DATE':
|
||||
case 'FIELD_REQUIRED':
|
||||
$error = sprintf($user->lang[$cp_result], $row['lang_name']);
|
||||
$error = sprintf(phpbb::$user->lang[$cp_result], $row['lang_name']);
|
||||
break;
|
||||
|
||||
case 'FIELD_TOO_SHORT':
|
||||
case 'FIELD_TOO_SMALL':
|
||||
$error = sprintf($user->lang[$cp_result], $row['lang_name'], $row['field_minlen']);
|
||||
$error = sprintf(phpbb::$user->lang[$cp_result], $row['lang_name'], $row['field_minlen']);
|
||||
break;
|
||||
|
||||
case 'FIELD_TOO_LONG':
|
||||
case 'FIELD_TOO_LARGE':
|
||||
$error = sprintf($user->lang[$cp_result], $row['lang_name'], $row['field_maxlen']);
|
||||
$error = sprintf(phpbb::$user->lang[$cp_result], $row['lang_name'], $row['field_maxlen']);
|
||||
break;
|
||||
|
||||
case 'FIELD_INVALID_CHARS':
|
||||
switch ($row['field_validation'])
|
||||
{
|
||||
case '[0-9]+':
|
||||
$error = sprintf($user->lang[$cp_result . '_NUMBERS_ONLY'], $row['lang_name']);
|
||||
$error = sprintf(phpbb::$user->lang[$cp_result . '_NUMBERS_ONLY'], $row['lang_name']);
|
||||
break;
|
||||
|
||||
case '[\w]+':
|
||||
$error = sprintf($user->lang[$cp_result . '_ALPHA_ONLY'], $row['lang_name']);
|
||||
$error = sprintf(phpbb::$user->lang[$cp_result . '_ALPHA_ONLY'], $row['lang_name']);
|
||||
break;
|
||||
|
||||
case '[\w_\+\. \-\[\]]+':
|
||||
$error = sprintf($user->lang[$cp_result . '_SPACERS_ONLY'], $row['lang_name']);
|
||||
$error = sprintf(phpbb::$user->lang[$cp_result . '_SPACERS_ONLY'], $row['lang_name']);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -358,8 +350,6 @@ class custom_profile
|
||||
*/
|
||||
public function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if ($mode == 'grab')
|
||||
{
|
||||
if (!is_array($user_id))
|
||||
@@ -489,9 +479,8 @@ class custom_profile
|
||||
}
|
||||
else if ($day && $month && $year)
|
||||
{
|
||||
global $user;
|
||||
// d/m/y 00:00 GMT isn't necessarily on the same d/m/y in the user's timezone, so add the timezone seconds
|
||||
return $user->format_date(gmmktime(0, 0, 0, $month, $day, $year) + $user->timezone + $user->dst, $user->lang['DATE_FORMAT'], true);
|
||||
return phpbb::$user->format_date(gmmktime(0, 0, 0, $month, $day, $year) + phpbb::$user->timezone + phpbb::$user->dst, phpbb::$user->lang['DATE_FORMAT'], true);
|
||||
}
|
||||
|
||||
return $value;
|
||||
@@ -555,14 +544,12 @@ class custom_profile
|
||||
*/
|
||||
private function get_var($field_validation, &$profile_row, $default_value, $preview)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
|
||||
$user_ident = $profile_row['field_ident'];
|
||||
// checkbox - only testing for isset
|
||||
if ($profile_row['field_type'] == FIELD_BOOL && $profile_row['field_length'] == 2)
|
||||
{
|
||||
$value = (phpbb_request::is_set($profile_row['field_ident'])) ? true : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]);
|
||||
$value = (phpbb_request::is_set($profile_row['field_ident'])) ? true : ((!isset(phpbb::$user->profile_fields[$user_ident]) || $preview) ? $default_value : phpbb::$user->profile_fields[$user_ident]);
|
||||
}
|
||||
else if ($profile_row['field_type'] == FIELD_INT)
|
||||
{
|
||||
@@ -572,17 +559,17 @@ class custom_profile
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$preview && isset($user->profile_fields[$user_ident]) && is_null($user->profile_fields[$user_ident]))
|
||||
if (!$preview && isset(phpbb::$user->profile_fields[$user_ident]) && is_null(phpbb::$user->profile_fields[$user_ident]))
|
||||
{
|
||||
$value = null;
|
||||
}
|
||||
else if (!isset($user->profile_fields[$user_ident]) || $preview)
|
||||
else if (!isset(phpbb::$user->profile_fields[$user_ident]) || $preview)
|
||||
{
|
||||
$value = $default_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = $user->profile_fields[$user_ident];
|
||||
$value = phpbb::$user->profile_fields[$user_ident];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,7 +577,7 @@ class custom_profile
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = (phpbb_request::is_set($profile_row['field_ident'])) ? request_var($profile_row['field_ident'], $default_value, true) : ((!isset($user->profile_fields[$user_ident]) || $preview) ? $default_value : $user->profile_fields[$user_ident]);
|
||||
$value = (phpbb_request::is_set($profile_row['field_ident'])) ? request_var($profile_row['field_ident'], $default_value, true) : ((!isset(phpbb::$user->profile_fields[$user_ident]) || $preview) ? $default_value : phpbb::$user->profile_fields[$user_ident]);
|
||||
|
||||
if (gettype($value) == 'string')
|
||||
{
|
||||
@@ -614,8 +601,6 @@ class custom_profile
|
||||
*/
|
||||
private function generate_int($profile_row, $preview = false)
|
||||
{
|
||||
global $template;
|
||||
|
||||
$profile_row['field_value'] = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
|
||||
$template->assign_block_vars(self::$profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
|
||||
}
|
||||
@@ -626,8 +611,6 @@ class custom_profile
|
||||
*/
|
||||
private function generate_date($profile_row, $preview = false)
|
||||
{
|
||||
global $user, $template;
|
||||
|
||||
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
|
||||
$user_ident = $profile_row['field_ident'];
|
||||
|
||||
@@ -639,14 +622,14 @@ class custom_profile
|
||||
{
|
||||
$profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
|
||||
}
|
||||
list($day, $month, $year) = explode('-', ((!isset($user->profile_fields[$user_ident]) || $preview) ? $profile_row['field_default_value'] : $user->profile_fields[$user_ident]));
|
||||
list($day, $month, $year) = explode('-', ((!isset(phpbb::$user->profile_fields[$user_ident]) || $preview) ? $profile_row['field_default_value'] : phpbb::$user->profile_fields[$user_ident]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($preview && $profile_row['field_default_value'] == 'now')
|
||||
{
|
||||
$profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
|
||||
list($day, $month, $year) = explode('-', ((!isset($user->profile_fields[$user_ident]) || $preview) ? $profile_row['field_default_value'] : $user->profile_fields[$user_ident]));
|
||||
list($day, $month, $year) = explode('-', ((!isset(phpbb::$user->profile_fields[$user_ident]) || $preview) ? $profile_row['field_default_value'] : phpbb::$user->profile_fields[$user_ident]));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -685,8 +668,6 @@ class custom_profile
|
||||
*/
|
||||
private function generate_bool($profile_row, $preview = false)
|
||||
{
|
||||
global $template;
|
||||
|
||||
$value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
|
||||
|
||||
$profile_row['field_value'] = $value;
|
||||
@@ -716,8 +697,6 @@ class custom_profile
|
||||
*/
|
||||
private function generate_string($profile_row, $preview = false)
|
||||
{
|
||||
global $template;
|
||||
|
||||
$profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview);
|
||||
$template->assign_block_vars(self::$profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER));
|
||||
}
|
||||
@@ -728,8 +707,6 @@ class custom_profile
|
||||
*/
|
||||
private function generate_text($profile_row, $preview = false)
|
||||
{
|
||||
global $template, $user;
|
||||
|
||||
$field_length = explode('|', $profile_row['field_length']);
|
||||
$profile_row['field_rows'] = $field_length[0];
|
||||
$profile_row['field_cols'] = $field_length[1];
|
||||
@@ -744,8 +721,6 @@ class custom_profile
|
||||
*/
|
||||
private function generate_dropdown($profile_row, $preview = false)
|
||||
{
|
||||
global $user, $template;
|
||||
|
||||
$value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
|
||||
|
||||
if (!isset($this->options_lang[$profile_row['field_id']]) || !isset($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]) || !sizeof($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]))
|
||||
@@ -773,8 +748,6 @@ class custom_profile
|
||||
*/
|
||||
private function process_field_row($mode, $profile_row)
|
||||
{
|
||||
global $template;
|
||||
|
||||
$preview = ($mode == 'preview') ? true : false;
|
||||
|
||||
// set template filename
|
||||
@@ -801,8 +774,6 @@ class custom_profile
|
||||
*/
|
||||
public static function build_insert_sql_array($cp_data)
|
||||
{
|
||||
global $db, $user, $auth;
|
||||
|
||||
$sql_not_in = array();
|
||||
foreach ($cp_data as $key => $null)
|
||||
{
|
||||
@@ -811,7 +782,7 @@ class custom_profile
|
||||
|
||||
$sql = 'SELECT f.field_type, f.field_ident, f.field_default_value, l.lang_default_value
|
||||
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
|
||||
WHERE l.lang_id = ' . $user->get_iso_lang_id() . '
|
||||
WHERE l.lang_id = ' . phpbb::$user->get_iso_lang_id() . '
|
||||
' . ((sizeof($sql_not_in)) ? ' AND ' . $db->sql_in_set('f.field_ident', $sql_not_in, true) : '') . '
|
||||
AND l.field_id = f.field_id';
|
||||
$result = $db->sql_query($sql);
|
||||
@@ -916,15 +887,13 @@ class custom_profile_admin extends custom_profile
|
||||
*/
|
||||
public function validate_options()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$validate_ary = array('CHARS_ANY' => '.*', 'NUMBERS_ONLY' => '[0-9]+', 'ALPHA_ONLY' => '[\w]+', 'ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+');
|
||||
|
||||
$validate_options = '';
|
||||
foreach ($validate_ary as $lang => $value)
|
||||
{
|
||||
$selected = ($this->vars['field_validation'] == $value) ? ' selected="selected"' : '';
|
||||
$validate_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
|
||||
$validate_options .= '<option value="' . $value . '"' . $selected . '>' . phpbb::$user->lang[$lang] . '</option>';
|
||||
}
|
||||
|
||||
return $validate_options;
|
||||
@@ -935,13 +904,11 @@ class custom_profile_admin extends custom_profile
|
||||
*/
|
||||
public function get_string_options()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$options = array(
|
||||
0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="text" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
|
||||
1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="text" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
|
||||
2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="text" name="field_maxlen" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
|
||||
3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
|
||||
0 => array('TITLE' => phpbb::$user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="text" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
|
||||
1 => array('TITLE' => phpbb::$user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="text" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
|
||||
2 => array('TITLE' => phpbb::$user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="text" name="field_maxlen" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
|
||||
3 => array('TITLE' => phpbb::$user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
|
||||
);
|
||||
|
||||
return $options;
|
||||
@@ -952,13 +919,11 @@ class custom_profile_admin extends custom_profile
|
||||
*/
|
||||
public function get_text_options()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$options = array(
|
||||
0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => '<input name="rows" size="5" value="' . $this->vars['rows'] . '" /> ' . $user->lang['ROWS'] . '</dd><dd><input name="columns" size="5" value="' . $this->vars['columns'] . '" /> ' . $user->lang['COLUMNS'] . ' <input type="hidden" name="field_length" value="' . $this->vars['field_length'] . '" />'),
|
||||
1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="text" name="field_minlen" size="10" value="' . $this->vars['field_minlen'] . '" />'),
|
||||
2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="text" name="field_maxlen" size="10" value="' . $this->vars['field_maxlen'] . '" />'),
|
||||
3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
|
||||
0 => array('TITLE' => phpbb::$user->lang['FIELD_LENGTH'], 'FIELD' => '<input name="rows" size="5" value="' . $this->vars['rows'] . '" /> ' . phpbb::$user->lang['ROWS'] . '</dd><dd><input name="columns" size="5" value="' . $this->vars['columns'] . '" /> ' . phpbb::$user->lang['COLUMNS'] . ' <input type="hidden" name="field_length" value="' . $this->vars['field_length'] . '" />'),
|
||||
1 => array('TITLE' => phpbb::$user->lang['MIN_FIELD_CHARS'], 'FIELD' => '<input type="text" name="field_minlen" size="10" value="' . $this->vars['field_minlen'] . '" />'),
|
||||
2 => array('TITLE' => phpbb::$user->lang['MAX_FIELD_CHARS'], 'FIELD' => '<input type="text" name="field_maxlen" size="10" value="' . $this->vars['field_maxlen'] . '" />'),
|
||||
3 => array('TITLE' => phpbb::$user->lang['FIELD_VALIDATION'], 'FIELD' => '<select name="field_validation">' . $this->validate_options() . '</select>')
|
||||
);
|
||||
|
||||
return $options;
|
||||
@@ -969,13 +934,11 @@ class custom_profile_admin extends custom_profile
|
||||
*/
|
||||
public function get_int_options()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$options = array(
|
||||
0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="text" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
|
||||
1 => array('TITLE' => $user->lang['MIN_FIELD_NUMBER'], 'FIELD' => '<input type="text" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
|
||||
2 => array('TITLE' => $user->lang['MAX_FIELD_NUMBER'], 'FIELD' => '<input type="text" name="field_maxlen" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
|
||||
3 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => '<input type="post" name="field_default_value" value="' . $this->vars['field_default_value'] . '" />')
|
||||
0 => array('TITLE' => phpbb::$user->lang['FIELD_LENGTH'], 'FIELD' => '<input type="text" name="field_length" size="5" value="' . $this->vars['field_length'] . '" />'),
|
||||
1 => array('TITLE' => phpbb::$user->lang['MIN_FIELD_NUMBER'], 'FIELD' => '<input type="text" name="field_minlen" size="5" value="' . $this->vars['field_minlen'] . '" />'),
|
||||
2 => array('TITLE' => phpbb::$user->lang['MAX_FIELD_NUMBER'], 'FIELD' => '<input type="text" name="field_maxlen" size="5" value="' . $this->vars['field_maxlen'] . '" />'),
|
||||
3 => array('TITLE' => phpbb::$user->lang['DEFAULT_VALUE'], 'FIELD' => '<input type="post" name="field_default_value" value="' . $this->vars['field_default_value'] . '" />')
|
||||
);
|
||||
|
||||
return $options;
|
||||
@@ -986,7 +949,7 @@ class custom_profile_admin extends custom_profile
|
||||
*/
|
||||
public function get_bool_options()
|
||||
{
|
||||
global $user, $lang_defs;
|
||||
global $lang_defs;
|
||||
|
||||
$default_lang_id = $lang_defs['iso'][phpbb::$config['default_lang']];
|
||||
|
||||
@@ -1004,8 +967,8 @@ class custom_profile_admin extends custom_profile
|
||||
);
|
||||
|
||||
$options = array(
|
||||
0 => array('TITLE' => $user->lang['FIELD_TYPE'], 'EXPLAIN' => $user->lang['BOOL_TYPE_EXPLAIN'], 'FIELD' => '<label><input type="radio" class="radio" name="field_length" value="1"' . (($this->vars['field_length'] == 1) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['RADIO_BUTTONS'] . '</label><label><input type="radio" class="radio" name="field_length" value="2"' . (($this->vars['field_length'] == 2) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['CHECKBOX'] . '</label>'),
|
||||
1 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row))
|
||||
0 => array('TITLE' => phpbb::$user->lang['FIELD_TYPE'], 'EXPLAIN' => phpbb::$user->lang['BOOL_TYPE_EXPLAIN'], 'FIELD' => '<label><input type="radio" class="radio" name="field_length" value="1"' . (($this->vars['field_length'] == 1) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . phpbb::$user->lang['RADIO_BUTTONS'] . '</label><label><input type="radio" class="radio" name="field_length" value="2"' . (($this->vars['field_length'] == 2) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . phpbb::$user->lang['CHECKBOX'] . '</label>'),
|
||||
1 => array('TITLE' => phpbb::$user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row))
|
||||
);
|
||||
|
||||
return $options;
|
||||
@@ -1016,7 +979,7 @@ class custom_profile_admin extends custom_profile
|
||||
*/
|
||||
public function get_dropdown_options()
|
||||
{
|
||||
global $user, $lang_defs;
|
||||
global $lang_defs;
|
||||
|
||||
$default_lang_id = $lang_defs['iso'][phpbb::$config['default_lang']];
|
||||
|
||||
@@ -1038,8 +1001,8 @@ class custom_profile_admin extends custom_profile
|
||||
$profile_row[1]['field_default_value'] = $this->vars['field_novalue'];
|
||||
|
||||
$options = array(
|
||||
0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row[0])),
|
||||
1 => array('TITLE' => $user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->process_field_row('preview', $profile_row[1]))
|
||||
0 => array('TITLE' => phpbb::$user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row[0])),
|
||||
1 => array('TITLE' => phpbb::$user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => phpbb::$user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->process_field_row('preview', $profile_row[1]))
|
||||
);
|
||||
|
||||
return $options;
|
||||
@@ -1050,7 +1013,7 @@ class custom_profile_admin extends custom_profile
|
||||
*/
|
||||
public function get_date_options()
|
||||
{
|
||||
global $user, $lang_defs;
|
||||
global $lang_defs;
|
||||
|
||||
$default_lang_id = $lang_defs['iso'][phpbb::$config['default_lang']];
|
||||
|
||||
@@ -1076,8 +1039,8 @@ class custom_profile_admin extends custom_profile
|
||||
}
|
||||
|
||||
$options = array(
|
||||
0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)),
|
||||
1 => array('TITLE' => $user->lang['ALWAYS_TODAY'], 'FIELD' => '<label><input type="radio" class="radio" name="always_now" value="1"' . (($s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['YES'] . '</label><label><input type="radio" class="radio" name="always_now" value="0"' . ((!$s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . $user->lang['NO'] . '</label>'),
|
||||
0 => array('TITLE' => phpbb::$user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)),
|
||||
1 => array('TITLE' => phpbb::$user->lang['ALWAYS_TODAY'], 'FIELD' => '<label><input type="radio" class="radio" name="always_now" value="1"' . (($s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . phpbb::$user->lang['YES'] . '</label><label><input type="radio" class="radio" name="always_now" value="0"' . ((!$s_checked) ? ' checked="checked"' : '') . ' onchange="document.getElementById(\'add_profile_field\').submit();" /> ' . phpbb::$user->lang['NO'] . '</label>'),
|
||||
);
|
||||
|
||||
return $options;
|
||||
|
@@ -255,7 +255,7 @@ class ftp extends transfer
|
||||
$this->password = $password;
|
||||
$this->timeout = $timeout;
|
||||
|
||||
// Make sure $this->root_path is layed out the same way as the $user->page['root_script_path'] value (/ at the end)
|
||||
// Make sure $this->root_path is layed out the same way as the phpbb::$user->page['root_script_path'] value (/ at the end)
|
||||
$this->root_path = str_replace('\\', '/', $this->root_path);
|
||||
|
||||
if (!empty($root_path))
|
||||
@@ -274,13 +274,11 @@ class ftp extends transfer
|
||||
*/
|
||||
private function data()
|
||||
{
|
||||
global $user;
|
||||
|
||||
return array(
|
||||
'host' => 'localhost',
|
||||
'username' => 'anonymous',
|
||||
'password' => '',
|
||||
'root_path' => $user->page['root_script_path'],
|
||||
'root_path' => phpbb::$user->page['root_script_path'],
|
||||
'port' => 21,
|
||||
'timeout' => 10
|
||||
);
|
||||
@@ -478,7 +476,7 @@ class ftp_fsock extends transfer
|
||||
$this->password = $password;
|
||||
$this->timeout = $timeout;
|
||||
|
||||
// Make sure $this->root_path is layed out the same way as the $user->page['root_script_path'] value (/ at the end)
|
||||
// Make sure $this->root_path is layed out the same way as the phpbb::$user->page['root_script_path'] value (/ at the end)
|
||||
$this->root_path = str_replace('\\', '/', $this->root_path);
|
||||
|
||||
if (!empty($root_path))
|
||||
@@ -497,13 +495,11 @@ class ftp_fsock extends transfer
|
||||
*/
|
||||
private function data()
|
||||
{
|
||||
global $user;
|
||||
|
||||
return array(
|
||||
'host' => 'localhost',
|
||||
'username' => 'anonymous',
|
||||
'password' => '',
|
||||
'root_path' => $user->page['root_script_path'],
|
||||
'root_path' => phpbb::$user->page['root_script_path'],
|
||||
'port' => 21,
|
||||
'timeout' => 10
|
||||
);
|
||||
|
@@ -269,8 +269,6 @@ class filespec
|
||||
*/
|
||||
function move_file($destination, $overwrite = false, $skip_image_check = false, $chmod = false)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (sizeof($this->error))
|
||||
{
|
||||
return false;
|
||||
@@ -312,7 +310,7 @@ class filespec
|
||||
{
|
||||
if (!@move_uploaded_file($this->filename, $this->destination_file))
|
||||
{
|
||||
$this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
|
||||
$this->error[] = sprintf(phpbb::$user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -327,7 +325,7 @@ class filespec
|
||||
{
|
||||
if (!@copy($this->filename, $this->destination_file))
|
||||
{
|
||||
$this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
|
||||
$this->error[] = sprintf(phpbb::$user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -340,7 +338,7 @@ class filespec
|
||||
|
||||
if (!@copy($this->filename, $this->destination_file))
|
||||
{
|
||||
$this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
|
||||
$this->error[] = sprintf(phpbb::$user->lang[$this->upload->error_prefix . 'GENERAL_UPLOAD_ERROR'], $this->destination_file);
|
||||
return false;
|
||||
}
|
||||
@unlink($this->filename);
|
||||
@@ -375,23 +373,23 @@ class filespec
|
||||
{
|
||||
if (!isset($types[$this->image_info[2]]))
|
||||
{
|
||||
$this->error[] = sprintf($user->lang['IMAGE_FILETYPE_INVALID'], $this->image_info[2], $this->mimetype);
|
||||
$this->error[] = sprintf(phpbb::$user->lang['IMAGE_FILETYPE_INVALID'], $this->image_info[2], $this->mimetype);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error[] = sprintf($user->lang['IMAGE_FILETYPE_MISMATCH'], $types[$this->image_info[2]][0], $this->extension);
|
||||
$this->error[] = sprintf(phpbb::$user->lang['IMAGE_FILETYPE_MISMATCH'], $types[$this->image_info[2]][0], $this->extension);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the dimensions match a valid image
|
||||
if (empty($this->width) || empty($this->height))
|
||||
{
|
||||
$this->error[] = $user->lang['ATTACHED_IMAGE_NOT_IMAGE'];
|
||||
$this->error[] = phpbb::$user->lang['ATTACHED_IMAGE_NOT_IMAGE'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
$this->error[] = phpbb::$user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,8 +405,6 @@ class filespec
|
||||
*/
|
||||
function additional_checks()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!$this->file_moved)
|
||||
{
|
||||
return false;
|
||||
@@ -417,17 +413,17 @@ class filespec
|
||||
// Filesize is too big or it's 0 if it was larger than the maxsize in the upload form
|
||||
if ($this->upload->max_filesize && ($this->get('filesize') > $this->upload->max_filesize || $this->filesize == 0))
|
||||
{
|
||||
$size_lang = ($this->upload->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->upload->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES'] );
|
||||
$size_lang = ($this->upload->max_filesize >= 1048576) ? phpbb::$user->lang['MIB'] : (($this->upload->max_filesize >= 1024) ? phpbb::$user->lang['KIB'] : phpbb::$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);
|
||||
$this->error[] = sprintf(phpbb::$user->lang[$this->upload->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->upload->valid_dimensions($this))
|
||||
{
|
||||
$this->error[] = sprintf($user->lang[$this->upload->error_prefix . 'WRONG_SIZE'], $this->upload->min_width, $this->upload->min_height, $this->upload->max_width, $this->upload->max_height, $this->width, $this->height);
|
||||
$this->error[] = sprintf(phpbb::$user->lang[$this->upload->error_prefix . 'WRONG_SIZE'], $this->upload->min_width, $this->upload->min_height, $this->upload->max_width, $this->upload->max_height, $this->width, $this->height);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -561,8 +557,6 @@ class fileupload
|
||||
*/
|
||||
function form_upload($form_name)
|
||||
{
|
||||
global $user;
|
||||
|
||||
unset($_FILES[$form_name]['local_mode']);
|
||||
$file = new filespec($_FILES[$form_name], $this);
|
||||
|
||||
@@ -587,21 +581,21 @@ class fileupload
|
||||
// Check if empty file got uploaded (not catched by is_uploaded_file)
|
||||
if (isset($_FILES[$form_name]['size']) && $_FILES[$form_name]['size'] == 0)
|
||||
{
|
||||
$file->error[] = $user->lang[$this->error_prefix . 'EMPTY_FILEUPLOAD'];
|
||||
$file->error[] = phpbb::$user->lang[$this->error_prefix . 'EMPTY_FILEUPLOAD'];
|
||||
return $file;
|
||||
}
|
||||
|
||||
// PHP Upload filesize exceeded
|
||||
if ($file->get('filename') == 'none')
|
||||
{
|
||||
$file->error[] = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
|
||||
$file->error[] = (@ini_get('upload_max_filesize') == '') ? phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf(phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
|
||||
return $file;
|
||||
}
|
||||
|
||||
// Not correctly uploaded
|
||||
if (!$file->is_uploaded())
|
||||
{
|
||||
$file->error[] = $user->lang[$this->error_prefix . 'NOT_UPLOADED'];
|
||||
$file->error[] = phpbb::$user->lang[$this->error_prefix . 'NOT_UPLOADED'];
|
||||
return $file;
|
||||
}
|
||||
|
||||
@@ -615,8 +609,6 @@ class fileupload
|
||||
*/
|
||||
function local_upload($source_file, $filedata = false)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$form_name = 'local';
|
||||
|
||||
$_FILES[$form_name]['local_mode'] = true;
|
||||
@@ -670,14 +662,14 @@ class fileupload
|
||||
// PHP Upload filesize exceeded
|
||||
if ($file->get('filename') == 'none')
|
||||
{
|
||||
$file->error[] = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
|
||||
$file->error[] = (@ini_get('upload_max_filesize') == '') ? phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf(phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
|
||||
return $file;
|
||||
}
|
||||
|
||||
// Not correctly uploaded
|
||||
if (!$file->is_uploaded())
|
||||
{
|
||||
$file->error[] = $user->lang[$this->error_prefix . 'NOT_UPLOADED'];
|
||||
$file->error[] = phpbb::$user->lang[$this->error_prefix . 'NOT_UPLOADED'];
|
||||
return $file;
|
||||
}
|
||||
|
||||
@@ -696,20 +688,18 @@ class fileupload
|
||||
*/
|
||||
function remote_upload($upload_url)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$upload_ary = array();
|
||||
$upload_ary['local_mode'] = true;
|
||||
|
||||
if (!preg_match('#^(https?://).*?\.(' . implode('|', $this->allowed_extensions) . ')$#i', $upload_url, $match))
|
||||
{
|
||||
$file = new fileerror($user->lang[$this->error_prefix . 'URL_INVALID']);
|
||||
$file = new fileerror(phpbb::$user->lang[$this->error_prefix . 'URL_INVALID']);
|
||||
return $file;
|
||||
}
|
||||
|
||||
if (empty($match[2]))
|
||||
{
|
||||
$file = new fileerror($user->lang[$this->error_prefix . 'URL_INVALID']);
|
||||
$file = new fileerror(phpbb::$user->lang[$this->error_prefix . 'URL_INVALID']);
|
||||
return $file;
|
||||
}
|
||||
|
||||
@@ -734,7 +724,7 @@ class fileupload
|
||||
|
||||
if (!($fsock = @fsockopen($host, $port, $errno, $errstr)))
|
||||
{
|
||||
$file = new fileerror($user->lang[$this->error_prefix . 'NOT_UPLOADED']);
|
||||
$file = new fileerror(phpbb::$user->lang[$this->error_prefix . 'NOT_UPLOADED']);
|
||||
return $file;
|
||||
}
|
||||
|
||||
@@ -772,7 +762,7 @@ class fileupload
|
||||
}
|
||||
else if (stripos($line, '404 not found') !== false)
|
||||
{
|
||||
$file = new fileerror($user->lang[$this->error_prefix . 'URL_NOT_FOUND']);
|
||||
$file = new fileerror(phpbb::$user->lang[$this->error_prefix . 'URL_NOT_FOUND']);
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
@@ -782,7 +772,7 @@ class fileupload
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
$file = new fileerror($user->lang[$this->error_prefix . 'EMPTY_REMOTE_DATA']);
|
||||
$file = new fileerror(phpbb::$user->lang[$this->error_prefix . 'EMPTY_REMOTE_DATA']);
|
||||
return $file;
|
||||
}
|
||||
|
||||
@@ -791,7 +781,7 @@ class fileupload
|
||||
|
||||
if (!($fp = @fopen($filename, 'wb')))
|
||||
{
|
||||
$file = new fileerror($user->lang[$this->error_prefix . 'NOT_UPLOADED']);
|
||||
$file = new fileerror(phpbb::$user->lang[$this->error_prefix . 'NOT_UPLOADED']);
|
||||
return $file;
|
||||
}
|
||||
|
||||
@@ -813,27 +803,25 @@ class fileupload
|
||||
*/
|
||||
function assign_internal_error($errorcode)
|
||||
{
|
||||
global $user;
|
||||
|
||||
switch ($errorcode)
|
||||
{
|
||||
case 1:
|
||||
$error = (@ini_get('upload_max_filesize') == '') ? $user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf($user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
|
||||
$error = (@ini_get('upload_max_filesize') == '') ? phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_NA'] : sprintf(phpbb::$user->lang[$this->error_prefix . 'PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize'));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']);
|
||||
$size_lang = ($this->max_filesize >= 1048576) ? phpbb::$user->lang['MIB'] : (($this->max_filesize >= 1024) ? phpbb::$user->lang['KIB'] : phpbb::$user->lang['BYTES']);
|
||||
$max_filesize = get_formatted_filesize($this->max_filesize, false);
|
||||
|
||||
$error = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang);
|
||||
$error = sprintf(phpbb::$user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$error = $user->lang[$this->error_prefix . 'PARTIAL_UPLOAD'];
|
||||
$error = phpbb::$user->lang[$this->error_prefix . 'PARTIAL_UPLOAD'];
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$error = $user->lang[$this->error_prefix . 'NOT_UPLOADED'];
|
||||
$error = phpbb::$user->lang[$this->error_prefix . 'NOT_UPLOADED'];
|
||||
break;
|
||||
|
||||
case 6:
|
||||
@@ -853,33 +841,31 @@ class fileupload
|
||||
*/
|
||||
function common_checks(&$file)
|
||||
{
|
||||
global $user;
|
||||
|
||||
// Filesize is too big or it's 0 if it was larger than the maxsize in the upload form
|
||||
if ($this->max_filesize && ($file->get('filesize') > $this->max_filesize || $file->get('filesize') == 0))
|
||||
{
|
||||
$size_lang = ($this->max_filesize >= 1048576) ? $user->lang['MIB'] : (($this->max_filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']);
|
||||
$size_lang = ($this->max_filesize >= 1048576) ? phpbb::$user->lang['MIB'] : (($this->max_filesize >= 1024) ? phpbb::$user->lang['KIB'] : phpbb::$user->lang['BYTES']);
|
||||
$max_filesize = get_formatted_filesize($this->max_filesize, false);
|
||||
|
||||
$file->error[] = sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang);
|
||||
$file->error[] = sprintf(phpbb::$user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize, $size_lang);
|
||||
}
|
||||
|
||||
// check Filename
|
||||
if (preg_match("#[\\/:*?\"<>|]#i", $file->get('realname')))
|
||||
{
|
||||
$file->error[] = sprintf($user->lang[$this->error_prefix . 'INVALID_FILENAME'], $file->get('realname'));
|
||||
$file->error[] = sprintf(phpbb::$user->lang[$this->error_prefix . 'INVALID_FILENAME'], $file->get('realname'));
|
||||
}
|
||||
|
||||
// Invalid Extension
|
||||
if (!$this->valid_extension($file))
|
||||
{
|
||||
$file->error[] = sprintf($user->lang[$this->error_prefix . 'DISALLOWED_EXTENSION'], $file->get('extension'));
|
||||
$file->error[] = sprintf(phpbb::$user->lang[$this->error_prefix . 'DISALLOWED_EXTENSION'], $file->get('extension'));
|
||||
}
|
||||
|
||||
// MIME Sniffing
|
||||
if (!$this->valid_content($file))
|
||||
{
|
||||
$file->error[] = sprintf($user->lang[$this->error_prefix . 'DISALLOWED_CONTENT']);
|
||||
$file->error[] = sprintf(phpbb::$user->lang[$this->error_prefix . 'DISALLOWED_CONTENT']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -292,8 +292,6 @@ function user_add($user_row, $cp_data = false)
|
||||
*/
|
||||
function user_delete($mode, $user_id, $post_username = false)
|
||||
{
|
||||
global $user, $auth;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USERS_TABLE . '
|
||||
WHERE user_id = ' . $user_id;
|
||||
@@ -378,7 +376,7 @@ function user_delete($mode, $user_id, $post_username = false)
|
||||
|
||||
if ($post_username === false)
|
||||
{
|
||||
$post_username = $user->lang['GUEST'];
|
||||
$post_username = phpbb::$user->lang['GUEST'];
|
||||
}
|
||||
|
||||
// If the user is inactive and newly registered we assume no posts from this user being there...
|
||||
@@ -573,8 +571,6 @@ function user_delete($mode, $user_id, $post_username = false)
|
||||
*/
|
||||
function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
|
||||
{
|
||||
global $user, $auth;
|
||||
|
||||
$deactivated = $activated = 0;
|
||||
$sql_statements = array();
|
||||
|
||||
@@ -613,7 +609,7 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
|
||||
$deactivated++;
|
||||
|
||||
// Remove the users session key...
|
||||
$user->reset_login_keys($row['user_id']);
|
||||
phpbb::$user->reset_login_keys($row['user_id']);
|
||||
}
|
||||
|
||||
$sql_ary += array(
|
||||
@@ -666,8 +662,6 @@ function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
|
||||
*/
|
||||
function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason, $ban_give_reason = '')
|
||||
{
|
||||
global $user, $auth;
|
||||
|
||||
// Delete stale bans
|
||||
$sql = 'DELETE FROM ' . BANLIST_TABLE . '
|
||||
WHERE ban_end < ' . time() . '
|
||||
@@ -741,7 +735,7 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
|
||||
if ($username != '')
|
||||
{
|
||||
$clean_name = utf8_clean_string($username);
|
||||
if ($clean_name == $user->data['username_clean'])
|
||||
if ($clean_name == phpbb::$user->data['username_clean'])
|
||||
{
|
||||
trigger_error('CANNOT_BAN_YOURSELF', E_USER_WARNING);
|
||||
}
|
||||
@@ -766,11 +760,11 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
|
||||
// Do not allow banning yourself
|
||||
if (sizeof($founder))
|
||||
{
|
||||
$sql .= ' AND ' . phpbb::$db->sql_in_set('user_id', array_merge(array_keys($founder), array($user->data['user_id'])), true);
|
||||
$sql .= ' AND ' . phpbb::$db->sql_in_set('user_id', array_merge(array_keys($founder), array(phpbb::$user->data['user_id'])), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql .= ' AND user_id <> ' . $user->data['user_id'];
|
||||
$sql .= ' AND user_id <> ' . phpbb::$user->data['user_id'];
|
||||
}
|
||||
|
||||
$result = phpbb::$db->sql_query($sql);
|
||||
@@ -1061,8 +1055,6 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
|
||||
*/
|
||||
function user_unban($mode, $ban)
|
||||
{
|
||||
global $user, $auth;
|
||||
|
||||
// Delete stale bans
|
||||
$sql = 'DELETE FROM ' . BANLIST_TABLE . '
|
||||
WHERE ban_end < ' . time() . '
|
||||
@@ -1185,8 +1177,6 @@ function user_ipwhois($ip)
|
||||
*/
|
||||
function validate_data($data, $val_ary)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$error = array();
|
||||
|
||||
foreach ($val_ary as $var => $val_seq)
|
||||
@@ -1204,7 +1194,7 @@ function validate_data($data, $val_ary)
|
||||
if ($result = call_user_func_array('validate_' . $function, $validate))
|
||||
{
|
||||
// Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted.
|
||||
$error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var);
|
||||
$error[] = (empty(phpbb::$user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1330,16 +1320,14 @@ function validate_match($string, $optional = false, $match = '')
|
||||
* Used for registering, changing names, and posting anonymously with a username
|
||||
*
|
||||
* @param string $username The username to check
|
||||
* @param string $allowed_username An allowed username, default being $user->data['username']
|
||||
* @param string $allowed_username An allowed username, default being phpbb::$user->data['username']
|
||||
*
|
||||
* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
|
||||
*/
|
||||
function validate_username($username, $allowed_username = false)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$clean_username = utf8_clean_string($username);
|
||||
$allowed_username = ($allowed_username === false) ? $user->data['username_clean'] : utf8_clean_string($allowed_username);
|
||||
$allowed_username = ($allowed_username === false) ? phpbb::$user->data['username_clean'] : utf8_clean_string($allowed_username);
|
||||
|
||||
if ($allowed_username == $clean_username)
|
||||
{
|
||||
@@ -1432,8 +1420,6 @@ function validate_username($username, $allowed_username = false)
|
||||
*/
|
||||
function validate_password($password)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!$password)
|
||||
{
|
||||
return false;
|
||||
@@ -1496,16 +1482,14 @@ function validate_password($password)
|
||||
* Check to see if email address is banned or already present in the DB
|
||||
*
|
||||
* @param string $email The email to check
|
||||
* @param string $allowed_email An allowed email, default being $user->data['user_email']
|
||||
* @param string $allowed_email An allowed email, default being phpbb::$user->data['user_email']
|
||||
*
|
||||
* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
|
||||
*/
|
||||
function validate_email($email, $allowed_email = false)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$email = strtolower($email);
|
||||
$allowed_email = ($allowed_email === false) ? strtolower($user->data['user_email']) : strtolower($allowed_email);
|
||||
$allowed_email = ($allowed_email === false) ? strtolower(phpbb::$user->data['user_email']) : strtolower($allowed_email);
|
||||
|
||||
if ($allowed_email == $email)
|
||||
{
|
||||
@@ -1529,7 +1513,7 @@ function validate_email($email, $allowed_email = false)
|
||||
}
|
||||
}
|
||||
|
||||
if (($ban_reason = $user->check_ban(false, false, $email, true)) !== false)
|
||||
if (($ban_reason = phpbb::$user->check_ban(false, false, $email, true)) !== false)
|
||||
{
|
||||
return ($ban_reason === true) ? 'EMAIL_BANNED' : $ban_reason;
|
||||
}
|
||||
@@ -1760,8 +1744,6 @@ function validate_jabber($jid)
|
||||
*/
|
||||
function avatar_delete($mode, $row, $clean_db = false)
|
||||
{
|
||||
global $user;
|
||||
|
||||
// Check if the users avatar is actually *not* a group avatar
|
||||
if ($mode == 'user')
|
||||
{
|
||||
@@ -1790,28 +1772,26 @@ function avatar_delete($mode, $row, $clean_db = false)
|
||||
*/
|
||||
function avatar_remote($data, &$error)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!preg_match('#^(http|https|ftp)://#i', $data['remotelink']))
|
||||
{
|
||||
$data['remotelink'] = 'http://' . $data['remotelink'];
|
||||
}
|
||||
if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.(gif|jpg|jpeg|png)$#i', $data['remotelink']))
|
||||
{
|
||||
$error[] = $user->lang['AVATAR_URL_INVALID'];
|
||||
$error[] = phpbb::$user->lang['AVATAR_URL_INVALID'];
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure getimagesize works...
|
||||
if (($image_data = @getimagesize($data['remotelink'])) === false && (empty($data['width']) || empty($data['height'])))
|
||||
{
|
||||
$error[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
$error[] = phpbb::$user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($image_data) && ($image_data[0] < 2 || $image_data[1] < 2))
|
||||
{
|
||||
$error[] = $user->lang['AVATAR_NO_SIZE'];
|
||||
$error[] = phpbb::$user->lang['AVATAR_NO_SIZE'];
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1820,7 +1800,7 @@ function avatar_remote($data, &$error)
|
||||
|
||||
if ($width < 2 || $height < 2)
|
||||
{
|
||||
$error[] = $user->lang['AVATAR_NO_SIZE'];
|
||||
$error[] = phpbb::$user->lang['AVATAR_NO_SIZE'];
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1833,11 +1813,11 @@ function avatar_remote($data, &$error)
|
||||
{
|
||||
if (!isset($types[$image_data[2]]))
|
||||
{
|
||||
$error[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
$error[] = phpbb::$user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$error[] = sprintf($user->lang['IMAGE_FILETYPE_MISMATCH'], $types[$image_data[2]][0], $extension);
|
||||
$error[] = sprintf(phpbb::$user->lang['IMAGE_FILETYPE_MISMATCH'], $types[$image_data[2]][0], $extension);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1846,7 +1826,7 @@ function avatar_remote($data, &$error)
|
||||
{
|
||||
if ($width > phpbb::$config['avatar_max_width'] || $height > phpbb::$config['avatar_max_height'])
|
||||
{
|
||||
$error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], phpbb::$config['avatar_min_width'], phpbb::$config['avatar_min_height'], phpbb::$config['avatar_max_width'], phpbb::$config['avatar_max_height'], $width, $height);
|
||||
$error[] = sprintf(phpbb::$user->lang['AVATAR_WRONG_SIZE'], phpbb::$config['avatar_min_width'], phpbb::$config['avatar_min_height'], phpbb::$config['avatar_max_width'], phpbb::$config['avatar_max_height'], $width, $height);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1855,7 +1835,7 @@ function avatar_remote($data, &$error)
|
||||
{
|
||||
if ($width < phpbb::$config['avatar_min_width'] || $height < phpbb::$config['avatar_min_height'])
|
||||
{
|
||||
$error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], phpbb::$config['avatar_min_width'], phpbb::$config['avatar_min_height'], phpbb::$config['avatar_max_width'], phpbb::$config['avatar_max_height'], $width, $height);
|
||||
$error[] = sprintf(phpbb::$user->lang['AVATAR_WRONG_SIZE'], phpbb::$config['avatar_min_width'], phpbb::$config['avatar_min_height'], phpbb::$config['avatar_max_width'], phpbb::$config['avatar_max_height'], $width, $height);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1868,8 +1848,6 @@ function avatar_remote($data, &$error)
|
||||
*/
|
||||
function avatar_upload($data, &$error)
|
||||
{
|
||||
global $user;
|
||||
|
||||
// Init upload class
|
||||
include_once(PHPBB_ROOT_PATH . 'includes/functions_upload.' . PHP_EXT);
|
||||
$upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), phpbb::$config['avatar_filesize'], phpbb::$config['avatar_min_width'], phpbb::$config['avatar_min_height'], phpbb::$config['avatar_max_width'], phpbb::$config['avatar_max_height'], explode('|', phpbb::$config['mime_triggers']));
|
||||
@@ -1936,15 +1914,13 @@ function get_avatar_filename($avatar_entry)
|
||||
*/
|
||||
function avatar_gallery($category, $avatar_select, $items_per_column, $block_var = 'avatar_row')
|
||||
{
|
||||
global $user, $template;
|
||||
|
||||
$avatar_list = array();
|
||||
|
||||
$path = PHPBB_ROOT_PATH . phpbb::$config['avatar_gallery_path'];
|
||||
|
||||
if (!file_exists($path) || !is_dir($path))
|
||||
{
|
||||
$avatar_list = array($user->lang['NO_AVATAR_CATEGORY'] => array());
|
||||
$avatar_list = array(phpbb::$user->lang['NO_AVATAR_CATEGORY'] => array());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1953,7 +1929,7 @@ function avatar_gallery($category, $avatar_select, $items_per_column, $block_var
|
||||
|
||||
if (!$dp)
|
||||
{
|
||||
return array($user->lang['NO_AVATAR_CATEGORY'] => array());
|
||||
return array(phpbb::$user->lang['NO_AVATAR_CATEGORY'] => array());
|
||||
}
|
||||
|
||||
while (($file = readdir($dp)) !== false)
|
||||
@@ -1990,7 +1966,7 @@ function avatar_gallery($category, $avatar_select, $items_per_column, $block_var
|
||||
|
||||
if (!sizeof($avatar_list))
|
||||
{
|
||||
$avatar_list = array($user->lang['NO_AVATAR_CATEGORY'] => array());
|
||||
$avatar_list = array(phpbb::$user->lang['NO_AVATAR_CATEGORY'] => array());
|
||||
}
|
||||
|
||||
@ksort($avatar_list);
|
||||
@@ -2040,8 +2016,6 @@ function avatar_gallery($category, $avatar_select, $items_per_column, $block_var
|
||||
*/
|
||||
function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $current_y = 0)
|
||||
{
|
||||
global $user;
|
||||
|
||||
switch ($avatar_type)
|
||||
{
|
||||
case AVATAR_REMOTE :
|
||||
@@ -2059,13 +2033,13 @@ function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $
|
||||
// Make sure getimagesize works...
|
||||
if (($image_data = @getimagesize($avatar)) === false)
|
||||
{
|
||||
$error[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
$error[] = phpbb::$user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($image_data[0] < 2 || $image_data[1] < 2)
|
||||
{
|
||||
$error[] = $user->lang['AVATAR_NO_SIZE'];
|
||||
$error[] = phpbb::$user->lang['AVATAR_NO_SIZE'];
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2093,8 +2067,6 @@ function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $
|
||||
*/
|
||||
function avatar_process_user(&$error, $custom_userdata = false)
|
||||
{
|
||||
global $auth, $user;
|
||||
|
||||
$data = array(
|
||||
'uploadurl' => request_var('uploadurl', ''),
|
||||
'remotelink' => request_var('remotelink', ''),
|
||||
@@ -2118,7 +2090,7 @@ function avatar_process_user(&$error, $custom_userdata = false)
|
||||
|
||||
if ($custom_userdata === false)
|
||||
{
|
||||
$userdata = &$user->data;
|
||||
$userdata = &phpbb::$user->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2188,7 +2160,7 @@ function avatar_process_user(&$error, $custom_userdata = false)
|
||||
{
|
||||
if ($data['width'] > phpbb::$config['avatar_max_width'] || $data['height'] > phpbb::$config['avatar_max_height'])
|
||||
{
|
||||
$error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], phpbb::$config['avatar_min_width'], phpbb::$config['avatar_min_height'], phpbb::$config['avatar_max_width'], phpbb::$config['avatar_max_height'], $data['width'], $data['height']);
|
||||
$error[] = sprintf(phpbb::$user->lang['AVATAR_WRONG_SIZE'], phpbb::$config['avatar_min_width'], phpbb::$config['avatar_min_height'], phpbb::$config['avatar_max_width'], phpbb::$config['avatar_max_height'], $data['width'], $data['height']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2198,7 +2170,7 @@ function avatar_process_user(&$error, $custom_userdata = false)
|
||||
{
|
||||
if ($data['width'] < phpbb::$config['avatar_min_width'] || $data['height'] < phpbb::$config['avatar_min_height'])
|
||||
{
|
||||
$error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], phpbb::$config['avatar_min_width'], phpbb::$config['avatar_min_height'], phpbb::$config['avatar_max_width'], phpbb::$config['avatar_max_height'], $data['width'], $data['height']);
|
||||
$error[] = sprintf(phpbb::$user->lang['AVATAR_WRONG_SIZE'], phpbb::$config['avatar_min_width'], phpbb::$config['avatar_min_height'], phpbb::$config['avatar_max_width'], phpbb::$config['avatar_max_height'], $data['width'], $data['height']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2218,7 +2190,7 @@ function avatar_process_user(&$error, $custom_userdata = false)
|
||||
$ext_new = $ext_old = '';
|
||||
if (isset($sql_ary['user_avatar']))
|
||||
{
|
||||
$userdata = ($custom_userdata === false) ? $user->data : $custom_userdata;
|
||||
$userdata = ($custom_userdata === false) ? phpbb::$user->data : $custom_userdata;
|
||||
$ext_new = (empty($sql_ary['user_avatar'])) ? '' : substr(strrchr($sql_ary['user_avatar'], '.'), 1);
|
||||
$ext_old = (empty($userdata['user_avatar'])) ? '' : substr(strrchr($userdata['user_avatar'], '.'), 1);
|
||||
|
||||
@@ -2235,7 +2207,7 @@ function avatar_process_user(&$error, $custom_userdata = false)
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE user_id = ' . (($custom_userdata === false) ? $user->data['user_id'] : $custom_userdata['user_id']);
|
||||
WHERE user_id = ' . (($custom_userdata === false) ? phpbb::$user->data['user_id'] : $custom_userdata['user_id']);
|
||||
phpbb::$db->sql_query($sql);
|
||||
|
||||
}
|
||||
@@ -2254,7 +2226,7 @@ function avatar_process_user(&$error, $custom_userdata = false)
|
||||
*/
|
||||
function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow_desc_bbcode = false, $allow_desc_urls = false, $allow_desc_smilies = false)
|
||||
{
|
||||
global $user, $file_upload;
|
||||
global $file_upload;
|
||||
|
||||
$error = array();
|
||||
$attribute_ary = array(
|
||||
@@ -2279,18 +2251,18 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
|
||||
// Check data. Limit group name length.
|
||||
if (!utf8_strlen($name) || utf8_strlen($name) > 60)
|
||||
{
|
||||
$error[] = (!utf8_strlen($name)) ? $user->lang['GROUP_ERR_USERNAME'] : $user->lang['GROUP_ERR_USER_LONG'];
|
||||
$error[] = (!utf8_strlen($name)) ? phpbb::$user->lang['GROUP_ERR_USERNAME'] : phpbb::$user->lang['GROUP_ERR_USER_LONG'];
|
||||
}
|
||||
|
||||
$err = group_validate_groupname($group_id, $name);
|
||||
if (!empty($err))
|
||||
{
|
||||
$error[] = $user->lang[$err];
|
||||
$error[] = phpbb::$user->lang[$err];
|
||||
}
|
||||
|
||||
if (!in_array($type, array(GROUP_OPEN, GROUP_CLOSED, GROUP_HIDDEN, GROUP_SPECIAL, GROUP_FREE)))
|
||||
{
|
||||
$error[] = $user->lang['GROUP_ERR_TYPE'];
|
||||
$error[] = phpbb::$user->lang['GROUP_ERR_TYPE'];
|
||||
}
|
||||
|
||||
if (!sizeof($error))
|
||||
@@ -2400,7 +2372,7 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
|
||||
group_set_user_default($group_id, $user_ary, $sql_ary);
|
||||
}
|
||||
|
||||
$name = ($type == GROUP_SPECIAL) ? $user->lang['G_' . $name] : $name;
|
||||
$name = ($type == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $name] : $name;
|
||||
add_log('admin', $log, $name);
|
||||
|
||||
group_update_listings($group_id);
|
||||
@@ -2520,8 +2492,6 @@ function group_delete($group_id, $group_name = false)
|
||||
*/
|
||||
function group_user_add($group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $default = false, $leader = 0, $pending = 0, $group_attributes = false)
|
||||
{
|
||||
global $auth;
|
||||
|
||||
// We need both username and user_id info
|
||||
$result = user_get_id_name($user_id_ary, $username_ary);
|
||||
|
||||
@@ -2621,8 +2591,6 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
|
||||
*/
|
||||
function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false)
|
||||
{
|
||||
global $auth;
|
||||
|
||||
$group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS');
|
||||
|
||||
// We need both username and user_id info
|
||||
@@ -2818,8 +2786,6 @@ function remove_default_rank($group_id, $user_ids)
|
||||
*/
|
||||
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
|
||||
{
|
||||
global $auth;
|
||||
|
||||
// We need both username and user_id info
|
||||
$result = user_get_id_name($user_id_ary, $username_ary);
|
||||
|
||||
@@ -3104,8 +3070,6 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
|
||||
*/
|
||||
function get_group_name($group_id)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$sql = 'SELECT group_name, group_type
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
WHERE group_id = ' . (int) $group_id;
|
||||
@@ -3118,7 +3082,7 @@ function get_group_name($group_id)
|
||||
return '';
|
||||
}
|
||||
|
||||
return ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
|
||||
return ($row['group_type'] == GROUP_SPECIAL) ? phpbb::$user->lang['G_' . $row['group_name']] : $row['group_name'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3193,8 +3157,6 @@ function group_memberships($group_id_ary = false, $user_id_ary = false, $return_
|
||||
*/
|
||||
function group_update_listings($group_id)
|
||||
{
|
||||
global $auth;
|
||||
|
||||
$hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_'));
|
||||
|
||||
if (!sizeof($hold_ary))
|
||||
|
@@ -42,8 +42,6 @@ class bbcode_firstpass extends bbcode
|
||||
$this->bbcode_init();
|
||||
}
|
||||
|
||||
global $user;
|
||||
|
||||
$this->bbcode_bitfield = '';
|
||||
$bitfield = new bitfield();
|
||||
|
||||
@@ -55,7 +53,7 @@ class bbcode_firstpass extends bbcode
|
||||
{
|
||||
if (preg_match($regexp, $this->message))
|
||||
{
|
||||
$this->warn_msg[] = sprintf($user->lang['UNAUTHORISED_BBCODE'] , '[' . $bbcode_name . ']');
|
||||
$this->warn_msg[] = sprintf(phpbb::$user->lang['UNAUTHORISED_BBCODE'] , '[' . $bbcode_name . ']');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -135,7 +133,6 @@ class bbcode_firstpass extends bbcode
|
||||
|
||||
if (!is_array($rowset))
|
||||
{
|
||||
global $db;
|
||||
$rowset = array();
|
||||
|
||||
$sql = 'SELECT *
|
||||
@@ -194,8 +191,6 @@ class bbcode_firstpass extends bbcode
|
||||
*/
|
||||
function bbcode_size($stx, $in)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!$this->check_bbcode('size', $in))
|
||||
{
|
||||
return $in;
|
||||
@@ -203,7 +198,7 @@ class bbcode_firstpass extends bbcode
|
||||
|
||||
if (phpbb::$config['max_' . $this->mode . '_font_size'] && phpbb::$config['max_' . $this->mode . '_font_size'] < $stx)
|
||||
{
|
||||
$this->warn_msg[] = sprintf($user->lang['MAX_FONT_SIZE_EXCEEDED'], phpbb::$config['max_' . $this->mode . '_font_size']);
|
||||
$this->warn_msg[] = sprintf(phpbb::$user->lang['MAX_FONT_SIZE_EXCEEDED'], phpbb::$config['max_' . $this->mode . '_font_size']);
|
||||
|
||||
return '[size=' . $stx . ']' . $in . '[/size]';
|
||||
}
|
||||
@@ -274,8 +269,6 @@ class bbcode_firstpass extends bbcode
|
||||
*/
|
||||
function bbcode_img($in)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!$this->check_bbcode('img', $in))
|
||||
{
|
||||
return $in;
|
||||
@@ -305,20 +298,20 @@ class bbcode_firstpass extends bbcode
|
||||
if ($stats === false)
|
||||
{
|
||||
$error = true;
|
||||
$this->warn_msg[] = $user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
$this->warn_msg[] = phpbb::$user->lang['UNABLE_GET_IMAGE_SIZE'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (phpbb::$config['max_' . $this->mode . '_img_height'] && phpbb::$config['max_' . $this->mode . '_img_height'] < $stats[1])
|
||||
{
|
||||
$error = true;
|
||||
$this->warn_msg[] = sprintf($user->lang['MAX_IMG_HEIGHT_EXCEEDED'], phpbb::$config['max_' . $this->mode . '_img_height']);
|
||||
$this->warn_msg[] = sprintf(phpbb::$user->lang['MAX_IMG_HEIGHT_EXCEEDED'], phpbb::$config['max_' . $this->mode . '_img_height']);
|
||||
}
|
||||
|
||||
if (phpbb::$config['max_' . $this->mode . '_img_width'] && phpbb::$config['max_' . $this->mode . '_img_width'] < $stats[0])
|
||||
{
|
||||
$error = true;
|
||||
$this->warn_msg[] = sprintf($user->lang['MAX_IMG_WIDTH_EXCEEDED'], phpbb::$config['max_' . $this->mode . '_img_width']);
|
||||
$this->warn_msg[] = sprintf(phpbb::$user->lang['MAX_IMG_WIDTH_EXCEEDED'], phpbb::$config['max_' . $this->mode . '_img_width']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,8 +329,6 @@ class bbcode_firstpass extends bbcode
|
||||
*/
|
||||
function bbcode_flash($width, $height, $in)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (!$this->check_bbcode('flash', $in))
|
||||
{
|
||||
return $in;
|
||||
@@ -358,13 +349,13 @@ class bbcode_firstpass extends bbcode
|
||||
if (phpbb::$config['max_' . $this->mode . '_img_height'] && phpbb::$config['max_' . $this->mode . '_img_height'] < $height)
|
||||
{
|
||||
$error = true;
|
||||
$this->warn_msg[] = sprintf($user->lang['MAX_FLASH_HEIGHT_EXCEEDED'], phpbb::$config['max_' . $this->mode . '_img_height']);
|
||||
$this->warn_msg[] = sprintf(phpbb::$user->lang['MAX_FLASH_HEIGHT_EXCEEDED'], phpbb::$config['max_' . $this->mode . '_img_height']);
|
||||
}
|
||||
|
||||
if (phpbb::$config['max_' . $this->mode . '_img_width'] && phpbb::$config['max_' . $this->mode . '_img_width'] < $width)
|
||||
{
|
||||
$error = true;
|
||||
$this->warn_msg[] = sprintf($user->lang['MAX_FLASH_WIDTH_EXCEEDED'], phpbb::$config['max_' . $this->mode . '_img_width']);
|
||||
$this->warn_msg[] = sprintf(phpbb::$user->lang['MAX_FLASH_WIDTH_EXCEEDED'], phpbb::$config['max_' . $this->mode . '_img_width']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -685,8 +676,6 @@ class bbcode_firstpass extends bbcode
|
||||
*/
|
||||
function bbcode_quote($in)
|
||||
{
|
||||
global $user;
|
||||
|
||||
/**
|
||||
* If you change this code, make sure the cases described within the following reports are still working:
|
||||
* #3572 - [quote="[test]test"]test [ test[/quote] - (correct: parsed)
|
||||
@@ -755,7 +744,7 @@ class bbcode_firstpass extends bbcode
|
||||
if (phpbb::$config['max_quote_depth'] && sizeof($close_tags) >= phpbb::$config['max_quote_depth'])
|
||||
{
|
||||
// there are too many nested quotes
|
||||
$error_ary['quote_depth'] = sprintf($user->lang['QUOTE_DEPTH_EXCEEDED'], phpbb::$config['max_quote_depth']);
|
||||
$error_ary['quote_depth'] = sprintf(phpbb::$user->lang['QUOTE_DEPTH_EXCEEDED'], phpbb::$config['max_quote_depth']);
|
||||
|
||||
$out .= $buffer . $tok;
|
||||
$tok = '[]';
|
||||
@@ -977,21 +966,19 @@ class bbcode_firstpass extends bbcode
|
||||
*/
|
||||
function path_in_domain($url)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (phpbb::$config['force_server_vars'])
|
||||
{
|
||||
$check_path = phpbb::$config['script_path'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$check_path = ($user->page['root_script_path'] != '/') ? substr($user->page['root_script_path'], 0, -1) : '/';
|
||||
$check_path = (phpbb::$user->page['root_script_path'] != '/') ? substr(phpbb::$user->page['root_script_path'], 0, -1) : '/';
|
||||
}
|
||||
|
||||
// Is the user trying to link to a php file in this domain and script path?
|
||||
if (strpos($url, '.' . PHP_EXT) !== false && strpos($url, $check_path) !== false)
|
||||
{
|
||||
$server_name = $user->host;
|
||||
$server_name = phpbb::$user->system['host'];
|
||||
|
||||
// Forcing server vars is the only way to specify/override the protocol
|
||||
if (phpbb::$config['force_server_vars'] || !$server_name)
|
||||
@@ -1059,8 +1046,6 @@ class parse_message extends bbcode_firstpass
|
||||
*/
|
||||
function parse($allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post')
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$mode = ($mode != 'post') ? 'sig' : 'post';
|
||||
|
||||
$this->mode = $mode;
|
||||
@@ -1095,7 +1080,7 @@ class parse_message extends bbcode_firstpass
|
||||
|
||||
if ((!$msg_len && $mode !== 'sig') || phpbb::$config['max_' . $mode . '_chars'] && $msg_len > phpbb::$config['max_' . $mode . '_chars'])
|
||||
{
|
||||
$this->warn_msg[] = (!$msg_len) ? $user->lang['TOO_FEW_CHARS'] : sprintf($user->lang['TOO_MANY_CHARS_' . strtoupper($mode)], $msg_len, phpbb::$config['max_' . $mode . '_chars']);
|
||||
$this->warn_msg[] = (!$msg_len) ? phpbb::$user->lang['TOO_FEW_CHARS'] : sprintf(phpbb::$user->lang['TOO_MANY_CHARS_' . strtoupper($mode)], $msg_len, phpbb::$config['max_' . $mode . '_chars']);
|
||||
return (!$update_this_message) ? $return_message : $this->warn_msg;
|
||||
}
|
||||
}
|
||||
@@ -1103,7 +1088,7 @@ class parse_message extends bbcode_firstpass
|
||||
// Check for "empty" message
|
||||
if ($mode !== 'sig' && utf8_clean_string($this->message) === '')
|
||||
{
|
||||
$this->warn_msg[] = $user->lang['TOO_FEW_CHARS'];
|
||||
$this->warn_msg[] = phpbb::$user->lang['TOO_FEW_CHARS'];
|
||||
return (!$update_this_message) ? $return_message : $this->warn_msg;
|
||||
}
|
||||
|
||||
@@ -1152,7 +1137,7 @@ class parse_message extends bbcode_firstpass
|
||||
// Check number of links
|
||||
if (phpbb::$config['max_' . $mode . '_urls'] && $num_urls > phpbb::$config['max_' . $mode . '_urls'])
|
||||
{
|
||||
$this->warn_msg[] = sprintf($user->lang['TOO_MANY_URLS'], phpbb::$config['max_' . $mode . '_urls']);
|
||||
$this->warn_msg[] = sprintf(phpbb::$user->lang['TOO_MANY_URLS'], phpbb::$config['max_' . $mode . '_urls']);
|
||||
return (!$update_this_message) ? $return_message : $this->warn_msg;
|
||||
}
|
||||
|
||||
@@ -1252,7 +1237,6 @@ class parse_message extends bbcode_firstpass
|
||||
*/
|
||||
function smilies($max_smilies = 0)
|
||||
{
|
||||
global $db, $user;
|
||||
static $match;
|
||||
static $replace;
|
||||
|
||||
@@ -1292,7 +1276,7 @@ class parse_message extends bbcode_firstpass
|
||||
|
||||
if ($num_matches !== false && $num_matches > $max_smilies)
|
||||
{
|
||||
$this->warn_msg[] = sprintf($user->lang['TOO_MANY_SMILIES'], $max_smilies);
|
||||
$this->warn_msg[] = sprintf(phpbb::$user->lang['TOO_MANY_SMILIES'], $max_smilies);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1307,8 +1291,6 @@ class parse_message extends bbcode_firstpass
|
||||
*/
|
||||
function parse_attachments($form_name, $mode, $forum_id, $submit, $preview, $refresh, $is_message = false)
|
||||
{
|
||||
global $auth, $user, $db;
|
||||
|
||||
$error = array();
|
||||
|
||||
$num_attachments = sizeof($this->attachment_data);
|
||||
@@ -1358,7 +1340,7 @@ class parse_message extends bbcode_firstpass
|
||||
'thumbnail' => $filedata['thumbnail'],
|
||||
'is_orphan' => 1,
|
||||
'in_message' => ($is_message) ? 1 : 0,
|
||||
'poster_id' => $user->data['user_id'],
|
||||
'poster_id' => phpbb::$user->data['user_id'],
|
||||
);
|
||||
|
||||
$db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
||||
@@ -1388,7 +1370,7 @@ class parse_message extends bbcode_firstpass
|
||||
}
|
||||
else
|
||||
{
|
||||
$error[] = sprintf($user->lang['TOO_MANY_ATTACHMENTS'], $cfg['max_attachments']);
|
||||
$error[] = sprintf(phpbb::$user->lang['TOO_MANY_ATTACHMENTS'], $cfg['max_attachments']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1411,7 +1393,7 @@ class parse_message extends bbcode_firstpass
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id'] . '
|
||||
AND is_orphan = 1
|
||||
AND poster_id = ' . $user->data['user_id'];
|
||||
AND poster_id = ' . phpbb::$user->data['user_id'];
|
||||
$result = $db->sql_query($sql);
|
||||
$row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
@@ -1460,7 +1442,7 @@ class parse_message extends bbcode_firstpass
|
||||
'thumbnail' => $filedata['thumbnail'],
|
||||
'is_orphan' => 1,
|
||||
'in_message' => ($is_message) ? 1 : 0,
|
||||
'poster_id' => $user->data['user_id'],
|
||||
'poster_id' => phpbb::$user->data['user_id'],
|
||||
);
|
||||
|
||||
$db->sql_query('INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
||||
@@ -1479,7 +1461,7 @@ class parse_message extends bbcode_firstpass
|
||||
}
|
||||
else
|
||||
{
|
||||
$error[] = sprintf($user->lang['TOO_MANY_ATTACHMENTS'], $cfg['max_attachments']);
|
||||
$error[] = sprintf(phpbb::$user->lang['TOO_MANY_ATTACHMENTS'], $cfg['max_attachments']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1495,13 +1477,11 @@ class parse_message extends bbcode_firstpass
|
||||
*/
|
||||
function get_submitted_attachment_data($check_user_id = false)
|
||||
{
|
||||
global $user, $db;
|
||||
|
||||
$this->filename_data['filecomment'] = utf8_normalize_nfc(request_var('filecomment', '', true));
|
||||
$attachment_data = phpbb_request::variable('attachment_data', array(0 => array('' => '')), true, phpbb_request::POST);
|
||||
$this->attachment_data = array();
|
||||
|
||||
$check_user_id = ($check_user_id === false) ? $user->data['user_id'] : $check_user_id;
|
||||
$check_user_id = ($check_user_id === false) ? phpbb::$user->data['user_id'] : $check_user_id;
|
||||
|
||||
if (!sizeof($attachment_data))
|
||||
{
|
||||
@@ -1554,7 +1534,7 @@ class parse_message extends bbcode_firstpass
|
||||
$sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment
|
||||
FROM ' . ATTACHMENTS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('attach_id', array_keys($orphan)) . '
|
||||
AND poster_id = ' . $user->data['user_id'] . '
|
||||
AND poster_id = ' . phpbb::$user->data['user_id'] . '
|
||||
AND is_orphan = 1';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -1582,8 +1562,6 @@ class parse_message extends bbcode_firstpass
|
||||
*/
|
||||
function parse_poll(&$poll)
|
||||
{
|
||||
global $auth, $user;
|
||||
|
||||
$poll_max_options = $poll['poll_max_options'];
|
||||
|
||||
// Parse Poll Option text ;)
|
||||
@@ -1606,18 +1584,18 @@ class parse_message extends bbcode_firstpass
|
||||
|
||||
if (!$poll['poll_title'] && $poll['poll_options_size'])
|
||||
{
|
||||
$this->warn_msg[] = $user->lang['NO_POLL_TITLE'];
|
||||
$this->warn_msg[] = phpbb::$user->lang['NO_POLL_TITLE'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (utf8_strlen(preg_replace('#\[\/?[a-z\*\+\-]+(=[\S]+)?\]#ius', ' ', $this->message)) > 100)
|
||||
{
|
||||
$this->warn_msg[] = $user->lang['POLL_TITLE_TOO_LONG'];
|
||||
$this->warn_msg[] = phpbb::$user->lang['POLL_TITLE_TOO_LONG'];
|
||||
}
|
||||
$poll['poll_title'] = $this->parse($poll['enable_bbcode'], (phpbb::$config['allow_post_links']) ? $poll['enable_urls'] : false, $poll['enable_smilies'], $poll['img_status'], false, false, phpbb::$config['allow_post_links'], false);
|
||||
if (strlen($poll['poll_title']) > 255)
|
||||
{
|
||||
$this->warn_msg[] = $user->lang['POLL_TITLE_COMP_TOO_LONG'];
|
||||
$this->warn_msg[] = phpbb::$user->lang['POLL_TITLE_COMP_TOO_LONG'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1627,15 +1605,15 @@ class parse_message extends bbcode_firstpass
|
||||
|
||||
if (sizeof($poll['poll_options']) == 1)
|
||||
{
|
||||
$this->warn_msg[] = $user->lang['TOO_FEW_POLL_OPTIONS'];
|
||||
$this->warn_msg[] = phpbb::$user->lang['TOO_FEW_POLL_OPTIONS'];
|
||||
}
|
||||
else if ($poll['poll_options_size'] > (int) phpbb::$config['max_poll_options'])
|
||||
{
|
||||
$this->warn_msg[] = $user->lang['TOO_MANY_POLL_OPTIONS'];
|
||||
$this->warn_msg[] = phpbb::$user->lang['TOO_MANY_POLL_OPTIONS'];
|
||||
}
|
||||
else if ($poll_max_options > $poll['poll_options_size'])
|
||||
{
|
||||
$this->warn_msg[] = $user->lang['TOO_MANY_USER_OPTIONS'];
|
||||
$this->warn_msg[] = phpbb::$user->lang['TOO_MANY_USER_OPTIONS'];
|
||||
}
|
||||
|
||||
$poll['poll_max_options'] = ($poll['poll_max_options'] < 1) ? 1 : (($poll['poll_max_options'] > phpbb::$config['max_poll_options']) ? phpbb::$config['max_poll_options'] : $poll['poll_max_options']);
|
||||
|
@@ -46,8 +46,6 @@ class fulltext_mysql extends search_backend
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
$result = $db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\'');
|
||||
$info = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
@@ -64,7 +62,7 @@ class fulltext_mysql extends search_backend
|
||||
|
||||
if ($engine != 'MyISAM')
|
||||
{
|
||||
return $user->lang['FULLTEXT_MYSQL_NOT_MYISAM'];
|
||||
return phpbb::$user->lang['FULLTEXT_MYSQL_NOT_MYISAM'];
|
||||
}
|
||||
|
||||
$sql = 'SHOW VARIABLES
|
||||
@@ -250,8 +248,6 @@ class fulltext_mysql extends search_backend
|
||||
*/
|
||||
public function keyword_search($type, &$fields, &$terms, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// No keywords? No posts.
|
||||
if (!$this->search_query)
|
||||
{
|
||||
@@ -409,8 +405,6 @@ class fulltext_mysql extends search_backend
|
||||
*/
|
||||
public function author_search($type, $firstpost_only, &$sort_by_sql, &$sort_key, &$sort_dir, &$sort_days, &$ex_fid_ary, &$m_approve_fid_ary, &$topic_id, &$author_ary, &$id_ary, $start, $per_page)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// No author? No posts.
|
||||
if (!sizeof($author_ary))
|
||||
{
|
||||
@@ -557,8 +551,6 @@ class fulltext_mysql extends search_backend
|
||||
*/
|
||||
public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Split old and new post/subject to obtain array of words
|
||||
$split_text = $this->split_message($message);
|
||||
$split_title = ($subject) ? $this->split_message($subject) : array();
|
||||
@@ -587,8 +579,6 @@ class fulltext_mysql extends search_backend
|
||||
*/
|
||||
public function tidy()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// destroy too old cached search results
|
||||
$this->destroy_cache(array());
|
||||
|
||||
@@ -600,8 +590,6 @@ class fulltext_mysql extends search_backend
|
||||
*/
|
||||
public function create_index($acp_module, $u_action)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Make sure we can actually use MySQL with fulltext indexes
|
||||
if ($error = $this->init())
|
||||
{
|
||||
@@ -647,8 +635,6 @@ class fulltext_mysql extends search_backend
|
||||
*/
|
||||
public function delete_index($acp_module, $u_action)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Make sure we can actually use MySQL with fulltext indexes
|
||||
if ($error = $this->init())
|
||||
{
|
||||
@@ -705,22 +691,18 @@ class fulltext_mysql extends search_backend
|
||||
*/
|
||||
public function index_stats()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if (empty($this->stats))
|
||||
{
|
||||
$this->get_stats();
|
||||
}
|
||||
|
||||
return array(
|
||||
$user->lang['FULLTEXT_MYSQL_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0,
|
||||
phpbb::$user->lang['FULLTEXT_MYSQL_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0,
|
||||
);
|
||||
}
|
||||
|
||||
private function get_stats()
|
||||
{
|
||||
global $db;
|
||||
|
||||
if ($db->dbms_type !== 'mysql')
|
||||
{
|
||||
$this->stats = array();
|
||||
@@ -766,8 +748,6 @@ class fulltext_mysql extends search_backend
|
||||
*/
|
||||
function acp()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$tpl = '';
|
||||
|
||||
// These are fields required in the config table
|
||||
|
Reference in New Issue
Block a user