| 1 |
<?php |
<?php |
| 2 |
/** |
/** |
| 3 |
* @version $Id: index.php,v 1.6 2005/11/21 11:57:20 csouza Exp $ |
* @version $Id: index.php,v 1.47 2005/08/26 08:10:43 mambofoundation Exp $ |
| 4 |
* @package Mambo |
* @package Mambo |
| 5 |
* @copyright (C) 2000 - 2005 Miro International Pty Ltd |
* @copyright (C) 2000 - 2005 Miro International Pty Ltd |
| 6 |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 7 |
* Mambo is Free Software |
* Mambo is Free Software |
| 8 |
*/ |
*/ |
| 9 |
|
|
| 10 |
// fix to address the globals overwrite problem in php versions < 4.4.1 |
/** Set flag that this is a parent file */ |
| 11 |
$protect_globals = array('_REQUEST', '_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_ENV', 'GLOBALS', '_SESSION'); |
if (!defined('_VALID_MOS')) define( '_VALID_MOS', 1 ); |
| 12 |
foreach ($protect_globals as $global) { |
|
| 13 |
if ( in_array($global , array_keys($_REQUEST)) || |
$protects = array('_REQUEST', '_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_ENV', 'GLOBALS', '_SESSION'); |
| 14 |
in_array($global , array_keys($_GET)) || |
|
| 15 |
in_array($global , array_keys($_POST)) || |
foreach ($protects as $protect) { |
| 16 |
in_array($global , array_keys($_COOKIE)) || |
if ( in_array($protect , array_keys($_REQUEST)) || |
| 17 |
in_array($global , array_keys($_FILES))) { |
in_array($protect , array_keys($_GET)) || |
| 18 |
|
in_array($protect , array_keys($_POST)) || |
| 19 |
|
in_array($protect , array_keys($_COOKIE)) || |
| 20 |
|
in_array($protect , array_keys($_FILES))) { |
| 21 |
die("Invalid Request."); |
die("Invalid Request."); |
| 22 |
} |
} |
| 23 |
} |
} |
| 24 |
|
|
| 25 |
/** Set flag that this is a parent file */ |
/** |
| 26 |
define( '_VALID_MOS', 1 ); |
* Utility function to return a value from a named array or a specified default |
| 27 |
|
*/ |
| 28 |
|
define( "_MOS_NOTRIM", 0x0001 ); |
| 29 |
|
define( "_MOS_ALLOWHTML", 0x0002 ); |
| 30 |
|
define( "_MOS_ALLOWRAW", 0x0004 ); |
| 31 |
|
define( "_MOS_NOMAGIC", 0x0008 ); |
| 32 |
|
function mosGetParam( &$arr, $name, $def=null, $mask=0 ) { |
| 33 |
|
if (isset( $arr[$name] )) { |
| 34 |
|
if (is_array($arr[$name])) foreach ($arr[$name] as $key=>$element) $result[$key] = mosGetParam ($arr[$name], $key, $def, $mask); |
| 35 |
|
else { |
| 36 |
|
$result = $arr[$name]; |
| 37 |
|
if (!($mask&_MOS_NOTRIM)) $result = trim($result); |
| 38 |
|
if (!is_numeric( $result)) { |
| 39 |
|
if (!($mask&_MOS_ALLOWHTML)) $result = strip_tags($result); |
| 40 |
|
if (!($mask&_MOS_ALLOWRAW)) { |
| 41 |
|
if (is_numeric($def)) $result = intval($result); |
| 42 |
|
} |
| 43 |
|
} |
| 44 |
|
} |
| 45 |
|
return $result; |
| 46 |
|
} else { |
| 47 |
|
return $def; |
| 48 |
|
} |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
function sefRelToAbs ($string) { |
| 52 |
|
$sef = mosSEF::getInstance(); |
| 53 |
|
return $sef->sefRelToAbs($string); |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
class mamboCore { |
| 57 |
|
var $rootPath = ''; |
| 58 |
|
var $Itemid = 0; |
| 59 |
|
var $option = ''; |
| 60 |
|
var $current_user = null; |
| 61 |
|
var $do_gzip_compress = false; |
| 62 |
|
|
| 63 |
|
function mamboCore () { |
| 64 |
|
global $adminside; |
| 65 |
|
$this->rootPath = dirname(__FILE__); |
| 66 |
|
// $this->rootPath = substr($_SERVER['SCRIPT_FILENAME'],0,-strlen($_SERVER['PHP_SELF'])+1); |
| 67 |
|
// if ($adminside) $this->rootPath = substr($this->rootPath,0,strlen($this->rootPath)-14); |
| 68 |
|
$this->checkConfig(); |
| 69 |
|
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 70 |
|
$this->getConfig(); |
| 71 |
|
$this->fixLanguage(); |
| 72 |
|
$this->secure(); |
| 73 |
|
@set_magic_quotes_runtime( 0 ); |
| 74 |
|
if (@$this->mosConfig_error_reporting === 0) error_reporting(0); |
| 75 |
|
elseif (@$this->mosConfig_error_reporting > 0) error_reporting($this->mosConfig_error_reporting); |
| 76 |
|
|
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
function &getMamboCore () { |
| 80 |
|
static $instance; |
| 81 |
|
if (!is_object($instance)) $instance = new mamboCore(); |
| 82 |
|
return $instance; |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
function rootPath () { |
| 86 |
|
if (realpath($this->rootPath) === false) die ('Invalid program load path'); |
| 87 |
|
return $this->rootPath; |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
function get ($property) { |
| 91 |
|
$config =& mamboCore::getMamboCore(); |
| 92 |
|
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; |
| 97 |
|
trigger_error("Invalid property ($property) requested from mamboCore"); |
| 98 |
|
return null; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
function is_set ($property) { |
| 102 |
|
$config =& mamboCore::getMamboCore(); |
| 103 |
|
return isset($config->$property); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
function set ($property, $value) { |
| 107 |
|
$config =& mamboCore::getMamboCore(); |
| 108 |
|
$config->$property = $value; |
| 109 |
|
$GLOBALS[$property] = $value; |
| 110 |
|
return $value; |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
function checkConfig () { |
| 114 |
|
// checks for configuration file, if none found loads installation page |
| 115 |
|
if (!file_exists($this->rootPath.'/configuration.php') OR filesize($this->rootPath.'/configuration.php') < 10 ) { |
| 116 |
|
header( 'Location: installation/index.php' ); |
| 117 |
|
exit(); |
| 118 |
|
} |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
function getConfig () { |
| 122 |
|
$code = ''; |
| 123 |
|
$f = @fopen($this->rootPath.'/configuration.php','rb'); |
| 124 |
|
if ($f) { |
| 125 |
|
while ($f AND !feof($f)) { |
| 126 |
|
$line = fgets($f, 256); |
| 127 |
|
$altered = str_replace('$', '$this->', $line); |
| 128 |
|
if ($line != $altered) $code .= $altered; |
| 129 |
|
} |
| 130 |
|
} |
| 131 |
|
else { |
| 132 |
|
header( 'Location: installation/index.php' ); |
| 133 |
|
exit(); |
| 134 |
|
} |
| 135 |
|
fclose($f); |
| 136 |
|
eval($code); |
| 137 |
|
$subdir = substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])); |
| 138 |
|
$subdir = str_replace('\\', '/', $subdir); |
| 139 |
|
$this->mosConfig_live_site = 'http://'.$_SERVER['SERVER_NAME'].$subdir; |
| 140 |
|
$this->mosConfig_absolute_path = $this->rootPath; |
| 141 |
|
preg_match_all('/\$this\-\>([A-Za-z_][A-Za-z0-9_]*)/', $code, $matches); |
| 142 |
|
foreach ($matches[1] as $match) $GLOBALS[$match] = $this->$match; |
| 143 |
|
if (!isset($this->mosConfig_register_globals)) { |
| 144 |
|
$this->mosConfig_register_globals = 0; |
| 145 |
|
$GLOBALS['mosConfig_register_globals'] = 0; |
| 146 |
|
} |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
function getFavIcon () { |
| 150 |
|
// favourites icon |
| 151 |
|
if (!isset($this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
| 152 |
|
if (!file_exists($this->rootPath.'/images/'.$this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
| 153 |
|
return $this->rootPath.'/images/'.$this->mosConfig_favicon; |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
function offlineCheck (&$user, &$database) { |
| 157 |
|
if ($this->mosConfig_offline) { |
| 158 |
|
require_once($this->rootPath().'/administrator/includes/admin.php'); |
| 159 |
|
session_name(md5($this->mosConfig_live_site)); |
| 160 |
|
session_start(); |
| 161 |
|
if ($user =& checkAdminSession($database)) return; |
| 162 |
|
include("$this->mosConfig_absolute_path/offline.php"); |
| 163 |
|
exit(); |
| 164 |
|
} |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
function fixLanguage () { |
| 168 |
|
|
| 169 |
|
|
| 170 |
|
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
| 171 |
|
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
| 172 |
|
|
| 173 |
|
|
| 174 |
|
########## DEPRECATED ############ |
| 175 |
|
if (isset($this->mosConfig_lang) AND $this->mosConfig_lang); |
| 176 |
|
else $this->set('mosConfig_lang', 'english'); |
| 177 |
|
$language_file = "$this->mosConfig_absolute_path/language/$this->mosConfig_lang.php"; |
| 178 |
|
if (file_exists($language_file)) require_once ($language_file); |
| 179 |
|
################################### |
| 180 |
|
|
| 181 |
|
//set_error_handler('error_handler'); |
| 182 |
|
$lang = $this->mosConfig_lang; |
| 183 |
|
|
| 184 |
|
|
| 185 |
|
$langfile = $this->rootPath.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR.$lang.'.xml'; |
| 186 |
|
$p = xml_parser_create(); |
| 187 |
|
xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0); |
| 188 |
|
xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1); |
| 189 |
|
xml_parse_into_struct($p, implode("", file($langfile)), $values); |
| 190 |
|
xml_parser_free($p); |
| 191 |
|
foreach($values as $key => $value) |
| 192 |
|
{ |
| 193 |
|
if ($value['tag'] == 'param') { |
| 194 |
|
$name = $value['attributes']['name']; |
| 195 |
|
$this->language[$name] = $value['attributes']['default']; |
| 196 |
|
} |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
DEFINE('_ISO','charset='.$this->language['encoding']); |
| 200 |
|
DEFINE('_DATE_FORMAT_LC', $this->language['dateformat']); //Uses PHP's strftime Command Format |
| 201 |
|
DEFINE('_DATE_FORMAT_LC2', $this->language['dateformat']." %H:%M"); |
| 202 |
|
|
| 203 |
|
//header('Content-Type: text/html; charset=utf-8'); |
| 204 |
|
$domain = $this->mosConfig_lang; |
| 205 |
|
$textdomain = $this->rootPath.'/language'; |
| 206 |
|
$gettext =& phpgettext(); |
| 207 |
|
$gettext->debug = 0; |
| 208 |
|
$gettext->has_gettext = 0; |
| 209 |
|
$gettext->setlocale($name); |
| 210 |
|
setlocale(LC_ALL, $this->language['locale']); |
| 211 |
|
setlocale(LC_CTYPE, $this->language['encoding']); |
| 212 |
|
$gettext->bindtextdomain($domain, $textdomain); |
| 213 |
|
$gettext->bind_textdomain_codeset($domain, $this->language['encoding']); |
| 214 |
|
$gettext->textdomain($domain); |
| 215 |
|
/**/ |
| 216 |
|
|
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
function secure () { |
| 220 |
|
$this->mosConfig_unsecure_site = $this->mosConfig_live_site; |
| 221 |
|
if ($_SERVER['SERVER_PORT'] == 443) { |
| 222 |
|
if (!isset($this->mosConfig_secure_site)) $this->mosConfig_secure_site = str_replace('http://', 'https://', $this->mosConfig_live_site); |
| 223 |
|
$this->mosConfig_live_site = $this->mosConfig_secure_site; |
| 224 |
|
} |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
function handleGlobals () { |
| 228 |
|
$superglobals = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET); |
| 229 |
|
if (isset( $_SESSION )) array_unshift ( $superglobals , $_SESSION ); |
| 230 |
|
|
| 231 |
|
// Emulate register_globals on |
| 232 |
|
if (!ini_get('register_globals') && $this->mosConfig_register_globals) { |
| 233 |
|
while(list($key,$value)=each($_GET)) { |
| 234 |
|
if (!isset($GLOBALS[$key])) $GLOBALS[$key]=$value; |
| 235 |
|
} |
| 236 |
|
} |
| 237 |
|
// Emulate register_globals off |
| 238 |
|
elseif (ini_get('register_globals') && !$this->mosConfig_register_globals) { |
| 239 |
|
foreach ( $superglobals as $superglobal ) { |
| 240 |
|
foreach ( $superglobal as $key => $value) { |
| 241 |
|
unset( $GLOBALS[$key]); |
| 242 |
|
} |
| 243 |
|
} |
| 244 |
|
} |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
function determineOptionAndItemid () { |
| 248 |
|
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 249 |
|
if ($option = strtolower(mosGetParam($_REQUEST, 'option'))); |
| 250 |
|
else { |
| 251 |
|
$menuhandler = mosMenuHandler::getInstance(); |
| 252 |
|
$menus =& $menuhandler->getByParentOrder($this->Itemid, 'mainmenu'); |
| 253 |
|
$this->Itemid = $menus[0]->id; |
| 254 |
|
$_REQUEST['Itemid'] = $this->Itemid; |
| 255 |
|
$link = $menus[0]->link; |
| 256 |
|
$pos = strpos( $link, '?' ); |
| 257 |
|
if ($pos !== false) $link = substr( $link, $pos+1 ). '&Itemid='.$this->Itemid; |
| 258 |
|
parse_str( $link, $temp ); |
| 259 |
|
/** this is a patch, need to rework when globals are handled better */ |
| 260 |
|
foreach ($temp as $k=>$v) $_GET[$k] = $v; |
| 261 |
|
if (isset($temp['option'])) $option = $temp['option']; |
| 262 |
|
else return ''; |
| 263 |
|
} |
| 264 |
|
/** patch to lessen the impact on templates */ |
| 265 |
|
if ($option == 'search') $option = 'com_search'; |
| 266 |
|
// checking if we can find the Itemid thru the component |
| 267 |
|
if ($this->Itemid === 0) { |
| 268 |
|
if ( $option == 'com_content') { |
| 269 |
|
require_once($this->rootPath().'/components/com_content/content.class.php'); |
| 270 |
|
$handler = contentHandler::getInstance(); |
| 271 |
|
$this->Itemid = $handler->getItemid(mosGetParam($_REQUEST, 'id', 0 )); |
| 272 |
|
$_REQUEST['Itemid'] = $this->Itemid; |
| 273 |
|
} |
| 274 |
|
else { |
| 275 |
|
$menuhandler = mosMenuHandler::getInstance(); |
| 276 |
|
$this->Itemid = $menuhandler->getIdLikeLink("index.php?option=$option"); |
| 277 |
|
if ($this->Itemid === 0) { |
| 278 |
|
$menuhandler = mosMenuHandler::getInstance(); |
| 279 |
|
$menus =& $menuhandler->getByParentOrder($this->Itemid, 'mainmenu'); |
| 280 |
|
} |
| 281 |
|
} |
| 282 |
|
} |
| 283 |
|
return $option; |
| 284 |
|
} |
| 285 |
|
|
| 286 |
|
function redirect ($url, $msg='') { |
| 287 |
|
$callcheck = array('InputFilter', 'process'); |
| 288 |
|
if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpinputfilter/class.inputfilter.php'); |
| 289 |
|
// specific filters |
| 290 |
|
$iFilter =& new InputFilter(); |
| 291 |
|
$url = $iFilter->process( $url ); |
| 292 |
|
$message = trim($iFilter->process($msg)); |
| 293 |
|
if ($iFilter->badAttributeValue(array('href', $url))) $url = mamboCore::get('mosConfig_live_site'); |
| 294 |
|
if ($message) { |
| 295 |
|
if (strpos($url, '?')) $url .= '&mosmsg='.urlencode($message); |
| 296 |
|
else $url .= '?mosmsg='.urlencode($message); |
| 297 |
|
} |
| 298 |
|
if (headers_sent()) echo "<script>document.location.href='$url';</script>\n"; |
| 299 |
|
else { |
| 300 |
|
@ob_end_clean(); // clear output buffer |
| 301 |
|
header( "Location: $url" ); |
| 302 |
|
} |
| 303 |
|
exit(); |
| 304 |
|
} |
| 305 |
|
|
| 306 |
|
function logMessage ($text) { |
| 307 |
|
// JS Popup message |
| 308 |
|
if (mosGetParam( $_POST, 'message', 0 )) { |
| 309 |
|
?> |
| 310 |
|
<script type="text/javascript"> |
| 311 |
|
<!--// |
| 312 |
|
alert( "<?php echo $text; ?>" ); |
| 313 |
|
//--> |
| 314 |
|
</script> |
| 315 |
|
<?php |
| 316 |
|
} |
| 317 |
|
if ($return = mosGetParam( $_REQUEST, 'return', '' )) { |
| 318 |
|
$this->redirect( $return ); |
| 319 |
|
} |
| 320 |
|
else { |
| 321 |
|
$this->redirect( $this->mosConfig_live_site.'/index.php' ); |
| 322 |
|
} |
| 323 |
|
} |
| 324 |
|
|
| 325 |
|
function handleLogin ($session) { |
| 326 |
|
require_once($this->rootPath().'/includes/authenticator.php'); |
| 327 |
|
$authenticator = mamboAuthenticator::getInstance(); |
| 328 |
|
$authenticator->loginUser(); |
| 329 |
|
$this->logMessage(_LOGIN_SUCCESS); |
| 330 |
|
} |
| 331 |
|
|
| 332 |
|
function handleLogout ($session) { |
| 333 |
|
require_once($this->rootPath().'/includes/authenticator.php'); |
| 334 |
|
$authenticator = mamboAuthenticator::getInstance(); |
| 335 |
|
$authenticator->logoutUser(); |
| 336 |
|
@session_destroy(); |
| 337 |
|
$this->logMessage(_LOGOUT_SUCCESS); |
| 338 |
|
} |
| 339 |
|
|
| 340 |
|
function standardHeaders () { |
| 341 |
|
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); |
| 342 |
|
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
| 343 |
|
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); |
| 344 |
|
header( 'Cache-Control: post-check=0, pre-check=0', false ); |
| 345 |
|
header( 'Pragma: no-cache' ); |
| 346 |
|
$mambothandler = mosMambotHandler::getInstance(); |
| 347 |
|
$mambothandler->loadBotGroup('system'); |
| 348 |
|
$mambothandler->trigger('onHeaders', array($this)); |
| 349 |
|
} |
| 350 |
|
|
| 351 |
|
function initGzip() { |
| 352 |
|
$this->do_gzip_compress = FALSE; |
| 353 |
|
//zlib.output_compression and ob_gzhandler don't get along well so we'll check to make |
| 354 |
|
//that zlib.output_compression is not enable in the php.ini before turning on ob_gzhandler |
| 355 |
|
if ( $this->mosConfig_gzip == 1 && (int)ini_get('zlib.output_compression') != 1 ) { |
| 356 |
|
$phpver = phpversion(); |
| 357 |
|
$useragent = mosGetParam( $_SERVER, 'HTTP_USER_AGENT', '' ); |
| 358 |
|
$canZip = mosGetParam( $_SERVER, 'HTTP_ACCEPT_ENCODING', '' ); |
| 359 |
|
|
| 360 |
|
if ( $phpver >= '4.0.4pl1' && |
| 361 |
|
( strpos($useragent,'compatible') !== false || |
| 362 |
|
strpos($useragent,'Gecko') !== false |
| 363 |
|
) |
| 364 |
|
) { |
| 365 |
|
if ( extension_loaded('zlib') ) { |
| 366 |
|
ob_start( 'ob_gzhandler' ); |
| 367 |
|
return; |
| 368 |
|
} |
| 369 |
|
} else if ( $phpver > '4.0' ) { |
| 370 |
|
if ( strpos($canZip,'gzip') !== false ) { |
| 371 |
|
if (extension_loaded( 'zlib' )) { |
| 372 |
|
$this->do_gzip_compress = TRUE; |
| 373 |
|
ob_start(); |
| 374 |
|
ob_implicit_flush(0); |
| 375 |
|
|
| 376 |
|
header( 'Content-Encoding: gzip' ); |
| 377 |
|
return; |
| 378 |
|
} |
| 379 |
|
} |
| 380 |
|
} |
| 381 |
|
} |
| 382 |
|
ob_start(); |
| 383 |
|
} |
| 384 |
|
|
| 385 |
|
/** |
| 386 |
|
* Perform GZIP |
| 387 |
|
*/ |
| 388 |
|
function doGzip() { |
| 389 |
|
if ( $this->do_gzip_compress ) { |
| 390 |
|
/** |
| 391 |
|
*Borrowed from php.net! |
| 392 |
|
*/ |
| 393 |
|
$gzip_contents = ob_get_contents(); |
| 394 |
|
ob_end_clean(); |
| 395 |
|
|
| 396 |
|
$gzip_size = strlen($gzip_contents); |
| 397 |
|
$gzip_crc = crc32($gzip_contents); |
| 398 |
|
|
| 399 |
|
$gzip_contents = gzcompress($gzip_contents, 9); |
| 400 |
|
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4); |
| 401 |
|
|
| 402 |
|
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00"; |
| 403 |
|
echo $gzip_contents; |
| 404 |
|
echo pack('V', $gzip_crc); |
| 405 |
|
echo pack('V', $gzip_size); |
| 406 |
|
} else { |
| 407 |
|
ob_end_flush(); |
| 408 |
|
} |
| 409 |
|
} |
| 410 |
|
|
| 411 |
|
function getLastPart ($separator, $field) { |
| 412 |
|
$parts = explode($separator, $field); |
| 413 |
|
return $parts[count($parts)-1]; |
| 414 |
|
} |
| 415 |
|
|
| 416 |
|
function allButLast ($separator, $field) { |
| 417 |
|
$lastSize = strlen(mamboCore::getLastPart($separator,$field)); |
| 418 |
|
return substr($field, 0, strlen($field)-$lastSize); |
| 419 |
|
} |
| 420 |
|
|
| 421 |
|
} |
| 422 |
|
|
| 423 |
|
if (!isset($adminside)) $adminside = 0; |
| 424 |
|
if (!isset($indextype)) $indextype = 1; |
| 425 |
|
|
| 426 |
|
$configuration =& mamboCore::getMamboCore(); |
| 427 |
|
$configuration->handleGlobals(); |
| 428 |
|
|
| 429 |
|
require_once ($configuration->rootPath().'/includes/database.php'); |
| 430 |
|
|
| 431 |
|
/** |
| 432 |
|
* Mambo basic error object |
| 433 |
|
*/ |
| 434 |
|
define ('_MOS_ERROR_INFORM', 0); |
| 435 |
|
define ('_MOS_ERROR_WARN', 1); |
| 436 |
|
define ('_MOS_ERROR_SEVERE', 2); |
| 437 |
|
define ('_MOS_ERROR_FATAL', 3); |
| 438 |
|
|
| 439 |
|
class mosError { |
| 440 |
|
var $text = ''; |
| 441 |
|
var $level = 0; |
| 442 |
|
|
| 443 |
|
function mosError ($text='', $level=_MOS_ERROR_INFORM) { |
| 444 |
|
$this->text = $text; |
| 445 |
|
$this->level = $level; |
| 446 |
|
} |
| 447 |
|
} |
| 448 |
|
|
| 449 |
|
/** |
| 450 |
|
* Mambo group of errors for some particular operation |
| 451 |
|
*/ |
| 452 |
|
class mosErrorSet { |
| 453 |
|
var $errors = array(); |
| 454 |
|
var $maxlevel = 0; |
| 455 |
|
|
| 456 |
|
// Parameter is an error object |
| 457 |
|
function addError ($error) { |
| 458 |
|
$this->errors[] = $error; |
| 459 |
|
if ($error->level > $this->maxlevel) $this->maxlevel = $error->level; |
| 460 |
|
} |
| 461 |
|
|
| 462 |
|
function addErrorDetails ($text='', $level=_MOS_ERROR_INFORM) { |
| 463 |
|
$error = new mosError($text, $level); |
| 464 |
|
$this->addError($error); |
| 465 |
|
} |
| 466 |
|
|
| 467 |
|
function &getErrors () { |
| 468 |
|
return $this->errors; |
| 469 |
|
} |
| 470 |
|
|
| 471 |
|
function getMaxLevel () { |
| 472 |
|
return $this->maxlevel; |
| 473 |
|
} |
| 474 |
|
|
| 475 |
|
function getCount () { |
| 476 |
|
return count($this->errors); |
| 477 |
|
} |
| 478 |
|
|
| 479 |
|
function mergeAnother ($errorset) { |
| 480 |
|
$this->errors = array_merge($this->errors, $errorset->errors); |
| 481 |
|
} |
| 482 |
|
|
| 483 |
|
} |
| 484 |
|
|
| 485 |
|
/** |
| 486 |
|
* Sorts an Array of objects |
| 487 |
|
*/ |
| 488 |
|
class mosObjectSorter { |
| 489 |
|
var $_keyname = ''; |
| 490 |
|
var $_direction = 0; |
| 491 |
|
var $_object_array = array(); |
| 492 |
|
|
| 493 |
|
function mosObjectSorter (&$a, $k, $sort_direction=1) { |
| 494 |
|
$this->_keyname = $k; |
| 495 |
|
$this->_direction = $sort_direction; |
| 496 |
|
$this->_object_array =& $a; |
| 497 |
|
$this->sort(); |
| 498 |
|
} |
| 499 |
|
|
| 500 |
|
function mosObjectCompare (&$a, &$b) { |
| 501 |
|
$key = $this->_keyname; |
| 502 |
|
if ($a->$key > $b->$key) return $this->_direction; |
| 503 |
|
if ($a->$key < $b->$key) return -$this->_direction; |
| 504 |
|
return 0; |
| 505 |
|
} |
| 506 |
|
|
| 507 |
|
function sort () { |
| 508 |
|
usort($this->_object_array, array($this,'mosObjectCompare')); |
| 509 |
|
} |
| 510 |
|
|
| 511 |
|
} |
| 512 |
|
|
| 513 |
|
/** |
| 514 |
|
* Pathway handler |
| 515 |
|
* @package Mambo |
| 516 |
|
*/ |
| 517 |
|
class mosPathway { |
| 518 |
|
/** @var array Names for display in pathway */ |
| 519 |
|
var $_names = null; |
| 520 |
|
/** @var array URLs for links from pathway */ |
| 521 |
|
var $_urls = null; |
| 522 |
|
|
| 523 |
|
/** |
| 524 |
|
* Constructor |
| 525 |
|
*/ |
| 526 |
|
function mosPathway () { |
| 527 |
|
$menuhandler = mosMenuHandler::getInstance(); |
| 528 |
|
$menus =& $menuhandler->getByParentOrder(0,'mainmenu'); |
| 529 |
|
$home = $menus[0]; |
| 530 |
|
$this->_names[] = $home->name; |
| 531 |
|
$this->_urls[] = sefRelToAbs($home->link."&Itemid=$home->id"); |
| 532 |
|
} |
| 533 |
|
|
| 534 |
|
/** |
| 535 |
|
* Singleton accessor |
| 536 |
|
*/ |
| 537 |
|
function &getInstance () { |
| 538 |
|
static $instance; |
| 539 |
|
if (!is_object($instance)) $instance = new mosPathway(); |
| 540 |
|
return $instance; |
| 541 |
|
} |
| 542 |
|
|
| 543 |
|
/** |
| 544 |
|
* Add an item to the pathway |
| 545 |
|
*/ |
| 546 |
|
function addItem ($name, $givenurl) { |
| 547 |
|
$last = count($this->_names) - 1; |
| 548 |
|
if (!$name) return; |
| 549 |
|
$url = sefRelToAbs($givenurl); |
| 550 |
|
if ($name == $this->_names[$last] AND $url == $this->_urls[$last]) return; |
| 551 |
|
$this->_names[$last+1] = $name; |
| 552 |
|
$this->_urls[$last+1] = $url; |
| 553 |
|
} |
| 554 |
|
|
| 555 |
|
function reduceToOne () { |
| 556 |
|
for ($i = count($this->_names) - 1; $i > 0; $i--) { |
| 557 |
|
unset($this->_names[$i]); |
| 558 |
|
unset($this->_urls[$i]); |
| 559 |
|
} |
| 560 |
|
} |
| 561 |
|
|
| 562 |
|
/** |
| 563 |
|
* Make a pathway string for display |
| 564 |
|
*/ |
| 565 |
|
function makePathway () { |
| 566 |
|
$last = count($this->_names) - 1; |
| 567 |
|
if ($last == 0) return ''; |
| 568 |
|
$mainframe = mosMainFrame::getInstance(); |
| 569 |
|
$result = "<span class='pathway'>"; |
| 570 |
|
$config = mamboCore::getMamboCore(); |
| 571 |
|
$rootpath = $config->rootPath(); |
| 572 |
|
$imgPath = 'templates/'.$mainframe->getTemplate().'/images/arrow.png'; |
| 573 |
|
if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='$config->mosConfig_live_site/$imgPath' border='0' alt='arrow' />"; |
| 574 |
|
else { |
| 575 |
|
$imgPath = '/images/M_images/arrow.png'; |
| 576 |
|
if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='$config->mosConfig_live_site/images/M_images/arrow.png' alt='arrow' />"; |
| 577 |
|
else $img = '>'; |
| 578 |
|
} |
| 579 |
|
foreach ($this->_names as $i=>$name) { |
| 580 |
|
if ($i === $last) $result .= "$name</span>"; |
| 581 |
|
else { |
| 582 |
|
$sefurl = sefRelToAbs($this->_urls[$i]); |
| 583 |
|
$result .= "<a href='$sefurl' class='pathway'>$name</a>"; |
| 584 |
|
$result .= " $img "; |
| 585 |
|
} |
| 586 |
|
} |
| 587 |
|
$customs = $mainframe->getCustomPathWay(); |
| 588 |
|
foreach ($customs as $custom) $result .= $custom; |
| 589 |
|
$result .= '</span>'; |
| 590 |
|
return $result; |
| 591 |
|
} |
| 592 |
|
|
| 593 |
|
} |
| 594 |
|
|
| 595 |
|
/** |
| 596 |
|
* Module database table class |
| 597 |
|
* @package Mambo |
| 598 |
|
*/ |
| 599 |
|
class mosMenu extends mosDBTable { |
| 600 |
|
/** @var int Primary key */ |
| 601 |
|
var $id=null; |
| 602 |
|
/** @var string */ |
| 603 |
|
var $menutype=null; |
| 604 |
|
/** @var string */ |
| 605 |
|
var $name=null; |
| 606 |
|
/** @var string */ |
| 607 |
|
var $link=null; |
| 608 |
|
/** @var int */ |
| 609 |
|
var $type=null; |
| 610 |
|
/** @var int */ |
| 611 |
|
var $published=null; |
| 612 |
|
/** @var int */ |
| 613 |
|
var $componentid=null; |
| 614 |
|
/** @var int */ |
| 615 |
|
var $parent=null; |
| 616 |
|
/** @var int */ |
| 617 |
|
var $sublevel=null; |
| 618 |
|
/** @var int */ |
| 619 |
|
var $ordering=null; |
| 620 |
|
/** @var boolean */ |
| 621 |
|
var $checked_out=null; |
| 622 |
|
/** @var datetime */ |
| 623 |
|
var $checked_out_time=null; |
| 624 |
|
/** @var boolean */ |
| 625 |
|
var $pollid=null; |
| 626 |
|
|
| 627 |
|
/** @var string */ |
| 628 |
|
var $browserNav=null; |
| 629 |
|
/** @var int */ |
| 630 |
|
var $access=null; |
| 631 |
|
/** @var int */ |
| 632 |
|
var $utaccess=null; |
| 633 |
|
/** @var string */ |
| 634 |
|
var $params=null; |
| 635 |
|
|
| 636 |
|
/** |
| 637 |
|
* @param database A database connector object |
| 638 |
|
*/ |
| 639 |
|
function mosMenu( $dummy ) { |
| 640 |
|
$db = mamboDatabase::getInstance(); |
| 641 |
|
$this->mosDBTable( '#__menu', 'id', $db ); |
| 642 |
|
} |
| 643 |
|
/** |
| 644 |
|
* binds an array/hash to this object |
| 645 |
|
* @param int $oid optional argument, if not specifed then the value of current key is used |
| 646 |
|
* @return any result from the database operation |
| 647 |
|
*/ |
| 648 |
|
function load( $oid=null ) { |
| 649 |
|
$k = $this->_tbl_key; |
| 650 |
|
if ($oid !== null) $this->$k = $oid; |
| 651 |
|
if ($this->$k === null) return false; |
| 652 |
|
$menuhandler = mosMenuHandler::getInstance(); |
| 653 |
|
$menu = $menuhandler->getMenuById($this->$k); |
| 654 |
|
if ($menu) { |
| 655 |
|
foreach (get_object_vars($menu) as $key=>$data) $this->$key = $data; |
| 656 |
|
return true; |
| 657 |
|
} |
| 658 |
|
else return false; |
| 659 |
|
} |
| 660 |
|
|
| 661 |
|
} |
| 662 |
|
|
| 663 |
|
/** |
| 664 |
|
* File Manager including safe mode provision? |
| 665 |
|
* @package Mambo |
| 666 |
|
*/ |
| 667 |
|
class mosFileManager { |
| 668 |
|
|
| 669 |
|
/** |
| 670 |
|
* Singleton accessor |
| 671 |
|
*/ |
| 672 |
|
function &getInstance () { |
| 673 |
|
static $instance; |
| 674 |
|
if (!is_object($instance)) $instance = new mosFileManager(); |
| 675 |
|
return $instance; |
| 676 |
|
} |
| 677 |
|
|
| 678 |
|
function deleteFile ($file) { |
| 679 |
|
if (file_exists($file)) unlink($file); |
| 680 |
|
} |
| 681 |
|
|
| 682 |
|
function deleteDirectory ($dir) { |
| 683 |
|
rmdir($dir); |
| 684 |
|
} |
| 685 |
|
|
| 686 |
|
function createDirectory ($dir) { |
| 687 |
|
list($upDirectory, $count) = $this->containingDirectory($dir); |
| 688 |
|
if ($count > 1 AND !file_exists($upDirectory)) $this->createDirectory($upDirectory); |
| 689 |
|
mkdir($dir); |
| 690 |
|
} |
| 691 |
|
|
| 692 |
|
function containingDirectory ($dir) { |
| 693 |
|
$dirs = preg_split('*[/|\\\]*', $dir); |
| 694 |
|
for ($i = count($dirs)-1; $i >= 0; $i--) { |
| 695 |
|
$text = trim($dirs[$i]); |
| 696 |
|
unset($dirs[$i]); |
| 697 |
|
if ($text) break; |
| 698 |
|
} |
| 699 |
|
return array(implode('/',$dirs), count($dirs)); |
| 700 |
|
} |
| 701 |
|
|
| 702 |
|
|
| 703 |
|
function forceCopy ($from, $to) { |
| 704 |
|
$todir = dirname($to); |
| 705 |
|
if (!file_exists($todir)) $this->createDirectory($todir); |
| 706 |
|
if (!file_exists($todir)) return false; |
| 707 |
|
$name = basename($from); |
| 708 |
|
$this->deleteFile($to.$name); |
| 709 |
|
return @copy($from, $to); |
| 710 |
|
} |
| 711 |
|
|
| 712 |
|
function lightCopy ($from, $to) { |
| 713 |
|
$name = basename($from); |
| 714 |
|
if (file_exists($to.$name)) return false; |
| 715 |
|
$todir = dirname($to); |
| 716 |
|
if (!file_exists($todir)) $this->createDirectory($todir); |
| 717 |
|
if (!file_exists($todir)) return false; |
| 718 |
|
return @copy($from, $to); |
| 719 |
|
} |
| 720 |
|
|
| 721 |
|
|
| 722 |
|
/** |
| 723 |
|
* Function to strip additional / or \ in a path name |
| 724 |
|
* @param string The path |
| 725 |
|
* @param boolean Add trailing slash |
| 726 |
|
*/ |
| 727 |
|
function mosPathName($p_path, $p_addtrailingslash=true) { |
| 728 |
|
if (substr(PHP_OS, 0, 3) == 'WIN') { |
| 729 |
|
$retval = str_replace( '/', '\\', $p_path ); |
| 730 |
|
if ($p_addtrailingslash AND substr( $retval, -1 ) != '\\') $retval .= '\\'; |
| 731 |
|
// Remove double \\ |
| 732 |
|
$retval = str_replace( '\\\\', '\\', $retval ); |
| 733 |
|
} |
| 734 |
|
else { |
| 735 |
|
$retval = str_replace( '\\', '/', $p_path ); |
| 736 |
|
if ($p_addtrailingslash AND substr( $retval, -1 ) != '/') $retval .= '/'; |
| 737 |
|
// Remove double // |
| 738 |
|
$retval = str_replace('//','/',$retval); |
| 739 |
|
} |
| 740 |
|
return $retval; |
| 741 |
|
} |
| 742 |
|
|
| 743 |
|
/** |
| 744 |
|
* Chmods files and directories recursively to mos global permissions. Available from 4.5.2 up. |
| 745 |
|
* @param path The starting file or directory (no trailing slash) |
| 746 |
|
* @param filemode Integer value to chmod files. NULL = dont chmod files. |
| 747 |
|
* @param dirmode Integer value to chmod directories. NULL = dont chmod directories. |
| 748 |
|
* @return TRUE=all succeeded FALSE=one or more chmods failed |
| 749 |
|
*/ |
| 750 |
|
function mosChmod($path) |
| 751 |
|
{ |
| 752 |
|
$fileperms = mamboCore::get('mosConfig_fileperms'); |
| 753 |
|
$dirperms = mamboCore::get('mosConfig_dirperms'); |
| 754 |
|
if ($fileperms != '') $filemode = octdec($fileperms); |
| 755 |
|
else $filemode = null; |
| 756 |
|
if ($dirperms != '') $dirmode = octdec($dirperms); |
| 757 |
|
else $dirmode = null; |
| 758 |
|
if (isset($filemode) OR isset($dirmode)) |
| 759 |
|
return $this->mosChmodRecursive($path, $filemode, $dirmode); |
| 760 |
|
return true; |
| 761 |
|
} // mosChmod |
| 762 |
|
|
| 763 |
|
/** |
| 764 |
|
* Chmods files and directories recursively to given permissions. Available from 4.5.2 up. |
| 765 |
|
* @param path The starting file or directory (no trailing slash) |
| 766 |
|
* @param filemode Integer value to chmod files. NULL = dont chmod files. |
| 767 |
|
* @param dirmode Integer value to chmod directories. NULL = dont chmod directories. |
| 768 |
|
* @return TRUE=all succeeded FALSE=one or more chmods failed |
| 769 |
|
*/ |
| 770 |
|
function mosChmodRecursive($path, $filemode=NULL, $dirmode=NULL) { |
| 771 |
|
$ret = true; |
| 772 |
|
if (is_dir($path)) { |
| 773 |
|
$topdir =& new mosDirectory($path); |
| 774 |
|
$files = $topdir->listFiles ('', 'file', true); |
| 775 |
|
$dirs = $topdir->listFiles ('', 'dir', true); |
| 776 |
|
} |
| 777 |
|
else { |
| 778 |
|
$files = array($path); |
| 779 |
|
$dirs = array(); |
| 780 |
|
} |
| 781 |
|
if (isset($filemode)) foreach ($files as $file) $ret = @chmod($file, $filemode) ? $ret : false; |
| 782 |
|
if (isset($dirmode)) foreach ($dirs as $dir) $ret = @chmod($dir, $dirmode) ? $ret : false; |
| 783 |
|
return $ret; |
| 784 |
|
} |
| 785 |
|
|
| 786 |
|
} |
| 787 |
|
|
| 788 |
|
class mosDirectory { |
| 789 |
|
var $path = ''; |
| 790 |
|
|
| 791 |
|
function mosDirectory ($path) { |
| 792 |
|
$path = str_replace('\\', '/', $path); |
| 793 |
|
if (substr($path,-1,1) == '/') $this->path = $path; |
| 794 |
|
else $this->path = $path.'/'; |
| 795 |
|
} |
| 796 |
|
|
| 797 |
|
function &listAll ($type='file', $recurse=false, $fullpath=false) { |
| 798 |
|
$results = array(); |
| 799 |
|
if ($dir = @opendir($this->path)) { |
| 800 |
|
while ($file = readdir($dir)) { |
| 801 |
|
if ($file == '.' OR $file == '..') continue; |
| 802 |
|
if (is_dir($this->path.$file)) { |
| 803 |
|
if ($recurse) { |
| 804 |
|
$subdir = new mosDirectory($this->path.$file); |
| 805 |
|
$results = array_merge($results, $subdir->listAll($type, $recurse, $fullpath)); |
| 806 |
|
unset($subdir); |
| 807 |
|
} |
| 808 |
|
if ($type == 'file') continue; |
| 809 |
|
} |
| 810 |
|
elseif ($type == 'dir') continue; |
| 811 |
|
if ($fullpath) $results[] = $this->path.$file; |
| 812 |
|
else $results[] = $file; |
| 813 |
|
} |
| 814 |
|
closedir($dir); |
| 815 |
|
} |
| 816 |
|
return $results; |
| 817 |
|
} |
| 818 |
|
|
| 819 |
|
function soleDir () { |
| 820 |
|
$found = ''; |
| 821 |
|
if ($dir = @opendir($this->path)) { |
| 822 |
|
while ($file = readdir($dir)) { |
| 823 |
|
if ($file == '.' OR $file == '..') continue; |
| 824 |
|
if (is_dir($this->path.$file)) { |
| 825 |
|
if ($found) return ''; |
| 826 |
|
else $found = $file; |
| 827 |
|
} |
| 828 |
|
else return ''; |
| 829 |
|
} |
| 830 |
|
closedir($dir); |
| 831 |
|
} |
| 832 |
|
return $found; |
| 833 |
|
} |
| 834 |
|
|
| 835 |
|
function deleteAll () { |
| 836 |
|
if (!file_exists($this->path)) return; |
| 837 |
|
$subdirs =& $this->listAll ('dir', false, true); |
| 838 |
|
foreach ($subdirs as $subdir) { |
| 839 |
|
$subdirectory = new mosDirectory($subdir); |
| 840 |
|
$subdirectory->deleteAll(); |
| 841 |
|
unset($subdirectory); |
| 842 |
|
} |
| 843 |
|
$filemanager = mosFileManager::getInstance(); |
| 844 |
|
$files =& $this->listAll ('file', false, true); |
| 845 |
|
foreach ($files as $file) $filemanager->deleteFile($file); |
| 846 |
|
$filemanager->deleteDirectory($this->path); |
| 847 |
|
} |
| 848 |
|
|
| 849 |
|
function createFresh () { |
| 850 |
|
$this->deleteAll(); |
| 851 |
|
$filemanager = mosFileManager::getInstance(); |
| 852 |
|
$filemanager->createDirectory($this->path); |
| 853 |
|
return true; |
| 854 |
|
} |
| 855 |
|
|
| 856 |
|
function createIfNeeded () { |
| 857 |
|
if (!file_exists($this->path)) { |
| 858 |
|
$filemanager = mosFileManager::getInstance(); |
| 859 |
|
$filemanager->createDirectory($this->path); |
| 860 |
|
} |
| 861 |
|
} |
| 862 |
|
|
| 863 |
|
function &listFiles ($pattern='', $type='file', $recurse=false, $fullpath=false) { |
| 864 |
|
$results = array(); |
| 865 |
|
$all =& $this->listAll($type, $recurse, $fullpath); |
| 866 |
|
foreach ($all as $file) { |
| 867 |
|
$name = basename($file); |
| 868 |
|
if ($pattern AND !preg_match( "/$pattern/", $name )) continue; |
| 869 |
|
if (($name != 'index.html') AND ($name[0] != '.')) $results[] = $file; |
| 870 |
|
} |
| 871 |
|
return $results; |
| 872 |
|
} |
| 873 |
|
|
| 874 |
|
function getSize () { |
| 875 |
|
$totalsize = 0; |
| 876 |
|
$files = $this->listFiles(); |
| 877 |
|
foreach ($files as $file) $totalsize += filesize($this->path.$file); |
| 878 |
|
return $totalsize; |
| 879 |
|
} |
| 880 |
|
|
| 881 |
|
} |
| 882 |
|
|
| 883 |
|
/** |
| 884 |
|
* Menu handler |
| 885 |
|
* @package Mambo |
| 886 |
|
*/ |
| 887 |
|
class mosMenuHandler { |
| 888 |
|
/** @var array Menu objects currently available */ |
| 889 |
|
var $_menus = null; |
| 890 |
|
/** @var array Counts of menu items by type and published status */ |
| 891 |
|
var $_counts = null; |
| 892 |
|
/** @var array Access to stored menu objects by ID */ |
| 893 |
|
var $_idlinks = null; |
| 894 |
|
/** @var array Items that may be useful for setting Itemid */ |
| 895 |
|
var $_byParentOrder = null; |
| 896 |
|
|
| 897 |
|
/** |
| 898 |
|
* Constructor |
| 899 |
|
*/ |
| 900 |
|
function mosMenuHandler() { |
| 901 |
|
global $my; |
| 902 |
|
$database = mamboDatabase::getInstance(); |
| 903 |
|
$sql = "SELECT * FROM #__menu ORDER BY name"; |
| 904 |
|
$this->_menus =& $database->doSQLget($sql, 'mosMenu'); |
| 905 |
|
if (!$this->_menus) $this->_menus = array(); |
| 906 |
|
foreach ($this->_menus as $key=>$menu) { |
| 907 |
|
$this->_idlinks[$menu->id] = $key; |
| 908 |
|
if ($menu->published == 1) $this->_byParentOrder[$menu->parent][$menu->ordering][$menu->menutype] = $key; |
| 909 |
|
if (isset($this->_counts[$menu->menutype][$menu->published])) $this->_counts[$menu->menutype][$menu->published]++; |
| 910 |
|
else $this->_counts[$menu->menutype][$menu->published] = 1; |
| 911 |
|
} |
| 912 |
|
if ($this->_byParentOrder) { |
| 913 |
|
foreach ($this->_byParentOrder as $parent=>$outer) ksort($this->_byParentOrder[$parent]); |
| 914 |
|
ksort($this->_byParentOrder); |
| 915 |
|
} |
| 916 |
|
} |
| 917 |
|
/** |
| 918 |
|
* Singleton accessor |
| 919 |
|
*/ |
| 920 |
|
function &getInstance () { |
| 921 |
|
static $instance; |
| 922 |
|
if (!is_object($instance)) $instance = new mosMenuHandler(); |
| 923 |
|
return $instance; |
| 924 |
|
} |
| 925 |
|
|
| 926 |
|
function &getMenuByID ($id) { |
| 927 |
|
if (isset($this->_idlinks[$id])) { |
| 928 |
|
$key = $this->_idlinks[$id]; |
| 929 |
|
return $this->_menus[$key]; |
| 930 |
|
} |
| 931 |
|
$result = null; |
| 932 |
|
return $result; |
| 933 |
|
} |
| 934 |
|
|
| 935 |
|
function getMenuCount ($type, $published) { |
| 936 |
|
if (isset($this->_counts[$type][$published])) return $this->_counts[$type][$published]; |
| 937 |
|
else return 0; |
| 938 |
|
} |
| 939 |
|
|
| 940 |
|
function &getMenusByType ($types) { |
| 941 |
|
$checker = explode(',', $types); |
| 942 |
|
$result = null; |
| 943 |
|
foreach ($this->_menus as $menu) { |
| 944 |
|
if (in_array($menu->menutype, $checker)) $result[] = $menu; |
| 945 |
|
} |
| 946 |
|
return $result; |
| 947 |
|
} |
| 948 |
|
|
| 949 |
|
function getIDByTypeLink ($type, $link) { |
| 950 |
|
foreach ($this->_menus as $menu) { |
| 951 |
|
if ($menu->published == 1 AND ($type == '*' OR $menu->type == $type) AND $menu->link == $link) return $menu->id; |
| 952 |
|
} |
| 953 |
|
return null; |
| 954 |
|
} |
| 955 |
|
|
| 956 |
|
function getIDLikeLink ($link) { |
| 957 |
|
$exact = $this->getIdByTypeLink('*', $link); |
| 958 |
|
if ($exact !== null) return $exact; |
| 959 |
|
foreach ($this->_menus as $menu) { |
| 960 |
|
if ($menu->published == 1 AND strpos($menu->link,$link) === 0) return $menu->id; |
| 961 |
|
} |
| 962 |
|
return 0; |
| 963 |
|
} |
| 964 |
|
|
| 965 |
|
function getIDByTypeCid ($type, $componentid) { |
| 966 |
|
foreach ($this->_menus as $menu) { |
| 967 |
|
if ($menu->published == 1 AND $menu->type == $type AND $menu->componentid == $componentid) return $menu->id; |
| 968 |
|
} |
| 969 |
|
return null; |
| 970 |
|
} |
| 971 |
|
|
| 972 |
|
function getGlobalBlogSectionCount () { |
| 973 |
|
$count = 0; |
| 974 |
|
foreach ($this->_menus as $menu) { |
| 975 |
|
if ($menu->type == 'content_blog_section' AND $menu->published == 1 AND $menu->componentid == 0) $count++; |
| 976 |
|
} |
| 977 |
|
return $count; |
| 978 |
|
} |
| 979 |
|
|
| 980 |
|
function getContentItemid ($Itemid, $type, $id, $catid=0) { |
| 981 |
|
if ($Itemid) return $Itemid; |
| 982 |
|
foreach ($this->_menus as $menu) { |
| 983 |
|
if (strpos($menu->link,'index.php?option=com_content') === false AND strpos($menu->link,'index.php?option=content') === false) continue; |
| 984 |
|
if (strpos($menu->link, $type) === false) continue; |
| 985 |
|
if ($catid) { |
| 986 |
|
if (strpos($menu->link, "&id=$catid") === false) continue; |
| 987 |
|
if (strpos($menu->link, "§ionid=$id") === false) continue; |
| 988 |
|
} |
| 989 |
|
elseif (strpos($menu->link, "&id=$id") === false) continue; |
| 990 |
|
return $menu->id; |
| 991 |
|
} |
| 992 |
|
return 0; |
| 993 |
|
} |
| 994 |
|
|
| 995 |
|
function getBestQueryMatch () { |
| 996 |
|
parse_str($_SERVER['QUERY_STRING'], $qitems); |
| 997 |
|
if (!isset($qitems['option'])) return 0; |
| 998 |
|
$failures = 999; |
| 999 |
|
$best = 0; |
| 1000 |
|
foreach ($this->_menus as $menu) { |
| 1001 |
|
$split = explode('?', $menu->link); |
| 1002 |
|
if (isset($split[1])) parse_str($split[1], $mitems); |
| 1003 |
|
else continue; |
| 1004 |
|
if (!isset($mitems['option']) OR $mitems['option'] != $qitems['option']) continue; |
| 1005 |
|
$thisfail = 0; |
| 1006 |
|
foreach ($mitems as $key=>$mitem) if (!isset($qitems[$key]) OR $mitem != $qitems[$key]) $thisfail++; |
| 1007 |
|
if ($thisfail < $failures) { |
| 1008 |
|
$best = $menu->id; |
| 1009 |
|
$failures = $thisfail; |
| 1010 |
|
} |
| 1011 |
|
} |
| 1012 |
|
return $best; |
| 1013 |
|
} |
| 1014 |
|
|
| 1015 |
|
|
| 1016 |
|
function &maxAccessLink ($link) { |
| 1017 |
|
$selected = null; |
| 1018 |
|
$access = 0; |
| 1019 |
|
foreach ($this->_menus as $key=>$menu) { |
| 1020 |
|
if (strpos($menu->link,$link) === 0 AND $menu->access > $access) { |
| 1021 |
|
$access = $menu->access; |
| 1022 |
|
$selected =& $this->_menus[$key]; |
| 1023 |
|
} |
| 1024 |
|
} |
| 1025 |
|
return $selected; |
| 1026 |
|
} |
| 1027 |
|
|
| 1028 |
|
function &getByParentOrder ($Itemid, $menutype, $maxaccess=0, $noparent=false) { |
| 1029 |
|
$result = array(); |
| 1030 |
|
if ($this->_byParentOrder !== null) { |
| 1031 |
|
foreach ($this->_byParentOrder as $parent=>$outer) { |
| 1032 |
|
foreach ($outer as $ordering=>$inner) { |
| 1033 |
|
foreach ($inner as $mtype=>$last) { |
| 1034 |
|
$key = $this->_byParentOrder[$parent][$ordering][$mtype]; |
| 1035 |
|
$menu = $this->_menus[$key]; |
| 1036 |
|
if ($menutype AND $mtype != $menutype) continue; |
| 1037 |
|
if ($Itemid AND $Itemid != $menu->id) continue; |
| 1038 |
|
if ($maxaccess AND $menu->access > $maxaccess) continue; |
| 1039 |
|
if ($noparent AND $parent != 0) continue; |
| 1040 |
|
$result[] = $this->_menus[$key]; |
| 1041 |
|
} |
| 1042 |
|
} |
| 1043 |
|
} |
| 1044 |
|
} |
| 1045 |
|
return $result; |
| 1046 |
|
} |
| 1047 |
|
|
| 1048 |
|
function setPathway ($Itemid) { |
| 1049 |
|
if ($Itemid) { |
| 1050 |
|
$menu = $this->getMenuByID($Itemid); |
| 1051 |
|
if ($menu->parent) $this->setPathway($menu->parent); |
| 1052 |
|
$pathway = mosPathway::getInstance(); |
| 1053 |
|
$pathway->addItem($menu->name, $menu->link."&Itemid=$Itemid"); |
| 1054 |
|
} |
| 1055 |
|
} |
| 1056 |
|
|
| 1057 |
|
/** |
| 1058 |
|
* Checks whether a menu option is within the users access level |
| 1059 |
|
* @param int Item id number |
| 1060 |
|
* @param string The menu option |
| 1061 |
|
* @param int The users group ID number |
| 1062 |
|
* @param database A database connector object |
| 1063 |
|
* @return boolean True if the visitor's group at least equal to the menu access |
| 1064 |
|
*/ |
| 1065 |
|
function menuCheck( $Itemid, $menu_option, $task, $gid ) { |
| 1066 |
|
$exceptions = array ('com_banner', 'com_poll', 'com_registration', 'com_rss'); |
| 1067 |
|
if (in_array($menu_option, $exceptions)) return true; |
| 1068 |
|
$dblink="index.php?option=$menu_option"; |
| 1069 |
|
if ($Itemid) { |
| 1070 |
|
$menu = $this->getMenuByID($Itemid); |
| 1071 |
|
if (strpos($menu->link,$dblink) ===0) $access = $menu->access; |
| 1072 |
|
} |
| 1073 |
|
if (!isset($access)) { |
| 1074 |
|
if ($task!='') $dblink .= "&task=$task"; |
| 1075 |
|
$menu = $this->maxAccessLink($dblink); |
| 1076 |
|
if (isset($menu)) { |
| 1077 |
|
$access = $menu->access; |
| 1078 |
|
mamboCore::set('Itemid', $menu->id); |
| 1079 |
|
} |
| 1080 |
|
} |
| 1081 |
|
return isset($access) ? $access <= $gid : false; |
| 1082 |
|
} |
| 1083 |
|
|
| 1084 |
|
function mosGetMenuLink( &$mitem, $level=0, &$params, $Itemid ) { |
| 1085 |
|
$txt = ''; |
| 1086 |
|
|
| 1087 |
|
switch ($mitem->type) { |
| 1088 |
|
case 'separator': |
| 1089 |
|
case 'component_item_link': |
| 1090 |
|
break; |
| 1091 |
|
case 'content_item_link': |
| 1092 |
|
$temp = split("&task=view&id=", $mitem->link); |
| 1093 |
|
if (isset($temp[1])) { |
| 1094 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 1095 |
|
$handler = contentHandler::getInstance(); |
| 1096 |
|
$mitem->link .= '&Itemid='.$handler->getItemid($temp[1]); |
| 1097 |
|
} |
| 1098 |
|
break; |
| 1099 |
|
case 'url': |
| 1100 |
|
$link = strtolower($mitem->link); |
| 1101 |
|
if (substr($link,0,10) == 'index.php?' AND strpos($link,'itemid=') === false) $mitem->link .= '&Itemid='. $mitem->id; |
| 1102 |
|
break; |
| 1103 |
|
case 'content_typed': |
| 1104 |
|
default: |
| 1105 |
|
$mitem->link .= '&Itemid='.$mitem->id; |
| 1106 |
|
break; |
| 1107 |
|
} |
| 1108 |
|
// Active Menu highlighting |
| 1109 |
|
if ( $Itemid == $mitem->id ) $id = 'id="active_menu'.$params->get( 'class_sfx' ).'"'; |
| 1110 |
|
else $id = ''; |
| 1111 |
|
$mitem->link = ampReplace( $mitem->link ); |
| 1112 |
|
if (strcasecmp(substr($mitem->link,0,4), 'http')) $mitem->link = sefRelToAbs( $mitem->link ); |
| 1113 |
|
if ($level > 0) $menuclass = 'sublevel'; |
| 1114 |
|
else $menuclass = 'mainlevel'; |
| 1115 |
|
$menuclass .= $params->get( 'class_sfx'); |
| 1116 |
|
|
| 1117 |
|
switch ($mitem->browserNav) { |
| 1118 |
|
// cases are slightly different |
| 1119 |
|
case 1: |
| 1120 |
|
// open in a new window |
| 1121 |
|
$txt = '<a href="'. $mitem->link .'" target="_blank" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>'; |
| 1122 |
|
break; |
| 1123 |
|
|
| 1124 |
|
case 2: |
| 1125 |
|
// open in a popup window |
| 1126 |
|
$txt = "<a href=\"#\" onclick=\"javascript: window.open('". $mitem->link ."', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\" class=\"$menuclass\" ". $id .">". $mitem->name ."</a>\n"; |
| 1127 |
|
break; |
| 1128 |
|
|
| 1129 |
|
case 3: |
| 1130 |
|
// don't link it |
| 1131 |
|
$txt = '<span class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</span>'; |
| 1132 |
|
break; |
| 1133 |
|
|
| 1134 |
|
default: // formerly case 2 |
| 1135 |
|
// open in parent window |
| 1136 |
|
$txt = '<a href="'. $mitem->link .'" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>'; |
| 1137 |
|
break; |
| 1138 |
|
} |
| 1139 |
|
|
| 1140 |
|
if ( $params->get( 'menu_images' ) ) { |
| 1141 |
|
$menu_params =& new mosParameters( $mitem->params ); |
| 1142 |
|
$menu_image = $menu_params->def( 'menu_image', -1 ); |
| 1143 |
|
if ($menu_image AND $menu_image <> '-1') { |
| 1144 |
|
$image = '<img src="'. mamboCore::get('mosConfig_live_site') .'/images/stories/'. $menu_image .'" border="0" alt="'. $mitem->name .'"/>'; |
| 1145 |
|
if ( $params->get('menu_images_align')) $txt = $txt .' '. $image; |
| 1146 |
|
else $txt = $image .' '. $txt; |
| 1147 |
|
} |
| 1148 |
|
} |
| 1149 |
|
return $txt; |
| 1150 |
|
} |
| 1151 |
|
|
| 1152 |
|
/** |
| 1153 |
|
* Vertically Indented Menu |
| 1154 |
|
*/ |
| 1155 |
|
function mosShowVIMenu( &$params ) { |
| 1156 |
|
global $my, $cur_template, $Itemid; |
| 1157 |
|
|
| 1158 |
|
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
| 1159 |
|
else $maxaccess = $my->gid; |
| 1160 |
|
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess); |
| 1161 |
|
foreach ($rows as $i=>$row) $crosslink[$row->id] = $i; |
| 1162 |
|
// indent icons |
| 1163 |
|
$base = mamboCore::get('mosConfig_live_site'); |
| 1164 |
|
switch ( $params->get( 'indent_image' ) ) { |
| 1165 |
|
case '1': |
| 1166 |
|
// Default images |
| 1167 |
|
for ( $i = 1; $i < 7; $i++ ) { |
| 1168 |
|
$img[$i] = "<img src=\"$base/images/M_images/indent$i.png\" alt=\"indent$i\" />"; |
| 1169 |
|
} |
| 1170 |
|
break; |
| 1171 |
|
case '2': |
| 1172 |
|
// Use Params |
| 1173 |
|
for ( $i = 1; $i < 7; $i++ ) { |
| 1174 |
|
$parm = $params->get('indent_image'. $i); |
| 1175 |
|
if ($parm == '-1' ) $img[$i] = NULL; |
| 1176 |
|
else $img[$i] = "<img src=\"$base/images/M_images/$parm\" alt=\"indent$i\" />"; |
| 1177 |
|
} |
| 1178 |
|
break; |
| 1179 |
|
case '3': |
| 1180 |
|
// None |
| 1181 |
|
for ( $i = 1; $i < 7; $i++ ) $img[$i] = NULL; |
| 1182 |
|
break; |
| 1183 |
|
default: |
| 1184 |
|
// Template |
| 1185 |
|
$imgpath = $base.'/templates/'. $cur_template .'/images'; |
| 1186 |
|
for ( $i = 1; $i < 7; $i++ ) { |
| 1187 |
|
$img[$i] = "<img src=\"$base/templates/$cur_template/images/indent$i.png\" alt=\"indent$i\" />"; |
| 1188 |
|
} |
| 1189 |
|
break; |
| 1190 |
|
} |
| 1191 |
|
|
| 1192 |
|
$indents = array( |
| 1193 |
|
// block prefix / item prefix / item suffix / block suffix |
| 1194 |
|
array( '<table width="100%" border="0" cellpadding="0" cellspacing="0">', '<tr align="left"><td>' , '</td></tr>', '</table>' ), |
| 1195 |
|
array( '', '<div style="padding-left: 4px">'. $img[1] , '</div>', '' ), |
| 1196 |
|
array( '', '<div style="padding-left: 8px">'. $img[2] , '</div>', '' ), |
| 1197 |
|
array( '', '<div style="padding-left: 12px">'. $img[3] , '</div>', '' ), |
| 1198 |
|
array( '', '<div style="padding-left: 16px">'. $img[4] , '</div>', '' ), |
| 1199 |
|
array( '', '<div style="padding-left: 20px">'. $img[5] , '</div>', '' ), |
| 1200 |
|
array( '', '<div style="padding-left: 24px">'. $img[6] , '</div>', '' ), |
| 1201 |
|
); |
| 1202 |
|
|
| 1203 |
|
// establish the hierarchy of the menu |
| 1204 |
|
$children = array(); |
| 1205 |
|
// first pass - collect children |
| 1206 |
|
foreach ($rows as $v ) $children[$v->parent][] = $v; |
| 1207 |
|
// second pass - collect 'open' menus |
| 1208 |
|
$open = array( $Itemid ); |
| 1209 |
|
for ($i = 0; $i < 20 AND isset($crosslink[$open[$i]]) AND isset($rows[$crosslink[$open[$i]]]); $i++) { |
| 1210 |
|
$next = $rows[$crosslink[$open[$i]]]->parent; |
| 1211 |
|
if ($next) $open[$i+1] = $next; |
| 1212 |
|
else break; |
| 1213 |
|
} |
| 1214 |
|
|
| 1215 |
|
$this->mosRecurseVIMenu( 0, 0, $children, $open, $indents, $params ); |
| 1216 |
|
|
| 1217 |
|
} |
| 1218 |
|
|
| 1219 |
|
/** |
| 1220 |
|
* Utility function to recursively work through a vertically indented |
| 1221 |
|
* hierarchial menu |
| 1222 |
|
*/ |
| 1223 |
|
function mosRecurseVIMenu( $id, $level, &$children, &$open, &$indents, &$params ) { |
| 1224 |
|
global $Itemid; |
| 1225 |
|
if (@$children[$id]) { |
| 1226 |
|
$n = min( $level, count($indents )-1); |
| 1227 |
|
echo "\n".$indents[$n][0]; |
| 1228 |
|
foreach ($children[$id] as $row) { |
| 1229 |
|
echo "\n".$indents[$n][1]; |
| 1230 |
|
echo $this->mosGetMenuLink( $row, $level, $params, $Itemid ); |
| 1231 |
|
// show menu with menu expanded - submenus visible |
| 1232 |
|
if ($params->get('expand_menu') OR in_array($row->id, $open)) $this->mosRecurseVIMenu( $row->id, $level+1, $children, $open, $indents, $params ); |
| 1233 |
|
echo $indents[$n][2]; |
| 1234 |
|
} |
| 1235 |
|
echo "\n".$indents[$n][3]; |
| 1236 |
|
} |
| 1237 |
|
} |
| 1238 |
|
|
| 1239 |
|
/** |
| 1240 |
|
* Draws a horizontal 'flat' style menu (very simple case) |
| 1241 |
|
*/ |
| 1242 |
|
function mosShowHFMenu( &$params, $style=0 ) { |
| 1243 |
|
global $my, $cur_template, $Itemid; |
| 1244 |
|
|
| 1245 |
|
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
| 1246 |
|
else $maxaccess = $my->gid; |
| 1247 |
|
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess, true); |
| 1248 |
|
|
| 1249 |
|
$links = array(); |
| 1250 |
|
foreach ($rows as $row) $links[] = $this->mosGetMenuLink( $row, 0, $params, $Itemid ); |
| 1251 |
|
$menuclass = 'mainlevel'. $params->get( 'class_sfx' ); |
| 1252 |
|
if (count( $links )) { |
| 1253 |
|
if ($style == 1) { |
| 1254 |
|
echo '<ul id="'. $menuclass .'">'; |
| 1255 |
|
foreach ($links as $link) echo '<li>' . $link . '</li>'; |
| 1256 |
|
echo '</ul>'; |
| 1257 |
|
} |
| 1258 |
|
else { |
| 1259 |
|
echo '<table width="100%" border="0" cellpadding="0" cellspacing="1">'; |
| 1260 |
|
echo '<tr>'; |
| 1261 |
|
echo '<td nowrap="nowrap">'; |
| 1262 |
|
echo '<span class="'. $menuclass .'"> '. $params->get( 'end_spacer' ) .' </span>'; |
| 1263 |
|
echo implode( '<span class="'. $menuclass .'"> '. $params->get( 'spacer' ) .' </span>', $links ); |
| 1264 |
|
echo '<span class="'. $menuclass .'"> '. $params->get( 'end_spacer' ) .' </span>'; |
| 1265 |
|
echo '</td></tr>'; |
| 1266 |
|
echo '</table>'; |
| 1267 |
|
} |
| 1268 |
|
} |
| 1269 |
|
} |
| 1270 |
|
} |
| 1271 |
|
|
| 1272 |
|
/** |
| 1273 |
|
* Plugin handler |
| 1274 |
|
* @package Mambo |
| 1275 |
|
*/ |
| 1276 |
|
class mosMambotHandler { |
| 1277 |
|
/** @var array An array of functions in event groups */ |
| 1278 |
|
var $_events=null; |
| 1279 |
|
/** @var array An array of lists */ |
| 1280 |
|
var $_lists=null; |
| 1281 |
|
/** @var array An array of mambots */ |
| 1282 |
|
var $_bots=null; |
| 1283 |
|
/** @var array An array of bools showing if corresponding bot is registered */ |
| 1284 |
|
var $_registered=array(); |
| 1285 |
|
/** @var int Index of the mambot being loaded */ |
| 1286 |
|
var $_loading=null; |
| 1287 |
|
|
| 1288 |
|
/** |
| 1289 |
|
* Constructor |
| 1290 |
|
*/ |
| 1291 |
|
function mosMambotHandler() { |
| 1292 |
|
$my = mamboCore::is_set('currentUser') ? mamboCore::get('currentUser') : null; |
| 1293 |
|
$gid = $my ? $my->gid : 0; |
| 1294 |
|
$this->_events = array(); |
| 1295 |
|
$database = mamboDatabase::getInstance(); |
| 1296 |
|
$database->setQuery( "SELECT folder, element, published, params, CONCAT_WS('/',folder,element) AS lookup" |
| 1297 |
|
. "\nFROM #__mambots" |
| 1298 |
|
. "\nWHERE published >= 1 AND access <= $gid" |
| 1299 |
|
. "\nORDER BY ordering" |
| 1300 |
|
); |
| 1301 |
|
$this->_bots = $database->loadObjectList(); |
| 1302 |
|
if (!$this->_bots) $this->_bots = array(); |
| 1303 |
|
} |
| 1304 |
|
/** |
| 1305 |
|
* Singleton accessor |
| 1306 |
|
*/ |
| 1307 |
|
function &getInstance () { |
| 1308 |
|
static $instance; |
| 1309 |
|
if (!is_object($instance)) $instance = new mosMambotHandler(); |
| 1310 |
|
return $instance; |
| 1311 |
|
} |
| 1312 |
|
/** |
| 1313 |
|
* Loads all the bot files for a particular group |
| 1314 |
|
* @param string The group name, relates to the sub-directory in the mambots directory |
| 1315 |
|
*/ |
| 1316 |
|
function loadBotGroup( $group ) { |
| 1317 |
|
global $_MAMBOTS; |
| 1318 |
|
$group = trim( $group ); |
| 1319 |
|
$total = 0; |
| 1320 |
|
$basepath = mamboCore::get('mosConfig_absolute_path'); |
| 1321 |
|
foreach ($this->_bots as $i=>$bot) { |
| 1322 |
|
if ($bot->folder != $group OR isset($this->_registered[$i])) continue; |
| 1323 |
|
$path = "$basepath/mambots/$bot->folder/$bot->element.php"; |
| 1324 |
|
if (file_exists( $path )) { |
| 1325 |
|
$this->_loading = $i; |
| 1326 |
|
require_once( $path ); |
| 1327 |
|
if (!isset($this->_registered[$i])) { |
| 1328 |
|
$botclass = str_replace('.','_',$bot->element); |
| 1329 |
|
$newbot = new $botclass(); |
| 1330 |
|
$function = array ($newbot, 'perform'); |
| 1331 |
|
$selected = $newbot->register(); |
| 1332 |
|
if (is_array($selected)) foreach ($selected as $select) $this->_events[$select][] = array($function, $i); |
| 1333 |
|
else $this->_events[$selected][] = array ($function, $i); |
| 1334 |
|
$this->_registered[$i] = true; |
| 1335 |
|
} |
| 1336 |
|
$total++; |
| 1337 |
|
} |
| 1338 |
|
} |
| 1339 |
|
$this->_loading = null; |
| 1340 |
|
if ($total) return true; |
| 1341 |
|
return false; |
| 1342 |
|
} |
| 1343 |
|
/** |
| 1344 |
|
* Registers a function to a particular event group |
| 1345 |
|
* @param string The event name |
| 1346 |
|
* @param string The function name |
| 1347 |
|
*/ |
| 1348 |
|
function registerFunction( $event, $function ) { |
| 1349 |
|
$this->_events[$event][] = array( $function, $this->_loading ); |
| 1350 |
|
$this->_registered[$this->_loading] = true; |
| 1351 |
|
} |
| 1352 |
|
/** |
| 1353 |
|
* Makes a option for a particular list in a group |
| 1354 |
|
* @param string The group name |
| 1355 |
|
* @param string The list name |
| 1356 |
|
* @param string The value for the list option |
| 1357 |
|
* @param string The text for the list option |
| 1358 |
|
*/ |
| 1359 |
|
function addListOption( $group, $listName, $value, $text='' ) { |
| 1360 |
|
$this->_lists[$group][$listName][] = mosHTML::makeOption( $value, $text ); |
| 1361 |
|
} |
| 1362 |
|
/** |
| 1363 |
|
* @param string The group name |
| 1364 |
|
* @param string The list name |
| 1365 |
|
* @return array |
| 1366 |
|
*/ |
| 1367 |
|
function getList( $group, $listName ) { |
| 1368 |
|
return $this->_lists[$group][$listName]; |
| 1369 |
|
} |
| 1370 |
|
/** |
| 1371 |
|
* Calls all functions according to passed parameters |
| 1372 |
|
* @param string The event name |
| 1373 |
|
* @param array An array of arguments |
| 1374 |
|
* @param boolean True is unpublished bots are to be processed |
| 1375 |
|
* @return array An array of results from each function call |
| 1376 |
|
*/ |
| 1377 |
|
function &_runBots ($event, $args, $doUnpublished=false) { |
| 1378 |
|
$result = array(); |
| 1379 |
|
if (isset( $this->_events[$event] )) { |
| 1380 |
|
foreach ($this->_events[$event] as $func) { |
| 1381 |
|
if (is_callable( $func[0] )) { |
| 1382 |
|
$botparams = $this->_bots[$func[1]]->params; |
| 1383 |
|
$args[] = new mosParameters($botparams); |
| 1384 |
|
$args[] = $event; |
| 1385 |
|
if ($doUnpublished) { |
| 1386 |
|
$args[0] = $this->_bots[$func[1]]->published; |
| 1387 |
|
$result[] = call_user_func_array( $func[0], $args ); |
| 1388 |
|
} else if ($this->_bots[$func[1]]->published) { |
| 1389 |
|
$result[] = call_user_func_array( $func[0], $args ); |
| 1390 |
|
} |
| 1391 |
|
} |
| 1392 |
|
} |
| 1393 |
|
} |
| 1394 |
|
return $result; |
| 1395 |
|
} |
| 1396 |
|
/** |
| 1397 |
|
* Calls all functions associated with an event group |
| 1398 |
|
* @param string The event name |
| 1399 |
|
* @param array An array of arguments |
| 1400 |
|
* @param boolean True is unpublished bots are to be processed |
| 1401 |
|
* @return array An array of results from each function call |
| 1402 |
|
*/ |
| 1403 |
|
function trigger( $event, $args=null, $doUnpublished=false ) { |
| 1404 |
|
if ($args === null) $args = array(); |
| 1405 |
|
// prepend the published argument |
| 1406 |
|
if ($doUnpublished) array_unshift( $args, null ); |
| 1407 |
|
$result =& $this->_runBots($event, $args, $doUnpublished); |
| 1408 |
|
return $result; |
| 1409 |
|
} |
| 1410 |
|
/** |
| 1411 |
|
* Same as trigger but only returns the first event and |
| 1412 |
|
* allows for a variable argument list |
| 1413 |
|
* @param string The event name |
| 1414 |
|
* @return array The result of the first function call |
| 1415 |
|
*/ |
| 1416 |
|
function call( $event ) { |
| 1417 |
|
$args =& func_get_args(); |
| 1418 |
|
array_shift( $args ); |
| 1419 |
|
$result =& $this->_runBots($event, $args); |
| 1420 |
|
if (isset($result[0])) return $result[0]; |
| 1421 |
|
return null; |
| 1422 |
|
} |
| 1423 |
|
} |
| 1424 |
|
|
| 1425 |
|
/** |
| 1426 |
|
* Users Table Class |
| 1427 |
|
* |
| 1428 |
|
* Provides access to the mos_templates table |
| 1429 |
|
* @package Mambo |
| 1430 |
|
*/ |
| 1431 |
|
class mosUser extends mosDBTable { |
| 1432 |
|
/** @var int Unique id*/ |
| 1433 |
|
var $id=null; |
| 1434 |
|
/** @var string The users real name (or nickname)*/ |
| 1435 |
|
var $name=null; |
| 1436 |
|
/** @var string The login name*/ |
| 1437 |
|
var $username=null; |
| 1438 |
|
/** @var string email*/ |
| 1439 |
|
var $email=null; |
| 1440 |
|
/** @var string MD5 encrypted password*/ |
| 1441 |
|
var $password=null; |
| 1442 |
|
/** @var string */ |
| 1443 |
|
var $usertype=null; |
| 1444 |
|
/** @var int */ |
| 1445 |
|
var $block=null; |
| 1446 |
|
/** @var int */ |
| 1447 |
|
var $sendEmail=null; |
| 1448 |
|
/** @var int The group id number */ |
| 1449 |
|
var $gid=null; |
| 1450 |
|
/** @var datetime */ |
| 1451 |
|
var $registerDate=null; |
| 1452 |
|
/** @var datetime */ |
| 1453 |
|
var $lastvisitDate=null; |
| 1454 |
|
/** @var string activation hash*/ |
| 1455 |
|
var $activation=null; |
| 1456 |
|
/** @var string */ |
| 1457 |
|
var $params=null; |
| 1458 |
|
|
| 1459 |
|
/** |
| 1460 |
|
* @param database A database connector object |
| 1461 |
|
*/ |
| 1462 |
|
function mosUser( $dummy ) { |
| 1463 |
|
$database = mamboDatabase::getInstance(); |
| 1464 |
|
$this->mosDBTable( '#__users', 'id', $database ); |
| 1465 |
|
} |
| 1466 |
|
|
| 1467 |
|
/** |
| 1468 |
|
* Fill a user object with information from the current session |
| 1469 |
|
*/ |
| 1470 |
|
function getSessionData() { |
| 1471 |
|
$session = mosSession::getCurrent(); |
| 1472 |
|
$this->id = intval( $session->userid ); |
| 1473 |
|
$this->username = $session->username; |
| 1474 |
|
$this->usertype = $session->usertype; |
| 1475 |
|
$this->gid = intval( $session->gid ); |
| 1476 |
|
} |
| 1477 |
|
/** |
| 1478 |
|
* Validation and filtering |
| 1479 |
|
* @return boolean True is satisfactory |
| 1480 |
|
*/ |
| 1481 |
|
function check() { |
| 1482 |
|
$this->_error = ''; |
| 1483 |
|
if ($this->name == '') $this->_error = _REGWARN_NAME; |
| 1484 |
|
elseif ($this->username == '') $this->_error = _REGWARN_UNAME; |
| 1485 |
|
elseif (strlen($this->username) < 3 OR preg_match("/[\\<\\>\\\"\\'\\%\\;\\(\\)\\&\\+\\-]/", $this->username)) $this->_error = sprintf( _VALID_AZ09, _PROMPT_UNAME, 2 ); |
| 1486 |
|
elseif (($this->email == '') OR preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email ) == 0) $this->_error = _REGWARN_MAIL; |
| 1487 |
|
else { |
| 1488 |
|
// check for existing username |
| 1489 |
|
$username = strtolower($this->username); |
| 1490 |
|
$this->_db->setQuery( "SELECT COUNT(id) FROM #__users " |
| 1491 |
|
. "\nWHERE LOWER(username)='$username' AND id!='$this->id'" |
| 1492 |
|
); |
| 1493 |
|
if ($this->_db->loadResult()) $this->_error = _REGWARN_INUSE; |
| 1494 |
|
elseif (mamboCore::get('mosConfig_uniquemail')) { |
| 1495 |
|
// check for existing email |
| 1496 |
|
$this->_db->setQuery( "SELECT COUNT(id) FROM #__users " |
| 1497 |
|
. "\nWHERE email='$this->email' AND id!='$this->id'" |
| 1498 |
|
); |
| 1499 |
|
if ($this->_db->loadResult()) $this->_error = _REGWARN_EMAIL_INUSE; |
| 1500 |
|
} |
| 1501 |
|
} |
| 1502 |
|
if ($this->_error) return false; |
| 1503 |
|
return true; |
| 1504 |
|
} |
| 1505 |
|
|
| 1506 |
|
function store( $updateNulls=false ) { |
| 1507 |
|
global $acl, $migrate; |
| 1508 |
|
$section_value = 'users'; |
| 1509 |
|
if( $this->id AND !$migrate) { |
| 1510 |
|
// update existing record |
| 1511 |
|
$ret = $this->_db->updateObject( $this->_tbl, $this, 'id', $updateNulls ); |
| 1512 |
|
// syncronise ACL |
| 1513 |
|
// single group handled at the moment |
| 1514 |
|
// trivial to expand to multiple groups |
| 1515 |
|
$groups = $acl->get_object_groups( $section_value, $this->id, 'ARO' ); |
| 1516 |
|
$acl->del_group_object( $groups[0], $section_value, $this->id, 'ARO' ); |
| 1517 |
|
$acl->add_group_object( $this->gid, $section_value, $this->id, 'ARO' ); |
| 1518 |
|
$object_id = $acl->get_object_id( $section_value, $this->id, 'ARO' ); |
| 1519 |
|
$acl->edit_object( $object_id, $section_value, $this->_db->getEscaped( $this->name ), $this->id, 0, 0, 'ARO' ); |
| 1520 |
|
} |
| 1521 |
|
else { |
| 1522 |
|
// new record |
| 1523 |
|
$ret = $this->_db->insertObject( $this->_tbl, $this, 'id' ); |
| 1524 |
|
// syncronise ACL |
| 1525 |
|
$acl->add_object( $section_value, $this->_db->getEscaped( $this->name ), $this->id, null, null, 'ARO' ); |
| 1526 |
|
$acl->add_group_object( $this->gid, $section_value, $this->id, 'ARO' ); |
| 1527 |
|
} |
| 1528 |
|
if ($ret) return true; |
| 1529 |
|
$this->_error = "mosUser::store failed <br />" . $this->_db->getErrorMsg(); |
| 1530 |
|
return false; |
| 1531 |
|
} |
| 1532 |
|
|
| 1533 |
|
function delete($oid=null) { |
| 1534 |
|
|
| 1535 |
|
if ($oid) $this->id = intval( $oid ); |
| 1536 |
|
$aro_id = $acl->get_object_id( 'users', $this->$k, 'ARO' ); |
| 1537 |
|
$acl->del_object( $aro_id, 'ARO', true ); |
| 1538 |
|
// $authoriser = mosAuthorisationAdmin::getInstance(); |
| 1539 |
|
// $authoriser->dropAccess('mosUser', $this->id); |
| 1540 |
|
$this->_error = ''; |
| 1541 |
|
$this->_db->setQuery( "DELETE FROM $this->_tbl WHERE id = '".$this->id."'" ); |
| 1542 |
|
if ($this->_db->query()) { |
| 1543 |
|
// cleanup related data |
| 1544 |
|
|
| 1545 |
|
// :: private messaging |
| 1546 |
|
$this->_db->setQuery( "DELETE FROM #__messages_cfg WHERE user_id='".$this->id."'" ); |
| 1547 |
|
if (!$this->_db->query()) $this->_error = $this->_db->getErrorMsg(); |
| 1548 |
|
else { |
| 1549 |
|
$this->_db->setQuery( "DELETE FROM #__messages WHERE user_id_to='".$this->$k."'" ); |
| 1550 |
|
if (!$this->_db->query()) $this->_error = $this->_db->getErrorMsg(); |
| 1551 |
|
} |
| 1552 |
|
} else $this->_error = $this->_db->getErrorMsg(); |
| 1553 |
|
if ($this->_error) return false; |
| 1554 |
|
return true; |
| 1555 |
|
} |
| 1556 |
|
} |
| 1557 |
|
|
| 1558 |
|
/** |
| 1559 |
|
* User login details class |
| 1560 |
|
* @package Mambo |
| 1561 |
|
*/ |
| 1562 |
|
class mosLoginDetails { |
| 1563 |
|
var $_user = ''; |
| 1564 |
|
var $_password = ''; |
| 1565 |
|
var $_remember = ''; |
| 1566 |
|
|
| 1567 |
// checks for configuration file, if none found loads installation page |
function mosLoginDetails ($user, $password='', $remember='') { |
| 1568 |
if ( !file_exists( 'configuration.php' ) || filesize( 'configuration.php' ) < 10 ) { |
$this->_user = $user; |
| 1569 |
header( 'Location: installation/index.php' ); |
$this->_password = $password; |
| 1570 |
exit(); |
$this->_remember = $remember; |
| 1571 |
} |
} |
| 1572 |
|
|
| 1573 |
include_once( 'globals.php' ); |
function getUser () { |
| 1574 |
require_once( 'configuration.php' ); |
return $this->_user; |
| 1575 |
|
} |
| 1576 |
|
|
| 1577 |
// displays offline page |
function getPassword () { |
| 1578 |
if ( $mosConfig_offline == 1 ){ |
return $this->_password; |
|
include( 'offline.php' ); |
|
|
exit(); |
|
| 1579 |
} |
} |
| 1580 |
|
|
| 1581 |
require_once( 'includes/mambo.php' ); |
function getRemember () { |
| 1582 |
if (file_exists( 'components/com_sef/sef.php' )) { |
return $this->_remember; |
|
require_once( 'components/com_sef/sef.php' ); |
|
|
} else { |
|
|
require_once( 'includes/sef.php' ); |
|
| 1583 |
} |
} |
|
require_once( 'includes/frontend.php' ); |
|
| 1584 |
|
|
|
/* |
|
|
Installation sub folder check, removed for work with CVS*/ |
|
|
if (file_exists( 'installation/index.php' )) { |
|
|
include ('offline.php'); |
|
|
exit(); |
|
| 1585 |
} |
} |
| 1586 |
/**/ |
/** |
| 1587 |
/** retrieve some expected url (or form) arguments */ |
* Mambo Mainframe class |
| 1588 |
$option = trim( strtolower( mosGetParam( $_REQUEST, 'option' ) ) ); |
* |
| 1589 |
$Itemid = intval( mosGetParam( $_REQUEST, 'Itemid', null ) ); |
* Provide many supporting API functions |
| 1590 |
$database = new database( $mosConfig_host, $mosConfig_user, $mosConfig_password, $mosConfig_db, $mosConfig_dbprefix ); |
* @package Mambo |
| 1591 |
$database->debug( $mosConfig_debug ); |
*/ |
| 1592 |
$acl = new gacl_api(); |
class mosMainFrame { |
| 1593 |
|
/** @var database Internal database class pointer */ |
| 1594 |
|
var $_db=null; |
| 1595 |
|
/** @var object A default option (e.g. component) */ |
| 1596 |
|
var $_option=null; |
| 1597 |
|
/** @var string The current template */ |
| 1598 |
|
var $_template=null; |
| 1599 |
|
/** @var array An array to hold global user state within a session */ |
| 1600 |
|
var $_userstate=null; |
| 1601 |
|
/** @var array An array of page meta information */ |
| 1602 |
|
var $_head=null; |
| 1603 |
|
/** @var string Custom html string to append to the pathway */ |
| 1604 |
|
var $_custom_pathway=array(); |
| 1605 |
|
|
| 1606 |
if ($option == '') { |
/** |
| 1607 |
if ($Itemid) { |
* Class constructor |
| 1608 |
$query = "SELECT id, link" |
* @param database A database connection object |
| 1609 |
. "\n FROM #__menu" |
* @param string The url option |
| 1610 |
. "\n WHERE menutype='mainmenu'" |
* @param string The path of the mos directory |
| 1611 |
. "\n AND id = '$Itemid'" |
*/ |
| 1612 |
. "\n AND published = '1'" |
function mosMainFrame( &$db, $option, $basePath, $isAdmin=false ) { |
| 1613 |
; |
$this->_db =& $db; |
| 1614 |
$database->setQuery( $query ); |
// load the configuration values |
| 1615 |
} else { |
//return( $this->loadConfig() ); |
| 1616 |
$query = "SELECT id, link" |
$this->_setTemplate($isAdmin); |
| 1617 |
. "\n FROM #__menu" |
if (substr($option,0,4) != 'com_') $this->_option = "com_$option"; |
| 1618 |
. "\n WHERE menutype='mainmenu' AND published='1'" |
else $this->_option = $option; |
| 1619 |
. "\n ORDER BY parent, ordering LIMIT 1" |
if (isset( $_SESSION['session_userstate'] )) $this->_userstate =& $_SESSION['session_userstate']; |
| 1620 |
; |
else $this->_userstate = null; |
| 1621 |
$database->setQuery( $query ); |
$this->_head['title'] = $GLOBALS['mosConfig_sitename']; |
| 1622 |
} |
$this->_head['meta'] = array(); |
| 1623 |
$menu = new mosMenu( $database ); |
$this->_head['custom'] = array(); |
| 1624 |
if ($database->loadObject( $menu )) { |
mosMainFrame::getInstance($this); |
|
$Itemid = $menu->id; |
|
|
} |
|
|
$link = $menu->link; |
|
|
if (($pos = strpos( $link, '?' )) !== false) { |
|
|
$link = substr( $link, $pos+1 ). '&Itemid='.$Itemid; |
|
| 1625 |
} |
} |
| 1626 |
parse_str( $link, $temp ); |
|
| 1627 |
/** this is a patch, need to rework when globals are handled better */ |
/** |
| 1628 |
foreach ($temp as $k=>$v) { |
* Get the current user - deprecated - use mamboCore instead |
| 1629 |
$GLOBALS[$k] = $v; |
*/ |
| 1630 |
$_REQUEST[$k] = $v; |
function getUser() { |
| 1631 |
if ($k == 'option') { |
return mamboCore::get('currentUser'); |
| 1632 |
$option = $v; |
} |
| 1633 |
|
|
| 1634 |
|
/** |
| 1635 |
|
* Singleton get instance |
| 1636 |
|
* @param object the mainframe instance (if called internally) |
| 1637 |
|
* Note that because of the need for creation parameters, this cannot |
| 1638 |
|
* be called successfully unless the mainframe object is already created |
| 1639 |
|
*/ |
| 1640 |
|
function &getInstance () { |
| 1641 |
|
static $mainframe; |
| 1642 |
|
if (func_num_args()) { |
| 1643 |
|
$args = func_get_args(); |
| 1644 |
|
$mainframe = $args[0]; |
| 1645 |
|
} |
| 1646 |
|
if (isset($mainframe)) $result =& $mainframe; |
| 1647 |
|
else $result = null; |
| 1648 |
|
return $result; |
| 1649 |
|
} |
| 1650 |
|
/** |
| 1651 |
|
* @param string |
| 1652 |
|
*/ |
| 1653 |
|
function setPageTitle( $title=null ) { |
| 1654 |
|
if (mamboCore::get('mosConfig_pagetitles')) { |
| 1655 |
|
$title = trim(htmlspecialchars($title)); |
| 1656 |
|
$base = mamboCore::get('mosConfig_sitename'); |
| 1657 |
|
$this->_head['title'] = $title ? $title.' - '.$base : $base; |
| 1658 |
} |
} |
| 1659 |
} |
} |
| 1660 |
|
/** |
| 1661 |
|
* @return string |
| 1662 |
|
*/ |
| 1663 |
|
function getPageTitle() { |
| 1664 |
|
return $this->_head['title']; |
| 1665 |
} |
} |
| 1666 |
|
|
| 1667 |
/** mainframe is an API workhorse, lots of 'core' interaction routines */ |
/** |
| 1668 |
$mainframe = new mosMainFrame( $database, $option, '.' ); |
* @param string The value of the name attibute |
| 1669 |
$mainframe->initSession(); |
* @param string The value of the content attibute |
| 1670 |
|
* @param string Text to display before the tag |
| 1671 |
// checking if we can find the Itemid thru the content |
* @param string Text to display after the tag |
| 1672 |
if ( $option == 'com_content' && $Itemid === 0 ) { |
*/ |
| 1673 |
$id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); |
function addMetaTag( $name, $content, $prepend='', $append='' ) { |
| 1674 |
$Itemid = $mainframe->getItemid( $id ); |
list($name, $content) = $this->_tidyMetaData($name, $content); |
| 1675 |
} |
$prepend = trim($prepend); |
| 1676 |
|
$append = trim($append); |
| 1677 |
/** do we have a valid Itemid yet?? */ |
$this->_head['meta'][$name] = array($content, $prepend, $append); |
| 1678 |
if ( $Itemid === 0 ) { |
} |
| 1679 |
/** Nope, just use the homepage then. */ |
/** |
| 1680 |
$query = "SELECT id" |
* @param string The value of the name attibute |
| 1681 |
. "\n FROM #__menu" |
*/ |
| 1682 |
. "\n WHERE menutype='mainmenu'" |
function _getMetaTag ($name) { |
| 1683 |
. "\n AND published='1'" |
return isset($this->_head['meta'][$name]) ? $this->_head['meta'][$name] : array('', '', ''); |
| 1684 |
. "\n ORDER BY parent, ordering" |
} |
| 1685 |
. "\n LIMIT 1" |
/** |
| 1686 |
; |
* @param string The value of the name attibute |
| 1687 |
$database->setQuery( $query ); |
* @param string The value of the content attibute to append to the existing |
| 1688 |
$Itemid = $database->loadResult(); |
*/ |
| 1689 |
|
function _tidyMetaData($name, $content) { |
| 1690 |
|
$result[] = trim(htmlspecialchars($name)); |
| 1691 |
|
$result[] = trim(htmlspecialchars($content)); |
| 1692 |
|
return $result; |
| 1693 |
|
} |
| 1694 |
|
/** |
| 1695 |
|
* @param string The value of the name attibute |
| 1696 |
|
* @param string The value of the content attibute to append to the existing |
| 1697 |
|
* Tags ordered in with Site Keywords and Description first |
| 1698 |
|
*/ |
| 1699 |
|
function appendMetaTag( $name, $content ) { |
| 1700 |
|
list($name, $content) = $this->_tidyMetaData($name, $content); |
| 1701 |
|
$tag = $this->_getMetaTag($name); |
| 1702 |
|
if ($tag[0] AND $content) $content .= ', '; |
| 1703 |
|
$tag[0] = $content.$tag[0]; |
| 1704 |
|
$this->_head['meta'][$name] = $tag; |
| 1705 |
} |
} |
| 1706 |
|
|
| 1707 |
/** patch to lessen the impact on templates */ |
/** |
| 1708 |
if ($option == 'search') { |
* @param string The value of the name attibute |
| 1709 |
$option = 'com_search'; |
* @param string The value of the content attibute to append to the existing |
| 1710 |
|
*/ |
| 1711 |
|
function prependMetaTag( $name, $content ) { |
| 1712 |
|
list($name, $content) = $this->_tidyMetaData($name, $content); |
| 1713 |
|
$tag = $this->_getMetaTag($name); |
| 1714 |
|
$tag[0] = $content.$tag[0]; |
| 1715 |
|
$this->_head['meta'][$name] = $tag; |
| 1716 |
|
} |
| 1717 |
|
/** |
| 1718 |
|
* Adds a custom html string to the head block |
| 1719 |
|
* @param string The html to add to the head |
| 1720 |
|
*/ |
| 1721 |
|
function addCustomHeadTag( $html ) { |
| 1722 |
|
$this->_head['custom'][] = trim( $html ); |
| 1723 |
|
} |
| 1724 |
|
/** |
| 1725 |
|
* @return string |
| 1726 |
|
*/ |
| 1727 |
|
function getHead() { |
| 1728 |
|
$head[] = '<title>'.$this->_head['title'].'</title>'; |
| 1729 |
|
foreach ($this->_head['meta'] as $name=>$meta) { |
| 1730 |
|
if ($meta[1]) $head[] = $meta[1]; |
| 1731 |
|
$head[] = '<meta name="' . $name . '" content="' . $meta[0] . '" />'; |
| 1732 |
|
if ($meta[2]) $head[] = $meta[2]; |
| 1733 |
|
} |
| 1734 |
|
foreach ($this->_head['custom'] as $html) $head[] = $html; |
| 1735 |
|
return implode( "\n", $head )."\n"; |
| 1736 |
|
} |
| 1737 |
|
/** |
| 1738 |
|
* @return string |
| 1739 |
|
*/ |
| 1740 |
|
function getCustomPathWay() { |
| 1741 |
|
return $this->_custom_pathway; |
| 1742 |
|
} |
| 1743 |
|
|
| 1744 |
|
function appendPathWay($html) { |
| 1745 |
|
$this->_custom_pathway[] = $html; |
| 1746 |
} |
} |
| 1747 |
|
|
| 1748 |
// loads english language file by default |
/** |
| 1749 |
if ( $mosConfig_lang == '' ) { |
* Gets the value of a user state variable |
| 1750 |
$mosConfig_lang = 'english'; |
* @param string The name of the variable |
| 1751 |
|
*/ |
| 1752 |
|
function getUserState( $var_name ) { |
| 1753 |
|
return is_array($this->_userstate) ? mosGetParam($this->_userstate, $var_name, null) : null; |
| 1754 |
|
} |
| 1755 |
|
/** |
| 1756 |
|
* Sets the value of a user state variable |
| 1757 |
|
* @param string The name of the variable |
| 1758 |
|
* @param string The value of the variable |
| 1759 |
|
*/ |
| 1760 |
|
function setUserState( $var_name, $var_value ) { |
| 1761 |
|
if (is_array( $this->_userstate )) $this->_userstate[$var_name] = $var_value; |
| 1762 |
|
} |
| 1763 |
|
/** |
| 1764 |
|
* Gets the value of a user state variable |
| 1765 |
|
* @param string The name of the user state variable |
| 1766 |
|
* @param string The name of the variable passed in a request |
| 1767 |
|
* @param string The default value for the variable if not found |
| 1768 |
|
*/ |
| 1769 |
|
function getUserStateFromRequest( $var_name, $req_name, $var_default=null ) { |
| 1770 |
|
if (isset($_REQUEST[$req_name])) $this->setUserState($var_name, $_REQUEST[$req_name]); |
| 1771 |
|
elseif (isset($var_default) AND !isset($this->userstate[$var_name])) $this->setUserState($var_name, $var_default); |
| 1772 |
|
return $this->getUserState($var_name); |
| 1773 |
|
} |
| 1774 |
|
/** |
| 1775 |
|
* Initialises the user session |
| 1776 |
|
* |
| 1777 |
|
* Old sessions are flushed based on the configuration value for the cookie |
| 1778 |
|
* lifetime. If an existing session, then the last access time is updated. |
| 1779 |
|
* If a new session, a session id is generated and a record is created in |
| 1780 |
|
* the mos_sessions table. |
| 1781 |
|
*/ |
| 1782 |
|
function &initSession() { |
| 1783 |
|
$session =& mosSession::getCurrent(); |
| 1784 |
|
return $session; |
| 1785 |
} |
} |
|
include_once ( 'language/'.$mosConfig_lang.'.php' ); |
|
| 1786 |
|
|
| 1787 |
// frontend login & logout controls |
/** |
| 1788 |
$return = mosGetParam( $_REQUEST, 'return', NULL ); |
* @param string The name of the variable (from configuration.php) |
| 1789 |
$message = mosGetParam( $_POST, 'message', 0 ); |
* @return mixed The value of the configuration variable or null if not found |
| 1790 |
if ($option == "login") { |
*/ |
| 1791 |
$mainframe->login(); |
function getCfg( $varname ) { |
| 1792 |
|
return mamboCore::get('mosConfig_'.$varname); |
| 1793 |
|
} |
| 1794 |
|
|
| 1795 |
// JS Popup message |
function _setTemplate( $isAdmin=false ) { |
| 1796 |
if ( $message ) { |
global $Itemid; |
| 1797 |
|
$cur_template = ''; |
| 1798 |
|
$sql = "SELECT template, client_id, menuid FROM #__templates_menu WHERE (client_id=0 or client_id=1)"; |
| 1799 |
|
if (isset($Itemid) AND $Itemid) $sql .= " AND (menuid=0 OR menuid=$Itemid)"; |
| 1800 |
|
else $sql .= " AND menuid=0"; |
| 1801 |
|
$sql .= " ORDER BY client_id, menuid"; |
| 1802 |
|
$this->_db->setQuery($sql); |
| 1803 |
|
$templates = $this->_db->loadObjectList(); |
| 1804 |
|
foreach ($templates as $template) { |
| 1805 |
|
if ($template->client_id == 1) { |
| 1806 |
|
if ($isAdmin) $cur_template = $template->template; |
| 1807 |
|
} |
| 1808 |
|
else $cur_template = $template->template; |
| 1809 |
|
} |
| 1810 |
|
if ($isAdmin) { |
| 1811 |
|
$path = mamboCore::get('mosConfig_absolute_path')."/administrator/templates/$cur_template/index.php"; |
| 1812 |
|
if (!file_exists( $path )) $cur_template = 'mambo_admin'; |
| 1813 |
|
} |
| 1814 |
|
else { |
| 1815 |
|
// TemplateChooser Start |
| 1816 |
|
$mos_user_template = mosGetParam( $_COOKIE, 'mos_user_template', '' ); |
| 1817 |
|
$mos_change_template = mosGetParam( $_REQUEST, 'mos_change_template', $mos_user_template ); |
| 1818 |
|
if ($mos_change_template) { |
| 1819 |
|
// check that template exists in case it was deleted |
| 1820 |
|
$path = mamboCore::get('mosConfig_absolute_path')."/templates/$mos_change_template/index.php"; |
| 1821 |
|
if (file_exists( $path)) { |
| 1822 |
|
$lifetime = 60*10; |
| 1823 |
|
$cur_template = $mos_change_template; |
| 1824 |
|
setcookie( "mos_user_template", "$mos_change_template", time()+$lifetime); |
| 1825 |
|
} else setcookie( "mos_user_template", "", time()-3600 ); |
| 1826 |
|
} |
| 1827 |
|
// TemplateChooser End |
| 1828 |
|
} |
| 1829 |
|
$this->_template = $cur_template; |
| 1830 |
|
} |
| 1831 |
|
|
| 1832 |
|
function getTemplate() { |
| 1833 |
|
return $this->_template; |
| 1834 |
|
} |
| 1835 |
|
|
| 1836 |
|
/** |
| 1837 |
|
* Checks to see if an image exists in the current templates image directory |
| 1838 |
|
* if it does it loads this image. Otherwise the default image is loaded. |
| 1839 |
|
* Also can be used in conjunction with the menulist param to create the chosen image |
| 1840 |
|
* load the default or use no image |
| 1841 |
|
*/ |
| 1842 |
|
function ImageCheck( $file, $directory='/images/M_images/', $param=NULL, $param_directory='/images/M_images/', $alt=NULL, $name='image', $type=1, $align='middle' ) { |
| 1843 |
|
$basepath = mamboCore::get('mosConfig_live_site'); |
| 1844 |
|
if ($param) $image = $basepath.$param_directory.$param; |
| 1845 |
|
else { |
| 1846 |
|
$endpath = '/templates/'.$this->getTemplate().'/images/'.$file; |
| 1847 |
|
if (file_exists(mamboCore::get('mosConfig_absolute_path').$endpath)) $image = $basepath.$endpath; |
| 1848 |
|
else $image = $basepath.$directory.$file; // outputs only path to image |
| 1849 |
|
} |
| 1850 |
|
// outputs actual html <img> tag |
| 1851 |
|
if ($type) $image = '<img src="'. $image .'" alt="'. $alt .'" align="'. $align .'" name="'. $name .'" border="0" />'; |
| 1852 |
|
return $image; |
| 1853 |
|
} |
| 1854 |
|
|
| 1855 |
|
/** |
| 1856 |
|
* Returns the first to be found of one or more files, or null |
| 1857 |
|
* |
| 1858 |
|
*/ |
| 1859 |
|
function tryFiles ($first_choice, $second_choice=null, $third_choice=null) { |
| 1860 |
|
if (file_exists($first_choice)) return $first_choice; |
| 1861 |
|
elseif ($second_choice AND file_exists($second_choice)) return $second_choice; |
| 1862 |
|
elseif ($third_choice AND file_exists($third_choice)) return $third_choice; |
| 1863 |
|
else return null; |
| 1864 |
|
} |
| 1865 |
|
|
| 1866 |
|
/** |
| 1867 |
|
* Returns a standard path variable |
| 1868 |
|
* |
| 1869 |
|
*/ |
| 1870 |
|
function getPath( $varname, $option='' ) { |
| 1871 |
|
$base = mamboCore::get('mosConfig_absolute_path'); |
| 1872 |
|
$origoption = $option; |
| 1873 |
|
if (!$option) $option = $this->_option; |
| 1874 |
|
$name = substr($option,4); |
| 1875 |
|
$bac_admin = "$base/administrator/components/com_admin/"; |
| 1876 |
|
$baco = "$base/administrator/components/$option/"; |
| 1877 |
|
$bttc = "$base/templates/$this->_template/components/"; |
| 1878 |
|
$bco = "$base/components/$option/"; |
| 1879 |
|
$bai = "$base/administrator/includes/"; |
| 1880 |
|
$bi = "$base/includes/"; |
| 1881 |
|
|
| 1882 |
|
switch ($varname) { |
| 1883 |
|
case 'front': return $this->tryFiles ($bco."$name.php"); |
| 1884 |
|
case 'front_html': return $this->tryFiles ($bttc."$name.html.php", $bco."$name.html.php"); |
| 1885 |
|
case 'admin': return $this->tryFiles ($baco."admin.$name.php", $bac_admin.'admin.admin.php'); |
| 1886 |
|
case 'admin_html': return $this->tryFiles ($baco."admin.$name.html.php", $bac_admin.'admin.admin.html.php'); |
| 1887 |
|
case 'toolbar': return $this->tryFiles ($baco."toolbar.$name.php"); |
| 1888 |
|
case 'toolbar_html': return $this->tryFiles ($baco."toolbar.$name.html.php"); |
| 1889 |
|
case 'toolbar_default': return $this->tryFiles ($bai.'toolbar.html.php'); |
| 1890 |
|
case 'class': return $this->tryFiles ($bco."$name.class.php", $baco."$name.class.php", $bi."$name.php"); |
| 1891 |
|
case 'com_xml': return $this->tryFiles ($baco."$name.xml", $bco."$name.xml"); |
| 1892 |
|
case 'mod0_xml': |
| 1893 |
|
if ($origoption) $path = $base."/modules/$option.xml"; |
| 1894 |
|
else $path = $base.'/modules/custom.xml'; |
| 1895 |
|
return $this->tryFiles ($path); |
| 1896 |
|
case 'mod1_xml': |
| 1897 |
|
if ($origoption) $path = $base."/administrator/modules/$option.xml"; |
| 1898 |
|
else $path = $base.'/administrator/modules/custom.xml'; |
| 1899 |
|
return $this->tryFiles ($path); |
| 1900 |
|
case 'bot_xml': return $this->tryFiles ($base."/mambots/$option.xml"); |
| 1901 |
|
case 'menu_xml': return $this->tryFiles ($base."/administrator/components/com_menus/$option/$option.xml"); |
| 1902 |
|
case 'installer_html': return $this->tryFiles($base."/administrator/components/com_installer/$option/$option.html.php"); |
| 1903 |
|
case 'installer_class': return $this->tryFiles($base."/administrator/components/com_installer/$option/$option.class.php"); |
| 1904 |
|
} |
| 1905 |
|
} |
| 1906 |
|
|
| 1907 |
|
/** |
| 1908 |
|
* Detects a 'visit' |
| 1909 |
|
* |
| 1910 |
|
* This function updates the agent and domain table hits for a particular |
| 1911 |
|
* visitor. The user agent is recorded/incremented if this is the first visit. |
| 1912 |
|
* A cookie is set to mark the first visit. |
| 1913 |
|
*/ |
| 1914 |
|
function detect() { |
| 1915 |
|
if (mamboCore::get('mosConfig_enable_stats') == 1) { |
| 1916 |
|
if (mosGetParam( $_COOKIE, 'mosvisitor', 0 )) return; |
| 1917 |
|
setcookie( "mosvisitor", "1" ); |
| 1918 |
|
|
| 1919 |
|
$agent = $_SERVER['HTTP_USER_AGENT']; |
| 1920 |
|
$browser = mosGetBrowser( $agent ); |
| 1921 |
|
$os = mosGetOS( $agent ); |
| 1922 |
|
$domain = gethostbyaddr( $_SERVER['REMOTE_ADDR'] ); |
| 1923 |
|
// tease out the last element of the domain |
| 1924 |
|
$tldomain = split( "\.", $domain ); |
| 1925 |
|
$tldomain = $tldomain[count( $tldomain )-1]; |
| 1926 |
|
if (is_numeric( $tldomain )) { |
| 1927 |
|
$tldomain = "Unknown"; |
| 1928 |
|
} |
| 1929 |
|
|
| 1930 |
|
$this->_db->setQuery( "SELECT count(*), type FROM #__stats_agents WHERE (agent='$browser' AND type=0) OR (agent='$os' AND type=1) OR (agent='$tldomain' AND type=2) GROUP BY type"); |
| 1931 |
|
$stats = $this->_db->loadObjectList(); |
| 1932 |
|
$sql['browser'] = "INSERT INTO #__stats_agents (agent,type) VALUES ('$browser',0)"; |
| 1933 |
|
$sql['os'] = "INSERT INTO #__stats_agents (agent,type) VALUES ('$os',1)"; |
| 1934 |
|
$sql['domain'] = "INSERT INTO #__stats_agents (agent,type) VALUES ('$tldomain',2)"; |
| 1935 |
|
if ($stats) foreach ($stats as $stat) { |
| 1936 |
|
if ($stat->type == 0) $sql['agents'] = "UPDATE #__stats_agents SET hits=(hits+1) WHERE agent='$browser' AND type=0"; |
| 1937 |
|
if ($stat->type == 1) $sql['os'] = "UPDATE #__stats_agents SET hits=(hits+1) WHERE agent='$os' AND type=1"; |
| 1938 |
|
if ($stat->type == 2) $sql['domain'] = "UPDATE #__stats_agents SET hits=(hits+1) WHERE agent='$tldomain' AND type=2"; |
| 1939 |
|
} |
| 1940 |
|
$this->_db->setQuery(implode('; ',$sql)); |
| 1941 |
|
$this->_db->query_batch(); |
| 1942 |
|
} |
| 1943 |
|
} |
| 1944 |
|
|
| 1945 |
|
/** |
| 1946 |
|
* @return correct Itemid for Content Item |
| 1947 |
|
*/ |
| 1948 |
|
function getItemid ($id, $typed=1, $link=1, $bs=1, $bc=1, $gbs=1) { |
| 1949 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 1950 |
|
$handler = contentHandler::getInstance(); |
| 1951 |
|
return $handler->getItemid($id, $typed, $link, $bs, $bc, $gbs); |
| 1952 |
|
} |
| 1953 |
|
|
| 1954 |
|
function liveBookMark () { |
| 1955 |
|
// support for Firefox Live Bookmarks ability for site syndication |
| 1956 |
|
$c_handler = mosComponentHandler::getInstance(); |
| 1957 |
|
$params = $c_handler->getParamsByName('Syndicate'); |
| 1958 |
|
$live_bookmark = $params->get( 'live_bookmark', 0 ); |
| 1959 |
|
if ($live_bookmark) { |
| 1960 |
|
// custom bookmark file name |
| 1961 |
|
$bookmark_file = $params->get( 'bookmark_file', $live_bookmark ); |
| 1962 |
|
$link_file = mamboCore::get('mosConfig_live_site').'/cache/'. $bookmark_file; |
| 1963 |
|
$filename = mamboCore::get('mosConfig_absolute_path').'/cache/'. $bookmark_file; |
| 1964 |
|
$cache = $params->get( 'cache', 1 ); |
| 1965 |
|
$cache_time = $params->get( 'cache_time', 3600 ); |
| 1966 |
|
$title = $params->def( 'title', mamboCore::get('mosConfig_sitename') ); |
| 1967 |
|
// checks to see if cache file exists, to determine whether to create a new one |
| 1968 |
|
if ( !file_exists( $filename ) || ( ( time() - filemtime( $filename ) ) > $cache_time ) ) { |
| 1969 |
|
$task = 'live_bookmark'; |
| 1970 |
|
// sets bookmark feed type |
| 1971 |
|
$_GET['feed'] = str_replace( '.xml', '', $live_bookmark ); |
| 1972 |
|
// loads rss component to create bookmark file |
| 1973 |
|
require_once( mamboCore::get('mosConfig_absolute_path').'/components/com_rss/rss.php' ); |
| 1974 |
|
} |
| 1975 |
|
// outputs link tag for page |
| 1976 |
?> |
?> |
| 1977 |
<script> |
<link rel="alternate" type="application/rss+xml" title="<?php echo $title; ?>" href="<?php echo $link_file; ?>" /> |
|
<!--// |
|
|
alert( "<?php echo _LOGIN_SUCCESS; ?>" ); |
|
|
//--> |
|
|
</script> |
|
| 1978 |
<?php |
<?php |
| 1979 |
} |
} |
| 1980 |
|
} |
| 1981 |
|
|
| 1982 |
|
function mosShowHead () { |
| 1983 |
|
global $_VERSION; |
| 1984 |
|
$mosConfig_live_site = mamboCore::get('mosConfig_live_site'); |
| 1985 |
|
$this->appendMetaTag( 'description', mamboCore::get('mosConfig_MetaDesc') ); |
| 1986 |
|
$this->appendMetaTag( 'keywords', mamboCore::get('mosConfig_MetaKeys') ); |
| 1987 |
|
$this->addMetaTag( 'Generator', $_VERSION->PRODUCT . " - " . $_VERSION->COPYRIGHT); |
| 1988 |
|
$this->addMetaTag( 'robots', 'index, follow' ); |
| 1989 |
|
echo $this->getHead(); |
| 1990 |
|
if (mamboCore::get('mosConfig_sef')) { |
| 1991 |
|
echo "<base href=\"$mosConfig_live_site/\" />\r\n"; |
| 1992 |
|
} |
| 1993 |
|
$my = mamboCore::get('currentUser'); |
| 1994 |
|
if ( $my->id ) { |
| 1995 |
|
?> |
| 1996 |
|
<script language="JavaScript1.2" src="<?php echo $mosConfig_live_site;?>/includes/js/mambojavascript.js" type="text/javascript"></script> |
| 1997 |
|
<?php |
| 1998 |
|
} |
| 1999 |
|
$this->liveBookMark(); |
| 2000 |
|
// outputs link tag for page |
| 2001 |
|
$configuration = mamboCore::getMamboCore(); |
| 2002 |
|
?> |
| 2003 |
|
<link rel="shortcut icon" href="<?php echo $configuration->getFavIcon();?>" /> |
| 2004 |
|
<?php |
| 2005 |
|
} |
| 2006 |
|
|
| 2007 |
|
} |
| 2008 |
|
|
| 2009 |
|
/** |
| 2010 |
|
* Class to support function caching |
| 2011 |
|
* @package Mambo |
| 2012 |
|
*/ |
| 2013 |
|
class mosCache { |
| 2014 |
|
/** |
| 2015 |
|
* @return object A function cache object |
| 2016 |
|
*/ |
| 2017 |
|
function &getCache( $group='' ) { |
| 2018 |
|
$mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path'); |
| 2019 |
|
require_once($mosConfig_absolute_path.'/includes/Cache/Lite/Function.php'); |
| 2020 |
|
$path = mamboCore::get('mosConfig_cachepath'); |
| 2021 |
|
$caching = mamboCore::get('mosConfig_caching'); |
| 2022 |
|
$time = mamboCore::get('mosConfig_cachetime'); |
| 2023 |
|
$options = array( |
| 2024 |
|
'cacheDir' => "$path/", |
| 2025 |
|
'caching' => $caching, |
| 2026 |
|
'defaultGroup' => $group, |
| 2027 |
|
'lifeTime' => $time |
| 2028 |
|
); |
| 2029 |
|
$cache =& new Cache_Lite_Function( $options ); |
| 2030 |
|
return $cache; |
| 2031 |
|
} |
| 2032 |
|
/** |
| 2033 |
|
* Cleans the cache |
| 2034 |
|
*/ |
| 2035 |
|
function cleanCache ($group=false) { |
| 2036 |
|
if (mamboCore::get('mosConfig_caching')) { |
| 2037 |
|
$cache =& mosCache::getCache( $group ); |
| 2038 |
|
$cache->clean( $group ); |
| 2039 |
|
} |
| 2040 |
|
} |
| 2041 |
|
} |
| 2042 |
|
|
| 2043 |
|
/** |
| 2044 |
|
* Session database table class |
| 2045 |
|
* @package Mambo |
| 2046 |
|
*/ |
| 2047 |
|
class mosSession extends mosDBTable { |
| 2048 |
|
/** @var int Primary key */ |
| 2049 |
|
var $session_id=null; |
| 2050 |
|
/** @var string */ |
| 2051 |
|
var $time=null; |
| 2052 |
|
/** @var string */ |
| 2053 |
|
var $userid=0; |
| 2054 |
|
/** @var string */ |
| 2055 |
|
var $usertype=null; |
| 2056 |
|
/** @var string */ |
| 2057 |
|
var $username=''; |
| 2058 |
|
/** @var time */ |
| 2059 |
|
var $gid=0; |
| 2060 |
|
/** @var int */ |
| 2061 |
|
var $guest=1; |
| 2062 |
|
/** @var string */ |
| 2063 |
|
var $_session_cookie=null; |
| 2064 |
|
|
| 2065 |
if ($return) { |
/** |
| 2066 |
mosRedirect( $return ); |
* @param database A database connector object |
| 2067 |
|
*/ |
| 2068 |
|
function mosSession( &$db ) { |
| 2069 |
|
$database = mamboDatabase::getInstance(); |
| 2070 |
|
$this->mosDBTable( '#__session', 'session_id', $database ); |
| 2071 |
|
$this->time = time(); |
| 2072 |
|
} |
| 2073 |
|
|
| 2074 |
|
function &getCurrent () { |
| 2075 |
|
static $currentSession; |
| 2076 |
|
if (!is_object($currentSession)) { |
| 2077 |
|
$currentSession = new mosSession($dummy); |
| 2078 |
|
$currentSession->purge(intval(mamboCore::get('mosConfig_lifetime'))); |
| 2079 |
|
$sessionCookieName = md5('site'.mamboCore::get('mosConfig_live_site')); |
| 2080 |
|
$sessioncookie = mosGetParam($_COOKIE, $sessionCookieName, null); |
| 2081 |
|
$usercookie = mosGetParam($_COOKIE, 'usercookie', null); |
| 2082 |
|
if ($currentSession->load(md5($sessioncookie.$_SERVER['REMOTE_ADDR']))) { |
| 2083 |
|
// Session cookie exists, update time in session table |
| 2084 |
|
$currentSession->time = time(); |
| 2085 |
|
$currentSession->update(); |
| 2086 |
} else { |
} else { |
| 2087 |
mosRedirect( 'index.php' ); |
$currentSession->generateId(); |
| 2088 |
|
if (!$currentSession->insert()) { |
| 2089 |
|
die( $currentSession->getError() ); |
| 2090 |
|
} |
| 2091 |
|
setcookie( $sessionCookieName, $currentSession->getCookie(), time() + 43200, '/' ); |
| 2092 |
|
//$_COOKIE["sessioncookie"] = $session->getCookie(); |
| 2093 |
|
if ($usercookie) { |
| 2094 |
|
// Remember me cookie exists. Login with usercookie info. |
| 2095 |
|
require_once (mamboCore::get('mosConfig_absolute_path').'/includes/authenticator.php'); |
| 2096 |
|
$authenticator = mamboAuthenticator::getInstance(); |
| 2097 |
|
$authenticator->authenticateUser ($message, $usercookie['username'], $usercookie['password'], null, $currentSession); |
| 2098 |
|
} |
| 2099 |
|
} |
| 2100 |
|
} |
| 2101 |
|
return $currentSession; |
| 2102 |
} |
} |
| 2103 |
|
|
| 2104 |
} else if ($option == "logout") { |
function insert() { |
| 2105 |
$mainframe->logout(); |
$ret = $this->_db->insertObject( $this->_tbl, $this ); |
| 2106 |
|
|
| 2107 |
// JS Popup message |
if( !$ret ) { |
| 2108 |
if ( $message ) { |
$this->_error = strtolower(get_class( $this ))."::store failed <br />" . $this->_db->stderr(); |
| 2109 |
?> |
return false; |
| 2110 |
<script> |
} else { |
| 2111 |
<!--// |
return true; |
| 2112 |
alert( "<?php echo _LOGOUT_SUCCESS; ?>" ); |
} |
|
//--> |
|
|
</script> |
|
|
<?php |
|
| 2113 |
} |
} |
| 2114 |
|
|
| 2115 |
if ($return) { |
function update( $updateNulls=false ) { |
| 2116 |
mosRedirect( $return ); |
$ret = $this->_db->updateObject( $this->_tbl, $this, 'session_id', $updateNulls ); |
| 2117 |
|
|
| 2118 |
|
if( !$ret ) { |
| 2119 |
|
$this->_error = strtolower(get_class( $this ))."::store failed <br />" . $this->_db->stderr(); |
| 2120 |
|
return false; |
| 2121 |
} else { |
} else { |
| 2122 |
mosRedirect( 'index.php' ); |
return true; |
| 2123 |
|
} |
| 2124 |
|
} |
| 2125 |
|
|
| 2126 |
|
function generateId() { |
| 2127 |
|
$failsafe = 20; |
| 2128 |
|
$randnum = 0; |
| 2129 |
|
while ($failsafe--) { |
| 2130 |
|
$randnum = md5( uniqid( microtime(), 1 ) ); |
| 2131 |
|
if ($randnum != "") { |
| 2132 |
|
$cryptrandnum = md5( $randnum ); |
| 2133 |
|
$this->_db->setQuery( "SELECT $this->_tbl_key FROM $this->_tbl WHERE $this->_tbl_key=MD5('$randnum')" ); |
| 2134 |
|
if(!$result = $this->_db->query()) { |
| 2135 |
|
die( $this->_db->stderr( true )); |
| 2136 |
|
// todo: handle gracefully |
| 2137 |
|
} |
| 2138 |
|
if ($this->_db->getNumRows($result) == 0) { |
| 2139 |
|
break; |
| 2140 |
|
} |
| 2141 |
} |
} |
| 2142 |
} |
} |
| 2143 |
|
$this->_session_cookie = $randnum; |
| 2144 |
|
$this->session_id = md5( $randnum . $_SERVER['REMOTE_ADDR'] ); |
| 2145 |
|
} |
| 2146 |
|
|
| 2147 |
/** get the information about the current user from the sessions table */ |
function getCookie() { |
| 2148 |
$my = $mainframe->getUser(); |
return $this->_session_cookie; |
| 2149 |
|
} |
| 2150 |
|
|
| 2151 |
/** detect first visit */ |
function purge( $inc=1800 ) { |
| 2152 |
$mainframe->detect(); |
$past = time() - $inc; |
| 2153 |
|
$query = "DELETE FROM $this->_tbl" |
| 2154 |
|
. "\nWHERE (time < $past)"; |
| 2155 |
|
$this->_db->setQuery($query); |
| 2156 |
|
|
| 2157 |
$gid = intval( $my->gid ); |
return $this->_db->query(); |
| 2158 |
|
} |
| 2159 |
|
} |
| 2160 |
|
|
| 2161 |
// gets template for page |
/** |
| 2162 |
$cur_template = $mainframe->getTemplate(); |
* Parameters handler |
| 2163 |
/** temp fix - this feature is currently disabled */ |
* @package Mambo |
| 2164 |
|
*/ |
| 2165 |
|
class mosParameters { |
| 2166 |
|
/** @var object */ |
| 2167 |
|
var $_params = null; |
| 2168 |
|
/** @var string The raw params string */ |
| 2169 |
|
var $_raw = null; |
| 2170 |
|
/** |
| 2171 |
|
* Constructor |
| 2172 |
|
* @param string The raw parms text |
| 2173 |
|
* @param string Path to the xml setup file |
| 2174 |
|
* @var string The type of setup file |
| 2175 |
|
*/ |
| 2176 |
|
function mosParameters( $text, $process_sections = false) { |
| 2177 |
|
$this->_params = $this->parse( $text, $process_sections ); |
| 2178 |
|
$this->_raw = $text; |
| 2179 |
|
} |
| 2180 |
|
/** |
| 2181 |
|
* Get the result of parsing the string provided on creation |
| 2182 |
|
* @return string parsed result |
| 2183 |
|
*/ |
| 2184 |
|
function getParams () { |
| 2185 |
|
return $this->_params; |
| 2186 |
|
} |
| 2187 |
|
/** |
| 2188 |
|
* @param string The name of the param |
| 2189 |
|
* @param string The value of the parameter |
| 2190 |
|
* @return string The set value |
| 2191 |
|
*/ |
| 2192 |
|
function set( $key, $value='' ) { |
| 2193 |
|
$this->_params->$key = $value; |
| 2194 |
|
return $value; |
| 2195 |
|
} |
| 2196 |
|
/** |
| 2197 |
|
* Sets a default value if not alreay assigned |
| 2198 |
|
* @param string The name of the param |
| 2199 |
|
* @param string The value of the parameter |
| 2200 |
|
* @return string The set value |
| 2201 |
|
*/ |
| 2202 |
|
function def( $key, $value='' ) { |
| 2203 |
|
return $this->set( $key, $this->get( $key, $value ) ); |
| 2204 |
|
} |
| 2205 |
|
/** |
| 2206 |
|
* @param string The name of the param |
| 2207 |
|
* @param mixed The default value if not found |
| 2208 |
|
* @return string |
| 2209 |
|
*/ |
| 2210 |
|
function get( $key, $default='' ) { |
| 2211 |
|
if (isset( $this->_params->$key )) return $this->_params->$key === '' ? $default : $this->_params->$key; |
| 2212 |
|
else return $default; |
| 2213 |
|
} |
| 2214 |
|
/** |
| 2215 |
|
* Look to see if string is bracketed by opener and closer |
| 2216 |
|
* If so, extract and trim the bracketed string |
| 2217 |
|
* Otherwise, return a null string |
| 2218 |
|
**/ |
| 2219 |
|
function getBracketed ($text, $opener, $closer) { |
| 2220 |
|
if (strlen($text) > 1 AND ($text[0] != $opener OR substr($text,-1) != $closer)) return ''; |
| 2221 |
|
else return trim(substr($text,1,-1)); |
| 2222 |
|
} |
| 2223 |
|
/** |
| 2224 |
|
* Parse an .ini string, based on phpDocumentor phpDocumentor_parse_ini_file function |
| 2225 |
|
* @param mixed The ini string or array of lines |
| 2226 |
|
* @param boolean add an associative index for each section [in brackets] |
| 2227 |
|
* @return object |
| 2228 |
|
*/ |
| 2229 |
|
function parse( $txt, $process_sections = false ) { |
| 2230 |
|
$result = new stdClass(); |
| 2231 |
|
if (is_string($txt)) $lines = explode( "\n", $txt ); |
| 2232 |
|
elseif (is_array($txt)) $lines = $txt; |
| 2233 |
|
else return $result; |
| 2234 |
|
|
| 2235 |
|
$sec_name = ''; |
| 2236 |
|
$unparsed = 0; |
| 2237 |
|
|
| 2238 |
|
foreach ($lines as $line) { |
| 2239 |
|
// ignore comments and null lines |
| 2240 |
|
$line = trim($line); |
| 2241 |
|
if (strlen($line) == 0 OR $line[0] == ';') continue; |
| 2242 |
|
|
| 2243 |
|
if ($sec_name = $this->getBracketed($line, '[', ']')) { |
| 2244 |
|
if ($process_sections) $result->$sec_name = new stdClass(); |
| 2245 |
|
continue; |
| 2246 |
|
} |
| 2247 |
|
|
| 2248 |
|
if (count($propsetter = explode ('=', $line, 2)) == 2) { |
| 2249 |
|
$property = trim($propsetter[0]); |
| 2250 |
|
if ($pquoted = $this->getBracketed($property, '"', '"')) $property = stripcslashes($pquoted); |
| 2251 |
|
$value = trim($propsetter[1]); |
| 2252 |
|
if ($value == 'false') $value = false; |
| 2253 |
|
elseif ($value == 'true') $value = true; |
| 2254 |
|
else if ($vquoted = $this->getBracketed($value, '"', '"')) $value = stripcslashes($vquoted); |
| 2255 |
|
if ($process_sections AND $sec_name) $result->$sec_name->$property = $value; |
| 2256 |
|
else $result->$property = $value; |
| 2257 |
|
} |
| 2258 |
|
else { |
| 2259 |
|
$property = '__invalid' . $unparsed++ . '__'; |
| 2260 |
|
if ($process_sections AND $sec_name) $result->$sec_name->$property = $line; |
| 2261 |
|
else $result->$property = $line; |
| 2262 |
|
} |
| 2263 |
|
} |
| 2264 |
|
return $result; |
| 2265 |
|
} |
| 2266 |
|
/** |
| 2267 |
|
* special handling for textarea param |
| 2268 |
|
*/ |
| 2269 |
|
function textareaHandling( &$txt ) { |
| 2270 |
|
foreach ($txt as $key=>$value) $txt[$key] = str_replace("\n", '<br />', $value); |
| 2271 |
|
return implode( "\n", $txt ); |
| 2272 |
|
} |
| 2273 |
|
} |
| 2274 |
|
|
| 2275 |
|
/** |
| 2276 |
|
* Page generation time |
| 2277 |
|
* @package Mambo |
| 2278 |
|
*/ |
| 2279 |
|
class mosProfiler { |
| 2280 |
|
var $start=0; |
| 2281 |
|
var $prefix=''; |
| 2282 |
|
|
| 2283 |
|
function mosProfiler( $prefix='' ) { |
| 2284 |
|
$this->start = $this->getmicrotime(); |
| 2285 |
|
$this->prefix = $prefix; |
| 2286 |
|
} |
| 2287 |
|
|
| 2288 |
/** @global A places to store information from processing of the component */ |
function mark( $label ) { |
| 2289 |
$_MOS_OPTION = array(); |
return sprintf ( "\n<div class=\"profiler\">$this->prefix %.3f $label</div>", $this->getmicrotime() - $this->start ); |
| 2290 |
|
} |
| 2291 |
|
|
| 2292 |
// precapture the output of the component |
function getmicrotime(){ |
| 2293 |
require_once( $mosConfig_absolute_path . '/editor/editor.php' ); |
list($usec, $sec) = explode(" ",microtime()); |
| 2294 |
|
return ((float)$usec + (float)$sec); |
| 2295 |
|
} |
| 2296 |
|
} |
| 2297 |
|
|
| 2298 |
ob_start(); |
require($configuration->rootPath().'/includes/version.php'); |
| 2299 |
if ($path = $mainframe->getPath( 'front' )) { |
$_VERSION =& new version(); |
| 2300 |
|
|
| 2301 |
|
$version = $_VERSION->PRODUCT .' '. $_VERSION->RELEASE .'.'. $_VERSION->DEV_LEVEL .' ' |
| 2302 |
|
. $_VERSION->DEV_STATUS |
| 2303 |
|
.' [ '.$_VERSION->CODENAME .' ] '. $_VERSION->RELDATE .' ' |
| 2304 |
|
. $_VERSION->RELTIME .' '. $_VERSION->RELTZ; |
| 2305 |
|
|
| 2306 |
|
if (phpversion() < '4.2.0') require_once( $configuration->rootPath() . '/includes/compat.php41x.php' ); |
| 2307 |
|
if (phpversion() < '4.3.0') require_once( $configuration->rootPath() . '/includes/compat.php42x.php' ); |
| 2308 |
|
|
| 2309 |
|
$local_backup_path = $configuration->rootPath().'/administrator/backups'; |
| 2310 |
|
$media_path = $configuration->rootPath().'/media/'; |
| 2311 |
|
$image_path = $configuration->rootPath().'/images/stories'; |
| 2312 |
|
$image_size = 100; |
| 2313 |
|
|
| 2314 |
|
$database = mamboDatabase::getInstance(); |
| 2315 |
|
$database->debug(mamboCore::get('mosConfig_debug')); |
| 2316 |
|
|
| 2317 |
|
if (!$adminside) { |
| 2318 |
|
$sefcode = $configuration->rootPath().'/components/com_sef/sef.php'; |
| 2319 |
|
if (file_exists($sefcode)) require_once($sefcode); |
| 2320 |
|
else require_once($configuration->rootPath().'/includes/sef.php'); |
| 2321 |
|
$urlerror = 0; |
| 2322 |
|
if (mamboCore::get('mosConfig_sef') AND $indextype == 3) { |
| 2323 |
|
$sef = mosSEF::getInstance(); |
| 2324 |
|
$urlerror = $sef->sefRetrieval(mamboCore::get('mosConfig_register_globals')); |
| 2325 |
|
$indextype = 1; |
| 2326 |
|
} |
| 2327 |
|
} |
| 2328 |
|
|
| 2329 |
|
/** retrieve some possible request string (or form) arguments */ |
| 2330 |
|
$type = mosGetParam($_REQUEST, 'type', 1); |
| 2331 |
|
$act = mosGetParam( $_REQUEST, 'act', '' ); |
| 2332 |
|
$do_pdf = mosGetParam( $_REQUEST, 'do_pdf', 0 ); |
| 2333 |
|
$id = mosGetParam( $_REQUEST, 'id', 0 ); |
| 2334 |
$task = mosGetParam( $_REQUEST, 'task', '' ); |
$task = mosGetParam( $_REQUEST, 'task', '' ); |
| 2335 |
$ret = mosMenuCheck( $Itemid, $option, $task, $gid ); |
$act = strtolower(mosGetParam($_REQUEST, 'act', '')); |
| 2336 |
if ($ret) { |
$section = mosGetParam($_REQUEST, 'section', ''); |
| 2337 |
|
$no_html = strtolower(mosGetParam($_REQUEST, 'no_html', '')); |
| 2338 |
|
|
| 2339 |
|
if ($adminside) { |
| 2340 |
|
// Start ACL |
| 2341 |
|
require_once($configuration->rootPath().'/includes/gacl.class.php' ); |
| 2342 |
|
require_once($configuration->rootPath().'/includes/gacl_api.class.php' ); |
| 2343 |
|
$acl = new gacl_api(); |
| 2344 |
|
// Handle special admin side options |
| 2345 |
|
$option = strtolower(mosGetParam($_REQUEST,'option','com_admin')); |
| 2346 |
|
// Login will, if it succeeds, start a new session and set $my |
| 2347 |
|
if ($option == 'login') { |
| 2348 |
|
require_once($configuration->rootPath().'/includes/authenticator.php'); |
| 2349 |
|
$authenticator = mamboAuthenticator::getInstance(); |
| 2350 |
|
$my = $authenticator->loginAdmin($acl); |
| 2351 |
|
} |
| 2352 |
|
// If this is not login, we should already have a valid admin session |
| 2353 |
|
else { |
| 2354 |
|
session_name(md5(mamboCore::get('mosConfig_live_site'))); |
| 2355 |
|
session_start(); |
| 2356 |
|
// Handle the remaining special options |
| 2357 |
|
if ($option == 'logout') { |
| 2358 |
|
require($configuration->rootPath().'/administrator/logout.php'); |
| 2359 |
|
exit(); |
| 2360 |
|
} |
| 2361 |
|
if ($option == 'simple_mode') $admin_mode = 'on'; |
| 2362 |
|
elseif ($option == 'advanced_mode') $admin_mode = 'off'; |
| 2363 |
|
else $admin_mode = mosGetParam($_SESSION, 'simple_editing', ''); |
| 2364 |
|
$_SESSION['simple_editing'] = mosGetParam($_POST, 'simple_editing', $admin_mode); |
| 2365 |
|
// Include admin side functions, check that we have a valid admin side session |
| 2366 |
|
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
| 2367 |
|
$my = checkAdminSession($database); |
| 2368 |
|
} |
| 2369 |
|
// We can now create the mainframe object |
| 2370 |
|
$mainframe =& new mosMainFrame($database, $option, '..', true); |
| 2371 |
|
// Provided $my is set, we have a valid admin side session and can include remaining code |
| 2372 |
|
if ($my) { |
| 2373 |
|
mamboCore::set('currentUser', $my); |
| 2374 |
|
require_once( $configuration->rootPath().'/includes/mambo.php' ); |
| 2375 |
|
require_once ($configuration->rootPath().'/includes/mambofunc.php'); |
| 2376 |
|
require_once ($configuration->rootPath().'/includes/mamboHTML.php'); |
| 2377 |
|
require_once( $configuration->rootPath().'/administrator/includes/mosAdminMenus.php'); |
| 2378 |
|
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
| 2379 |
|
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
| 2380 |
|
$_MAMBOTS = mosMambotHandler::getInstance(); |
| 2381 |
|
// If no_html is set, we avoid starting the template, and go straight to the component |
| 2382 |
|
if ($no_html) { |
| 2383 |
|
if ($path = $mainframe->getPath( "admin" )) require $path; |
| 2384 |
|
exit(); |
| 2385 |
|
} |
| 2386 |
|
$configuration->initGzip(); |
| 2387 |
|
// When adminside = 3 we assume that HTML is being explicitly written and do nothing more |
| 2388 |
|
if ($adminside != 3) { |
| 2389 |
|
$path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/index.php'; |
| 2390 |
require_once( $path ); |
require_once( $path ); |
| 2391 |
} else { |
$configuration->doGzip(); |
|
mosNotAuth(); |
|
| 2392 |
} |
} |
| 2393 |
} else { |
else { |
| 2394 |
echo _NOT_EXIST; |
$pop = mosGetParam($_REQUEST, 'pop', ''); |
| 2395 |
|
if ($pop) require_once($configuration->rootPath()."/administrator/popups/$pop"); |
| 2396 |
|
else require_once($configuration->rootPath()."/administrator/popups/index3pop.php"); |
| 2397 |
|
$configuration->doGzip(); |
| 2398 |
} |
} |
| 2399 |
$_MOS_OPTION['buffer'] = ob_get_contents(); |
} |
| 2400 |
ob_end_clean(); |
// If $my was not set, the only possibility is to ask for an admin side login |
| 2401 |
|
else { |
| 2402 |
|
$configuration->initGzip(); |
| 2403 |
|
$path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/login.php'; |
| 2404 |
|
require_once( $path ); |
| 2405 |
|
$configuration->doGzip(); |
| 2406 |
|
} |
| 2407 |
|
} |
| 2408 |
|
// Finished admin side; the rest is user side code: |
| 2409 |
|
else { |
| 2410 |
|
$option = $configuration->determineOptionAndItemid(); |
| 2411 |
|
$configuration->handleGlobals(); |
| 2412 |
|
$Itemid = $configuration->get('Itemid'); |
| 2413 |
|
|
| 2414 |
|
$mainframe =& new mosMainFrame($database, $option, '.'); |
| 2415 |
|
$session = mosSession::getCurrent(); |
| 2416 |
|
if ($option == 'login') $configuration->handleLogin($session); |
| 2417 |
|
elseif ($option == 'logout') $configuration->handleLogout($session); |
| 2418 |
|
|
| 2419 |
|
$my =& new mosUser($database); |
| 2420 |
|
$my->getSessionData(); |
| 2421 |
|
mamboCore::set('currentUser',$my); |
| 2422 |
|
$configuration->offlineCheck($my, $database); |
| 2423 |
|
$gid = intval( $my->gid ); |
| 2424 |
|
// gets template for page |
| 2425 |
|
$cur_template = $mainframe->getTemplate(); |
| 2426 |
|
|
| 2427 |
initGzip(); |
require_once( $configuration->rootPath().'/includes/frontend.php' ); |
| 2428 |
|
require_once( $configuration->rootPath().'/includes/mambo.php' ); |
| 2429 |
|
require_once ($configuration->rootPath().'/includes/mambofunc.php'); |
| 2430 |
|
require_once ($configuration->rootPath().'/includes/mamboHTML.php'); |
| 2431 |
|
|
| 2432 |
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); |
if ($indextype == 2 AND $do_pdf == 1 ) { |
| 2433 |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
include_once('includes/pdf.php'); |
| 2434 |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); |
exit(); |
| 2435 |
header( 'Cache-Control: post-check=0, pre-check=0', false ); |
} |
| 2436 |
header( 'Pragma: no-cache' ); |
|
| 2437 |
|
/** detect first visit */ |
| 2438 |
|
$mainframe->detect(); |
| 2439 |
|
|
| 2440 |
|
/** @global mosPlugin $_MAMBOTS */ |
| 2441 |
|
$_MAMBOTS = mosMambotHandler::getInstance(); |
| 2442 |
|
require_once( $configuration->rootPath().'/editor/editor.php' ); |
| 2443 |
|
require_once( $configuration->rootPath() . '/includes/gacl.class.php' ); |
| 2444 |
|
require_once( $configuration->rootPath() . '/includes/gacl_api.class.php' ); |
| 2445 |
|
$acl = new gacl_api(); |
| 2446 |
|
|
| 2447 |
|
/** Get the component handler */ |
| 2448 |
|
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
| 2449 |
|
$c_handler = mosComponentHandler::getInstance(); |
| 2450 |
|
$c_handler->startBuffer(); |
| 2451 |
|
|
| 2452 |
|
if (!$urlerror AND $path = $mainframe->getPath( 'front' )) { |
| 2453 |
|
$menuhandler = mosMenuHandler::getInstance(); |
| 2454 |
|
$ret = $menuhandler->menuCheck($Itemid, $option, $task, $gid); |
| 2455 |
|
$menuhandler->setPathway($Itemid); |
| 2456 |
|
if ($ret) require_once( $path ); |
| 2457 |
|
else mosNotAuth(); |
| 2458 |
|
} |
| 2459 |
|
else { |
| 2460 |
|
header ('HTTP/1.1 404 Not Found'); |
| 2461 |
|
$mainframe->setPageTitle(T_('404 Error - page not found')); |
| 2462 |
|
include ($configuration->rootPath().'/page404.php'); |
| 2463 |
|
} |
| 2464 |
|
|
| 2465 |
|
$c_handler->endBuffer(); |
| 2466 |
|
|
| 2467 |
|
$configuration->initGzip(); |
| 2468 |
|
|
| 2469 |
|
$configuration->standardHeaders(); |
| 2470 |
|
if ($indextype == 1) { |
| 2471 |
// loads template file |
// loads template file |
| 2472 |
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { |
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { |
| 2473 |
echo _TEMPLATE_WARN . $cur_template; |
echo '<font color=\"red\"><b>'.T_('Template File Not Found! Looking for template').'</b></font>'.$cur_template; |
| 2474 |
} else { |
} else { |
| 2475 |
require_once( 'templates/'. $cur_template .'/index.php' ); |
require_once( 'templates/'. $cur_template .'/index.php' ); |
| 2476 |
|
$mambothandler = mosMambotHandler::getInstance(); |
| 2477 |
|
$mambothandler->loadBotGroup('system'); |
| 2478 |
|
$mambothandler->trigger('afterTemplate', array($configuration)); |
| 2479 |
echo "<!-- ".time()." -->"; |
echo "<!-- ".time()." -->"; |
| 2480 |
} |
} |
|
|
|
|
// displays queries performed for page |
|
|
if ($mosConfig_debug) { |
|
|
echo $database->_ticker . ' queries executed'; |
|
|
echo '<pre>'; |
|
|
foreach ($database->_log as $k=>$sql) { |
|
|
echo $k+1 . "\n" . $sql . '<hr />'; |
|
| 2481 |
} |
} |
| 2482 |
|
elseif ($indextype == 2) { |
| 2483 |
|
if ( $no_html == 0 ) { |
| 2484 |
|
// needed to seperate the ISO number from the language file constant _ISO |
| 2485 |
|
$iso = split( '=', _ISO ); |
| 2486 |
|
// xml prolog |
| 2487 |
|
echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>'; |
| 2488 |
|
?> |
| 2489 |
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2490 |
|
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 2491 |
|
<head> |
| 2492 |
|
<link rel="stylesheet" href="templates/<?php echo $cur_template;?>/css/template_css.css" type="text/css" /> |
| 2493 |
|
<meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" /> |
| 2494 |
|
<meta name="robots" content="noindex, nofollow"> |
| 2495 |
|
</head> |
| 2496 |
|
<body class="contentpane"> |
| 2497 |
|
<?php mosMainBody(); ?> |
| 2498 |
|
</body> |
| 2499 |
|
</html> |
| 2500 |
|
<?php |
| 2501 |
|
} else { |
| 2502 |
|
mosMainBody(); |
| 2503 |
|
} |
| 2504 |
|
} |
| 2505 |
|
|
| 2506 |
|
$configuration->doGzip(); |
| 2507 |
} |
} |
| 2508 |
|
// displays queries performed for page |
| 2509 |
|
if ($configuration->get('mosConfig_debug')) $database->displayLogged(); |
| 2510 |
|
|
|
doGzip(); |
|
| 2511 |
?> |
?> |