| 10 |
define ('_MOS_ERROR_SEVERE', 2); |
define ('_MOS_ERROR_SEVERE', 2); |
| 11 |
define ('_MOS_ERROR_FATAL', 3); |
define ('_MOS_ERROR_FATAL', 3); |
| 12 |
|
|
| 13 |
|
/** |
| 14 |
|
* Enter description here... |
| 15 |
|
* |
| 16 |
|
*/ |
| 17 |
class mosError { |
class mosError { |
| 18 |
|
/** |
| 19 |
|
* Enter description here... |
| 20 |
|
* |
| 21 |
|
* @var unknown_type |
| 22 |
|
*/ |
| 23 |
var $text = ''; |
var $text = ''; |
| 24 |
|
/** |
| 25 |
|
* Enter description here... |
| 26 |
|
* |
| 27 |
|
* @var unknown_type |
| 28 |
|
*/ |
| 29 |
var $level = 0; |
var $level = 0; |
| 30 |
|
|
| 31 |
|
/** |
| 32 |
|
* Enter description here... |
| 33 |
|
* |
| 34 |
|
* @param unknown_type $text |
| 35 |
|
* @param unknown_type $level |
| 36 |
|
* @return mosError |
| 37 |
|
*/ |
| 38 |
function mosError ($text='', $level=_MOS_ERROR_INFORM) { |
function mosError ($text='', $level=_MOS_ERROR_INFORM) { |
| 39 |
$this->text = $text; |
$this->text = $text; |
| 40 |
$this->level = $level; |
$this->level = $level; |
| 45 |
* Mambo group of errors for some particular operation |
* Mambo group of errors for some particular operation |
| 46 |
*/ |
*/ |
| 47 |
class mosErrorSet { |
class mosErrorSet { |
| 48 |
|
/** |
| 49 |
|
* Enter description here... |
| 50 |
|
* |
| 51 |
|
* @var unknown_type |
| 52 |
|
*/ |
| 53 |
var $errors = array(); |
var $errors = array(); |
| 54 |
|
/** |
| 55 |
|
* Enter description here... |
| 56 |
|
* |
| 57 |
|
* @var unknown_type |
| 58 |
|
*/ |
| 59 |
var $maxlevel = 0; |
var $maxlevel = 0; |
| 60 |
|
|
| 61 |
// Parameter is an error object |
// Parameter is an error object |
| 62 |
|
/** |
| 63 |
|
* Enter description here... |
| 64 |
|
* |
| 65 |
|
* @param unknown_type $error |
| 66 |
|
*/ |
| 67 |
function addError ($error) { |
function addError ($error) { |
| 68 |
$this->errors[] = $error; |
$this->errors[] = $error; |
| 69 |
if ($error->level > $this->maxlevel) $this->maxlevel = $error->level; |
if ($error->level > $this->maxlevel) $this->maxlevel = $error->level; |
| 70 |
} |
} |
| 71 |
|
|
| 72 |
|
/** |
| 73 |
|
* Enter description here... |
| 74 |
|
* |
| 75 |
|
* @param unknown_type $text |
| 76 |
|
* @param unknown_type $level |
| 77 |
|
*/ |
| 78 |
function addErrorDetails ($text='', $level=_MOS_ERROR_INFORM) { |
function addErrorDetails ($text='', $level=_MOS_ERROR_INFORM) { |
| 79 |
$error = new mosError($text, $level); |
$error = new mosError($text, $level); |
| 80 |
$this->addError($error); |
$this->addError($error); |
| 81 |
} |
} |
| 82 |
|
|
| 83 |
|
/** |
| 84 |
|
* Enter description here... |
| 85 |
|
* |
| 86 |
|
* @return unknown |
| 87 |
|
*/ |
| 88 |
function &getErrors () { |
function &getErrors () { |
| 89 |
return $this->errors; |
return $this->errors; |
| 90 |
} |
} |
| 91 |
|
|
| 92 |
|
/** |
| 93 |
|
* Enter description here... |
| 94 |
|
* |
| 95 |
|
* @return unknown |
| 96 |
|
*/ |
| 97 |
function getMaxLevel () { |
function getMaxLevel () { |
| 98 |
return $this->maxlevel; |
return $this->maxlevel; |
| 99 |
} |
} |
| 100 |
|
|
| 101 |
|
/** |
| 102 |
|
* Enter description here... |
| 103 |
|
* |
| 104 |
|
* @return unknown |
| 105 |
|
*/ |
| 106 |
function getCount () { |
function getCount () { |
| 107 |
return count($this->errors); |
return count($this->errors); |
| 108 |
} |
} |
| 109 |
|
|
| 110 |
|
/** |
| 111 |
|
* Enter description here... |
| 112 |
|
* |
| 113 |
|
* @param unknown_type $errorset |
| 114 |
|
*/ |
| 115 |
function mergeAnother ($errorset) { |
function mergeAnother ($errorset) { |
| 116 |
$this->errors = array_merge($this->errors, $errorset->errors); |
$this->errors = array_merge($this->errors, $errorset->errors); |
| 117 |
} |
} |
| 119 |
} |
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
/** |
| 123 |
|
* Enter description here... |
| 124 |
|
* |
| 125 |
|
*/ |
| 126 |
class mamboCore { |
class mamboCore { |
| 127 |
|
/** |
| 128 |
|
* Enter description here... |
| 129 |
|
* |
| 130 |
|
* @var unknown_type |
| 131 |
|
*/ |
| 132 |
var $rootPath = ''; |
var $rootPath = ''; |
| 133 |
|
/** |
| 134 |
|
* Enter description here... |
| 135 |
|
* |
| 136 |
|
* @var unknown_type |
| 137 |
|
*/ |
| 138 |
var $Itemid = 0; |
var $Itemid = 0; |
| 139 |
|
/** |
| 140 |
|
* Enter description here... |
| 141 |
|
* |
| 142 |
|
* @var unknown_type |
| 143 |
|
*/ |
| 144 |
var $option = ''; |
var $option = ''; |
| 145 |
|
/** |
| 146 |
|
* Enter description here... |
| 147 |
|
* |
| 148 |
|
* @var unknown_type |
| 149 |
|
*/ |
| 150 |
var $subdirectory; |
var $subdirectory; |
| 151 |
|
/** |
| 152 |
|
* Enter description here... |
| 153 |
|
* |
| 154 |
|
* @var unknown_type |
| 155 |
|
*/ |
| 156 |
var $current_user = null; |
var $current_user = null; |
| 157 |
|
/** |
| 158 |
|
* Enter description here... |
| 159 |
|
* |
| 160 |
|
* @var unknown_type |
| 161 |
|
*/ |
| 162 |
var $do_gzip_compress = false; |
var $do_gzip_compress = false; |
| 163 |
|
/** |
| 164 |
|
* Enter description here... |
| 165 |
|
* |
| 166 |
|
* @var unknown_type |
| 167 |
|
*/ |
| 168 |
var $init_errorlevel = 0; |
var $init_errorlevel = 0; |
| 169 |
|
|
| 170 |
|
/** |
| 171 |
|
* Enter description here... |
| 172 |
|
* |
| 173 |
|
* @return mamboCore |
| 174 |
|
*/ |
| 175 |
function mamboCore () { |
function mamboCore () { |
| 176 |
global $adminside; |
global $adminside; |
| 177 |
$this->init_errorlevel = error_reporting(0); |
$this->init_errorlevel = error_reporting(0); |
| 178 |
$this->rootPath = str_replace('\\', '/', realpath('../')); |
$this->rootPath = str_replace('\\', '/', str_replace('includes', '', realpath(dirname(__FILE__)))); |
| 179 |
$this->checkConfig(); |
$this->checkConfig(); |
| 180 |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 181 |
$this->getConfig(); |
$this->getConfig(); |
| 185 |
else error_reporting($this->init_errorlevel); |
else error_reporting($this->init_errorlevel); |
| 186 |
} |
} |
| 187 |
|
|
| 188 |
|
/** |
| 189 |
|
* Enter description here... |
| 190 |
|
* |
| 191 |
|
* @return unknown |
| 192 |
|
*/ |
| 193 |
function &getMamboCore () { |
function &getMamboCore () { |
| 194 |
static $instance; |
static $instance; |
| 195 |
if (!is_object($instance)) $instance = new mamboCore(); |
if (!is_object($instance)) $instance = new mamboCore(); |
| 196 |
return $instance; |
return $instance; |
| 197 |
} |
} |
| 198 |
|
|
| 199 |
|
/** |
| 200 |
|
* Enter description here... |
| 201 |
|
* |
| 202 |
|
* @return unknown |
| 203 |
|
*/ |
| 204 |
function rootPath () { |
function rootPath () { |
| 205 |
if (realpath($this->rootPath) === false) die ('Invalid program load path'); |
if (realpath($this->rootPath) === false) die ('Invalid program load path'); |
| 206 |
return $this->rootPath; |
return $this->rootPath; |
| 207 |
} |
} |
| 208 |
|
|
| 209 |
|
/** |
| 210 |
|
* Enter description here... |
| 211 |
|
* |
| 212 |
|
* @param unknown_type $property |
| 213 |
|
* @return unknown |
| 214 |
|
*/ |
| 215 |
function get ($property) { |
function get ($property) { |
| 216 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 217 |
if ($property == 'mosConfig_absolute_path') { |
if ($property == 'mosConfig_absolute_path') { |
| 223 |
return null; |
return null; |
| 224 |
} |
} |
| 225 |
|
|
| 226 |
|
/** |
| 227 |
|
* Enter description here... |
| 228 |
|
* |
| 229 |
|
* @param unknown_type $property |
| 230 |
|
* @return unknown |
| 231 |
|
*/ |
| 232 |
function is_set ($property) { |
function is_set ($property) { |
| 233 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 234 |
return isset($config->$property); |
return isset($config->$property); |
| 235 |
} |
} |
| 236 |
|
|
| 237 |
|
/** |
| 238 |
|
* Enter description here... |
| 239 |
|
* |
| 240 |
|
* @param unknown_type $property |
| 241 |
|
* @param unknown_type $value |
| 242 |
|
* @return unknown |
| 243 |
|
*/ |
| 244 |
function set ($property, $value) { |
function set ($property, $value) { |
| 245 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 246 |
$config->$property = $value; |
$config->$property = $value; |
| 248 |
return $value; |
return $value; |
| 249 |
} |
} |
| 250 |
|
|
| 251 |
|
/** |
| 252 |
|
* Enter description here... |
| 253 |
|
* |
| 254 |
|
*/ |
| 255 |
function checkConfig () { |
function checkConfig () { |
| 256 |
// checks for configuration file, if none found loads installation page |
// checks for configuration file, if none found loads installation page |
| 257 |
if (!file_exists($this->rootPath.'/configuration.php') OR filesize($this->rootPath.'/configuration.php') < 10 ) { |
if (!file_exists($this->rootPath.'/configuration.php') OR filesize($this->rootPath.'/configuration.php') < 10 ) { |
| 258 |
header( 'Location: installation/index.php' ); |
#header( 'Location: installation/index.php' ); |
| 259 |
exit(); |
exit(); |
| 260 |
} |
} |
| 261 |
} |
} |
| 262 |
|
|
| 263 |
|
/** |
| 264 |
|
* Enter description here... |
| 265 |
|
* |
| 266 |
|
*/ |
| 267 |
function getConfig () { |
function getConfig () { |
| 268 |
global $adminside; |
global $adminside; |
| 269 |
$code = ''; |
$code = ''; |
| 276 |
} |
} |
| 277 |
} |
} |
| 278 |
else { |
else { |
| 279 |
header( 'Location: installation/index.php' ); |
#header( 'Location: installation/index.php' ); |
| 280 |
exit(); |
exit(); |
| 281 |
} |
} |
| 282 |
fclose($f); |
fclose($f); |
| 283 |
eval($code); |
eval($code); |
| 284 |
if (isset($_SERVER['DOCUMENT_ROOT']) AND strlen($_SERVER['DOCUMENT_ROOT'])) $docroot = str_replace('\\', '/', str_replace('\\\\', '\\', $_SERVER['DOCUMENT_ROOT'])); |
|
| 285 |
|
|
| 286 |
|
if (isset($_SERVER['DOCUMENT_ROOT']) AND strlen($_SERVER['DOCUMENT_ROOT'])) { |
| 287 |
|
$docroot = str_replace('\\', '/', str_replace('\\\\', '\\', $_SERVER['DOCUMENT_ROOT'])); |
| 288 |
|
} |
| 289 |
else { |
else { |
| 290 |
// Find information about where execution started |
// Find information about where execution started |
| 291 |
$origin = array_pop(debug_backtrace()); |
$origin = array_pop(debug_backtrace()); |
| 294 |
$localpath = $_SERVER['PHP_SELF']; |
$localpath = $_SERVER['PHP_SELF']; |
| 295 |
$docroot = substr($absolutepath,0,strpos($absolutepath,$localpath)); |
$docroot = substr($absolutepath,0,strpos($absolutepath,$localpath)); |
| 296 |
} |
} |
| 297 |
$mamboroot = str_replace('\\', '/', dirname(__FILE__)); |
$mamboroot = str_replace('\\', '/', $this->rootPath); |
| 298 |
$this->subdirectory = substr($mamboroot, strlen($docroot)); |
$this->subdirectory = substr($mamboroot, strlen($docroot)); |
| 299 |
|
|
| 300 |
|
|
| 301 |
$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'); |
| 302 |
if (isset($_SERVER['HTTP_HOST'])) { |
if (isset($_SERVER['HTTP_HOST'])) { |
| 303 |
$withport = explode(':', $_SERVER['HTTP_HOST']); |
$withport = explode(':', $_SERVER['HTTP_HOST']); |
| 321 |
$this->mosConfig_register_globals = 0; |
$this->mosConfig_register_globals = 0; |
| 322 |
$GLOBALS['mosConfig_register_globals'] = 0; |
$GLOBALS['mosConfig_register_globals'] = 0; |
| 323 |
} |
} |
| 324 |
|
|
| 325 |
} |
} |
| 326 |
|
|
| 327 |
|
/** |
| 328 |
|
* Enter description here... |
| 329 |
|
* |
| 330 |
|
* @return unknown |
| 331 |
|
*/ |
| 332 |
function getFavIcon () { |
function getFavIcon () { |
| 333 |
// favourites icon |
// favourites icon |
| 334 |
if (!isset($this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
if (!isset($this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
| 336 |
return $this->mosConfig_live_site.'/images/'.$this->mosConfig_favicon; |
return $this->mosConfig_live_site.'/images/'.$this->mosConfig_favicon; |
| 337 |
} |
} |
| 338 |
|
|
| 339 |
|
/** |
| 340 |
|
* Enter description here... |
| 341 |
|
* |
| 342 |
|
* @param unknown_type $user |
| 343 |
|
* @param unknown_type $database |
| 344 |
|
*/ |
| 345 |
function offlineCheck (&$user, &$database) { |
function offlineCheck (&$user, &$database) { |
| 346 |
if ($this->mosConfig_offline OR file_exists($this->rootPath.'/installation/index.php')) { |
if ($this->mosConfig_offline OR file_exists($this->rootPath.'/installation/index.php')) { |
| 347 |
require_once($this->rootPath().'/administrator/includes/admin.php'); |
require_once($this->rootPath().'/administrator/includes/admin.php'); |
| 356 |
} |
} |
| 357 |
} |
} |
| 358 |
|
|
| 359 |
|
/** |
| 360 |
|
* Enter description here... |
| 361 |
|
* |
| 362 |
|
*/ |
| 363 |
function fixLanguage () { |
function fixLanguage () { |
| 364 |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
| 365 |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
| 392 |
$gettext->setlocale($this->mosConfig_lang); |
$gettext->setlocale($this->mosConfig_lang); |
| 393 |
} |
} |
| 394 |
|
|
| 395 |
|
/** |
| 396 |
|
* Enter description here... |
| 397 |
|
* |
| 398 |
|
*/ |
| 399 |
function handleGlobals () { |
function handleGlobals () { |
| 400 |
$superglobals = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET); |
$superglobals = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET); |
| 401 |
if (isset( $_SESSION )) array_unshift ( $superglobals , $_SESSION ); |
if (isset( $_SESSION )) array_unshift ( $superglobals , $_SESSION ); |
| 419 |
} |
} |
| 420 |
} |
} |
| 421 |
|
|
| 422 |
|
/** |
| 423 |
|
* Enter description here... |
| 424 |
|
* |
| 425 |
|
* @return unknown |
| 426 |
|
*/ |
| 427 |
function determineOptionAndItemid () { |
function determineOptionAndItemid () { |
| 428 |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 429 |
if ($option = strtolower(mosGetParam($_REQUEST, 'option'))); |
if ($option = strtolower(mosGetParam($_REQUEST, 'option'))); |
| 463 |
return $option; |
return $option; |
| 464 |
} |
} |
| 465 |
|
|
| 466 |
|
/** |
| 467 |
|
* Enter description here... |
| 468 |
|
* |
| 469 |
|
* @param unknown_type $url |
| 470 |
|
* @param unknown_type $msg |
| 471 |
|
*/ |
| 472 |
function redirect ($url, $msg='') { |
function redirect ($url, $msg='') { |
| 473 |
$callcheck = array('InputFilter', 'process'); |
$callcheck = array('InputFilter', 'process'); |
| 474 |
if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpInputFilter/class.inputfilter.php'); |
if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpInputFilter/class.inputfilter.php'); |
| 489 |
exit(); |
exit(); |
| 490 |
} |
} |
| 491 |
|
|
| 492 |
|
/** |
| 493 |
|
* Enter description here... |
| 494 |
|
* |
| 495 |
|
* @param unknown_type $text |
| 496 |
|
*/ |
| 497 |
function logMessage ($text) { |
function logMessage ($text) { |
| 498 |
// JS Popup message |
// JS Popup message |
| 499 |
if (mosGetParam( $_POST, 'message', 0 )) { |
if (mosGetParam( $_POST, 'message', 0 )) { |
| 513 |
} |
} |
| 514 |
} |
} |
| 515 |
|
|
| 516 |
|
/** |
| 517 |
|
* Enter description here... |
| 518 |
|
* |
| 519 |
|
*/ |
| 520 |
function handleLogin () { |
function handleLogin () { |
| 521 |
require_once($this->rootPath().'/includes/authenticator.php'); |
require_once($this->rootPath().'/includes/authenticator.php'); |
| 522 |
$authenticator =& mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 525 |
else mamboCore::redirect('index.php'); |
else mamboCore::redirect('index.php'); |
| 526 |
} |
} |
| 527 |
|
|
| 528 |
|
/** |
| 529 |
|
* Enter description here... |
| 530 |
|
* |
| 531 |
|
*/ |
| 532 |
function handleLogout () { |
function handleLogout () { |
| 533 |
require_once($this->rootPath().'/includes/authenticator.php'); |
require_once($this->rootPath().'/includes/authenticator.php'); |
| 534 |
$authenticator =& mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 536 |
$this->logMessage(_LOGOUT_SUCCESS); |
$this->logMessage(_LOGOUT_SUCCESS); |
| 537 |
} |
} |
| 538 |
|
|
| 539 |
|
/** |
| 540 |
|
* Enter description here... |
| 541 |
|
* |
| 542 |
|
*/ |
| 543 |
function standardHeaders () { |
function standardHeaders () { |
| 544 |
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); |
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); |
| 545 |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
| 551 |
$mambothandler->trigger('onHeaders', array($this)); |
$mambothandler->trigger('onHeaders', array($this)); |
| 552 |
} |
} |
| 553 |
|
|
| 554 |
|
/** |
| 555 |
|
* Enter description here... |
| 556 |
|
* |
| 557 |
|
*/ |
| 558 |
function initGzip() { |
function initGzip() { |
| 559 |
$this->do_gzip_compress = FALSE; |
$this->do_gzip_compress = FALSE; |
| 560 |
//zlib.output_compression and ob_gzhandler don't get along well so we'll check to make |
//zlib.output_compression and ob_gzhandler don't get along well so we'll check to make |
| 615 |
} |
} |
| 616 |
} |
} |
| 617 |
|
|
| 618 |
|
/** |
| 619 |
|
* Enter description here... |
| 620 |
|
* |
| 621 |
|
* @param unknown_type $separator |
| 622 |
|
* @param unknown_type $field |
| 623 |
|
* @return unknown |
| 624 |
|
*/ |
| 625 |
function getLastPart ($separator, $field) { |
function getLastPart ($separator, $field) { |
| 626 |
$parts = explode($separator, $field); |
$parts = explode($separator, $field); |
| 627 |
return $parts[count($parts)-1]; |
return $parts[count($parts)-1]; |
| 628 |
} |
} |
| 629 |
|
|
| 630 |
|
/** |
| 631 |
|
* Enter description here... |
| 632 |
|
* |
| 633 |
|
* @param unknown_type $separator |
| 634 |
|
* @param unknown_type $field |
| 635 |
|
* @return unknown |
| 636 |
|
*/ |
| 637 |
function allButLast ($separator, $field) { |
function allButLast ($separator, $field) { |
| 638 |
$lastSize = strlen(mamboCore::getLastPart($separator,$field)); |
$lastSize = strlen(mamboCore::getLastPart($separator,$field)); |
| 639 |
return substr($field, 0, strlen($field)-$lastSize); |
return substr($field, 0, strlen($field)-$lastSize); |
| 646 |
* Sorts an Array of objects |
* Sorts an Array of objects |
| 647 |
*/ |
*/ |
| 648 |
class mosObjectSorter { |
class mosObjectSorter { |
| 649 |
|
/** |
| 650 |
|
* Enter description here... |
| 651 |
|
* |
| 652 |
|
* @var unknown_type |
| 653 |
|
*/ |
| 654 |
var $_keyname = ''; |
var $_keyname = ''; |
| 655 |
|
/** |
| 656 |
|
* Enter description here... |
| 657 |
|
* |
| 658 |
|
* @var unknown_type |
| 659 |
|
*/ |
| 660 |
var $_direction = 0; |
var $_direction = 0; |
| 661 |
|
/** |
| 662 |
|
* Enter description here... |
| 663 |
|
* |
| 664 |
|
* @var unknown_type |
| 665 |
|
*/ |
| 666 |
var $_object_array = array(); |
var $_object_array = array(); |
| 667 |
|
|
| 668 |
|
/** |
| 669 |
|
* Enter description here... |
| 670 |
|
* |
| 671 |
|
* @param unknown_type $a |
| 672 |
|
* @param unknown_type $k |
| 673 |
|
* @param unknown_type $sort_direction |
| 674 |
|
* @return mosObjectSorter |
| 675 |
|
*/ |
| 676 |
function mosObjectSorter (&$a, $k, $sort_direction=1) { |
function mosObjectSorter (&$a, $k, $sort_direction=1) { |
| 677 |
$this->_keyname = $k; |
$this->_keyname = $k; |
| 678 |
$this->_direction = $sort_direction; |
$this->_direction = $sort_direction; |
| 680 |
$this->sort(); |
$this->sort(); |
| 681 |
} |
} |
| 682 |
|
|
| 683 |
|
/** |
| 684 |
|
* Enter description here... |
| 685 |
|
* |
| 686 |
|
* @param unknown_type $a |
| 687 |
|
* @param unknown_type $b |
| 688 |
|
* @return unknown |
| 689 |
|
*/ |
| 690 |
function mosObjectCompare (&$a, &$b) { |
function mosObjectCompare (&$a, &$b) { |
| 691 |
$key = $this->_keyname; |
$key = $this->_keyname; |
| 692 |
if ($a->$key > $b->$key) return $this->_direction; |
if ($a->$key > $b->$key) return $this->_direction; |
| 694 |
return 0; |
return 0; |
| 695 |
} |
} |
| 696 |
|
|
| 697 |
|
/** |
| 698 |
|
* Enter description here... |
| 699 |
|
* |
| 700 |
|
*/ |
| 701 |
function sort () { |
function sort () { |
| 702 |
usort($this->_object_array, array($this,'mosObjectCompare')); |
usort($this->_object_array, array($this,'mosObjectCompare')); |
| 703 |
} |
} |
| 746 |
$this->_urls[$last+1] = $url; |
$this->_urls[$last+1] = $url; |
| 747 |
} |
} |
| 748 |
|
|
| 749 |
|
/** |
| 750 |
|
* Enter description here... |
| 751 |
|
* |
| 752 |
|
*/ |
| 753 |
function reduceToOne () { |
function reduceToOne () { |
| 754 |
for ($i = count($this->_names) - 1; $i > 0; $i--) { |
for ($i = count($this->_names) - 1; $i > 0; $i--) { |
| 755 |
unset($this->_names[$i]); |
unset($this->_names[$i]); |
| 873 |
return $instance; |
return $instance; |
| 874 |
} |
} |
| 875 |
|
|
| 876 |
|
/** |
| 877 |
|
* Enter description here... |
| 878 |
|
* |
| 879 |
|
* @param unknown_type $file |
| 880 |
|
* @return unknown |
| 881 |
|
*/ |
| 882 |
function deleteFile ($file) { |
function deleteFile ($file) { |
| 883 |
if (file_exists($file)) { |
if (file_exists($file)) { |
| 884 |
@chmod($file, 0644); |
@chmod($file, 0644); |
| 887 |
return true; |
return true; |
| 888 |
} |
} |
| 889 |
|
|
| 890 |
|
/** |
| 891 |
|
* Enter description here... |
| 892 |
|
* |
| 893 |
|
* @param unknown_type $dir |
| 894 |
|
* @return unknown |
| 895 |
|
*/ |
| 896 |
function deleteDirectory ($dir) { |
function deleteDirectory ($dir) { |
| 897 |
if (file_exists($dir)) { |
if (file_exists($dir)) { |
| 898 |
if (is_dir($dir)) { |
if (is_dir($dir)) { |
| 904 |
return true; |
return true; |
| 905 |
} |
} |
| 906 |
|
|
| 907 |
|
/** |
| 908 |
|
* Enter description here... |
| 909 |
|
* |
| 910 |
|
* @param unknown_type $fileSysObject |
| 911 |
|
*/ |
| 912 |
function setPermissions ($fileSysObject) { |
function setPermissions ($fileSysObject) { |
| 913 |
if (file_exists($fileSysObject)) { |
if (file_exists($fileSysObject)) { |
| 914 |
if (is_dir($fileSysObject)) $perms = mamboCore::get('mosConfig_dirperms'); |
if (is_dir($fileSysObject)) $perms = mamboCore::get('mosConfig_dirperms'); |
| 922 |
} |
} |
| 923 |
} |
} |
| 924 |
|
|
| 925 |
|
/** |
| 926 |
|
* Enter description here... |
| 927 |
|
* |
| 928 |
|
* @param unknown_type $dir |
| 929 |
|
* @return unknown |
| 930 |
|
*/ |
| 931 |
function makeDirectory ($dir) { |
function makeDirectory ($dir) { |
| 932 |
$perms = mamboCore::get('mosConfig_dirperms'); |
$perms = mamboCore::get('mosConfig_dirperms'); |
| 933 |
$origmask = @umask(0); |
$origmask = @umask(0); |
| 939 |
} |
} |
| 940 |
|
|
| 941 |
|
|
| 942 |
|
/** |
| 943 |
|
* Enter description here... |
| 944 |
|
* |
| 945 |
|
* @param unknown_type $dir |
| 946 |
|
* @param unknown_type $onlyCheck |
| 947 |
|
* @return unknown |
| 948 |
|
*/ |
| 949 |
function createDirectory ($dir, $onlyCheck=false) { |
function createDirectory ($dir, $onlyCheck=false) { |
| 950 |
if (file_exists($dir)) { |
if (file_exists($dir)) { |
| 951 |
if (is_dir($dir) AND is_writable($dir)) return true; |
if (is_dir($dir) AND is_writable($dir)) return true; |
| 959 |
else return $this->makeDirectory($dir); |
else return $this->makeDirectory($dir); |
| 960 |
} |
} |
| 961 |
|
|
| 962 |
|
/** |
| 963 |
|
* Enter description here... |
| 964 |
|
* |
| 965 |
|
* @param unknown_type $dir |
| 966 |
|
* @return unknown |
| 967 |
|
*/ |
| 968 |
function containingDirectory ($dir) { |
function containingDirectory ($dir) { |
| 969 |
$dirs = preg_split('*[/|\\\]*', $dir); |
$dirs = preg_split('*[/|\\\]*', $dir); |
| 970 |
for ($i = count($dirs)-1; $i >= 0; $i--) { |
for ($i = count($dirs)-1; $i >= 0; $i--) { |
| 977 |
return array($result1, $result2); |
return array($result1, $result2); |
| 978 |
} |
} |
| 979 |
|
|
| 980 |
|
/** |
| 981 |
|
* Enter description here... |
| 982 |
|
* |
| 983 |
|
* @param unknown_type $from |
| 984 |
|
* @param unknown_type $to |
| 985 |
|
* @return unknown |
| 986 |
|
*/ |
| 987 |
function simpleCopy ($from, $to) { |
function simpleCopy ($from, $to) { |
| 988 |
if (@copy($from, $to)) { |
if (@copy($from, $to)) { |
| 989 |
$this->setPermissions($to); |
$this->setPermissions($to); |
| 992 |
else return false; |
else return false; |
| 993 |
} |
} |
| 994 |
|
|
| 995 |
|
/** |
| 996 |
|
* Enter description here... |
| 997 |
|
* |
| 998 |
|
* @param unknown_type $from |
| 999 |
|
* @param unknown_type $to |
| 1000 |
|
* @return unknown |
| 1001 |
|
*/ |
| 1002 |
function forceCopy ($from, $to) { |
function forceCopy ($from, $to) { |
| 1003 |
$todir = dirname($to); |
$todir = dirname($to); |
| 1004 |
if (!file_exists($todir)) $this->createDirectory($todir); |
if (!file_exists($todir)) $this->createDirectory($todir); |
| 1008 |
return $this->simpleCopy ($from, $to); |
return $this->simpleCopy ($from, $to); |
| 1009 |
} |
} |
| 1010 |
|
|
| 1011 |
|
/** |
| 1012 |
|
* Enter description here... |
| 1013 |
|
* |
| 1014 |
|
* @param unknown_type $from |
| 1015 |
|
* @param unknown_type $to |
| 1016 |
|
* @return unknown |
| 1017 |
|
*/ |
| 1018 |
function lightCopy ($from, $to) { |
function lightCopy ($from, $to) { |
| 1019 |
$name = basename($from); |
$name = basename($from); |
| 1020 |
if (file_exists($to.$name)) return false; |
if (file_exists($to.$name)) return false; |
| 1024 |
return $this->simpleCopy ($from, $to); |
return $this->simpleCopy ($from, $to); |
| 1025 |
} |
} |
| 1026 |
|
|
| 1027 |
|
/** |
| 1028 |
|
* Enter description here... |
| 1029 |
|
* |
| 1030 |
|
* @param unknown_type $to |
| 1031 |
|
* @return unknown |
| 1032 |
|
*/ |
| 1033 |
function acceptCopy ($to) { |
function acceptCopy ($to) { |
| 1034 |
$todir = dirname($to); |
$todir = dirname($to); |
| 1035 |
return $this->createDirectory($todir, true); |
return $this->createDirectory($todir, true); |
| 1102 |
|
|
| 1103 |
} |
} |
| 1104 |
|
|
| 1105 |
|
/** |
| 1106 |
|
* Enter description here... |
| 1107 |
|
* |
| 1108 |
|
*/ |
| 1109 |
class mosDirectory { |
class mosDirectory { |
| 1110 |
|
/** |
| 1111 |
|
* Enter description here... |
| 1112 |
|
* |
| 1113 |
|
* @var unknown_type |
| 1114 |
|
*/ |
| 1115 |
var $path = ''; |
var $path = ''; |
| 1116 |
|
|
| 1117 |
|
/** |
| 1118 |
|
* Enter description here... |
| 1119 |
|
* |
| 1120 |
|
* @param unknown_type $path |
| 1121 |
|
* @return mosDirectory |
| 1122 |
|
*/ |
| 1123 |
function mosDirectory ($path) { |
function mosDirectory ($path) { |
| 1124 |
$path = str_replace('\\', '/', $path); |
$path = str_replace('\\', '/', $path); |
| 1125 |
if (substr($path,-1,1) == '/') $this->path = $path; |
if (substr($path,-1,1) == '/') $this->path = $path; |
| 1126 |
else $this->path = $path.'/'; |
else $this->path = $path.'/'; |
| 1127 |
} |
} |
| 1128 |
|
|
| 1129 |
|
/** |
| 1130 |
|
* Enter description here... |
| 1131 |
|
* |
| 1132 |
|
* @param unknown_type $type |
| 1133 |
|
* @param unknown_type $recurse |
| 1134 |
|
* @param unknown_type $fullpath |
| 1135 |
|
* @return unknown |
| 1136 |
|
*/ |
| 1137 |
function &listAll ($type='file', $recurse=false, $fullpath=false) { |
function &listAll ($type='file', $recurse=false, $fullpath=false) { |
| 1138 |
$results = array(); |
$results = array(); |
| 1139 |
if ($dir = @opendir($this->path)) { |
if ($dir = @opendir($this->path)) { |
| 1156 |
return $results; |
return $results; |
| 1157 |
} |
} |
| 1158 |
|
|
| 1159 |
|
/** |
| 1160 |
|
* Enter description here... |
| 1161 |
|
* |
| 1162 |
|
* @return unknown |
| 1163 |
|
*/ |
| 1164 |
function soleDir () { |
function soleDir () { |
| 1165 |
$found = ''; |
$found = ''; |
| 1166 |
if ($dir = @opendir($this->path)) { |
if ($dir = @opendir($this->path)) { |
| 1177 |
return $found; |
return $found; |
| 1178 |
} |
} |
| 1179 |
|
|
| 1180 |
|
/** |
| 1181 |
|
* Enter description here... |
| 1182 |
|
* |
| 1183 |
|
*/ |
| 1184 |
function deleteAll () { |
function deleteAll () { |
| 1185 |
if (!file_exists($this->path)) return; |
if (!file_exists($this->path)) return; |
| 1186 |
$subdirs =& $this->listAll ('dir', false, true); |
$subdirs =& $this->listAll ('dir', false, true); |
| 1195 |
$filemanager->deleteDirectory($this->path); |
$filemanager->deleteDirectory($this->path); |
| 1196 |
} |
} |
| 1197 |
|
|
| 1198 |
|
/** |
| 1199 |
|
* Enter description here... |
| 1200 |
|
* |
| 1201 |
|
* @return unknown |
| 1202 |
|
*/ |
| 1203 |
function createFresh () { |
function createFresh () { |
| 1204 |
$this->deleteAll(); |
$this->deleteAll(); |
| 1205 |
$filemanager =& mosFileManager::getInstance(); |
$filemanager =& mosFileManager::getInstance(); |
| 1207 |
return true; |
return true; |
| 1208 |
} |
} |
| 1209 |
|
|
| 1210 |
|
/** |
| 1211 |
|
* Enter description here... |
| 1212 |
|
* |
| 1213 |
|
*/ |
| 1214 |
function createIfNeeded () { |
function createIfNeeded () { |
| 1215 |
if (!file_exists($this->path)) { |
if (!file_exists($this->path)) { |
| 1216 |
$filemanager =& mosFileManager::getInstance(); |
$filemanager =& mosFileManager::getInstance(); |
| 1218 |
} |
} |
| 1219 |
} |
} |
| 1220 |
|
|
| 1221 |
|
/** |
| 1222 |
|
* Enter description here... |
| 1223 |
|
* |
| 1224 |
|
* @param unknown_type $pattern |
| 1225 |
|
* @param unknown_type $type |
| 1226 |
|
* @param unknown_type $recurse |
| 1227 |
|
* @param unknown_type $fullpath |
| 1228 |
|
* @return unknown |
| 1229 |
|
*/ |
| 1230 |
function &listFiles ($pattern='', $type='file', $recurse=false, $fullpath=false) { |
function &listFiles ($pattern='', $type='file', $recurse=false, $fullpath=false) { |
| 1231 |
$results = array(); |
$results = array(); |
| 1232 |
$all =& $this->listAll($type, $recurse, $fullpath); |
$all =& $this->listAll($type, $recurse, $fullpath); |
| 1238 |
return $results; |
return $results; |
| 1239 |
} |
} |
| 1240 |
|
|
| 1241 |
|
/** |
| 1242 |
|
* Enter description here... |
| 1243 |
|
* |
| 1244 |
|
* @return unknown |
| 1245 |
|
*/ |
| 1246 |
function getSize () { |
function getSize () { |
| 1247 |
$totalsize = 0; |
$totalsize = 0; |
| 1248 |
$files =& $this->listFiles(); |
$files =& $this->listFiles(); |
| 1295 |
return $instance; |
return $instance; |
| 1296 |
} |
} |
| 1297 |
|
|
| 1298 |
|
/** |
| 1299 |
|
* Enter description here... |
| 1300 |
|
* |
| 1301 |
|
* @param unknown_type $id |
| 1302 |
|
* @return unknown |
| 1303 |
|
*/ |
| 1304 |
function &getMenuByID ($id) { |
function &getMenuByID ($id) { |
| 1305 |
if (isset($this->_idlinks[$id])) { |
if (isset($this->_idlinks[$id])) { |
| 1306 |
$key = $this->_idlinks[$id]; |
$key = $this->_idlinks[$id]; |
| 1310 |
return $result; |
return $result; |
| 1311 |
} |
} |
| 1312 |
|
|
| 1313 |
|
/** |
| 1314 |
|
* Enter description here... |
| 1315 |
|
* |
| 1316 |
|
* @param unknown_type $type |
| 1317 |
|
* @param unknown_type $published |
| 1318 |
|
* @return unknown |
| 1319 |
|
*/ |
| 1320 |
function getMenuCount ($type, $published) { |
function getMenuCount ($type, $published) { |
| 1321 |
if (isset($this->_counts[$type][$published])) return $this->_counts[$type][$published]; |
if (isset($this->_counts[$type][$published])) return $this->_counts[$type][$published]; |
| 1322 |
else return 0; |
else return 0; |
| 1323 |
} |
} |
| 1324 |
|
|
| 1325 |
|
/** |
| 1326 |
|
* Enter description here... |
| 1327 |
|
* |
| 1328 |
|
* @param unknown_type $types |
| 1329 |
|
* @return unknown |
| 1330 |
|
*/ |
| 1331 |
function &getMenusByType ($types) { |
function &getMenusByType ($types) { |
| 1332 |
$checker = explode(',', $types); |
$checker = explode(',', $types); |
| 1333 |
$result = null; |
$result = null; |
| 1337 |
return $result; |
return $result; |
| 1338 |
} |
} |
| 1339 |
|
|
| 1340 |
|
/** |
| 1341 |
|
* Enter description here... |
| 1342 |
|
* |
| 1343 |
|
* @return unknown |
| 1344 |
|
*/ |
| 1345 |
function &getMenuTypes () { |
function &getMenuTypes () { |
| 1346 |
$types = array(); |
$types = array(); |
| 1347 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1351 |
return $types; |
return $types; |
| 1352 |
} |
} |
| 1353 |
|
|
| 1354 |
|
/** |
| 1355 |
|
* Enter description here... |
| 1356 |
|
* |
| 1357 |
|
* @param unknown_type $type |
| 1358 |
|
* @param unknown_type $link |
| 1359 |
|
* @return unknown |
| 1360 |
|
*/ |
| 1361 |
function getIDByTypeLink ($type, $link) { |
function getIDByTypeLink ($type, $link) { |
| 1362 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1363 |
if ($menu->published == 1 AND ($type == '*' OR $menu->type == $type) AND $menu->link == $link) return $menu->id; |
if ($menu->published == 1 AND ($type == '*' OR $menu->type == $type) AND $menu->link == $link) return $menu->id; |
| 1365 |
return null; |
return null; |
| 1366 |
} |
} |
| 1367 |
|
|
| 1368 |
|
/** |
| 1369 |
|
* Enter description here... |
| 1370 |
|
* |
| 1371 |
|
* @param unknown_type $link |
| 1372 |
|
* @return unknown |
| 1373 |
|
*/ |
| 1374 |
function getIDLikeLink ($link) { |
function getIDLikeLink ($link) { |
| 1375 |
$exact = $this->getIdByTypeLink('*', $link); |
$exact = $this->getIdByTypeLink('*', $link); |
| 1376 |
if ($exact !== null) return $exact; |
if ($exact !== null) return $exact; |
| 1380 |
return 0; |
return 0; |
| 1381 |
} |
} |
| 1382 |
|
|
| 1383 |
|
/** |
| 1384 |
|
* Enter description here... |
| 1385 |
|
* |
| 1386 |
|
* @param unknown_type $type |
| 1387 |
|
* @param unknown_type $componentid |
| 1388 |
|
* @return unknown |
| 1389 |
|
*/ |
| 1390 |
function getIDByTypeCid ($type, $componentid) { |
function getIDByTypeCid ($type, $componentid) { |
| 1391 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1392 |
if ($menu->published == 1 AND $menu->type == $type AND $menu->componentid == $componentid) return $menu->id; |
if ($menu->published == 1 AND $menu->type == $type AND $menu->componentid == $componentid) return $menu->id; |
| 1394 |
return null; |
return null; |
| 1395 |
} |
} |
| 1396 |
|
|
| 1397 |
|
/** |
| 1398 |
|
* Enter description here... |
| 1399 |
|
* |
| 1400 |
|
* @return unknown |
| 1401 |
|
*/ |
| 1402 |
function getGlobalBlogSectionCount () { |
function getGlobalBlogSectionCount () { |
| 1403 |
$count = 0; |
$count = 0; |
| 1404 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1407 |
return $count; |
return $count; |
| 1408 |
} |
} |
| 1409 |
|
|
| 1410 |
|
/** |
| 1411 |
|
* Enter description here... |
| 1412 |
|
* |
| 1413 |
|
* @param unknown_type $Itemid |
| 1414 |
|
* @param unknown_type $type |
| 1415 |
|
* @param unknown_type $id |
| 1416 |
|
* @param unknown_type $catid |
| 1417 |
|
* @return unknown |
| 1418 |
|
*/ |
| 1419 |
function getContentItemid ($Itemid, $type, $id, $catid=0) { |
function getContentItemid ($Itemid, $type, $id, $catid=0) { |
| 1420 |
if ($Itemid) return $Itemid; |
if ($Itemid) return $Itemid; |
| 1421 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1431 |
return 0; |
return 0; |
| 1432 |
} |
} |
| 1433 |
|
|
| 1434 |
|
/** |
| 1435 |
|
* Enter description here... |
| 1436 |
|
* |
| 1437 |
|
* @return unknown |
| 1438 |
|
*/ |
| 1439 |
function getBestQueryMatch () { |
function getBestQueryMatch () { |
| 1440 |
parse_str($_SERVER['QUERY_STRING'], $qitems); |
parse_str($_SERVER['QUERY_STRING'], $qitems); |
| 1441 |
if (!isset($qitems['option'])) return 0; |
if (!isset($qitems['option'])) return 0; |
| 1457 |
} |
} |
| 1458 |
|
|
| 1459 |
|
|
| 1460 |
|
/** |
| 1461 |
|
* Enter description here... |
| 1462 |
|
* |
| 1463 |
|
* @param unknown_type $link |
| 1464 |
|
* @return unknown |
| 1465 |
|
*/ |
| 1466 |
function &maxAccessLink ($link) { |
function &maxAccessLink ($link) { |
| 1467 |
$selected = null; |
$selected = null; |
| 1468 |
$access = 0; |
$access = 0; |
| 1475 |
return $selected; |
return $selected; |
| 1476 |
} |
} |
| 1477 |
|
|
| 1478 |
|
/** |
| 1479 |
|
* Enter description here... |
| 1480 |
|
* |
| 1481 |
|
* @param unknown_type $Itemid |
| 1482 |
|
* @param unknown_type $menutype |
| 1483 |
|
* @param unknown_type $maxaccess |
| 1484 |
|
* @param unknown_type $noparent |
| 1485 |
|
* @return unknown |
| 1486 |
|
*/ |
| 1487 |
function &getByParentOrder ($Itemid, $menutype, $maxaccess=0, $noparent=false) { |
function &getByParentOrder ($Itemid, $menutype, $maxaccess=0, $noparent=false) { |
| 1488 |
$result = array(); |
$result = array(); |
| 1489 |
if ($this->_byParentOrder !== null) { |
if ($this->_byParentOrder !== null) { |
| 1504 |
return $result; |
return $result; |
| 1505 |
} |
} |
| 1506 |
|
|
| 1507 |
|
/** |
| 1508 |
|
* Enter description here... |
| 1509 |
|
* |
| 1510 |
|
* @param unknown_type $Itemid |
| 1511 |
|
*/ |
| 1512 |
function setPathway ($Itemid) { |
function setPathway ($Itemid) { |
| 1513 |
if ($Itemid) { |
if ($Itemid) { |
| 1514 |
$menu =& $this->getMenuByID($Itemid); |
$menu =& $this->getMenuByID($Itemid); |
| 1549 |
return isset($access) ? $access <= $gid : false; |
return isset($access) ? $access <= $gid : false; |
| 1550 |
} |
} |
| 1551 |
|
|
| 1552 |
|
/** |
| 1553 |
|
* Enter description here... |
| 1554 |
|
* |
| 1555 |
|
* @param unknown_type $mitem |
| 1556 |
|
* @param unknown_type $level |
| 1557 |
|
* @param unknown_type $params |
| 1558 |
|
* @param unknown_type $Itemid |
| 1559 |
|
* @return unknown |
| 1560 |
|
*/ |
| 1561 |
function mosGetMenuLink( &$mitem, $level=0, &$params, $Itemid ) { |
function mosGetMenuLink( &$mitem, $level=0, &$params, $Itemid ) { |
| 1562 |
$txt = ''; |
$txt = ''; |
| 1563 |
|
|