1
0
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:
SteveD
2013-02-13 22:34:06 +00:00
parent bcaf4e70c6
commit b9a452e793
3 changed files with 875 additions and 871 deletions

View File

@@ -2,7 +2,7 @@
/* /*
* e107 website system * 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 * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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 class eIPHandler
{ {
@@ -271,8 +270,8 @@ class eIPHandler
if ($ip == 'ff02:0000:0000:0000:0000:0000:0000:0001') return FALSE; if ($ip == 'ff02:0000:0000:0000:0000:0000:0000:0001') return FALSE;
if ($ip == '::1') return FALSE; // localhost if ($ip == '::1') return FALSE; // localhost
if ($ip == '0000:0000:0000:0000:0000:0000:0000:0001') return FALSE; if ($ip == '0000:0000:0000:0000:0000:0000:0000:0001') return FALSE;
if (substr($ip, 0, 5) == 'fc00:') return FALSE; // local addresses
// @todo add: // @todo add:
// fc00::/7 - local addresses
// ::0 (all zero) - invalid // ::0 (all zero) - invalid
// ff02::1:ff00:0/104 - Solicited-Node multicast addresses - add? // ff02::1:ff00:0/104 - Solicited-Node multicast addresses - add?
// 2001:0000::/29 through 2001:01f8::/29 - special purpose addresses // 2001:0000::/29 through 2001:01f8::/29 - special purpose addresses
@@ -717,7 +716,7 @@ class eIPHandler
*/ */
function makeDomainQuery($email, $fieldName = 'banlist_ip') function makeDomainQuery($email, $fieldName = 'banlist_ip')
{ {
global $tp; $tp = e107::getParser();
if (($tv = strrpos('@', $email)) !== FALSE) if (($tv = strrpos('@', $email)) !== FALSE)
{ {
$email = substr($email, $tv+1); $email = substr($email, $tv+1);
@@ -852,8 +851,8 @@ class eIPHandler
$sql = e107::getDb(); $sql = e107::getDb();
$pref = e107::getPref(); $pref = e107::getPref();
$tp = e107::getParser(); $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); //$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')) if ($sql->db_Select('banlist', '*', $query.' ORDER BY `banlist_bantype` DESC'))
{ {

View File

@@ -2,7 +2,7 @@
/* /*
* e107 website system * 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 * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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'); define('e_SAVE_FILETYPES', 'filetypes_.xml');
/** /**
File upload handler - this is the preferred interface for new code * File upload handler - this is the preferred interface for new code
------------------- *
function process_uploaded_files($uploaddir, $fileinfo = FALSE, $options = array()) * Routine processes the array of uploaded files according to both specific options set by the caller, and
Parameters: * system options configured by the main admin.
@param string $uploaddir - target directory (checked that it exists, but path not otherwise changed) *
* function process_uploaded_files($uploaddir, $fileinfo = FALSE, $options = array())
@param string $fileinfo - determines any special handling of file name (combines previous $fileinfo and $avatar parameters): * Parameters:
FALSE - default option; no processing * @param string $uploaddir - target directory (checked that it exists, but path not otherwise changed)
"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). * @param string $fileinfo - determines any special handling of file name (combines previous $fileinfo and $avatar parameters):
"prefix+extra_text" - indicates an attachment or file, and specifies some optional text which is prefixed to the file name * FALSE - default option; no processing
"unique" * "attachment+extra_text" - indicates an attachment (related to forum post or PM), and specifies some optional text which is
- if the proposed destination file doesn't exist, saved under given name * incorporated into the final file name (the original $fileinfo parameter).
- if the proposed destination file does exist, prepends time() to the file name to make it unique * "prefix+extra_text" - indicates an attachment or file, and specifies some optional text which is prefixed to the file name
'avatar' * "unique"
- indicates an avatar is being uploaded (not used - options must be set elsewhere) * - 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
@param array $options - an array of supplementary options, all of which will be given appropriate defaults if not defined: * 'avatar'
'filetypes' - name of file containing list of valid file types * - indicates an avatar is being uploaded (not used - options must be set elsewhere)
- 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. * @param array $options - an array of supplementary options, all of which will be given appropriate defaults if not defined:
- FALSE disables this option (which implies that 'extra_file_types' is used) * 'filetypes' - name of file containing list of valid file types
'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 * - Always looks in the admin directory
file specified by the 'filetypes' option. Enables restriction to, for example, image files. * - defaults to e_ADMIN.filetypes.xml, else e_ADMIN.admin_filetypes.php for admins (if file exists), otherwise e_ADMIN.filetypes.php for users.
'extra_file_types' - if is FALSE or undefined, rejects totally unknown file extensions (even if in $options['filetypes'] file). * - FALSE disables this option (which implies that 'extra_file_types' is used)
if TRUE, accepts totally unknown file extensions which are in $options['filetypes'] file. * '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
otherwise specifies a comma-separated list of additional permitted file extensions * file specified by the 'filetypes' option. Enables restriction to, for example, image files.
'final_chmod' - chmod() to be applied to uploaded files (0644 default) (This routine expects an integer value, so watch formatting/decoding - its normally * 'extra_file_types' - if is FALSE or undefined, rejects totally unknown file extensions (even if in $options['filetypes'] file).
specified in octal. Typically use intval($permissions,8) to convert) * if TRUE, accepts totally unknown file extensions which are in $options['filetypes'] file.
'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 specifies a comma-separated list of additional permitted file extensions
- otherwise uses $pref['upload_maxfilesize'] if set * 'final_chmod' - chmod() to be applied to uploaded files (0644 default) (This routine expects an integer value, so watch formatting/decoding - its normally
- overriding limit of the smaller of 'post_max_size' and 'upload_max_size' if set in php.ini * specified in octal. Typically use intval($permissions,8) to convert)
(Note: other parts of E107 don't understand strings with a multiplier letter yet) * 'max_upload_size' - maximum size of uploaded files in bytes, or as a string with a 'multiplier' letter (e.g. 16M) at the end.
'file_array_name' - the name of the 'input' array - defaults to file_userfile[] - otherwise as set. * - otherwise uses $pref['upload_maxfilesize'] if set
'max_file_count' - maximum number of files which can be uploaded - default is 'unlimited' if this is zero or not set. * - overriding limit of the smaller of 'post_max_size' and 'upload_max_size' if set in php.ini
'overwrite' - if TRUE, existing file of the same name is overwritten; otherwise returns 'duplicate file' error (default FALSE) * (Note: other parts of E107 don't understand strings with a multiplier letter yet)
'save_to_db' - [obsolete] storage type - if set and TRUE, uploaded files were saved in the database (rather than as flat files) * '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.
@return boolean|array * 'overwrite' - if TRUE, existing file of the same name is overwritten; otherwise returns 'duplicate file' error (default FALSE)
Returns FALSE if the upload directory doesn't exist, or various other errors occurred which restrict the amount of meaningful information. * 'save_to_db' - [obsolete] storage type - if set and TRUE, uploaded files were saved in the database (rather than as flat files)
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: * @return boolean|array
$uploaded[$c]['name'] - file name - as saved to disc * Returns FALSE if the upload directory doesn't exist, or various other errors occurred which restrict the amount of meaningful information.
$uploaded[$c]['rawname'] - original file name, prior to any addition of identifiers etc (useful for display purposes) * Returns an array, with one set of entries per uploaded file, regardless of whether saved or
$uploaded[$c]['type'] - mime type (if set - as sent by browser) * discarded (not all fields always present) - $c is array index:
$uploaded[$c]['size'] - size in bytes (should be zero if error) * $uploaded[$c]['name'] - file name - as saved to disc
$uploaded[$c]['error'] - numeric error code (zero = OK) * $uploaded[$c]['rawname'] - original file name, prior to any addition of identifiers etc (useful for display purposes)
$uploaded[$c]['index'] - if upload successful, the index position from the file_userfile[] array - usually numeric, but may be alphanumeric if coded * $uploaded[$c]['type'] - mime type (if set - as sent by browser)
$uploaded[$c]['message'] - text of displayed message relating to file * $uploaded[$c]['size'] - size in bytes (should be zero if error)
$uploaded[$c]['line'] - only if an error occurred, has line number (from __LINE__) * $uploaded[$c]['error'] - numeric error code (zero = OK)
$uploaded[$c]['file'] - only if an error occurred, has file name (from __FILE__) * $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
On exit, uploaded files should all have been removed from the temporary directory. * $uploaded[$c]['line'] - only if an error occurred, has line number (from __LINE__)
No messages displayed - its caller's responsibility to handle errors and display info to * $uploaded[$c]['file'] - only if an error occurred, has file name (from __FILE__)
user (or can use handle_upload_messages() from this module) *
* On exit, uploaded files should all have been removed from the temporary directory.
Details of uploaded files are in $_FILES['file_userfile'] (or other array name as set) on entry. * No messages displayed - its caller's responsibility to handle errors and display info to
Elements passed (from PHP) relating to each file: * user (or can use handle_upload_messages() from this module)
['name'] - the original name *
['type'] - mime type (if provided - not checked by PHP) * Details of uploaded files are in $_FILES['file_userfile'] (or other array name as set) on entry.
['size'] - file size in bytes * Elements passed (from PHP) relating to each file:
['tmp_name'] - temporary file name on server * ['name'] - the original name
['error'] - error code. 0 = 'good'. 1..4 main others, although up to 8 defined for later PHP versions * ['type'] - mime type (if provided - not checked by PHP)
Files stored in server's temporary directory, unless another set * ['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) function process_uploaded_files($uploaddir, $fileinfo = FALSE, $options = NULL)
{ {
global $admin_log; $admin_log = e107::getAdminLog();
$ul_temp_dir = ''; $ul_temp_dir = '';
if (ini_get('open_basedir') != '') 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 = "") function file_upload($uploaddir, $avatar = FALSE, $fileinfo = "", $overwrite = "")
{ {
global $admin_log; $admin_log = e107::getAdminLog();
$options = array( $options = array(
'extra_file_types'=>TRUE 'extra_file_types'=>TRUE
); // As default, allow any filetype enabled in filetypes.php ); // 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) function calc_max_upload_size($max_up = -1)
{ {
global $pref,$admin_log; global $pref;
$admin_log = e107::getAdminLog();
// Work out maximum allowable file size // Work out maximum allowable file size
if (UH_DEBUG) if (UH_DEBUG)
{ {

View File

@@ -2,7 +2,7 @@
/* /*
* e107 website system * 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 * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 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) function get_forum_stats($get_stats=true)
{ {
global $sql; $sql = e107::getDb();
if(!e107::isInstalled('forum')) if(!e107::isInstalled('forum'))
return array(); return array();
@@ -204,7 +204,7 @@ class login_menu_class
function get_chatbox_menu_stats() function get_chatbox_menu_stats()
{ {
global $sql; $sql = e107::getDb();
if(!e107::isInstalled('chatbox_menu')) if(!e107::isInstalled('chatbox_menu'))
return array(); 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) function get_plugin_data($plugid)
{ {
if(($tmp = getcachedvars('loginbox_eplug_data_'.$plugid)) !== FALSE) return $tmp; if(($tmp = getcachedvars('loginbox_eplug_data_'.$plugid)) !== FALSE) return $tmp;
$ret = array(); $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'); require_once(e_HANDLER.'xml_class.php');
$xml = new xmlClass; $xml = new xmlClass;