mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 03:40:37 +02:00
Minor tidying - lose a few globals, a few 'todos'
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright 2008-2011 e107 Inc (e107.org)
|
||||
* Copyright 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
@@ -58,7 +58,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// define("BAN_TYPE_LEGACY",0); // Quick fix for PHP Notice. If the error is triggered from somewhere else, the class name needs adding - eIPHandler::BAN_TYPE_LEGACY
|
||||
|
||||
class eIPHandler
|
||||
{
|
||||
@@ -271,8 +270,8 @@ class eIPHandler
|
||||
if ($ip == 'ff02:0000:0000:0000:0000:0000:0000:0001') return FALSE;
|
||||
if ($ip == '::1') return FALSE; // localhost
|
||||
if ($ip == '0000:0000:0000:0000:0000:0000:0000:0001') return FALSE;
|
||||
if (substr($ip, 0, 5) == 'fc00:') return FALSE; // local addresses
|
||||
// @todo add:
|
||||
// fc00::/7 - local addresses
|
||||
// ::0 (all zero) - invalid
|
||||
// ff02::1:ff00:0/104 - Solicited-Node multicast addresses - add?
|
||||
// 2001:0000::/29 through 2001:01f8::/29 - special purpose addresses
|
||||
@@ -717,7 +716,7 @@ class eIPHandler
|
||||
*/
|
||||
function makeDomainQuery($email, $fieldName = 'banlist_ip')
|
||||
{
|
||||
global $tp;
|
||||
$tp = e107::getParser();
|
||||
if (($tv = strrpos('@', $email)) !== FALSE)
|
||||
{
|
||||
$email = substr($email, $tv+1);
|
||||
@@ -852,8 +851,8 @@ class eIPHandler
|
||||
$sql = e107::getDb();
|
||||
$pref = e107::getPref();
|
||||
$tp = e107::getParser();
|
||||
$admin_log = e107::getAdminLog();
|
||||
|
||||
//global $admin_log;
|
||||
//$admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"DBG","Check for Ban",$query,FALSE,LOG_TO_ROLLING);
|
||||
if ($sql->db_Select('banlist', '*', $query.' ORDER BY `banlist_bantype` DESC'))
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
@@ -42,75 +42,77 @@ define('e_READ_FILETYPES', 'filetypes.xml'); // Upload permissions
|
||||
define('e_SAVE_FILETYPES', 'filetypes_.xml');
|
||||
|
||||
/**
|
||||
File upload handler - this is the preferred interface for new code
|
||||
-------------------
|
||||
function process_uploaded_files($uploaddir, $fileinfo = FALSE, $options = array())
|
||||
Parameters:
|
||||
@param string $uploaddir - target directory (checked that it exists, but path not otherwise changed)
|
||||
|
||||
@param string $fileinfo - determines any special handling of file name (combines previous $fileinfo and $avatar parameters):
|
||||
FALSE - default option; no processing
|
||||
"attachment+extra_text" - indicates an attachment (related to forum post or PM), and specifies some optional text which is
|
||||
incorporated into the final file name (the original $fileinfo parameter).
|
||||
"prefix+extra_text" - indicates an attachment or file, and specifies some optional text which is prefixed to the file name
|
||||
"unique"
|
||||
- if the proposed destination file doesn't exist, saved under given name
|
||||
- if the proposed destination file does exist, prepends time() to the file name to make it unique
|
||||
'avatar'
|
||||
- indicates an avatar is being uploaded (not used - options must be set elsewhere)
|
||||
|
||||
@param array $options - an array of supplementary options, all of which will be given appropriate defaults if not defined:
|
||||
'filetypes' - name of file containing list of valid file types
|
||||
- Always looks in the admin directory
|
||||
- defaults to e_ADMIN.filetypes.xml, else e_ADMIN.admin_filetypes.php for admins (if file exists), otherwise e_ADMIN.filetypes.php for users.
|
||||
- FALSE disables this option (which implies that 'extra_file_types' is used)
|
||||
'file_mask' - comma-separated list of file types which if defined limits the allowed file types to those which are in both this list and the
|
||||
file specified by the 'filetypes' option. Enables restriction to, for example, image files.
|
||||
'extra_file_types' - if is FALSE or undefined, rejects totally unknown file extensions (even if in $options['filetypes'] file).
|
||||
if TRUE, accepts totally unknown file extensions which are in $options['filetypes'] file.
|
||||
otherwise specifies a comma-separated list of additional permitted file extensions
|
||||
'final_chmod' - chmod() to be applied to uploaded files (0644 default) (This routine expects an integer value, so watch formatting/decoding - its normally
|
||||
specified in octal. Typically use intval($permissions,8) to convert)
|
||||
'max_upload_size' - maximum size of uploaded files in bytes, or as a string with a 'multiplier' letter (e.g. 16M) at the end.
|
||||
- otherwise uses $pref['upload_maxfilesize'] if set
|
||||
- overriding limit of the smaller of 'post_max_size' and 'upload_max_size' if set in php.ini
|
||||
(Note: other parts of E107 don't understand strings with a multiplier letter yet)
|
||||
'file_array_name' - the name of the 'input' array - defaults to file_userfile[] - otherwise as set.
|
||||
'max_file_count' - maximum number of files which can be uploaded - default is 'unlimited' if this is zero or not set.
|
||||
'overwrite' - if TRUE, existing file of the same name is overwritten; otherwise returns 'duplicate file' error (default FALSE)
|
||||
'save_to_db' - [obsolete] storage type - if set and TRUE, uploaded files were saved in the database (rather than as flat files)
|
||||
|
||||
@return boolean|array
|
||||
Returns FALSE if the upload directory doesn't exist, or various other errors occurred which restrict the amount of meaningful information.
|
||||
Returns an array, with one set of entries per uploaded file, regardless of whether saved or
|
||||
discarded (not all fields always present) - $c is array index:
|
||||
$uploaded[$c]['name'] - file name - as saved to disc
|
||||
$uploaded[$c]['rawname'] - original file name, prior to any addition of identifiers etc (useful for display purposes)
|
||||
$uploaded[$c]['type'] - mime type (if set - as sent by browser)
|
||||
$uploaded[$c]['size'] - size in bytes (should be zero if error)
|
||||
$uploaded[$c]['error'] - numeric error code (zero = OK)
|
||||
$uploaded[$c]['index'] - if upload successful, the index position from the file_userfile[] array - usually numeric, but may be alphanumeric if coded
|
||||
$uploaded[$c]['message'] - text of displayed message relating to file
|
||||
$uploaded[$c]['line'] - only if an error occurred, has line number (from __LINE__)
|
||||
$uploaded[$c]['file'] - only if an error occurred, has file name (from __FILE__)
|
||||
|
||||
On exit, uploaded files should all have been removed from the temporary directory.
|
||||
No messages displayed - its caller's responsibility to handle errors and display info to
|
||||
user (or can use handle_upload_messages() from this module)
|
||||
|
||||
Details of uploaded files are in $_FILES['file_userfile'] (or other array name as set) on entry.
|
||||
Elements passed (from PHP) relating to each file:
|
||||
['name'] - the original name
|
||||
['type'] - mime type (if provided - not checked by PHP)
|
||||
['size'] - file size in bytes
|
||||
['tmp_name'] - temporary file name on server
|
||||
['error'] - error code. 0 = 'good'. 1..4 main others, although up to 8 defined for later PHP versions
|
||||
Files stored in server's temporary directory, unless another set
|
||||
* File upload handler - this is the preferred interface for new code
|
||||
*
|
||||
* Routine processes the array of uploaded files according to both specific options set by the caller, and
|
||||
* system options configured by the main admin.
|
||||
*
|
||||
* function process_uploaded_files($uploaddir, $fileinfo = FALSE, $options = array())
|
||||
* Parameters:
|
||||
* @param string $uploaddir - target directory (checked that it exists, but path not otherwise changed)
|
||||
*
|
||||
* @param string $fileinfo - determines any special handling of file name (combines previous $fileinfo and $avatar parameters):
|
||||
* FALSE - default option; no processing
|
||||
* "attachment+extra_text" - indicates an attachment (related to forum post or PM), and specifies some optional text which is
|
||||
* incorporated into the final file name (the original $fileinfo parameter).
|
||||
* "prefix+extra_text" - indicates an attachment or file, and specifies some optional text which is prefixed to the file name
|
||||
* "unique"
|
||||
* - if the proposed destination file doesn't exist, saved under given name
|
||||
* - if the proposed destination file does exist, prepends time() to the file name to make it unique
|
||||
* 'avatar'
|
||||
* - indicates an avatar is being uploaded (not used - options must be set elsewhere)
|
||||
*
|
||||
* @param array $options - an array of supplementary options, all of which will be given appropriate defaults if not defined:
|
||||
* 'filetypes' - name of file containing list of valid file types
|
||||
* - Always looks in the admin directory
|
||||
* - defaults to e_ADMIN.filetypes.xml, else e_ADMIN.admin_filetypes.php for admins (if file exists), otherwise e_ADMIN.filetypes.php for users.
|
||||
* - FALSE disables this option (which implies that 'extra_file_types' is used)
|
||||
* 'file_mask' - comma-separated list of file types which if defined limits the allowed file types to those which are in both this list and the
|
||||
* file specified by the 'filetypes' option. Enables restriction to, for example, image files.
|
||||
* 'extra_file_types' - if is FALSE or undefined, rejects totally unknown file extensions (even if in $options['filetypes'] file).
|
||||
* if TRUE, accepts totally unknown file extensions which are in $options['filetypes'] file.
|
||||
* otherwise specifies a comma-separated list of additional permitted file extensions
|
||||
* 'final_chmod' - chmod() to be applied to uploaded files (0644 default) (This routine expects an integer value, so watch formatting/decoding - its normally
|
||||
* specified in octal. Typically use intval($permissions,8) to convert)
|
||||
* 'max_upload_size' - maximum size of uploaded files in bytes, or as a string with a 'multiplier' letter (e.g. 16M) at the end.
|
||||
* - otherwise uses $pref['upload_maxfilesize'] if set
|
||||
* - overriding limit of the smaller of 'post_max_size' and 'upload_max_size' if set in php.ini
|
||||
* (Note: other parts of E107 don't understand strings with a multiplier letter yet)
|
||||
* 'file_array_name' - the name of the 'input' array - defaults to file_userfile[] - otherwise as set.
|
||||
* 'max_file_count' - maximum number of files which can be uploaded - default is 'unlimited' if this is zero or not set.
|
||||
* 'overwrite' - if TRUE, existing file of the same name is overwritten; otherwise returns 'duplicate file' error (default FALSE)
|
||||
* 'save_to_db' - [obsolete] storage type - if set and TRUE, uploaded files were saved in the database (rather than as flat files)
|
||||
*
|
||||
* @return boolean|array
|
||||
* Returns FALSE if the upload directory doesn't exist, or various other errors occurred which restrict the amount of meaningful information.
|
||||
* Returns an array, with one set of entries per uploaded file, regardless of whether saved or
|
||||
* discarded (not all fields always present) - $c is array index:
|
||||
* $uploaded[$c]['name'] - file name - as saved to disc
|
||||
* $uploaded[$c]['rawname'] - original file name, prior to any addition of identifiers etc (useful for display purposes)
|
||||
* $uploaded[$c]['type'] - mime type (if set - as sent by browser)
|
||||
* $uploaded[$c]['size'] - size in bytes (should be zero if error)
|
||||
* $uploaded[$c]['error'] - numeric error code (zero = OK)
|
||||
* $uploaded[$c]['index'] - if upload successful, the index position from the file_userfile[] array - usually numeric, but may be alphanumeric if coded
|
||||
* $uploaded[$c]['message'] - text of displayed message relating to file
|
||||
* $uploaded[$c]['line'] - only if an error occurred, has line number (from __LINE__)
|
||||
* $uploaded[$c]['file'] - only if an error occurred, has file name (from __FILE__)
|
||||
*
|
||||
* On exit, uploaded files should all have been removed from the temporary directory.
|
||||
* No messages displayed - its caller's responsibility to handle errors and display info to
|
||||
* user (or can use handle_upload_messages() from this module)
|
||||
*
|
||||
* Details of uploaded files are in $_FILES['file_userfile'] (or other array name as set) on entry.
|
||||
* Elements passed (from PHP) relating to each file:
|
||||
* ['name'] - the original name
|
||||
* ['type'] - mime type (if provided - not checked by PHP)
|
||||
* ['size'] - file size in bytes
|
||||
* ['tmp_name'] - temporary file name on server
|
||||
* ['error'] - error code. 0 = 'good'. 1..4 main others, although up to 8 defined for later PHP versions
|
||||
* Files stored in server's temporary directory, unless another set
|
||||
*/
|
||||
|
||||
function process_uploaded_files($uploaddir, $fileinfo = FALSE, $options = NULL)
|
||||
{
|
||||
global $admin_log;
|
||||
$admin_log = e107::getAdminLog();
|
||||
|
||||
$ul_temp_dir = '';
|
||||
if (ini_get('open_basedir') != '')
|
||||
@@ -429,7 +431,7 @@ function handle_upload_messages(&$upload_array, $errors_only = TRUE, $use_handle
|
||||
|
||||
function file_upload($uploaddir, $avatar = FALSE, $fileinfo = "", $overwrite = "")
|
||||
{
|
||||
global $admin_log;
|
||||
$admin_log = e107::getAdminLog();
|
||||
$options = array(
|
||||
'extra_file_types'=>TRUE
|
||||
); // As default, allow any filetype enabled in filetypes.php
|
||||
@@ -748,7 +750,8 @@ function vet_file($filename, $target_name, $allowed_filetypes = '', $unknown = F
|
||||
*/
|
||||
function calc_max_upload_size($max_up = -1)
|
||||
{
|
||||
global $pref,$admin_log;
|
||||
global $pref;
|
||||
$admin_log = e107::getAdminLog();
|
||||
// Work out maximum allowable file size
|
||||
if (UH_DEBUG)
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
@@ -171,7 +171,7 @@ class login_menu_class
|
||||
|
||||
function get_forum_stats($get_stats=true)
|
||||
{
|
||||
global $sql;
|
||||
$sql = e107::getDb();
|
||||
|
||||
if(!e107::isInstalled('forum'))
|
||||
return array();
|
||||
@@ -204,7 +204,7 @@ class login_menu_class
|
||||
|
||||
function get_chatbox_menu_stats()
|
||||
{
|
||||
global $sql;
|
||||
$sql = e107::getDb();
|
||||
|
||||
if(!e107::isInstalled('chatbox_menu'))
|
||||
return array();
|
||||
@@ -339,14 +339,16 @@ class login_menu_class
|
||||
|
||||
|
||||
/**
|
||||
* @todo - $plugin_path is undefined - needs to be obtained from somewhere
|
||||
* Get data for a plugin
|
||||
*
|
||||
* @param string $plugid - name (= base directory) of the required plugin
|
||||
*/
|
||||
function get_plugin_data($plugid)
|
||||
{
|
||||
if(($tmp = getcachedvars('loginbox_eplug_data_'.$plugid)) !== FALSE) return $tmp;
|
||||
|
||||
$ret = array();
|
||||
if (is_readable(e_PLUGIN.vartrue($plugin_path).'/plugin.xml'))
|
||||
if (is_readable(e_PLUGIN.$plugid.'/plugin.xml'))
|
||||
{
|
||||
require_once(e_HANDLER.'xml_class.php');
|
||||
$xml = new xmlClass;
|
||||
|
Reference in New Issue
Block a user