| 89 |
|
|
| 90 |
function get ($property) { |
function get ($property) { |
| 91 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 92 |
if ($property == 'mosConfig_absolute_path' AND realpath($config->mosConfig_absolute_path) === false) die ('Invalid program load path'); |
if ($property == 'mosConfig_absolute_path') { |
| 93 |
|
if (realpath($config->mosConfig_absolute_path) === false) die ('Invalid program load path'); |
| 94 |
|
else return $config->rootPath; |
| 95 |
|
} |
| 96 |
if (isset($config->$property)) return $config->$property; |
if (isset($config->$property)) return $config->$property; |
| 97 |
trigger_error("Invalid property ($property) requested from mamboCore"); |
trigger_error("Invalid property ($property) requested from mamboCore"); |
| 98 |
return null; |
return null; |
| 137 |
$subdir = substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])); |
$subdir = substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])); |
| 138 |
$subdir = str_replace('\\', '/', $subdir); |
$subdir = str_replace('\\', '/', $subdir); |
| 139 |
$this->mosConfig_live_site = 'http://'.$_SERVER['SERVER_NAME'].$subdir; |
$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); |
preg_match_all('/\$this\-\>([A-Za-z_][A-Za-z0-9_]*)/', $code, $matches); |
| 142 |
foreach ($matches[1] as $match) $GLOBALS[$match] = $this->$match; |
foreach ($matches[1] as $match) $GLOBALS[$match] = $this->$match; |
| 143 |
if (!isset($this->mosConfig_register_globals)) { |
if (!isset($this->mosConfig_register_globals)) { |
| 166 |
|
|
| 167 |
function fixLanguage () { |
function fixLanguage () { |
| 168 |
|
|
| 169 |
|
|
| 170 |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
| 171 |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
| 172 |
|
|
|
DEFINE('_ISO','charset=utf-8'); |
|
|
DEFINE('_DATE_FORMAT_LC',"%A, %d %B %Y"); //Uses PHP's strftime Command Format |
|
|
DEFINE('_DATE_FORMAT_LC2',"%A, %d %B %Y %H:%M"); |
|
| 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 |
/*/ the current character set |
|
| 185 |
if (!isset($this->mosConfig_charset)) { |
$langfile = $this->rootPath.DIRECTORY_SEPARATOR.'language'.DIRECTORY_SEPARATOR.$lang.'.xml'; |
| 186 |
$this->set('mosConfig_charset', 'iso-8859-1');/*'utf-8'* / |
$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 |
$language_file = "$this->mosConfig_absolute_path/language/$this->mosConfig_lang.php"; |
DEFINE('_DATE_FORMAT_LC', $this->language['dateformat']); //Uses PHP's strftime Command Format |
| 201 |
if (file_exists($language_file)) require_once ($language_file); |
DEFINE('_DATE_FORMAT_LC2', $this->language['dateformat']." %H:%M"); |
| 202 |
error_reporting(0); |
|
| 203 |
set_error_handler('error_handler'); |
//header('Content-Type: text/html; charset=utf-8'); |
| 204 |
$domain = $this->mosConfig_lang; |
$domain = $this->mosConfig_lang; |
| 205 |
$textdomain = $this->mosConfig_absolute_path.'/language'; |
$textdomain = $this->rootPath.'/language'; |
| 206 |
$gettext =& phpgettext(); |
$gettext =& phpgettext(); |
| 207 |
$gettext->debug = 1; |
$gettext->debug = 0; |
| 208 |
$gettext->has_gettext = 0; |
$gettext->has_gettext = 0; |
| 209 |
$gettext->setlocale($this->mosConfig_lang);; |
$gettext->setlocale($name); |
| 210 |
|
setlocale(LC_ALL, $this->language['locale']); |
| 211 |
|
setlocale(LC_CTYPE, $this->language['encoding']); |
| 212 |
$gettext->bindtextdomain($domain, $textdomain); |
$gettext->bindtextdomain($domain, $textdomain); |
| 213 |
$gettext->bind_textdomain_codeset($domain, 'utf-8'); |
$gettext->bind_textdomain_codeset($domain, $this->language['encoding']); |
| 214 |
$gettext->textdomain($domain); |
$gettext->textdomain($domain); |
| 215 |
/**/ |
/**/ |
| 216 |
|
|
| 290 |
$iFilter =& new InputFilter(); |
$iFilter =& new InputFilter(); |
| 291 |
$url = $iFilter->process( $url ); |
$url = $iFilter->process( $url ); |
| 292 |
$message = trim($iFilter->process($msg)); |
$message = trim($iFilter->process($msg)); |
| 293 |
if ($iFilter->badAttributeValue(array('href', $url))) $url = $GLOBALS['mosConfig_live_site']; |
if ($iFilter->badAttributeValue(array('href', $url))) $url = mamboCore::get('mosConfig_live_site'); |
| 294 |
if ($message) { |
if ($message) { |
| 295 |
if (strpos($url, '?')) $url .= '&mosmsg='.urlencode($message); |
if (strpos($url, '?')) $url .= '&mosmsg='.urlencode($message); |
| 296 |
else $url .= '?mosmsg='.urlencode($message); |
else $url .= '?mosmsg='.urlencode($message); |
| 429 |
require_once ($configuration->rootPath().'/includes/database.php'); |
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 |
* Sorts an Array of objects |
| 487 |
*/ |
*/ |
| 488 |
class mosObjectSorter { |
class mosObjectSorter { |
| 563 |
* Make a pathway string for display |
* Make a pathway string for display |
| 564 |
*/ |
*/ |
| 565 |
function makePathway () { |
function makePathway () { |
| 566 |
|
$last = count($this->_names) - 1; |
| 567 |
|
if ($last == 0) return ''; |
| 568 |
$mainframe = mosMainFrame::getInstance(); |
$mainframe = mosMainFrame::getInstance(); |
| 569 |
$result = "<span class='pathway'>"; |
$result = "<span class='pathway'>"; |
| 570 |
$config = mamboCore::getMamboCore(); |
$config = mamboCore::getMamboCore(); |
| 576 |
if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='$config->mosConfig_live_site/images/M_images/arrow.png' alt='arrow' />"; |
if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='$config->mosConfig_live_site/images/M_images/arrow.png' alt='arrow' />"; |
| 577 |
else $img = '>'; |
else $img = '>'; |
| 578 |
} |
} |
|
$last = count($this->_names) - 1; |
|
| 579 |
foreach ($this->_names as $i=>$name) { |
foreach ($this->_names as $i=>$name) { |
| 580 |
if ($i === $last) $result .= "$name</span>"; |
if ($i === $last) $result .= "$name</span>"; |
| 581 |
else { |
else { |
| 586 |
} |
} |
| 587 |
$customs = $mainframe->getCustomPathWay(); |
$customs = $mainframe->getCustomPathWay(); |
| 588 |
foreach ($customs as $custom) $result .= $custom; |
foreach ($customs as $custom) $result .= $custom; |
| 589 |
|
$result .= '</span>'; |
| 590 |
return $result; |
return $result; |
| 591 |
} |
} |
| 592 |
|
|
| 684 |
} |
} |
| 685 |
|
|
| 686 |
function createDirectory ($dir) { |
function createDirectory ($dir) { |
| 687 |
|
list($upDirectory, $count) = $this->containingDirectory($dir); |
| 688 |
|
if ($count > 1 AND !file_exists($upDirectory)) $this->createDirectory($upDirectory); |
| 689 |
mkdir($dir); |
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) { |
function forceCopy ($from, $to) { |
| 704 |
$todir = dirname($to); |
$todir = dirname($to); |
| 705 |
if (!file_exists($todir)) $this->createDirectory($todir); |
if (!file_exists($todir)) $this->createDirectory($todir); |
| 706 |
$name = mamboCore::getLastPart('/', $from); |
if (!file_exists($todir)) return false; |
| 707 |
|
$name = basename($from); |
| 708 |
$this->deleteFile($to.$name); |
$this->deleteFile($to.$name); |
| 709 |
copy($from, $to); |
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 |
|
|
| 1328 |
$botclass = str_replace('.','_',$bot->element); |
$botclass = str_replace('.','_',$bot->element); |
| 1329 |
$newbot = new $botclass(); |
$newbot = new $botclass(); |
| 1330 |
$function = array ($newbot, 'perform'); |
$function = array ($newbot, 'perform'); |
| 1331 |
$this->_events[$newbot->register()][] = array ($function, $i); |
$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; |
$this->_registered[$i] = true; |
| 1335 |
} |
} |
| 1336 |
$total++; |
$total++; |
| 1380 |
foreach ($this->_events[$event] as $func) { |
foreach ($this->_events[$event] as $func) { |
| 1381 |
if (is_callable( $func[0] )) { |
if (is_callable( $func[0] )) { |
| 1382 |
$botparams = $this->_bots[$func[1]]->params; |
$botparams = $this->_bots[$func[1]]->params; |
| 1383 |
$args[] =& new mosParameters($botparams); |
$args[] = new mosParameters($botparams); |
| 1384 |
|
$args[] = $event; |
| 1385 |
if ($doUnpublished) { |
if ($doUnpublished) { |
| 1386 |
$args[0] = $this->_bots[$func[1]]->published; |
$args[0] = $this->_bots[$func[1]]->published; |
| 1387 |
$result[] = call_user_func_array( $func[0], $args ); |
$result[] = call_user_func_array( $func[0], $args ); |
| 1486 |
elseif (($this->email == '') OR preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email ) == 0) $this->_error = _REGWARN_MAIL; |
elseif (($this->email == '') OR preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email ) == 0) $this->_error = _REGWARN_MAIL; |
| 1487 |
else { |
else { |
| 1488 |
// check for existing username |
// check for existing username |
| 1489 |
|
$username = strtolower($this->username); |
| 1490 |
$this->_db->setQuery( "SELECT COUNT(id) FROM #__users " |
$this->_db->setQuery( "SELECT COUNT(id) FROM #__users " |
| 1491 |
. "\nWHERE LOWER(username)=LOWER('$this->username') AND id!='$this->id'" |
. "\nWHERE LOWER(username)='$username' AND id!='$this->id'" |
| 1492 |
); |
); |
| 1493 |
if ($this->_db->loadResult()) $this->_error = _REGWARN_INUSE; |
if ($this->_db->loadResult()) $this->_error = _REGWARN_INUSE; |
| 1494 |
elseif (mamboCore::get('mosConfig_uniquemail')) { |
elseif (mamboCore::get('mosConfig_uniquemail')) { |
| 1504 |
} |
} |
| 1505 |
|
|
| 1506 |
function store( $updateNulls=false ) { |
function store( $updateNulls=false ) { |
| 1507 |
global $migrate; |
global $acl, $migrate; |
| 1508 |
if( $this->id AND !$migrate) $ret = $this->_db->updateObject( $this->_tbl, $this, $this->id, $updateNulls ); |
$section_value = 'users'; |
| 1509 |
else $ret = $this->_db->insertObject( $this->_tbl, $this, $this->id ); |
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; |
if ($ret) return true; |
| 1529 |
$this->_error = "mosUser::store failed <br />" . $this->_db->getErrorMsg(); |
$this->_error = "mosUser::store failed <br />" . $this->_db->getErrorMsg(); |
| 1530 |
return false; |
return false; |
| 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 |
|
function mosLoginDetails ($user, $password='', $remember='') { |
| 1568 |
|
$this->_user = $user; |
| 1569 |
|
$this->_password = $password; |
| 1570 |
|
$this->_remember = $remember; |
| 1571 |
|
} |
| 1572 |
|
|
| 1573 |
|
function getUser () { |
| 1574 |
|
return $this->_user; |
| 1575 |
|
} |
| 1576 |
|
|
| 1577 |
|
function getPassword () { |
| 1578 |
|
return $this->_password; |
| 1579 |
|
} |
| 1580 |
|
|
| 1581 |
|
function getRemember () { |
| 1582 |
|
return $this->_remember; |
| 1583 |
|
} |
| 1584 |
|
|
| 1585 |
|
} |
| 1586 |
|
/** |
| 1587 |
* Mambo Mainframe class |
* Mambo Mainframe class |
| 1588 |
* |
* |
| 1589 |
* Provide many supporting API functions |
* Provide many supporting API functions |
| 1625 |
} |
} |
| 1626 |
|
|
| 1627 |
/** |
/** |
| 1628 |
|
* Get the current user - deprecated - use mamboCore instead |
| 1629 |
|
*/ |
| 1630 |
|
function getUser() { |
| 1631 |
|
return mamboCore::get('currentUser'); |
| 1632 |
|
} |
| 1633 |
|
|
| 1634 |
|
/** |
| 1635 |
* Singleton get instance |
* Singleton get instance |
| 1636 |
* @param object the mainframe instance (if called internally) |
* @param object the mainframe instance (if called internally) |
| 1637 |
* Note that because of the need for creation parameters, this cannot |
* Note that because of the need for creation parameters, this cannot |
| 2092 |
//$_COOKIE["sessioncookie"] = $session->getCookie(); |
//$_COOKIE["sessioncookie"] = $session->getCookie(); |
| 2093 |
if ($usercookie) { |
if ($usercookie) { |
| 2094 |
// Remember me cookie exists. Login with usercookie info. |
// Remember me cookie exists. Login with usercookie info. |
| 2095 |
|
require_once (mamboCore::get('mosConfig_absolute_path').'/includes/authenticator.php'); |
| 2096 |
$authenticator = mamboAuthenticator::getInstance(); |
$authenticator = mamboAuthenticator::getInstance(); |
| 2097 |
$authenticator->authenticateUser ($message, $usercookie['username'], $usercookie['password'], null, $currentSession); |
$authenticator->authenticateUser ($message, $usercookie['username'], $usercookie['password'], null, $currentSession); |
| 2098 |
} |
} |