1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +02:00

More work on eUrl

This commit is contained in:
mcfly
2008-11-25 16:26:03 +00:00
parent 52e6697bae
commit b7f0185feb
7 changed files with 241 additions and 200 deletions

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/class2.php,v $ | $Source: /cvs_backup/e107_0.8/class2.php,v $
| $Revision: 1.72 $ | $Revision: 1.73 $
| $Date: 2008-11-24 20:18:59 $ | $Date: 2008-11-25 16:26:02 $
| $Author: secretr $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
// //
@@ -277,17 +277,20 @@ define("MPREFIX", $mySQLprefix);
e107_require_once(e_HANDLER."mysql_class.php"); e107_require_once(e_HANDLER."mysql_class.php");
$sql =& new db; $e107->sql =& new db;
$sql = &$e107->sql;
$sql->db_SetErrorReporting(FALSE); $sql->db_SetErrorReporting(FALSE);
$sql->db_Mark_Time('Start: SQL Connect'); $sql->db_Mark_Time('Start: SQL Connect');
$merror=$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); $merror=$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);
$sql2 =& new db; // create after the initial connection. $sql2 =& new db; // create after the initial connection.
$sql->db_Mark_Time('Start: Prefs, misc tables'); $sql->db_Mark_Time('Start: Prefs, misc tables');
require_once(e_HANDLER.'admin_log_class.php'); require_once(e_HANDLER.'admin_log_class.php');
$admin_log = new e_admin_log(); $e107->admin_log =& new e_admin_log;
$admin_log = &$e107->admin_log;
if ($merror === "e1") { if ($merror === "e1") {
message_handler("CRITICAL_ERROR", 6, ": generic, ", "class2.php"); message_handler("CRITICAL_ERROR", 6, ": generic, ", "class2.php");
@@ -437,7 +440,7 @@ if ($pref['user_tracking'] == "session")
$_SESSION['challenge'] = sha1(time().session_id()); // Create a unique challenge string for CHAP login $_SESSION['challenge'] = sha1(time().session_id()); // Create a unique challenge string for CHAP login
} }
$ubrowser = md5('E107'.$_SERVER['HTTP_USER_AGENT']); $ubrowser = md5('E107'.$_SERVER['HTTP_USER_AGENT']);
if (!isset($_SESSION['ubrowser'])) if (!isset($_SESSION['ubrowser']))
{ {
$_SESSION['ubrowser'] = $ubrowser; $_SESSION['ubrowser'] = $ubrowser;
} }
@@ -563,14 +566,16 @@ e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/".e_LANGUAGE."_custom.php");
$tp->initCharset(); // Now we know the site CHARSET, define how to handle utf-8 as necessary $tp->initCharset(); // Now we know the site CHARSET, define how to handle utf-8 as necessary
if($pref['sitelanguage'] != e_LANGUAGE && isset($pref['multilanguage']) && $pref['multilanguage'] && !$pref['multilanguage_subdomain'])
if($pref['sitelanguage'] != e_LANGUAGE && isset($pref['multilanguage']) && $pref['multilanguage'] && !$pref['multilanguage_subdomain']){ {
list($clc) = explode("_",CORE_LC); list($clc) = explode("_",CORE_LC);
define("e_LAN", strtolower($clc)); define("e_LAN", strtolower($clc));
define("e_LANQRY", "[".e_LAN."]"); define("e_LANQRY", "[".e_LAN."]");
unset($clc); unset($clc);
}else{ }
define("e_LAN", FALSE); else
{
define("e_LAN", FALSE);
define("e_LANQRY", FALSE); define("e_LANQRY", FALSE);
} }
$sql->db_Mark_Time('(Start: Pref/multilang done)'); $sql->db_Mark_Time('(Start: Pref/multilang done)');
@@ -581,13 +586,16 @@ $sql->db_Mark_Time('(Start: Pref/multilang done)');
$sql -> db_Mark_Time('Start: Misc resources. Online user tracking, cache'); $sql -> db_Mark_Time('Start: Misc resources. Online user tracking, cache');
// cache class // cache class
$e107cache = new ecache; $e107->ecache = new ecache;
$e107cache = &$e107->ecache;
e107_require_once(e_HANDLER."override_class.php"); e107_require_once(e_HANDLER."override_class.php");
$override=new override; $e107->override = new override;
$override = &$e107->override;
e107_require_once(e_HANDLER."event_class.php"); e107_require_once(e_HANDLER."event_class.php");
$e_event=new e107_event; $e107->e_event = new e107_event;
$e_event = &$e107->e_event;
if (isset($pref['notify']) && $pref['notify'] == true) { if (isset($pref['notify']) && $pref['notify'] == true) {
e107_require_once(e_HANDLER.'notify_class.php'); e107_require_once(e_HANDLER.'notify_class.php');
@@ -725,13 +733,15 @@ if (!class_exists('e107_table')) {
} }
//############################################################# //#############################################################
$ns=new e107table;
$e107->ns = new e107table;
$ns = &$e107->ns;
$e107->ban(); $e107->ban();
if(varset($pref['force_userupdate']) && USER && !isset($_E107['no_forceuserupdate'])) if(varset($pref['force_userupdate']) && USER && !isset($_E107['no_forceuserupdate']))
{ {
if(force_userupdate()) if(force_userupdate())
{ {
header("Location: ".e_BASE."usersettings.php?update"); header("Location: ".e_BASE."usersettings.php?update");
exit(); exit();
@@ -784,14 +794,14 @@ if ($pref['maintainance_flag'] && ADMIN == FALSE && strpos(e_SELF, "admin.php")
$sql->db_Mark_Time('(Start: Login/logout/ban/tz)'); $sql->db_Mark_Time('(Start: Login/logout/ban/tz)');
if (isset($_POST['userlogin']) || isset($_POST['userlogin_x'])) if (isset($_POST['userlogin']) || isset($_POST['userlogin_x']))
{ {
e107_require_once(e_HANDLER."login.php"); e107_require_once(e_HANDLER."login.php");
$usr = new userlogin($_POST['username'], $_POST['userpass'], $_POST['autologin'],varset($_POST['hashchallenge'],'')); $usr = new userlogin($_POST['username'], $_POST['userpass'], $_POST['autologin'],varset($_POST['hashchallenge'],''));
} }
if ((e_QUERY == 'logout') || (($pref['user_tracking'] == "session") && isset($_SESSION['ubrowser']) && ($_SESSION['ubrowser'] != $ubrowser))) if ((e_QUERY == 'logout') || (($pref['user_tracking'] == "session") && isset($_SESSION['ubrowser']) && ($_SESSION['ubrowser'] != $ubrowser)))
//if (e_QUERY == 'logout') //if (e_QUERY == 'logout')
{ {
if (USER) if (USER)
{ {
@@ -885,15 +895,15 @@ $sql->db_Mark_Time('(Start: Find/Load Theme)');
//---------------------------- //----------------------------
// The following files are assumed to use admin theme: // The following files are assumed to use admin theme:
// 1. Any file in the admin directory (check for non-plugin added to avoid mismatches) // 1. Any file in the admin directory (check for non-plugin added to avoid mismatches)
// 2. any plugin file starting with 'admin_' // 2. any plugin file starting with 'admin_'
// 3. any plugin file in a folder called admin/ // 3. any plugin file in a folder called admin/
// 4. any file that specifies $eplug_admin = TRUE; // 4. any file that specifies $eplug_admin = TRUE;
// //
// e_SELF has the full HTML path // e_SELF has the full HTML path
$inAdminDir = FALSE; $inAdminDir = FALSE;
$isPluginDir = strpos(e_SELF,'/'.$PLUGINS_DIRECTORY) !== FALSE; // True if we're in a plugin $isPluginDir = strpos(e_SELF,'/'.$PLUGINS_DIRECTORY) !== FALSE; // True if we're in a plugin
$e107Path = str_replace($e107->base_path, "", e_SELF); // Knock off the initial bits $e107Path = str_replace($e107->base_path, "", e_SELF); // Knock off the initial bits
if ( if (
(!$isPluginDir && strpos($e107Path, $ADMIN_DIRECTORY) === 0 ) // Core admin directory (!$isPluginDir && strpos($e107Path, $ADMIN_DIRECTORY) === 0 ) // Core admin directory
|| ($isPluginDir && (strpos(e_PAGE,"admin_") === 0 || strpos($e107Path, "admin/") !== FALSE)) // Plugin admin file or directory || ($isPluginDir && (strpos(e_PAGE,"admin_") === 0 || strpos($e107Path, "admin/") !== FALSE)) // Plugin admin file or directory
|| (varsettrue($eplug_admin)) // Admin forced || (varsettrue($eplug_admin)) // Admin forced
@@ -907,17 +917,17 @@ if(!defined("THEME"))
{ {
if ($inAdminDir && varsettrue($pref['admintheme'])&& (strpos(e_SELF.'?'.e_QUERY, 'menus.php?configure') === FALSE)) if ($inAdminDir && varsettrue($pref['admintheme'])&& (strpos(e_SELF.'?'.e_QUERY, 'menus.php?configure') === FALSE))
{ {
/* if (strpos(e_SELF, "newspost.php") !== FALSE) /* if (strpos(e_SELF, "newspost.php") !== FALSE)
{ {
define("MAINTHEME", e_THEME.$pref['sitetheme']."/"); MAINTHEME no longer used in core distribution define("MAINTHEME", e_THEME.$pref['sitetheme']."/"); MAINTHEME no longer used in core distribution
} */ } */
checkvalidtheme($pref['admintheme']); checkvalidtheme($pref['admintheme']);
} }
elseif (USERTHEME !== FALSE && USERTHEME != "USERTHEME") elseif (USERTHEME !== FALSE && USERTHEME != "USERTHEME")
{ {
checkvalidtheme(USERTHEME); checkvalidtheme(USERTHEME);
} }
else else
{ {
checkvalidtheme($pref['sitetheme']); checkvalidtheme($pref['sitetheme']);
} }
@@ -930,16 +940,16 @@ if(!defined("THEME"))
// here we USE the theme // here we USE the theme
if ($inAdminDir) if ($inAdminDir)
{ {
if (file_exists(THEME.'admin_theme.php')) if (file_exists(THEME.'admin_theme.php'))
{ {
require_once(THEME.'admin_theme.php'); require_once(THEME.'admin_theme.php');
} }
else else
{ {
require_once(THEME."theme.php"); require_once(THEME."theme.php");
} }
} }
else else
{ {
require_once(THEME."theme.php"); require_once(THEME."theme.php");
} }
@@ -959,8 +969,8 @@ if ($inAdminDir)
{ {
e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_".e_PAGE); e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_".e_PAGE);
e107_include_once(e_LANGUAGEDIR."English/admin/lan_".e_PAGE); e107_include_once(e_LANGUAGEDIR."English/admin/lan_".e_PAGE);
} }
elseif (!in_array("lan_".e_PAGE,$exclude_lan) && !$isPluginDir) elseif (!in_array("lan_".e_PAGE,$exclude_lan) && !$isPluginDir)
{ {
e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_".e_PAGE); e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_".e_PAGE);
e107_include_once(e_LANGUAGEDIR."English/lan_".e_PAGE); e107_include_once(e_LANGUAGEDIR."English/lan_".e_PAGE);
@@ -982,7 +992,7 @@ if ($pref['anon_post'] ? define("ANON", TRUE) : define("ANON", FALSE));
if (Empty($pref['newsposts']) ? define("ITEMVIEW", 15) : define("ITEMVIEW", $pref['newsposts'])); if (Empty($pref['newsposts']) ? define("ITEMVIEW", 15) : define("ITEMVIEW", $pref['newsposts']));
if ($pref['antiflood1'] == 1) if ($pref['antiflood1'] == 1)
{ {
define('FLOODPROTECT', TRUE); define('FLOODPROTECT', TRUE);
define('FLOODTIMEOUT', max(varset($pref['antiflood_timeout'],10),3)); define('FLOODTIMEOUT', max(varset($pref['antiflood_timeout'],10),3));
@@ -1068,7 +1078,7 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
$lans = explode(",", e_LANLIST); $lans = explode(",", e_LANLIST);
$varList = explode(",", trim($var)); $varList = explode(",", trim($var));
rsort($varList); // check the language first.(ie. numbers come last) rsort($varList); // check the language first.(ie. numbers come last)
foreach($varList as $v) foreach($varList as $v)
{ {
@@ -1182,19 +1192,20 @@ function get_user_data($uid, $extra = "")
} }
} }
} }
//=========================================================== //===========================================================
// Now look up the 'inherited' user classes // Now look up the 'inherited' user classes
global $e_userclass; global $e_userclass;
if (!isset($e_userclass) && !is_object($e_userclass)) if (!isset($e_userclass) && !is_object($e_userclass))
{ {
require_once(e_HANDLER."userclass_class.php"); require_once(e_HANDLER."userclass_class.php");
$e_userclass = new user_class; $e107->e_userclass = new user_class;
$e_userclass = &$e107->e_userclass;
} }
$var['user_class'] = $e_userclass->get_all_user_classes($var['user_class']); $var['user_class'] = $e_userclass->get_all_user_classes($var['user_class']);
//=========================================================== //===========================================================
cachevars("userdata_{$uid}", $var); cachevars("userdata_{$uid}", $var);
return $var; return $var;
} }
@@ -1204,9 +1215,9 @@ function get_user_data($uid, $extra = "")
function save_prefs($table = 'core', $uid = USERID, $row_val = '') function save_prefs($table = 'core', $uid = USERID, $row_val = '')
{ {
global $pref, $user_pref, $tp, $PrefCache, $sql, $eArrayStorage; global $pref, $user_pref, $tp, $PrefCache, $sql, $eArrayStorage;
if ($table == 'core') if ($table == 'core')
{ {
if ($row_val == '') if ($row_val == '')
{ // Save old version as a backup first { // Save old version as a backup first
$sql->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('SitePrefs_Backup', '".addslashes($PrefCache)."') "); $sql->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('SitePrefs_Backup', '".addslashes($PrefCache)."') ");
@@ -1225,7 +1236,7 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '')
} }
} }
} }
else else
{ {
$_user_pref = $tp -> toDB($user_pref); $_user_pref = $tp -> toDB($user_pref);
$tmp=addslashes(serialize($_user_pref)); $tmp=addslashes(serialize($_user_pref));
@@ -1317,7 +1328,7 @@ function init_session() {
list($uid, $upw)= explode(".", $cli_log); list($uid, $upw)= explode(".", $cli_log);
} }
if (empty($uid) || empty($upw)) if (empty($uid) || empty($upw))
{ {
cookie(e_COOKIE, "", (time() - 2592000)); cookie(e_COOKIE, "", (time() - 2592000));
$_SESSION[e_COOKIE] = ""; $_SESSION[e_COOKIE] = "";
@@ -1363,18 +1374,18 @@ function init_session() {
$currentUser['user_realname'] = $result['user_login']; // Used by force_userupdate $currentUser['user_realname'] = $result['user_login']; // Used by force_userupdate
define("USERLV", $result['user_lastvisit']); define("USERLV", $result['user_lastvisit']);
if ($result['user_ban'] == 1) if ($result['user_ban'] == 1)
{ {
if (isset($pref['ban_messages'])) if (isset($pref['ban_messages']))
{ {
echo $tp->toHTML(varsettrue($pref['ban_messages'][6])); // Show message if one set echo $tp->toHTML(varsettrue($pref['ban_messages'][6])); // Show message if one set
} }
exit; exit;
} }
$user_pref = ($result['user_prefs']) ? unserialize($result['user_prefs']) : ''; $user_pref = ($result['user_prefs']) ? unserialize($result['user_prefs']) : '';
if (isset($_POST['settheme'])) if (isset($_POST['settheme']))
{ {
$user_pref['sitetheme'] = ($pref['sitetheme'] == $_POST['sitetheme'] ? "" : $_POST['sitetheme']); $user_pref['sitetheme'] = ($pref['sitetheme'] == $_POST['sitetheme'] ? "" : $_POST['sitetheme']);
save_prefs("user"); save_prefs("user");
@@ -1382,7 +1393,7 @@ function init_session() {
define("USERTHEME", (isset($user_pref['sitetheme']) && file_exists(e_THEME.$user_pref['sitetheme']."/theme.php") ? $user_pref['sitetheme'] : FALSE)); define("USERTHEME", (isset($user_pref['sitetheme']) && file_exists(e_THEME.$user_pref['sitetheme']."/theme.php") ? $user_pref['sitetheme'] : FALSE));
global $ADMIN_DIRECTORY, $PLUGINS_DIRECTORY; global $ADMIN_DIRECTORY, $PLUGINS_DIRECTORY;
if ($result['user_admin']) if ($result['user_admin'])
{ {
define("ADMIN", TRUE); define("ADMIN", TRUE);
define("ADMINID", $result['user_id']); define("ADMINID", $result['user_id']);
@@ -1390,13 +1401,13 @@ function init_session() {
define("ADMINPERMS", $result['user_perms']); define("ADMINPERMS", $result['user_perms']);
define("ADMINEMAIL", $result['user_email']); define("ADMINEMAIL", $result['user_email']);
define("ADMINPWCHANGE", $result['user_pwchange']); define("ADMINPWCHANGE", $result['user_pwchange']);
} }
else else
{ {
define("ADMIN", FALSE); define("ADMIN", FALSE);
} }
} }
else else
{ {
define("USER", FALSE); define("USER", FALSE);
define('USERID', 0); define('USERID', 0);
@@ -1418,7 +1429,8 @@ $sql->db_Mark_Time('Start: Go online');
if(!isset($_E107['no_online']) && varset($pref['track_online'])) if(!isset($_E107['no_online']) && varset($pref['track_online']))
{ {
e107_require_once(e_HANDLER."online_class.php"); e107_require_once(e_HANDLER."online_class.php");
$e_online = new e_online(); $e107->e_online = new e_online;
$e_online = &$e107->e_online;
$e_online->online($pref['track_online'], $pref['flood_protect']); $e_online->online($pref['track_online'], $pref['flood_protect']);
} }
@@ -1533,9 +1545,9 @@ function class_list($uid = '')
{ {
$clist = explode(',', $class_list); $clist = explode(',', $class_list);
} }
$clist[] = e_UC_MEMBER; $clist[] = e_UC_MEMBER;
if ($admin_status == true) if ($admin_status == true)
{ {
$clist[] = e_UC_ADMIN; $clist[] = e_UC_ADMIN;
@@ -1550,10 +1562,10 @@ function class_list($uid = '')
{ {
$clist[] = e_UC_GUEST; $clist[] = e_UC_GUEST;
} }
$clist[] = e_UC_READONLY; $clist[] = e_UC_READONLY;
$clist[] = e_UC_PUBLIC; $clist[] = e_UC_PUBLIC;
return implode(',', $clist); return implode(',', $clist);
} }
@@ -1586,9 +1598,9 @@ function e107_require($fname) {
function include_lan($path, $force = false) function include_lan($path, $force = false)
{ {
if (!is_readable($path)) if (!is_readable($path))
{ {
$path = str_replace(e_LANGUAGE, 'English', $path); $path = str_replace(e_LANGUAGE, 'English', $path);
} }
@@ -1607,12 +1619,12 @@ function include_lan_admin($path)
if(!function_exists("print_a")) if(!function_exists("print_a"))
{ {
function print_a($var, $return = false) function print_a($var, $return = false)
{ {
$charset = "utf-8"; $charset = "utf-8";
if(defined("CHARSET")) if(defined("CHARSET"))
{ {
$charset = CHARSET; $charset = CHARSET;
} }
@@ -1620,8 +1632,8 @@ if(!function_exists("print_a"))
{ {
echo '<pre>'.htmlspecialchars(print_r($var, true), ENT_QUOTES, $charset).'</pre>'; echo '<pre>'.htmlspecialchars(print_r($var, true), ENT_QUOTES, $charset).'</pre>';
return true; return true;
} }
else else
{ {
return '<pre>'.htmlspecialchars(print_r($var, true), ENT_QUOTES, $charset).'</pre>'; return '<pre>'.htmlspecialchars(print_r($var, true), ENT_QUOTES, $charset).'</pre>';
} }
@@ -1631,7 +1643,7 @@ if(!function_exists("print_a"))
// Check that all required user fields (including extended fields) are valid. // Check that all required user fields (including extended fields) are valid.
// Return TRUE if update required // Return TRUE if update required
function force_userupdate() function force_userupdate()
{ {
global $sql,$pref,$currentUser; global $sql,$pref,$currentUser;

View File

@@ -1,6 +1,6 @@
// $Id: url.sc,v 1.2 2008-11-24 18:18:47 mcfly_e107 Exp $ // $Id: url.sc,v 1.3 2008-11-25 16:26:02 mcfly_e107 Exp $
$e107 = e107::getInstance(); $e107 = e107::getInstance();
list($part, $section, $type, $parms) = explode('::', $parm, 4); list($section, $type, $parms) = explode('|', $parm, 3);
if(strpos($parms, '=') !== false) if(strpos($parms, '=') !== false)
{ {
parse_str($parms, $p); parse_str($parms, $p);
@@ -9,9 +9,4 @@ else
{ {
$p[$parms] = 1; $p[$parms] = 1;
} }
$e107->url->core = ($part == 'core'); return $e107->url->getURL($section, $type, $p);
if($e107->url->createURL($section, $type, $p))
{
return $e107->url->link;
}
return 'Failed';

View File

@@ -1,66 +1,101 @@
<?php <?php
/* /*
+ ----------------------------------------------------------------------------+ + ----------------------------------------------------------------------------+
| e107 website system | e107 website system
| |
| <20>Steve Dunstan 2001-2002 | <20>Steve Dunstan 2001-2002
| http://e107.org | http://e107.org
| jalist@e107.org | jalist@e107.org
| |
| Released under the terms and conditions of the | Released under the terms and conditions of the
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/e107Url.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/e107Url.php,v $
| $Revision: 1.1 $ | $Revision: 1.2 $
| $Date: 2008-11-24 18:06:03 $ | $Date: 2008-11-25 16:26:02 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
class eURL class eURL
{ {
var $core = false; var $_link_handlers = array();
var $link = '';
/**
function createURL($section, $urlType, $urlItems) * Get plugin url
{ *
if(!is_array($urlItems)) * @param string $section
{ * @param string $urlType
$urlItems = array($urlItems => 1); * @param string|array $urlItems
} * @return string URL
$functionName = 'url_'.$section.'_'.$urlType; */
if(!function_exists($functionName)) function getUrl($section, $urlType, $urlItems = array())
{ {
$fileName = ($this->core ? e_FILE."url/custom/base/{$section}/{$urlType}.php" : e_FILE."url/custom/plugins/{$section}/{$urlType}.php"); if (!is_array($urlItems))
if(is_readable($fileName)) {
{ $urlItems = array($urlItems => 1);
include_once($fileName); }
}
else $handlerId = $section . '/' . $urlType;
{ if (!isset($this->_link_handlers[$handlerId]))
$fileName = ($this->core ? e_FILE."url/base/{$section}/{$urlType}.php" : e_PLUGIN."{$section}/url/{$urlType}.php"); {
if(is_readable($fileName)) $this->_link_handlers[$handlerId] = $this->_initHandler($section, $urlType);
{ }
include_once($fileName);
} return (string )call_user_func($this->_link_handlers[$handlerId], $urlItems);
else }
{
return false; function _initHandler($section, $urlType)
} {
} $handlerId = $section . '/' . $urlType;
if(!function_exists($functionName)) $handler = 'url_' . $section . '_' . $urlType;
{ $core = false;
return false; if (strpos($section, ':') !== false)
} {
} list($tmp, $section) = explode(':', $section, 2);
$core = ($tmp === 'core');
if($this->link = call_user_func($functionName, $urlItems)) }
{
return true; // Check to see if custom code is active and exists
} if (varsettrue($pref['url_config'][$section]))
{
return false; $fileName = ($core ? e_FILE."url/custom/base/{$handlerId}.php" : e_FILE."url/custom/plugins/{$handlerId}.php");
} if (is_readable($fileName))
{
} include_once ($fileName);
}
if (function_exists($handler))
{
return $handler;
}
}
$fileName = ($core ? e_FILE."url/base/{$handlerId}.php" : e_PLUGIN."{$section}/url/{$urlType}.php");
if (is_readable($fileName))
{
include_once ($fileName);
}
return $handler;
}
/*
Preparing for PHP5
Exmample future calls (after stopping PHP4 support):
$e107->url->getForum('post', array('edit' => 10));
$e107->url->getCoreUser('user', array('id' => 10));
function __call($method, $arguments) {
if (strpos($method, "getCore") === 0)
{
$section = strtolower(substr($method, 7));
return $this->getCoreUrl($section, varset($arguments[0]), varset($arguments[1]));
}
elseif (strpos($method, "get") === 0)
{
$section = strtolower(substr($method, 3));
return $this->getUrl($section, varset($arguments[0]), varset($arguments[1]));
}
return '';
}
*/
}

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
| $Revision: 1.24 $ | $Revision: 1.25 $
| $Date: 2008-11-25 14:36:33 $ | $Date: 2008-11-25 16:26:02 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -42,16 +42,15 @@ class e107
* @param string $e107_root_path * @param string $e107_root_path
* @return e107 * @return e107
*/ */
function e107($e107_paths, $e107_root_path) function e107()
{ {
if(defined('e107_php4_check') && constant('e107_php4_check')) if(defined('e107_php4_check') && constant('e107_php4_check'))
{ {
echo ('Fatal error! You are not allowed to direct instantinate an object for singleton class! Please use e107::getInstance()'); echo ('Fatal error! You are not allowed to direct instantinate an object for singleton class! Please use e107::getInstance()');
exit(); exit();
} }
$this->_init($e107_paths, $e107_root_path);
} }
function _init($e107_paths, $e107_root_path) function _init($e107_paths, $e107_root_path)
{ {
$this->e107_dirs = $e107_paths; $this->e107_dirs = $e107_paths;
@@ -67,7 +66,7 @@ class e107
function &getInstance() function &getInstance()
{ {
static $instance = array();//it's array because of an odd PHP 4 bug static $instance = array();//it's array because of an odd PHP 4 bug
if(!$instance) if(!$instance)
{ {
$instance[0] = new e107(); $instance[0] = new e107();
@@ -228,7 +227,7 @@ class e107
* Check if current user is banned * Check if current user is banned
* *
*/ */
function ban() function ban()
{ {
global $sql, $e107, $tp, $pref; global $sql, $e107, $tp, $pref;
$ban_count = $sql->db_Count("banlist"); $ban_count = $sql->db_Count("banlist");
@@ -297,7 +296,7 @@ class e107
// $admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"DBG","Whitelist hit",$query,FALSE,LOG_TO_ROLLING); // $admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"DBG","Whitelist hit",$query,FALSE,LOG_TO_ROLLING);
return TRUE; return TRUE;
} }
// Found banlist entry in table here // Found banlist entry in table here
if (($row['banlist_banexpires'] > 0) && ($row['banlist_banexpires'] < time())) if (($row['banlist_banexpires'] > 0) && ($row['banlist_banexpires'] < time()))
{ // Ban has expired - delete from DB { // Ban has expired - delete from DB
@@ -322,11 +321,11 @@ class e107
} }
$admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,'BAN_03','LAN_AUDIT_LOG_003',$query,FALSE,LOG_TO_ROLLING); $admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,'BAN_03','LAN_AUDIT_LOG_003',$query,FALSE,LOG_TO_ROLLING);
exit(); exit();
} }
// $admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"DBG","No ban found",$query,FALSE,LOG_TO_ROLLING); // $admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"DBG","No ban found",$query,FALSE,LOG_TO_ROLLING);
return TRUE; // Email address OK return TRUE; // Email address OK
} }
// Add an entry to the banlist. $bantype = 1 for manual, 2 for flooding, 4 for multiple logins // Add an entry to the banlist. $bantype = 1 for manual, 2 for flooding, 4 for multiple logins
// Returns TRUE if ban accepted. // Returns TRUE if ban accepted.
@@ -340,7 +339,7 @@ class e107
if (!$ban_ip) return FALSE; if (!$ban_ip) return FALSE;
// See if the address is in the whitelist // See if the address is in the whitelist
if ($sql->db_Select('banlist','*','`banlist_bantype` >= '.BAN_TYPE_WHITELIST)) if ($sql->db_Select('banlist','*','`banlist_bantype` >= '.BAN_TYPE_WHITELIST))
{ // Got a whitelist entry for this { // Got a whitelist entry for this
$admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"BANLIST_11",'LAN_AL_BANLIST_11',$ban_ip,FALSE,LOG_TO_ROLLING); $admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"BANLIST_11",'LAN_AL_BANLIST_11',$ban_ip,FALSE,LOG_TO_ROLLING);
return FALSE; return FALSE;
} }
@@ -362,14 +361,14 @@ class e107
* @return string * @return string
* returns the address in internal 'normalised' IPV6 format - so most code should continue to work provided the DB Field is big enougn * returns the address in internal 'normalised' IPV6 format - so most code should continue to work provided the DB Field is big enougn
*/ */
function getip() function getip()
{ {
if(!$this->_ip_cache) if(!$this->_ip_cache)
{ {
if (getenv('HTTP_X_FORWARDED_FOR')) if (getenv('HTTP_X_FORWARDED_FOR'))
{ {
$ip=$_SERVER['REMOTE_ADDR']; $ip=$_SERVER['REMOTE_ADDR'];
if (preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", getenv('HTTP_X_FORWARDED_FOR'), $ip3)) if (preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", getenv('HTTP_X_FORWARDED_FOR'), $ip3))
{ {
$ip2 = array('#^0\..*#', $ip2 = array('#^0\..*#',
'#^127\..*#', // Local loopbacks '#^127\..*#', // Local loopbacks
@@ -381,12 +380,12 @@ class e107
); );
$ip = preg_replace($ip2, $ip, $ip3[1]); $ip = preg_replace($ip2, $ip, $ip3[1]);
} }
} }
else else
{ {
$ip = $_SERVER['REMOTE_ADDR']; $ip = $_SERVER['REMOTE_ADDR'];
} }
if ($ip == "") if ($ip == "")
{ {
$ip = "x.x.x.x"; $ip = "x.x.x.x";
} }
@@ -395,7 +394,7 @@ class e107
return $this->_ip_cache; return $this->_ip_cache;
} }
// Encode an IP address to internal representation. Returns string if successful; FALSE on error // Encode an IP address to internal representation. Returns string if successful; FALSE on error
// Default separates fields with ':'; set $div='' to produce a 32-char packed hex string // Default separates fields with ':'; set $div='' to produce a 32-char packed hex string
function ipEncode($ip, $div=':') function ipEncode($ip, $div=':')
@@ -419,7 +418,7 @@ class e107
{ {
$ret .= $divider.'0000'; // Always put in one set of zeros for the blank $ret .= $divider.'0000'; // Always put in one set of zeros for the blank
$divider = $div; $divider = $div;
if ($s > 0) if ($s > 0)
{ {
$ret .= str_repeat($div.'0000',$s); $ret .= str_repeat($div.'0000',$s);
$s = 0; $s = 0;
@@ -441,8 +440,8 @@ class e107
} }
return FALSE; // Unknown return FALSE; // Unknown
} }
// Takes an encoded IP address - returns a displayable one // Takes an encoded IP address - returns a displayable one
// Set $IP4Legacy TRUE to display 'old' (IPv4) addresses in the familiar dotted format, FALSE to display in standard IPV6 format // Set $IP4Legacy TRUE to display 'old' (IPv4) addresses in the familiar dotted format, FALSE to display in standard IPV6 format
// Should handle most things that can be thrown at it. // Should handle most things that can be thrown at it.
@@ -521,9 +520,9 @@ class e107
return 'unknown'; return 'unknown';
} }
function get_host_name($ip_address) function get_host_name($ip_address)
{ {
if(!$this->_host_name_cache[$ip_address]) if(!$this->_host_name_cache[$ip_address])
{ {
$this->_host_name_cache[$ip_address] = gethostbyaddr($ip_address); $this->_host_name_cache[$ip_address] = gethostbyaddr($ip_address);
} }
@@ -533,7 +532,7 @@ class e107
// Return a memory value formatted helpfully // Return a memory value formatted helpfully
// $dp overrides the number of decimal places displayed - realistically, only 0..3 are sensible // $dp overrides the number of decimal places displayed - realistically, only 0..3 are sensible
function parseMemorySize($size, $dp = 2) function parseMemorySize($size, $dp = 2)
{ {
if (!$size) { $size = 0; } if (!$size) { $size = 0; }
if ($size < 4096) if ($size < 4096)
@@ -561,8 +560,8 @@ class e107
} }
return (number_format($size, $dp).$memunit); return (number_format($size, $dp).$memunit);
} }
/** /**
* Get the current memory usage of the code * Get the current memory usage of the code
* *
@@ -576,8 +575,8 @@ class e107
// With PHP>=5.2.0, can show peak usage as well // With PHP>=5.2.0, can show peak usage as well
if (function_exists("memory_get_peak_usage")) $ret .= '/'.$this->parseMemorySize(memory_get_peak_usage(TRUE)); if (function_exists("memory_get_peak_usage")) $ret .= '/'.$this->parseMemorySize(memory_get_peak_usage(TRUE));
return $ret; return $ret;
} }
else else
{ {
return ('Unknown'); return ('Unknown');
} }

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_shortcodes.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/pm/pm_shortcodes.php,v $
| $Revision: 1.6 $ | $Revision: 1.7 $
| $Date: 2008-11-24 18:06:03 $ | $Date: 2008-11-25 16:26:02 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -297,7 +297,7 @@ SC_END
SC_BEGIN PM_DELETE SC_BEGIN PM_DELETE
global $pm_info; global $pm_info;
if($parm != "") if($parm != "")
{ {
$extra = '.'.$parm; $extra = '.'.$parm;
} }
else else
@@ -350,14 +350,13 @@ if($pm_info['pm_to'] == USERID)
SC_END SC_END
SC_BEGIN SEND_PM_LINK SC_BEGIN SEND_PM_LINK
$e107 = e107::getInstance();
$pm_outbox = pm_getInfo('outbox'); $pm_outbox = pm_getInfo('outbox');
if($pm_outbox['outbox']['filled'] < 100) if($pm_outbox['outbox']['filled'] < 100)
{ {
$e107->url->core = false; $e107 = e107::getInstance();
if($e107->url->createUrl('pm','main','send')) if($link = $e107->url->getUrl('pm','main','send'))
{ {
return "<a href='{$e107->url->link}'>".PM_SEND_LINK."</a>"; return "<a href='{$link}'>".PM_SEND_LINK."</a>";
} }
} }
return ""; return "";

View File

@@ -11,13 +11,12 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/pm/private_msg_menu.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/pm/private_msg_menu.php,v $
| $Revision: 1.4 $ | $Revision: 1.5 $
| $Date: 2008-11-24 18:06:03 $ | $Date: 2008-11-25 16:26:02 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
global $sysprefs, $pref, $pm_prefs; global $sysprefs, $pref, $pm_prefs;
if(!isset($pm_prefs['perpage'])) if(!isset($pm_prefs['perpage']))
{ {
@@ -31,6 +30,7 @@ define("PM_OUTBOX_ICON", "<img src='".e_PLUGIN_ABS."pm/images/mail_send.png' sty
define("PM_SEND_LINK", LAN_PM_35); define("PM_SEND_LINK", LAN_PM_35);
define("NEWPM_ANIMATION", "<img src='".e_PLUGIN_ABS."pm/images/newpm.gif' alt='' style='border:0' />"); define("NEWPM_ANIMATION", "<img src='".e_PLUGIN_ABS."pm/images/newpm.gif' alt='' style='border:0' />");
$sc_style['SEND_PM_LINK']['pre'] = "<br /><br />[ "; $sc_style['SEND_PM_LINK']['pre'] = "<br /><br />[ ";
$sc_style['SEND_PM_LINK']['post'] = " ]"; $sc_style['SEND_PM_LINK']['post'] = " ]";
@@ -47,19 +47,20 @@ $sc_style['NEWPM_ANIMATE']['post'] = "</a>";
if(!isset($pm_menu_template)) if(!isset($pm_menu_template))
{ {
$pm_menu_template = " $pm_menu_template = "
<a href='{URL=plugin::pm::main::box=inbox}'>".PM_INBOX_ICON."</a> <a href='{URL=pm|main|box=inbox}'>".PM_INBOX_ICON."</a>
<a href='{URL=plugin::pm::main::box=inbox}'>".LAN_PM_25."</a> <a href='{URL=pm|main|box=inbox}'>".LAN_PM_25."</a>
{NEWPM_ANIMATE} {NEWPM_ANIMATE}
<br /> <br />
{INBOX_TOTAL} ".LAN_PM_36.", {INBOX_UNREAD} ".LAN_PM_37." {INBOX_FILLED} {INBOX_TOTAL} ".LAN_PM_36.", {INBOX_UNREAD} ".LAN_PM_37." {INBOX_FILLED}
<br /> <br />
<a href='{URL=plugin::pm::main::box=outbox}'>".PM_OUTBOX_ICON."</a> <a href='{URL=pm|main|box=outbox}'>".PM_OUTBOX_ICON."</a>
<a href='{URL=plugin::pm::main::box=outbox}'>".LAN_PM_26."</a><br /> <a href='{URL=pm|main|box=outbox}'>".LAN_PM_26."</a><br />
{OUTBOX_TOTAL} ".LAN_PM_36.", {OUTBOX_UNREAD} ".LAN_PM_37." {OUTBOX_FILLED} {OUTBOX_TOTAL} ".LAN_PM_36.", {OUTBOX_UNREAD} ".LAN_PM_37." {OUTBOX_FILLED}
{SEND_PM_LINK} {SEND_PM_LINK}
"; ";
} }
if(check_class($pm_prefs['pm_class'])) if(check_class($pm_prefs['pm_class']))
{ {
global $tp, $pm_inbox; global $tp, $pm_inbox;

View File

@@ -1,15 +1,15 @@
<?php <?php
// $Id: main.php,v 1.2 2008-11-25 16:26:03 mcfly_e107 Exp $
function url_pm_main($parms) function url_pm_main($parms)
{ {
if(isset($parms['box'])) if(isset($parms['box']))
{ {
return e_PLUGIN_ABS."pm/pm.php?{$parms['box']}"; return e_PLUGIN_ABS."pm/pm.php?{$parms['box']}";
} }
if(isset($parms['send'])) if(isset($parms['send']))
{ {
return e_PLUGIN_ABS."pm/pm.php?send"; return e_PLUGIN_ABS."pm/pm.php?send";
} }
} }