| 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 |
|
|
| 51 |
} |
} |
| 52 |
|
|
| 53 |
function sefRelToAbs ($string) { |
function sefRelToAbs ($string) { |
| 54 |
$sef = mosSEF::getInstance(); |
$sef =& mosSEF::getInstance(); |
| 55 |
return $sef->sefRelToAbs($string); |
return $sef->sefRelToAbs($string); |
| 56 |
} |
} |
| 57 |
|
|
| 59 |
var $rootPath = ''; |
var $rootPath = ''; |
| 60 |
var $Itemid = 0; |
var $Itemid = 0; |
| 61 |
var $option = ''; |
var $option = ''; |
| 62 |
|
var $subdirectory; |
| 63 |
var $current_user = null; |
var $current_user = null; |
| 64 |
var $do_gzip_compress = false; |
var $do_gzip_compress = false; |
| 65 |
|
|
| 66 |
function mamboCore () { |
function mamboCore () { |
| 67 |
global $adminside; |
global $adminside; |
| 68 |
$this->rootPath = dirname(__FILE__); |
$this->rootPath = dirname(__FILE__); |
|
// $this->rootPath = substr($_SERVER['SCRIPT_FILENAME'],0,-strlen($_SERVER['PHP_SELF'])+1); |
|
|
// if ($adminside) $this->rootPath = substr($this->rootPath,0,strlen($this->rootPath)-14); |
|
| 69 |
$this->checkConfig(); |
$this->checkConfig(); |
| 70 |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 71 |
$this->getConfig(); |
$this->getConfig(); |
| 72 |
$this->fixLanguage(); |
$this->fixLanguage(); |
|
$this->secure(); |
|
| 73 |
@set_magic_quotes_runtime( 0 ); |
@set_magic_quotes_runtime( 0 ); |
| 74 |
if (@$this->mosConfig_error_reporting === 0) error_reporting(0); |
if (@$this->mosConfig_error_reporting === 0) error_reporting(0); |
| 75 |
elseif (@$this->mosConfig_error_reporting > 0) error_reporting($this->mosConfig_error_reporting); |
elseif (@$this->mosConfig_error_reporting > 0) error_reporting($this->mosConfig_error_reporting); |
| 89 |
|
|
| 90 |
function get ($property) { |
function get ($property) { |
| 91 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 92 |
if ($property == 'mosConfig_absolute_path' AND realpath($config->mosConfig_absolute_path) === false) die ('Invalid program load path'); |
if ($property == 'mosConfig_absolute_path') { |
| 93 |
|
if (realpath($config->mosConfig_absolute_path) === false) die ('Invalid program load path'); |
| 94 |
|
else return $config->rootPath; |
| 95 |
|
} |
| 96 |
if (isset($config->$property)) return $config->$property; |
if (isset($config->$property)) return $config->$property; |
| 97 |
trigger_error("Invalid property ($property) requested from mamboCore"); |
trigger_error("Invalid property ($property) requested from mamboCore"); |
| 98 |
return null; |
return null; |
| 125 |
while ($f AND !feof($f)) { |
while ($f AND !feof($f)) { |
| 126 |
$line = fgets($f, 256); |
$line = fgets($f, 256); |
| 127 |
$altered = str_replace('$', '$this->', $line); |
$altered = str_replace('$', '$this->', $line); |
| 128 |
if ($line != $altered) $code .= $altered; |
if ($altered != $line) $code .= $altered; |
| 129 |
} |
} |
| 130 |
} |
} |
| 131 |
else { |
else { |
| 135 |
fclose($f); |
fclose($f); |
| 136 |
eval($code); |
eval($code); |
| 137 |
$subdir = substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])); |
$subdir = substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])); |
| 138 |
$subdir = str_replace('\\', '/', $subdir); |
$this->subdirectory = str_replace('\\', '/', $subdir); |
| 139 |
$this->mosConfig_live_site = 'http://'.$_SERVER['SERVER_NAME'].$subdir; |
$scheme = isset($_SERVER['HTTP_SCHEME']) ? $_SERVER['HTTP_SCHEME'] : ((isset($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS'] != 'off')) ? 'https' : 'http'); |
| 140 |
|
if (isset($_SERVER['HTTP_HOST'])) { |
| 141 |
|
$withport = explode(':', $_SERVER['HTTP_HOST']); |
| 142 |
|
$servername = $withport[0]; |
| 143 |
|
if (isset($withport[1])) $port = ':'.$withport[1]; |
| 144 |
|
} |
| 145 |
|
elseif (isset($_SERVER['SERVER_NAME'])) $servername = $_SERVER['SERVER_NAME']; |
| 146 |
|
else trigger_error(T_('Impossible to determine the name of this server'), E_USER_ERROR); |
| 147 |
|
if (!isset($port) AND !empty($_SERVER['SERVER_PORT'])) $port = ':'.$_SERVER['SERVER_PORT']; |
| 148 |
|
if (isset($port)) { |
| 149 |
|
if (($scheme == 'http' AND $port == ':80') OR ($scheme == 'https' AND $port == ':443')) $port = ''; |
| 150 |
|
} |
| 151 |
|
else $port = ''; |
| 152 |
|
$afterscheme = '://'.$servername.$port.$this->subdirectory; |
| 153 |
|
$this->mosConfig_live_site = $this->mosConfig_secure_site = $scheme.$afterscheme; |
| 154 |
|
$this->mosConfig_unsecure_site = 'http'.$afterscheme; |
| 155 |
|
// $this->mosConfig_live_site = 'http://'.$_SERVER['SERVER_NAME'].$this->subdirectory; |
| 156 |
|
$this->mosConfig_absolute_path = $this->rootPath; |
| 157 |
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); |
| 158 |
foreach ($matches[1] as $match) $GLOBALS[$match] = $this->$match; |
foreach ($matches[1] as $match) $GLOBALS[$match] = $this->$match; |
| 159 |
if (!isset($this->mosConfig_register_globals)) { |
if (!isset($this->mosConfig_register_globals)) { |
| 181 |
} |
} |
| 182 |
|
|
| 183 |
function fixLanguage () { |
function fixLanguage () { |
|
|
|
|
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
|
| 184 |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
| 185 |
|
|
| 186 |
DEFINE('_ISO','charset=utf-8'); |
########## DEPRECATED ############ |
| 187 |
DEFINE('_DATE_FORMAT_LC',"%A, %d %B %Y"); //Uses PHP's strftime Command Format |
if (isset($this->mosConfig_lang) AND $this->mosConfig_lang); |
| 188 |
DEFINE('_DATE_FORMAT_LC2',"%A, %d %B %Y %H:%M"); |
else $this->set('mosConfig_lang', 'english'); |
| 189 |
|
$language_file = "$this->mosConfig_absolute_path/language/$this->mosConfig_lang.php"; |
|
|
|
|
/*/ the current character set |
|
|
if (!isset($this->mosConfig_charset)) { |
|
|
$this->set('mosConfig_charset', 'iso-8859-1');/*'utf-8'* / |
|
|
} |
|
|
|
|
|
|
|
|
/*$language_file = "$this->mosConfig_absolute_path/language/$this->mosConfig_lang.php"; |
|
| 190 |
if (file_exists($language_file)) require_once ($language_file); |
if (file_exists($language_file)) require_once ($language_file); |
| 191 |
error_reporting(0); |
################################### |
|
set_error_handler('error_handler');*/ |
|
|
$domain = $this->mosConfig_lang; |
|
|
$textdomain = $this->mosConfig_absolute_path.'/language'; |
|
|
$gettext =& phpgettext(); |
|
|
$gettext->debug = 0; |
|
|
$gettext->has_gettext = 0; |
|
|
$gettext->setlocale($this->mosConfig_lang);; |
|
|
$gettext->bindtextdomain($domain, $textdomain); |
|
|
$gettext->bind_textdomain_codeset($domain, 'utf-8'); |
|
|
$gettext->textdomain($domain); |
|
|
/**/ |
|
| 192 |
|
|
| 193 |
|
$lang = $this->mosConfig_lang; |
| 194 |
|
$langfile = $this->rootPath.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR.$lang.'.xml'; |
| 195 |
|
$p = xml_parser_create(); |
| 196 |
|
xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0); |
| 197 |
|
xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1); |
| 198 |
|
xml_parse_into_struct($p, implode("", file($langfile)), $values); |
| 199 |
|
xml_parser_free($p); |
| 200 |
|
foreach($values as $key => $value) |
| 201 |
|
{ |
| 202 |
|
if ($value['tag'] == 'param') { |
| 203 |
|
$name = $value['attributes']['name']; |
| 204 |
|
$this->language[$name] = $value['attributes']['default']; |
| 205 |
} |
} |
|
|
|
|
function secure () { |
|
|
$this->mosConfig_unsecure_site = $this->mosConfig_live_site; |
|
|
if ($_SERVER['SERVER_PORT'] == 443) { |
|
|
if (!isset($this->mosConfig_secure_site)) $this->mosConfig_secure_site = str_replace('http://', 'https://', $this->mosConfig_live_site); |
|
|
$this->mosConfig_live_site = $this->mosConfig_secure_site; |
|
| 206 |
} |
} |
| 207 |
|
if (!defined('_ISO')) DEFINE('_ISO','charset='.$this->language['encoding']); |
| 208 |
|
if (!defined('_DATE_FORMAT_LC')) DEFINE('_DATE_FORMAT_LC', $this->language['dateformat']); //Uses PHP's strftime Command Format |
| 209 |
|
if (!defined('_DATE_FORMAT_LC2')) DEFINE('_DATE_FORMAT_LC2', $this->language['dateformat']." %H:%M"); |
| 210 |
|
|
| 211 |
|
$gettext =& phpgettext(); |
| 212 |
|
$gettext->debug = $this->mosConfig_locale_debug; |
| 213 |
|
$gettext->has_gettext = $this->mosConfig_locale_use_gettext; |
| 214 |
|
$gettext->setlocale($this->mosConfig_lang, $this->mosConfig_locale); |
| 215 |
} |
} |
| 216 |
|
|
| 217 |
function handleGlobals () { |
function handleGlobals () { |
| 238 |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 239 |
if ($option = strtolower(mosGetParam($_REQUEST, 'option'))); |
if ($option = strtolower(mosGetParam($_REQUEST, 'option'))); |
| 240 |
else { |
else { |
| 241 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 242 |
$menus =& $menuhandler->getByParentOrder($this->Itemid, 'mainmenu'); |
$menus =& $menuhandler->getByParentOrder($this->Itemid, 'mainmenu'); |
| 243 |
$this->Itemid = $menus[0]->id; |
$this->Itemid = $menus[0]->id; |
| 244 |
$_REQUEST['Itemid'] = $this->Itemid; |
$_REQUEST['Itemid'] = $this->Itemid; |
| 257 |
if ($this->Itemid === 0) { |
if ($this->Itemid === 0) { |
| 258 |
if ( $option == 'com_content') { |
if ( $option == 'com_content') { |
| 259 |
require_once($this->rootPath().'/components/com_content/content.class.php'); |
require_once($this->rootPath().'/components/com_content/content.class.php'); |
| 260 |
$handler = contentHandler::getInstance(); |
$handler =& contentHandler::getInstance(); |
| 261 |
$this->Itemid = $handler->getItemid(mosGetParam($_REQUEST, 'id', 0 )); |
$this->Itemid = $handler->getItemid(mosGetParam($_REQUEST, 'id', 0 )); |
| 262 |
$_REQUEST['Itemid'] = $this->Itemid; |
$_REQUEST['Itemid'] = $this->Itemid; |
| 263 |
} |
} |
| 264 |
else { |
else { |
| 265 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 266 |
$this->Itemid = $menuhandler->getIdLikeLink("index.php?option=$option"); |
$this->Itemid = $menuhandler->getIdLikeLink("index.php?option=$option"); |
| 267 |
if ($this->Itemid === 0) { |
if ($this->Itemid === 0) { |
| 268 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 269 |
$menus =& $menuhandler->getByParentOrder($this->Itemid, 'mainmenu'); |
$menus =& $menuhandler->getByParentOrder($this->Itemid, 'mainmenu'); |
| 270 |
} |
} |
| 271 |
} |
} |
| 275 |
|
|
| 276 |
function redirect ($url, $msg='') { |
function redirect ($url, $msg='') { |
| 277 |
$callcheck = array('InputFilter', 'process'); |
$callcheck = array('InputFilter', 'process'); |
| 278 |
if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpinputfilter/class.inputfilter.php'); |
if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpInputFilter/class.inputfilter.php'); |
| 279 |
// specific filters |
// specific filters |
| 280 |
$iFilter =& new InputFilter(); |
$iFilter =& new InputFilter(); |
| 281 |
$url = $iFilter->process( $url ); |
$url = $iFilter->process( $url ); |
| 282 |
$message = trim($iFilter->process($msg)); |
$message = trim($iFilter->process($msg)); |
| 283 |
if ($iFilter->badAttributeValue(array('href', $url))) $url = $GLOBALS['mosConfig_live_site']; |
if ($iFilter->badAttributeValue(array('href', $url))) $url = mamboCore::get('mosConfig_live_site'); |
| 284 |
if ($message) { |
if ($message) { |
| 285 |
if (strpos($url, '?')) $url .= '&mosmsg='.urlencode($message); |
if (strpos($url, '?')) $url .= '&mosmsg='.urlencode($message); |
| 286 |
else $url .= '?mosmsg='.urlencode($message); |
else $url .= '?mosmsg='.urlencode($message); |
| 312 |
} |
} |
| 313 |
} |
} |
| 314 |
|
|
| 315 |
function handleLogin ($session) { |
function handleLogin () { |
| 316 |
require_once($this->rootPath().'/includes/authenticator.php'); |
require_once($this->rootPath().'/includes/authenticator.php'); |
| 317 |
$authenticator = mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 318 |
$authenticator->loginUser(); |
$loggedin = $authenticator->loginUser(); |
| 319 |
$this->logMessage(_LOGIN_SUCCESS); |
if ($loggedin) $this->logMessage(_LOGIN_SUCCESS); |
| 320 |
|
else mamboCore::redirect('index.php'); |
| 321 |
} |
} |
| 322 |
|
|
| 323 |
function handleLogout ($session) { |
function handleLogout () { |
| 324 |
require_once($this->rootPath().'/includes/authenticator.php'); |
require_once($this->rootPath().'/includes/authenticator.php'); |
| 325 |
$authenticator = mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 326 |
$authenticator->logoutUser(); |
$authenticator->logoutUser(); |
|
@session_destroy(); |
|
| 327 |
$this->logMessage(_LOGOUT_SUCCESS); |
$this->logMessage(_LOGOUT_SUCCESS); |
| 328 |
} |
} |
| 329 |
|
|
| 333 |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); |
| 334 |
header( 'Cache-Control: post-check=0, pre-check=0', false ); |
header( 'Cache-Control: post-check=0, pre-check=0', false ); |
| 335 |
header( 'Pragma: no-cache' ); |
header( 'Pragma: no-cache' ); |
| 336 |
$mambothandler = mosMambotHandler::getInstance(); |
$mambothandler =& mosMambotHandler::getInstance(); |
| 337 |
$mambothandler->loadBotGroup('system'); |
$mambothandler->loadBotGroup('system'); |
| 338 |
$mambothandler->trigger('onHeaders', array($this)); |
$mambothandler->trigger('onHeaders', array($this)); |
| 339 |
} |
} |
| 342 |
$this->do_gzip_compress = FALSE; |
$this->do_gzip_compress = FALSE; |
| 343 |
//zlib.output_compression and ob_gzhandler don't get along well so we'll check to make |
//zlib.output_compression and ob_gzhandler don't get along well so we'll check to make |
| 344 |
//that zlib.output_compression is not enable in the php.ini before turning on ob_gzhandler |
//that zlib.output_compression is not enable in the php.ini before turning on ob_gzhandler |
| 345 |
if ( $this->mosConfig_gzip == 1 && (int)ini_get('zlib.output_compression') != 1 ) { |
if ( $this->mosConfig_gzip == 1 AND (int)ini_get('zlib.output_compression') != 1 ) { |
| 346 |
$phpver = phpversion(); |
$phpver = phpversion(); |
| 347 |
$useragent = mosGetParam( $_SERVER, 'HTTP_USER_AGENT', '' ); |
$useragent = mosGetParam( $_SERVER, 'HTTP_USER_AGENT', '' ); |
| 348 |
$canZip = mosGetParam( $_SERVER, 'HTTP_ACCEPT_ENCODING', '' ); |
$canZip = mosGetParam( $_SERVER, 'HTTP_ACCEPT_ENCODING', '' ); |
| 349 |
|
|
| 350 |
if ( $phpver >= '4.0.4pl1' && |
if ( $phpver >= '4.0.4pl1' AND |
| 351 |
( strpos($useragent,'compatible') !== false || |
( strpos($useragent,'compatible') !== false || |
| 352 |
strpos($useragent,'Gecko') !== false |
strpos($useragent,'Gecko') !== false |
| 353 |
) |
) |
| 419 |
require_once ($configuration->rootPath().'/includes/database.php'); |
require_once ($configuration->rootPath().'/includes/database.php'); |
| 420 |
|
|
| 421 |
/** |
/** |
| 422 |
|
* Mambo basic error object |
| 423 |
|
*/ |
| 424 |
|
define ('_MOS_ERROR_INFORM', 0); |
| 425 |
|
define ('_MOS_ERROR_WARN', 1); |
| 426 |
|
define ('_MOS_ERROR_SEVERE', 2); |
| 427 |
|
define ('_MOS_ERROR_FATAL', 3); |
| 428 |
|
|
| 429 |
|
class mosError { |
| 430 |
|
var $text = ''; |
| 431 |
|
var $level = 0; |
| 432 |
|
|
| 433 |
|
function mosError ($text='', $level=_MOS_ERROR_INFORM) { |
| 434 |
|
$this->text = $text; |
| 435 |
|
$this->level = $level; |
| 436 |
|
} |
| 437 |
|
} |
| 438 |
|
|
| 439 |
|
/** |
| 440 |
|
* Mambo group of errors for some particular operation |
| 441 |
|
*/ |
| 442 |
|
class mosErrorSet { |
| 443 |
|
var $errors = array(); |
| 444 |
|
var $maxlevel = 0; |
| 445 |
|
|
| 446 |
|
// Parameter is an error object |
| 447 |
|
function addError ($error) { |
| 448 |
|
$this->errors[] = $error; |
| 449 |
|
if ($error->level > $this->maxlevel) $this->maxlevel = $error->level; |
| 450 |
|
} |
| 451 |
|
|
| 452 |
|
function addErrorDetails ($text='', $level=_MOS_ERROR_INFORM) { |
| 453 |
|
$error = new mosError($text, $level); |
| 454 |
|
$this->addError($error); |
| 455 |
|
} |
| 456 |
|
|
| 457 |
|
function &getErrors () { |
| 458 |
|
return $this->errors; |
| 459 |
|
} |
| 460 |
|
|
| 461 |
|
function getMaxLevel () { |
| 462 |
|
return $this->maxlevel; |
| 463 |
|
} |
| 464 |
|
|
| 465 |
|
function getCount () { |
| 466 |
|
return count($this->errors); |
| 467 |
|
} |
| 468 |
|
|
| 469 |
|
function mergeAnother ($errorset) { |
| 470 |
|
$this->errors = array_merge($this->errors, $errorset->errors); |
| 471 |
|
} |
| 472 |
|
|
| 473 |
|
} |
| 474 |
|
|
| 475 |
|
/** |
| 476 |
* Sorts an Array of objects |
* Sorts an Array of objects |
| 477 |
*/ |
*/ |
| 478 |
class mosObjectSorter { |
class mosObjectSorter { |
| 514 |
* Constructor |
* Constructor |
| 515 |
*/ |
*/ |
| 516 |
function mosPathway () { |
function mosPathway () { |
| 517 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 518 |
$menus =& $menuhandler->getByParentOrder(0,'mainmenu'); |
$menus =& $menuhandler->getByParentOrder(0,'mainmenu'); |
| 519 |
$home = $menus[0]; |
$home = $menus[0]; |
| 520 |
$this->_names[] = $home->name; |
$this->_names[] = $home->name; |
| 553 |
* Make a pathway string for display |
* Make a pathway string for display |
| 554 |
*/ |
*/ |
| 555 |
function makePathway () { |
function makePathway () { |
| 556 |
$mainframe = mosMainFrame::getInstance(); |
$last = count($this->_names) - 1; |
| 557 |
|
if ($last == 0) return ''; |
| 558 |
|
$mainframe =& mosMainFrame::getInstance(); |
| 559 |
$result = "<span class='pathway'>"; |
$result = "<span class='pathway'>"; |
| 560 |
$config = mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 561 |
$rootpath = $config->rootPath(); |
$rootpath = $config->rootPath(); |
| 562 |
$imgPath = 'templates/'.$mainframe->getTemplate().'/images/arrow.png'; |
$imgPath = 'templates/'.$mainframe->getTemplate().'/images/arrow.png'; |
| 563 |
if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='$config->mosConfig_live_site/$imgPath' border='0' alt='arrow' />"; |
if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='$config->mosConfig_live_site/$imgPath' border='0' alt='arrow' />"; |
| 566 |
if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='$config->mosConfig_live_site/images/M_images/arrow.png' alt='arrow' />"; |
if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='$config->mosConfig_live_site/images/M_images/arrow.png' alt='arrow' />"; |
| 567 |
else $img = '>'; |
else $img = '>'; |
| 568 |
} |
} |
|
$last = count($this->_names) - 1; |
|
| 569 |
foreach ($this->_names as $i=>$name) { |
foreach ($this->_names as $i=>$name) { |
| 570 |
if ($i === $last) $result .= "$name</span>"; |
if ($i === $last) $result .= "$name</span>"; |
| 571 |
else { |
else { |
| 576 |
} |
} |
| 577 |
$customs = $mainframe->getCustomPathWay(); |
$customs = $mainframe->getCustomPathWay(); |
| 578 |
foreach ($customs as $custom) $result .= $custom; |
foreach ($customs as $custom) $result .= $custom; |
| 579 |
|
$result .= '</span>'; |
| 580 |
return $result; |
return $result; |
| 581 |
} |
} |
| 582 |
|
|
| 627 |
* @param database A database connector object |
* @param database A database connector object |
| 628 |
*/ |
*/ |
| 629 |
function mosMenu( $dummy ) { |
function mosMenu( $dummy ) { |
| 630 |
$db = mamboDatabase::getInstance(); |
$db =& mamboDatabase::getInstance(); |
| 631 |
$this->mosDBTable( '#__menu', 'id', $db ); |
$this->mosDBTable( '#__menu', 'id', $db ); |
| 632 |
} |
} |
| 633 |
/** |
/** |
| 639 |
$k = $this->_tbl_key; |
$k = $this->_tbl_key; |
| 640 |
if ($oid !== null) $this->$k = $oid; |
if ($oid !== null) $this->$k = $oid; |
| 641 |
if ($this->$k === null) return false; |
if ($this->$k === null) return false; |
| 642 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 643 |
$menu = $menuhandler->getMenuById($this->$k); |
$menu =& $menuhandler->getMenuById($this->$k); |
| 644 |
if ($menu) { |
if ($menu) { |
| 645 |
foreach (get_object_vars($menu) as $key=>$data) $this->$key = $data; |
foreach (get_object_vars($menu) as $key=>$data) $this->$key = $data; |
| 646 |
return true; |
return true; |
| 666 |
} |
} |
| 667 |
|
|
| 668 |
function deleteFile ($file) { |
function deleteFile ($file) { |
| 669 |
if (file_exists($file)) unlink($file); |
if (file_exists($file)) { |
| 670 |
|
@chmod($file, 0644); |
| 671 |
|
return unlink($file); |
| 672 |
|
} |
| 673 |
|
return true; |
| 674 |
} |
} |
| 675 |
|
|
| 676 |
function deleteDirectory ($dir) { |
function deleteDirectory ($dir) { |
| 677 |
rmdir($dir); |
if (file_exists($dir)) { |
| 678 |
|
if (is_dir($dir)) { |
| 679 |
|
@chmod($dir, 0755); |
| 680 |
|
return rmdir($dir); |
| 681 |
|
} |
| 682 |
|
return false; |
| 683 |
|
} |
| 684 |
|
return true; |
| 685 |
} |
} |
| 686 |
|
|
| 687 |
function createDirectory ($dir) { |
function createDirectory ($dir) { |
| 688 |
mkdir($dir); |
if (file_exists($dir)) { |
| 689 |
|
if (is_dir($dir)) return true; |
| 690 |
|
else return false; |
| 691 |
|
} |
| 692 |
|
list($upDirectory, $count) = $this->containingDirectory($dir); |
| 693 |
|
if ($count > 1 AND !file_exists($upDirectory)) if (!$this->createDirectory($upDirectory)) return false; |
| 694 |
|
if (!is_dir($upDirectory)) return false; |
| 695 |
|
$dirperms = mamboCore::get('mosConfig_dirperms'); |
| 696 |
|
if ($dirperms) { |
| 697 |
|
$origmask = @umask(0); |
| 698 |
|
$mode = octdec($dirperms); |
| 699 |
|
} |
| 700 |
|
else $mode = 0755; |
| 701 |
|
if (!@mkdir($dir, $mode )) $result = false; |
| 702 |
|
else { |
| 703 |
|
$result = true; |
| 704 |
|
@chmod ($dir, $mode); |
| 705 |
|
} |
| 706 |
|
if (isset($origmask)) @umask($origmask); |
| 707 |
|
return $result; |
| 708 |
|
} |
| 709 |
|
|
| 710 |
|
function containingDirectory ($dir) { |
| 711 |
|
$dirs = preg_split('*[/|\\\]*', $dir); |
| 712 |
|
for ($i = count($dirs)-1; $i >= 0; $i--) { |
| 713 |
|
$text = trim($dirs[$i]); |
| 714 |
|
unset($dirs[$i]); |
| 715 |
|
if ($text) break; |
| 716 |
|
} |
| 717 |
|
return array(implode('/',$dirs), count($dirs)); |
| 718 |
} |
} |
| 719 |
|
|
| 720 |
|
|
| 721 |
function forceCopy ($from, $to) { |
function forceCopy ($from, $to) { |
| 722 |
$todir = dirname($to); |
$todir = dirname($to); |
| 723 |
if (!file_exists($todir)) $this->createDirectory($todir); |
if (!file_exists($todir)) $this->createDirectory($todir); |
| 724 |
$name = mamboCore::getLastPart('/', $from); |
if (!file_exists($todir)) return false; |
| 725 |
|
$name = basename($from); |
| 726 |
$this->deleteFile($to.$name); |
$this->deleteFile($to.$name); |
| 727 |
copy($from, $to); |
return @copy($from, $to); |
| 728 |
|
} |
| 729 |
|
|
| 730 |
|
function lightCopy ($from, $to) { |
| 731 |
|
$name = basename($from); |
| 732 |
|
if (file_exists($to.$name)) return false; |
| 733 |
|
$todir = dirname($to); |
| 734 |
|
if (!file_exists($todir)) $this->createDirectory($todir); |
| 735 |
|
if (!file_exists($todir)) return false; |
| 736 |
|
return @copy($from, $to); |
| 737 |
} |
} |
| 738 |
|
|
| 739 |
|
|
| 768 |
function mosChmod($path) |
function mosChmod($path) |
| 769 |
{ |
{ |
| 770 |
$fileperms = mamboCore::get('mosConfig_fileperms'); |
$fileperms = mamboCore::get('mosConfig_fileperms'); |
|
$dirperms = mamboCore::get('mosConfig_dirperms'); |
|
| 771 |
if ($fileperms != '') $filemode = octdec($fileperms); |
if ($fileperms != '') $filemode = octdec($fileperms); |
| 772 |
else $filemode = null; |
else $filemode = null; |
| 773 |
|
$dirperms = mamboCore::get('mosConfig_dirperms'); |
| 774 |
if ($dirperms != '') $dirmode = octdec($dirperms); |
if ($dirperms != '') $dirmode = octdec($dirperms); |
| 775 |
else $dirmode = null; |
else $dirmode = null; |
| 776 |
if (isset($filemode) OR isset($dirmode)) |
if (isset($filemode) OR isset($dirmode)) |
| 789 |
$ret = true; |
$ret = true; |
| 790 |
if (is_dir($path)) { |
if (is_dir($path)) { |
| 791 |
$topdir =& new mosDirectory($path); |
$topdir =& new mosDirectory($path); |
| 792 |
$files = $topdir->listFiles ('', 'file', true); |
$files =& $topdir->listFiles ('', 'file', true); |
| 793 |
$dirs = $topdir->listFiles ('', 'dir', true); |
$dirs =& $topdir->listFiles ('', 'dir', true); |
| 794 |
} |
} |
| 795 |
else { |
else { |
| 796 |
$files = array($path); |
$files = array($path); |
| 858 |
$subdirectory->deleteAll(); |
$subdirectory->deleteAll(); |
| 859 |
unset($subdirectory); |
unset($subdirectory); |
| 860 |
} |
} |
| 861 |
$filemanager = mosFileManager::getInstance(); |
$filemanager =& mosFileManager::getInstance(); |
| 862 |
$files =& $this->listAll ('file', false, true); |
$files =& $this->listAll ('file', false, true); |
| 863 |
foreach ($files as $file) $filemanager->deleteFile($file); |
foreach ($files as $file) $filemanager->deleteFile($file); |
| 864 |
$filemanager->deleteDirectory($this->path); |
$filemanager->deleteDirectory($this->path); |
| 866 |
|
|
| 867 |
function createFresh () { |
function createFresh () { |
| 868 |
$this->deleteAll(); |
$this->deleteAll(); |
| 869 |
$filemanager = mosFileManager::getInstance(); |
$filemanager =& mosFileManager::getInstance(); |
| 870 |
$filemanager->createDirectory($this->path); |
$filemanager->createDirectory($this->path); |
| 871 |
return true; |
return true; |
| 872 |
} |
} |
| 873 |
|
|
| 874 |
function createIfNeeded () { |
function createIfNeeded () { |
| 875 |
if (!file_exists($this->path)) { |
if (!file_exists($this->path)) { |
| 876 |
$filemanager = mosFileManager::getInstance(); |
$filemanager =& mosFileManager::getInstance(); |
| 877 |
$filemanager->createDirectory($this->path); |
$filemanager->createDirectory($this->path); |
| 878 |
} |
} |
| 879 |
} |
} |
| 891 |
|
|
| 892 |
function getSize () { |
function getSize () { |
| 893 |
$totalsize = 0; |
$totalsize = 0; |
| 894 |
$files = $this->listFiles(); |
$files =& $this->listFiles(); |
| 895 |
foreach ($files as $file) $totalsize += filesize($this->path.$file); |
foreach ($files as $file) $totalsize += filesize($this->path.$file); |
| 896 |
return $totalsize; |
return $totalsize; |
| 897 |
} |
} |
| 917 |
*/ |
*/ |
| 918 |
function mosMenuHandler() { |
function mosMenuHandler() { |
| 919 |
global $my; |
global $my; |
| 920 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 921 |
$sql = "SELECT * FROM #__menu ORDER BY name"; |
$sql = "SELECT * FROM #__menu ORDER BY name"; |
| 922 |
$this->_menus =& $database->doSQLget($sql, 'mosMenu'); |
$this->_menus =& $database->doSQLget($sql, 'mosMenu'); |
| 923 |
if (!$this->_menus) $this->_menus = array(); |
if (!$this->_menus) $this->_menus = array(); |
| 944 |
function &getMenuByID ($id) { |
function &getMenuByID ($id) { |
| 945 |
if (isset($this->_idlinks[$id])) { |
if (isset($this->_idlinks[$id])) { |
| 946 |
$key = $this->_idlinks[$id]; |
$key = $this->_idlinks[$id]; |
| 947 |
return $this->_menus[$key]; |
$result = $this->_menus[$key]; |
| 948 |
} |
} |
| 949 |
$result = null; |
else $result = null; |
| 950 |
return $result; |
return $result; |
| 951 |
} |
} |
| 952 |
|
|
| 1053 |
$menu = $this->_menus[$key]; |
$menu = $this->_menus[$key]; |
| 1054 |
if ($menutype AND $mtype != $menutype) continue; |
if ($menutype AND $mtype != $menutype) continue; |
| 1055 |
if ($Itemid AND $Itemid != $menu->id) continue; |
if ($Itemid AND $Itemid != $menu->id) continue; |
| 1056 |
if ($maxaccess AND $menu->access > $maxaccess) continue; |
if ($menu->access > $maxaccess) continue; |
| 1057 |
if ($noparent AND $parent != 0) continue; |
if ($noparent AND $parent != 0) continue; |
| 1058 |
$result[] = $this->_menus[$key]; |
$result[] = $this->_menus[$key]; |
| 1059 |
} |
} |
| 1065 |
|
|
| 1066 |
function setPathway ($Itemid) { |
function setPathway ($Itemid) { |
| 1067 |
if ($Itemid) { |
if ($Itemid) { |
| 1068 |
$menu = $this->getMenuByID($Itemid); |
$menu =& $this->getMenuByID($Itemid); |
| 1069 |
if ($menu->parent) $this->setPathway($menu->parent); |
if ($menu->parent) $this->setPathway($menu->parent); |
| 1070 |
$pathway = mosPathway::getInstance(); |
$pathway =& mosPathway::getInstance(); |
| 1071 |
$pathway->addItem($menu->name, $menu->link."&Itemid=$Itemid"); |
$pathway->addItem($menu->name, $menu->link."&Itemid=$Itemid"); |
| 1072 |
} |
} |
| 1073 |
} |
} |
| 1085 |
if (in_array($menu_option, $exceptions)) return true; |
if (in_array($menu_option, $exceptions)) return true; |
| 1086 |
$dblink="index.php?option=$menu_option"; |
$dblink="index.php?option=$menu_option"; |
| 1087 |
if ($Itemid) { |
if ($Itemid) { |
| 1088 |
$menu = $this->getMenuByID($Itemid); |
$menu =& $this->getMenuByID($Itemid); |
| 1089 |
if (strpos($menu->link,$dblink) ===0) $access = $menu->access; |
if (strpos($menu->link,$dblink) ===0) $access = $menu->access; |
| 1090 |
} |
} |
| 1091 |
if (!isset($access)) { |
if (!isset($access)) { |
| 1092 |
if ($task!='') $dblink .= "&task=$task"; |
if ($task!='') $dblink .= "&task=$task"; |
| 1093 |
$menu = $this->maxAccessLink($dblink); |
$menu =& $this->maxAccessLink($dblink); |
| 1094 |
if (isset($menu)) { |
if (isset($menu)) { |
| 1095 |
$access = $menu->access; |
$access = $menu->access; |
| 1096 |
mamboCore::set('Itemid', $menu->id); |
mamboCore::set('Itemid', $menu->id); |
| 1110 |
$temp = split("&task=view&id=", $mitem->link); |
$temp = split("&task=view&id=", $mitem->link); |
| 1111 |
if (isset($temp[1])) { |
if (isset($temp[1])) { |
| 1112 |
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 1113 |
$handler = contentHandler::getInstance(); |
$handler =& contentHandler::getInstance(); |
| 1114 |
$mitem->link .= '&Itemid='.$handler->getItemid($temp[1]); |
$mitem->link .= '&Itemid='.$handler->getItemid($temp[1]); |
| 1115 |
} |
} |
| 1116 |
break; |
break; |
| 1310 |
$my = mamboCore::is_set('currentUser') ? mamboCore::get('currentUser') : null; |
$my = mamboCore::is_set('currentUser') ? mamboCore::get('currentUser') : null; |
| 1311 |
$gid = $my ? $my->gid : 0; |
$gid = $my ? $my->gid : 0; |
| 1312 |
$this->_events = array(); |
$this->_events = array(); |
| 1313 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 1314 |
$database->setQuery( "SELECT folder, element, published, params, CONCAT_WS('/',folder,element) AS lookup" |
$database->setQuery( "SELECT folder, element, published, params, CONCAT_WS('/',folder,element) AS lookup" |
| 1315 |
. "\nFROM #__mambots" |
. "\nFROM #__mambots" |
| 1316 |
. "\nWHERE published >= 1 AND access <= $gid" |
. "\nWHERE published >= 1 AND access <= $gid" |
| 1328 |
return $instance; |
return $instance; |
| 1329 |
} |
} |
| 1330 |
/** |
/** |
| 1331 |
|
* Register a class-type mambot, provided it has a perform method |
| 1332 |
|
* - can register for multiple events if desired |
| 1333 |
|
* @param object The mambot object |
| 1334 |
|
* @param mixed string or array of strings - the mambot events to be registered |
| 1335 |
|
* @param int the subscript for use in the main array of mambots |
| 1336 |
|
*/ |
| 1337 |
|
function _botRegister (&$botObject, &$selected, $i) { |
| 1338 |
|
$function = array(&$botObject, 'perform'); |
| 1339 |
|
if (!is_callable($function)) return; |
| 1340 |
|
if (is_array($selected)) foreach ($selected as $select) $this->_botRegister($botObject, $select); |
| 1341 |
|
$this->_events[$selected][] = array ($function, $i); |
| 1342 |
|
$this->_registered[$i] = true; |
| 1343 |
|
} |
| 1344 |
|
|
| 1345 |
|
/** |
| 1346 |
* Loads all the bot files for a particular group |
* Loads all the bot files for a particular group |
| 1347 |
* @param string The group name, relates to the sub-directory in the mambots directory |
* @param string The group name, relates to the sub-directory in the mambots directory |
| 1348 |
*/ |
*/ |
| 1359 |
require_once( $path ); |
require_once( $path ); |
| 1360 |
if (!isset($this->_registered[$i])) { |
if (!isset($this->_registered[$i])) { |
| 1361 |
$botclass = str_replace('.','_',$bot->element); |
$botclass = str_replace('.','_',$bot->element); |
| 1362 |
|
if (class_exists($botclass)) { |
| 1363 |
$newbot = new $botclass(); |
$newbot = new $botclass(); |
| 1364 |
$function = array ($newbot, 'perform'); |
if (is_callable(array(&$newbot, 'register'))) { |
| 1365 |
$this->_events[$newbot->register()][] = array ($function, $i); |
$selected = $newbot->register(); |
| 1366 |
$this->_registered[$i] = true; |
$this->_botRegister($newbot, $selected, $i); |
| 1367 |
|
} |
| 1368 |
|
} |
| 1369 |
} |
} |
| 1370 |
$total++; |
$total++; |
| 1371 |
} |
} |
| 1414 |
foreach ($this->_events[$event] as $func) { |
foreach ($this->_events[$event] as $func) { |
| 1415 |
if (is_callable( $func[0] )) { |
if (is_callable( $func[0] )) { |
| 1416 |
$botparams = $this->_bots[$func[1]]->params; |
$botparams = $this->_bots[$func[1]]->params; |
| 1417 |
$args[] =& new mosParameters($botparams); |
$args[] = new mosParameters($botparams); |
| 1418 |
|
$args[] = $event; |
| 1419 |
if ($doUnpublished) { |
if ($doUnpublished) { |
| 1420 |
$args[0] = $this->_bots[$func[1]]->published; |
$args[0] = $this->_bots[$func[1]]->published; |
| 1421 |
$result[] = call_user_func_array( $func[0], $args ); |
$result[] = call_user_func_array( $func[0], $args ); |
| 1494 |
* @param database A database connector object |
* @param database A database connector object |
| 1495 |
*/ |
*/ |
| 1496 |
function mosUser( $dummy ) { |
function mosUser( $dummy ) { |
| 1497 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 1498 |
$this->mosDBTable( '#__users', 'id', $database ); |
$this->mosDBTable( '#__users', 'id', $database ); |
| 1499 |
} |
} |
| 1500 |
|
|
| 1502 |
* Fill a user object with information from the current session |
* Fill a user object with information from the current session |
| 1503 |
*/ |
*/ |
| 1504 |
function getSessionData() { |
function getSessionData() { |
| 1505 |
$session = mosSession::getCurrent(); |
$session =& mosSession::getCurrent(); |
| 1506 |
$this->id = intval( $session->userid ); |
$this->id = intval( $session->userid ); |
| 1507 |
$this->username = $session->username; |
$this->username = $session->username; |
| 1508 |
$this->usertype = $session->usertype; |
$this->usertype = $session->usertype; |
| 1520 |
elseif (($this->email == '') OR preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email ) == 0) $this->_error = _REGWARN_MAIL; |
elseif (($this->email == '') OR preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email ) == 0) $this->_error = _REGWARN_MAIL; |
| 1521 |
else { |
else { |
| 1522 |
// check for existing username |
// check for existing username |
| 1523 |
|
$username = strtolower($this->username); |
| 1524 |
$this->_db->setQuery( "SELECT COUNT(id) FROM #__users " |
$this->_db->setQuery( "SELECT COUNT(id) FROM #__users " |
| 1525 |
. "\nWHERE LOWER(username)=LOWER('$this->username') AND id!='$this->id'" |
. "\nWHERE LOWER(username)='$username' AND id!='$this->id'" |
| 1526 |
); |
); |
| 1527 |
if ($this->_db->loadResult()) $this->_error = _REGWARN_INUSE; |
if ($this->_db->loadResult()) $this->_error = _REGWARN_INUSE; |
| 1528 |
elseif (mamboCore::get('mosConfig_uniquemail')) { |
elseif (mamboCore::get('mosConfig_uniquemail')) { |
| 1538 |
} |
} |
| 1539 |
|
|
| 1540 |
function store( $updateNulls=false ) { |
function store( $updateNulls=false ) { |
| 1541 |
global $migrate; |
global $acl, $migrate; |
| 1542 |
if( $this->id AND !$migrate) $ret = $this->_db->updateObject( $this->_tbl, $this, $this->id, $updateNulls ); |
$section_value = 'users'; |
| 1543 |
else $ret = $this->_db->insertObject( $this->_tbl, $this, $this->id ); |
if( $this->id AND !$migrate) { |
| 1544 |
|
// update existing record |
| 1545 |
|
$ret = $this->_db->updateObject( $this->_tbl, $this, 'id', $updateNulls ); |
| 1546 |
|
// syncronise ACL |
| 1547 |
|
// single group handled at the moment |
| 1548 |
|
// trivial to expand to multiple groups |
| 1549 |
|
$groups = $acl->get_object_groups( $section_value, $this->id, 'ARO' ); |
| 1550 |
|
$acl->del_group_object( $groups[0], $section_value, $this->id, 'ARO' ); |
| 1551 |
|
$acl->add_group_object( $this->gid, $section_value, $this->id, 'ARO' ); |
| 1552 |
|
$object_id = $acl->get_object_id( $section_value, $this->id, 'ARO' ); |
| 1553 |
|
$acl->edit_object( $object_id, $section_value, $this->_db->getEscaped( $this->name ), $this->id, 0, 0, 'ARO' ); |
| 1554 |
|
} |
| 1555 |
|
else { |
| 1556 |
|
// new record |
| 1557 |
|
$ret = $this->_db->insertObject( $this->_tbl, $this, 'id' ); |
| 1558 |
|
// syncronise ACL |
| 1559 |
|
$acl->add_object( $section_value, $this->_db->getEscaped( $this->name ), $this->id, null, null, 'ARO' ); |
| 1560 |
|
$acl->add_group_object( $this->gid, $section_value, $this->id, 'ARO' ); |
| 1561 |
|
} |
| 1562 |
if ($ret) return true; |
if ($ret) return true; |
| 1563 |
$this->_error = "mosUser::store failed <br />" . $this->_db->getErrorMsg(); |
$this->_error = "mosUser::store failed <br />" . $this->_db->getErrorMsg(); |
| 1564 |
return false; |
return false; |
| 1590 |
} |
} |
| 1591 |
|
|
| 1592 |
/** |
/** |
| 1593 |
|
* User login details class |
| 1594 |
|
* @package Mambo |
| 1595 |
|
*/ |
| 1596 |
|
class mosLoginDetails { |
| 1597 |
|
var $_user = ''; |
| 1598 |
|
var $_password = ''; |
| 1599 |
|
var $_remember = ''; |
| 1600 |
|
|
| 1601 |
|
function mosLoginDetails ($user, $password='', $remember='') { |
| 1602 |
|
$this->_user = $user; |
| 1603 |
|
$this->_password = $password; |
| 1604 |
|
$this->_remember = $remember; |
| 1605 |
|
} |
| 1606 |
|
|
| 1607 |
|
function getUser () { |
| 1608 |
|
return $this->_user; |
| 1609 |
|
} |
| 1610 |
|
|
| 1611 |
|
function getPassword () { |
| 1612 |
|
return $this->_password; |
| 1613 |
|
} |
| 1614 |
|
|
| 1615 |
|
function getRemember () { |
| 1616 |
|
return $this->_remember; |
| 1617 |
|
} |
| 1618 |
|
|
| 1619 |
|
} |
| 1620 |
|
/** |
| 1621 |
* Mambo Mainframe class |
* Mambo Mainframe class |
| 1622 |
* |
* |
| 1623 |
* Provide many supporting API functions |
* Provide many supporting API functions |
| 1659 |
} |
} |
| 1660 |
|
|
| 1661 |
/** |
/** |
| 1662 |
|
* Get the current user - deprecated - use mamboCore instead |
| 1663 |
|
*/ |
| 1664 |
|
function getUser() { |
| 1665 |
|
return mamboCore::get('currentUser'); |
| 1666 |
|
} |
| 1667 |
|
/** |
| 1668 |
|
* Logout the current user - deprecated - use the code here directly |
| 1669 |
|
*/ |
| 1670 |
|
function logout() { |
| 1671 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/includes/authenticator.php'); |
| 1672 |
|
$authenticator =& mamboAuthenticator::getInstance(); |
| 1673 |
|
$authenticator->logoutUser(); |
| 1674 |
|
} |
| 1675 |
|
/** |
| 1676 |
|
* Login a user given name and password - deprecated - use the code here directly |
| 1677 |
|
*/ |
| 1678 |
|
function login ($username=null,$passwd=null) { |
| 1679 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/includes/authenticator.php'); |
| 1680 |
|
$authenticator =& mamboAuthenticator::getInstance(); |
| 1681 |
|
return $authenticator->loginUser($username, $passwd); |
| 1682 |
|
} |
| 1683 |
|
|
| 1684 |
|
/** |
| 1685 |
* Singleton get instance |
* Singleton get instance |
| 1686 |
* @param object the mainframe instance (if called internally) |
* @param object the mainframe instance (if called internally) |
| 1687 |
* Note that because of the need for creation parameters, this cannot |
* Note that because of the need for creation parameters, this cannot |
| 1746 |
* @param string The value of the content attibute to append to the existing |
* @param string The value of the content attibute to append to the existing |
| 1747 |
* Tags ordered in with Site Keywords and Description first |
* Tags ordered in with Site Keywords and Description first |
| 1748 |
*/ |
*/ |
| 1749 |
function appendMetaTag( $name, $content ) { |
function appendMetaTag( $name, $content, $ifEmpty=false ) { |
| 1750 |
list($name, $content) = $this->_tidyMetaData($name, $content); |
list($name, $content) = $this->_tidyMetaData($name, $content); |
| 1751 |
$tag = $this->_getMetaTag($name); |
$tag = $this->_getMetaTag($name); |
| 1752 |
|
if ($tag[0] AND $ifEmpty) return; |
| 1753 |
if ($tag[0] AND $content) $content .= ', '; |
if ($tag[0] AND $content) $content .= ', '; |
| 1754 |
$tag[0] = $content.$tag[0]; |
$tag[0] = $content.$tag[0]; |
| 1755 |
$this->_head['meta'][$name] = $tag; |
$this->_head['meta'][$name] = $tag; |
| 1869 |
if ($mos_change_template) { |
if ($mos_change_template) { |
| 1870 |
// check that template exists in case it was deleted |
// check that template exists in case it was deleted |
| 1871 |
$path = mamboCore::get('mosConfig_absolute_path')."/templates/$mos_change_template/index.php"; |
$path = mamboCore::get('mosConfig_absolute_path')."/templates/$mos_change_template/index.php"; |
| 1872 |
if (file_exists( $path)) { |
if (strpos($mos_change_template,'..') == false AND strpos($mos_change_template,':') == false AND file_exists($path)) { |
| 1873 |
$lifetime = 60*10; |
$lifetime = 60*10; |
| 1874 |
$cur_template = $mos_change_template; |
$cur_template = $mos_change_template; |
| 1875 |
setcookie( "mos_user_template", "$mos_change_template", time()+$lifetime); |
setcookie( "mos_user_template", "$mos_change_template", time()+$lifetime); |
| 1998 |
*/ |
*/ |
| 1999 |
function getItemid ($id, $typed=1, $link=1, $bs=1, $bc=1, $gbs=1) { |
function getItemid ($id, $typed=1, $link=1, $bs=1, $bc=1, $gbs=1) { |
| 2000 |
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2001 |
$handler = contentHandler::getInstance(); |
$handler =& contentHandler::getInstance(); |
| 2002 |
return $handler->getItemid($id, $typed, $link, $bs, $bc, $gbs); |
return $handler->getItemid($id, $typed, $link, $bs, $bc, $gbs); |
| 2003 |
} |
} |
| 2004 |
|
|
| 2005 |
function liveBookMark () { |
function liveBookMark () { |
| 2006 |
// support for Firefox Live Bookmarks ability for site syndication |
// support for Firefox Live Bookmarks ability for site syndication |
| 2007 |
$c_handler = mosComponentHandler::getInstance(); |
$c_handler =& mosComponentHandler::getInstance(); |
| 2008 |
$params = $c_handler->getParamsByName('Syndicate'); |
$params = $c_handler->getParamsByName('Syndicate'); |
| 2009 |
$live_bookmark = $params->get( 'live_bookmark', 0 ); |
$live_bookmark = $params->get( 'live_bookmark', 0 ); |
| 2010 |
if ($live_bookmark) { |
if ($live_bookmark) { |
| 2033 |
function mosShowHead () { |
function mosShowHead () { |
| 2034 |
global $_VERSION; |
global $_VERSION; |
| 2035 |
$mosConfig_live_site = mamboCore::get('mosConfig_live_site'); |
$mosConfig_live_site = mamboCore::get('mosConfig_live_site'); |
| 2036 |
$this->appendMetaTag( 'description', mamboCore::get('mosConfig_MetaDesc') ); |
$this->appendMetaTag( 'description', mamboCore::get('mosConfig_MetaDesc'), true ); |
| 2037 |
$this->appendMetaTag( 'keywords', mamboCore::get('mosConfig_MetaKeys') ); |
$this->appendMetaTag( 'keywords', mamboCore::get('mosConfig_MetaKeys'), true ); |
|
$this->addMetaTag( 'Generator', $_VERSION->PRODUCT . " - " . $_VERSION->COPYRIGHT); |
|
|
$this->addMetaTag( 'robots', 'index, follow' ); |
|
| 2038 |
echo $this->getHead(); |
echo $this->getHead(); |
| 2039 |
if (mamboCore::get('mosConfig_sef')) { |
if (mamboCore::get('mosConfig_sef')) { |
| 2040 |
echo "<base href=\"$mosConfig_live_site/\" />\r\n"; |
echo "<base href=\"$mosConfig_live_site/\" />\r\n"; |
| 2047 |
} |
} |
| 2048 |
$this->liveBookMark(); |
$this->liveBookMark(); |
| 2049 |
// outputs link tag for page |
// outputs link tag for page |
| 2050 |
$configuration = mamboCore::getMamboCore(); |
$configuration =& mamboCore::getMamboCore(); |
| 2051 |
?> |
?> |
| 2052 |
<link rel="shortcut icon" href="<?php echo $configuration->getFavIcon();?>" /> |
<link rel="shortcut icon" href="<?php echo $configuration->getFavIcon();?>" /> |
| 2053 |
<?php |
<?php |
| 2115 |
* @param database A database connector object |
* @param database A database connector object |
| 2116 |
*/ |
*/ |
| 2117 |
function mosSession( &$db ) { |
function mosSession( &$db ) { |
| 2118 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 2119 |
$this->mosDBTable( '#__session', 'session_id', $database ); |
$this->mosDBTable( '#__session', 'session_id', $database ); |
| 2120 |
$this->time = time(); |
$this->time = time(); |
| 2121 |
} |
} |
| 2141 |
//$_COOKIE["sessioncookie"] = $session->getCookie(); |
//$_COOKIE["sessioncookie"] = $session->getCookie(); |
| 2142 |
if ($usercookie) { |
if ($usercookie) { |
| 2143 |
// Remember me cookie exists. Login with usercookie info. |
// Remember me cookie exists. Login with usercookie info. |
| 2144 |
$authenticator = mamboAuthenticator::getInstance(); |
require_once (mamboCore::get('mosConfig_absolute_path').'/includes/authenticator.php'); |
| 2145 |
|
$authenticator =& mamboAuthenticator::getInstance(); |
| 2146 |
$authenticator->authenticateUser ($message, $usercookie['username'], $usercookie['password'], null, $currentSession); |
$authenticator->authenticateUser ($message, $usercookie['username'], $usercookie['password'], null, $currentSession); |
| 2147 |
} |
} |
| 2148 |
} |
} |
| 2313 |
return $result; |
return $result; |
| 2314 |
} |
} |
| 2315 |
/** |
/** |
| 2316 |
|
* @param string The name of the control, or the default text area if a setup file is not found |
| 2317 |
|
* @return string HTML |
| 2318 |
|
*/ |
| 2319 |
|
function render( $name='params' ) { |
| 2320 |
|
if (is_file($this->_path)) { |
| 2321 |
|
$parser = new mosXMLParams ($this->_path, $this, $name); |
| 2322 |
|
if (count($parser->html)) return implode("\n", $parser->html); |
| 2323 |
|
} |
| 2324 |
|
$raw = $this->_raw; |
| 2325 |
|
return "<textarea name='$name' cols='40' rows='10' class='text_area'$raw</textarea>"; |
| 2326 |
|
} |
| 2327 |
|
|
| 2328 |
|
/** |
| 2329 |
* special handling for textarea param |
* special handling for textarea param |
| 2330 |
*/ |
*/ |
| 2331 |
function textareaHandling( &$txt ) { |
function textareaHandling( &$txt ) { |
| 2371 |
$local_backup_path = $configuration->rootPath().'/administrator/backups'; |
$local_backup_path = $configuration->rootPath().'/administrator/backups'; |
| 2372 |
$media_path = $configuration->rootPath().'/media/'; |
$media_path = $configuration->rootPath().'/media/'; |
| 2373 |
$image_path = $configuration->rootPath().'/images/stories'; |
$image_path = $configuration->rootPath().'/images/stories'; |
| 2374 |
|
$lang_path = $configuration->rootPath().'/language'; |
| 2375 |
$image_size = 100; |
$image_size = 100; |
| 2376 |
|
|
| 2377 |
$database = mamboDatabase::getInstance(); |
$database =& mamboDatabase::getInstance(); |
| 2378 |
$database->debug(mamboCore::get('mosConfig_debug')); |
$database->debug(mamboCore::get('mosConfig_debug')); |
| 2379 |
|
|
| 2380 |
|
// |
| 2381 |
|
|
| 2382 |
|
$gettext =& phpgettext(); |
| 2383 |
|
$gettext->bindtextdomain('common', $configuration->rootPath().'/language'); |
| 2384 |
|
$gettext->textdomain('common'); |
| 2385 |
|
//dump($gettext->textdomain(substr($option, 3))); |
| 2386 |
|
//$gettext->bindtextdomain('frontend', $lang_path); |
| 2387 |
|
//$gettext->textdomain('frontend'); |
| 2388 |
|
|
| 2389 |
if (!$adminside) { |
if (!$adminside) { |
| 2390 |
$sefcode = $configuration->rootPath().'/components/com_sef/sef.php'; |
$sefcode = $configuration->rootPath().'/components/com_sef/sef.php'; |
| 2391 |
if (file_exists($sefcode)) require_once($sefcode); |
if (file_exists($sefcode)) require_once($sefcode); |
| 2392 |
else require_once($configuration->rootPath().'/includes/sef.php'); |
else require_once($configuration->rootPath().'/includes/sef.php'); |
| 2393 |
$urlerror = 0; |
$urlerror = 0; |
| 2394 |
if (mamboCore::get('mosConfig_sef') AND $indextype == 3) { |
if (mamboCore::get('mosConfig_sef') AND $indextype == 3) { |
| 2395 |
$sef = mosSEF::getInstance(); |
$sef =& mosSEF::getInstance(); |
| 2396 |
$urlerror = $sef->sefRetrieval(mamboCore::get('mosConfig_register_globals')); |
$urlerror = $sef->sefRetrieval(mamboCore::get('mosConfig_register_globals')); |
| 2397 |
$indextype = 1; |
$indextype = 1; |
| 2398 |
} |
} |
| 2415 |
$acl = new gacl_api(); |
$acl = new gacl_api(); |
| 2416 |
// Handle special admin side options |
// Handle special admin side options |
| 2417 |
$option = strtolower(mosGetParam($_REQUEST,'option','com_admin')); |
$option = strtolower(mosGetParam($_REQUEST,'option','com_admin')); |
| 2418 |
|
|
| 2419 |
|
$domain = substr($option, 4); |
| 2420 |
|
$gettext->bindtextdomain('administrator', $lang_path); |
| 2421 |
|
$gettext->bindtextdomain($domain, $lang_path); |
| 2422 |
|
$admindomain = $gettext->textdomain(); |
| 2423 |
|
$gettext->textdomain('administrator'); |
| 2424 |
// Login will, if it succeeds, start a new session and set $my |
// Login will, if it succeeds, start a new session and set $my |
| 2425 |
if ($option == 'login') { |
if ($option == 'login') { |
| 2426 |
require_once($configuration->rootPath().'/includes/authenticator.php'); |
require_once($configuration->rootPath().'/includes/authenticator.php'); |
| 2427 |
$authenticator = mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 2428 |
$my = $authenticator->loginAdmin($acl); |
$my = $authenticator->loginAdmin($acl); |
| 2429 |
} |
} |
| 2430 |
// If this is not login, we should already have a valid admin session |
// If this is not login, we should already have a valid admin session |
| 2447 |
// We can now create the mainframe object |
// We can now create the mainframe object |
| 2448 |
$mainframe =& new mosMainFrame($database, $option, '..', true); |
$mainframe =& new mosMainFrame($database, $option, '..', true); |
| 2449 |
// 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 |
| 2450 |
|
|
| 2451 |
if ($my) { |
if ($my) { |
| 2452 |
mamboCore::set('currentUser', $my); |
mamboCore::set('currentUser', $my); |
| 2453 |
require_once( $configuration->rootPath().'/includes/mambo.php' ); |
require_once( $configuration->rootPath().'/includes/mambo.php' ); |
| 2456 |
require_once( $configuration->rootPath().'/administrator/includes/mosAdminMenus.php'); |
require_once( $configuration->rootPath().'/administrator/includes/mosAdminMenus.php'); |
| 2457 |
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
| 2458 |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
| 2459 |
$_MAMBOTS = mosMambotHandler::getInstance(); |
require_once( $configuration->rootPath() . '/components/com_content/content.class.php' ); |
| 2460 |
|
$_MAMBOTS =& mosMambotHandler::getInstance(); |
| 2461 |
|
|
| 2462 |
|
|
| 2463 |
// If no_html is set, we avoid starting the template, and go straight to the component |
// If no_html is set, we avoid starting the template, and go straight to the component |
| 2464 |
if ($no_html) { |
if ($no_html) { |
| 2465 |
if ($path = $mainframe->getPath( "admin" )) require $path; |
if ($path = $mainframe->getPath( "admin" )) require $path; |
| 2473 |
$configuration->doGzip(); |
$configuration->doGzip(); |
| 2474 |
} |
} |
| 2475 |
else { |
else { |
| 2476 |
|
if (!isset($popup)) { |
| 2477 |
$pop = mosGetParam($_REQUEST, 'pop', ''); |
$pop = mosGetParam($_REQUEST, 'pop', ''); |
| 2478 |
if ($pop) require_once($configuration->rootPath()."/administrator/popups/$pop"); |
if ($pop) require_once($configuration->rootPath()."/administrator/popups/$pop"); |
| 2479 |
else require_once($configuration->rootPath()."/administrator/popups/index3pop.php"); |
else require_once($configuration->rootPath()."/administrator/popups/index3pop.php"); |
| 2480 |
$configuration->doGzip(); |
$configuration->doGzip(); |
| 2481 |
} |
} |
| 2482 |
} |
} |
| 2483 |
|
} |
| 2484 |
// 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 ask for an admin side login |
| 2485 |
else { |
else { |
| 2486 |
$configuration->initGzip(); |
$configuration->initGzip(); |
| 2495 |
$configuration->handleGlobals(); |
$configuration->handleGlobals(); |
| 2496 |
$Itemid = $configuration->get('Itemid'); |
$Itemid = $configuration->get('Itemid'); |
| 2497 |
|
|
| 2498 |
|
// load frontend language file |
| 2499 |
|
$gettext->bindtextdomain(substr($option, 4), $configuration->rootPath().'/language'); |
| 2500 |
|
$gettext->bindtextdomain('frontend', $configuration->rootPath().'/language'); |
| 2501 |
|
$frontdomain = $gettext->textdomain(); |
| 2502 |
|
$gettext->textdomain('frontend'); |
| 2503 |
|
|
| 2504 |
|
|
| 2505 |
$mainframe =& new mosMainFrame($database, $option, '.'); |
$mainframe =& new mosMainFrame($database, $option, '.'); |
| 2506 |
$session = mosSession::getCurrent(); |
if ($option == 'login') $configuration->handleLogin(); |
| 2507 |
if ($option == 'login') $configuration->handleLogin($session); |
elseif ($option == 'logout') $configuration->handleLogout(); |
|
elseif ($option == 'logout') $configuration->handleLogout($session); |
|
| 2508 |
|
|
| 2509 |
|
$session =& mosSession::getCurrent(); |
| 2510 |
$my =& new mosUser($database); |
$my =& new mosUser($database); |
| 2511 |
$my->getSessionData(); |
$my->getSessionData(); |
| 2512 |
mamboCore::set('currentUser',$my); |
mamboCore::set('currentUser',$my); |
| 2529 |
$mainframe->detect(); |
$mainframe->detect(); |
| 2530 |
|
|
| 2531 |
/** @global mosPlugin $_MAMBOTS */ |
/** @global mosPlugin $_MAMBOTS */ |
| 2532 |
$_MAMBOTS = mosMambotHandler::getInstance(); |
$_MAMBOTS =& mosMambotHandler::getInstance(); |
| 2533 |
require_once( $configuration->rootPath().'/editor/editor.php' ); |
require_once( $configuration->rootPath().'/editor/editor.php' ); |
| 2534 |
require_once( $configuration->rootPath() . '/includes/gacl.class.php' ); |
require_once( $configuration->rootPath() . '/includes/gacl.class.php' ); |
| 2535 |
require_once( $configuration->rootPath() . '/includes/gacl_api.class.php' ); |
require_once( $configuration->rootPath() . '/includes/gacl_api.class.php' ); |
| 2536 |
|
require_once( $configuration->rootPath() . '/components/com_content/content.class.php' ); |
| 2537 |
$acl = new gacl_api(); |
$acl = new gacl_api(); |
| 2538 |
|
|
| 2539 |
|
|
| 2540 |
/** Get the component handler */ |
/** Get the component handler */ |
| 2541 |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
| 2542 |
$c_handler = mosComponentHandler::getInstance(); |
$c_handler =& mosComponentHandler::getInstance(); |
| 2543 |
$c_handler->startBuffer(); |
$c_handler->startBuffer(); |
| 2544 |
|
|
| 2545 |
if (!$urlerror AND $path = $mainframe->getPath( 'front' )) { |
if (!$urlerror AND $path = $mainframe->getPath( 'front' )) { |
| 2546 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler =& mosMenuHandler::getInstance(); |
| 2547 |
$ret = $menuhandler->menuCheck($Itemid, $option, $task, $gid); |
$ret = $menuhandler->menuCheck($Itemid, $option, $task, $gid); |
| 2548 |
$menuhandler->setPathway($Itemid); |
$menuhandler->setPathway($Itemid); |
| 2549 |
if ($ret) require_once( $path ); |
if ($ret) { |
| 2550 |
|
$gettext->textdomain(substr($option, 4)); // get the component lang file |
| 2551 |
|
require_once( $path ); |
| 2552 |
|
$gettext->textdomain($frontdomain); |
| 2553 |
|
} |
| 2554 |
else mosNotAuth(); |
else mosNotAuth(); |
| 2555 |
} |
} |
| 2556 |
else { |
else { |
| 2564 |
$configuration->initGzip(); |
$configuration->initGzip(); |
| 2565 |
|
|
| 2566 |
$configuration->standardHeaders(); |
$configuration->standardHeaders(); |
| 2567 |
if ($indextype == 1) { |
if (mosGetParam($_GET, 'syndstyle', '') == 'yes') mosMainBody(); |
| 2568 |
|
elseif ($indextype == 1) { |
| 2569 |
// loads template file |
// loads template file |
| 2570 |
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { |
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { |
| 2571 |
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; |
| 2572 |
} else { |
} else { |
| 2573 |
require_once( 'templates/'. $cur_template .'/index.php' ); |
require_once( 'templates/'. $cur_template .'/index.php' ); |
| 2574 |
$mambothandler = mosMambotHandler::getInstance(); |
$mambothandler =& mosMambotHandler::getInstance(); |
| 2575 |
$mambothandler->loadBotGroup('system'); |
$mambothandler->loadBotGroup('system'); |
| 2576 |
$mambothandler->trigger('afterTemplate', array($configuration)); |
$mambothandler->trigger('afterTemplate', array($configuration)); |
| 2577 |
echo "<!-- ".time()." -->"; |
echo "<!-- ".time()." -->"; |