| 8 |
*/ |
*/ |
| 9 |
|
|
| 10 |
/** Set flag that this is a parent file */ |
/** Set flag that this is a parent file */ |
| 11 |
define( '_VALID_MOS', 1 ); |
if (!defined('_VALID_MOS')) define( '_VALID_MOS', 1 ); |
| 12 |
session_start(); |
|
| 13 |
$protects = array('_REQUEST', '_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_ENV', 'GLOBALS', '_SESSION'); |
$protects = array('_REQUEST', '_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_ENV', 'GLOBALS', '_SESSION'); |
| 14 |
|
|
| 15 |
foreach ($protects as $protect) { |
foreach ($protects as $protect) { |
| 48 |
} |
} |
| 49 |
} |
} |
| 50 |
|
|
|
<<<<<<< .mine |
|
|
|
|
|
// loads english language file by default |
|
|
if ( $mosConfig_lang == '' ) { |
|
|
$mosConfig_lang = 'english'; |
|
|
} |
|
|
#include_once ( 'language/'.$mosConfig_lang.'.php' ); |
|
|
DEFINE('_ISO','charset=iso-8859-1'); |
|
|
DEFINE('_DATE_FORMAT_LC',"%A, %d %B %Y"); //Uses PHP's strftime Command Format |
|
|
DEFINE('_DATE_FORMAT_LC2',"%A, %d %B %Y %H:%M"); |
|
|
|
|
|
// include phpgettext library |
|
|
require_once( 'includes/phpgettext/phpgettext.class.php' ); |
|
|
$domain = 'frontend'; |
|
|
$textdomain = $mosConfig_absolute_path.'language'; |
|
|
$charset = 'utf-8'; |
|
|
$phpgettext =& phpgettext(); |
|
|
$phpgettext->setlocale($mosConfig_lang); |
|
|
$phpgettext->bindtextdomain($domain, $textdomain); |
|
|
$phpgettext->bind_textdomain_codeset($domain, $charset); |
|
|
$phpgettext->textdomain($domain); |
|
|
|
|
|
|
|
|
// displays offline page |
|
|
if ( $mosConfig_offline == 1 ){ |
|
|
include( 'offline.php' ); |
|
|
exit(); |
|
|
======= |
|
| 51 |
function sefRelToAbs ($string) { |
function sefRelToAbs ($string) { |
| 52 |
$sef = mosSEF::getInstance(); |
$sef = mosSEF::getInstance(); |
| 53 |
return $sef->sefRelToAbs($string); |
return $sef->sefRelToAbs($string); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>>>>>>> .theirs |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
* @version $Id: version.php,v 1.6 2005/08/17 04:03:42 eddieajau Exp $ |
|
|
* @package Mambo |
|
|
* @copyright (C) 2000 - 2005 Miro International Pty Ltd |
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
|
|
* Mambo is Free Software |
|
|
*/ |
|
|
|
|
|
/** Version information */ |
|
|
class version { |
|
|
/** @var string Product */ |
|
|
var $PRODUCT = 'Mambo'; |
|
|
/** @var int Main Release Level */ |
|
|
var $RELEASE = '4.5'; |
|
|
/** @var string Development Status */ |
|
|
var $DEV_STATUS = 'Stable'; |
|
|
/** @var int Sub Release Level */ |
|
|
var $DEV_LEVEL = '4'; |
|
|
/** @var string Codename */ |
|
|
var $CODENAME = 'Titan'; |
|
|
/** @var string Date */ |
|
|
var $RELDATE = '17-Aug-2005'; |
|
|
/** @var string Time */ |
|
|
var $RELTIME = '03:00'; |
|
|
/** @var string Timezone */ |
|
|
var $RELTZ = 'GMT'; |
|
|
/** @var string Copyright Text */ |
|
|
var $COPYRIGHT = 'Copyright 2000 - 2005 Miro International Pty Ltd. All rights reserved.'; |
|
|
/** @var string URL */ |
|
|
var $URL = '<a href="http://www.mamboserver.com">Mambo</a> is Free Software released under the GNU/GPL License.'; |
|
| 54 |
} |
} |
| 55 |
|
|
| 56 |
class mamboCore { |
class mamboCore { |
| 57 |
var $rootPath = ''; |
var $rootPath = ''; |
| 58 |
var $Itemid = 0; |
var $Itemid = 0; |
| 59 |
var $option = ''; |
var $option = ''; |
| 60 |
var $_db; |
var $current_user = null; |
| 61 |
var $do_gzip_compress = false; |
var $do_gzip_compress = false; |
|
var $_section_limit = 250; |
|
|
var $_section_status = 0; |
|
|
var $_sections; |
|
| 62 |
|
|
| 63 |
function mamboCore () { |
function mamboCore () { |
| 64 |
global $adminside; |
global $adminside; |
| 65 |
$this->rootPath = $this->allButLast('/',$_SERVER['SCRIPT_FILENAME']); |
$this->rootPath = dirname(__FILE__); |
| 66 |
if ($adminside) $this->rootPath = substr($this->rootPath,0,strlen($this->rootPath)-14); |
// $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(); |
$this->checkConfig(); |
| 69 |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 70 |
$this->getConfig(); |
$this->getConfig(); |
| 71 |
$this->fixLanguage(); |
$this->fixLanguage(); |
| 72 |
$this->secure(); |
$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 () { |
function &getMamboCore () { |
| 109 |
|
|
| 110 |
function checkConfig () { |
function checkConfig () { |
| 111 |
// checks for configuration file, if none found loads installation page |
// checks for configuration file, if none found loads installation page |
| 112 |
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 ) { |
| 113 |
header( 'Location: installation/index.php' ); |
header( 'Location: installation/index.php' ); |
| 114 |
exit(); |
exit(); |
| 115 |
} |
} |
| 117 |
|
|
| 118 |
function getConfig () { |
function getConfig () { |
| 119 |
$code = ''; |
$code = ''; |
| 120 |
$f = @fopen($this->rootPath.'configuration.php','rb'); |
$f = @fopen($this->rootPath.'/configuration.php','rb'); |
| 121 |
if ($f) { |
if ($f) { |
| 122 |
while ($f AND !feof($f)) { |
while ($f AND !feof($f)) { |
| 123 |
$line = fgets($f, 256); |
$line = fgets($f, 256); |
| 139 |
} |
} |
| 140 |
} |
} |
| 141 |
|
|
| 142 |
|
function getFavIcon () { |
| 143 |
|
// favourites icon |
| 144 |
|
if (!isset($this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
| 145 |
|
if (!file_exists($this->rootPath.'/images/'.$this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
| 146 |
|
return $this->rootPath.'/images/'.$this->mosConfig_favicon; |
| 147 |
|
} |
| 148 |
|
|
| 149 |
function offlineCheck (&$user, &$database) { |
function offlineCheck (&$user, &$database) { |
| 150 |
if ($this->mosConfig_offline) { |
if ($this->mosConfig_offline) { |
| 151 |
require_once($this->rootPath().'/administrator/includes/admin.php'); |
require_once($this->rootPath().'/administrator/includes/admin.php'); |
| 193 |
} |
} |
| 194 |
|
|
| 195 |
function determineOptionAndItemid () { |
function determineOptionAndItemid () { |
| 196 |
|
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 197 |
if ($option = strtolower(mosGetParam($_REQUEST, 'option'))); |
if ($option = strtolower(mosGetParam($_REQUEST, 'option'))); |
| 198 |
else { |
else { |
|
if (!is_object($this->_db)) $this->_db = mamboDatabase::getInstance(); |
|
| 199 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler = mosMenuHandler::getInstance(); |
| 200 |
$menus =& $menuhandler->getByParentOrder($this->Itemid, 'mainmenu'); |
$menus =& $menuhandler->getByParentOrder($this->Itemid, 'mainmenu'); |
| 201 |
$this->Itemid = $menus[0]->id; |
$this->Itemid = $menus[0]->id; |
| 202 |
|
$_REQUEST['Itemid'] = $this->Itemid; |
| 203 |
$link = $menus[0]->link; |
$link = $menus[0]->link; |
| 204 |
if (($pos = strpos( $link, '?' )) !== false) $link = substr( $link, $pos+1 ). '&Itemid='.$this->Itemid; |
$pos = strpos( $link, '?' ); |
| 205 |
|
if ($pos !== false) $link = substr( $link, $pos+1 ). '&Itemid='.$this->Itemid; |
| 206 |
parse_str( $link, $temp ); |
parse_str( $link, $temp ); |
| 207 |
/** this is a patch, need to rework when globals are handled better */ |
/** this is a patch, need to rework when globals are handled better */ |
| 208 |
foreach ($temp as $k=>$v) $GLOBALS[$k] = $_REQUEST[$k] = $v; |
foreach ($temp as $k=>$v) $_GET[$k] = $v; |
| 209 |
if (isset($temp['option'])) $option = $temp['option']; |
if (isset($temp['option'])) $option = $temp['option']; |
| 210 |
else return ''; |
else return ''; |
| 211 |
} |
} |
| 212 |
/** patch to lessen the impact on templates */ |
/** patch to lessen the impact on templates */ |
| 213 |
if ($option == 'search') $option = 'com_search'; |
if ($option == 'search') $option = 'com_search'; |
| 214 |
// checking if we can find the Itemid thru the content |
// checking if we can find the Itemid thru the component |
| 215 |
if ( $option == 'com_content' && $this->Itemid === 0 ) $this->Itemid = $this->getItemid(mosGetParam($_REQUEST, 'id', 0 )); |
if ($this->Itemid === 0) { |
| 216 |
|
if ( $option == 'com_content') { |
| 217 |
|
require_once($this->rootPath().'/components/com_content/content.class.php'); |
| 218 |
|
$handler = contentHandler::getInstance(); |
| 219 |
|
$this->Itemid = $handler->getItemid(mosGetParam($_REQUEST, 'id', 0 )); |
| 220 |
|
$_REQUEST['Itemid'] = $this->Itemid; |
| 221 |
|
} |
| 222 |
|
} |
| 223 |
return $option; |
return $option; |
| 224 |
} |
} |
| 225 |
|
|
| 358 |
return substr($field, 0, strlen($field)-$lastSize); |
return substr($field, 0, strlen($field)-$lastSize); |
| 359 |
} |
} |
| 360 |
|
|
|
function getSection ($id) { |
|
|
$limit = $this->_section_limit; |
|
|
if (!$this->_section_status) { |
|
|
$this->_db->setQuery("SELECT i.id, i.sectionid FROM #__content AS i, #__sections AS s WHERE i.sectionid=s.id ORDER BY i.id DESC LIMIT $limit"); |
|
|
$sections = $this->_db->loadObjectList(); |
|
|
if ($sections) { |
|
|
foreach ($sections as $section) $this->_sections[$section->id] = $section->sectionid; |
|
|
$this->_section_status = count($sections); |
|
|
} |
|
|
} |
|
|
if ($this->_section_status) { |
|
|
if (isset($this->_sections[$id])) return $this->_sections[$id]; |
|
|
if (count($this->_sections) < $limit) return 0; |
|
|
$this->_db->setQuery("SELECT i.sectionid FROM #__content AS i, #__sections AS s WHERE i.sectionid=s.id AND i.id=$id"); |
|
|
return $this->_db->loadResult(); |
|
|
} |
|
|
else return 0; |
|
| 361 |
} |
} |
| 362 |
|
|
| 363 |
function getItemid ($id, $typed=1, $link=1, $bs=1, $bc=1, $gbs=1) { |
require_once ('database.php'); |
|
if (!is_object($this->_db)) $this->_db = mamboDatabase::getInstance(); |
|
|
$_Itemid = null; |
|
|
$menuhandler = mosMenuHandler::getInstance(); |
|
|
if ($typed) { |
|
|
// Search for typed link |
|
|
$_Itemid = $menuhandler->getIDByTypeLink('content_typed', "index.php?option=com_content&task=view&id=$id"); |
|
|
} |
|
|
|
|
|
if ($_Itemid == null AND $link) { |
|
|
// Search for item link |
|
|
$_Itemid = $menuhandler->getIDByTypeLink('content_item_link', "index.php?option=com_content&task=view&id=$id"); |
|
|
} |
|
|
|
|
|
$sectionid = $this->getSection($id); |
|
|
if ($_Itemid == null) { |
|
|
// Search in sections |
|
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_section', $sectionid); |
|
|
} |
|
|
if ($_Itemid == null) { |
|
|
// Search in sections |
|
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_blog_section', $sectionid); |
|
|
} |
|
|
if ($_Itemid == null) { |
|
|
// Search in sections |
|
|
$_Itemid = $menuhandler->getIDByTypeCid ('content_blog_category', $sectionid); |
|
|
} |
|
|
if ($_Itemid == null AND $gbs) { |
|
|
// Search in global blog section |
|
|
$_Itemid = $menuhandler->getIDByTypeCid('content_blog_section', 0); |
|
|
} |
|
|
/* |
|
|
<<<<<<< .mine |
|
|
Installation sub folder check, removed for work with CVS* / |
|
|
if (file_exists( 'installation/index.php' )) { |
|
|
include ('offline.php'); |
|
|
exit(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======= |
|
|
if ($_Itemid == '') { |
|
|
// Search in global blog category |
|
|
$this->_db->setQuery( "SELECT id " |
|
|
."\nFROM #__menu " |
|
|
."\nWHERE type='content_blog_category' AND published='1' AND componentid=0" ); |
|
|
$_Itemid = $this->_db->loadResult(); |
|
|
} |
|
|
*/ |
|
|
if ($_Itemid) $this->Itemid = $_Itemid; |
|
|
return $this->Itemid; |
|
|
} |
|
|
>>>>>>> .theirs |
|
|
} |
|
| 364 |
|
|
| 365 |
/** |
/** |
| 366 |
* Sorts an Array of objects |
* Sorts an Array of objects |
| 423 |
/** |
/** |
| 424 |
* Add an item to the pathway |
* Add an item to the pathway |
| 425 |
*/ |
*/ |
| 426 |
function addItem ($name, $url) { |
function addItem ($name, $givenurl) { |
| 427 |
$last = count($this->_names) - 1; |
$last = count($this->_names) - 1; |
| 428 |
if (!$name) return; |
if (!$name) return; |
| 429 |
|
$url = sefRelToAbs($givenurl); |
| 430 |
if ($name == $this->_names[$last] AND $url == $this->_urls[$last]) return; |
if ($name == $this->_names[$last] AND $url == $this->_urls[$last]) return; |
| 431 |
$this->_names[$last+1] = $name; |
$this->_names[$last+1] = $name; |
| 432 |
$this->_urls[$last+1] = $url; |
$this->_urls[$last+1] = $url; |
| 463 |
$result .= " $img "; |
$result .= " $img "; |
| 464 |
} |
} |
| 465 |
} |
} |
| 466 |
|
$customs = $mainframe->getCustomPathWay(); |
| 467 |
|
foreach ($customs as $custom) $result .= $custom; |
| 468 |
return $result; |
return $result; |
| 469 |
} |
} |
| 470 |
|
|
| 538 |
|
|
| 539 |
} |
} |
| 540 |
|
|
|
<<<<<<< .mine |
|
|
/** do we have a valid Itemid yet?? */ |
|
|
if ( $Itemid === null ) { |
|
|
/** Nope, just use the homepage then. */ |
|
|
$query = "SELECT id" |
|
|
. "\n FROM #__menu" |
|
|
. "\n WHERE menutype='mainmenu'" |
|
|
. "\n AND published='1'" |
|
|
. "\n ORDER BY parent, ordering" |
|
|
. "\n LIMIT 1" |
|
|
; |
|
|
$database->setQuery( $query ); |
|
|
$Itemid = $database->loadResult(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======= |
|
| 541 |
/** |
/** |
| 542 |
* File Manager including safe mode provision? |
* File Manager including safe mode provision? |
| 543 |
* @package Mambo |
* @package Mambo |
| 617 |
return $ret; |
return $ret; |
| 618 |
} |
} |
| 619 |
|
|
|
>>>>>>> .theirs |
|
| 620 |
} |
} |
| 621 |
|
|
| 622 |
class mosDirectory { |
class mosDirectory { |
| 660 |
|
|
| 661 |
} |
} |
| 662 |
|
|
| 663 |
<<<<<<< .mine |
/** |
| 664 |
|
* Menu handler |
| 665 |
|
* @package Mambo |
| 666 |
|
*/ |
| 667 |
|
class mosMenuHandler { |
| 668 |
|
/** @var array Menu objects currently available */ |
| 669 |
|
var $_menus = null; |
| 670 |
|
/** @var array Counts of menu items by type and published status */ |
| 671 |
|
var $_counts = null; |
| 672 |
|
/** @var array Access to stored menu objects by ID */ |
| 673 |
|
var $_idlinks = null; |
| 674 |
|
/** @var array Items that may be useful for setting Itemid */ |
| 675 |
|
var $_byParentOrder = null; |
| 676 |
|
|
| 677 |
|
/** |
| 678 |
|
* Constructor |
| 679 |
|
*/ |
| 680 |
|
function mosMenuHandler() { |
| 681 |
|
global $my; |
| 682 |
|
$database = mamboDatabase::getInstance(); |
| 683 |
|
$sql = "SELECT * FROM #__menu ORDER BY name"; |
| 684 |
|
$this->_menus =& $database->doSQLget($sql, 'mosMenu'); |
| 685 |
|
if (!$this->_menus) $this->_menus = array(); |
| 686 |
|
foreach ($this->_menus as $key=>$menu) { |
| 687 |
|
$this->_idlinks[$menu->id] = $key; |
| 688 |
|
if ($menu->published == 1) $this->_byParentOrder[$menu->parent][$menu->ordering][$menu->menutype] = $key; |
| 689 |
|
if (isset($this->_counts[$menu->menutype][$menu->published])) $this->_counts[$menu->menutype][$menu->published]++; |
| 690 |
|
else $this->_counts[$menu->menutype][$menu->published] = 1; |
| 691 |
|
} |
| 692 |
|
if ($this->_byParentOrder) { |
| 693 |
|
foreach ($this->_byParentOrder as $parent=>$outer) ksort($this->_byParentOrder[$parent]); |
| 694 |
|
ksort($this->_byParentOrder); |
| 695 |
|
} |
| 696 |
|
} |
| 697 |
|
/** |
| 698 |
|
* Singleton accessor |
| 699 |
|
*/ |
| 700 |
|
function &getInstance () { |
| 701 |
|
static $instance; |
| 702 |
|
if (!is_object($instance)) $instance = new mosMenuHandler(); |
| 703 |
|
return $instance; |
| 704 |
|
} |
| 705 |
|
|
| 706 |
|
function &getMenuByID ($id) { |
| 707 |
|
if (isset($this->_idlinks[$id])) { |
| 708 |
|
$key = $this->_idlinks[$id]; |
| 709 |
|
return $this->_menus[$key]; |
| 710 |
|
} |
| 711 |
|
$result = null; |
| 712 |
|
return $result; |
| 713 |
|
} |
| 714 |
|
|
| 715 |
|
function getMenuCount ($type, $published) { |
| 716 |
|
if (isset($this->_counts[$type][$published])) return $this->_counts[$type][$published]; |
| 717 |
|
else return 0; |
| 718 |
|
} |
| 719 |
|
|
| 720 |
|
function &getMenusByType ($types) { |
| 721 |
|
$checker = explode(',', $types); |
| 722 |
|
$result = null; |
| 723 |
|
foreach ($this->_menus as $menu) { |
| 724 |
|
if (in_array($menu->menutype, $checker)) $result[] = $menu; |
| 725 |
|
} |
| 726 |
|
return $result; |
| 727 |
|
} |
| 728 |
|
|
| 729 |
|
function getIDByTypeLink ($type, $link) { |
| 730 |
|
foreach ($this->_menus as $menu) { |
| 731 |
|
if ($menu->published == 1 AND ($type == '*' OR $menu->type == $type) AND $menu->link == $link) return $menu->id; |
| 732 |
|
} |
| 733 |
|
return null; |
| 734 |
|
} |
| 735 |
|
|
| 736 |
|
function getIDLikeLink ($link) { |
| 737 |
|
$exact = $this->getIdByTypeLink('*', $link); |
| 738 |
|
if ($exact !== null) return $exact; |
| 739 |
|
foreach ($this->_menus as $menu) { |
| 740 |
|
if ($menu->published == 1 AND strpos($menu->link,$link) === 0) return $menu->id; |
| 741 |
|
} |
| 742 |
|
return 0; |
| 743 |
|
} |
| 744 |
|
|
| 745 |
|
function getIDByTypeCid ($type, $componentid) { |
| 746 |
|
foreach ($this->_menus as $menu) { |
| 747 |
|
if ($menu->published == 1 AND $menu->type == $type AND $menu->componentid == $componentid) return $menu->id; |
| 748 |
|
} |
| 749 |
|
return null; |
| 750 |
|
} |
| 751 |
|
|
| 752 |
|
function getGlobalBlogSectionCount () { |
| 753 |
|
$count = 0; |
| 754 |
|
foreach ($this->_menus as $menu) { |
| 755 |
|
if ($menu->type == 'content_blog_section' AND $menu->published == 1 AND $menu->componentid == 0) $count++; |
| 756 |
|
} |
| 757 |
|
return $count; |
| 758 |
|
} |
| 759 |
|
|
| 760 |
|
function getContentItemid ($Itemid, $type, $id, $catid=0) { |
| 761 |
|
if ($Itemid) return $Itemid; |
| 762 |
|
foreach ($this->_menus as $menu) { |
| 763 |
|
if (strpos($menu->link,'index.php?option=com_content') === false AND strpos($menu->link,'index.php?option=content') === false) continue; |
| 764 |
|
if (strpos($menu->link, $type) === false) continue; |
| 765 |
|
if ($catid) { |
| 766 |
|
if (strpos($menu->link, "&id=$catid") === false) continue; |
| 767 |
|
if (strpos($menu->link, "§ionid=$id") === false) continue; |
| 768 |
|
} |
| 769 |
|
elseif (strpos($menu->link, "&id=$id") === false) continue; |
| 770 |
|
return $menu->id; |
| 771 |
|
} |
| 772 |
|
return 0; |
| 773 |
|
} |
| 774 |
|
|
| 775 |
|
function getBestQueryMatch () { |
| 776 |
|
parse_str($_SERVER['QUERY_STRING'], $qitems); |
| 777 |
|
if (!isset($qitems['option'])) return 0; |
| 778 |
|
$failures = 999; |
| 779 |
|
$best = 0; |
| 780 |
|
foreach ($this->_menus as $menu) { |
| 781 |
|
$split = explode('?', $menu->link); |
| 782 |
|
if (isset($split[1])) parse_str($split[1], $mitems); |
| 783 |
|
else continue; |
| 784 |
|
if (!isset($mitems['option']) OR $mitems['option'] != $qitems['option']) continue; |
| 785 |
|
$thisfail = 0; |
| 786 |
|
foreach ($mitems as $key=>$mitem) if (!isset($qitems[$key]) OR $mitem != $qitems[$key]) $thisfail++; |
| 787 |
|
if ($thisfail < $failures) { |
| 788 |
|
$best = $menu->id; |
| 789 |
|
$failures = $thisfail; |
| 790 |
|
} |
| 791 |
|
} |
| 792 |
|
return $best; |
| 793 |
|
} |
| 794 |
|
|
| 795 |
|
|
| 796 |
|
function &maxAccessLink ($link) { |
| 797 |
|
$selected = null; |
| 798 |
|
$access = 0; |
| 799 |
|
foreach ($this->_menus as $key=>$menu) { |
| 800 |
|
if (strpos($menu->link,$link) === 0 AND $menu->access > $access) { |
| 801 |
|
$access = $menu->access; |
| 802 |
|
$selected =& $this->_menus[$key]; |
| 803 |
|
} |
| 804 |
|
} |
| 805 |
|
return $selected; |
| 806 |
|
} |
| 807 |
|
|
| 808 |
|
function &getByParentOrder ($Itemid, $menutype, $maxaccess=0, $noparent=false) { |
| 809 |
|
$result = array(); |
| 810 |
|
if ($this->_byParentOrder !== null) { |
| 811 |
|
foreach ($this->_byParentOrder as $parent=>$outer) { |
| 812 |
|
foreach ($outer as $ordering=>$inner) { |
| 813 |
|
foreach ($inner as $mtype=>$last) { |
| 814 |
|
$key = $this->_byParentOrder[$parent][$ordering][$mtype]; |
| 815 |
|
$menu = $this->_menus[$key]; |
| 816 |
|
if ($menutype AND $mtype != $menutype) continue; |
| 817 |
|
if ($Itemid AND $Itemid != $menu->id) continue; |
| 818 |
|
if ($maxaccess AND $menu->access > $maxaccess) continue; |
| 819 |
|
if ($noparent AND $parent != 0) continue; |
| 820 |
|
$result[] = $this->_menus[$key]; |
| 821 |
|
} |
| 822 |
|
} |
| 823 |
|
} |
| 824 |
|
} |
| 825 |
|
return $result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======= |
|
|
/** |
|
|
* Menu handler |
|
|
* @package Mambo |
|
|
*/ |
|
|
class mosMenuHandler { |
|
|
/** @var array Menu objects currently available */ |
|
|
var $_menus = null; |
|
|
/** @var array Counts of menu items by type and published status */ |
|
|
var $_counts = null; |
|
|
/** @var array Access to stored menu objects by ID */ |
|
|
var $_idlinks = null; |
|
|
/** @var array Items that may be useful for setting Itemid */ |
|
|
var $_byParentOrder = null; |
|
|
|
|
|
/** |
|
|
* Constructor |
|
|
*/ |
|
|
function mosMenuHandler() { |
|
|
global $my; |
|
|
$database = mamboDatabase::getInstance(); |
|
|
$sql = "SELECT * FROM #__menu ORDER BY name"; |
|
|
$this->_menus =& $database->doSQLget($sql, 'mosMenu'); |
|
|
if (!$this->_menus) $this->_menus = array(); |
|
|
foreach ($this->_menus as $key=>$menu) { |
|
|
$this->_idlinks[$menu->id] = $key; |
|
|
if ($menu->published == 1) $this->_byParentOrder[$menu->parent][$menu->ordering][$menu->menutype] = $key; |
|
|
if (isset($this->_counts[$menu->menutype][$menu->published])) $this->_counts[$menu->menutype][$menu->published]++; |
|
|
else $this->_counts[$menu->menutype][$menu->published] = 1; |
|
|
} |
|
|
if ($this->_byParentOrder) { |
|
|
foreach ($this->_byParentOrder as $parent=>$outer) ksort($this->_byParentOrder[$parent]); |
|
|
ksort($this->_byParentOrder); |
|
|
} |
|
|
} |
|
|
/** |
|
|
* Singleton accessor |
|
|
*/ |
|
|
function &getInstance () { |
|
|
static $instance; |
|
|
if (!is_object($instance)) $instance = new mosMenuHandler(); |
|
|
return $instance; |
|
|
} |
|
|
|
|
|
function &getMenuByID ($id) { |
|
|
if (isset($this->_idlinks[$id])) { |
|
|
$key = $this->_idlinks[$id]; |
|
|
return $this->_menus[$key]; |
|
|
} |
|
|
$result = null; |
|
|
return $result; |
|
|
} |
|
|
|
|
|
function getMenuCount ($type, $published) { |
|
|
if (isset($this->_counts[$type][$published])) return $this->_counts[$type][$published]; |
|
|
else return 0; |
|
|
} |
|
|
|
|
|
function &getMenusByType ($types) { |
|
|
$checker = explode(',', $types); |
|
|
$result = null; |
|
|
foreach ($this->_menus as $menu) { |
|
|
if (in_array($menu->menutype, $checker)) $result[] = $menu; |
|
|
} |
|
|
return $result; |
|
|
} |
|
|
|
|
|
function getIDByTypeLink ($type, $link) { |
|
|
foreach ($this->_menus as $menu) { |
|
|
if ($menu->published == 1 AND ($type == '*' OR $menu->type == $type) AND $menu->link == $link) return $menu->id; |
|
|
} |
|
|
return null; |
|
|
} |
|
|
|
|
|
function getIDLikeLink ($link) { |
|
|
$exact = $this->getIdByTypeLink('*', $link); |
|
|
if ($exact !== null) return $exact; |
|
|
foreach ($this->_menus as $menu) { |
|
|
if ($menu->published == 1 AND strpos($menu->link,$link) === 0) return $menu->id; |
|
|
} |
|
|
return null; |
|
|
} |
|
|
|
|
|
function getIDByTypeCid ($type, $componentid) { |
|
|
foreach ($this->_menus as $menu) { |
|
|
if ($menu->published == 1 AND $menu->type == $type AND $menu->componentid == $componentid) return $menu->id; |
|
|
} |
|
|
return null; |
|
|
} |
|
|
|
|
|
function getGlobalBlogSectionCount () { |
|
|
$count = 0; |
|
|
foreach ($this->_menus as $menu) { |
|
|
if ($menu->type == 'content_blog_section' AND $menu->published == 1 AND $menu->componentid == 0) $count++; |
|
|
} |
|
|
return $count; |
|
|
} |
|
|
|
|
|
function getContentItemid ($Itemid, $type, $id, $catid=0) { |
|
|
if ($Itemid) return $Itemid; |
|
|
foreach ($this->_menus as $menu) { |
|
|
if (strpos($menu->link,'index.php?option=com_content') === false AND strpos($menu->link,'index.php?option=content') === false) continue; |
|
|
if (strpos($menu->link, $type) === false) continue; |
|
|
if ($catid) { |
|
|
if (strpos($menu->link, "&id=$catid") === false) continue; |
|
|
if (strpos($menu->link, "§ionid=$id") === false) continue; |
|
|
} |
|
|
elseif (strpos($menu->link, "&id=$id") === false) continue; |
|
|
return $menu->id; |
|
|
} |
|
|
return 0; |
|
|
} |
|
|
|
|
|
function getBestQueryMatch () { |
|
|
parse_str($_SERVER['QUERY_STRING'], $qitems); |
|
|
if (!isset($qitems['option'])) return 0; |
|
|
$failures = 999; |
|
|
$best = 0; |
|
|
foreach ($this->_menus as $menu) { |
|
|
$split = explode('?', $menu->link); |
|
|
if (isset($split[1])) parse_str($split[1], $mitems); |
|
|
else continue; |
|
|
if (!isset($mitems['option']) OR $mitems['option'] != $qitems['option']) continue; |
|
|
$thisfail = 0; |
|
|
foreach ($mitems as $key=>$mitem) if (!isset($qitems[$key]) OR $mitem != $qitems[$key]) $thisfail++; |
|
|
if ($thisfail < $failures) { |
|
|
$best = $menu->id; |
|
|
$failures = $thisfail; |
|
|
} |
|
|
} |
|
|
return $best; |
|
|
} |
|
|
|
|
|
|
|
|
function &maxAccessLink ($link) { |
|
|
$selected = null; |
|
|
$access = 0; |
|
|
foreach ($this->_menus as $key=>$menu) { |
|
|
if (strpos($menu->link,$link) === 0 AND $menu->access > $access) { |
|
|
$access = $menu->access; |
|
|
$selected =& $this->_menus[$key]; |
|
|
} |
|
|
} |
|
|
return $selected; |
|
|
} |
|
|
|
|
|
function &getByParentOrder ($Itemid, $menutype, $maxaccess=0, $noparent=false) { |
|
|
$result = array(); |
|
|
if ($this->_byParentOrder !== null) { |
|
|
foreach ($this->_byParentOrder as $parent=>$outer) { |
|
|
foreach ($outer as $ordering=>$inner) { |
|
|
foreach ($inner as $mtype=>$last) { |
|
|
$key = $this->_byParentOrder[$parent][$ordering][$mtype]; |
|
|
$menu = $this->_menus[$key]; |
|
|
if ($menutype AND $mtype != $menutype) continue; |
|
|
if ($Itemid AND $Itemid != $menu->id) continue; |
|
|
if ($maxaccess AND $menu->access > $maxaccess) continue; |
|
|
if ($noparent AND $parent != 0) continue; |
|
|
$result[] = $this->_menus[$key]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return $result; |
|
|
} |
|
|
|
|
|
function setPathway ($Itemid) { |
|
|
if ($Itemid) { |
|
|
$menu = $this->getMenuByID($Itemid); |
|
|
if ($menu->parent) $this->setPathway($menu->parent); |
|
|
$pathway = mosPathway::getInstance(); |
|
|
$pathway->addItem($menu->name, $menu->link."&Itemid=$Itemid"); |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Checks whether a menu option is within the users access level |
|
|
* @param int Item id number |
|
|
* @param string The menu option |
|
|
* @param int The users group ID number |
|
|
* @param database A database connector object |
|
|
* @return boolean True if the visitor's group at least equal to the menu access |
|
|
*/ |
|
|
function menuCheck( $Itemid, $menu_option, $task, $gid ) { |
|
|
$exceptions = array ('com_banner', 'com_poll', 'com_registration', 'com_rss'); |
|
|
if (in_array($menu_option, $exceptions)) return true; |
|
|
$dblink="index.php?option=$menu_option"; |
|
|
if ($Itemid) { |
|
|
$menu = $this->getMenuByID($Itemid); |
|
|
if (strpos($menu->link,$dblink) ===0) $access = $menu->access; |
|
|
} |
|
|
if (!isset($access)) { |
|
|
if ($task!='') $dblink .= "&task=$task"; |
|
|
$menu = $this->maxAccessLink($dblink); |
|
|
if (isset($menu)) { |
|
|
$access = $menu->access; |
|
|
mamboCore::set('Itemid', $menu->id); |
|
|
} |
|
|
} |
|
|
return isset($access) ? $access <= $gid : false; |
|
|
} |
|
|
|
|
|
function mosGetMenuLink( &$mitem, $level=0, &$params, $Itemid ) { |
|
|
$txt = ''; |
|
|
|
|
|
switch ($mitem->type) { |
|
|
case 'separator': |
|
|
case 'component_item_link': |
|
|
break; |
|
|
case 'content_item_link': |
|
|
$temp = split("&task=view&id=", $mitem->link); |
|
|
if (isset($temp[1])) { |
|
|
$configuration = mamboCore::getMamboCore(); |
|
|
$mitem->link .= '&Itemid='.$configuration->getItemid($temp[1]); |
|
|
} |
|
|
break; |
|
|
case 'url': |
|
|
$link = strtolower($mitem->link); |
|
|
if (substr($link,0,10) == 'index.php?' AND strpos($link,'itemid=') === false) $mitem->link .= '&Itemid='. $mitem->id; |
|
|
break; |
|
|
case 'content_typed': |
|
|
default: |
|
|
$mitem->link .= '&Itemid='.$mitem->id; |
|
|
break; |
|
|
} |
|
|
// Active Menu highlighting |
|
|
if ( $Itemid == $mitem->id ) $id = 'id="active_menu'.$params->get( 'class_sfx' ).'"'; |
|
|
else $id = ''; |
|
|
$mitem->link = ampReplace( $mitem->link ); |
|
|
if (strcasecmp(substr($mitem->link,0,4), 'http')) $mitem->link = sefRelToAbs( $mitem->link ); |
|
|
if ($level > 0) $menuclass = 'sublevel'; |
|
|
else $menuclass = 'mainlevel'; |
|
|
$menuclass .= $params->get( 'class_sfx'); |
|
|
|
|
|
switch ($mitem->browserNav) { |
|
|
// cases are slightly different |
|
|
case 1: |
|
|
// open in a new window |
|
|
$txt = '<a href="'. $mitem->link .'" target="_blank" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>'; |
|
|
break; |
|
|
|
|
|
case 2: |
|
|
// open in a popup window |
|
|
$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"; |
|
|
break; |
|
|
|
|
|
case 3: |
|
|
// don't link it |
|
|
$txt = '<span class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</span>'; |
|
|
break; |
|
|
|
|
|
default: // formerly case 2 |
|
|
// open in parent window |
|
|
$txt = '<a href="'. $mitem->link .'" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>'; |
|
|
break; |
|
|
} |
|
|
|
|
|
if ( $params->get( 'menu_images' ) ) { |
|
|
$menu_params =& new mosParameters( $mitem->params ); |
|
|
$menu_image = $menu_params->def( 'menu_image', -1 ); |
|
|
if ($menu_image AND $menu_image <> '-1') { |
|
|
$image = '<img src="'. mamboCore::get('mosConfig_live_site') .'/images/stories/'. $menu_image .'" border="0" alt="'. $mitem->name .'"/>'; |
|
|
if ( $params->get('menu_images_align')) $txt = $txt .' '. $image; |
|
|
else $txt = $image .' '. $txt; |
|
|
} |
|
|
} |
|
|
return $txt; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Vertically Indented Menu |
|
|
*/ |
|
|
function mosShowVIMenu( &$params ) { |
|
|
global $my, $cur_template, $Itemid; |
|
|
|
|
|
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
|
|
else $maxaccess = $my->gid; |
|
|
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess); |
|
|
foreach ($rows as $i=>$row) $crosslink[$row->id] = $i; |
|
|
// indent icons |
|
|
$base = mamboCore::get('mosConfig_live_site'); |
|
|
switch ( $params->get( 'indent_image' ) ) { |
|
|
case '1': |
|
|
// Default images |
|
|
for ( $i = 1; $i < 7; $i++ ) { |
|
|
$img[$i] = "<img src=\"$base/images/M_images/indent$i.png\" alt=\"indent$i\" />"; |
|
|
} |
|
|
break; |
|
|
case '2': |
|
|
// Use Params |
|
|
for ( $i = 1; $i < 7; $i++ ) { |
|
|
$parm = $params->get('indent_image'. $i); |
|
|
if ($parm == '-1' ) $img[$i] = NULL; |
|
|
else $img[$i] = "<img src=\"$base/images/M_images/$parm\" alt=\"indent$i\" />"; |
|
|
} |
|
|
break; |
|
|
case '3': |
|
|
// None |
|
|
for ( $i = 1; $i < 7; $i++ ) $img[$i] = NULL; |
|
|
break; |
|
|
default: |
|
|
// Template |
|
|
$imgpath = $base.'/templates/'. $cur_template .'/images'; |
|
|
for ( $i = 1; $i < 7; $i++ ) { |
|
|
$img[$i] = "<img src=\"$base/templates/$cur_template/images/indent$i.png\" alt=\"indent$i\" />"; |
|
|
} |
|
|
break; |
|
|
} |
|
|
|
|
|
$indents = array( |
|
|
// block prefix / item prefix / item suffix / block suffix |
|
|
array( '<table width="100%" border="0" cellpadding="0" cellspacing="0">', '<tr align="left"><td>' , '</td></tr>', '</table>' ), |
|
|
array( '', '<div style="padding-left: 4px">'. $img[1] , '</div>', '' ), |
|
|
array( '', '<div style="padding-left: 8px">'. $img[2] , '</div>', '' ), |
|
|
array( '', '<div style="padding-left: 12px">'. $img[3] , '</div>', '' ), |
|
|
array( '', '<div style="padding-left: 16px">'. $img[4] , '</div>', '' ), |
|
|
array( '', '<div style="padding-left: 20px">'. $img[5] , '</div>', '' ), |
|
|
array( '', '<div style="padding-left: 24px">'. $img[6] , '</div>', '' ), |
|
|
); |
|
|
|
|
|
// establish the hierarchy of the menu |
|
|
$children = array(); |
|
|
// first pass - collect children |
|
|
foreach ($rows as $v ) $children[$v->parent][] = $v; |
|
|
// second pass - collect 'open' menus |
|
|
$open = array( $Itemid ); |
|
|
for ($i = 0; $i < 20 AND isset($crosslink[$open[$i]]) AND isset($rows[$crosslink[$open[$i]]]); $i++) { |
|
|
$next = $rows[$crosslink[$open[$i]]]->parent; |
|
|
if ($next) $open[$i+1] = $next; |
|
|
else break; |
|
|
} |
|
|
|
|
|
$this->mosRecurseVIMenu( 0, 0, $children, $open, $indents, $params ); |
|
|
|
|
|
} |
|
|
|
|
|
/** |
|
|
* Utility function to recursively work through a vertically indented |
|
|
* hierarchial menu |
|
|
*/ |
|
|
function mosRecurseVIMenu( $id, $level, &$children, &$open, &$indents, &$params ) { |
|
|
global $Itemid; |
|
|
if (@$children[$id]) { |
|
|
$n = min( $level, count($indents )-1); |
|
|
echo "\n".$indents[$n][0]; |
|
|
foreach ($children[$id] as $row) { |
|
|
echo "\n".$indents[$n][1]; |
|
|
echo $this->mosGetMenuLink( $row, $level, $params, $Itemid ); |
|
|
// show menu with menu expanded - submenus visible |
|
|
if ($params->get('expand_menu') OR in_array($row->id, $open)) $this->mosRecurseVIMenu( $row->id, $level+1, $children, $open, $indents, $params ); |
|
|
echo $indents[$n][2]; |
|
|
} |
|
|
echo "\n".$indents[$n][3]; |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Draws a horizontal 'flat' style menu (very simple case) |
|
|
*/ |
|
|
function mosShowHFMenu( &$params, $style=0 ) { |
|
|
global $my, $cur_template, $Itemid; |
|
|
|
|
|
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
|
|
else $maxaccess = $my->gid; |
|
|
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess, true); |
|
|
|
|
|
$links = array(); |
|
|
foreach ($rows as $row) $links[] = $this->mosGetMenuLink( $row, 0, $params, $Itemid ); |
|
|
$menuclass = 'mainlevel'. $params->get( 'class_sfx' ); |
|
|
if (count( $links )) { |
|
|
if ($style == 1) { |
|
|
echo '<ul id="'. $menuclass .'">'; |
|
|
foreach ($links as $link) echo '<li>' . $link . '</li>'; |
|
|
echo '</ul>'; |
|
|
} |
|
|
else { |
|
|
echo '<table width="100%" border="0" cellpadding="0" cellspacing="1">'; |
|
|
echo '<tr>'; |
|
|
echo '<td nowrap="nowrap">'; |
|
|
echo '<span class="'. $menuclass .'"> '. $params->get( 'end_spacer' ) .' </span>'; |
|
|
echo implode( '<span class="'. $menuclass .'"> '. $params->get( 'spacer' ) .' </span>', $links ); |
|
|
echo '<span class="'. $menuclass .'"> '. $params->get( 'end_spacer' ) .' </span>'; |
|
|
echo '</td></tr>'; |
|
|
echo '</table>'; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
>>>>>>> .theirs |
|
|
|
|
|
<<<<<<< .mine |
|
|
|
|
|
|
|
|
// frontend login & logout controls |
|
|
$return = mosGetParam( $_REQUEST, 'return', NULL ); |
|
|
if ($option == "login") { |
|
|
$mainframe->login(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======= |
|
|
/** |
|
|
* Plugin handler |
|
|
* @package Mambo |
|
|
*/ |
|
|
class mosMambotHandler { |
|
|
/** @var array An array of functions in event groups */ |
|
|
var $_events=null; |
|
|
/** @var array An array of lists */ |
|
|
var $_lists=null; |
|
|
/** @var array An array of mambots */ |
|
|
var $_bots=null; |
|
|
/** @var int Index of the mambot being loaded */ |
|
|
var $_loading=null; |
|
|
>>>>>>> .theirs |
|
|
|
|
|
<<<<<<< .mine |
|
|
// JS Popup message |
|
|
if ( mosGetParam( $_POST, 'message', 0 ) ) { |
|
|
?> |
|
|
<script> |
|
|
<!--// |
|
|
alert( "<?php echo T_('You have Logged In succesfully'); ?>" ); |
|
|
//--> |
|
|
</script> |
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======= |
|
|
/** |
|
|
* Constructor |
|
|
*/ |
|
|
function mosMambotHandler() { |
|
|
global $my; |
|
|
$this->_events = array(); |
|
|
$database = mamboDatabase::getInstance(); |
|
|
$database->setQuery( "SELECT folder, element, published, params, CONCAT_WS('/',folder,element) AS lookup" |
|
|
. "\nFROM #__mambots" |
|
|
. "\nWHERE published >= 1 AND access <= $my->gid" |
|
|
. "\nORDER BY ordering" |
|
|
); |
|
|
$this->_bots = $database->loadObjectList(); |
|
|
if (!$this->_bots) $this->_bots = array(); |
|
|
|
|
|
>>>>>>> .theirs |
|
|
} |
|
|
/** |
|
|
* Singleton accessor |
|
|
*/ |
|
|
function &getInstance () { |
|
|
static $instance; |
|
|
if (!is_object($instance)) $instance = new mosMambotHandler(); |
|
|
return $instance; |
|
|
} |
|
|
/** |
|
|
* Loads all the bot files for a particular group |
|
|
* @param string The group name, relates to the sub-directory in the mambots directory |
|
|
*/ |
|
|
function loadBotGroup( $group ) { |
|
|
global $_MAMBOTS; |
|
|
$group = trim( $group ); |
|
|
$total = 0; |
|
|
$basepath = mamboCore::get('mosConfig_absolute_path'); |
|
|
foreach ($this->_bots as $i=>$bot) { |
|
|
if ($bot->folder != $group) continue; |
|
|
$path = "$basepath/mambots/$bot->folder/$bot->element.php"; |
|
|
if (file_exists( $path )) { |
|
|
$this->_loading = $i; |
|
|
require_once( $path ); |
|
|
$total++; |
|
|
} |
|
|
} |
|
|
$this->_loading = null; |
|
|
if ($total) return true; |
|
|
return false; |
|
|
} |
|
|
/** |
|
|
* Registers a function to a particular event group |
|
|
* @param string The event name |
|
|
* @param string The function name |
|
|
*/ |
|
|
function registerFunction( $event, $function ) { |
|
|
$this->_events[$event][] = array( $function, $this->_loading ); |
|
|
} |
|
|
/** |
|
|
* Makes a option for a particular list in a group |
|
|
* @param string The group name |
|
|
* @param string The list name |
|
|
* @param string The value for the list option |
|
|
* @param string The text for the list option |
|
|
*/ |
|
|
function addListOption( $group, $listName, $value, $text='' ) { |
|
|
$this->_lists[$group][$listName][] = mosHTML::makeOption( $value, $text ); |
|
|
} |
|
|
/** |
|
|
* @param string The group name |
|
|
* @param string The list name |
|
|
* @return array |
|
|
*/ |
|
|
function getList( $group, $listName ) { |
|
|
return $this->_lists[$group][$listName]; |
|
|
} |
|
|
/** |
|
|
* Calls all functions according to passed parameters |
|
|
* @param string The event name |
|
|
* @param array An array of arguments |
|
|
* @param boolean True is unpublished bots are to be processed |
|
|
* @return array An array of results from each function call |
|
|
*/ |
|
|
function &_runBots ($event, $args, $doUnpublished=false) { |
|
|
$result = array(); |
|
|
if (isset( $this->_events[$event] )) { |
|
|
foreach ($this->_events[$event] as $func) { |
|
|
if (function_exists( $func[0] )) { |
|
|
$args[] = $this->_bots[$func[1]]->params; |
|
|
if ($doUnpublished) { |
|
|
$args[0] = $this->_bots[$func[1]]->published; |
|
|
$result[] = call_user_func_array( $func[0], $args ); |
|
|
} else if ($this->_bots[$func[1]]->published) { |
|
|
$result[] = call_user_func_array( $func[0], $args ); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return $result; |
|
|
} |
|
|
/** |
|
|
* Calls all functions associated with an event group |
|
|
* @param string The event name |
|
|
* @param array An array of arguments |
|
|
* @param boolean True is unpublished bots are to be processed |
|
|
* @return array An array of results from each function call |
|
|
*/ |
|
|
function trigger( $event, $args=null, $doUnpublished=false ) { |
|
|
if ($args === null) $args = array(); |
|
|
// prepend the published argument |
|
|
if ($doUnpublished) array_unshift( $args, null ); |
|
|
$result =& $this->_runBots($event, $args, $doUnpublished); |
|
|
return $result; |
|
|
} |
|
|
/** |
|
|
* Same as trigger but only returns the first event and |
|
|
* allows for a variable argument list |
|
|
* @param string The event name |
|
|
* @return array The result of the first function call |
|
|
*/ |
|
|
function call( $event ) { |
|
|
$args =& func_get_args(); |
|
|
array_shift( $args ); |
|
|
$result =& $this->_runBots($event, $args); |
|
|
if (isset($result[0])) return $result[0]; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Database connector class |
|
|
* @subpackage Database |
|
|
* @package Mambo |
|
|
*/ |
|
|
class database { |
|
|
/** @var string Internal variable to hold the query sql */ |
|
|
var $_sql=''; |
|
|
/** @var int Internal variable to hold the database error number */ |
|
|
var $_errorNum=0; |
|
|
/** @var string Internal variable to hold the database error message */ |
|
|
var $_errorMsg=''; |
|
|
/** @var string Internal variable to hold the prefix used on all database tables */ |
|
|
var $_table_prefix=''; |
|
|
/** @var Internal variable to hold the connector resource */ |
|
|
var $_resource=''; |
|
|
/** @var Internal variable to hold the last query cursor */ |
|
|
var $_cursor=null; |
|
|
/** @var boolean Debug option */ |
|
|
var $_debug=0; |
|
|
/** @var array A log of queries */ |
|
|
var $_log=array(); |
|
|
|
|
|
/** |
|
|
* Database object constructor |
|
|
* @param string Database host |
|
|
* @param string Database user name |
|
|
* @param string Database user password |
|
|
* @param string Database name |
|
|
* @param string Common prefix for all tables |
|
|
*/ |
|
|
function database( $host='localhost', $user, $pass, $db, $table_prefix ) { |
|
|
// perform a number of fatality checks, then die gracefully |
|
|
if (!function_exists( 'mysql_connect' )) $this->forceOffline(1); |
|
|
if (!($this->_resource = @mysql_connect( $host, $user, $pass ))) $this->forceOffline(2); |
|
|
if (!mysql_select_db($db)) $this->forceOffline(3); |
|
|
$this->_table_prefix = $table_prefix; |
|
|
} |
|
|
|
|
|
function forceOffline ($error_number) { |
|
|
$mosSystemError = $error_number; |
|
|
$basePath = dirname( __FILE__ ); |
|
|
include $basePath . '/configuration.php'; |
|
|
include $basePath . '/offline.php'; |
|
|
exit(); |
|
|
} |
|
|
/** |
|
|
* @param int |
|
|
*/ |
|
|
function debug( $level ) { |
|
|
$this->_debug = intval( $level ); |
|
|
} |
|
|
|
|
|
function debug_trace () { |
|
|
trigger_error( $this->_errorNum, E_USER_NOTICE ); |
|
|
//echo "<pre>" . $this->_sql . "</pre>\n"; |
|
|
if (function_exists('debug_backtrace')) { |
|
|
foreach(debug_backtrace() as $back) { |
|
|
if (@$back['file']) { |
|
|
echo '<br />'.$back['file'].':'.$back['line']; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
/** |
|
|
* @return int The error number for the most recent query |
|
|
*/ |
|
|
function getErrorNum() { |
|
|
return $this->_errorNum; |
|
|
} |
|
|
/** |
|
|
* @return string The error message for the most recent query |
|
|
*/ |
|
|
function getErrorMsg() { |
|
|
return str_replace( array( "\n", "'" ), array( '\n', "\'" ), $this->_errorMsg ); |
|
|
} |
|
|
/** |
|
|
* Get a database escaped string |
|
|
* @return string |
|
|
*/ |
|
|
function getEscaped( $text ) { |
|
|
return mysql_escape_string( $text ); |
|
|
} |
|
|
/** |
|
|
* Get a quoted database escaped string |
|
|
* @return string |
|
|
*/ |
|
|
function Quote( $text ) { |
|
|
return '\'' . mysql_escape_string( $text ) . '\''; |
|
|
} |
|
|
/** |
|
|
* Sets the SQL query string for later execution. |
|
|
* |
|
|
* This function replaces a string identifier <var>$prefix</var> with the |
|
|
* string held is the <var>_table_prefix</var> class variable. |
|
|
* |
|
|
* @param string The SQL query |
|
|
* @param string The common table prefix |
|
|
*/ |
|
|
function setQuery( $sql, $prefix='#__' ) { |
|
|
$this->_sql = $this->replacePrefix($sql, $prefix); |
|
|
} |
|
|
|
|
|
/** |
|
|
* This function replaces a string identifier <var>$prefix</var> with the |
|
|
* string held is the <var>_table_prefix</var> class variable. |
|
|
* |
|
|
* @param string The SQL query |
|
|
* @param string The common table prefix |
|
|
* @author thede, David McKinnis |
|
|
*/ |
|
|
function replacePrefix ($sql, $prefix='#__') { |
|
|
$done = ''; |
|
|
while (strlen($sql)) { |
|
|
if ($double = preg_match('/\"([^\\\"]|\\.)*"/', $sql,$matches_double,PREG_OFFSET_CAPTURE) OR |
|
|
$single = preg_match("/\'([^\\\']|\\.)*'/", $sql,$matches_single,PREG_OFFSET_CAPTURE)) { |
|
|
if ($single == 0 OR ($double AND $matches_double[0][1] < $matches_single[0][1])) { |
|
|
$done .= str_replace($prefix, $this->_table_prefix, substr($sql,0,$matches_double[0][1])).$matches_double[0][0]; |
|
|
$sql = substr($sql,$matches_double[0][1]+strlen($matches_double[0][0])); |
|
|
} |
|
|
else { |
|
|
$done .= str_replace($prefix, $this->_table_prefix, substr($sql,0,$matches_single[0][1])).$matches_single[0][0]; |
|
|
$sql = substr($sql,$matches_single[0][1]+strlen($matches_single[0][0])); |
|
|
} |
|
|
} |
|
|
else return $done.str_replace($prefix, $this->_table_prefix,$sql); |
|
|
} |
|
|
return $done; |
|
|
} |
|
|
/** |
|
|
* @return string The current value of the internal SQL vairable |
|
|
*/ |
|
|
function getQuery($sql='') { |
|
|
if ($sql == '') $sql = $this->_sql; |
|
|
return "<pre>" . htmlspecialchars( $sql ) . "</pre>"; |
|
|
} |
|
|
/** |
|
|
* Execute the query |
|
|
* @return mixed A database resource if successful, FALSE if not. |
|
|
*/ |
|
|
function query($sql = '') { |
|
|
global $mosConfig_debug; |
|
|
if ($sql == '') $sql = $this->_sql; |
|
|
if ($this->_debug) $this->_log[] = $sql; |
|
|
if ($this->_cursor = mysql_query($sql, $this->_resource)) { |
|
|
$this->_errorNum = 0; |
|
|
$this->_errorMsg = ''; |
|
|
return $this->_cursor; |
|
|
} |
|
|
else { |
|
|
$this->_errorNum = mysql_errno( $this->_resource ); |
|
|
$this->_errorMsg = mysql_error( $this->_resource )." SQL=$sql"; |
|
|
if ($this->_debug) $this->debug_trace(); |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
<<<<<<< .mine |
|
|
// JS Popup message |
|
|
if ( mosGetParam( $_POST, 'message', 0 ) ) { |
|
|
?> |
|
|
<script> |
|
|
<!--// |
|
|
alert( "<?php echo T_('You have Logged Out successfully'); ?>" ); |
|
|
//--> |
|
|
</script> |
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======= |
|
|
function query_batch( $abort_on_error=true, $p_transaction_safe = false) { |
|
|
$this->_errorNum = 0; |
|
|
$this->_errorMsg = ''; |
|
|
if ($p_transaction_safe) { |
|
|
$si = mysql_get_server_info(); |
|
|
preg_match_all( "/(\d+)\.(\d+)\.(\d+)/i", $si, $m ); |
|
|
$prefix = ''; |
|
|
if ($m[1] >= 4) $prefix = 'START TRANSACTION; '; |
|
|
elseif ($m[2] >= 23) { |
|
|
if ($m[3] >= 19) $prefix = 'BEGIN WORK; '; |
|
|
elseif ($m[3] >= 17) $prefix = 'BEGIN; '; |
|
|
} |
|
|
if ($prefix) $this->_sql = $prefix.$this->_sql.'; COMMIT;'; |
|
|
} |
|
|
$query_split = preg_split ("/[;]+/", $this->_sql); |
|
|
$error = 0; |
|
|
foreach ($query_split as $command_line) { |
|
|
$command_line = trim( $command_line ); |
|
|
if ($command_line != '') { |
|
|
if (!$this->query($command_line)) { |
|
|
$error = 1; echo 'xxx '; |
|
|
if ($abort_on_error) { |
|
|
return $this->_cursor; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return $error ? false : true; |
|
|
>>>>>>> .theirs |
|
|
} |
|
|
|
|
|
/** |
|
|
* Diagnostic function |
|
|
*/ |
|
|
function explain() { |
|
|
if (!($cur = $this->query("EXPLAIN ".$this->_sql))) return null; |
|
|
$headline = $header = $body = ''; |
|
|
$buf = '<table cellspacing="1" cellpadding="2" border="0" bgcolor="#000000" align="center">'; |
|
|
$buf .= $this->getQuery("EXPLAIN ".$this->_sql); |
|
|
while ($row = mysql_fetch_assoc($cur)) { |
|
|
$body .= "<tr>"; |
|
|
foreach ($row as $k=>$v) { |
|
|
if ($headline == '') $header .= "<th bgcolor=\"#ffffff\">$k</th>"; |
|
|
$body .= "<td bgcolor=\"#ffffff\">$v</td>"; |
|
|
} |
|
|
$headline = $header; |
|
|
$body .= "</tr>"; |
|
|
} |
|
|
$buf .= "<tr>$headline</tr>$body</table><br /> "; |
|
|
mysql_free_result( $cur ); |
|
|
return "<div style=\"background-color:#FFFFCC\" align=\"left\">$buf</div>"; |
|
|
} |
|
|
/** |
|
|
* @return int The number of rows returned from the most recent query. |
|
|
*/ |
|
|
function getNumRows( $cur=null ) { |
|
|
return mysql_num_rows( $cur ? $cur : $this->_cursor ); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Load an array of retrieved database objects or values |
|
|
* @param int Database cursor |
|
|
* @param string The field name of a primary key |
|
|
* @return array If <var>key</var> is empty as sequential list of returned records. |
|
|
* If <var>key</var> is not empty then the returned array is indexed by the value |
|
|
* the database key. Returns <var>null</var> if the query fails. |
|
|
*/ |
|
|
function &retrieveResults ($key='', $max=0, $result_type='row') { |
|
|
$results = array(); |
|
|
$sql_function = 'mysql_fetch_'.$result_type; |
|
|
if ($cur = $this->query()) { |
|
|
while ($row = $sql_function($cur)) { |
|
|
if ($key != '') $results[$row->$key] = $row; |
|
|
else $results[] = $row; |
|
|
if ($max AND count($results) >= $max) break; |
|
|
} |
|
|
mysql_free_result($cur); |
|
|
} |
|
|
return $results; |
|
|
} |
|
|
/** |
|
|
* This method loads the first field of the first row returned by the query. |
|
|
* |
|
|
* @return The value returned in the query or null if the query failed. |
|
|
*/ |
|
|
function loadResult() { |
|
|
$results =& $this->retrieveResults('', 1, 'row'); |
|
|
if (count($results)) return $results[0][0]; |
|
|
else return null; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Load an array of single field results into an array |
|
|
*/ |
|
|
function loadResultArray($numinarray = 0) { |
|
|
$results =& $this->retrieveResults('', 0, 'row'); |
|
|
$values = array(); |
|
|
foreach ($results as $result) $values[] = $result[$numinarray]; |
|
|
if (count($values)) return $values; |
|
|
else return null; |
|
|
} |
|
|
/** |
|
|
* Load a assoc list of database rows |
|
|
* @param string The field name of a primary key |
|
|
* @return array If <var>key</var> is empty as sequential list of returned records. |
|
|
*/ |
|
|
function loadAssocList( $key='' ) { |
|
|
$results =& $this->retrieveResults($key, 0, 'assoc'); |
|
|
if (count($results)) return $results[0][0]; |
|
|
else return null; |
|
|
} |
|
|
/** |
|
|
* Copy the named array content into the object as properties |
|
|
* only existing properties of object are filled. when undefined in hash, properties wont be deleted |
|
|
* @param array the input array |
|
|
* @param obj byref the object to fill of any class |
|
|
* @param string |
|
|
* @param boolean |
|
|
*/ |
|
|
function mosBindArrayToObject( $array, &$obj, $ignore='', $prefix=NULL, $checkSlashes=true ) { |
|
|
if (!is_array($array) OR !is_object($obj)) return false; |
|
|
if ($prefix == null) $prefix = ''; |
|
|
foreach (get_object_vars($obj) as $k => $v) { |
|
|
if( substr( $k, 0, 1 ) != '_' AND strpos($ignore, $k) === false) { |
|
|
if (isset($array[$prefix.$k])) { |
|
|
$obj->$k = ($checkSlashes AND get_magic_quotes_gpc()) ? $this->mosStripslashes( $array[$prefix.$k] ) : $array[$prefix.$k]; |
|
|
} |
|
|
} |
|
|
} |
|
|
return true; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Strip slashes from strings or arrays of strings |
|
|
* @param value the input string or array |
|
|
*/ |
|
|
function mosStripslashes(&$value) { |
|
|
if (is_string($value)) $ret = stripslashes($value); |
|
|
else { |
|
|
if (is_array($value)) { |
|
|
$ret = array(); |
|
|
while (list($key,$val) = each($value)) { |
|
|
$ret[$key] = $this->mosStripslashes($val); |
|
|
} // while |
|
|
} else $ret = $value; |
|
|
} // if |
|
|
return $ret; |
|
|
} // mosStripSlashes |
|
|
|
|
|
/** |
|
|
* This global function loads the first row of a query into an object |
|
|
* |
|
|
* If an object is passed to this function, the returned row is bound to the existing elements of <var>object</var>. |
|
|
* If <var>object</var> has a value of null, then all of the returned query fields returned in the object. |
|
|
* @param string The SQL query |
|
|
* @param object The address of variable |
|
|
*/ |
|
|
function loadObject( &$object ) { |
|
|
if ($object != null) { |
|
|
$results =& $this->retrieveResults('', 1, 'assoc'); |
|
|
if (count($results)) { |
|
|
$this->mosBindArrayToObject($results[0], $object, null, null, false); |
|
|
return true; |
|
|
} |
|
|
} |
|
|
else { |
|
|
$results =& $this->retrieveResults('', 1, 'object'); |
|
|
if (count($results)) { |
|
|
$object = $results[0]; |
|
|
return true; |
|
|
} |
|
|
else $object = null; |
|
|
} |
|
|
return false; |
|
|
} |
|
|
/** |
|
|
* Load a list of database objects |
|
|
* @param string The field name of a primary key |
|
|
* @return array If <var>key</var> is empty as sequential list of returned records. |
|
|
* If <var>key</var> is not empty then the returned array is indexed by the value |
|
|
* the database key. Returns <var>null</var> if the query fails. |
|
|
*/ |
|
|
function loadObjectList( $key='' ) { |
|
|
$results =& $this->retrieveResults($key, 0, 'object'); |
|
|
if (count($results)) return $results; |
|
|
else return null; |
|
|
} |
|
|
/** |
|
|
* @return The first row of the query. |
|
|
*/ |
|
|
function loadRow() { |
|
|
$results =& $this->retrieveResults('', 1, 'row'); |
|
|
if (count(results)) return $results[0]; |
|
|
else return null; |
|
|
} |
|
|
/** |
|
|
* Load a list of database rows (numeric column indexing) |
|
|
* @param string The field name of a primary key |
|
|
* @return array If <var>key</var> is empty as sequential list of returned records. |
|
|
* If <var>key</var> is not empty then the returned array is indexed by the value |
|
|
* the database key. Returns <var>null</var> if the query fails. |
|
|
*/ |
|
|
function loadRowList( $key='' ) { |
|
|
$results =& $this->retrieveResults('', 0, 'row'); |
|
|
if (count(results)) return $results; |
|
|
else return null; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Document::db_insertObject() |
|
|
* |
|
|
* { Description } |
|
|
* |
|
|
* @param [type] $keyName |
|
|
* @param [type] $verbose |
|
|
*/ |
|
|
function insertObject( $table, &$object, $keyName = NULL, $verbose=false ) { |
|
|
$fmtsql = "INSERT INTO $table ( %s ) VALUES ( %s ) "; |
|
|
$fields = array(); |
|
|
foreach (get_object_vars( $object ) as $k => $v) { |
|
|
if (is_array($v) OR is_object($v) OR $v === NULL OR $k[0] == '_') continue; |
|
|
$fields[] = "`$k`"; |
|
|
$values[] = "'" . $this->getEscaped( $v ) . "'"; |
|
|
} |
|
|
if (!isset($fields)) die ('class database method insertObject - no fields'); |
|
|
$this->setQuery( sprintf( $fmtsql, implode( ",", $fields ), implode( ",", $values ) ) ); |
|
|
($verbose) && print "$sql<br />\n"; |
|
|
if (!$this->query()) return false; |
|
|
$id = mysql_insert_id(); |
|
|
($verbose) && print "id=[$id]<br />\n"; |
|
|
if ($keyName && $id) $object->$keyName = $id; |
|
|
return true; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Document::db_updateObject() |
|
|
* |
|
|
* { Description } |
|
|
* |
|
|
* @param [type] $updateNulls |
|
|
*/ |
|
|
function updateObject( $table, &$object, $keyName, $updateNulls=true ) { |
|
|
$fmtsql = "UPDATE $table SET %s WHERE %s"; |
|
|
$tmp = array(); |
|
|
foreach (get_object_vars( $object ) as $k => $v) { |
|
|
if (is_array($v) OR is_object($v) OR $k[0] == '_' OR ($v === null AND !$updateNulls)) continue; |
|
|
if( $k == $keyName ) { // PK not to be updated |
|
|
$where = "$keyName='" . $this->getEscaped( $v ) . "'"; |
|
|
continue; |
|
|
} |
|
|
if ($v) $v = $this->getEscaped($v); |
|
|
$tmp[] = "`$k`='$v'"; |
|
|
} |
|
|
if (!isset($tmp)) return true; |
|
|
if (!isset($where)) die ('database class updateObject method - no key value'); |
|
|
$this->setQuery( sprintf( $fmtsql, implode( ",", $tmp ) , $where ) ); |
|
|
return $this->query(); |
|
|
} |
|
|
|
|
|
/** |
|
|
* @param boolean If TRUE, displays the last SQL statement sent to the database |
|
|
* @return string A standised error message |
|
|
*/ |
|
|
function stderr( $showSQL = false ) { |
|
|
return "DB function failed with error number $this->_errorNum" |
|
|
."<br /><font color=\"red\">$this->_errorMsg</font>" |
|
|
.($showSQL ? "<br />SQL = <pre>$this->_sql</pre>" : ''); |
|
|
} |
|
|
|
|
|
function insertid() |
|
|
{ |
|
|
return mysql_insert_id(); |
|
|
} |
|
|
|
|
|
function getVersion() |
|
|
{ |
|
|
return mysql_get_server_info(); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Fudge method for ADOdb compatibility |
|
|
*/ |
|
|
function GenID( $foo1=null, $foo2=null ) { |
|
|
return '0'; |
|
|
} |
|
|
/** |
|
|
* @return array A list of all the tables in the database |
|
|
*/ |
|
|
function getTableList() { |
|
|
$this->setQuery( 'SHOW tables' ); |
|
|
$this->query(); |
|
|
return $this->loadResultArray(); |
|
|
} |
|
|
/** |
|
|
* @param array A list of table names |
|
|
* @return array A list the create SQL for the tables |
|
|
*/ |
|
|
function getTableCreate( $tables ) { |
|
|
$result = array(); |
|
|
|
|
|
foreach ($tables as $tblval) { |
|
|
$this->setQuery( 'SHOW CREATE table ' . $tblval ); |
|
|
$this->query(); |
|
|
$result[$tblval] = $this->loadResultArray( 1 ); |
|
|
} |
|
|
|
|
|
return $result; |
|
|
} |
|
|
/** |
|
|
* @param array A list of table names |
|
|
* @return array An array of fields by table |
|
|
*/ |
|
|
function getTableFields( $tables ) { |
|
|
$result = array(); |
|
|
|
|
|
foreach ($tables as $tblval) { |
|
|
$this->setQuery( 'SHOW FIELDS FROM ' . $tblval ); |
|
|
$this->query(); |
|
|
$fields = $this->loadObjectList(); |
|
|
foreach ($fields as $field) { |
|
|
$result[$tblval][$field->Field] = preg_replace("/[(0-9)]/",'', $field->Type ); |
|
|
} |
|
|
} |
|
|
|
|
|
return $result; |
|
|
} |
|
|
|
|
|
function displayLogged () { |
|
|
echo count($this->_log).' queries executed'; |
|
|
echo '<pre>'; |
|
|
foreach ($this->_log as $k=>$sql) { |
|
|
echo $k+1 . "\n" . $sql . '<hr />'; |
|
|
} |
|
|
} |
|
|
|
|
|
/* Helper method - maybe should go into database itself */ |
|
|
function doSQL ($sql) { |
|
|
$this->setQuery($sql); |
|
|
if (!$this->query()) { |
|
|
echo "<script> alert('".$this->getErrorMsg()."'); window.history.go(-1); </script>\n"; |
|
|
exit(); |
|
|
} |
|
|
} |
|
|
|
|
|
/* Helper method - maybe could go into database itself */ |
|
|
function &doSQLget ($sql, $classname) { |
|
|
$this->setQuery($sql); |
|
|
$rows = $this->loadObjectList(); |
|
|
$target = get_class_vars($classname); |
|
|
if ($rows) { |
|
|
foreach ($rows as $row) { |
|
|
$next =& new $classname(0); |
|
|
foreach ($target as $field=>$value) { |
|
|
if (isset($row->$field)) $next->$field = $row->$field; |
|
|
} |
|
|
$result[] = $next; |
|
|
} |
|
|
} |
|
|
else $result = array(); |
|
|
return $result; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
class mamboDatabase extends database { |
|
|
|
|
|
function mamboDatabase () { |
|
|
$host = mamboCore::get('mosConfig_host'); |
|
|
$user = mamboCore::get('mosConfig_user'); |
|
|
$pw = mamboCore::get('mosConfig_password'); |
|
|
$db = mamboCore::get('mosConfig_db'); |
|
|
$prefix = mamboCore::get('mosConfig_dbprefix'); |
|
|
parent::database($host, $user, $pw, $db, $prefix); |
|
|
} |
|
|
|
|
|
function &getInstance () { |
|
|
static $instance; |
|
|
if (!is_object($instance)) $instance = new mamboDatabase(); |
|
|
return $instance; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
* mosDBTable Abstract Class. |
|
|
* @abstract |
|
|
* @package Mambo |
|
|
* @subpackage Database |
|
|
* |
|
|
* Parent classes to all database derived objects. Customisation will generally |
|
|
* not involve tampering with this object. |
|
|
* @package Mambo |
|
|
* @author Andrew Eddie <eddieajau@users.sourceforge.net |
|
|
*/ |
|
|
class mosDBTable { |
|
|
/** @var string Name of the table in the db schema relating to child class */ |
|
|
var $_tbl = ''; |
|
|
/** @var string Name of the primary key field in the table */ |
|
|
var $_tbl_key = ''; |
|
|
/** @var string Error message */ |
|
|
var $_error = ''; |
|
|
/** @var mosDatabase Database connector */ |
|
|
var $_db = null; |
|
|
|
|
|
/** |
|
|
* Object constructor to set table and key field |
|
|
* |
|
|
* Can be overloaded/supplemented by the child class |
|
|
* @param string $table name of the table in the db schema relating to child class |
|
|
* @param string $key name of the primary key field in the table |
|
|
*/ |
|
|
function mosDBTable( $table, $key, &$db ) { |
|
|
$this->_tbl = $table; |
|
|
$this->_tbl_key = $key; |
|
|
$this->_db =& $db; |
|
|
} |
|
|
|
|
|
/** |
|
|
* @return bool True if DB query failed. Sets the error message |
|
|
*/ |
|
|
function queryTestFailure () { |
|
|
if ($this->_db->query()) return false; |
|
|
$this->_error = $this->_db->getErrorMsg(); |
|
|
return true; |
|
|
} |
|
|
/** |
|
|
* Filters public properties |
|
|
* @access protected |
|
|
* @param array List of fields to ignore |
|
|
*/ |
|
|
function filter( $ignoreList=null ) { |
|
|
$callcheck = array('InputFilter', 'process'); |
|
|
if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpinputfilter/class.inputfilter.php'); |
|
|
// specific filters |
|
|
$iFilter =& new InputFilter(); |
|
|
if (is_array($ignoreList)) foreach ($this->getPublicProperties() as $k) { |
|
|
if (!in_array($k, $ignoreList)) $this->$k = $iFilter->process($this->$k); |
|
|
} |
|
|
else foreach ($this->getPublicProperties() as $k) $this->$k = $iFilter->process($this->$k); |
|
|
} |
|
|
/** |
|
|
* @return string Returns the error message |
|
|
*/ |
|
|
function getError() { |
|
|
return $this->_error; |
|
|
} |
|
|
/** |
|
|
* Gets the value of the class variable |
|
|
* @param string The name of the class variable |
|
|
* @return mixed The value of the class var (or null if no var of that name exists) |
|
|
*/ |
|
|
function get( $_property ) { |
|
|
if(isset( $this->$_property )) return $this->$_property; |
|
|
else return null; |
|
|
} |
|
|
/** |
|
|
* Returns an array of public properties |
|
|
* @return array |
|
|
*/ |
|
|
function getPublicProperties() { |
|
|
static $cache = null; |
|
|
if (is_null( $cache )) { |
|
|
$cache = array(); |
|
|
foreach (get_class_vars( get_class( $this ) ) as $key=>$val) { |
|
|
if (substr( $key, 0, 1 ) != '_') { |
|
|
$cache[] = $key; |
|
|
} |
|
|
} |
|
|
} |
|
|
return $cache; |
|
|
} |
|
|
/** |
|
|
* Checks if this object lacks the property given by the parameter |
|
|
* @param string The name of the property |
|
|
* @return bool |
|
|
*/ |
|
|
function lacks( $property ) { |
|
|
$thisclass = strtolower(get_class($this)); |
|
|
if (!array_key_exists( $property, get_class_vars($thisclass) )) { |
|
|
$this->_error = "WARNING: $thisclass does not support $property."; |
|
|
return true; |
|
|
} |
|
|
return false; |
|
|
} |
|
|
/** |
|
|
* Set the value of the class variable |
|
|
* @param string The name of the class variable |
|
|
* @param mixed The value to assign to the variable |
|
|
*/ |
|
|
function set( $_property, $_value ) { |
|
|
$this->$_property = $_value; |
|
|
} |
|
|
/** |
|
|
* binds a named array/hash to this object |
|
|
* |
|
|
* can be overloaded/supplemented by the child class |
|
|
* @param array $hash named array |
|
|
* @return null|string null is operation was satisfactory, otherwise returns an error |
|
|
*/ |
|
|
function bind( $array, $ignore="" ) { |
|
|
$database = $this->_db; |
|
|
if (is_array($array)) return $database->mosBindArrayToObject($array, $this, $ignore); |
|
|
$this->_error = strtolower(get_class( $this ))."::bind failed."; |
|
|
return false; |
|
|
} |
|
|
|
|
|
<<<<<<< .mine |
|
|
ob_start(); |
|
|
if ($path = $mainframe->getPath( 'front' )) { |
|
|
$task = mosGetParam( $_REQUEST, 'task', '' ); |
|
|
$ret = mosMenuCheck( $Itemid, $option, $task, $gid ); |
|
|
if ($ret) { |
|
|
$phpgettext->textdomain($option); |
|
|
require_once( $path ); |
|
|
} else { |
|
|
mosNotAuth(); |
|
|
|
|
|
|
|
|
======= |
|
|
/** |
|
|
* binds an array/hash to this object |
|
|
* @param int $oid optional argument, if not specifed then the value of current key is used |
|
|
* @return any result from the database operation |
|
|
*/ |
|
|
function load( $oid=null ) { |
|
|
$k = $this->_tbl_key; |
|
|
if ($oid !== null) $this->$k = $oid; |
|
|
if ($this->$k === null) return false; |
|
|
$this->_db->setQuery("SELECT * FROM $this->_tbl WHERE $this->_tbl_key='".$this->$k."'" ); |
|
|
return $this->_db->loadObject($this); |
|
|
>>>>>>> .theirs |
|
|
} |
|
|
<<<<<<< .mine |
|
|
} else { |
|
|
echo T_('The page you are trying to access does not exist. Please select a page from the main menu.'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======= |
|
|
|
|
|
/** |
|
|
* generic check method |
|
|
* |
|
|
* can be overloaded/supplemented by the child class |
|
|
* @return boolean True if the object is ok |
|
|
*/ |
|
|
function check() { |
|
|
return true; |
|
| 826 |
} |
} |
| 827 |
|
|
| 828 |
/** |
function setPathway ($Itemid) { |
| 829 |
* Inserts a new row if id is zero or updates an existing row in the database table |
if ($Itemid) { |
| 830 |
* |
$menu = $this->getMenuByID($Itemid); |
| 831 |
* Can be overloaded/supplemented by the child class |
if ($menu->parent) $this->setPathway($menu->parent); |
| 832 |
* @param boolean If false, null object variables are not updated |
$pathway = mosPathway::getInstance(); |
| 833 |
* @return null|string null if successful otherwise returns and error message |
$pathway->addItem($menu->name, $menu->link."&Itemid=$Itemid"); |
| 834 |
*/ |
} |
|
function store( $updateNulls=false ) { |
|
|
$k = $this->_tbl_key; |
|
|
global $migrate; |
|
|
if( $this->$k && !$migrate) $ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls ); |
|
|
else $ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key ); |
|
|
if( !$ret ) { |
|
|
$this->_error = strtolower(get_class( $this ))."::store failed <br />" . $this->_db->getErrorMsg(); |
|
|
return false; |
|
|
} else return true; |
|
| 835 |
} |
} |
| 836 |
|
|
| 837 |
/** |
/** |
| 838 |
* Determine from the direction parameter which operator and order to use in SQL |
* Checks whether a menu option is within the users access level |
| 839 |
|
* @param int Item id number |
| 840 |
|
* @param string The menu option |
| 841 |
|
* @param int The users group ID number |
| 842 |
|
* @param database A database connector object |
| 843 |
|
* @return boolean True if the visitor's group at least equal to the menu access |
| 844 |
*/ |
*/ |
| 845 |
function orderCodes ($direction) { |
function menuCheck( $Itemid, $menu_option, $task, $gid ) { |
| 846 |
if ($direction < 0) { |
$exceptions = array ('com_banner', 'com_poll', 'com_registration', 'com_rss'); |
| 847 |
$relation = '<'; |
if (in_array($menu_option, $exceptions)) return true; |
| 848 |
$ordering = ' ORDER BY ordering DESC'; |
$dblink="index.php?option=$menu_option"; |
| 849 |
|
if ($Itemid) { |
| 850 |
|
$menu = $this->getMenuByID($Itemid); |
| 851 |
|
if (strpos($menu->link,$dblink) ===0) $access = $menu->access; |
| 852 |
} |
} |
| 853 |
elseif ($direction > 0) { |
if (!isset($access)) { |
| 854 |
$relation = '>'; |
if ($task!='') $dblink .= "&task=$task"; |
| 855 |
$ordering = ' ORDER BY ordering ASC'; |
$menu = $this->maxAccessLink($dblink); |
| 856 |
|
if (isset($menu)) { |
| 857 |
|
$access = $menu->access; |
| 858 |
|
mamboCore::set('Itemid', $menu->id); |
| 859 |
} |
} |
|
else { |
|
|
$relation = '='; |
|
|
$ordering = ''; |
|
| 860 |
} |
} |
| 861 |
return array ($relation, $ordering); |
return isset($access) ? $access <= $gid : false; |
| 862 |
} |
} |
| 863 |
/** |
|
| 864 |
*/ |
function mosGetMenuLink( &$mitem, $level=0, &$params, $Itemid ) { |
| 865 |
function move( $direction, $where='' ) { |
$txt = ''; |
| 866 |
$k = $this->_tbl_key; |
|
| 867 |
list ($relation, $ordering) = $this->orderCodes($direction); |
switch ($mitem->type) { |
| 868 |
$sql = "SELECT $this->_tbl_key, ordering FROM $this->_tbl WHERE ordering $relation $this->ordering"; |
case 'separator': |
| 869 |
$sql .= ($where ? "\n AND $where" : '').$ordering.' LIMIT 1'; |
case 'component_item_link': |
| 870 |
$this->_db->setQuery( $sql ); |
break; |
| 871 |
$row = null; |
case 'content_item_link': |
| 872 |
if ($this->_db->loadObject($row)) { |
$temp = split("&task=view&id=", $mitem->link); |
| 873 |
$sql = "UPDATE $this->_tbl SET ordering='$row->ordering' WHERE $this->_tbl_key='".$this->$k."'"; |
if (isset($temp[1])) { |
| 874 |
$this->_db->doSQL($sql); |
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 875 |
|
$handler = contentHandler::getInstance(); |
| 876 |
|
$mitem->link .= '&Itemid='.$handler->getItemid($temp[1]); |
| 877 |
|
} |
| 878 |
|
break; |
| 879 |
|
case 'url': |
| 880 |
|
$link = strtolower($mitem->link); |
| 881 |
|
if (substr($link,0,10) == 'index.php?' AND strpos($link,'itemid=') === false) $mitem->link .= '&Itemid='. $mitem->id; |
| 882 |
|
break; |
| 883 |
|
case 'content_typed': |
| 884 |
|
default: |
| 885 |
|
$mitem->link .= '&Itemid='.$mitem->id; |
| 886 |
|
break; |
| 887 |
} |
} |
| 888 |
$sql = "UPDATE $this->_tbl SET ordering='$this->ordering' WHERE $this->_tbl_key='".$row->$k."'"; |
// Active Menu highlighting |
| 889 |
if ($row) $this->ordering = $row->ordering; |
if ( $Itemid == $mitem->id ) $id = 'id="active_menu'.$params->get( 'class_sfx' ).'"'; |
| 890 |
$this->_db->doSQL($sql); |
else $id = ''; |
| 891 |
|
$mitem->link = ampReplace( $mitem->link ); |
| 892 |
|
if (strcasecmp(substr($mitem->link,0,4), 'http')) $mitem->link = sefRelToAbs( $mitem->link ); |
| 893 |
|
if ($level > 0) $menuclass = 'sublevel'; |
| 894 |
|
else $menuclass = 'mainlevel'; |
| 895 |
|
$menuclass .= $params->get( 'class_sfx'); |
| 896 |
|
|
| 897 |
|
switch ($mitem->browserNav) { |
| 898 |
|
// cases are slightly different |
| 899 |
|
case 1: |
| 900 |
|
// open in a new window |
| 901 |
|
$txt = '<a href="'. $mitem->link .'" target="_blank" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>'; |
| 902 |
|
break; |
| 903 |
|
|
| 904 |
|
case 2: |
| 905 |
|
// open in a popup window |
| 906 |
|
$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"; |
| 907 |
|
break; |
| 908 |
|
|
| 909 |
|
case 3: |
| 910 |
|
// don't link it |
| 911 |
|
$txt = '<span class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</span>'; |
| 912 |
|
break; |
| 913 |
|
|
| 914 |
|
default: // formerly case 2 |
| 915 |
|
// open in parent window |
| 916 |
|
$txt = '<a href="'. $mitem->link .'" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>'; |
| 917 |
|
break; |
| 918 |
} |
} |
|
/** |
|
|
* Compacts the ordering sequence of the selected records |
|
|
* @param string Additional where query to limit ordering to a particular subset of records |
|
|
*/ |
|
|
function updateOrder( $where='' ) { |
|
|
if ($this->lacks('ordering')) return false; |
|
|
$k = $this->_tbl_key; |
|
|
if ($this->_tbl == "#__content_frontpage") $order2 = ", content_id DESC"; |
|
|
else $order2 = ""; |
|
| 919 |
|
|
| 920 |
$sql = "SELECT $k, ordering FROM $this->_tbl " |
if ( $params->get( 'menu_images' ) ) { |
| 921 |
. ($where ? "\nWHERE $where" : '') |
$menu_params =& new mosParameters( $mitem->params ); |
| 922 |
. "\nORDER BY ordering$order2"; |
$menu_image = $menu_params->def( 'menu_image', -1 ); |
| 923 |
$this->_db->setQuery($sql); |
if ($menu_image AND $menu_image <> '-1') { |
| 924 |
if (!$rows = $this->_db->loadObjectList()) { |
$image = '<img src="'. mamboCore::get('mosConfig_live_site') .'/images/stories/'. $menu_image .'" border="0" alt="'. $mitem->name .'"/>'; |
| 925 |
$this->_error = $this->_db->getErrorMsg(); |
if ( $params->get('menu_images_align')) $txt = $txt .' '. $image; |
| 926 |
return false; |
else $txt = $image .' '. $txt; |
| 927 |
} |
} |
|
$neworder = max(min($this->ordering, count($rows)), 1); |
|
|
$i = 1; |
|
|
foreach ($rows as $row) { |
|
|
$key = $row->$k; |
|
|
if ($i == $neworder) $i++; |
|
|
if ($key == $this->$k) { |
|
|
$i--; |
|
|
$ordering = $neworder; |
|
|
} |
|
|
else $ordering = $i; |
|
|
$sql = "UPDATE $this->_tbl SET ordering=$ordering WHERE $k = $key "; |
|
|
$this->_db->doSQL($sql); |
|
|
$i++; |
|
| 928 |
} |
} |
| 929 |
return true; |
return $txt; |
| 930 |
} |
} |
| 931 |
|
|
| 932 |
/** |
/** |
| 933 |
* Default delete method |
* Vertically Indented Menu |
|
* |
|
|
* can be overloaded/supplemented by the child class |
|
|
* @return true if successful otherwise returns and error message |
|
| 934 |
*/ |
*/ |
| 935 |
function delete( $oid=null ) { |
function mosShowVIMenu( &$params ) { |
| 936 |
$k = $this->_tbl_key; |
global $my, $cur_template, $Itemid; |
|
if ($oid) $this->$k = intval( $oid ); |
|
|
$this->_db->setQuery( "DELETE FROM $this->_tbl WHERE $this->_tbl_key = '".$this->$k."'" ); |
|
|
if ($this->queryTestFailure()) return false; |
|
|
return true; |
|
|
} |
|
| 937 |
|
|
| 938 |
function checkout( $who, $oid=null ) { |
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
| 939 |
if ($this->lacks('checked_out')) return false; |
else $maxaccess = $my->gid; |
| 940 |
$k = $this->_tbl_key; |
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess); |
| 941 |
if ($oid !== null) $this->$k = $oid; |
foreach ($rows as $i=>$row) $crosslink[$row->id] = $i; |
| 942 |
$time = date( "%Y-%m-%d H:i:s" ); |
// indent icons |
| 943 |
if (intval( $who )) { |
$base = mamboCore::get('mosConfig_live_site'); |
| 944 |
// new way of storing editor, by id |
switch ( $params->get( 'indent_image' ) ) { |
| 945 |
$this->_db->setQuery( "UPDATE $this->_tbl" |
case '1': |
| 946 |
. "\nSET checked_out='$who', checked_out_time='$time'" |
// Default images |
| 947 |
. "\nWHERE $this->_tbl_key='".$this->$k."'" |
for ( $i = 1; $i < 7; $i++ ) { |
| 948 |
); |
$img[$i] = "<img src=\"$base/images/M_images/indent$i.png\" alt=\"indent$i\" />"; |
|
} else { |
|
|
// old way of storing editor, by name |
|
|
$this->_db->setQuery( "UPDATE $this->_tbl" |
|
|
. "\nSET checked_out='1', checked_out_time='$time', editor='".$who."' " |
|
|
. "\nWHERE $this->_tbl_key='".$this->$k."'" |
|
|
); |
|
| 949 |
} |
} |
| 950 |
return $this->_db->query(); |
break; |
| 951 |
|
case '2': |
| 952 |
|
// Use Params |
| 953 |
|
for ( $i = 1; $i < 7; $i++ ) { |
| 954 |
|
$parm = $params->get('indent_image'. $i); |
| 955 |
|
if ($parm == '-1' ) $img[$i] = NULL; |
| 956 |
|
else $img[$i] = "<img src=\"$base/images/M_images/$parm\" alt=\"indent$i\" />"; |
| 957 |
} |
} |
| 958 |
|
break; |
| 959 |
function checkin( $oid=null ) { |
case '3': |
| 960 |
if ($this->lacks('checked_out')) return false; |
// None |
| 961 |
$k = $this->_tbl_key; |
for ( $i = 1; $i < 7; $i++ ) $img[$i] = NULL; |
| 962 |
if ($oid !== null) $this->$k = $oid; |
break; |
| 963 |
$time = date("H:i:s"); |
default: |
| 964 |
$this->_db->setQuery( "UPDATE $this->_tbl" |
// Template |
| 965 |
. "\nSET checked_out='0', checked_out_time='0000-00-00 00:00:00'" |
$imgpath = $base.'/templates/'. $cur_template .'/images'; |
| 966 |
. "\nWHERE $this->_tbl_key='".$this->$k."'" |
for ( $i = 1; $i < 7; $i++ ) { |
| 967 |
); |
$img[$i] = "<img src=\"$base/templates/$cur_template/images/indent$i.png\" alt=\"indent$i\" />"; |
| 968 |
return $this->_db->query(); |
} |
| 969 |
|
break; |
| 970 |
} |
} |
| 971 |
|
|
| 972 |
function hit( $oid=null ) { |
$indents = array( |
| 973 |
$k = $this->_tbl_key; |
// block prefix / item prefix / item suffix / block suffix |
| 974 |
if ($oid !== null) $this->$k = intval( $oid ); |
array( '<table width="100%" border="0" cellpadding="0" cellspacing="0">', '<tr align="left"><td>' , '</td></tr>', '</table>' ), |
| 975 |
$key = $this->$k; |
array( '', '<div style="padding-left: 4px">'. $img[1] , '</div>', '' ), |
| 976 |
$this->_db->setQuery( "UPDATE $this->_tbl SET hits=(hits+1) WHERE $this->_tbl_key='$key'" ); |
array( '', '<div style="padding-left: 8px">'. $img[2] , '</div>', '' ), |
| 977 |
$this->_db->query(); |
array( '', '<div style="padding-left: 12px">'. $img[3] , '</div>', '' ), |
| 978 |
|
array( '', '<div style="padding-left: 16px">'. $img[4] , '</div>', '' ), |
| 979 |
if (mamboCore::get('mosConfig_enable_log_items')) { |
array( '', '<div style="padding-left: 20px">'. $img[5] , '</div>', '' ), |
| 980 |
$now = date( "Y-m-d" ); |
array( '', '<div style="padding-left: 24px">'. $img[6] , '</div>', '' ), |
|
$this->_db->setQuery( "SELECT hits" |
|
|
. "\nFROM #__core_log_items" |
|
|
. "\nWHERE time_stamp='$now' AND item_table='$this->_tbl' AND item_id='$key'" |
|
|
); |
|
|
$hits = intval( $this->_db->loadResult() ); |
|
|
if ($hits) $this->_db->setQuery( "UPDATE #__core_log_items SET hits=(hits+1)" |
|
|
. "\nWHERE time_stamp='$now' AND item_table='$this->_tbl' AND item_id='".$this->$k."'" |
|
|
); |
|
|
else $this->_db->setQuery( "INSERT INTO #__core_log_items VALUES" |
|
|
. "\n('$now','$this->_tbl','".$this->$k."','1')" |
|
| 981 |
); |
); |
| 982 |
$this->_db->query(); |
|
| 983 |
|
// establish the hierarchy of the menu |
| 984 |
|
$children = array(); |
| 985 |
|
// first pass - collect children |
| 986 |
|
foreach ($rows as $v ) $children[$v->parent][] = $v; |
| 987 |
|
// second pass - collect 'open' menus |
| 988 |
|
$open = array( $Itemid ); |
| 989 |
|
for ($i = 0; $i < 20 AND isset($crosslink[$open[$i]]) AND isset($rows[$crosslink[$open[$i]]]); $i++) { |
| 990 |
|
$next = $rows[$crosslink[$open[$i]]]->parent; |
| 991 |
|
if ($next) $open[$i+1] = $next; |
| 992 |
|
else break; |
| 993 |
} |
} |
| 994 |
|
|
| 995 |
|
$this->mosRecurseVIMenu( 0, 0, $children, $open, $indents, $params ); |
| 996 |
|
|
| 997 |
} |
} |
| 998 |
|
|
| 999 |
/** |
/** |
| 1000 |
* Generic save function |
* Utility function to recursively work through a vertically indented |
| 1001 |
* @param array Source array for binding to class vars |
* hierarchial menu |
|
* @param string Filter for the order updating |
|
|
* @returns TRUE if completely successful, FALSE if partially or not succesful. |
|
| 1002 |
*/ |
*/ |
| 1003 |
function save( $source, $order_filter ) { |
function mosRecurseVIMenu( $id, $level, &$children, &$open, &$indents, &$params ) { |
| 1004 |
if (!$this->bind($_POST) OR !$this->check() OR !$this->store()OR !$this->checkin()) return false; |
global $Itemid; |
| 1005 |
$filter_value = $this->$order_filter; |
if (@$children[$id]) { |
| 1006 |
$this->updateOrder( $order_filter ? "`$order_filter`='$filter_value'" : "" ); |
$n = min( $level, count($indents )-1); |
| 1007 |
$this->_error = ''; |
echo "\n".$indents[$n][0]; |
| 1008 |
return true; |
foreach ($children[$id] as $row) { |
| 1009 |
|
echo "\n".$indents[$n][1]; |
| 1010 |
|
echo $this->mosGetMenuLink( $row, $level, $params, $Itemid ); |
| 1011 |
|
// show menu with menu expanded - submenus visible |
| 1012 |
|
if ($params->get('expand_menu') OR in_array($row->id, $open)) $this->mosRecurseVIMenu( $row->id, $level+1, $children, $open, $indents, $params ); |
| 1013 |
|
echo $indents[$n][2]; |
| 1014 |
} |
} |
| 1015 |
|
echo "\n".$indents[$n][3]; |
|
/** |
|
|
* Generic Publish/Unpublish function |
|
|
* @param array An array of id numbers |
|
|
* @param integer 0 if unpublishing, 1 if publishing |
|
|
* @param integer The id of the user performnig the operation |
|
|
*/ |
|
|
function publish_array( $cid=null, $publish=1, $myid=0 ) { |
|
|
if (!is_array( $cid ) OR count( $cid ) < 1) { |
|
|
$this->_error = "No items selected."; |
|
|
return false; |
|
| 1016 |
} |
} |
|
$cids = implode( ',', $cid ); |
|
|
$this->_db->setQuery( "UPDATE $this->_tbl SET published='$publish'" |
|
|
. "\nWHERE $this->_tbl_key IN ($cids) AND (checked_out=0 OR checked_out='$myid')" |
|
|
); |
|
|
if ($this->queryTestFailure()) return false; |
|
|
if (count( $cid ) == 1) $this->checkin( $cid[0] ); |
|
|
return true; |
|
| 1017 |
} |
} |
| 1018 |
|
|
| 1019 |
/** |
/** |
| 1020 |
* Export item list to xml |
* Draws a horizontal 'flat' style menu (very simple case) |
|
* @param boolean Map foreign keys to text values |
|
| 1021 |
*/ |
*/ |
| 1022 |
function toXML( $mapKeysToText=false ) { |
function mosShowHFMenu( &$params, $style=0 ) { |
| 1023 |
$xml = '<record table="' . $this->_tbl . '"'; |
global $my, $cur_template, $Itemid; |
|
if ($mapKeysToText) $xml .= ' mapkeystotext="true"'; |
|
|
$xml .= '>'; |
|
|
foreach (get_object_vars($this) as $k => $v) { |
|
|
if ($v === null OR is_array($v) OR is_object($v)) continue; |
|
|
if ($k[0] == '_') continue; // internal field |
|
|
$xml .= '<' . $k . '><![CDATA[' . $v . ']]></' . $k . '>'; |
|
|
} |
|
|
$xml .= '</record>'; |
|
|
return $xml; |
|
|
} |
|
|
>>>>>>> .theirs |
|
|
} |
|
|
|
|
|
/** |
|
|
* Abstract class for classes where the objects of the class can be relatively easily |
|
|
* stored in a single database table. Can usually be adapted to more complex cases. |
|
|
* Requires child classes to implement: tableName(), notSQL(). |
|
|
* tableName() must return the name of the database table, using #__ in the usual Mambo way |
|
|
* notSQL() must return an array of strings, where each string is the name of a |
|
|
* variable that is NOT in the database table, or is not written explicitly, |
|
|
* e.g. the auto-increment key. If this is the ONLY non-SQL field, then the |
|
|
* child class need not implement it, as that it is already in the abstract class. |
|
|
* Child classes may implement timeStampField, in which case it must return the name |
|
|
* of a field that will have a timestamp placed in it whenever the DB is written. |
|
|
*/ |
|
|
|
|
|
class mosDBTableEntry { |
|
|
/** @var int ID for file record in database */ |
|
|
var $id = 0; |
|
|
var $database = ''; |
|
|
|
|
|
<<<<<<< .mine |
|
|
// loads template file |
|
|
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { |
|
|
|
|
|
echo "<font color=\"red\"><b>" . sprintf(T_('Template File Not Found! Looking for template: %s'), $cur_template) ."</b></font>"; |
|
|
} else { |
|
|
require_once( 'templates/'. $cur_template .'/index.php' ); |
|
|
echo "<!-- ".time()." -->"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1024 |
|
|
| 1025 |
|
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
| 1026 |
|
else $maxaccess = $my->gid; |
| 1027 |
|
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess, true); |
| 1028 |
|
|
| 1029 |
======= |
$links = array(); |
| 1030 |
function mosDBTableEntry () { |
foreach ($rows as $row) $links[] = $this->mosGetMenuLink( $row, 0, $params, $Itemid ); |
| 1031 |
die ('Cannot instantiate mosDBTableEntry'); |
$menuclass = 'mainlevel'. $params->get( 'class_sfx' ); |
| 1032 |
|
if (count( $links )) { |
| 1033 |
|
if ($style == 1) { |
| 1034 |
|
echo '<ul id="'. $menuclass .'">'; |
| 1035 |
|
foreach ($links as $link) echo '<li>' . $link . '</li>'; |
| 1036 |
|
echo '</ul>'; |
| 1037 |
} |
} |
| 1038 |
|
else { |
| 1039 |
function getDatabase () { |
echo '<table width="100%" border="0" cellpadding="0" cellspacing="1">'; |
| 1040 |
if (!is_object($this->database)) $this->database = mamboDatabase::getInstance(); |
echo '<tr>'; |
| 1041 |
return $this->database; |
echo '<td nowrap="nowrap">'; |
| 1042 |
|
echo '<span class="'. $menuclass .'"> '. $params->get( 'end_spacer' ) .' </span>'; |
| 1043 |
|
echo implode( '<span class="'. $menuclass .'"> '. $params->get( 'spacer' ) .' </span>', $links ); |
| 1044 |
|
echo '<span class="'. $menuclass .'"> '. $params->get( 'end_spacer' ) .' </span>'; |
| 1045 |
|
echo '</td></tr>'; |
| 1046 |
|
echo '</table>'; |
| 1047 |
} |
} |
|
|
|
|
/* Stores all POST data where the name matches an object variable name */ |
|
|
function addPostData () { |
|
|
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
|
|
if ($field!='id' AND isset($_POST[$field])) { |
|
|
$this->$field = trim($_POST[$field]); |
|
| 1048 |
} |
} |
| 1049 |
} |
} |
|
$this->forceBools(); |
|
| 1050 |
} |
} |
| 1051 |
|
|
| 1052 |
/* Provided in case child class does not implement it. Can force any values */ |
/** |
| 1053 |
/* within some limited range. In particular, can force bools to be 0 or 1 */ |
* Plugin handler |
| 1054 |
function forceBools () { |
* @package Mambo |
| 1055 |
return; |
*/ |
| 1056 |
|
class mosMambotHandler { |
| 1057 |
|
/** @var array An array of functions in event groups */ |
| 1058 |
|
var $_events=null; |
| 1059 |
|
/** @var array An array of lists */ |
| 1060 |
|
var $_lists=null; |
| 1061 |
|
/** @var array An array of mambots */ |
| 1062 |
|
var $_bots=null; |
| 1063 |
|
/** @var array An array of bools showing if corresponding bot is registered */ |
| 1064 |
|
var $_registered=array(); |
| 1065 |
|
/** @var int Index of the mambot being loaded */ |
| 1066 |
|
var $_loading=null; |
| 1067 |
|
|
| 1068 |
|
/** |
| 1069 |
|
* Constructor |
| 1070 |
|
*/ |
| 1071 |
|
function mosMambotHandler() { |
| 1072 |
|
if (mamboCore::is_set('currentUser')) $gid = mamboCore::get('currentUser')->gid; |
| 1073 |
|
else $gid = 0; |
| 1074 |
|
$this->_events = array(); |
| 1075 |
|
$database = mamboDatabase::getInstance(); |
| 1076 |
|
$database->setQuery( "SELECT folder, element, published, params, CONCAT_WS('/',folder,element) AS lookup" |
| 1077 |
|
. "\nFROM #__mambots" |
| 1078 |
|
. "\nWHERE published >= 1 AND access <= $gid" |
| 1079 |
|
. "\nORDER BY ordering" |
| 1080 |
|
); |
| 1081 |
|
$this->_bots = $database->loadObjectList(); |
| 1082 |
|
if (!$this->_bots) $this->_bots = array(); |
| 1083 |
} |
} |
| 1084 |
|
/** |
| 1085 |
/* Updates an existing DB entry with the object's current values */ |
* Singleton accessor |
| 1086 |
function updateObjectDB () { |
*/ |
| 1087 |
$this->prepareValues(); |
function &getInstance () { |
| 1088 |
$database = $this->getDatabase(); |
static $instance; |
| 1089 |
$database->doSQL($this->updateSQL()); |
if (!is_object($instance)) $instance = new mosMambotHandler(); |
| 1090 |
|
return $instance; |
| 1091 |
} |
} |
| 1092 |
|
/** |
| 1093 |
/* Deletes the current object from the DB */ |
* Loads all the bot files for a particular group |
| 1094 |
function delete () { |
* @param string The group name, relates to the sub-directory in the mambots directory |
| 1095 |
$table = $this->tableName(); |
*/ |
| 1096 |
$sql = "DELETE FROM $table WHERE id=$this->id"; |
function loadBotGroup( $group ) { |
| 1097 |
$database = $this->getDatabase(); |
global $_MAMBOTS; |
| 1098 |
$database->doSQL($sql); |
$group = trim( $group ); |
| 1099 |
|
$total = 0; |
| 1100 |
|
$basepath = mamboCore::get('mosConfig_absolute_path'); |
| 1101 |
|
foreach ($this->_bots as $i=>$bot) { |
| 1102 |
|
if ($bot->folder != $group OR isset($this->_registered[$i])) continue; |
| 1103 |
|
$path = "$basepath/mambots/$bot->folder/$bot->element.php"; |
| 1104 |
|
if (file_exists( $path )) { |
| 1105 |
|
$this->_loading = $i; |
| 1106 |
|
require_once( $path ); |
| 1107 |
|
if (!isset($this->_registered[$i])) { |
| 1108 |
|
$botclass = str_replace('.','_',$bot->element); |
| 1109 |
|
$newbot = new $botclass(); |
| 1110 |
|
$function = array ($newbot, 'perform'); |
| 1111 |
|
$this->_events[$newbot->register()][] = array ($function, $i); |
| 1112 |
|
$this->_registered[$i] = true; |
| 1113 |
} |
} |
| 1114 |
|
$total++; |
|
/* Provided in case the child class does not provide a method for timeStampField */ |
|
|
function timeStampField () { |
|
|
return ''; |
|
| 1115 |
} |
} |
|
|
|
|
/* Provides SQL for updating the DB with the contents of the current object */ |
|
|
function updateSQL () { |
|
|
$tabname = $this->tableName(); |
|
|
$sql = "UPDATE $tabname SET %s WHERE id=$this->id"; |
|
|
$exclude = $this->notSQL(); |
|
|
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
|
|
if (!in_array($field,$exclude)) $setter[] = $field."='".$this->$field."'"; |
|
| 1116 |
} |
} |
| 1117 |
$timestamp = $this->timeStampField(); |
$this->_loading = null; |
| 1118 |
if ($timestamp) $setter[] = $timestamp."='".date('Y-m-d H:i:s')."'"; |
if ($total) return true; |
| 1119 |
return sprintf($sql,implode(',', $setter)); |
return false; |
| 1120 |
} |
} |
| 1121 |
|
/** |
| 1122 |
/* Default method for identifying fields not to be written to the DB */ |
* Registers a function to a particular event group |
| 1123 |
/* The child classes may override this and return more items in the array */ |
* @param string The event name |
| 1124 |
function notSQL () { |
* @param string The function name |
| 1125 |
return array ('id'); |
*/ |
| 1126 |
|
function registerFunction( $event, $function ) { |
| 1127 |
|
$this->_events[$event][] = array( $function, $this->_loading ); |
| 1128 |
|
$this->_registered[$this->_loading] = true; |
| 1129 |
} |
} |
| 1130 |
|
/** |
| 1131 |
/* Provides SQL to insert the current object into the DB */ |
* Makes a option for a particular list in a group |
| 1132 |
function insertSQL () { |
* @param string The group name |
| 1133 |
$tabname = $this->tableName(); |
* @param string The list name |
| 1134 |
$sql = "INSERT INTO $tabname (%s) VALUES (%s)"; |
* @param string The value for the list option |
| 1135 |
$exclude = $this->notSQL(); |
* @param string The text for the list option |
| 1136 |
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
*/ |
| 1137 |
if (!in_array($field,$exclude)) { |
function addListOption( $group, $listName, $value, $text='' ) { |
| 1138 |
$infields[] = $field; |
$this->_lists[$group][$listName][] = mosHTML::makeOption( $value, $text ); |
|
$values[] = "'".$this->$field."'"; |
|
| 1139 |
} |
} |
| 1140 |
|
/** |
| 1141 |
|
* @param string The group name |
| 1142 |
|
* @param string The list name |
| 1143 |
|
* @return array |
| 1144 |
|
*/ |
| 1145 |
|
function getList( $group, $listName ) { |
| 1146 |
|
return $this->_lists[$group][$listName]; |
| 1147 |
} |
} |
| 1148 |
$timestamp = $this->timeStampField(); |
/** |
| 1149 |
if ($timestamp) { |
* Calls all functions according to passed parameters |
| 1150 |
$infields[] = $timestamp; |
* @param string The event name |
| 1151 |
$values[] = "'".date('Y-m-d H:i:s')."'"; |
* @param array An array of arguments |
| 1152 |
|
* @param boolean True is unpublished bots are to be processed |
| 1153 |
|
* @return array An array of results from each function call |
| 1154 |
|
*/ |
| 1155 |
|
function &_runBots ($event, $args, $doUnpublished=false) { |
| 1156 |
|
$result = array(); |
| 1157 |
|
if (isset( $this->_events[$event] )) { |
| 1158 |
|
foreach ($this->_events[$event] as $func) { |
| 1159 |
|
if (is_callable( $func[0] )) { |
| 1160 |
|
$botparams = $this->_bots[$func[1]]->params; |
| 1161 |
|
$args[] =& new mosParameters($botparams); |
| 1162 |
|
if ($doUnpublished) { |
| 1163 |
|
$args[0] = $this->_bots[$func[1]]->published; |
| 1164 |
|
$result[] = call_user_func_array( $func[0], $args ); |
| 1165 |
|
} else if ($this->_bots[$func[1]]->published) { |
| 1166 |
|
$result[] = call_user_func_array( $func[0], $args ); |
| 1167 |
} |
} |
|
return sprintf($sql, implode(',', $infields), implode(',', $values)); |
|
| 1168 |
} |
} |
|
|
|
|
/* Copies any matching fields from some arbitrary object into the current object */ |
|
|
function setValues (&$anObject) { |
|
|
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
|
|
if ($field != 'id' AND isset($anObject->$field)) $this->$field = $anObject->$field; |
|
| 1169 |
} |
} |
| 1170 |
} |
} |
| 1171 |
|
return $result; |
|
/* Ensures values can safely be written to DB; assumes magic quotes forced off */ |
|
|
function prepareValues () { |
|
|
$database = $this->getDatabase(); |
|
|
foreach (get_class_vars(get_class($this)) as $field=>$value) { |
|
|
if (!is_numeric($this->$field)) $this->$field = $database->getEscaped($this->$field); |
|
| 1172 |
} |
} |
| 1173 |
|
/** |
| 1174 |
|
* Calls all functions associated with an event group |
| 1175 |
|
* @param string The event name |
| 1176 |
|
* @param array An array of arguments |
| 1177 |
|
* @param boolean True is unpublished bots are to be processed |
| 1178 |
|
* @return array An array of results from each function call |
| 1179 |
|
*/ |
| 1180 |
|
function trigger( $event, $args=null, $doUnpublished=false ) { |
| 1181 |
|
if ($args === null) $args = array(); |
| 1182 |
|
// prepend the published argument |
| 1183 |
|
if ($doUnpublished) array_unshift( $args, null ); |
| 1184 |
|
$result =& $this->_runBots($event, $args, $doUnpublished); |
| 1185 |
|
return $result; |
| 1186 |
} |
} |
| 1187 |
|
/** |
| 1188 |
/* Takes some arbitrary SELECT type SQL and places the first or only result into the current object */ |
* Same as trigger but only returns the first event and |
| 1189 |
function readDataBase($sql) { |
* allows for a variable argument list |
| 1190 |
$database = $this->getDatabase(); |
* @param string The event name |
| 1191 |
$database->setQuery( $sql ); |
* @return array The result of the first function call |
| 1192 |
if (!$database->loadObject($this)) $this->id = 0; |
*/ |
| 1193 |
|
function call( $event ) { |
| 1194 |
|
$args =& func_get_args(); |
| 1195 |
|
array_shift( $args ); |
| 1196 |
|
$result =& $this->_runBots($event, $args); |
| 1197 |
|
if (isset($result[0])) return $result[0]; |
| 1198 |
|
return null; |
| 1199 |
} |
} |
|
|
|
|
>>>>>>> .theirs |
|
| 1200 |
} |
} |
| 1201 |
|
|
|
<<<<<<< .mine |
|
|
// displays queries performed for page |
|
|
if ($mosConfig_debug) { |
|
|
printf(Tn_('%d query executed', '%d queries executed', $database->_ticker), $database->_ticker); |
|
|
echo '<pre>'; |
|
|
foreach ($database->_log as $k=>$sql) { |
|
|
echo $k+1 . "\n" . $sql . '<hr />'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======= |
|
|
|
|
| 1202 |
/** |
/** |
| 1203 |
* Users Table Class |
* Users Table Class |
| 1204 |
* |
* |
| 1205 |
* Provides access to the mos_templates table |
* Provides access to the mos_templates table |
| 1206 |
* @package Mambo |
* @package Mambo |
| 1207 |
*/ |
*/ |
| 1208 |
class mosUser extends mosDBTable { |
class mosUser extends mosDBTable { |
| 1209 |
/** @var int Unique id*/ |
/** @var int Unique id*/ |
| 1210 |
var $id=null; |
var $id=null; |
| 1211 |
/** @var string The users real name (or nickname)*/ |
/** @var string The users real name (or nickname)*/ |
| 1212 |
var $name=null; |
var $name=null; |
| 1213 |
/** @var string The login name*/ |
/** @var string The login name*/ |
| 1214 |
var $username=null; |
var $username=null; |
| 1215 |
/** @var string email*/ |
/** @var string email*/ |
| 1216 |
var $email=null; |
var $email=null; |
| 1217 |
/** @var string MD5 encrypted password*/ |
/** @var string MD5 encrypted password*/ |
| 1218 |
var $password=null; |
var $password=null; |
| 1219 |
/** @var string */ |
/** @var string */ |
| 1220 |
var $usertype=null; |
var $usertype=null; |
| 1221 |
/** @var int */ |
/** @var int */ |
| 1222 |
var $block=null; |
var $block=null; |
| 1223 |
/** @var int */ |
/** @var int */ |
| 1224 |
var $sendEmail=null; |
var $sendEmail=null; |
| 1225 |
/** @var int The group id number */ |
/** @var int The group id number */ |
| 1226 |
var $gid=null; |
var $gid=null; |
| 1227 |
/** @var datetime */ |
/** @var datetime */ |
| 1228 |
var $registerDate=null; |
var $registerDate=null; |
| 1229 |
/** @var datetime */ |
/** @var datetime */ |
| 1230 |
var $lastvisitDate=null; |
var $lastvisitDate=null; |
| 1231 |
/** @var string activation hash*/ |
/** @var string activation hash*/ |
| 1232 |
var $activation=null; |
var $activation=null; |
| 1233 |
/** @var string */ |
/** @var string */ |
| 1234 |
var $params=null; |
var $params=null; |
|
|
|
|
/** |
|
|
* @param database A database connector object |
|
|
*/ |
|
|
function mosUser( $dummy ) { |
|
|
$database = mamboDatabase::getInstance(); |
|
|
$this->mosDBTable( '#__users', 'id', $database ); |
|
|
>>>>>>> .theirs |
|
|
} |
|
|
<<<<<<< .mine |
|
|
echo '</pre>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1235 |
|
|
| 1236 |
======= |
/** |
| 1237 |
|
* @param database A database connector object |
| 1238 |
|
*/ |
| 1239 |
|
function mosUser( $dummy ) { |
| 1240 |
|
$database = mamboDatabase::getInstance(); |
| 1241 |
|
$this->mosDBTable( '#__users', 'id', $database ); |
| 1242 |
|
} |
| 1243 |
|
|
| 1244 |
/** |
/** |
| 1245 |
* Fill a user object with information from the current session |
* Fill a user object with information from the current session |
| 1311 |
if ($this->_error) return false; |
if ($this->_error) return false; |
| 1312 |
return true; |
return true; |
| 1313 |
} |
} |
|
>>>>>>> .theirs |
|
| 1314 |
} |
} |
| 1315 |
|
|
| 1316 |
/** |
/** |
| 1331 |
/** @var array An array of page meta information */ |
/** @var array An array of page meta information */ |
| 1332 |
var $_head=null; |
var $_head=null; |
| 1333 |
/** @var string Custom html string to append to the pathway */ |
/** @var string Custom html string to append to the pathway */ |
| 1334 |
var $_custom_pathway=null; |
var $_custom_pathway=array(); |
| 1335 |
|
|
| 1336 |
/** |
/** |
| 1337 |
* Class constructor |
* Class constructor |
| 1661 |
if ($stat->type == 2) $sql['domain'] = "UPDATE #__stats_agents SET hits=(hits+1) WHERE agent='$tldomain' AND type=2"; |
if ($stat->type == 2) $sql['domain'] = "UPDATE #__stats_agents SET hits=(hits+1) WHERE agent='$tldomain' AND type=2"; |
| 1662 |
} |
} |
| 1663 |
$this->_db->setQuery(implode('; ',$sql)); |
$this->_db->setQuery(implode('; ',$sql)); |
| 1664 |
$this->_db->query(); |
$this->_db->query_batch(); |
| 1665 |
} |
} |
| 1666 |
} |
} |
| 1667 |
|
|
| 1669 |
* @return correct Itemid for Content Item |
* @return correct Itemid for Content Item |
| 1670 |
*/ |
*/ |
| 1671 |
function getItemid ($id, $typed=1, $link=1, $bs=1, $bc=1, $gbs=1) { |
function getItemid ($id, $typed=1, $link=1, $bs=1, $bc=1, $gbs=1) { |
| 1672 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 1673 |
|
$handler = contentHandler::getInstance(); |
| 1674 |
|
return $handler->getItemid($id, $typed, $link, $bs, $bc, $gbs); |
| 1675 |
|
} |
| 1676 |
|
|
| 1677 |
|
function liveBookMark () { |
| 1678 |
|
// support for Firefox Live Bookmarks ability for site syndication |
| 1679 |
|
$c_handler = mosComponentHandler::getInstance(); |
| 1680 |
|
$params = $c_handler->getParamsByName('Syndicate'); |
| 1681 |
|
$live_bookmark = $params->get( 'live_bookmark', 0 ); |
| 1682 |
|
if ($live_bookmark) { |
| 1683 |
|
// custom bookmark file name |
| 1684 |
|
$bookmark_file = $params->get( 'bookmark_file', $live_bookmark ); |
| 1685 |
|
$link_file = mamboCore::get('mosConfig_live_site').'/cache/'. $bookmark_file; |
| 1686 |
|
$filename = mamboCore::get('mosConfig_absolute_path').'/cache/'. $bookmark_file; |
| 1687 |
|
$cache = $params->get( 'cache', 1 ); |
| 1688 |
|
$cache_time = $params->get( 'cache_time', 3600 ); |
| 1689 |
|
$title = $params->def( 'title', mamboCore::get('mosConfig_sitename') ); |
| 1690 |
|
// checks to see if cache file exists, to determine whether to create a new one |
| 1691 |
|
if ( !file_exists( $filename ) || ( ( time() - filemtime( $filename ) ) > $cache_time ) ) { |
| 1692 |
|
$task = 'live_bookmark'; |
| 1693 |
|
// sets bookmark feed type |
| 1694 |
|
$_GET['feed'] = str_replace( '.xml', '', $live_bookmark ); |
| 1695 |
|
// loads rss component to create bookmark file |
| 1696 |
|
require_once( mamboCore::get('mosConfig_absolute_path').'/components/com_rss/rss.php' ); |
| 1697 |
|
} |
| 1698 |
|
// outputs link tag for page |
| 1699 |
|
?> |
| 1700 |
|
<link rel="alternate" type="application/rss+xml" title="<?php echo $title; ?>" href="<?php echo $link_file; ?>" /> |
| 1701 |
|
<?php |
| 1702 |
|
} |
| 1703 |
|
} |
| 1704 |
|
|
| 1705 |
|
function mosShowHead () { |
| 1706 |
|
global $_VERSION; |
| 1707 |
|
$mosConfig_live_site = mamboCore::get('mosConfig_live_site'); |
| 1708 |
|
$this->appendMetaTag( 'description', mamboCore::get('mosConfig_MetaDesc') ); |
| 1709 |
|
$this->appendMetaTag( 'keywords', mamboCore::get('mosConfig_MetaKeys') ); |
| 1710 |
|
$this->addMetaTag( 'Generator', $_VERSION->PRODUCT . " - " . $_VERSION->COPYRIGHT); |
| 1711 |
|
$this->addMetaTag( 'robots', 'index, follow' ); |
| 1712 |
|
echo $this->getHead(); |
| 1713 |
|
if (mamboCore::get('mosConfig_sef')) { |
| 1714 |
|
echo "<base href=\"$mosConfig_live_site/\" />\r\n"; |
| 1715 |
|
} |
| 1716 |
|
$my = mamboCore::get('currentUser'); |
| 1717 |
|
if ( $my->id ) { |
| 1718 |
|
?> |
| 1719 |
|
<script language="JavaScript1.2" src="<?php echo $mosConfig_live_site;?>/includes/js/mambojavascript.js" type="text/javascript"></script> |
| 1720 |
|
<?php |
| 1721 |
|
} |
| 1722 |
|
$this->liveBookMark(); |
| 1723 |
|
// outputs link tag for page |
| 1724 |
$configuration = mamboCore::getMamboCore(); |
$configuration = mamboCore::getMamboCore(); |
| 1725 |
return $configuration->getItemid($id, $typed, $link, $bs, $bc, $gbs); |
?> |
| 1726 |
|
<link rel="shortcut icon" href="<?php echo $configuration->getFavIcon();?>" /> |
| 1727 |
|
<?php |
| 1728 |
} |
} |
| 1729 |
|
|
| 1730 |
} |
} |
| 1881 |
} |
} |
| 1882 |
|
|
| 1883 |
/** |
/** |
| 1884 |
|
* Parameters handler |
| 1885 |
|
* @package Mambo |
| 1886 |
|
*/ |
| 1887 |
|
class mosParameters { |
| 1888 |
|
/** @var object */ |
| 1889 |
|
var $_params = null; |
| 1890 |
|
/** @var string The raw params string */ |
| 1891 |
|
var $_raw = null; |
| 1892 |
|
/** @var string Path to the xml setup file */ |
| 1893 |
|
var $_path = null; |
| 1894 |
|
/** @var string The type of setup file */ |
| 1895 |
|
var $_type = null; |
| 1896 |
|
/** @var object The xml params element */ |
| 1897 |
|
var $_xmlElem = null; |
| 1898 |
|
/** |
| 1899 |
|
* Constructor |
| 1900 |
|
* @param string The raw parms text |
| 1901 |
|
* @param string Path to the xml setup file |
| 1902 |
|
* @var string The type of setup file |
| 1903 |
|
*/ |
| 1904 |
|
function mosParameters( $text, $path='', $type='component' ) { |
| 1905 |
|
$this->_params = $this->parse( $text ); |
| 1906 |
|
$this->_raw = $text; |
| 1907 |
|
$this->_path = $path; |
| 1908 |
|
$this->_type = $type; |
| 1909 |
|
} |
| 1910 |
|
/** |
| 1911 |
|
* @param string The name of the param |
| 1912 |
|
* @param string The value of the parameter |
| 1913 |
|
* @return string The set value |
| 1914 |
|
*/ |
| 1915 |
|
function set( $key, $value='' ) { |
| 1916 |
|
$this->_params->$key = $value; |
| 1917 |
|
return $value; |
| 1918 |
|
} |
| 1919 |
|
/** |
| 1920 |
|
* Sets a default value if not alreay assigned |
| 1921 |
|
* @param string The name of the param |
| 1922 |
|
* @param string The value of the parameter |
| 1923 |
|
* @return string The set value |
| 1924 |
|
*/ |
| 1925 |
|
function def( $key, $value='' ) { |
| 1926 |
|
return $this->set( $key, $this->get( $key, $value ) ); |
| 1927 |
|
} |
| 1928 |
|
/** |
| 1929 |
|
* @param string The name of the param |
| 1930 |
|
* @param mixed The default value if not found |
| 1931 |
|
* @return string |
| 1932 |
|
*/ |
| 1933 |
|
function get( $key, $default='' ) { |
| 1934 |
|
if (isset( $this->_params->$key )) { |
| 1935 |
|
return $this->_params->$key === '' ? $default : $this->_params->$key; |
| 1936 |
|
} else { |
| 1937 |
|
return $default; |
| 1938 |
|
} |
| 1939 |
|
} |
| 1940 |
|
/** |
| 1941 |
|
* Parse an .ini string, based on phpDocumentor phpDocumentor_parse_ini_file function |
| 1942 |
|
* @param mixed The ini string or array of lines |
| 1943 |
|
* @param boolean add an associative index for each section [in brackets] |
| 1944 |
|
* @return object |
| 1945 |
|
*/ |
| 1946 |
|
function parse( $txt, $process_sections = false ) { |
| 1947 |
|
if (is_string( $txt )) { |
| 1948 |
|
$lines = explode( "\n", $txt ); |
| 1949 |
|
} else if (is_array( $txt )) { |
| 1950 |
|
$lines = $txt; |
| 1951 |
|
} else { |
| 1952 |
|
$lines = array(); |
| 1953 |
|
} |
| 1954 |
|
$obj = new stdClass(); |
| 1955 |
|
|
| 1956 |
|
$sec_name = ''; |
| 1957 |
|
$unparsed = 0; |
| 1958 |
|
if (!$lines) { |
| 1959 |
|
return $obj; |
| 1960 |
|
} |
| 1961 |
|
foreach ($lines as $line) { |
| 1962 |
|
// ignore comments |
| 1963 |
|
if ($line && $line[0] == ';') { |
| 1964 |
|
continue; |
| 1965 |
|
} |
| 1966 |
|
$line = trim( $line ); |
| 1967 |
|
|
| 1968 |
|
if ($line == '') { |
| 1969 |
|
continue; |
| 1970 |
|
} |
| 1971 |
|
if ($line && $line[0] == '[' && $line[strlen($line) - 1] == ']') { |
| 1972 |
|
$sec_name = substr( $line, 1, strlen($line) - 2 ); |
| 1973 |
|
if ($process_sections) { |
| 1974 |
|
$obj->$sec_name = new stdClass(); |
| 1975 |
|
} |
| 1976 |
|
} else { |
| 1977 |
|
if ($pos = strpos( $line, '=' )) { |
| 1978 |
|
$property = trim( substr( $line, 0, $pos ) ); |
| 1979 |
|
|
| 1980 |
|
if (substr($property, 0, 1) == '"' && substr($property, -1) == '"') { |
| 1981 |
|
$property = stripcslashes(substr($property,1,count($property) - 2)); |
| 1982 |
|
} |
| 1983 |
|
$value = trim( substr( $line, $pos + 1 ) ); |
| 1984 |
|
if ($value == 'false') { |
| 1985 |
|
$value = false; |
| 1986 |
|
} |
| 1987 |
|
if ($value == 'true') { |
| 1988 |
|
$value = true; |
| 1989 |
|
} |
| 1990 |
|
if (substr( $value, 0, 1 ) == '"' && substr( $value, -1 ) == '"') { |
| 1991 |
|
$value = stripcslashes( substr( $value, 1, count( $value ) - 2 ) ); |
| 1992 |
|
} |
| 1993 |
|
|
| 1994 |
|
if ($process_sections) { |
| 1995 |
|
if ($sec_name != '') { |
| 1996 |
|
$obj->$sec_name->$property = $value; |
| 1997 |
|
} else { |
| 1998 |
|
$obj->$property = $value; |
| 1999 |
|
} |
| 2000 |
|
} else { |
| 2001 |
|
$obj->$property = $value; |
| 2002 |
|
} |
| 2003 |
|
} else { |
| 2004 |
|
if ($line && trim($line[0]) == ';') { |
| 2005 |
|
continue; |
| 2006 |
|
} |
| 2007 |
|
if ($process_sections) { |
| 2008 |
|
$property = '__invalid' . $unparsed++ . '__'; |
| 2009 |
|
if ($process_sections) { |
| 2010 |
|
if ($sec_name != '') { |
| 2011 |
|
$obj->$sec_name->$property = trim($line); |
| 2012 |
|
} else { |
| 2013 |
|
$obj->$property = trim($line); |
| 2014 |
|
} |
| 2015 |
|
} else { |
| 2016 |
|
$obj->$property = trim($line); |
| 2017 |
|
} |
| 2018 |
|
} |
| 2019 |
|
} |
| 2020 |
|
} |
| 2021 |
|
} |
| 2022 |
|
return $obj; |
| 2023 |
|
} |
| 2024 |
|
/** |
| 2025 |
|
* @param string The name of the control, or the default text area if a setup file is not found |
| 2026 |
|
* @return string HTML |
| 2027 |
|
*/ |
| 2028 |
|
function render( $name='params' ) { |
| 2029 |
|
global $mosConfig_absolute_path; |
| 2030 |
|
|
| 2031 |
|
if ($this->_path) { |
| 2032 |
|
if (!is_object( $this->_xmlElem )) { |
| 2033 |
|
require_once( $mosConfig_absolute_path . '/includes/domit/xml_domit_lite_include.php' ); |
| 2034 |
|
|
| 2035 |
|
$xmlDoc =& new DOMIT_Lite_Document(); |
| 2036 |
|
$xmlDoc->resolveErrors( true ); |
| 2037 |
|
if ($xmlDoc->loadXML( $this->_path, false, true )) { |
| 2038 |
|
$element =& $xmlDoc->documentElement; |
| 2039 |
|
|
| 2040 |
|
if ($element->getTagName() == 'mosinstall' && $element->getAttribute( "type" ) == $this->_type) { |
| 2041 |
|
if ($element = &$xmlDoc->getElementsByPath( 'params', 1 )) { |
| 2042 |
|
$this->_xmlElem =& $element; |
| 2043 |
|
} |
| 2044 |
|
} |
| 2045 |
|
} |
| 2046 |
|
} |
| 2047 |
|
} |
| 2048 |
|
|
| 2049 |
|
if (is_object( $this->_xmlElem )) { |
| 2050 |
|
$html = array(); |
| 2051 |
|
$html[] = '<table class="paramlist">'; |
| 2052 |
|
|
| 2053 |
|
$element =& $this->_xmlElem; |
| 2054 |
|
|
| 2055 |
|
if ($description = $element->getAttribute( 'description' )) { |
| 2056 |
|
// add the params description to the display |
| 2057 |
|
$html[] = '<tr><td colspan="3">' . $description . '</td></tr>'; |
| 2058 |
|
} |
| 2059 |
|
|
| 2060 |
|
//$params = mosParseParams( $row->params ); |
| 2061 |
|
$this->_methods = get_class_methods( get_class( $this ) ); |
| 2062 |
|
|
| 2063 |
|
foreach ($element->childNodes as $param) { |
| 2064 |
|
$result = $this->renderParam( $param, $name ); |
| 2065 |
|
$html[] = '<tr>'; |
| 2066 |
|
|
| 2067 |
|
$html[] = '<td width="35%" align="right" valign="top">' . $result[0] . '</td>'; |
| 2068 |
|
$html[] = '<td>' . $result[1] . '</td>'; |
| 2069 |
|
$html[] = '<td width="10%" align="left" valign="top">' . $result[2] . "</td>"; |
| 2070 |
|
|
| 2071 |
|
$html[] = '</tr>'; |
| 2072 |
|
} |
| 2073 |
|
$html[] = '</table>'; |
| 2074 |
|
|
| 2075 |
|
if (count( $element->childNodes ) < 1) { |
| 2076 |
|
$html[] = "<tr><td colspan=\"2\"><i>" . _NO_PARAMS . "</i></td></tr>"; |
| 2077 |
|
} |
| 2078 |
|
return implode( "\n", $html ); |
| 2079 |
|
} else { |
| 2080 |
|
return "<textarea name=\"$name\" cols=\"40\" rows=\"10\" class=\"text_area\">$this->_raw</textarea>"; |
| 2081 |
|
} |
| 2082 |
|
} |
| 2083 |
|
/** |
| 2084 |
|
* @param object A param tag node |
| 2085 |
|
* @param string The control name |
| 2086 |
|
* @return array Any array of the label, the form element and the tooltip |
| 2087 |
|
*/ |
| 2088 |
|
function renderParam( &$param, $control_name='params' ) { |
| 2089 |
|
$result = array(); |
| 2090 |
|
|
| 2091 |
|
$name = $param->getAttribute( 'name' ); |
| 2092 |
|
$label = $param->getAttribute( 'label' ); |
| 2093 |
|
|
| 2094 |
|
$value = $this->get( $name, $param->getAttribute( 'default' ) ); |
| 2095 |
|
$description = $param->getAttribute( 'description' ); |
| 2096 |
|
|
| 2097 |
|
$result[0] = $label ? $label : $name; |
| 2098 |
|
if ( $result[0] == '@spacer' ) { |
| 2099 |
|
$result[0] = '<hr/>'; |
| 2100 |
|
} else if ( $result[0] ) { |
| 2101 |
|
$result[0] .= ':'; |
| 2102 |
|
} |
| 2103 |
|
|
| 2104 |
|
$type = $param->getAttribute( 'type' ); |
| 2105 |
|
|
| 2106 |
|
if (in_array( '_form_' . $type, $this->_methods )) { |
| 2107 |
|
$result[1] = call_user_func( array( &$this, '_form_' . $type ), $name, $value, $param, $control_name ); |
| 2108 |
|
} else { |
| 2109 |
|
$result[1] = _HANDLER . ' = ' . $type; |
| 2110 |
|
} |
| 2111 |
|
|
| 2112 |
|
if ( $description ) { |
| 2113 |
|
$result[2] = mosToolTip( $description, $name ); |
| 2114 |
|
} else { |
| 2115 |
|
$result[2] = ''; |
| 2116 |
|
} |
| 2117 |
|
|
| 2118 |
|
return $result; |
| 2119 |
|
} |
| 2120 |
|
/** |
| 2121 |
|
* @param string The name of the form element |
| 2122 |
|
* @param string The value of the element |
| 2123 |
|
* @param object The xml element for the parameter |
| 2124 |
|
* @param string The control name |
| 2125 |
|
* @return string The html for the element |
| 2126 |
|
*/ |
| 2127 |
|
function _form_text( $name, $value, &$node, $control_name ) { |
| 2128 |
|
$size = $node->getAttribute( 'size' ); |
| 2129 |
|
|
| 2130 |
|
return '<input type="text" name="'. $control_name .'['. $name .']" value="'. $value .'" class="text_area" size="'. $size .'"/>'; |
| 2131 |
|
} |
| 2132 |
|
/** |
| 2133 |
|
* @param string The name of the form element |
| 2134 |
|
* @param string The value of the element |
| 2135 |
|
* @param object The xml element for the parameter |
| 2136 |
|
* @param string The control name |
| 2137 |
|
* @return string The html for the element |
| 2138 |
|
*/ |
| 2139 |
|
function _form_list( $name, $value, &$node, $control_name ) { |
| 2140 |
|
$size = $node->getAttribute( 'size' ); |
| 2141 |
|
|
| 2142 |
|
$options = array(); |
| 2143 |
|
foreach ($node->childNodes as $option) { |
| 2144 |
|
$val = $option->getAttribute( 'value' ); |
| 2145 |
|
$text = $option->gettext(); |
| 2146 |
|
$options[] = mosHTML::makeOption( $val, $text ); |
| 2147 |
|
} |
| 2148 |
|
|
| 2149 |
|
return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value ); |
| 2150 |
|
} |
| 2151 |
|
/** |
| 2152 |
|
* @param string The name of the form element |
| 2153 |
|
* @param string The value of the element |
| 2154 |
|
* @param object The xml element for the parameter |
| 2155 |
|
* @param string The control name |
| 2156 |
|
* @return string The html for the element |
| 2157 |
|
*/ |
| 2158 |
|
function _form_radio( $name, $value, &$node, $control_name ) { |
| 2159 |
|
$options = array(); |
| 2160 |
|
foreach ($node->childNodes as $option) { |
| 2161 |
|
$val = $option->getAttribute( 'value' ); |
| 2162 |
|
$text = $option->gettext(); |
| 2163 |
|
$options[] = mosHTML::makeOption( $val, $text, true ); |
| 2164 |
|
} |
| 2165 |
|
|
| 2166 |
|
return mosHTML::radioList( $options, ''. $control_name .'['. $name .']', '', $value ); |
| 2167 |
|
} |
| 2168 |
|
/** |
| 2169 |
|
* @param string The name of the form element |
| 2170 |
|
* @param string The value of the element |
| 2171 |
|
* @param object The xml element for the parameter |
| 2172 |
|
* @param string The control name |
| 2173 |
|
* @return string The html for the element |
| 2174 |
|
*/ |
| 2175 |
|
function _form_mos_section( $name, $value, &$node, $control_name ) { |
| 2176 |
|
global $database; |
| 2177 |
|
|
| 2178 |
|
$query = "SELECT id AS value, title AS text" |
| 2179 |
|
. "\n FROM #__sections" |
| 2180 |
|
. "\n WHERE published='1' AND scope='content'" |
| 2181 |
|
. "\n ORDER BY title" |
| 2182 |
|
; |
| 2183 |
|
$database->setQuery( $query ); |
| 2184 |
|
$options = $database->loadObjectList(); |
| 2185 |
|
array_unshift( $options, mosHTML::makeOption( '0', '- Select Content Section -' ) ); |
| 2186 |
|
|
| 2187 |
|
return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value ); |
| 2188 |
|
} |
| 2189 |
|
/** |
| 2190 |
|
* @param string The name of the form element |
| 2191 |
|
* @param string The value of the element |
| 2192 |
|
* @param object The xml element for the parameter |
| 2193 |
|
* @param string The control name |
| 2194 |
|
* @return string The html for the element |
| 2195 |
|
*/ |
| 2196 |
|
function _form_mos_category( $name, $value, &$node, $control_name ) { |
| 2197 |
|
global $database; |
| 2198 |
|
|
| 2199 |
|
$query = "SELECT c.id AS value, CONCAT_WS( '/',s.title, c.title ) AS text" |
| 2200 |
|
. "\n FROM #__categories AS c" |
| 2201 |
|
. "\n LEFT JOIN #__sections AS s ON s.id=c.section" |
| 2202 |
|
. "\n WHERE c.published='1' AND s.scope='content'" |
| 2203 |
|
. "\n ORDER BY c.title" |
| 2204 |
|
; |
| 2205 |
|
$database->setQuery( $query ); |
| 2206 |
|
$options = $database->loadObjectList(); |
| 2207 |
|
array_unshift( $options, mosHTML::makeOption( '0', '- Select Content Category -' ) ); |
| 2208 |
|
|
| 2209 |
|
return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value ); |
| 2210 |
|
} |
| 2211 |
|
/** |
| 2212 |
|
* @param string The name of the form element |
| 2213 |
|
* @param string The value of the element |
| 2214 |
|
* @param object The xml element for the parameter |
| 2215 |
|
* @param string The control name |
| 2216 |
|
* @return string The html for the element |
| 2217 |
|
*/ |
| 2218 |
|
// function _form_mos_menu( $name, $value, &$node, $control_name ) { |
| 2219 |
|
// global $database; |
| 2220 |
|
// |
| 2221 |
|
// $menuTypes = $mainframe->menutypes(); |
| 2222 |
|
// |
| 2223 |
|
// foreach($menuTypes as $menutype ) { |
| 2224 |
|
// $options[] = mosHTML::makeOption( $menutype, $menutype ); |
| 2225 |
|
// } |
| 2226 |
|
// array_unshift( $options, mosHTML::makeOption( '', '- Select Menu -' ) ); |
| 2227 |
|
// |
| 2228 |
|
// return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value ); |
| 2229 |
|
// } |
| 2230 |
|
/** |
| 2231 |
|
* @param string The name of the form element |
| 2232 |
|
* @param string The value of the element |
| 2233 |
|
* @param object The xml element for the parameter |
| 2234 |
|
* @param string The control name |
| 2235 |
|
* @return string The html for the element |
| 2236 |
|
*/ |
| 2237 |
|
function _form_imagelist( $name, $value, &$node, $control_name ) { |
| 2238 |
|
global $mosConfig_absolute_path; |
| 2239 |
|
|
| 2240 |
|
// path to images directory |
| 2241 |
|
$path = $mosConfig_absolute_path . $node->getAttribute( 'directory' ); |
| 2242 |
|
$files = mosReadDirectory( $path, '\.png$|\.gif$|\.jpg$|\.bmp$|\.ico$' ); |
| 2243 |
|
|
| 2244 |
|
$options = array(); |
| 2245 |
|
foreach ($files as $file) { |
| 2246 |
|
$options[] = mosHTML::makeOption( $file, $file ); |
| 2247 |
|
} |
| 2248 |
|
if ( !$node->getAttribute( 'hide_none' ) ) { |
| 2249 |
|
array_unshift( $options, mosHTML::makeOption( '-1', '- Do not use an image -' ) ); |
| 2250 |
|
} |
| 2251 |
|
if ( !$node->getAttribute( 'hide_default' ) ) { |
| 2252 |
|
array_unshift( $options, mosHTML::makeOption( '', '- Use Default image -' ) ); |
| 2253 |
|
} |
| 2254 |
|
|
| 2255 |
|
return mosHTML::selectList( $options, ''. $control_name .'['. $name .']', 'class="inputbox"', 'value', 'text', $value ); |
| 2256 |
|
} |
| 2257 |
|
|
| 2258 |
|
/** |
| 2259 |
|
* @param string The name of the form element |
| 2260 |
|
* @param string The value of the element |
| 2261 |
|
* @param object The xml element for the parameter |
| 2262 |
|
* @param string The control name |
| 2263 |
|
* @return string The html for the element |
| 2264 |
|
*/ |
| 2265 |
|
function _form_textarea( $name, $value, &$node, $control_name ) { |
| 2266 |
|
$rows = $node->getAttribute( 'rows' ); |
| 2267 |
|
$cols = $node->getAttribute( 'cols' ); |
| 2268 |
|
// convert <br /> tags so they are not visible when editing |
| 2269 |
|
$value = str_replace( '<br />', "\n", $value ); |
| 2270 |
|
|
| 2271 |
|
return '<textarea name="params['. $name .']" cols="'. $cols .'" rows="'. $rows .'" class="text_area">'. $value .'</textarea>'; |
| 2272 |
|
} |
| 2273 |
|
|
| 2274 |
|
/** |
| 2275 |
|
* @param string The name of the form element |
| 2276 |
|
* @param string The value of the element |
| 2277 |
|
* @param object The xml element for the parameter |
| 2278 |
|
* @param string The control name |
| 2279 |
|
* @return string The html for the element |
| 2280 |
|
*/ |
| 2281 |
|
function _form_spacer( $name, $value, &$node, $control_name ) { |
| 2282 |
|
if ( $value ) { |
| 2283 |
|
return $value; |
| 2284 |
|
} else { |
| 2285 |
|
return '<hr />'; |
| 2286 |
|
} |
| 2287 |
|
} |
| 2288 |
|
|
| 2289 |
|
/** |
| 2290 |
|
* special handling for textarea param |
| 2291 |
|
*/ |
| 2292 |
|
function textareaHandling( &$txt ) { |
| 2293 |
|
$total = count( $txt ); |
| 2294 |
|
for( $i=0; $i < $total; $i++ ) { |
| 2295 |
|
if ( strstr( $txt[$i], "\n" ) ) { |
| 2296 |
|
$txt[$i] = str_replace( "\n", '<br />', $txt[$i] ); |
| 2297 |
|
} |
| 2298 |
|
} |
| 2299 |
|
$txt = implode( "\n", $txt ); |
| 2300 |
|
|
| 2301 |
|
return $txt; |
| 2302 |
|
} |
| 2303 |
|
} |
| 2304 |
|
|
| 2305 |
|
/** |
| 2306 |
* Page generation time |
* Page generation time |
| 2307 |
* @package Mambo |
* @package Mambo |
| 2308 |
*/ |
*/ |
| 2329 |
if (!isset($adminside)) $adminside = 0; |
if (!isset($adminside)) $adminside = 0; |
| 2330 |
if (!isset($indextype)) $indextype = 1; |
if (!isset($indextype)) $indextype = 1; |
| 2331 |
|
|
| 2332 |
|
|
| 2333 |
|
$configuration =& mamboCore::getMamboCore(); |
| 2334 |
|
$configuration->handleGlobals(); |
| 2335 |
|
|
| 2336 |
|
require($configuration->rootPath().'/includes/version.php'); |
| 2337 |
$_VERSION =& new version(); |
$_VERSION =& new version(); |
| 2338 |
|
|
| 2339 |
$version = $_VERSION->PRODUCT .' '. $_VERSION->RELEASE .'.'. $_VERSION->DEV_LEVEL .' ' |
$version = $_VERSION->PRODUCT .' '. $_VERSION->RELEASE .'.'. $_VERSION->DEV_LEVEL .' ' |
| 2341 |
.' [ '.$_VERSION->CODENAME .' ] '. $_VERSION->RELDATE .' ' |
.' [ '.$_VERSION->CODENAME .' ] '. $_VERSION->RELDATE .' ' |
| 2342 |
. $_VERSION->RELTIME .' '. $_VERSION->RELTZ; |
. $_VERSION->RELTIME .' '. $_VERSION->RELTZ; |
| 2343 |
|
|
|
$configuration =& mamboCore::getMamboCore(); |
|
|
|
|
|
$configuration->handleGlobals(); |
|
|
|
|
| 2344 |
if (phpversion() < '4.2.0') require_once( $configuration->rootPath() . '/includes/compat.php41x.php' ); |
if (phpversion() < '4.2.0') require_once( $configuration->rootPath() . '/includes/compat.php41x.php' ); |
| 2345 |
if (phpversion() < '4.3.0') require_once( $configuration->rootPath() . '/includes/compat.php42x.php' ); |
if (phpversion() < '4.3.0') require_once( $configuration->rootPath() . '/includes/compat.php42x.php' ); |
| 2346 |
|
|
|
@set_magic_quotes_runtime( 0 ); |
|
|
|
|
|
if (@$mosConfig_error_reporting === 0) error_reporting( 0 ); |
|
|
elseif (@$mosConfig_error_reporting > 0) error_reporting( $mosConfig_error_reporting ); |
|
|
|
|
| 2347 |
$local_backup_path = $configuration->rootPath().'/administrator/backups'; |
$local_backup_path = $configuration->rootPath().'/administrator/backups'; |
| 2348 |
$media_path = $configuration->rootPath().'/media/'; |
$media_path = $configuration->rootPath().'/media/'; |
| 2349 |
$image_path = $configuration->rootPath().'/images/stories'; |
$image_path = $configuration->rootPath().'/images/stories'; |
| 2350 |
$image_size = 100; |
$image_size = 100; |
| 2351 |
|
|
| 2352 |
/** retrieve all possible request string (or form) arguments */ |
$database = mamboDatabase::getInstance(); |
| 2353 |
|
$database->debug(mamboCore::get('mosConfig_debug')); |
| 2354 |
|
|
| 2355 |
|
if (!$adminside) { |
| 2356 |
|
$sefcode = $configuration->rootPath().'/components/com_sef/sef.php'; |
| 2357 |
|
if (file_exists($sefcode)) require_once($sefcode); |
| 2358 |
|
else require_once($configuration->rootPath().'/includes/sef.php'); |
| 2359 |
|
$urlerror = 0; |
| 2360 |
|
if (mamboCore::get('mosConfig_sef') AND $indextype == 3) { |
| 2361 |
|
$sef = mosSEF::getInstance(); |
| 2362 |
|
$urlerror = $sef->sefRetrieval(mamboCore::get('mosConfig_register_globals')); |
| 2363 |
|
$indextype = 1; |
| 2364 |
|
} |
| 2365 |
|
} |
| 2366 |
|
|
| 2367 |
|
/** retrieve some possible request string (or form) arguments */ |
| 2368 |
$type = mosGetParam($_REQUEST, 'type', 1); |
$type = mosGetParam($_REQUEST, 'type', 1); |
|
$no_html = mosGetParam( $_REQUEST, 'no_html', 0 ); |
|
| 2369 |
$act = mosGetParam( $_REQUEST, 'act', '' ); |
$act = mosGetParam( $_REQUEST, 'act', '' ); |
| 2370 |
$do_pdf = mosGetParam( $_REQUEST, 'do_pdf', 0 ); |
$do_pdf = mosGetParam( $_REQUEST, 'do_pdf', 0 ); |
|
$pop = mosGetParam( $_REQUEST, 'pop', 0 ); |
|
| 2371 |
$id = mosGetParam( $_REQUEST, 'id', 0 ); |
$id = mosGetParam( $_REQUEST, 'id', 0 ); |
| 2372 |
$task = mosGetParam($_REQUEST, 'task', ''); |
$task = mosGetParam($_REQUEST, 'task', ''); |
| 2373 |
$act = strtolower(mosGetParam($_REQUEST, 'act', '')); |
$act = strtolower(mosGetParam($_REQUEST, 'act', '')); |
| 2374 |
$section = mosGetParam($_REQUEST, 'section', ''); |
$section = mosGetParam($_REQUEST, 'section', ''); |
| 2375 |
$no_html = strtolower(mosGetParam($_REQUEST, 'no_html', '')); |
$no_html = strtolower(mosGetParam($_REQUEST, 'no_html', '')); |
| 2376 |
|
|
|
$database = mamboDatabase::getInstance(); |
|
|
$database->debug(mamboCore::get('mosConfig_debug')); |
|
|
|
|
| 2377 |
if ($adminside) { |
if ($adminside) { |
| 2378 |
$option = strtolower(mosGetParam($_REQUEST,'option','com_admin')); |
// Start ACL |
| 2379 |
require_once($configuration->rootPath().'/includes/gacl.class.php' ); |
require_once($configuration->rootPath().'/includes/gacl.class.php' ); |
| 2380 |
require_once($configuration->rootPath().'/includes/gacl_api.class.php' ); |
require_once($configuration->rootPath().'/includes/gacl_api.class.php' ); |
| 2381 |
$acl = new gacl_api(); |
$acl = new gacl_api(); |
| 2382 |
|
// Handle special admin side options |
| 2383 |
|
$option = strtolower(mosGetParam($_REQUEST,'option','com_admin')); |
| 2384 |
|
// Login will, if it succeeds, start a new session and set $my |
| 2385 |
if ($option == 'login') { |
if ($option == 'login') { |
| 2386 |
require_once($configuration->rootPath().'/includes/authenticator.php'); |
require_once($configuration->rootPath().'/includes/authenticator.php'); |
| 2387 |
$authenticator = mamboAuthenticator::getInstance(); |
$authenticator = mamboAuthenticator::getInstance(); |
| 2388 |
$my = $authenticator->loginAdmin($acl); |
$my = $authenticator->loginAdmin($acl); |
| 2389 |
} |
} |
| 2390 |
|
// If this is not login, we should already have a valid admin session |
| 2391 |
else { |
else { |
| 2392 |
session_name(md5(mamboCore::get('mosConfig_live_site'))); |
session_name(md5(mamboCore::get('mosConfig_live_site'))); |
| 2393 |
session_start(); |
session_start(); |
| 2394 |
|
// Handle the remaining special options |
| 2395 |
if ($option == 'logout') { |
if ($option == 'logout') { |
| 2396 |
require($configuration->rootPath().'/administrator/logout.php'); |
require($configuration->rootPath().'/administrator/logout.php'); |
| 2397 |
exit(); |
exit(); |
| 2398 |
} |
} |
|
else { |
|
|
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
|
|
$my = checkAdminSession($database); |
|
| 2399 |
if ($option == 'simple_mode') $admin_mode = 'on'; |
if ($option == 'simple_mode') $admin_mode = 'on'; |
| 2400 |
elseif ($option == 'advanced_mode') $admin_mode = 'off'; |
elseif ($option == 'advanced_mode') $admin_mode = 'off'; |
| 2401 |
else $admin_mode = mosGetParam($_SESSION, 'simple_editing', ''); |
else $admin_mode = mosGetParam($_SESSION, 'simple_editing', ''); |
| 2402 |
$_SESSION['simple_editing'] = mosGetParam($_POST, 'simple_editing', $admin_mode); |
$_SESSION['simple_editing'] = mosGetParam($_POST, 'simple_editing', $admin_mode); |
| 2403 |
|
// Include admin side functions, check that we have a valid admin side session |
| 2404 |
|
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
| 2405 |
|
$my = checkAdminSession($database); |
| 2406 |
} |
} |
| 2407 |
} |
// We can now create the mainframe object |
| 2408 |
$mainframe =& new mosMainFrame($database, $option, '..', true); |
$mainframe =& new mosMainFrame($database, $option, '..', true); |
| 2409 |
|
// Provided $my is set, we have a valid admin side session and can include remaining code |
| 2410 |
if ($my) { |
if ($my) { |
| 2411 |
|
mamboCore::set('currentUser', $my); |
| 2412 |
require_once( $configuration->rootPath().'/includes/mambo.php' ); |
require_once( $configuration->rootPath().'/includes/mambo.php' ); |
| 2413 |
require_once ($configuration->rootPath().'/includes/mambofunc.php'); |
require_once ($configuration->rootPath().'/includes/mambofunc.php'); |
| 2414 |
require_once ($configuration->rootPath().'/includes/mamboHTML.php'); |
require_once ($configuration->rootPath().'/includes/mamboHTML.php'); |
| 2415 |
require_once( $configuration->rootPath().'/administrator/includes/mosAdminMenus.php'); |
require_once( $configuration->rootPath().'/administrator/includes/mosAdminMenus.php'); |
| 2416 |
require_once( $configuration->rootPath().'/includes/mamboxml.php' ); |
require_once( $configuration->rootPath().'/includes/mamboxml.php' ); |
| 2417 |
|
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
| 2418 |
|
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
| 2419 |
$_MAMBOTS = mosMambotHandler::getInstance(); |
$_MAMBOTS = mosMambotHandler::getInstance(); |
| 2420 |
// start the html output |
// If no_html is set, we avoid starting the template, and go straight to the component |
| 2421 |
if ($no_html) { |
if ($no_html) { |
| 2422 |
if ($path = $mainframe->getPath( "admin" )) require $path; |
if ($path = $mainframe->getPath( "admin" )) require $path; |
| 2423 |
exit(); |
exit(); |
| 2424 |
} |
} |
| 2425 |
$configuration->initGzip(); |
$configuration->initGzip(); |
| 2426 |
require_once($configuration->rootPath().'/administrator/includes/admin.php'); |
// When adminside = 3 we assume that HTML is being explicitly written and do nothing more |
| 2427 |
if ($adminside != 3) { |
if ($adminside != 3) { |
| 2428 |
$path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/index.php'; |
$path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/index.php'; |
| 2429 |
require_once($path); |
require_once($path); |
| 2430 |
$configuration->doGzip(); |
$configuration->doGzip(); |
| 2431 |
} |
} |
| 2432 |
|
else { |
| 2433 |
|
$pop = mosGetParam($_REQUEST, 'pop', ''); |
| 2434 |
|
if ($pop) require_once($configuration->rootPath()."/administrator/popups/$pop"); |
| 2435 |
|
else require_once($configuration->rootPath()."/administrator/popups/index3pop.php"); |
| 2436 |
|
$configuration->doGzip(); |
| 2437 |
|
} |
| 2438 |
} |
} |
| 2439 |
|
// If $my was not set, the only possibility is to ask for an admin side login |
| 2440 |
else { |
else { |
| 2441 |
$configuration->initGzip(); |
$configuration->initGzip(); |
| 2442 |
$path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/login.php'; |
$path = $configuration->rootPath().'/administrator/templates/'.$mainframe->getTemplate().'/login.php'; |
| 2444 |
$configuration->doGzip(); |
$configuration->doGzip(); |
| 2445 |
} |
} |
| 2446 |
} |
} |
| 2447 |
|
// Finished admin side; the rest is user side code: |
| 2448 |
else { |
else { |
|
$sefcode = $configuration->rootPath().'/components/com_sef/sef.php'; |
|
|
if (file_exists($sefcode)) require_once($sefcode); |
|
|
else require_once($configuration->rootPath().'/includes/sef.php'); |
|
|
$urlerror = 0; |
|
|
if (mamboCore::get('mosConfig_sef') AND $indextype == 3) { |
|
|
$sef = mosSEF::getInstance(); |
|
|
$urlerror = $sef->sefRetrieval(mamboCore::get('mosConfig_register_globals')); |
|
|
$indextype = 1; |
|
|
$configuration->handleGlobals(); |
|
|
} |
|
| 2449 |
$option = $configuration->determineOptionAndItemid(); |
$option = $configuration->determineOptionAndItemid(); |
| 2450 |
|
$configuration->handleGlobals(); |
| 2451 |
$Itemid = $configuration->get('Itemid'); |
$Itemid = $configuration->get('Itemid'); |
| 2452 |
|
|
| 2453 |
$mainframe =& new mosMainFrame($database, $option, '.'); |
$mainframe =& new mosMainFrame($database, $option, '.'); |
| 2454 |
$session = mosSession::getCurrent(); |
$session = mosSession::getCurrent(); |
| 2455 |
|
|
| 2458 |
|
|
| 2459 |
$my =& new mosUser($database); |
$my =& new mosUser($database); |
| 2460 |
$my->getSessionData(); |
$my->getSessionData(); |
| 2461 |
|
mamboCore::set('currentUser',$my); |
| 2462 |
$configuration->offlineCheck($my, $database); |
$configuration->offlineCheck($my, $database); |
| 2463 |
$gid = intval( $my->gid ); |
$gid = intval( $my->gid ); |
| 2464 |
// gets template for page |
// gets template for page |
| 2485 |
require_once( $configuration->rootPath() . '/includes/gacl_api.class.php' ); |
require_once( $configuration->rootPath() . '/includes/gacl_api.class.php' ); |
| 2486 |
$acl = new gacl_api(); |
$acl = new gacl_api(); |
| 2487 |
|
|
| 2488 |
/** @global A places to store information from processing of the component */ |
/** Get the component handler */ |
| 2489 |
$_MOS_OPTION = array(); |
require_once( $configuration->rootPath() . '/includes/cmtclasses.php' ); |
| 2490 |
|
$c_handler = mosComponentHandler::getInstance(); |
| 2491 |
ob_start(); |
$c_handler->startBuffer(); |
| 2492 |
|
|
| 2493 |
if (!$urlerror AND $path = $mainframe->getPath( 'front' )) { |
if (!$urlerror AND $path = $mainframe->getPath( 'front' )) { |
| 2494 |
$menuhandler = mosMenuHandler::getInstance(); |
$menuhandler = mosMenuHandler::getInstance(); |
| 2498 |
else mosNotAuth(); |
else mosNotAuth(); |
| 2499 |
} |
} |
| 2500 |
else { |
else { |
| 2501 |
header ("HTTP/1.0 404 Not Found"); |
header ('HTTP/1.1 404 Not Found'); |
| 2502 |
|
$mainframe->setPageTitle('404 Error - page not found'); |
| 2503 |
include ($configuration->rootPath().'/page404.php'); |
include ($configuration->rootPath().'/page404.php'); |
| 2504 |
} |
} |
| 2505 |
|
|
| 2506 |
$_MOS_OPTION['buffer'] = ob_get_contents(); |
$c_handler->endBuffer(); |
|
ob_end_clean(); |
|
| 2507 |
|
|
| 2508 |
$configuration->initGzip(); |
$configuration->initGzip(); |
| 2509 |
|
|
| 2510 |
$configuration->standardHeaders(); |
$configuration->standardHeaders(); |
|
|
|
| 2511 |
if ($indextype == 1) { |
if ($indextype == 1) { |
| 2512 |
// loads template file |
// loads template file |
| 2513 |
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { |
if ( !file_exists( 'templates/'. $cur_template .'/index.php' ) ) { |