| 1 |
<?php |
<?php |
| 2 |
|
/** |
| 3 |
|
* @package Mambo Open Source |
| 4 |
|
* @copyright (C) 2005 - 2006 Mambo Foundation Inc. |
| 5 |
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 6 |
|
* |
| 7 |
|
* Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure |
| 8 |
|
* that Mambo remained free Open Source software owned and managed by the community. |
| 9 |
|
* Mambo is Free Software |
| 10 |
|
*/ |
| 11 |
|
|
| 12 |
/** |
/** |
| 13 |
* Mambo basic error object |
* Mambo basic error object |
| 225 |
function mamboCore () { |
function mamboCore () { |
| 226 |
global $adminside; |
global $adminside; |
| 227 |
$this->init_errorlevel = error_reporting(0); |
$this->init_errorlevel = error_reporting(0); |
| 228 |
$this->rootPath = str_replace('\\', '/', str_replace('includes', '', realpath(dirname(__FILE__)))); |
//$this->rootPath = str_replace('\\', '/', realpath(str_replace('includes', '', dirname(__FILE__)))); |
| 229 |
|
$this->rootPath = str_replace('\\', '/',str_replace('includes', '', dirname(__FILE__))); |
| 230 |
$this->checkConfig(); |
$this->checkConfig(); |
| 231 |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 232 |
$this->getConfig(); |
$this->getConfig(); |
| 253 |
* @return unknown |
* @return unknown |
| 254 |
*/ |
*/ |
| 255 |
function rootPath () { |
function rootPath () { |
| 256 |
if (realpath($this->rootPath) === false) die ('Invalid program load path'); |
//if (realpath($this->rootPath) === false) die ('Invalid program load path'); |
| 257 |
|
if (file_exists($this->rootPath) === false) die ('Invalid program load path'); |
| 258 |
return $this->rootPath; |
return $this->rootPath; |
| 259 |
} |
} |
| 260 |
|
|
| 267 |
function get ($property) { |
function get ($property) { |
| 268 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 269 |
if ($property == 'mosConfig_absolute_path') { |
if ($property == 'mosConfig_absolute_path') { |
| 270 |
if (realpath($config->mosConfig_absolute_path) === false) die ('Invalid program load path'); |
//if (realpath($config->mosConfig_absolute_path) === false) die ('Invalid program load path'); |
| 271 |
|
if (file_exists($config->mosConfig_absolute_path) === false) die ('Invalid program load path'); |
| 272 |
else return $config->rootPath; |
else return $config->rootPath; |
| 273 |
} |
} |
| 274 |
if (isset($config->$property)) return $config->$property; |
if (isset($config->$property)) return $config->$property; |
| 323 |
$f = @fopen($this->rootPath.'/configuration.php','rb'); |
$f = @fopen($this->rootPath.'/configuration.php','rb'); |
| 324 |
if ($f) { |
if ($f) { |
| 325 |
while ($f AND !feof($f)) { |
while ($f AND !feof($f)) { |
| 326 |
$line = fgets($f, 256); |
$line = fgets($f); |
| 327 |
$altered = str_replace('$', '$this->', $line); |
$altered = str_replace('$', '$this->', $line); |
| 328 |
if ($altered != $line) $code .= $altered; |
if ($altered != $line) $code .= $altered; |
| 329 |
} |
} |
| 350 |
$mamboroot = str_replace('\\', '/', rtrim($this->rootPath, '\/')); |
$mamboroot = str_replace('\\', '/', rtrim($this->rootPath, '\/')); |
| 351 |
$this->subdirectory = substr($mamboroot, strlen($docroot)); |
$this->subdirectory = substr($mamboroot, strlen($docroot)); |
| 352 |
|
|
|
|
|
| 353 |
$scheme = isset($_SERVER['HTTP_SCHEME']) ? $_SERVER['HTTP_SCHEME'] : ((isset($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS'] != 'off')) ? 'https' : 'http'); |
$scheme = isset($_SERVER['HTTP_SCHEME']) ? $_SERVER['HTTP_SCHEME'] : ((isset($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS'] != 'off')) ? 'https' : 'http'); |
| 354 |
if (isset($_SERVER['HTTP_HOST'])) { |
if (isset($_SERVER['HTTP_HOST'])) { |
| 355 |
$withport = explode(':', $_SERVER['HTTP_HOST']); |
$withport = explode(':', $_SERVER['HTTP_HOST']); |
| 364 |
} |
} |
| 365 |
else $port = ''; |
else $port = ''; |
| 366 |
$afterscheme = '://'.$servername.$port.$this->subdirectory; |
$afterscheme = '://'.$servername.$port.$this->subdirectory; |
| 367 |
$this->mosConfig_live_site = $this->mosConfig_secure_site = $scheme.$afterscheme; |
//$this->mosConfig_live_site = $this->mosConfig_secure_site = $scheme.$afterscheme; |
| 368 |
$this->mosConfig_unsecure_site = 'http'.$afterscheme; |
$this->mosConfig_unsecure_site = 'http'.$afterscheme; |
| 369 |
$this->mosConfig_absolute_path = $this->rootPath; |
$this->mosConfig_absolute_path = $this->rootPath; |
| 370 |
preg_match_all('/\$this\-\>([A-Za-z_][A-Za-z0-9_]*)/', $code, $matches); |
preg_match_all('/\$this\-\>([A-Za-z_][A-Za-z0-9_]*)/', $code, $matches); |
| 417 |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
| 418 |
require_once($this->mosConfig_absolute_path.'/includes/mambofunc.php'); |
require_once($this->mosConfig_absolute_path.'/includes/mambofunc.php'); |
| 419 |
require_once($this->mosConfig_absolute_path.'/includes/mambolanguage.class.php'); |
require_once($this->mosConfig_absolute_path.'/includes/mambolanguage.class.php'); |
| 420 |
error_reporting(E_ALL) ; |
#error_reporting(E_ALL) ; |
| 421 |
########## DEPRECATED ############ |
########## DEPRECATED ############ |
| 422 |
if (isset($this->mosConfig_lang) AND $this->mosConfig_lang); |
if (isset($this->mosConfig_lang) AND $this->mosConfig_lang); |
| 423 |
else $this->set('mosConfig_lang', 'english'); |
else $this->set('mosConfig_lang', 'english'); |
| 426 |
################################### |
################################### |
| 427 |
|
|
| 428 |
|
|
| 429 |
$this->mosConfig_lang = mosGetParam($_POST, 'setLanguage', $this->mosConfig_lang); |
$this->mosConfig_locale = mosGetParam($_POST, 'lang', $this->mosConfig_locale); |
|
|
|
| 430 |
|
|
| 431 |
$language =& mamboLanguage::getInstance($this->mosConfig_lang, $this->rootPath.'/language/'); |
$language =& new mamboLanguage($this->mosConfig_locale, $this->rootPath.'/language/'); |
| 432 |
$languages = $language->getLanguages(); |
$languages = $language->getLanguages(); |
| 433 |
$charset = $language->get('charset'); |
$charset = $language->get('charset'); |
| 434 |
$dateformat = $language->get('dateformat'); |
$dateformat = $language->get('dateformat'); |
| 435 |
|
$this->mosConfig_lang = $language->get('lang'); |
| 436 |
$this->current_language = $language; |
$this->current_language = $language; |
| 437 |
if (!defined('_ISO')) DEFINE('_ISO','charset='.$charset); |
if (!defined('_ISO')) DEFINE('_ISO','charset='.$charset); |
| 438 |
if (!defined('_DATE_FORMAT_LC')) DEFINE('_DATE_FORMAT_LC', $dateformat); //Uses PHP's strftime Command Format |
if (!defined('_DATE_FORMAT_LC')) DEFINE('_DATE_FORMAT_LC', $dateformat); //Uses PHP's strftime Command Format |
| 439 |
if (!defined('_DATE_FORMAT_LC2')) DEFINE('_DATE_FORMAT_LC2', $dateformat); |
if (!defined('_DATE_FORMAT_LC2')) DEFINE('_DATE_FORMAT_LC2', $dateformat); |
| 440 |
|
|
| 441 |
$gettext =& phpgettext(); |
|
|
$gettext->debug = $this->mosConfig_locale_debug; |
|
|
$gettext->has_gettext = $this->mosConfig_locale_use_gettext; |
|
|
$gettext->setlocale($this->mosConfig_lang); |
|
| 442 |
} |
} |
| 443 |
|
|
| 444 |
/** |
/** |
| 463 |
foreach ( $superglobals as $superglobal ) { |
foreach ( $superglobals as $superglobal ) { |
| 464 |
foreach ( $superglobal as $key => $value) { |
foreach ( $superglobal as $key => $value) { |
| 465 |
unset( $GLOBALS[$key]); |
unset( $GLOBALS[$key]); |
| 466 |
|
unset( $GLOBALS[$key]); |
| 467 |
} |
} |
| 468 |
} |
} |
| 469 |
} |
} |
| 487 |
if ($pos !== false) $link = substr( $link, $pos+1 ). '&Itemid='.$this->Itemid; |
if ($pos !== false) $link = substr( $link, $pos+1 ). '&Itemid='.$this->Itemid; |
| 488 |
parse_str( $link, $temp ); |
parse_str( $link, $temp ); |
| 489 |
/** this is a patch, need to rework when globals are handled better */ |
/** this is a patch, need to rework when globals are handled better */ |
| 490 |
foreach ($temp as $k=>$v) $_GET[$k] = $v; |
foreach ($temp as $k=>$v) $_GET[$k] = $_REQUEST[$k] = $v; |
| 491 |
if (isset($temp['option'])) $option = $temp['option']; |
if (isset($temp['option'])) $option = $temp['option']; |
| 492 |
else return ''; |
else return ''; |
| 493 |
} |
} |
| 571 |
require_once($this->rootPath().'/includes/authenticator.php'); |
require_once($this->rootPath().'/includes/authenticator.php'); |
| 572 |
$authenticator =& mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 573 |
$loggedin = $authenticator->loginUser(); |
$loggedin = $authenticator->loginUser(); |
| 574 |
if ($loggedin) $this->logMessage(_LOGIN_SUCCESS); |
if ($loggedin) $this->logMessage('_LOGIN_SUCCESS'); |
| 575 |
else mamboCore::redirect('index.php'); |
else mamboCore::redirect('index.php'); |
| 576 |
} |
} |
| 577 |
|
|
| 583 |
require_once($this->rootPath().'/includes/authenticator.php'); |
require_once($this->rootPath().'/includes/authenticator.php'); |
| 584 |
$authenticator =& mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 585 |
$authenticator->logoutUser(); |
$authenticator->logoutUser(); |
| 586 |
$this->logMessage(_LOGOUT_SUCCESS); |
$this->logMessage('_LOGOUT_SUCCESS'); |
| 587 |
} |
} |
| 588 |
|
|
| 589 |
/** |
/** |
| 811 |
* Make a pathway string for display |
* Make a pathway string for display |
| 812 |
*/ |
*/ |
| 813 |
function makePathway () { |
function makePathway () { |
|
$last = count($this->_names) - 1; |
|
|
if ($last == 0) return ''; |
|
| 814 |
$mainframe =& mosMainFrame::getInstance(); |
$mainframe =& mosMainFrame::getInstance(); |
| 815 |
|
$customs = $mainframe->getCustomPathWay(); |
| 816 |
|
$last = count($this->_names) - 1; |
| 817 |
|
if ($last == 0 AND count($customs == 0)) return ''; |
| 818 |
$result = "<span class='pathway'>"; |
$result = "<span class='pathway'>"; |
| 819 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 820 |
$rootpath = $config->rootPath(); |
$rootpath = $config->rootPath(); |
| 826 |
else $img = '>'; |
else $img = '>'; |
| 827 |
} |
} |
| 828 |
foreach ($this->_names as $i=>$name) { |
foreach ($this->_names as $i=>$name) { |
| 829 |
if ($i === $last) $result .= "$name</span>"; |
if ($i === $last AND count($customs) == 0) $result .= "$name</span>"; |
| 830 |
|
elseif (strstr($this->_urls[$i], 'view')) $result .= ""; |
| 831 |
else { |
else { |
| 832 |
$sefurl = sefRelToAbs($this->_urls[$i]); |
$sefurl = sefRelToAbs($this->_urls[$i]); |
| 833 |
$result .= "<a href='$sefurl' class='pathway'>$name</a>"; |
$result .= "<a href='$sefurl' class='pathway'>$name</a>"; |
| 834 |
$result .= " $img "; |
$result .= " $img "; |
| 835 |
} |
} |
| 836 |
} |
} |
|
$customs = $mainframe->getCustomPathWay(); |
|
| 837 |
foreach ($customs as $custom) $result .= $custom; |
foreach ($customs as $custom) $result .= $custom; |
| 838 |
$result .= '</span>'; |
if (count($customs)) $result .= '</span>'; |
| 839 |
return $result; |
return $result; |
| 840 |
} |
} |
| 841 |
|
|
| 1874 |
$selected = $newbot->register(); |
$selected = $newbot->register(); |
| 1875 |
$this->_botRegister($newbot, $selected, $i); |
$this->_botRegister($newbot, $selected, $i); |
| 1876 |
} |
} |
| 1877 |
|
unset($newbot); |
| 1878 |
} |
} |
| 1879 |
} |
} |
| 1880 |
$total++; |
$total++; |
| 2040 |
* @return boolean True is satisfactory |
* @return boolean True is satisfactory |
| 2041 |
*/ |
*/ |
| 2042 |
function check() { |
function check() { |
| 2043 |
|
Global $mosConfig_absolute_path; |
| 2044 |
|
include $mosConfig_absolute_path . ('/language/english.php'); |
| 2045 |
$this->_error = ''; |
$this->_error = ''; |
| 2046 |
if ($this->name == '') $this->_error = _REGWARN_NAME; |
if ($this->name == '') $this->_error = _REGWARN_NAME; |
| 2047 |
elseif ($this->username == '') $this->_error = _REGWARN_UNAME; |
elseif ($this->username == '') $this->_error = _REGWARN_UNAME; |
| 2212 |
} |
} |
| 2213 |
|
|
| 2214 |
/** |
/** |
| 2215 |
* Singleton get instance |
* @param object |
|
* @param object the mainframe instance (if called internally) |
|
|
* Note that because of the need for creation parameters, this cannot |
|
|
* be called successfully unless the mainframe object is already created |
|
| 2216 |
*/ |
*/ |
| 2217 |
function &getInstance () { |
function &getInstance () { |
| 2218 |
static $mainframe; |
global $mainframe; |
| 2219 |
if (func_num_args()) { |
if (isset($mainframe)) { |
| 2220 |
$args = func_get_args(); |
return $mainframe; |
| 2221 |
$mainframe = $args[0]; |
} else { |
| 2222 |
} |
$result = null; |
|
if (isset($mainframe)) $result =& $mainframe; |
|
|
else $result = null; |
|
| 2223 |
return $result; |
return $result; |
| 2224 |
} |
} |
| 2225 |
|
} |
| 2226 |
|
|
| 2227 |
/** |
/** |
| 2228 |
* @param string |
* @param string |
| 2229 |
*/ |
*/ |
| 2345 |
* @param string The default value for the variable if not found |
* @param string The default value for the variable if not found |
| 2346 |
*/ |
*/ |
| 2347 |
function getUserStateFromRequest( $var_name, $req_name, $var_default=null ) { |
function getUserStateFromRequest( $var_name, $req_name, $var_default=null ) { |
| 2348 |
|
if (is_array($this->_userstate)) { |
| 2349 |
if (isset($_REQUEST[$req_name])) $this->setUserState($var_name, $_REQUEST[$req_name]); |
if (isset($_REQUEST[$req_name])) $this->setUserState($var_name, $_REQUEST[$req_name]); |
| 2350 |
elseif (isset($var_default) AND !isset($this->userstate[$var_name])) $this->setUserState($var_name, $var_default); |
else if (isset($var_default) AND !isset($this->_userstate[$var_name])) $this->setUserState($var_name, $var_default); |
| 2351 |
return $this->getUserState($var_name); |
return $this->_userstate[$var_name]; |
| 2352 |
|
} else { |
| 2353 |
|
return null; |
| 2354 |
|
} |
| 2355 |
} |
} |
| 2356 |
/** |
/** |
| 2357 |
* Initialises the user session |
* Initialises the user session |
| 2535 |
|
|
| 2536 |
function liveBookMark () { |
function liveBookMark () { |
| 2537 |
// support for Firefox Live Bookmarks ability for site syndication |
// support for Firefox Live Bookmarks ability for site syndication |
| 2538 |
|
$live_bookmark = 0; |
| 2539 |
$c_handler =& mosComponentHandler::getInstance(); |
$c_handler =& mosComponentHandler::getInstance(); |
| 2540 |
$params = $c_handler->getParamsByName('Syndicate'); |
$params =& $c_handler->getParamsByName('Syndicate'); |
| 2541 |
|
if (!is_null($params)){ |
| 2542 |
$live_bookmark = $params->get( 'live_bookmark', 0 ); |
$live_bookmark = $params->get( 'live_bookmark', 0 ); |
| 2543 |
|
} |
| 2544 |
|
|
| 2545 |
if ($live_bookmark) { |
if ($live_bookmark) { |
| 2546 |
// custom bookmark file name |
// custom bookmark file name |
| 2547 |
$bookmark_file = $params->get( 'bookmark_file', $live_bookmark ); |
$bookmark_file = $params->get( 'bookmark_file', $live_bookmark ); |
| 2588 |
<?php |
<?php |
| 2589 |
} |
} |
| 2590 |
|
|
| 2591 |
|
|
| 2592 |
|
/** |
| 2593 |
|
* retained for backward compatability |
| 2594 |
|
*/ |
| 2595 |
|
function getBlogSectionCount() { |
| 2596 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2597 |
|
$handler =& new contentHandler(); |
| 2598 |
|
return $handler->getBlogSectionCount(); |
| 2599 |
|
} |
| 2600 |
|
|
| 2601 |
|
function getBlogCategoryCount() { |
| 2602 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2603 |
|
$handler =& new contentHandler(); |
| 2604 |
|
return $handler->getBlogCategoryCount(); |
| 2605 |
|
} |
| 2606 |
|
|
| 2607 |
|
function getGlobalBlogSectionCount() { |
| 2608 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2609 |
|
$handler =& new contentHandler(); |
| 2610 |
|
return $handler->getGlobalBlogSectionCount(); |
| 2611 |
|
} |
| 2612 |
|
|
| 2613 |
|
function getStaticContentCount() { |
| 2614 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2615 |
|
$handler =& new contentHandler(); |
| 2616 |
|
return $handler->getStaticContentCount(); |
| 2617 |
|
} |
| 2618 |
|
|
| 2619 |
|
function getContentItemLinkCount() { |
| 2620 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2621 |
|
$handler =& new contentHandler(); |
| 2622 |
|
return $handler->getContentItemLinkCount(); |
| 2623 |
|
} |
| 2624 |
|
/** |
| 2625 |
|
* retained for backward compatability |
| 2626 |
|
*/ |
| 2627 |
|
|
| 2628 |
} |
} |
| 2629 |
|
|
| 2630 |
/** |
/** |