| 1 |
<?php |
<?php |
| 2 |
/** |
/** |
| 3 |
* @version $Id: index.php,v 1.47 2005/08/26 08:10:43 mambofoundation Exp $ |
* @package Mambo Open Source |
| 4 |
* @package Mambo |
* @copyright (C) 2005 - 2006 Mambo Foundation Inc. |
|
* @copyright (C) 2000 - 2005 Miro International Pty Ltd |
|
| 5 |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 6 |
|
* |
| 7 |
|
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure |
| 8 |
|
* that Mambo remained free Open Source software owned and managed by the community. |
| 9 |
* Mambo is Free Software |
* Mambo is Free Software |
| 10 |
*/ |
*/ |
| 11 |
|
|
| 62 |
var $subdirectory; |
var $subdirectory; |
| 63 |
var $current_user = null; |
var $current_user = null; |
| 64 |
var $do_gzip_compress = false; |
var $do_gzip_compress = false; |
| 65 |
|
var $init_errorlevel = 0; |
| 66 |
|
|
| 67 |
function mamboCore () { |
function mamboCore () { |
| 68 |
global $adminside; |
global $adminside; |
| 69 |
$this->rootPath = dirname(__FILE__); |
$this->init_errorlevel = error_reporting(0); |
| 70 |
|
$this->rootPath = str_replace('\\', '/', dirname(__FILE__)); |
| 71 |
$this->checkConfig(); |
$this->checkConfig(); |
| 72 |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 73 |
$this->getConfig(); |
$this->getConfig(); |
| 74 |
$this->fixLanguage(); |
$this->fixLanguage(); |
| 75 |
@set_magic_quotes_runtime( 0 ); |
@set_magic_quotes_runtime( 0 ); |
| 76 |
if (@$this->mosConfig_error_reporting === 0) error_reporting(0); |
if (@$this->mosConfig_error_reporting > 0 OR @$this->mosConfig_error_reporting ===0) error_reporting($this->mosConfig_error_reporting); |
| 77 |
elseif (@$this->mosConfig_error_reporting > 0) error_reporting($this->mosConfig_error_reporting); |
else error_reporting($this->init_errorlevel); |
|
|
|
| 78 |
} |
} |
| 79 |
|
|
| 80 |
function &getMamboCore () { |
function &getMamboCore () { |
| 120 |
} |
} |
| 121 |
|
|
| 122 |
function getConfig () { |
function getConfig () { |
| 123 |
|
global $adminside; |
| 124 |
$code = ''; |
$code = ''; |
| 125 |
$f = @fopen($this->rootPath.'/configuration.php','rb'); |
$f = @fopen($this->rootPath.'/configuration.php','rb'); |
| 126 |
if ($f) { |
if ($f) { |
| 136 |
} |
} |
| 137 |
fclose($f); |
fclose($f); |
| 138 |
eval($code); |
eval($code); |
| 139 |
$subdir = substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])); |
if (isset($_SERVER['DOCUMENT_ROOT']) AND strlen($_SERVER['DOCUMENT_ROOT'])) $docroot = $_SERVER['DOCUMENT_ROOT']; |
| 140 |
$this->subdirectory = str_replace('\\', '/', $subdir); |
else { |
| 141 |
|
// Find information about where execution started |
| 142 |
|
$origin = array_pop(debug_backtrace()); |
| 143 |
|
// Find the PHP script at the start, with a fix for Windows slashes |
| 144 |
|
$absolutepath = str_replace('\\', '/', $origin['file']); |
| 145 |
|
$localpath = $_SERVER['PHP_SELF']; |
| 146 |
|
$docroot = substr($absolutepath,0,strpos($absolutepath,$localpath)); |
| 147 |
|
} |
| 148 |
|
$mamboroot = str_replace('\\', '/', dirname(__FILE__)); |
| 149 |
|
$this->subdirectory = substr($mamboroot, strlen($docroot)); |
| 150 |
$scheme = isset($_SERVER['HTTP_SCHEME']) ? $_SERVER['HTTP_SCHEME'] : ((isset($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS'] != 'off')) ? 'https' : 'http'); |
$scheme = isset($_SERVER['HTTP_SCHEME']) ? $_SERVER['HTTP_SCHEME'] : ((isset($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS'] != 'off')) ? 'https' : 'http'); |
| 151 |
if (isset($_SERVER['HTTP_HOST'])) { |
if (isset($_SERVER['HTTP_HOST'])) { |
| 152 |
$withport = explode(':', $_SERVER['HTTP_HOST']); |
$withport = explode(':', $_SERVER['HTTP_HOST']); |
| 163 |
$afterscheme = '://'.$servername.$port.$this->subdirectory; |
$afterscheme = '://'.$servername.$port.$this->subdirectory; |
| 164 |
$this->mosConfig_live_site = $this->mosConfig_secure_site = $scheme.$afterscheme; |
$this->mosConfig_live_site = $this->mosConfig_secure_site = $scheme.$afterscheme; |
| 165 |
$this->mosConfig_unsecure_site = 'http'.$afterscheme; |
$this->mosConfig_unsecure_site = 'http'.$afterscheme; |
|
// $this->mosConfig_live_site = 'http://'.$_SERVER['SERVER_NAME'].$this->subdirectory; |
|
| 166 |
$this->mosConfig_absolute_path = $this->rootPath; |
$this->mosConfig_absolute_path = $this->rootPath; |
| 167 |
preg_match_all('/\$this\-\>([A-Za-z_][A-Za-z0-9_]*)/', $code, $matches); |
preg_match_all('/\$this\-\>([A-Za-z_][A-Za-z0-9_]*)/', $code, $matches); |
| 168 |
foreach ($matches[1] as $match) $GLOBALS[$match] = $this->$match; |
foreach ($matches[1] as $match) $GLOBALS[$match] = $this->$match; |
| 180 |
} |
} |
| 181 |
|
|
| 182 |
function offlineCheck (&$user, &$database) { |
function offlineCheck (&$user, &$database) { |
| 183 |
if ($this->mosConfig_offline) { |
if ($this->mosConfig_offline OR file_exists($this->rootPath.'/installation/index.php')) { |
| 184 |
require_once($this->rootPath().'/administrator/includes/admin.php'); |
require_once($this->rootPath().'/administrator/includes/admin.php'); |
| 185 |
session_name(md5($this->mosConfig_live_site)); |
session_name(md5($this->mosConfig_live_site)); |
| 186 |
session_start(); |
session_start(); |
| 187 |
if ($user =& checkAdminSession($database)) return; |
$session =& mosSession::getCurrent(); |
| 188 |
|
$my =& new mosUser(); |
| 189 |
|
$my->getSessionData(); |
| 190 |
|
if (mosSession::validate($my)) return; |
| 191 |
include("$this->mosConfig_absolute_path/offline.php"); |
include("$this->mosConfig_absolute_path/offline.php"); |
| 192 |
exit(); |
exit(); |
| 193 |
} |
} |
| 194 |
} |
} |
| 195 |
|
|
| 196 |
function fixLanguage () { |
function fixLanguage () { |
|
|
|
|
|
|
|
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
|
| 197 |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
| 198 |
|
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
| 199 |
|
require_once($this->mosConfig_absolute_path.'/includes/mambofunc.php'); |
| 200 |
|
require_once($this->mosConfig_absolute_path.'/includes/mambolanguage.class.php'); |
| 201 |
|
error_reporting(E_ALL) ; |
| 202 |
########## DEPRECATED ############ |
########## DEPRECATED ############ |
| 203 |
if (isset($this->mosConfig_lang) AND $this->mosConfig_lang); |
if (isset($this->mosConfig_lang) AND $this->mosConfig_lang); |
| 204 |
else $this->set('mosConfig_lang', 'english'); |
else $this->set('mosConfig_lang', 'english'); |
| 206 |
if (file_exists($language_file)) require_once ($language_file); |
if (file_exists($language_file)) require_once ($language_file); |
| 207 |
################################### |
################################### |
| 208 |
|
|
|
#set_error_handler('error_handler'); |
|
|
$lang = $this->mosConfig_lang; |
|
| 209 |
|
|
| 210 |
|
$this->mosConfig_lang = mosGetParam($_POST, 'setLanguage', $this->mosConfig_lang); |
|
$langfile = $this->rootPath.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR.$lang.'.xml'; |
|
|
/*$this->language[$this->mosConfig_language] = array( |
|
|
'locale' => 'pt, pt.utf-8', |
|
|
'encoding' => 'utf-8', |
|
|
'direction' => 'rtl', |
|
|
'dateformat' => '%A, %d %B %Y', |
|
|
'offset' => '+00:00' |
|
|
); |
|
|
*/ |
|
|
$p = xml_parser_create(); |
|
|
xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0); |
|
|
xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1); |
|
|
xml_parse_into_struct($p, implode("", file($langfile)), $values); |
|
|
xml_parser_free($p); |
|
|
foreach($values as $key => $value) |
|
|
{ |
|
|
if ($value['tag'] == 'param') { |
|
|
$name = $value['attributes']['name']; |
|
|
$this->language[$name] = $value['attributes']['default']; |
|
|
} |
|
|
} |
|
| 211 |
|
|
| 212 |
|
|
| 213 |
if (!defined('_ISO')) DEFINE('_ISO','charset='.$this->language['encoding']); |
$language =& mamboLanguage::getInstance($this->mosConfig_lang, $this->rootPath.'/language/'); |
| 214 |
if (!defined('_DATE_FORMAT_LC')) DEFINE('_DATE_FORMAT_LC', $this->language['dateformat']); //Uses PHP's strftime Command Format |
$languages = $language->getLanguages(); |
| 215 |
if (!defined('_DATE_FORMAT_LC2')) DEFINE('_DATE_FORMAT_LC2', $this->language['dateformat']." %H:%M"); |
$charset = $language->get('charset'); |
| 216 |
|
$dateformat = $language->get('dateformat'); |
| 217 |
|
$this->current_language = $language; |
| 218 |
|
if (!defined('_ISO')) DEFINE('_ISO','charset='.$charset); |
| 219 |
|
if (!defined('_DATE_FORMAT_LC')) DEFINE('_DATE_FORMAT_LC', $dateformat); //Uses PHP's strftime Command Format |
| 220 |
|
if (!defined('_DATE_FORMAT_LC2')) DEFINE('_DATE_FORMAT_LC2', $dateformat); |
| 221 |
|
|
|
//header('Content-Type: text/html; charset=utf-8'); |
|
| 222 |
$gettext =& phpgettext(); |
$gettext =& phpgettext(); |
| 223 |
$gettext->debug = 0; |
$gettext->debug = $this->mosConfig_locale_debug; |
| 224 |
$gettext->has_gettext = 0; |
$gettext->has_gettext = $this->mosConfig_locale_use_gettext; |
| 225 |
$gettext->setlocale($this->mosConfig_lang, $this->mosConfig_locale); |
$gettext->setlocale($this->mosConfig_lang); |
|
/*dump($gettext->getlocale()); |
|
|
$gettext->bindtextdomain('administrator', $lang_path);/*dump($gettext->getlocale()); |
|
|
dump(setlocale(LC_CTYPE, ''));; |
|
|
|
|
|
|
|
|
dump(array($gettext, $this));*/ |
|
|
|
|
| 226 |
} |
} |
| 227 |
|
|
| 228 |
function handleGlobals () { |
function handleGlobals () { |
| 421 |
|
|
| 422 |
} |
} |
| 423 |
|
|
| 424 |
|
/* This is the new error handler to store errors in the database |
| 425 |
|
class mosErrorHandler { |
| 426 |
|
var $types = array ( |
| 427 |
|
E_STRICT => 'Strict check', |
| 428 |
|
E_USER_WARNING => 'User Warning', |
| 429 |
|
E_USER_NOTICE => 'User Notice', |
| 430 |
|
E_WARNING => 'Warning', |
| 431 |
|
E_NOTICE => 'Notice', |
| 432 |
|
E_CORE_WARNING => 'Core Warning', |
| 433 |
|
E_COMPILE_WARNING => 'Compile Warning', |
| 434 |
|
E_USER_ERROR => 'User Error', |
| 435 |
|
E_ERROR => 'Error', |
| 436 |
|
E_PARSE => 'Parse error', |
| 437 |
|
E_CORE_ERROR => 'Core Error', |
| 438 |
|
E_COMPILE_ERROR => 'Compile Error' |
| 439 |
|
); |
| 440 |
|
|
| 441 |
|
function mosErrorHandler () { |
| 442 |
|
set_error_handler(array(&$this, 'handler')); |
| 443 |
|
} |
| 444 |
|
|
| 445 |
|
function handler ($errno, $errstr, $errfile, $errline, $errcontext) { |
| 446 |
|
if ($errno = E_STRICT) return; |
| 447 |
|
$string = $this->types[$errno].': '.$errstr.' in '.$errfile.' at '.$errline; |
| 448 |
|
$database = mamboDatabase::getInstance(); |
| 449 |
|
if (eregi('^(sql)$', $errstr)) { |
| 450 |
|
$extra = $database->getErrorMsg(); |
| 451 |
|
} |
| 452 |
|
if (function_exists('debug_backtrace')) { |
| 453 |
|
foreach(debug_backtrace() as $back) { |
| 454 |
|
if (@$back['file']) { |
| 455 |
|
$extra .= "\n".$back['file'].':'.$back['line']; |
| 456 |
|
} |
| 457 |
|
} |
| 458 |
|
} |
| 459 |
|
$database->setQuery("DELETE FROM #__errors WHERE file=$errfile AND line=$errline AND number=$errno"); |
| 460 |
|
$database->query(); |
| 461 |
|
$database->setQuery("INSERT INTO #__errors VALUES (0, $errno, '$errfile', $errline, '$string', '$extra')"); |
| 462 |
|
$database->query(); |
| 463 |
|
} |
| 464 |
|
} |
| 465 |
|
*/ |
| 466 |
|
|
| 467 |
if (!isset($adminside)) $adminside = 0; |
if (!isset($adminside)) $adminside = 0; |
| 468 |
if (!isset($indextype)) $indextype = 1; |
if (!isset($indextype)) $indextype = 1; |
| 469 |
|
|
| 471 |
$configuration->handleGlobals(); |
$configuration->handleGlobals(); |
| 472 |
|
|
| 473 |
require_once ($configuration->rootPath().'/includes/database.php'); |
require_once ($configuration->rootPath().'/includes/database.php'); |
| 474 |
|
//new mosErrorHandler(); |
| 475 |
|
|
| 476 |
/** |
/** |
| 477 |
* Mambo basic error object |
* Mambo basic error object |
| 681 |
/** |
/** |
| 682 |
* @param database A database connector object |
* @param database A database connector object |
| 683 |
*/ |
*/ |
| 684 |
function mosMenu( $dummy ) { |
function mosMenu() { |
| 685 |
$db =& mamboDatabase::getInstance(); |
$db =& mamboDatabase::getInstance(); |
| 686 |
$this->mosDBTable( '#__menu', 'id', $db ); |
$this->mosDBTable( '#__menu', 'id', $db ); |
| 687 |
} |
} |
| 844 |
$ret = true; |
$ret = true; |
| 845 |
if (is_dir($path)) { |
if (is_dir($path)) { |
| 846 |
$topdir =& new mosDirectory($path); |
$topdir =& new mosDirectory($path); |
| 847 |
$files =& $topdir->listFiles ('', 'file', true); |
$files =& $topdir->listFiles ('', 'file', true, true); |
| 848 |
$dirs =& $topdir->listFiles ('', 'dir', true); |
$dirs =& $topdir->listFiles ('', 'dir', true, true); |
| 849 |
} |
} |
| 850 |
else { |
else { |
| 851 |
$files = array($path); |
$files = array($path); |
| 971 |
* Constructor |
* Constructor |
| 972 |
*/ |
*/ |
| 973 |
function mosMenuHandler() { |
function mosMenuHandler() { |
|
global $my; |
|
| 974 |
$database =& mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 975 |
$sql = "SELECT * FROM #__menu ORDER BY name"; |
$sql = "SELECT * FROM #__menu ORDER BY name"; |
| 976 |
$this->_menus =& $database->doSQLget($sql, 'mosMenu'); |
$this->_menus =& $database->doSQLget($sql, 'mosMenu'); |
| 1018 |
return $result; |
return $result; |
| 1019 |
} |
} |
| 1020 |
|
|
| 1021 |
|
function &getMenuTypes () { |
| 1022 |
|
$types = array(); |
| 1023 |
|
foreach ($this->_menus as $menu) { |
| 1024 |
|
if (!isset($types[$menu->menutype])) $types[$menu->menutype] = 0; |
| 1025 |
|
$types[$menu->menutype]++; |
| 1026 |
|
} |
| 1027 |
|
return $types; |
| 1028 |
|
} |
| 1029 |
|
|
| 1030 |
function getIDByTypeLink ($type, $link) { |
function getIDByTypeLink ($type, $link) { |
| 1031 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1032 |
if ($menu->published == 1 AND ($type == '*' OR $menu->type == $type) AND $menu->link == $link) return $menu->id; |
if ($menu->published == 1 AND ($type == '*' OR $menu->type == $type) AND $menu->link == $link) return $menu->id; |
| 1144 |
* @return boolean True if the visitor's group at least equal to the menu access |
* @return boolean True if the visitor's group at least equal to the menu access |
| 1145 |
*/ |
*/ |
| 1146 |
function menuCheck( $Itemid, $menu_option, $task, $gid ) { |
function menuCheck( $Itemid, $menu_option, $task, $gid ) { |
| 1147 |
$exceptions = array ('com_banner', 'com_poll', 'com_registration', 'com_rss'); |
// Construct a link to this component - if no menu for it, assume it is OK |
|
if (in_array($menu_option, $exceptions)) return true; |
|
| 1148 |
$dblink="index.php?option=$menu_option"; |
$dblink="index.php?option=$menu_option"; |
| 1149 |
|
if ($this->getIDLikeLink($dblink) == 0) return true; |
| 1150 |
if ($Itemid) { |
if ($Itemid) { |
| 1151 |
$menu =& $this->getMenuByID($Itemid); |
$menu =& $this->getMenuByID($Itemid); |
| 1152 |
if (strpos($menu->link,$dblink) ===0) $access = $menu->access; |
if (strpos($menu->link,$dblink) ===0) $access = $menu->access; |
| 1235 |
*/ |
*/ |
| 1236 |
function mosShowVIMenu( &$params ) { |
function mosShowVIMenu( &$params ) { |
| 1237 |
global $my, $cur_template, $Itemid; |
global $my, $cur_template, $Itemid; |
|
|
|
| 1238 |
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
| 1239 |
else $maxaccess = $my->gid; |
else $maxaccess = $my->gid; |
| 1240 |
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess); |
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess); |
| 1543 |
var $sendEmail=null; |
var $sendEmail=null; |
| 1544 |
/** @var int The group id number */ |
/** @var int The group id number */ |
| 1545 |
var $gid=null; |
var $gid=null; |
| 1546 |
|
/** @var int Group number from ACL */ |
| 1547 |
|
var $grp=null; |
| 1548 |
/** @var datetime */ |
/** @var datetime */ |
| 1549 |
var $registerDate=null; |
var $registerDate=null; |
| 1550 |
/** @var datetime */ |
/** @var datetime */ |
| 1557 |
/** |
/** |
| 1558 |
* @param database A database connector object |
* @param database A database connector object |
| 1559 |
*/ |
*/ |
| 1560 |
function mosUser( $dummy ) { |
function mosUser() { |
| 1561 |
$database =& mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 1562 |
$this->mosDBTable( '#__users', 'id', $database ); |
$this->mosDBTable( '#__users', 'id', $database ); |
| 1563 |
} |
} |
| 1564 |
|
|
| 1565 |
/** |
/** |
| 1566 |
|
* Return true if this user is an administrator, false otherwise |
| 1567 |
|
*/ |
| 1568 |
|
function isAdmin() { |
| 1569 |
|
return ( strtolower( $this->usertype ) == 'superadministrator' OR strtolower( $this->usertype ) == 'super administrator' OR (isset($this->grp) AND $this->grp == 16) ) ? true : false; |
| 1570 |
|
} |
| 1571 |
|
|
| 1572 |
|
/** |
| 1573 |
* Fill a user object with information from the current session |
* Fill a user object with information from the current session |
| 1574 |
*/ |
*/ |
| 1575 |
function getSessionData() { |
function getSessionData() { |
| 1579 |
$this->usertype = $session->usertype; |
$this->usertype = $session->usertype; |
| 1580 |
$this->gid = intval( $session->gid ); |
$this->gid = intval( $session->gid ); |
| 1581 |
} |
} |
| 1582 |
|
|
| 1583 |
|
function getSession () { |
| 1584 |
|
$this->id = mosGetParam( $_SESSION, 'session_user_id', 0 ); |
| 1585 |
|
$this->username = mosGetParam( $_SESSION, 'session_username', '' ); |
| 1586 |
|
$this->usertype = mosGetParam( $_SESSION, 'session_usertype', '' ); |
| 1587 |
|
$this->gid = mosGetParam( $_SESSION, 'session_gid', 0 ); |
| 1588 |
|
$this->grp = mosGetParam( $_SESSION, 'session_grp', 0); |
| 1589 |
|
} |
| 1590 |
/** |
/** |
| 1591 |
* Validation and filtering |
* Validation and filtering |
| 1592 |
* @return boolean True is satisfactory |
* @return boolean True is satisfactory |
| 1644 |
} |
} |
| 1645 |
|
|
| 1646 |
function delete($oid=null) { |
function delete($oid=null) { |
| 1647 |
|
global $acl; |
| 1648 |
|
$k = $this->_tbl_key; |
| 1649 |
if ($oid) $this->id = intval( $oid ); |
if ($oid) $this->id = intval( $oid ); |
| 1650 |
$aro_id = $acl->get_object_id( 'users', $this->$k, 'ARO' ); |
$aro_id = $acl->get_object_id( 'users', $this->$k, 'ARO' ); |
| 1651 |
$acl->del_object( $aro_id, 'ARO', true ); |
$acl->del_object( $aro_id, 'ARO', true ); |
| 2176 |
class mosSession extends mosDBTable { |
class mosSession extends mosDBTable { |
| 2177 |
/** @var int Primary key */ |
/** @var int Primary key */ |
| 2178 |
var $session_id=null; |
var $session_id=null; |
| 2179 |
/** @var string */ |
/** @var time */ |
| 2180 |
var $time=null; |
var $time=null; |
| 2181 |
/** @var string */ |
/** @var int User ID */ |
| 2182 |
var $userid=0; |
var $userid=0; |
| 2183 |
/** @var string */ |
/** @var string */ |
| 2184 |
var $usertype=null; |
var $usertype=null; |
| 2185 |
/** @var string */ |
/** @var string */ |
| 2186 |
var $username=''; |
var $username=''; |
| 2187 |
/** @var time */ |
/** @var int User group ID */ |
| 2188 |
var $gid=0; |
var $gid=0; |
| 2189 |
/** @var int */ |
/** @var int */ |
| 2190 |
var $guest=1; |
var $guest=1; |
| 2194 |
/** |
/** |
| 2195 |
* @param database A database connector object |
* @param database A database connector object |
| 2196 |
*/ |
*/ |
| 2197 |
function mosSession( &$db ) { |
function mosSession() { |
| 2198 |
$database =& mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 2199 |
$this->mosDBTable( '#__session', 'session_id', $database ); |
$this->mosDBTable( '#__session', 'session_id', $database ); |
| 2200 |
$this->time = time(); |
$this->time = time(); |
| 2201 |
} |
} |
| 2202 |
|
|
| 2203 |
|
function validate ($user) { |
| 2204 |
|
// check against db record of session |
| 2205 |
|
$session_id = mosGetParam( $_SESSION, 'session_id', '' ); |
| 2206 |
|
$logintime = mosGetParam( $_SESSION, 'session_logintime', '' ); |
| 2207 |
|
if ($session_id == md5( $user->id.$user->username.$user->usertype.$logintime )) { |
| 2208 |
|
$current_time = time(); |
| 2209 |
|
$database = mamboDatabase::getInstance(); |
| 2210 |
|
$database->setQuery ("UPDATE #__session" |
| 2211 |
|
. "\nSET time='$current_time', guest=-3-guest" |
| 2212 |
|
. "\nWHERE session_id='$session_id'" |
| 2213 |
|
. " AND username = '" . $database->getEscaped( $user->username ) . "'" |
| 2214 |
|
. " AND userid = " . intval( $user->id ) |
| 2215 |
|
); |
| 2216 |
|
if (!$result = $database->query()) echo $database->stderr(); |
| 2217 |
|
elseif ($database->getAffectedRows() == 1) return true; |
| 2218 |
|
} |
| 2219 |
|
return false; |
| 2220 |
|
} |
| 2221 |
|
|
| 2222 |
function &getCurrent () { |
function &getCurrent () { |
| 2223 |
static $currentSession; |
static $currentSession; |
| 2224 |
if (!is_object($currentSession)) { |
if (!is_object($currentSession)) { |
| 2225 |
$currentSession = new mosSession($dummy); |
$currentSession = new mosSession(); |
| 2226 |
$currentSession->purge(intval(mamboCore::get('mosConfig_lifetime'))); |
mosSession::purge(); |
| 2227 |
$sessionCookieName = md5('site'.mamboCore::get('mosConfig_live_site')); |
$sessionCookieName = md5('site'.mamboCore::get('mosConfig_live_site')); |
| 2228 |
$sessioncookie = mosGetParam($_COOKIE, $sessionCookieName, null); |
$sessioncookie = mosGetParam($_COOKIE, $sessionCookieName, null); |
| 2229 |
$usercookie = mosGetParam($_COOKIE, 'usercookie', null); |
$usercookie = mosGetParam($_COOKIE, 'usercookie', null); |
| 2279 |
if ($randnum != "") { |
if ($randnum != "") { |
| 2280 |
$cryptrandnum = md5( $randnum ); |
$cryptrandnum = md5( $randnum ); |
| 2281 |
$this->_db->setQuery( "SELECT $this->_tbl_key FROM $this->_tbl WHERE $this->_tbl_key=MD5('$randnum')" ); |
$this->_db->setQuery( "SELECT $this->_tbl_key FROM $this->_tbl WHERE $this->_tbl_key=MD5('$randnum')" ); |
| 2282 |
if(!$result = $this->_db->query()) { |
if(!($result = $this->_db->query())) { |
| 2283 |
die( $this->_db->stderr( true )); |
die( $this->_db->stderr( true )); |
| 2284 |
// todo: handle gracefully |
// todo: handle gracefully |
| 2285 |
} |
} |
| 2296 |
return $this->_session_cookie; |
return $this->_session_cookie; |
| 2297 |
} |
} |
| 2298 |
|
|
| 2299 |
function purge( $inc=1800 ) { |
function purge () { |
| 2300 |
$past = time() - $inc; |
$past = time() - intval(mamboCore::get('mosConfig_lifetime')); |
| 2301 |
$query = "DELETE FROM $this->_tbl" |
$adminpast = time() - 3600; |
| 2302 |
. "\nWHERE (time < $past)"; |
$database = mamboDatabase::getInstance(); |
| 2303 |
$this->_db->setQuery($query); |
$database->setQuery("DELETE FROM #__session WHERE (time<$past AND guest>=0) OR (time<$adminpast AND guest<0)"); |
| 2304 |
|
return $database->query(); |
|
return $this->_db->query(); |
|
| 2305 |
} |
} |
| 2306 |
|
|
| 2307 |
} |
} |
| 2308 |
|
|
| 2309 |
/** |
/** |
| 2421 |
if (count($parser->html)) return implode("\n", $parser->html); |
if (count($parser->html)) return implode("\n", $parser->html); |
| 2422 |
} |
} |
| 2423 |
$raw = $this->_raw; |
$raw = $this->_raw; |
| 2424 |
return "<textarea name='$name' cols='40' rows='10' class='text_area'$raw</textarea>"; |
return "<textarea name='$name' cols='40' rows='10' class='text_area'>$raw</textarea>"; |
| 2425 |
} |
} |
| 2426 |
|
|
| 2427 |
/** |
/** |
| 2456 |
} |
} |
| 2457 |
} |
} |
| 2458 |
|
|
| 2459 |
|
|
| 2460 |
require($configuration->rootPath().'/includes/version.php'); |
require($configuration->rootPath().'/includes/version.php'); |
| 2461 |
$_VERSION =& new version(); |
$_VERSION =& new version(); |
| 2462 |
|
|
| 2507 |
$act = strtolower(mosGetParam($_REQUEST, 'act', '')); |
$act = strtolower(mosGetParam($_REQUEST, 'act', '')); |
| 2508 |
$section = mosGetParam($_REQUEST, 'section', ''); |
$section = mosGetParam($_REQUEST, 'section', ''); |
| 2509 |
$no_html = strtolower(mosGetParam($_REQUEST, 'no_html', '')); |
$no_html = strtolower(mosGetParam($_REQUEST, 'no_html', '')); |
| 2510 |
|
$cid = (array) mosGetParam( $_POST, 'cid', array() ); |
| 2511 |
|
|
| 2512 |
|
ini_set('session.use_trans_sid', 0); |
| 2513 |
|
ini_set('session.use_cookies', 1); |
| 2514 |
|
ini_set('session.use_only_cookies', 1); |
| 2515 |
|
|
| 2516 |
|
|
| 2517 |
if ($adminside) { |
if ($adminside) { |
| 2518 |
// Start ACL |
// Start ACL |
| 2527 |
$gettext->bindtextdomain($domain, $lang_path); |
$gettext->bindtextdomain($domain, $lang_path); |
| 2528 |
$admindomain = $gettext->textdomain(); |
$admindomain = $gettext->textdomain(); |
| 2529 |
$gettext->textdomain('administrator'); |
$gettext->textdomain('administrator'); |
| 2530 |
// Login will, if it succeeds, start a new session and set $my |
session_name(md5(mamboCore::get('mosConfig_live_site'))); |
| 2531 |
if ($option == 'login') { |
session_start(); |
| 2532 |
|
// restore some session variables |
| 2533 |
|
$my = new mosUser(); |
| 2534 |
|
$my->getSession(); |
| 2535 |
|
if (mosSession::validate($my)) mosSession::purge(); |
| 2536 |
|
else $my = null; |
| 2537 |
|
if (!$my AND $option == 'login') { |
| 2538 |
require_once($configuration->rootPath().'/includes/authenticator.php'); |
require_once($configuration->rootPath().'/includes/authenticator.php'); |
| 2539 |
$authenticator =& mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 2540 |
$my = $authenticator->loginAdmin($acl); |
$my = $authenticator->loginAdmin($acl); |
| 2541 |
} |
} |
|
// If this is not login, we should already have a valid admin session |
|
|
else { |
|
|
session_name(md5(mamboCore::get('mosConfig_live_site'))); |
|
|
session_start(); |
|
| 2542 |
// Handle the remaining special options |
// Handle the remaining special options |
| 2543 |
if ($option == 'logout') { |
elseif ($option == 'logout') { |
| 2544 |
require($configuration->rootPath().'/administrator/logout.php'); |
require($configuration->rootPath().'/administrator/logout.php'); |
| 2545 |
exit(); |
exit(); |
| 2546 |
} |
} |
|
if ($option == 'simple_mode') $admin_mode = 'on'; |
|
|
elseif ($option == 'advanced_mode') $admin_mode = 'off'; |
|
|
else $admin_mode = mosGetParam($_SESSION, 'simple_editing', ''); |
|
|
$_SESSION['simple_editing'] = mosGetParam($_POST, 'simple_editing', $admin_mode); |
|
|
// Include admin side functions, check that we have a valid admin side session |
|
|
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
|
|
$my = checkAdminSession($database); |
|
|
} |
|
| 2547 |
// We can now create the mainframe object |
// We can now create the mainframe object |
| 2548 |
$mainframe =& new mosMainFrame($database, $option, '..', true); |
$mainframe =& new mosMainFrame($database, $option, '..', true); |
| 2549 |
// Provided $my is set, we have a valid admin side session and can include remaining code |
// Provided $my is set, we have a valid admin side session and can include remaining code |
|
|
|
| 2550 |
if ($my) { |
if ($my) { |
| 2551 |
mamboCore::set('currentUser', $my); |
mamboCore::set('currentUser', $my); |
| 2552 |
|
if ($option == 'simple_mode') $admin_mode = 'on'; |
| 2553 |
|
elseif ($option == 'advanced_mode') $admin_mode = 'off'; |
| 2554 |
|
else $admin_mode = mosGetParam($_SESSION, 'simple_editing', ''); |
| 2555 |
|
$_SESSION['simple_editing'] = mosGetParam($_POST, 'simple_editing', $admin_mode); |
| 2556 |
|
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
| 2557 |
require_once( $configuration->rootPath().'/includes/mambo.php' ); |
require_once( $configuration->rootPath().'/includes/mambo.php' ); |
| 2558 |
require_once ($configuration->rootPath().'/includes/mambofunc.php'); |
require_once ($configuration->rootPath().'/includes/mambofunc.php'); |
| 2559 |
require_once ($configuration->rootPath().'/includes/mamboHTML.php'); |
require_once ($configuration->rootPath().'/includes/mamboHTML.php'); |
| 2577 |
$configuration->doGzip(); |
$configuration->doGzip(); |
| 2578 |
} |
} |
| 2579 |
else { |
else { |
| 2580 |
if (!$popup) { |
if (!isset($popup)) { |
| 2581 |
$pop = mosGetParam($_REQUEST, 'pop', ''); |
$pop = mosGetParam($_REQUEST, 'pop', ''); |
| 2582 |
if ($pop) require_once($configuration->rootPath()."/administrator/popups/$pop"); |
if ($pop) require($configuration->rootPath()."/administrator/popups/$pop"); |
| 2583 |
else require_once($configuration->rootPath()."/administrator/popups/index3pop.php"); |
else require($configuration->rootPath()."/administrator/popups/index3pop.php"); |
| 2584 |
$configuration->doGzip(); |
$configuration->doGzip(); |
| 2585 |
} |
} |
| 2586 |
} |
} |
| 2587 |
} |
} |
| 2588 |
// If $my was not set, the only possibility is to ask for an admin side login |
// If $my was not set, the only possibility is to offer a login screen |
| 2589 |
else { |
else { |
| 2590 |
$configuration->initGzip(); |
$configuration->initGzip(); |
| 2591 |
$path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/login.php'; |
$path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/login.php'; |
| 2611 |
elseif ($option == 'logout') $configuration->handleLogout(); |
elseif ($option == 'logout') $configuration->handleLogout(); |
| 2612 |
|
|
| 2613 |
$session =& mosSession::getCurrent(); |
$session =& mosSession::getCurrent(); |
| 2614 |
$my =& new mosUser($database); |
$my =& new mosUser(); |
| 2615 |
$my->getSessionData(); |
$my->getSessionData(); |
| 2616 |
mamboCore::set('currentUser',$my); |
mamboCore::set('currentUser',$my); |
| 2617 |
$configuration->offlineCheck($my, $database); |
$configuration->offlineCheck($my, $database); |
| 2640 |
require_once( $configuration->rootPath() . '/components/com_content/content.class.php' ); |
require_once( $configuration->rootPath() . '/components/com_content/content.class.php' ); |
| 2641 |
$acl = new gacl_api(); |
$acl = new gacl_api(); |
| 2642 |
|
|
|
|
|
| 2643 |
/** Get the component handler */ |
/** Get the component handler */ |
| 2644 |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
| 2645 |
$c_handler =& mosComponentHandler::getInstance(); |
$c_handler =& mosComponentHandler::getInstance(); |
| 2651 |
$menuhandler->setPathway($Itemid); |
$menuhandler->setPathway($Itemid); |
| 2652 |
if ($ret) { |
if ($ret) { |
| 2653 |
$gettext->textdomain(substr($option, 4)); // get the component lang file |
$gettext->textdomain(substr($option, 4)); // get the component lang file |
| 2654 |
require_once( $path ); |
require ($path); |
| 2655 |
$gettext->textdomain($frontdomain); |
$gettext->textdomain($frontdomain); |
| 2656 |
} |
} |
| 2657 |
else mosNotAuth(); |
else mosNotAuth(); |
| 2707 |
$configuration->doGzip(); |
$configuration->doGzip(); |
| 2708 |
} |
} |
| 2709 |
// displays queries performed for page |
// displays queries performed for page |
| 2710 |
if ($configuration->get('mosConfig_debug')) $database->displayLogged(); |
if ($configuration->get('mosConfig_debug') AND $adminside != 3) $database->displayLogged(); |
| 2711 |
|
|
| 2712 |
?> |
?> |