- changed SUPER_MODERATORS to GLOBAL_MODERATORS

- do not cache moderators having no allowed auth settings
- added fsock method to transfer class (this has been made by wGEric for us)


git-svn-id: file:///svn/phpbb/trunk@5870 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2006-04-30 14:09:13 +00:00
parent e69278b5cd
commit 3536a60e10
7 changed files with 317 additions and 7 deletions

View file

@ -101,9 +101,7 @@ $m_permissions = array(
$a_permissions = array(
'a_' => array(0, 1),
'a_server' => array(0, 1),
'a_defaults'=> array(0, 1),
'a_board' => array(0, 1),
'a_cookies' => array(0, 1),
'a_clearlogs' => array(0, 1),
'a_words' => array(0, 1),
'a_icons' => array(0, 1),
@ -219,7 +217,7 @@ foreach ($prefixes as $prefix)
mass_auth('group', 0, 'inactive_coppa', $auth_option, ACL_NO);
mass_auth('group', 0, 'registered_coppa', $auth_option, ACL_NO);
mass_auth('group', 0, 'registered', $auth_option, (($prefix != 'm_' && $prefix != 'a_') ? ACL_YES : ACL_NO));
mass_auth('group', 0, 'super_moderators', $auth_option, (($prefix != 'a_') ? ACL_YES : ACL_NO));
mass_auth('group', 0, 'global_moderators', $auth_option, (($prefix != 'a_') ? ACL_YES : ACL_NO));
mass_auth('group', 0, 'administrators', $auth_option, ACL_YES);
mass_auth('group', 0, 'bots', $auth_option, (($prefix != 'm_' && $prefix != 'a_') ? ACL_YES : ACL_NO));
}

View file

@ -1812,6 +1812,22 @@ function cache_moderators()
{
foreach ($forum_id_ary as $forum_id => $auth_ary)
{
$flag = false;
foreach ($auth_ary as $auth_option => $setting)
{
// Make sure at least one ACL_YES option is set...
if ($setting == ACL_YES)
{
$flag = true;
break;
}
}
if (!$flag)
{
continue;
}
$sql_ary[] = array(
'forum_id' => $forum_id,
'user_id' => 0,

View file

@ -212,12 +212,18 @@ class transfer
function methods()
{
$methods = array();
$disabled_functions = explode(',', @ini_get('disable_functions'));
if (@extension_loaded('ftp'))
{
$methods[] = 'ftp';
}
if (!in_array('fsockopen', $disabled_functions))
{
$methods[] = 'ftp_fsock';
}
return $methods;
}
}
@ -419,4 +425,293 @@ class ftp extends transfer
}
}
/**
* @package phpBB3
* FTP fsock transfer class
* @author wGEric
*/
class ftp_fsock extends transfer
{
var $data_connection;
/**
* Standard parameters for FTP session
*/
function ftp_fsock($host, $username, $password, $root_path, $port = 21, $timeout = 10)
{
$this->host = $host;
$this->port = $port;
$this->username = $username;
$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 (prefixed with / and no / at the end)
$this->root_path = str_replace('\\', '/', $this->root_path);
$this->root_path = (($root_path{0} != '/' ) ? '/' : '') . ((substr($root_path, -1, 1) == '/') ? substr($root_path, 0, -1) : $root_path);
// Init some needed values
transfer::transfer();
return;
}
/**
* Requests data
*/
function data()
{
global $user;
return array('host' => 'localhost' , 'username' => 'anonymous', 'password' => '', 'root_path' => $user->page['root_script_path'], 'port' => 21, 'timeout' => 10);
}
/**
* Init FTP Session
*/
function _init()
{
$errno = 0;
$errstr = '';
// connect to the server
$this->connection = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
if (!$this->connection || !$this->_check_command())
{
return false;
}
@stream_set_timeout($this->connection, $this->timeout);
// login
if (!$this->_send_command('USER', $this->username))
{
return false;
}
if (!$this->_send_command('PASS', $this->password))
{
return false;
}
// change to the root directory
if (!$this->_chdir($this->root_path))
{
return 'Unable to change directory';
}
return true;
}
/**
* Create Directory (MKDIR)
*/
function _mkdir($dir)
{
return $this->_send_command('MKD', $dir);
}
/**
* Remove directory (RMDIR)
*/
function _rmdir($dir)
{
return $this->_send_command('RMD', $dir);
}
/**
* Change current working directory (CHDIR)
*/
function _chdir($dir = '')
{
if (substr($dir, -1, 1) == '/')
{
$dir = substr($dir, 0, -1);
}
return $this->_send_command('CWD', $dir);
}
/**
* change file permissions (CHMOD)
*/
function _chmod($file, $perms)
{
return $this->_send_command('SITE CHMOD', $perms . ' ' . $file);;
}
/**
* Upload file to location (PUT)
*/
function _put($from_file, $to_file)
{
// We only use the BINARY file mode to cicumvent rewrite actions from ftp server (mostly linefeeds being replaced)
// 'I' == BINARY
// 'A' == ASCII
if (!$this->_send_command('TYPE', 'I'))
{
return false;
}
$this->_putcmd('STOR', $to_file, false);
// open the connection to send file over
if (!$this->_open_data_connection())
{
return false;
}
// send the file
$fp = @fopen($from_file, 'rb');
while (!@feof($fp))
{
@fwrite($$this->data_connection, @fread($fp, 4096));
}
@fclose($fp);
// close connection
$this->_close_data_connection();
return $this->_check_command();
}
/**
* Delete file (DELETE)
*/
function _delete($file)
{
return $this->_send_command('DELE', $file);
}
/**
* Close ftp session (CLOSE)
*/
function _close()
{
if (!$this->connection)
{
return false;
}
return $this->_send_command('QUIT');
}
/**
* Return current working directory (CWD)
* At the moment not used by parent class
*/
function _cwd()
{
$this->_send_command('PWD', '', false);
return preg_replace('#^[0-9]{3} "(.+)" .+\r\n#', '\\1', $this->_check_command(true));
}
/**
* Return list of files in a given directory (LS)
* At the moment not used by parent class
*/
function _ls($dir = './')
{
if (!$this->_open_data_connection())
{
return false;
}
$this->_send_command('NLST', $dir);
$list = array();
while (!@feof($this->data_connection))
{
$list[] = preg_replace('#[\r\n]#', '', @fgets($this->data_connection, 512));
}
$this->_close_data_connection();
return $list;
}
/**
* Send a command to server (FTP fsock only function)
*/
function _send_command($command, $args = '', $check = true)
{
if (!empty($args))
{
$command = "$command $args";
}
fwrite($this->connection, $command . "\r\n");
if ($check === true && !$this->_check_command())
{
return false;
}
return true;
}
/**
* Opens a connection to send data (FTP fosck only function)
*/
function _open_data_connection()
{
$this->_send_command('PASV', '', false);
if (!$ip_port = $this->_check_command(true))
{
return false;
}
// open the connection to start sending the file
if (!preg_match('#[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+#', $ip_port, $temp))
{
// bad ip and port
return false;
}
$temp = explode(',', $temp[0]);
$server_ip = $temp[0] . '.' . $temp[1] . '.' . $temp[2] . '.' . $temp[3];
$server_port = $temp[4] * 256 + $temp[5];
$errno = 0;
$errstr = '';
if (!$this->data_connection = @fsockopen($server_ip, $server_port, $errno, $errstr, $this->timeout))
{
return false;
}
@stream_set_timeout($$this->data_connection, $this->timeout);
return true;
}
/**
* Closes a connection used to send data
*/
function _close_data_connection()
{
return @fclose($this->data_connecton);
}
/**
* Check to make sure command was successful (FTP fsock only function)
*/
function _check_command($return = false)
{
$response = '';
do
{
$result = @fgets($this->connection, 512);
$response .= $result;
}
while (substr($response, 3, 1) != ' ');
if (!preg_match('#^[123]#', $response))
{
return false;
}
return ($return) ? $response : true;
}
}
?>

View file

@ -1417,7 +1417,7 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
{
global $db, $auth;
$group_order = array('ADMINISTRATORS', 'SUPER_MODERATORS', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS');
$group_order = array('ADMINISTRATORS', 'GLOBAL_MODERATORS', 'REGISTERED_COPPA', 'REGISTERED', 'BOTS', 'GUESTS');
// We need both username and user_id info
user_get_id_name($user_id_ary, $username_ary);

View file

@ -417,7 +417,7 @@ INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, gr
INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('INACTIVE_COPPA', 3, '', 0, '', '', '');
INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('REGISTERED', 3, '', 0, '', '', '');
INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('REGISTERED_COPPA', 3, '', 0, '', '', '');
INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('SUPER_MODERATORS', 3, '00AA00', 0, '', '', '');
INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('GLOBAL_MODERATORS', 3, '00AA00', 0, '', '', '');
INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('ADMINISTRATORS', 3, 'AA0000', 1, '', '', '');
INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('BOTS', 3, '9E8DA7', 1, '', '', '');
@ -671,7 +671,7 @@ INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting)
INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting) SELECT 7, 1, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_option IN ('f_poll', 'f_announce', 'f_sticky', 'f_attach');
INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting) SELECT 7, 2, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_option IN ('f_poll', 'f_announce', 'f_sticky', 'f_attach');
# SUPER MODERATOR group - moderator rights
# GLOBAL MODERATOR group - moderator rights
INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting) SELECT 6, 0, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_option LIKE 'u_%' AND auth_option NOT IN ('u_chggrp', 'u_chgname');
INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_setting) SELECT 6, 0, auth_option_id, 1 FROM phpbb_auth_options WHERE auth_option LIKE 'm_%';

View file

@ -395,6 +395,7 @@ $lang = array_merge($lang, array(
'LOG_CONFIG_SEARCH' => '<b>Altered search settings</b>',
'LOG_CONFIG_SERVER' => '<b>Altered server settings</b>',
'LOG_CONFIG_SETTINGS' => '<b>Altered board settings</b>',
'LOG_CONFIG_VISUAL' => '<b>Altered visual confirmation settings</b>',
'LOG_DISALLOW_ADD' => '<b>Added disallowed username</b><br />&#187; %s',
'LOG_DISALLOW_DELETE' => '<b>Deleted disallowed username</b>',

View file

@ -189,7 +189,7 @@ $lang = array_merge($lang, array(
'G_INACTIVE_COPPA' => 'Unapproved COPPA Users',
'G_REGISTERED' => 'Registered Users',
'G_REGISTERED_COPPA' => 'Registered COPPA Users',
'G_SUPER_MODERATORS' => 'Super Moderators',
'G_GLOBAL_MODERATORS' => 'Global Moderators',
'HIDDEN_USERS_ONLINE' => '%d Hidden users online',
'HIDDEN_USERS_TOTAL' => '%d Hidden and ',