| 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; |
| 176 |
// favourites icon |
// favourites icon |
| 177 |
if (!isset($this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
if (!isset($this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
| 178 |
if (!file_exists($this->rootPath.'/images/'.$this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
if (!file_exists($this->rootPath.'/images/'.$this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
| 179 |
return $this->rootPath.'/images/'.$this->mosConfig_favicon; |
return $this->mosConfig_live_site.'/images/'.$this->mosConfig_favicon; |
| 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 |
$langfile = $this->rootPath.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR.$lang.'.xml'; |
$this->mosConfig_lang = mosGetParam($_POST, 'setLanguage', $this->mosConfig_lang); |
|
/*$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 |
} |
} |
| 739 |
return true; |
return true; |
| 740 |
} |
} |
| 741 |
|
|
| 742 |
function createDirectory ($dir) { |
function setPermissions ($fileSysObject) { |
| 743 |
if (is_dir($dir)) return true; |
if (file_exists($fileSysObject)) { |
| 744 |
list($upDirectory, $count) = $this->containingDirectory($dir); |
if (is_dir($fileSysObject)) $perms = mamboCore::get('mosConfig_dirperms'); |
| 745 |
if ($count > 1 AND !is_dir($upDirectory)) if (!$this->createDirectory($upDirectory)) return false; |
else $perms = mamboCore::get('mosConfig_fileperms'); |
| 746 |
$dirperms = mamboCore::get('mosConfig_dirperms'); |
if ($perms) { |
|
if ($dirperms) { |
|
| 747 |
$origmask = @umask(0); |
$origmask = @umask(0); |
| 748 |
$mode = octdec($dirperms); |
$mode = octdec($perms); |
| 749 |
|
@chmod($fileSysObject, $mode); |
| 750 |
|
@umask($origmask); |
| 751 |
|
} |
| 752 |
} |
} |
|
else $mode = 0777; |
|
|
if (!@mkdir($dir, $mode )) $result = false; |
|
|
else { |
|
|
$result = true; |
|
|
@chmod ($dir, $mode); |
|
| 753 |
} |
} |
| 754 |
if (isset($origmask)) @umask($origmask); |
|
| 755 |
|
function makeDirectory ($dir) { |
| 756 |
|
$perms = mamboCore::get('mosConfig_dirperms'); |
| 757 |
|
$origmask = @umask(0); |
| 758 |
|
if ($perms) $result = @mkdir($dir, octdec($perms)); |
| 759 |
|
else $result = @mkdir($dir, 0755); |
| 760 |
|
if ($result) $this->setPermissions($dir); |
| 761 |
|
@umask($origmask); |
| 762 |
return $result; |
return $result; |
| 763 |
} |
} |
| 764 |
|
|
| 765 |
|
|
| 766 |
|
function createDirectory ($dir, $onlyCheck=false) { |
| 767 |
|
if (file_exists($dir)) { |
| 768 |
|
if (is_dir($dir) AND is_writable($dir)) return true; |
| 769 |
|
else return false; |
| 770 |
|
} |
| 771 |
|
list($upDirectory, $count) = $this->containingDirectory($dir); |
| 772 |
|
if ($count > 1 AND !file_exists($upDirectory) AND !($result = $this->createDirectory($upDirectory, $onlyCheck))) return false; |
| 773 |
|
if ($onlyCheck AND isset($result)) return true; |
| 774 |
|
if (!is_dir($upDirectory) OR !is_writable($upDirectory)) return false; |
| 775 |
|
if ($onlyCheck) return true; |
| 776 |
|
else return $this->makeDirectory($dir); |
| 777 |
|
} |
| 778 |
|
|
| 779 |
function containingDirectory ($dir) { |
function containingDirectory ($dir) { |
| 780 |
$dirs = preg_split('*[/|\\\]*', $dir); |
$dirs = preg_split('*[/|\\\]*', $dir); |
| 781 |
for ($i = count($dirs)-1; $i >= 0; $i--) { |
for ($i = count($dirs)-1; $i >= 0; $i--) { |
| 783 |
unset($dirs[$i]); |
unset($dirs[$i]); |
| 784 |
if ($text) break; |
if ($text) break; |
| 785 |
} |
} |
| 786 |
return array(implode('/',$dirs), count($dirs)); |
$result2 = count($dirs); |
| 787 |
|
$result1 = implode('/',$dirs).($result2 > 1 ? '' : '/'); |
| 788 |
|
return array($result1, $result2); |
| 789 |
} |
} |
| 790 |
|
|
| 791 |
|
function simpleCopy ($from, $to) { |
| 792 |
|
if (@copy($from, $to)) { |
| 793 |
|
$this->setPermissions($to); |
| 794 |
|
return true; |
| 795 |
|
} |
| 796 |
|
else return false; |
| 797 |
|
} |
| 798 |
|
|
| 799 |
function forceCopy ($from, $to) { |
function forceCopy ($from, $to) { |
| 800 |
$todir = dirname($to); |
$todir = dirname($to); |
| 802 |
if (!file_exists($todir)) return false; |
if (!file_exists($todir)) return false; |
| 803 |
$name = basename($from); |
$name = basename($from); |
| 804 |
$this->deleteFile($to.$name); |
$this->deleteFile($to.$name); |
| 805 |
return @copy($from, $to); |
return $this->simpleCopy ($from, $to); |
| 806 |
} |
} |
| 807 |
|
|
| 808 |
function lightCopy ($from, $to) { |
function lightCopy ($from, $to) { |
| 811 |
$todir = dirname($to); |
$todir = dirname($to); |
| 812 |
if (!file_exists($todir)) $this->createDirectory($todir); |
if (!file_exists($todir)) $this->createDirectory($todir); |
| 813 |
if (!file_exists($todir)) return false; |
if (!file_exists($todir)) return false; |
| 814 |
return @copy($from, $to); |
return $this->simpleCopy ($from, $to); |
| 815 |
|
} |
| 816 |
|
|
| 817 |
|
function acceptCopy ($to) { |
| 818 |
|
$todir = dirname($to); |
| 819 |
|
return $this->createDirectory($todir, true); |
| 820 |
} |
} |
| 821 |
|
|
| 822 |
|
|
| 872 |
$ret = true; |
$ret = true; |
| 873 |
if (is_dir($path)) { |
if (is_dir($path)) { |
| 874 |
$topdir =& new mosDirectory($path); |
$topdir =& new mosDirectory($path); |
| 875 |
$files =& $topdir->listFiles ('', 'file', true); |
$files =& $topdir->listFiles ('', 'file', true, true); |
| 876 |
$dirs =& $topdir->listFiles ('', 'dir', true); |
$dirs =& $topdir->listFiles ('', 'dir', true, true); |
| 877 |
} |
} |
| 878 |
else { |
else { |
| 879 |
$files = array($path); |
$files = array($path); |
| 999 |
* Constructor |
* Constructor |
| 1000 |
*/ |
*/ |
| 1001 |
function mosMenuHandler() { |
function mosMenuHandler() { |
|
global $my; |
|
| 1002 |
$database =& mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 1003 |
$sql = "SELECT * FROM #__menu ORDER BY name"; |
$sql = "SELECT * FROM #__menu ORDER BY name"; |
| 1004 |
$this->_menus =& $database->doSQLget($sql, 'mosMenu'); |
$this->_menus =& $database->doSQLget($sql, 'mosMenu'); |
| 1026 |
function &getMenuByID ($id) { |
function &getMenuByID ($id) { |
| 1027 |
if (isset($this->_idlinks[$id])) { |
if (isset($this->_idlinks[$id])) { |
| 1028 |
$key = $this->_idlinks[$id]; |
$key = $this->_idlinks[$id]; |
| 1029 |
return $this->_menus[$key]; |
$result = $this->_menus[$key]; |
| 1030 |
} |
} |
| 1031 |
$result = null; |
else $result = null; |
| 1032 |
return $result; |
return $result; |
| 1033 |
} |
} |
| 1034 |
|
|
| 1046 |
return $result; |
return $result; |
| 1047 |
} |
} |
| 1048 |
|
|
| 1049 |
|
function &getMenuTypes () { |
| 1050 |
|
$types = array(); |
| 1051 |
|
foreach ($this->_menus as $menu) { |
| 1052 |
|
if (!isset($types[$menu->menutype])) $types[$menu->menutype] = 0; |
| 1053 |
|
$types[$menu->menutype]++; |
| 1054 |
|
} |
| 1055 |
|
return $types; |
| 1056 |
|
} |
| 1057 |
|
|
| 1058 |
function getIDByTypeLink ($type, $link) { |
function getIDByTypeLink ($type, $link) { |
| 1059 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1060 |
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 |
$menu = $this->_menus[$key]; |
$menu = $this->_menus[$key]; |
| 1145 |
if ($menutype AND $mtype != $menutype) continue; |
if ($menutype AND $mtype != $menutype) continue; |
| 1146 |
if ($Itemid AND $Itemid != $menu->id) continue; |
if ($Itemid AND $Itemid != $menu->id) continue; |
| 1147 |
if ($maxaccess AND $menu->access > $maxaccess) continue; |
if ($menu->access > $maxaccess) continue; |
| 1148 |
if ($noparent AND $parent != 0) continue; |
if ($noparent AND $parent != 0) continue; |
| 1149 |
$result[] = $this->_menus[$key]; |
$result[] = $this->_menus[$key]; |
| 1150 |
} |
} |
| 1172 |
* @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 |
| 1173 |
*/ |
*/ |
| 1174 |
function menuCheck( $Itemid, $menu_option, $task, $gid ) { |
function menuCheck( $Itemid, $menu_option, $task, $gid ) { |
| 1175 |
$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; |
|
| 1176 |
$dblink="index.php?option=$menu_option"; |
$dblink="index.php?option=$menu_option"; |
| 1177 |
|
if ($menu_option == 'com_content' AND $Itemid == 1) return true; |
| 1178 |
|
if ($this->getIDLikeLink($dblink) == 0) return true; |
| 1179 |
if ($Itemid) { |
if ($Itemid) { |
| 1180 |
$menu =& $this->getMenuByID($Itemid); |
$menu =& $this->getMenuByID($Itemid); |
| 1181 |
if (strpos($menu->link,$dblink) ===0) $access = $menu->access; |
if (strpos($menu->link,$dblink) ===0) $access = $menu->access; |
| 1264 |
*/ |
*/ |
| 1265 |
function mosShowVIMenu( &$params ) { |
function mosShowVIMenu( &$params ) { |
| 1266 |
global $my, $cur_template, $Itemid; |
global $my, $cur_template, $Itemid; |
|
|
|
| 1267 |
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
| 1268 |
else $maxaccess = $my->gid; |
else $maxaccess = $my->gid; |
| 1269 |
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess); |
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess); |
| 1426 |
* @param int the subscript for use in the main array of mambots |
* @param int the subscript for use in the main array of mambots |
| 1427 |
*/ |
*/ |
| 1428 |
function _botRegister (&$botObject, &$selected, $i) { |
function _botRegister (&$botObject, &$selected, $i) { |
| 1429 |
$function = array(&$newbot, 'perform'); |
$function = array(&$botObject, 'perform'); |
| 1430 |
if (!is_callable($function)) return; |
if (!is_callable($function)) return; |
| 1431 |
if (is_array($selected)) foreach ($selected as $select) $this->_botRegister($botObject, $select); |
if (is_array($selected)) foreach ($selected as $select) $this->_botRegister($botObject, $select); |
| 1432 |
$this->_events[$selected][] = array ($function, $i); |
$this->_events[$selected][] = array ($function, $i); |
| 1572 |
var $sendEmail=null; |
var $sendEmail=null; |
| 1573 |
/** @var int The group id number */ |
/** @var int The group id number */ |
| 1574 |
var $gid=null; |
var $gid=null; |
| 1575 |
|
/** @var int Group number from ACL */ |
| 1576 |
|
var $grp=null; |
| 1577 |
/** @var datetime */ |
/** @var datetime */ |
| 1578 |
var $registerDate=null; |
var $registerDate=null; |
| 1579 |
/** @var datetime */ |
/** @var datetime */ |
| 1586 |
/** |
/** |
| 1587 |
* @param database A database connector object |
* @param database A database connector object |
| 1588 |
*/ |
*/ |
| 1589 |
function mosUser( $dummy ) { |
function mosUser() { |
| 1590 |
$database =& mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 1591 |
$this->mosDBTable( '#__users', 'id', $database ); |
$this->mosDBTable( '#__users', 'id', $database ); |
| 1592 |
} |
} |
| 1593 |
|
|
| 1594 |
/** |
/** |
| 1595 |
|
* Return true if this user is an administrator, false otherwise |
| 1596 |
|
*/ |
| 1597 |
|
function isAdmin() { |
| 1598 |
|
return ( strtolower( $this->usertype ) == 'superadministrator' OR strtolower( $this->usertype ) == 'super administrator' OR (isset($this->grp) AND $this->grp == 16) ) ? true : false; |
| 1599 |
|
} |
| 1600 |
|
|
| 1601 |
|
/** |
| 1602 |
* Fill a user object with information from the current session |
* Fill a user object with information from the current session |
| 1603 |
*/ |
*/ |
| 1604 |
function getSessionData() { |
function getSessionData() { |
| 1608 |
$this->usertype = $session->usertype; |
$this->usertype = $session->usertype; |
| 1609 |
$this->gid = intval( $session->gid ); |
$this->gid = intval( $session->gid ); |
| 1610 |
} |
} |
| 1611 |
|
|
| 1612 |
|
function getSession () { |
| 1613 |
|
$this->id = mosGetParam( $_SESSION, 'session_user_id', 0 ); |
| 1614 |
|
$this->username = mosGetParam( $_SESSION, 'session_username', '' ); |
| 1615 |
|
$this->usertype = mosGetParam( $_SESSION, 'session_usertype', '' ); |
| 1616 |
|
$this->gid = mosGetParam( $_SESSION, 'session_gid', 0 ); |
| 1617 |
|
$this->grp = mosGetParam( $_SESSION, 'session_grp', 0); |
| 1618 |
|
} |
| 1619 |
/** |
/** |
| 1620 |
* Validation and filtering |
* Validation and filtering |
| 1621 |
* @return boolean True is satisfactory |
* @return boolean True is satisfactory |
| 1673 |
} |
} |
| 1674 |
|
|
| 1675 |
function delete($oid=null) { |
function delete($oid=null) { |
| 1676 |
|
global $acl; |
| 1677 |
|
$k = $this->_tbl_key; |
| 1678 |
if ($oid) $this->id = intval( $oid ); |
if ($oid) $this->id = intval( $oid ); |
| 1679 |
$aro_id = $acl->get_object_id( 'users', $this->$k, 'ARO' ); |
$aro_id = $acl->get_object_id( 'users', $this->$k, 'ARO' ); |
| 1680 |
$acl->del_object( $aro_id, 'ARO', true ); |
$acl->del_object( $aro_id, 'ARO', true ); |
| 2205 |
class mosSession extends mosDBTable { |
class mosSession extends mosDBTable { |
| 2206 |
/** @var int Primary key */ |
/** @var int Primary key */ |
| 2207 |
var $session_id=null; |
var $session_id=null; |
| 2208 |
/** @var string */ |
/** @var time */ |
| 2209 |
var $time=null; |
var $time=null; |
| 2210 |
/** @var string */ |
/** @var int User ID */ |
| 2211 |
var $userid=0; |
var $userid=0; |
| 2212 |
/** @var string */ |
/** @var string */ |
| 2213 |
var $usertype=null; |
var $usertype=null; |
| 2214 |
/** @var string */ |
/** @var string */ |
| 2215 |
var $username=''; |
var $username=''; |
| 2216 |
/** @var time */ |
/** @var int User group ID */ |
| 2217 |
var $gid=0; |
var $gid=0; |
| 2218 |
/** @var int */ |
/** @var int */ |
| 2219 |
var $guest=1; |
var $guest=1; |
| 2223 |
/** |
/** |
| 2224 |
* @param database A database connector object |
* @param database A database connector object |
| 2225 |
*/ |
*/ |
| 2226 |
function mosSession( &$db ) { |
function mosSession() { |
| 2227 |
$database =& mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 2228 |
$this->mosDBTable( '#__session', 'session_id', $database ); |
$this->mosDBTable( '#__session', 'session_id', $database ); |
| 2229 |
$this->time = time(); |
$this->time = time(); |
| 2230 |
} |
} |
| 2231 |
|
|
| 2232 |
|
function validate ($user) { |
| 2233 |
|
// check against db record of session |
| 2234 |
|
$session_id = mosGetParam( $_SESSION, 'session_id', '' ); |
| 2235 |
|
$logintime = mosGetParam( $_SESSION, 'session_logintime', '' ); |
| 2236 |
|
if ($session_id == md5( $user->id.$user->username.$user->usertype.$logintime )) { |
| 2237 |
|
$current_time = time(); |
| 2238 |
|
$database = mamboDatabase::getInstance(); |
| 2239 |
|
$database->setQuery ("UPDATE #__session" |
| 2240 |
|
. "\nSET time='$current_time', guest=-3-guest" |
| 2241 |
|
. "\nWHERE session_id='$session_id'" |
| 2242 |
|
. " AND username = '" . $database->getEscaped( $user->username ) . "'" |
| 2243 |
|
. " AND userid = " . intval( $user->id ) |
| 2244 |
|
); |
| 2245 |
|
if (!$result = $database->query()) echo $database->stderr(); |
| 2246 |
|
elseif ($database->getAffectedRows() == 1) return true; |
| 2247 |
|
} |
| 2248 |
|
return false; |
| 2249 |
|
} |
| 2250 |
|
|
| 2251 |
function &getCurrent () { |
function &getCurrent () { |
| 2252 |
static $currentSession; |
static $currentSession; |
| 2253 |
if (!is_object($currentSession)) { |
if (!is_object($currentSession)) { |
| 2254 |
$currentSession = new mosSession($dummy); |
$currentSession = new mosSession(); |
| 2255 |
$currentSession->purge(intval(mamboCore::get('mosConfig_lifetime'))); |
mosSession::purge(); |
| 2256 |
$sessionCookieName = md5('site'.mamboCore::get('mosConfig_live_site')); |
$sessionCookieName = md5('site'.mamboCore::get('mosConfig_live_site')); |
| 2257 |
$sessioncookie = mosGetParam($_COOKIE, $sessionCookieName, null); |
$sessioncookie = mosGetParam($_COOKIE, $sessionCookieName, null); |
| 2258 |
$usercookie = mosGetParam($_COOKIE, 'usercookie', null); |
$usercookie = mosGetParam($_COOKIE, 'usercookie', null); |
| 2308 |
if ($randnum != "") { |
if ($randnum != "") { |
| 2309 |
$cryptrandnum = md5( $randnum ); |
$cryptrandnum = md5( $randnum ); |
| 2310 |
$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')" ); |
| 2311 |
if(!$result = $this->_db->query()) { |
if(!($result = $this->_db->query())) { |
| 2312 |
die( $this->_db->stderr( true )); |
die( $this->_db->stderr( true )); |
| 2313 |
// todo: handle gracefully |
// todo: handle gracefully |
| 2314 |
} |
} |
| 2325 |
return $this->_session_cookie; |
return $this->_session_cookie; |
| 2326 |
} |
} |
| 2327 |
|
|
| 2328 |
function purge( $inc=1800 ) { |
function purge () { |
| 2329 |
$past = time() - $inc; |
$past = time() - intval(mamboCore::get('mosConfig_lifetime')); |
| 2330 |
$query = "DELETE FROM $this->_tbl" |
$adminpast = time() - 3600; |
| 2331 |
. "\nWHERE (time < $past)"; |
$database = mamboDatabase::getInstance(); |
| 2332 |
$this->_db->setQuery($query); |
$database->setQuery("DELETE FROM #__session WHERE (time<$past AND guest>=0) OR (time<$adminpast AND guest<0)"); |
| 2333 |
|
return $database->query(); |
|
return $this->_db->query(); |
|
| 2334 |
} |
} |
| 2335 |
|
|
| 2336 |
} |
} |
| 2337 |
|
|
| 2338 |
/** |
/** |
| 2450 |
if (count($parser->html)) return implode("\n", $parser->html); |
if (count($parser->html)) return implode("\n", $parser->html); |
| 2451 |
} |
} |
| 2452 |
$raw = $this->_raw; |
$raw = $this->_raw; |
| 2453 |
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>"; |
| 2454 |
} |
} |
| 2455 |
|
|
| 2456 |
/** |
/** |
| 2485 |
} |
} |
| 2486 |
} |
} |
| 2487 |
|
|
| 2488 |
|
|
| 2489 |
require($configuration->rootPath().'/includes/version.php'); |
require($configuration->rootPath().'/includes/version.php'); |
| 2490 |
$_VERSION =& new version(); |
$_VERSION =& new version(); |
| 2491 |
|
|
| 2536 |
$act = strtolower(mosGetParam($_REQUEST, 'act', '')); |
$act = strtolower(mosGetParam($_REQUEST, 'act', '')); |
| 2537 |
$section = mosGetParam($_REQUEST, 'section', ''); |
$section = mosGetParam($_REQUEST, 'section', ''); |
| 2538 |
$no_html = strtolower(mosGetParam($_REQUEST, 'no_html', '')); |
$no_html = strtolower(mosGetParam($_REQUEST, 'no_html', '')); |
| 2539 |
|
$cid = (array) mosGetParam( $_POST, 'cid', array() ); |
| 2540 |
|
|
| 2541 |
|
ini_set('session.use_trans_sid', 0); |
| 2542 |
|
ini_set('session.use_cookies', 1); |
| 2543 |
|
ini_set('session.use_only_cookies', 1); |
| 2544 |
|
|
| 2545 |
|
|
| 2546 |
if ($adminside) { |
if ($adminside) { |
| 2547 |
// Start ACL |
// Start ACL |
| 2556 |
$gettext->bindtextdomain($domain, $lang_path); |
$gettext->bindtextdomain($domain, $lang_path); |
| 2557 |
$admindomain = $gettext->textdomain(); |
$admindomain = $gettext->textdomain(); |
| 2558 |
$gettext->textdomain('administrator'); |
$gettext->textdomain('administrator'); |
| 2559 |
// Login will, if it succeeds, start a new session and set $my |
session_name(md5(mamboCore::get('mosConfig_live_site'))); |
| 2560 |
if ($option == 'login') { |
session_start(); |
| 2561 |
|
// restore some session variables |
| 2562 |
|
$my = new mosUser(); |
| 2563 |
|
$my->getSession(); |
| 2564 |
|
if (mosSession::validate($my)) mosSession::purge(); |
| 2565 |
|
else $my = null; |
| 2566 |
|
if (!$my AND $option == 'login') { |
| 2567 |
require_once($configuration->rootPath().'/includes/authenticator.php'); |
require_once($configuration->rootPath().'/includes/authenticator.php'); |
| 2568 |
$authenticator =& mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 2569 |
$my = $authenticator->loginAdmin($acl); |
$my = $authenticator->loginAdmin($acl); |
| 2570 |
} |
} |
|
// If this is not login, we should already have a valid admin session |
|
|
else { |
|
|
session_name(md5(mamboCore::get('mosConfig_live_site'))); |
|
|
session_start(); |
|
| 2571 |
// Handle the remaining special options |
// Handle the remaining special options |
| 2572 |
if ($option == 'logout') { |
elseif ($option == 'logout') { |
| 2573 |
require($configuration->rootPath().'/administrator/logout.php'); |
require($configuration->rootPath().'/administrator/logout.php'); |
| 2574 |
exit(); |
exit(); |
| 2575 |
} |
} |
|
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); |
|
|
} |
|
| 2576 |
// We can now create the mainframe object |
// We can now create the mainframe object |
| 2577 |
$mainframe =& new mosMainFrame($database, $option, '..', true); |
$mainframe =& new mosMainFrame($database, $option, '..', true); |
| 2578 |
// 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 |
|
|
|
| 2579 |
if ($my) { |
if ($my) { |
| 2580 |
mamboCore::set('currentUser', $my); |
mamboCore::set('currentUser', $my); |
| 2581 |
|
if ($option == 'simple_mode') $admin_mode = 'on'; |
| 2582 |
|
elseif ($option == 'advanced_mode') $admin_mode = 'off'; |
| 2583 |
|
else $admin_mode = mosGetParam($_SESSION, 'simple_editing', ''); |
| 2584 |
|
$_SESSION['simple_editing'] = mosGetParam($_POST, 'simple_editing', $admin_mode); |
| 2585 |
|
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
| 2586 |
require_once( $configuration->rootPath().'/includes/mambo.php' ); |
require_once( $configuration->rootPath().'/includes/mambo.php' ); |
| 2587 |
require_once ($configuration->rootPath().'/includes/mambofunc.php'); |
require_once ($configuration->rootPath().'/includes/mambofunc.php'); |
| 2588 |
require_once ($configuration->rootPath().'/includes/mamboHTML.php'); |
require_once ($configuration->rootPath().'/includes/mamboHTML.php'); |
| 2589 |
require_once( $configuration->rootPath().'/administrator/includes/mosAdminMenus.php'); |
require_once( $configuration->rootPath().'/administrator/includes/mosAdminMenus.php'); |
| 2590 |
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
| 2591 |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
| 2592 |
|
require_once( $configuration->rootPath() . '/components/com_content/content.class.php' ); |
| 2593 |
$_MAMBOTS =& mosMambotHandler::getInstance(); |
$_MAMBOTS =& mosMambotHandler::getInstance(); |
| 2594 |
|
|
| 2595 |
|
|
| 2606 |
$configuration->doGzip(); |
$configuration->doGzip(); |
| 2607 |
} |
} |
| 2608 |
else { |
else { |
| 2609 |
if (!$popup) { |
if (!isset($popup)) { |
| 2610 |
$pop = mosGetParam($_REQUEST, 'pop', ''); |
$pop = mosGetParam($_REQUEST, 'pop', ''); |
| 2611 |
if ($pop) require_once($configuration->rootPath()."/administrator/popups/$pop"); |
if ($pop) require($configuration->rootPath()."/administrator/popups/$pop"); |
| 2612 |
else require_once($configuration->rootPath()."/administrator/popups/index3pop.php"); |
else require($configuration->rootPath()."/administrator/popups/index3pop.php"); |
| 2613 |
$configuration->doGzip(); |
$configuration->doGzip(); |
| 2614 |
} |
} |
| 2615 |
} |
} |
| 2616 |
} |
} |
| 2617 |
// 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 |
| 2618 |
else { |
else { |
| 2619 |
$configuration->initGzip(); |
$configuration->initGzip(); |
| 2620 |
$path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/login.php'; |
$path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/login.php'; |
| 2640 |
elseif ($option == 'logout') $configuration->handleLogout(); |
elseif ($option == 'logout') $configuration->handleLogout(); |
| 2641 |
|
|
| 2642 |
$session =& mosSession::getCurrent(); |
$session =& mosSession::getCurrent(); |
| 2643 |
$my =& new mosUser($database); |
$my =& new mosUser(); |
| 2644 |
$my->getSessionData(); |
$my->getSessionData(); |
| 2645 |
mamboCore::set('currentUser',$my); |
mamboCore::set('currentUser',$my); |
| 2646 |
$configuration->offlineCheck($my, $database); |
$configuration->offlineCheck($my, $database); |
| 2666 |
require_once( $configuration->rootPath().'/editor/editor.php' ); |
require_once( $configuration->rootPath().'/editor/editor.php' ); |
| 2667 |
require_once( $configuration->rootPath() . '/includes/gacl.class.php' ); |
require_once( $configuration->rootPath() . '/includes/gacl.class.php' ); |
| 2668 |
require_once( $configuration->rootPath() . '/includes/gacl_api.class.php' ); |
require_once( $configuration->rootPath() . '/includes/gacl_api.class.php' ); |
| 2669 |
|
require_once( $configuration->rootPath() . '/components/com_content/content.class.php' ); |
| 2670 |
$acl = new gacl_api(); |
$acl = new gacl_api(); |
| 2671 |
|
|
|
|
|
| 2672 |
/** Get the component handler */ |
/** Get the component handler */ |
| 2673 |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
| 2674 |
$c_handler =& mosComponentHandler::getInstance(); |
$c_handler =& mosComponentHandler::getInstance(); |
| 2680 |
$menuhandler->setPathway($Itemid); |
$menuhandler->setPathway($Itemid); |
| 2681 |
if ($ret) { |
if ($ret) { |
| 2682 |
$gettext->textdomain(substr($option, 4)); // get the component lang file |
$gettext->textdomain(substr($option, 4)); // get the component lang file |
| 2683 |
require_once( $path ); |
require ($path); |
| 2684 |
$gettext->textdomain($frontdomain); |
$gettext->textdomain($frontdomain); |
| 2685 |
} |
} |
| 2686 |
else mosNotAuth(); |
else mosNotAuth(); |
| 2696 |
$configuration->initGzip(); |
$configuration->initGzip(); |
| 2697 |
|
|
| 2698 |
$configuration->standardHeaders(); |
$configuration->standardHeaders(); |
| 2699 |
if ($indextype == 1) { |
if (mosGetParam($_GET, 'syndstyle', '') == 'yes') mosMainBody(); |
| 2700 |
|
elseif ($indextype == 1) { |
| 2701 |
// loads template file |
// loads template file |
| 2702 |
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { |
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { |
| 2703 |
echo '<font color=\"red\"><b>'.T_('Template File Not Found! Looking for template').'</b></font>'.$cur_template; |
echo '<font color=\"red\"><b>'.T_('Template File Not Found! Looking for template').'</b></font>'.$cur_template; |
| 2736 |
$configuration->doGzip(); |
$configuration->doGzip(); |
| 2737 |
} |
} |
| 2738 |
// displays queries performed for page |
// displays queries performed for page |
| 2739 |
if ($configuration->get('mosConfig_debug')) $database->displayLogged(); |
if ($configuration->get('mosConfig_debug') AND $adminside != 3) $database->displayLogged(); |
| 2740 |
|
|
| 2741 |
?> |
?> |