diff --git a/class2.php b/class2.php
index 1aff09d5a..d5ba41fdf 100644
--- a/class2.php
+++ b/class2.php
@@ -2,16 +2,14 @@
/*
* e107 website system
*
-* Copyright (C) 2008-2009 e107 Inc (e107.org)
+* Copyright (C) 2008-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* General purpose file
*
-* $Source: /cvs_backup/e107_0.8/class2.php,v $
-* $Revision$
-* $Date$
-* $Author$
+* $URL$
+* $Id$
*
*/
//
@@ -1556,10 +1554,11 @@ function init_session()
*/
- global $pref, $user_pref, $currentUser, $e107, $_E107;
+ global $pref, $user_pref, $currentUser, $_E107;
$sql = e107::getDb();
$tp = e107::getParser();
+ $e107 = e107::getInstance();
$eArrayStorage = e107::getArrayStorage();
@@ -1596,7 +1595,7 @@ function init_session()
{
list($uid, $upw)=(isset($_COOKIE[e_COOKIE]) && $_COOKIE[e_COOKIE] ? explode(".", $_COOKIE[e_COOKIE]) : explode(".", $_SESSION[e_COOKIE]));
}
- else
+ else // FIXME - this will never happen - see above
{
list($uid, $upw)= explode('.', $cli_log);
}
diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php
index 0a6f83dd4..94915196d 100644
--- a/e107_handlers/e107_class.php
+++ b/e107_handlers/e107_class.php
@@ -51,6 +51,14 @@ class e107
public $site_theme;
+ /**
+ * Contains reference to global $_E107 array
+ * Assignment is done inside prepare_request() method
+ *
+ * @var array
+ */
+ protected $_E107 = array();
+
/**
* @var string Current request type (http or https)
*/
@@ -175,6 +183,7 @@ class e107
'sitelinks' => '{e_HANDLER}sitelinks_class.php',
'themeHandler' => '{e_HANDLER}theme_handler.php',
'user_class' => '{e_HANDLER}userclass_class.php',
+ 'userlogin' => '{e_HANDLER}login.php',
'xmlClass' => '{e_HANDLER}xml_class.php',
);
@@ -477,6 +486,31 @@ class e107
return (isset($this->e107_dirs[$key]) ? $this->e107_dirs[$key] : '');
}
+ /**
+ * Get value from $_E107 config array
+ * Note: will always return false if called before prepare_request() method!
+ *
+ * @param string $key
+ * @return boolean
+ */
+ public static function getE107($key)
+ {
+ $self = self::getInstance();
+ return (isset($self->_E107[$key]) && $self->_E107[$key] ? true : false);
+ }
+
+ /**
+ * Convenient proxy to $_E107 getter - check if
+ * the system is currently running in cli mode
+ * Note: will always return false if called before prepare_request() method!
+ *
+ * @return boolean
+ */
+ public static function isCli()
+ {
+ return self::getE107('cli');
+ }
+
/**
* Get mysql config var (e107_config.php)
* Replaces all $mySQL(*) globals
@@ -1099,7 +1133,7 @@ class e107
{
return self::getUser();
}
- $user = self::getRegistry('targets/core/user/'.$user_id);
+ $user = self::getRegistry('core/e107/user/'.$user_id);
if(null === $user)
{
$user = self::getObject('e_system_user');
@@ -1115,7 +1149,13 @@ class e107
*/
public static function getUser()
{
- return self::getSingleton('e_user', true, 'targets/core/current_user');
+ $user = self::getRegistry('core/e107/current_user');
+ if(null === $user)
+ {
+ $user = self::getObject('e_user');
+ self::setRegistry('core/e107/current_user', $user);
+ }
+ return $user;
}
/**
@@ -1731,8 +1771,11 @@ class e107
}
}
+ // we can now start use $e107->_E107
+ if(isset($GLOBALS['_E107']) && is_array($GLOBALS['_E107'])) $this->_E107 = & $GLOBALS['_E107'];
+
// remove ajax_used=1 from query string to avoid SELF problems, ajax should always be detected via e_AJAX_REQUEST constant
- $_SERVER['QUERY_STRING'] = str_replace(array('ajax_used=1', '&&'), array('', '&'), $_SERVER['QUERY_STRING']);
+ $_SERVER['QUERY_STRING'] = trim(str_replace(array('ajax_used=1', '&&'), array('', '&'), $_SERVER['QUERY_STRING']), '&');
// e107 uses relative url's, which are broken by "pretty" URL's. So for now we don't support / after .php
if(($pos = strpos($_SERVER['PHP_SELF'], '.php/')) !== false) // redirect bad URLs to the correct one.
@@ -1853,8 +1896,6 @@ class e107
*/
public function set_paths()
{
- global $_E107;
-
// ssl_enabled pref not needed anymore, scheme is auto-detected
$this->HTTP_SCHEME = 'http';
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
@@ -1865,7 +1906,7 @@ class e107
$path = ""; $i = 0;
// FIXME - Again, what if someone moves handlers under the webroot?
- if(!isset($_E107['cli']))
+ if(!self::isCli())
{
while (!file_exists("{$path}class2.php"))
{
@@ -1904,7 +1945,7 @@ class e107
}
define('e_ROOT', $e_ROOT); // Specified format gives trailing slash already (at least on Windows)
- $this->relative_base_path = (!isset($_E107['cli'])) ? $path : e_ROOT;
+ $this->relative_base_path = (!self::isCli()) ? $path : e_ROOT;
$this->http_path = "http://{$_SERVER['HTTP_HOST']}{$this->server_path}";
$this->https_path = "https://{$_SERVER['HTTP_HOST']}{$this->server_path}";
$this->file_path = $path;
diff --git a/e107_handlers/login.php b/e107_handlers/login.php
index d215eef7b..e1d151310 100644
--- a/e107_handlers/login.php
+++ b/e107_handlers/login.php
@@ -3,16 +3,14 @@
/*
* e107 website system
*
- * Copyright (C) 2008-2009 e107 Inc (e107.org)
+ * Copyright (C) 2008-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* e107 Main
*
- * $Source: /cvs_backup/e107_0.8/e107_handlers/login.php,v $
- * $Revision$
- * $Date$
- * $Author$
+ * $Id$
+ * $URL$
*/
@@ -61,7 +59,7 @@ class userlogin
' @param string $response - response string returned by CHAP login (instead of password)
# @return boolean - FALSE on login fail, TRUE on login successful
*/
- public function __construct($username, $userpass, $autologin, $response = '')
+ public function __construct($username, $userpass, $autologin, $response = '', $noredirect = false)
{
global $pref, $e_event, $_E107;
@@ -72,7 +70,7 @@ class userlogin
{
return FALSE;
}
-
+
$tp = e107::getParser();
$sql = e107::getDb();
@@ -102,7 +100,7 @@ class userlogin
{
if (varset($pref['auth_badpassword'], TRUE) || ($this->checkUserPassword($userpass, $response, $forceLogin) === TRUE))
{
- $result = LOGIN_CONTINUE; // Valid User exists in local DB
+ $result = LOGIN_CONTINUE; // Valid User exists in local DB
}
}
}
@@ -248,6 +246,8 @@ class userlogin
}
}
+ if($noredirect) return;
+
$redir = e_SELF;
if (e_QUERY) $redir .= '?'.str_replace('&','&',e_QUERY);
if (isset($pref['frontpage_force']) && is_array($pref['frontpage_force']))
@@ -267,19 +267,24 @@ class userlogin
}
}
}
-
- $redirPrev = e107::getRedirect()->getPreviousUrl();
-
+
+ $redirPrev = e107::getRedirect()->getPreviousUrl();
+
if($redirPrev)
- {
- e107::getRedirect()->redirect($redirPrev);
+ {
+ e107::getRedirect()->redirect($redirPrev);
}
- e107::getRedirect()->redirect($redir);
+ e107::getRedirect()->redirect($redir);
exit();
}
+ public function getUserData()
+ {
+ return $this->userData;
+ }
+
/**
* Look up a user in the e107 database, according to the options set (for login name/email address)
* Note: PASSWORD IS NOT VERIFIED BY THIS ROUTINE
@@ -312,7 +317,7 @@ class userlogin
{ // Invalid user
return $this->invalidLogin($username,LOGIN_BAD_USER);
}
-
+
// User is in DB here
$this->userData = $this->e107->sql -> db_Fetch(MYSQL_ASSOC); // Get user info
$this->userData['user_perms'] = trim($this->userData['user_perms']);
@@ -432,7 +437,7 @@ class userlogin
break;
case LOGIN_NOT_ACTIVATED :
$srch = array("[","]");
- $repl = array("","");
+ $repl = array("","");
define("LOGINMESSAGE", str_replace($srch,$repl,LAN_LOGIN_22)."
");
$this->logNote('LAN_ROLL_LOG_05', $username);
$this->genNote($username, LAN_LOGIN_27);
diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php
index 7cb9b71d0..fffab76eb 100644
--- a/e107_handlers/model_class.php
+++ b/e107_handlers/model_class.php
@@ -35,7 +35,7 @@ class e_model
protected $_data = array();
/**
- * Data structure (types) array, required for {@link e_admin_model::sanitize()} method,
+ * Data structure (types) array, required for {@link e_front_model::sanitize()} method,
* it also serves as a map (find data) for building DB queries,
* copy/sanitize posted data to object data, etc.
*
@@ -1382,7 +1382,7 @@ class e_front_model extends e_model
* Predefined data fields types, passed to DB handler
*
* @param array $field_types
- * @return e_model
+ * @return e_front_model
*/
public function setDbTypes($field_types)
{
diff --git a/e107_handlers/pref_class.php b/e107_handlers/pref_class.php
index c245def17..fccc882ba 100644
--- a/e107_handlers/pref_class.php
+++ b/e107_handlers/pref_class.php
@@ -2,16 +2,14 @@
/*
* e107 website system
*
- * Copyright (C) 2008-2009 e107 Inc (e107.org)
+ * Copyright (C) 2008-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* e107 Preference Handler
*
- * $Source: /cvs_backup/e107_0.8/e107_handlers/pref_class.php,v $
- * $Revision$
- * $Date$
- * $Author$
+ * $URL$
+ * $Id$
*/
if (!defined('e107_INIT')) { exit; }
@@ -23,11 +21,11 @@ require_once(e_HANDLER.'model_class.php');
*
* @package e107
* @category e107_handlers
- * @version 1.0
+ * @version $Id$
* @author SecretR
* @copyright Copyright (c) 2009, e107 Inc.
*/
-class e_pref extends e_admin_model
+class e_pref extends e_front_model
{
/**
* Preference ID - DB row value
@@ -504,7 +502,7 @@ class e_pref extends e_admin_model
e107::getMessage()->addInfo('Settings not saved as no changes were made.', 'default', $session_messages);
return 0;
}
-
+
$admin_log = e107::getAdminLog();
//Save to DB
@@ -538,7 +536,7 @@ class e_pref extends e_admin_model
// auto admin log
if(is_array($old)) // fix install problems - no old prefs available
{
- $new = $this->getPref();
+ $new = $this->getPref();
$admin_log->logArrayDiffs($new, $old, 'PREFS_02', false);
unset($new, $old);
}
@@ -682,31 +680,16 @@ class e_pref extends e_admin_model
/**
* Override
*/
- public function dbInsert()
+ public function delete()
{
}
/**
* Override
*/
- public function dbUpdate()
+ protected function dbUpdate()
{
}
-
- /**
- * Override
- */
- public function dbReplace()
- {
- }
-
- /**
- * Override
- */
- public function dbDelete()
- {
- }
-
}
/**
@@ -861,6 +844,22 @@ class e_plugin_pref extends e_pref
{
return $this->plugin_id;
}
+
+ /**
+ * Delete plugin preferences
+ * @see e107_handlers/e_pref#delete()
+ * @return boolean
+ */
+ public function delete()
+ {
+ $ret = false;
+ if($this->plugin_id)
+ {
+ $ret = e107::getDb($this->plugin_id)->db_Delete('core', "e107_name='{$this->plugin_id}'");
+ $this->destroy();
+ }
+ return $ret;
+ }
}
/**
@@ -1037,13 +1036,13 @@ class prefs
*
* all pref sets other than menu_pref get toDB()
*/
- function setArray($name = '', $table = 'core', $uid = USERID)
+ function setArray($name = '', $table = 'core', $uid = USERID)
{
$tp = e107::getParser();
- if (!strlen($name))
+ if (!strlen($name))
{
- switch ($table)
+ switch ($table)
{
case 'core':
$name = 'pref';
@@ -1055,9 +1054,9 @@ class prefs
}
global $$name;
- if ($name != 'menu_pref')
+ if ($name != 'menu_pref')
{
- foreach($$name as $key => $prefvalue)
+ foreach($$name as $key => $prefvalue)
{
$$name[$key] = $tp->toDB($prefvalue);
}
diff --git a/e107_handlers/user_handler.php b/e107_handlers/user_handler.php
index 80dcb66cc..e78abe1dd 100644
--- a/e107_handlers/user_handler.php
+++ b/e107_handlers/user_handler.php
@@ -2,22 +2,20 @@
/*
* e107 website system
*
- * Copyright (C) 2008-2009 e107 Inc (e107.org)
+ * Copyright (C) 2008-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Handler - user-related functions
*
- * $Source: /cvs_backup/e107_0.8/e107_handlers/user_handler.php,v $
- * $Revision$
- * $Date$
- * $Author$
+ * $URL$
+ * $Id$
*
*/
/**
- *
+ *
* @package e107
* @subpackage e107_handlers
* @version $Id$;
@@ -181,8 +179,8 @@ class UserHandler
* @param string $password - plaintext password as entered by user
* @param string $login_name - string used to log in (could actually be email address)
* @param string $stored_hash - required value for password to match
- *
- * @return PASSWORD_INVALID|PASSWORD_VALID|string
+ *
+ * @return PASSWORD_INVALID|PASSWORD_VALID|string
* PASSWORD_INVALID if no match
* PASSWORD_VALID if valid password
* Return a new hash to store if valid password but non-preferred encoding
@@ -445,25 +443,27 @@ class UserHandler
* @param array $lode - user information from DB - 'user_id' and 'user_password' required
* @param bool $autologin - TRUE if the 'Remember Me' box ticked
*
- * @return none
+ * @return void
*/
public function makeUserCookie($lode,$autologin = FALSE)
{
global $pref;
$cookieval = $lode['user_id'].'.'.md5($lode['user_password']); // (Use extra md5 on cookie value to obscure hashed value for password)
- if ($pref['user_tracking'] == 'session')
+ if (e107::getPref('user_tracking') == 'session')
{
- $_SESSION[$pref['cookie_name']] = $cookieval;
+ $_SESSION[e107::getPref('cookie_name')] = $cookieval;
}
else
{
if ($autologin == 1)
{ // Cookie valid for up to 30 days
- cookie($pref['cookie_name'], $cookieval, (time() + 3600 * 24 * 30));
+ cookie(e107::getPref('cookie_name'), $cookieval, (time() + 3600 * 24 * 30));
+ $_COOKIE[e107::getPref('cookie_name')] = $cookieval; // make it available to the global scope before the page is reloaded
}
else
{
- cookie($pref['cookie_name'], $cookieval);
+ cookie(e107::getPref('cookie_name'), $cookieval);
+ $_COOKIE[e107::getPref('cookie_name')] = $cookieval; // make it available to the global scope before the page is reloaded
}
}
}
@@ -833,7 +833,7 @@ e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_administrator.php");
class e_userperms
{
protected $core_perms = array(
-
+
"1"=> ADMSLAN_19,
"2"=> ADMSLAN_20,
"3"=> ADMSLAN_21,
@@ -868,39 +868,39 @@ class e_userperms
"N"=> ADMSLAN_47,
// "Z"=> ADMSLAN_62,
);
-
+
protected $plugin_perms = array();
-
+
protected $language_perms = array();
-
+
protected $main_perms = array();
-
+
protected $permSectionDiz = array(
'core' => ADMSLAN_74,
'plugin' => ADLAN_CL_7,
'language' => ADLAN_132,
'main' => ADMSLAN_58
);
-
-
+
+
function __construct()
{
-
-
+
+
$sql = e107::getDb('sql2');
$tp = e107::getParser();
-
-
+
+
$sql->db_Select("plugin", "*", "plugin_installflag='1'");
while ($row2 = $sql->db_Fetch())
{
$this->plugin_perms[("P".$row2['plugin_id'])] = LAN_PLUGIN." - ".$tp->toHTML($row2['plugin_name'], FALSE, 'RAWTEXT,defs');
- }
-
+ }
+
asort($this->plugin_perms);
-
+
$this->plugin_perms = array("Z"=>ADMSLAN_62) + $this->plugin_perms;
-
+
if(e107::getConfig()->getPref('multilanguage'))
{
$lanlist = explode(",",e_LANLIST);
@@ -910,20 +910,20 @@ class e_userperms
$this->language_perms[$langs] = $langs;
}
}
-
+
if(getperms('0'))
{
$this->main_perms = array('0' => ADMSLAN_58);
}
-
+
}
-
+
function renderSectionDiz($key)
{
- return $this->permSectionDiz[$key];
+ return $this->permSectionDiz[$key];
}
-
-
+
+
function getPermList($type='all')
{
if($type == 'core')
@@ -942,34 +942,34 @@ class e_userperms
{
return $this->main_perms;
}
-
+
if($type == 'grouped')
{
$ret = array();
$ret['core'] = $this->core_perms;
$ret['plugin'] = $this->plugin_perms;
-
+
if(vartrue($this->language_perms))
{
$ret['language'] = $this->language_perms;
}
-
+
if(vartrue($this->main_perms))
{
$ret['main'] = $this->main_perms;
}
-
+
return $ret;
-
+
}
-
+
return array_merge($this->core_perms,$this->plugin_perms,$this->language_perms,$this->main_perms);
}
-
+
function checkb($arg, $perms, $label='')
{
$frm = e107::getForm();
-
+
$par = "