mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Added support for CLI login. --u=[username] --p=[password]
This commit is contained in:
43
class2.php
43
class2.php
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/class2.php,v $
|
||||
| $Revision: 1.45 $
|
||||
| $Date: 2008-01-21 03:54:10 $
|
||||
| $Revision: 1.46 $
|
||||
| $Date: 2008-01-22 00:39:08 $
|
||||
| $Author: e107coders $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -49,6 +49,11 @@ $oblev_before_start = ob_get_level();
|
||||
//
|
||||
// B: Remove all output buffering
|
||||
//
|
||||
if(!isset($_E107) || !is_array($_E107)) { $_E107 = array(); }
|
||||
if($_E107['cli'] && !$_E107['debug'] && isset($_SERVER["HTTP_USER_AGENT"]))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
if(!$_E107['cli'])
|
||||
{
|
||||
while (@ob_end_clean()); // destroy all ouput buffering
|
||||
@@ -75,7 +80,7 @@ if($register_globals == true){
|
||||
unset($global);
|
||||
}
|
||||
|
||||
if(!isset($_E107) || !is_array($_E107)) { $_E107 = array(); }
|
||||
|
||||
if(isset($_E107['minimal']))
|
||||
{
|
||||
$_e107vars = array('forceuserupdate', 'online', 'theme', 'menus', 'prunetmp');
|
||||
@@ -1193,18 +1198,42 @@ function init_session() {
|
||||
# - return boolean
|
||||
# - scope public
|
||||
*/
|
||||
global $sql, $pref, $user_pref, $tp, $currentUser, $e107;
|
||||
global $sql, $pref, $user_pref, $tp, $currentUser, $e107, $_E107;
|
||||
|
||||
define('USERIP', $e107->getip());
|
||||
if (!isset($_COOKIE[$pref['cookie_name']]) && !isset($_SESSION[$pref['cookie_name']])) {
|
||||
|
||||
if($_E107['cli'] && $_SERVER['argv'][1])
|
||||
{
|
||||
require_once(e_HANDLER."cli_class.php");
|
||||
$cli = new eCLI;
|
||||
$arg = $cli->parse_args();
|
||||
if($arg['u'] && $arg['p'])
|
||||
{
|
||||
e107_require_once(e_HANDLER."login.php");
|
||||
$usr = new userlogin;
|
||||
$cli_log = $usr->userlogin(trim($arg['u']), trim($arg['p']), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_COOKIE[$pref['cookie_name']]) && !isset($_SESSION[$pref['cookie_name']]) && !$_E107['cli'])
|
||||
{
|
||||
define("USER", FALSE);
|
||||
define("USERTHEME", FALSE);
|
||||
define("ADMIN", FALSE);
|
||||
define("GUEST", TRUE);
|
||||
define('USERCLASS', '');
|
||||
define('USEREMAIL', '');
|
||||
} else {
|
||||
list($uid, $upw)=(isset($_COOKIE[$pref['cookie_name']]) && $_COOKIE[$pref['cookie_name']] ? explode(".", $_COOKIE[$pref['cookie_name']]) : explode(".", $_SESSION[$pref['cookie_name']]));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$_E107['cli'])
|
||||
{
|
||||
list($uid, $upw)=(isset($_COOKIE[$pref['cookie_name']]) && $_COOKIE[$pref['cookie_name']] ? explode(".", $_COOKIE[$pref['cookie_name']]) : explode(".", $_SESSION[$pref['cookie_name']]));
|
||||
}
|
||||
else
|
||||
{
|
||||
list($uid, $upw)= explode(".", $cli_log);
|
||||
}
|
||||
|
||||
if (empty($uid) || empty($upw)) {
|
||||
cookie($pref['cookie_name'], "", (time() - 2592000));
|
||||
|
@@ -12,9 +12,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/login.php,v $
|
||||
| $Revision: 1.15 $
|
||||
| $Date: 2008-01-15 21:57:38 $
|
||||
| $Author: e107steved $
|
||||
| $Revision: 1.16 $
|
||||
| $Date: 2008-01-22 00:39:08 $
|
||||
| $Author: e107coders $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@ class userlogin
|
||||
# - scope public
|
||||
*/
|
||||
global $pref, $e_event, $sql, $e107, $tp;
|
||||
global $admin_log;
|
||||
global $admin_log,$_E107;
|
||||
|
||||
$username = trim($username);
|
||||
$userpass = trim($userpass);
|
||||
@@ -145,7 +145,7 @@ class userlogin
|
||||
$this->update_xup($user_id, $user_xup);
|
||||
}
|
||||
|
||||
if ($pref['user_tracking'] == "session")
|
||||
if ($pref['user_tracking'] == "session")
|
||||
{
|
||||
$_SESSION[$pref['cookie_name']] = $cookieval;
|
||||
}
|
||||
@@ -209,12 +209,16 @@ class userlogin
|
||||
}
|
||||
}
|
||||
|
||||
if($_E107['cli'])
|
||||
{
|
||||
return $cookieval;
|
||||
}
|
||||
|
||||
if (strstr($_SERVER['SERVER_SOFTWARE'], "Apache")) {
|
||||
header("Location: ".$redir);
|
||||
exit;
|
||||
header("Location: ".$redir);
|
||||
exit;
|
||||
} else {
|
||||
echo "<script type='text/javascript'>document.location.href='{$redir}'</script>\n";
|
||||
echo "<script type='text/javascript'>document.location.href='{$redir}'</script>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -309,4 +313,4 @@ class userlogin
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
Reference in New Issue
Block a user