| 1 |
<?php |
<?php |
| 2 |
|
/** |
| 3 |
|
* @package Mambo |
| 4 |
|
* @author Mambo Foundation Inc see README.php |
| 5 |
|
* @copyright Mambo Foundation Inc. |
| 6 |
|
* See COPYRIGHT.php for copyright notices and details. |
| 7 |
|
* @license GNU/GPL Version 2, see LICENSE.php |
| 8 |
|
* Mambo is free software; you can redistribute it and/or |
| 9 |
|
* modify it under the terms of the GNU General Public License |
| 10 |
|
* as published by the Free Software Foundation; version 2 of the License. |
| 11 |
|
*/ |
| 12 |
|
|
| 13 |
/** |
/** |
| 14 |
* Mambo basic error object |
* Mambo basic error object |
| 18 |
define ('_MOS_ERROR_SEVERE', 2); |
define ('_MOS_ERROR_SEVERE', 2); |
| 19 |
define ('_MOS_ERROR_FATAL', 3); |
define ('_MOS_ERROR_FATAL', 3); |
| 20 |
|
|
| 21 |
|
/** |
| 22 |
|
* Enter description here... |
| 23 |
|
* |
| 24 |
|
*/ |
| 25 |
class mosError { |
class mosError { |
| 26 |
|
/** |
| 27 |
|
* Enter description here... |
| 28 |
|
* |
| 29 |
|
* @var unknown_type |
| 30 |
|
*/ |
| 31 |
var $text = ''; |
var $text = ''; |
| 32 |
|
/** |
| 33 |
|
* Enter description here... |
| 34 |
|
* |
| 35 |
|
* @var unknown_type |
| 36 |
|
*/ |
| 37 |
var $level = 0; |
var $level = 0; |
| 38 |
|
|
| 39 |
|
/** |
| 40 |
|
* Enter description here... |
| 41 |
|
* |
| 42 |
|
* @param unknown_type $text |
| 43 |
|
* @param unknown_type $level |
| 44 |
|
* @return mosError |
| 45 |
|
*/ |
| 46 |
function mosError ($text='', $level=_MOS_ERROR_INFORM) { |
function mosError ($text='', $level=_MOS_ERROR_INFORM) { |
| 47 |
$this->text = $text; |
$this->text = $text; |
| 48 |
$this->level = $level; |
$this->level = $level; |
| 53 |
* Mambo group of errors for some particular operation |
* Mambo group of errors for some particular operation |
| 54 |
*/ |
*/ |
| 55 |
class mosErrorSet { |
class mosErrorSet { |
| 56 |
|
/** |
| 57 |
|
* Enter description here... |
| 58 |
|
* |
| 59 |
|
* @var unknown_type |
| 60 |
|
*/ |
| 61 |
var $errors = array(); |
var $errors = array(); |
| 62 |
|
/** |
| 63 |
|
* Enter description here... |
| 64 |
|
* |
| 65 |
|
* @var unknown_type |
| 66 |
|
*/ |
| 67 |
var $maxlevel = 0; |
var $maxlevel = 0; |
| 68 |
|
|
| 69 |
// Parameter is an error object |
// Parameter is an error object |
| 70 |
|
/** |
| 71 |
|
* Enter description here... |
| 72 |
|
* |
| 73 |
|
* @param unknown_type $error |
| 74 |
|
*/ |
| 75 |
function addError ($error) { |
function addError ($error) { |
| 76 |
$this->errors[] = $error; |
$this->errors[] = $error; |
| 77 |
if ($error->level > $this->maxlevel) $this->maxlevel = $error->level; |
if ($error->level > $this->maxlevel) $this->maxlevel = $error->level; |
| 78 |
} |
} |
| 79 |
|
|
| 80 |
|
/** |
| 81 |
|
* Enter description here... |
| 82 |
|
* |
| 83 |
|
* @param unknown_type $text |
| 84 |
|
* @param unknown_type $level |
| 85 |
|
*/ |
| 86 |
function addErrorDetails ($text='', $level=_MOS_ERROR_INFORM) { |
function addErrorDetails ($text='', $level=_MOS_ERROR_INFORM) { |
| 87 |
$error = new mosError($text, $level); |
$error = new mosError($text, $level); |
| 88 |
$this->addError($error); |
$this->addError($error); |
| 89 |
} |
} |
| 90 |
|
|
| 91 |
|
/** |
| 92 |
|
* Enter description here... |
| 93 |
|
* |
| 94 |
|
* @return unknown |
| 95 |
|
*/ |
| 96 |
function &getErrors () { |
function &getErrors () { |
| 97 |
return $this->errors; |
return $this->errors; |
| 98 |
} |
} |
| 99 |
|
|
| 100 |
|
/** |
| 101 |
|
* Enter description here... |
| 102 |
|
* |
| 103 |
|
* @return unknown |
| 104 |
|
*/ |
| 105 |
function getMaxLevel () { |
function getMaxLevel () { |
| 106 |
return $this->maxlevel; |
return $this->maxlevel; |
| 107 |
} |
} |
| 108 |
|
|
| 109 |
|
/** |
| 110 |
|
* Enter description here... |
| 111 |
|
* |
| 112 |
|
* @return unknown |
| 113 |
|
*/ |
| 114 |
function getCount () { |
function getCount () { |
| 115 |
return count($this->errors); |
return count($this->errors); |
| 116 |
} |
} |
| 117 |
|
|
| 118 |
|
/** |
| 119 |
|
* Enter description here... |
| 120 |
|
* |
| 121 |
|
* @param unknown_type $errorset |
| 122 |
|
*/ |
| 123 |
function mergeAnother ($errorset) { |
function mergeAnother ($errorset) { |
| 124 |
$this->errors = array_merge($this->errors, $errorset->errors); |
$this->errors = array_merge($this->errors, $errorset->errors); |
| 125 |
} |
} |
| 127 |
} |
} |
| 128 |
|
|
| 129 |
|
|
| 130 |
|
/* This is the new error handler to store errors in the database |
| 131 |
|
class mosErrorHandler { |
| 132 |
|
var $types = array ( |
| 133 |
|
E_STRICT => 'Strict check', |
| 134 |
|
E_USER_WARNING => 'User Warning', |
| 135 |
|
E_USER_NOTICE => 'User Notice', |
| 136 |
|
E_WARNING => 'Warning', |
| 137 |
|
E_NOTICE => 'Notice', |
| 138 |
|
E_CORE_WARNING => 'Core Warning', |
| 139 |
|
E_COMPILE_WARNING => 'Compile Warning', |
| 140 |
|
E_USER_ERROR => 'User Error', |
| 141 |
|
E_ERROR => 'Error', |
| 142 |
|
E_PARSE => 'Parse error', |
| 143 |
|
E_CORE_ERROR => 'Core Error', |
| 144 |
|
E_COMPILE_ERROR => 'Compile Error' |
| 145 |
|
); |
| 146 |
|
|
| 147 |
|
function mosErrorHandler () { |
| 148 |
|
set_error_handler(array(&$this, 'handler')); |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
function handler ($errno, $errstr, $errfile, $errline, $errcontext) { |
| 152 |
|
if ($errno = E_STRICT) return; |
| 153 |
|
$string = $this->types[$errno].': '.$errstr.' in '.$errfile.' at '.$errline; |
| 154 |
|
$database =& mamboDatabase::getInstance(); |
| 155 |
|
if (eregi('^(sql)$', $errstr)) { |
| 156 |
|
$extra = $database->getErrorMsg(); |
| 157 |
|
} |
| 158 |
|
if (function_exists('debug_backtrace')) { |
| 159 |
|
foreach(debug_backtrace() as $back) { |
| 160 |
|
if (@$back['file']) { |
| 161 |
|
$extra .= "\n".$back['file'].':'.$back['line']; |
| 162 |
|
} |
| 163 |
|
} |
| 164 |
|
} |
| 165 |
|
$database->setQuery("DELETE FROM #__errors WHERE file=$errfile AND line=$errline AND number=$errno"); |
| 166 |
|
$database->query(); |
| 167 |
|
$database->setQuery("INSERT INTO #__errors VALUES (0, $errno, '$errfile', $errline, '$string', '$extra')"); |
| 168 |
|
$database->query(); |
| 169 |
|
} |
| 170 |
|
} |
| 171 |
|
*/ |
| 172 |
|
|
| 173 |
|
/** |
| 174 |
|
* Enter description here... |
| 175 |
|
* |
| 176 |
|
*/ |
| 177 |
class mamboCore { |
class mamboCore { |
| 178 |
|
/** |
| 179 |
|
* Enter description here... |
| 180 |
|
* |
| 181 |
|
* @var unknown_type |
| 182 |
|
*/ |
| 183 |
var $rootPath = ''; |
var $rootPath = ''; |
| 184 |
|
/** |
| 185 |
|
* Enter description here... |
| 186 |
|
* |
| 187 |
|
* @var unknown_type |
| 188 |
|
*/ |
| 189 |
var $Itemid = 0; |
var $Itemid = 0; |
| 190 |
|
/** |
| 191 |
|
* Enter description here... |
| 192 |
|
* |
| 193 |
|
* @var unknown_type |
| 194 |
|
*/ |
| 195 |
var $option = ''; |
var $option = ''; |
| 196 |
|
/** |
| 197 |
|
* Enter description here... |
| 198 |
|
* |
| 199 |
|
* @var unknown_type |
| 200 |
|
*/ |
| 201 |
var $subdirectory; |
var $subdirectory; |
| 202 |
|
/** |
| 203 |
|
* Enter description here... |
| 204 |
|
* |
| 205 |
|
* @var unknown_type |
| 206 |
|
*/ |
| 207 |
var $current_user = null; |
var $current_user = null; |
| 208 |
|
/** |
| 209 |
|
* Enter description here... |
| 210 |
|
* |
| 211 |
|
* @var unknown_type |
| 212 |
|
*/ |
| 213 |
var $do_gzip_compress = false; |
var $do_gzip_compress = false; |
| 214 |
|
/** |
| 215 |
|
* Enter description here... |
| 216 |
|
* |
| 217 |
|
* @var unknown_type |
| 218 |
|
*/ |
| 219 |
var $init_errorlevel = 0; |
var $init_errorlevel = 0; |
| 220 |
|
|
| 221 |
|
/** |
| 222 |
|
* Enter description here... |
| 223 |
|
* |
| 224 |
|
* @return mamboCore |
| 225 |
|
*/ |
| 226 |
function mamboCore () { |
function mamboCore () { |
| 227 |
global $adminside; |
global $adminside; |
| 228 |
$this->init_errorlevel = error_reporting(0); |
$this->init_errorlevel = error_reporting(0); |
| 229 |
$this->rootPath = str_replace('\\', '/', realpath('../')); |
//$this->rootPath = str_replace('\\', '/', realpath(str_replace('includes', '', dirname(__FILE__)))); |
| 230 |
|
$this->rootPath = str_replace('\\', '/',str_replace('includes', '', dirname(__FILE__))); |
| 231 |
$this->checkConfig(); |
$this->checkConfig(); |
| 232 |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 233 |
$this->getConfig(); |
$this->getConfig(); |
| 237 |
else error_reporting($this->init_errorlevel); |
else error_reporting($this->init_errorlevel); |
| 238 |
} |
} |
| 239 |
|
|
| 240 |
|
/** |
| 241 |
|
* Enter description here... |
| 242 |
|
* |
| 243 |
|
* @return unknown |
| 244 |
|
*/ |
| 245 |
function &getMamboCore () { |
function &getMamboCore () { |
| 246 |
static $instance; |
static $instance; |
| 247 |
if (!is_object($instance)) $instance = new mamboCore(); |
if (!is_object($instance)) $instance = new mamboCore(); |
| 248 |
return $instance; |
return $instance; |
| 249 |
} |
} |
| 250 |
|
|
| 251 |
|
/** |
| 252 |
|
* Enter description here... |
| 253 |
|
* |
| 254 |
|
* @return unknown |
| 255 |
|
*/ |
| 256 |
function rootPath () { |
function rootPath () { |
| 257 |
if (realpath($this->rootPath) === false) die ('Invalid program load path'); |
//if (realpath($this->rootPath) === false) die ('Invalid program load path'); |
| 258 |
|
if (file_exists($this->rootPath) === false) die ('Invalid program load path'); |
| 259 |
return $this->rootPath; |
return $this->rootPath; |
| 260 |
} |
} |
| 261 |
|
|
| 262 |
|
/** |
| 263 |
|
* Enter description here... |
| 264 |
|
* |
| 265 |
|
* @param unknown_type $property |
| 266 |
|
* @return unknown |
| 267 |
|
*/ |
| 268 |
function get ($property) { |
function get ($property) { |
| 269 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 270 |
if ($property == 'mosConfig_absolute_path') { |
if ($property == 'mosConfig_absolute_path') { |
| 271 |
if (realpath($config->mosConfig_absolute_path) === false) die ('Invalid program load path'); |
//if (realpath($config->mosConfig_absolute_path) === false) die ('Invalid program load path'); |
| 272 |
|
if (file_exists($config->mosConfig_absolute_path) === false) die ('Invalid program load path'); |
| 273 |
else return $config->rootPath; |
else return $config->rootPath; |
| 274 |
} |
} |
| 275 |
if (isset($config->$property)) return $config->$property; |
if (isset($config->$property)) return $config->$property; |
| 277 |
return null; |
return null; |
| 278 |
} |
} |
| 279 |
|
|
| 280 |
|
/** |
| 281 |
|
* Enter description here... |
| 282 |
|
* |
| 283 |
|
* @param unknown_type $property |
| 284 |
|
* @return unknown |
| 285 |
|
*/ |
| 286 |
function is_set ($property) { |
function is_set ($property) { |
| 287 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 288 |
return isset($config->$property); |
return isset($config->$property); |
| 289 |
} |
} |
| 290 |
|
|
| 291 |
|
/** |
| 292 |
|
* Enter description here... |
| 293 |
|
* |
| 294 |
|
* @param unknown_type $property |
| 295 |
|
* @param unknown_type $value |
| 296 |
|
* @return unknown |
| 297 |
|
*/ |
| 298 |
function set ($property, $value) { |
function set ($property, $value) { |
| 299 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 300 |
$config->$property = $value; |
$config->$property = $value; |
| 302 |
return $value; |
return $value; |
| 303 |
} |
} |
| 304 |
|
|
| 305 |
|
/** |
| 306 |
|
* Enter description here... |
| 307 |
|
* |
| 308 |
|
*/ |
| 309 |
function checkConfig () { |
function checkConfig () { |
| 310 |
// checks for configuration file, if none found loads installation page |
// checks for configuration file, if none found loads installation page |
| 311 |
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 ) { |
| 314 |
} |
} |
| 315 |
} |
} |
| 316 |
|
|
| 317 |
|
/** |
| 318 |
|
* Enter description here... |
| 319 |
|
* |
| 320 |
|
*/ |
| 321 |
function getConfig () { |
function getConfig () { |
| 322 |
global $adminside; |
global $adminside; |
| 323 |
$code = ''; |
$code = ''; |
| 324 |
$f = @fopen($this->rootPath.'/configuration.php','rb'); |
$f = @fopen($this->rootPath.'/configuration.php','rb'); |
| 325 |
if ($f) { |
if ($f) { |
| 326 |
while ($f AND !feof($f)) { |
while ($f AND !feof($f)) { |
| 327 |
$line = fgets($f, 256); |
$line = fgets($f); |
| 328 |
$altered = str_replace('$', '$this->', $line); |
$altered = preg_replace('/^\$/', '$this->', $line); |
| 329 |
if ($altered != $line) $code .= $altered; |
if ($altered != $line) $code .= $altered; |
| 330 |
} |
} |
| 331 |
} |
} |
| 332 |
else { |
else { |
| 333 |
header( 'Location: installation/index.php' ); |
#header( 'Location: installation/index.php' ); |
| 334 |
exit(); |
exit(); |
| 335 |
} |
} |
| 336 |
fclose($f); |
fclose($f); |
| 337 |
eval($code); |
eval($code); |
| 338 |
if (isset($_SERVER['DOCUMENT_ROOT']) AND strlen($_SERVER['DOCUMENT_ROOT'])) $docroot = str_replace('\\', '/', str_replace('\\\\', '\\', $_SERVER['DOCUMENT_ROOT'])); |
|
| 339 |
else { |
|
| 340 |
|
/*if (isset($_SERVER['DOCUMENT_ROOT']) AND strlen($_SERVER['DOCUMENT_ROOT'])) { |
| 341 |
|
$docroot = str_replace('\\', '/', str_replace('\\\\', '\\', $_SERVER['DOCUMENT_ROOT'])); |
| 342 |
|
} |
| 343 |
|
else {*/ |
| 344 |
// Find information about where execution started |
// Find information about where execution started |
| 345 |
$origin = array_pop(debug_backtrace()); |
$origin = array_pop(debug_backtrace()); |
| 346 |
// Find the PHP script at the start, with a fix for Windows slashes |
// Find the PHP script at the start, with a fix for Windows slashes |
| 347 |
$absolutepath = str_replace('\\', '/', $origin['file']); |
$absolutepath = str_replace('\\', '/', $origin['file']); |
| 348 |
$localpath = $_SERVER['PHP_SELF']; |
$localpath = $_SERVER['PHP_SELF']; |
| 349 |
$docroot = substr($absolutepath,0,strpos($absolutepath,$localpath)); |
$docroot = substr($absolutepath,0,strpos($absolutepath,$localpath)); |
| 350 |
} |
/*}*/ |
| 351 |
$mamboroot = str_replace('\\', '/', dirname(__FILE__)); |
$mamboroot = str_replace('\\', '/', rtrim($this->rootPath, '\/')); |
| 352 |
$this->subdirectory = substr($mamboroot, strlen($docroot)); |
$this->subdirectory = substr($mamboroot, strlen($docroot)); |
| 353 |
|
|
| 354 |
$scheme = isset($_SERVER['HTTP_SCHEME']) ? $_SERVER['HTTP_SCHEME'] : ((isset($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS'] != 'off')) ? 'https' : 'http'); |
$scheme = isset($_SERVER['HTTP_SCHEME']) ? $_SERVER['HTTP_SCHEME'] : ((isset($_SERVER['HTTPS']) AND strtolower($_SERVER['HTTPS'] != 'off')) ? 'https' : 'http'); |
| 355 |
if (isset($_SERVER['HTTP_HOST'])) { |
if (isset($_SERVER['HTTP_HOST'])) { |
| 356 |
$withport = explode(':', $_SERVER['HTTP_HOST']); |
$withport = explode(':', $_SERVER['HTTP_HOST']); |
| 365 |
} |
} |
| 366 |
else $port = ''; |
else $port = ''; |
| 367 |
$afterscheme = '://'.$servername.$port.$this->subdirectory; |
$afterscheme = '://'.$servername.$port.$this->subdirectory; |
| 368 |
$this->mosConfig_live_site = $this->mosConfig_secure_site = $scheme.$afterscheme; |
//$this->mosConfig_live_site = $this->mosConfig_secure_site = $scheme.$afterscheme; |
| 369 |
$this->mosConfig_unsecure_site = 'http'.$afterscheme; |
$this->mosConfig_unsecure_site = 'http'.$afterscheme; |
| 370 |
$this->mosConfig_absolute_path = $this->rootPath; |
$this->mosConfig_absolute_path = $this->rootPath; |
| 371 |
preg_match_all('/\$this\-\>([A-Za-z_][A-Za-z0-9_]*)/', $code, $matches); |
preg_match_all('/\$this\-\>([A-Za-z_][A-Za-z0-9_]*)/', $code, $matches); |
| 374 |
$this->mosConfig_register_globals = 0; |
$this->mosConfig_register_globals = 0; |
| 375 |
$GLOBALS['mosConfig_register_globals'] = 0; |
$GLOBALS['mosConfig_register_globals'] = 0; |
| 376 |
} |
} |
| 377 |
|
|
| 378 |
} |
} |
| 379 |
|
|
| 380 |
|
/** |
| 381 |
|
* Enter description here... |
| 382 |
|
* |
| 383 |
|
* @return unknown |
| 384 |
|
*/ |
| 385 |
function getFavIcon () { |
function getFavIcon () { |
| 386 |
// favourites icon |
// favourites icon |
| 387 |
if (!isset($this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
if (!isset($this->mosConfig_favicon)) $this->mosConfig_favicon = 'favicon.ico'; |
| 389 |
return $this->mosConfig_live_site.'/images/'.$this->mosConfig_favicon; |
return $this->mosConfig_live_site.'/images/'.$this->mosConfig_favicon; |
| 390 |
} |
} |
| 391 |
|
|
| 392 |
|
/** |
| 393 |
|
* Enter description here... |
| 394 |
|
* |
| 395 |
|
* @param unknown_type $user |
| 396 |
|
* @param unknown_type $database |
| 397 |
|
*/ |
| 398 |
function offlineCheck (&$user, &$database) { |
function offlineCheck (&$user, &$database) { |
| 399 |
if ($this->mosConfig_offline OR file_exists($this->rootPath.'/installation/index.php')) { |
global $adminside; |
| 400 |
|
if (($this->mosConfig_offline && !$adminside) OR file_exists($this->rootPath.'/installation/index.php')) { |
| 401 |
require_once($this->rootPath().'/administrator/includes/admin.php'); |
require_once($this->rootPath().'/administrator/includes/admin.php'); |
| 402 |
session_name(md5($this->mosConfig_live_site)); |
session_name(md5($this->mosConfig_live_site)); |
| 403 |
session_start(); |
session_start(); |
| 410 |
} |
} |
| 411 |
} |
} |
| 412 |
|
|
| 413 |
|
/** |
| 414 |
|
* Enter description here... |
| 415 |
|
* |
| 416 |
|
*/ |
| 417 |
function fixLanguage () { |
function fixLanguage () { |
| 418 |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/phpgettext.class.php'); |
| 419 |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
require_once($this->mosConfig_absolute_path.'/includes/phpgettext/error.php'); |
| 420 |
require_once($this->mosConfig_absolute_path.'/includes/mambofunc.php'); |
require_once($this->mosConfig_absolute_path.'/includes/mambofunc.php'); |
| 421 |
require_once($this->mosConfig_absolute_path.'/includes/mambolanguage.class.php'); |
require_once($this->mosConfig_absolute_path.'/includes/mambolanguage.class.php'); |
| 422 |
error_reporting(E_ALL) ; |
if (!mosGetParam($_REQUEST, 'lang')); |
| 423 |
|
else $this->mosConfig_locale = mosGetParam($_REQUEST, 'lang', $this->mosConfig_locale); |
| 424 |
|
$language =& new mamboLanguage($this->mosConfig_locale, $this->rootPath.'/language/'); |
| 425 |
|
$languages = $language->getLanguages(); |
| 426 |
|
$charset = $language->get('charset'); |
| 427 |
|
$dateformat = $language->get('dateformat'); |
| 428 |
|
$this->mosConfig_lang = $language->get('lang'); |
| 429 |
|
$this->current_language = $language; |
| 430 |
|
if (!defined('_ISO')) DEFINE('_ISO','charset='.$charset); |
| 431 |
|
header('Content-type: text/html; '._ISO); |
| 432 |
|
if (!defined('_DATE_FORMAT_LC')) DEFINE('_DATE_FORMAT_LC', $dateformat); //Uses PHP's strftime Command Format |
| 433 |
|
if (!defined('_DATE_FORMAT_LC2')) DEFINE('_DATE_FORMAT_LC2', $dateformat); |
| 434 |
|
|
| 435 |
|
#error_reporting(E_ALL) ; |
| 436 |
########## DEPRECATED ############ |
########## DEPRECATED ############ |
| 437 |
if (isset($this->mosConfig_lang) AND $this->mosConfig_lang); |
if (isset($this->mosConfig_lang) AND $this->mosConfig_lang); |
| 438 |
else $this->set('mosConfig_lang', 'english'); |
else $this->set('mosConfig_lang', 'english'); |
| 439 |
$language_file = "$this->mosConfig_absolute_path/language/$this->mosConfig_lang.php"; |
$language_file = "$this->mosConfig_absolute_path/language/$this->mosConfig_lang.php"; |
| 440 |
if (file_exists($language_file)) require_once ($language_file); |
if (file_exists($language_file)) require_once ($language_file); |
| 441 |
|
else require_once ("$this->mosConfig_absolute_path/language/english.php"); |
| 442 |
################################### |
################################### |
| 443 |
|
|
| 444 |
|
|
|
$this->mosConfig_lang = mosGetParam($_POST, 'setLanguage', $this->mosConfig_lang); |
|
| 445 |
|
|
| 446 |
|
|
|
$language =& mamboLanguage::getInstance($this->mosConfig_lang, $this->rootPath.'/language/'); |
|
|
$languages = $language->getLanguages(); |
|
|
$charset = $language->get('charset'); |
|
|
$dateformat = $language->get('dateformat'); |
|
|
$this->current_language = $language; |
|
|
if (!defined('_ISO')) DEFINE('_ISO','charset='.$charset); |
|
|
if (!defined('_DATE_FORMAT_LC')) DEFINE('_DATE_FORMAT_LC', $dateformat); //Uses PHP's strftime Command Format |
|
|
if (!defined('_DATE_FORMAT_LC2')) DEFINE('_DATE_FORMAT_LC2', $dateformat); |
|
|
|
|
|
$gettext =& phpgettext(); |
|
|
$gettext->debug = $this->mosConfig_locale_debug; |
|
|
$gettext->has_gettext = $this->mosConfig_locale_use_gettext; |
|
|
$gettext->setlocale($this->mosConfig_lang); |
|
| 447 |
} |
} |
| 448 |
|
|
| 449 |
|
/** |
| 450 |
|
* Enter description here... |
| 451 |
|
* |
| 452 |
|
*/ |
| 453 |
function handleGlobals () { |
function handleGlobals () { |
| 454 |
$superglobals = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET); |
$superglobals = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET); |
| 455 |
if (isset( $_SESSION )) array_unshift ( $superglobals , $_SESSION ); |
if (isset( $_SESSION )) array_unshift ( $superglobals , $_SESSION ); |
| 468 |
foreach ( $superglobals as $superglobal ) { |
foreach ( $superglobals as $superglobal ) { |
| 469 |
foreach ( $superglobal as $key => $value) { |
foreach ( $superglobal as $key => $value) { |
| 470 |
unset( $GLOBALS[$key]); |
unset( $GLOBALS[$key]); |
| 471 |
|
unset( $GLOBALS[$key]); |
| 472 |
} |
} |
| 473 |
} |
} |
| 474 |
} |
} |
| 475 |
} |
} |
| 476 |
|
|
| 477 |
|
/** |
| 478 |
|
* Enter description here... |
| 479 |
|
* |
| 480 |
|
* @return unknown |
| 481 |
|
*/ |
| 482 |
function determineOptionAndItemid () { |
function determineOptionAndItemid () { |
| 483 |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
$this->Itemid = mosGetParam($_REQUEST, 'Itemid', 0); |
| 484 |
if ($option = strtolower(mosGetParam($_REQUEST, 'option'))); |
if ($option = strtolower(mosGetParam($_REQUEST, 'option'))); |
| 492 |
if ($pos !== false) $link = substr( $link, $pos+1 ). '&Itemid='.$this->Itemid; |
if ($pos !== false) $link = substr( $link, $pos+1 ). '&Itemid='.$this->Itemid; |
| 493 |
parse_str( $link, $temp ); |
parse_str( $link, $temp ); |
| 494 |
/** this is a patch, need to rework when globals are handled better */ |
/** this is a patch, need to rework when globals are handled better */ |
| 495 |
foreach ($temp as $k=>$v) $_GET[$k] = $v; |
foreach ($temp as $k=>$v) $_GET[$k] = $_REQUEST[$k] = $v; |
| 496 |
if (isset($temp['option'])) $option = $temp['option']; |
if (isset($temp['option'])) $option = $temp['option']; |
| 497 |
else return ''; |
else return ''; |
| 498 |
} |
} |
| 518 |
return $option; |
return $option; |
| 519 |
} |
} |
| 520 |
|
|
| 521 |
|
/** |
| 522 |
|
* Enter description here... |
| 523 |
|
* |
| 524 |
|
* @param unknown_type $url |
| 525 |
|
* @param unknown_type $msg |
| 526 |
|
*/ |
| 527 |
function redirect ($url, $msg='') { |
function redirect ($url, $msg='') { |
| 528 |
$callcheck = array('InputFilter', 'process'); |
$callcheck = array('InputFilter', 'process'); |
| 529 |
if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpInputFilter/class.inputfilter.php'); |
if (!is_callable($callcheck)) require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpInputFilter/class.inputfilter.php'); |
| 544 |
exit(); |
exit(); |
| 545 |
} |
} |
| 546 |
|
|
| 547 |
|
/** |
| 548 |
|
* Enter description here... |
| 549 |
|
* |
| 550 |
|
* @param unknown_type $text |
| 551 |
|
*/ |
| 552 |
function logMessage ($text) { |
function logMessage ($text) { |
| 553 |
// JS Popup message |
// JS Popup message |
| 554 |
if (mosGetParam( $_POST, 'message', 0 )) { |
if (mosGetParam( $_POST, 'message', 0 )) { |
| 568 |
} |
} |
| 569 |
} |
} |
| 570 |
|
|
| 571 |
|
/** |
| 572 |
|
* Enter description here... |
| 573 |
|
* |
| 574 |
|
*/ |
| 575 |
function handleLogin () { |
function handleLogin () { |
| 576 |
require_once($this->rootPath().'/includes/authenticator.php'); |
require_once($this->rootPath().'/includes/authenticator.php'); |
| 577 |
$authenticator =& mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 578 |
$loggedin = $authenticator->loginUser(); |
$loggedin = $authenticator->loginUser(); |
| 579 |
if ($loggedin) $this->logMessage(_LOGIN_SUCCESS); |
if ($loggedin) $this->logMessage(T_('You have Logged In succesfully')); |
| 580 |
else mamboCore::redirect('index.php'); |
else mamboCore::redirect('index.php'); |
| 581 |
} |
} |
| 582 |
|
|
| 583 |
|
/** |
| 584 |
|
* Enter description here... |
| 585 |
|
* |
| 586 |
|
*/ |
| 587 |
function handleLogout () { |
function handleLogout () { |
| 588 |
require_once($this->rootPath().'/includes/authenticator.php'); |
require_once($this->rootPath().'/includes/authenticator.php'); |
| 589 |
$authenticator =& mamboAuthenticator::getInstance(); |
$authenticator =& mamboAuthenticator::getInstance(); |
| 590 |
$authenticator->logoutUser(); |
$authenticator->logoutUser(); |
| 591 |
$this->logMessage(_LOGOUT_SUCCESS); |
$this->logMessage(T_('You have Logged Out successfully')); |
| 592 |
} |
} |
| 593 |
|
|
| 594 |
|
/** |
| 595 |
|
* Enter description here... |
| 596 |
|
* |
| 597 |
|
*/ |
| 598 |
function standardHeaders () { |
function standardHeaders () { |
| 599 |
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); |
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); |
| 600 |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
| 606 |
$mambothandler->trigger('onHeaders', array($this)); |
$mambothandler->trigger('onHeaders', array($this)); |
| 607 |
} |
} |
| 608 |
|
|
| 609 |
|
/** |
| 610 |
|
* Enter description here... |
| 611 |
|
* |
| 612 |
|
*/ |
| 613 |
function initGzip() { |
function initGzip() { |
| 614 |
$this->do_gzip_compress = FALSE; |
$this->do_gzip_compress = FALSE; |
| 615 |
//zlib.output_compression and ob_gzhandler don't get along well so we'll check to make |
//zlib.output_compression and ob_gzhandler don't get along well so we'll check to make |
| 670 |
} |
} |
| 671 |
} |
} |
| 672 |
|
|
| 673 |
|
/** |
| 674 |
|
* Enter description here... |
| 675 |
|
* |
| 676 |
|
* @param unknown_type $separator |
| 677 |
|
* @param unknown_type $field |
| 678 |
|
* @return unknown |
| 679 |
|
*/ |
| 680 |
function getLastPart ($separator, $field) { |
function getLastPart ($separator, $field) { |
| 681 |
$parts = explode($separator, $field); |
$parts = explode($separator, $field); |
| 682 |
return $parts[count($parts)-1]; |
return $parts[count($parts)-1]; |
| 683 |
} |
} |
| 684 |
|
|
| 685 |
|
/** |
| 686 |
|
* Enter description here... |
| 687 |
|
* |
| 688 |
|
* @param unknown_type $separator |
| 689 |
|
* @param unknown_type $field |
| 690 |
|
* @return unknown |
| 691 |
|
*/ |
| 692 |
function allButLast ($separator, $field) { |
function allButLast ($separator, $field) { |
| 693 |
$lastSize = strlen(mamboCore::getLastPart($separator,$field)); |
$lastSize = strlen(mamboCore::getLastPart($separator,$field)); |
| 694 |
return substr($field, 0, strlen($field)-$lastSize); |
return substr($field, 0, strlen($field)-$lastSize); |
| 701 |
* Sorts an Array of objects |
* Sorts an Array of objects |
| 702 |
*/ |
*/ |
| 703 |
class mosObjectSorter { |
class mosObjectSorter { |
| 704 |
|
/** |
| 705 |
|
* Enter description here... |
| 706 |
|
* |
| 707 |
|
* @var unknown_type |
| 708 |
|
*/ |
| 709 |
var $_keyname = ''; |
var $_keyname = ''; |
| 710 |
|
/** |
| 711 |
|
* Enter description here... |
| 712 |
|
* |
| 713 |
|
* @var unknown_type |
| 714 |
|
*/ |
| 715 |
var $_direction = 0; |
var $_direction = 0; |
| 716 |
|
/** |
| 717 |
|
* Enter description here... |
| 718 |
|
* |
| 719 |
|
* @var unknown_type |
| 720 |
|
*/ |
| 721 |
var $_object_array = array(); |
var $_object_array = array(); |
| 722 |
|
|
| 723 |
|
/** |
| 724 |
|
* Enter description here... |
| 725 |
|
* |
| 726 |
|
* @param unknown_type $a |
| 727 |
|
* @param unknown_type $k |
| 728 |
|
* @param unknown_type $sort_direction |
| 729 |
|
* @return mosObjectSorter |
| 730 |
|
*/ |
| 731 |
function mosObjectSorter (&$a, $k, $sort_direction=1) { |
function mosObjectSorter (&$a, $k, $sort_direction=1) { |
| 732 |
$this->_keyname = $k; |
$this->_keyname = $k; |
| 733 |
$this->_direction = $sort_direction; |
$this->_direction = $sort_direction; |
| 735 |
$this->sort(); |
$this->sort(); |
| 736 |
} |
} |
| 737 |
|
|
| 738 |
|
/** |
| 739 |
|
* Enter description here... |
| 740 |
|
* |
| 741 |
|
* @param unknown_type $a |
| 742 |
|
* @param unknown_type $b |
| 743 |
|
* @return unknown |
| 744 |
|
*/ |
| 745 |
function mosObjectCompare (&$a, &$b) { |
function mosObjectCompare (&$a, &$b) { |
| 746 |
$key = $this->_keyname; |
$key = $this->_keyname; |
| 747 |
if ($a->$key > $b->$key) return $this->_direction; |
if ($a->$key > $b->$key) return $this->_direction; |
| 749 |
return 0; |
return 0; |
| 750 |
} |
} |
| 751 |
|
|
| 752 |
|
/** |
| 753 |
|
* Enter description here... |
| 754 |
|
* |
| 755 |
|
*/ |
| 756 |
function sort () { |
function sort () { |
| 757 |
usort($this->_object_array, array($this,'mosObjectCompare')); |
usort($this->_object_array, array($this,'mosObjectCompare')); |
| 758 |
} |
} |
| 801 |
$this->_urls[$last+1] = $url; |
$this->_urls[$last+1] = $url; |
| 802 |
} |
} |
| 803 |
|
|
| 804 |
|
/** |
| 805 |
|
* Enter description here... |
| 806 |
|
* |
| 807 |
|
*/ |
| 808 |
function reduceToOne () { |
function reduceToOne () { |
| 809 |
for ($i = count($this->_names) - 1; $i > 0; $i--) { |
for ($i = count($this->_names) - 1; $i > 0; $i--) { |
| 810 |
unset($this->_names[$i]); |
unset($this->_names[$i]); |
| 816 |
* Make a pathway string for display |
* Make a pathway string for display |
| 817 |
*/ |
*/ |
| 818 |
function makePathway () { |
function makePathway () { |
|
$last = count($this->_names) - 1; |
|
|
if ($last == 0) return ''; |
|
| 819 |
$mainframe =& mosMainFrame::getInstance(); |
$mainframe =& mosMainFrame::getInstance(); |
| 820 |
|
$customs = $mainframe->getCustomPathWay(); |
| 821 |
|
$last = count($this->_names) - 1; |
| 822 |
|
if ($last == 0 AND count($customs == 0)) return ''; |
| 823 |
$result = "<span class='pathway'>"; |
$result = "<span class='pathway'>"; |
| 824 |
$config =& mamboCore::getMamboCore(); |
$config =& mamboCore::getMamboCore(); |
| 825 |
$rootpath = $config->rootPath(); |
$rootpath = $config->rootPath(); |
| 830 |
if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='$config->mosConfig_live_site/images/M_images/arrow.png' alt='arrow' />"; |
if (file_exists( "$rootpath/$imgPath" )) $img = "<img src='$config->mosConfig_live_site/images/M_images/arrow.png' alt='arrow' />"; |
| 831 |
else $img = '>'; |
else $img = '>'; |
| 832 |
} |
} |
| 833 |
|
$uri =& mosUriHelper::getInstance(); |
| 834 |
foreach ($this->_names as $i=>$name) { |
foreach ($this->_names as $i=>$name) { |
| 835 |
if ($i === $last) $result .= "$name</span>"; |
$uri->setUri($this->_urls[$i]); |
| 836 |
|
if ($i === $last AND count($customs) == 0) $result .= "$name</span>"; |
| 837 |
|
elseif (strstr($uri->get('task'), 'view')) $result .= ""; |
| 838 |
else { |
else { |
| 839 |
$sefurl = sefRelToAbs($this->_urls[$i]); |
$sefurl = sefRelToAbs($this->_urls[$i]); |
| 840 |
$result .= "<a href='$sefurl' class='pathway'>$name</a>"; |
$result .= "<a href='$sefurl' class='pathway'>$name</a>"; |
| 841 |
$result .= " $img "; |
$result .= " $img "; |
| 842 |
} |
} |
| 843 |
} |
} |
|
$customs = $mainframe->getCustomPathWay(); |
|
| 844 |
foreach ($customs as $custom) $result .= $custom; |
foreach ($customs as $custom) $result .= $custom; |
| 845 |
$result .= '</span>'; |
if (count($customs)) $result .= '</span>'; |
| 846 |
return $result; |
return $result; |
| 847 |
} |
} |
| 848 |
|
|
| 931 |
return $instance; |
return $instance; |
| 932 |
} |
} |
| 933 |
|
|
| 934 |
|
/** |
| 935 |
|
* Enter description here... |
| 936 |
|
* |
| 937 |
|
* @param unknown_type $file |
| 938 |
|
* @return unknown |
| 939 |
|
*/ |
| 940 |
function deleteFile ($file) { |
function deleteFile ($file) { |
| 941 |
if (file_exists($file)) { |
if (file_exists($file)) { |
| 942 |
@chmod($file, 0644); |
@chmod($file, 0644); |
| 945 |
return true; |
return true; |
| 946 |
} |
} |
| 947 |
|
|
| 948 |
|
/** |
| 949 |
|
* Enter description here... |
| 950 |
|
* |
| 951 |
|
* @param unknown_type $dir |
| 952 |
|
* @return unknown |
| 953 |
|
*/ |
| 954 |
function deleteDirectory ($dir) { |
function deleteDirectory ($dir) { |
| 955 |
if (file_exists($dir)) { |
if (file_exists($dir)) { |
| 956 |
if (is_dir($dir)) { |
if (is_dir($dir)) { |
| 962 |
return true; |
return true; |
| 963 |
} |
} |
| 964 |
|
|
| 965 |
|
/** |
| 966 |
|
* Enter description here... |
| 967 |
|
* |
| 968 |
|
* @param unknown_type $fileSysObject |
| 969 |
|
*/ |
| 970 |
function setPermissions ($fileSysObject) { |
function setPermissions ($fileSysObject) { |
| 971 |
if (file_exists($fileSysObject)) { |
if (file_exists($fileSysObject)) { |
| 972 |
if (is_dir($fileSysObject)) $perms = mamboCore::get('mosConfig_dirperms'); |
if (is_dir($fileSysObject)) $perms = mamboCore::get('mosConfig_dirperms'); |
| 980 |
} |
} |
| 981 |
} |
} |
| 982 |
|
|
| 983 |
|
/** |
| 984 |
|
* Enter description here... |
| 985 |
|
* |
| 986 |
|
* @param unknown_type $dir |
| 987 |
|
* @return unknown |
| 988 |
|
*/ |
| 989 |
function makeDirectory ($dir) { |
function makeDirectory ($dir) { |
| 990 |
$perms = mamboCore::get('mosConfig_dirperms'); |
$perms = mamboCore::get('mosConfig_dirperms'); |
| 991 |
$origmask = @umask(0); |
$origmask = @umask(0); |
| 997 |
} |
} |
| 998 |
|
|
| 999 |
|
|
| 1000 |
|
/** |
| 1001 |
|
* Enter description here... |
| 1002 |
|
* |
| 1003 |
|
* @param unknown_type $dir |
| 1004 |
|
* @param unknown_type $onlyCheck |
| 1005 |
|
* @return unknown |
| 1006 |
|
*/ |
| 1007 |
function createDirectory ($dir, $onlyCheck=false) { |
function createDirectory ($dir, $onlyCheck=false) { |
| 1008 |
if (file_exists($dir)) { |
if (file_exists($dir)) { |
| 1009 |
if (is_dir($dir) AND is_writable($dir)) return true; |
if (is_dir($dir) AND is_writable($dir)) return true; |
| 1017 |
else return $this->makeDirectory($dir); |
else return $this->makeDirectory($dir); |
| 1018 |
} |
} |
| 1019 |
|
|
| 1020 |
|
/** |
| 1021 |
|
* Enter description here... |
| 1022 |
|
* |
| 1023 |
|
* @param unknown_type $dir |
| 1024 |
|
* @return unknown |
| 1025 |
|
*/ |
| 1026 |
function containingDirectory ($dir) { |
function containingDirectory ($dir) { |
| 1027 |
$dirs = preg_split('*[/|\\\]*', $dir); |
$dirs = preg_split('*[/|\\\]*', $dir); |
| 1028 |
for ($i = count($dirs)-1; $i >= 0; $i--) { |
for ($i = count($dirs)-1; $i >= 0; $i--) { |
| 1035 |
return array($result1, $result2); |
return array($result1, $result2); |
| 1036 |
} |
} |
| 1037 |
|
|
| 1038 |
|
/** |
| 1039 |
|
* Enter description here... |
| 1040 |
|
* |
| 1041 |
|
* @param unknown_type $from |
| 1042 |
|
* @param unknown_type $to |
| 1043 |
|
* @return unknown |
| 1044 |
|
*/ |
| 1045 |
function simpleCopy ($from, $to) { |
function simpleCopy ($from, $to) { |
| 1046 |
if (@copy($from, $to)) { |
if (@copy($from, $to)) { |
| 1047 |
$this->setPermissions($to); |
$this->setPermissions($to); |
| 1050 |
else return false; |
else return false; |
| 1051 |
} |
} |
| 1052 |
|
|
| 1053 |
|
/** |
| 1054 |
|
* Enter description here... |
| 1055 |
|
* |
| 1056 |
|
* @param unknown_type $from |
| 1057 |
|
* @param unknown_type $to |
| 1058 |
|
* @return unknown |
| 1059 |
|
*/ |
| 1060 |
function forceCopy ($from, $to) { |
function forceCopy ($from, $to) { |
| 1061 |
$todir = dirname($to); |
$todir = dirname($to); |
| 1062 |
if (!file_exists($todir)) $this->createDirectory($todir); |
if (!file_exists($todir)) $this->createDirectory($todir); |
| 1066 |
return $this->simpleCopy ($from, $to); |
return $this->simpleCopy ($from, $to); |
| 1067 |
} |
} |
| 1068 |
|
|
| 1069 |
|
/** |
| 1070 |
|
* Enter description here... |
| 1071 |
|
* |
| 1072 |
|
* @param unknown_type $from |
| 1073 |
|
* @param unknown_type $to |
| 1074 |
|
* @return unknown |
| 1075 |
|
*/ |
| 1076 |
function lightCopy ($from, $to) { |
function lightCopy ($from, $to) { |
| 1077 |
$name = basename($from); |
$name = basename($from); |
| 1078 |
if (file_exists($to.$name)) return false; |
if (file_exists($to.$name)) return false; |
| 1082 |
return $this->simpleCopy ($from, $to); |
return $this->simpleCopy ($from, $to); |
| 1083 |
} |
} |
| 1084 |
|
|
| 1085 |
|
/** |
| 1086 |
|
* Enter description here... |
| 1087 |
|
* |
| 1088 |
|
* @param unknown_type $to |
| 1089 |
|
* @return unknown |
| 1090 |
|
*/ |
| 1091 |
function acceptCopy ($to) { |
function acceptCopy ($to) { |
| 1092 |
$todir = dirname($to); |
$todir = dirname($to); |
| 1093 |
return $this->createDirectory($todir, true); |
return $this->createDirectory($todir, true); |
| 1160 |
|
|
| 1161 |
} |
} |
| 1162 |
|
|
| 1163 |
|
/** |
| 1164 |
|
* Enter description here... |
| 1165 |
|
* |
| 1166 |
|
*/ |
| 1167 |
class mosDirectory { |
class mosDirectory { |
| 1168 |
|
/** |
| 1169 |
|
* Enter description here... |
| 1170 |
|
* |
| 1171 |
|
* @var unknown_type |
| 1172 |
|
*/ |
| 1173 |
var $path = ''; |
var $path = ''; |
| 1174 |
|
|
| 1175 |
|
/** |
| 1176 |
|
* Enter description here... |
| 1177 |
|
* |
| 1178 |
|
* @param unknown_type $path |
| 1179 |
|
* @return mosDirectory |
| 1180 |
|
*/ |
| 1181 |
function mosDirectory ($path) { |
function mosDirectory ($path) { |
| 1182 |
$path = str_replace('\\', '/', $path); |
$path = str_replace('\\', '/', $path); |
| 1183 |
if (substr($path,-1,1) == '/') $this->path = $path; |
if (substr($path,-1,1) == '/') $this->path = $path; |
| 1184 |
else $this->path = $path.'/'; |
else $this->path = $path.'/'; |
| 1185 |
} |
} |
| 1186 |
|
|
| 1187 |
|
/** |
| 1188 |
|
* Enter description here... |
| 1189 |
|
* |
| 1190 |
|
* @param unknown_type $type |
| 1191 |
|
* @param unknown_type $recurse |
| 1192 |
|
* @param unknown_type $fullpath |
| 1193 |
|
* @return unknown |
| 1194 |
|
*/ |
| 1195 |
function &listAll ($type='file', $recurse=false, $fullpath=false) { |
function &listAll ($type='file', $recurse=false, $fullpath=false) { |
| 1196 |
$results = array(); |
$results = array(); |
| 1197 |
if ($dir = @opendir($this->path)) { |
if ($dir = @opendir($this->path)) { |
| 1198 |
while ($file = readdir($dir)) { |
while (false !== ($file = readdir($dir))) { |
| 1199 |
if ($file == '.' OR $file == '..') continue; |
if ($file == '.' OR $file == '..') continue; |
| 1200 |
if (is_dir($this->path.$file)) { |
if (is_dir($this->path.$file)) { |
| 1201 |
if ($recurse) { |
if ($recurse) { |
| 1211 |
} |
} |
| 1212 |
closedir($dir); |
closedir($dir); |
| 1213 |
} |
} |
| 1214 |
|
asort($results); |
| 1215 |
return $results; |
return $results; |
| 1216 |
} |
} |
| 1217 |
|
|
| 1218 |
|
/** |
| 1219 |
|
* Enter description here... |
| 1220 |
|
* |
| 1221 |
|
* @return unknown |
| 1222 |
|
*/ |
| 1223 |
function soleDir () { |
function soleDir () { |
| 1224 |
$found = ''; |
$found = ''; |
| 1225 |
if ($dir = @opendir($this->path)) { |
if ($dir = @opendir($this->path)) { |
| 1226 |
while ($file = readdir($dir)) { |
while (false !== ($file = readdir($dir))) { |
| 1227 |
if ($file == '.' OR $file == '..') continue; |
if ($file == '.' OR $file == '..') continue; |
| 1228 |
if (is_dir($this->path.$file)) { |
if (is_dir($this->path.$file)) { |
| 1229 |
if ($found) return ''; |
if ($found) return ''; |
| 1236 |
return $found; |
return $found; |
| 1237 |
} |
} |
| 1238 |
|
|
| 1239 |
|
/** |
| 1240 |
|
* Enter description here... |
| 1241 |
|
* |
| 1242 |
|
*/ |
| 1243 |
function deleteAll () { |
function deleteAll () { |
| 1244 |
if (!file_exists($this->path)) return; |
if (!file_exists($this->path)) return; |
| 1245 |
$subdirs =& $this->listAll ('dir', false, true); |
$subdirs =& $this->listAll ('dir', false, true); |
| 1254 |
$filemanager->deleteDirectory($this->path); |
$filemanager->deleteDirectory($this->path); |
| 1255 |
} |
} |
| 1256 |
|
|
| 1257 |
|
/** |
| 1258 |
|
* Enter description here... |
| 1259 |
|
* |
| 1260 |
|
* @return unknown |
| 1261 |
|
*/ |
| 1262 |
function createFresh () { |
function createFresh () { |
| 1263 |
$this->deleteAll(); |
$this->deleteAll(); |
| 1264 |
$filemanager =& mosFileManager::getInstance(); |
$filemanager =& mosFileManager::getInstance(); |
| 1266 |
return true; |
return true; |
| 1267 |
} |
} |
| 1268 |
|
|
| 1269 |
|
/** |
| 1270 |
|
* Enter description here... |
| 1271 |
|
* |
| 1272 |
|
*/ |
| 1273 |
function createIfNeeded () { |
function createIfNeeded () { |
| 1274 |
if (!file_exists($this->path)) { |
if (!file_exists($this->path)) { |
| 1275 |
$filemanager =& mosFileManager::getInstance(); |
$filemanager =& mosFileManager::getInstance(); |
| 1277 |
} |
} |
| 1278 |
} |
} |
| 1279 |
|
|
| 1280 |
|
/** |
| 1281 |
|
* Enter description here... |
| 1282 |
|
* |
| 1283 |
|
* @param unknown_type $pattern |
| 1284 |
|
* @param unknown_type $type |
| 1285 |
|
* @param unknown_type $recurse |
| 1286 |
|
* @param unknown_type $fullpath |
| 1287 |
|
* @return unknown |
| 1288 |
|
*/ |
| 1289 |
function &listFiles ($pattern='', $type='file', $recurse=false, $fullpath=false) { |
function &listFiles ($pattern='', $type='file', $recurse=false, $fullpath=false) { |
| 1290 |
$results = array(); |
$results = array(); |
| 1291 |
$all =& $this->listAll($type, $recurse, $fullpath); |
$all =& $this->listAll($type, $recurse, $fullpath); |
| 1297 |
return $results; |
return $results; |
| 1298 |
} |
} |
| 1299 |
|
|
| 1300 |
|
/** |
| 1301 |
|
* Enter description here... |
| 1302 |
|
* |
| 1303 |
|
* @return unknown |
| 1304 |
|
*/ |
| 1305 |
function getSize () { |
function getSize () { |
| 1306 |
$totalsize = 0; |
$totalsize = 0; |
| 1307 |
$files =& $this->listFiles(); |
$files =& $this->listFiles(); |
| 1354 |
return $instance; |
return $instance; |
| 1355 |
} |
} |
| 1356 |
|
|
| 1357 |
|
/** |
| 1358 |
|
* Enter description here... |
| 1359 |
|
* |
| 1360 |
|
* @param unknown_type $id |
| 1361 |
|
* @return unknown |
| 1362 |
|
*/ |
| 1363 |
function &getMenuByID ($id) { |
function &getMenuByID ($id) { |
| 1364 |
if (isset($this->_idlinks[$id])) { |
if (isset($this->_idlinks[$id])) { |
| 1365 |
$key = $this->_idlinks[$id]; |
$key = $this->_idlinks[$id]; |
| 1369 |
return $result; |
return $result; |
| 1370 |
} |
} |
| 1371 |
|
|
| 1372 |
|
/** |
| 1373 |
|
* Enter description here... |
| 1374 |
|
* |
| 1375 |
|
* @param unknown_type $type |
| 1376 |
|
* @param unknown_type $published |
| 1377 |
|
* @return unknown |
| 1378 |
|
*/ |
| 1379 |
function getMenuCount ($type, $published) { |
function getMenuCount ($type, $published) { |
| 1380 |
if (isset($this->_counts[$type][$published])) return $this->_counts[$type][$published]; |
if (isset($this->_counts[$type][$published])) return $this->_counts[$type][$published]; |
| 1381 |
else return 0; |
else return 0; |
| 1382 |
} |
} |
| 1383 |
|
|
| 1384 |
|
/** |
| 1385 |
|
* Enter description here... |
| 1386 |
|
* |
| 1387 |
|
* @param unknown_type $types |
| 1388 |
|
* @return unknown |
| 1389 |
|
*/ |
| 1390 |
function &getMenusByType ($types) { |
function &getMenusByType ($types) { |
| 1391 |
$checker = explode(',', $types); |
$checker = explode(',', $types); |
| 1392 |
$result = null; |
$result = null; |
| 1396 |
return $result; |
return $result; |
| 1397 |
} |
} |
| 1398 |
|
|
| 1399 |
|
/** |
| 1400 |
|
* Enter description here... |
| 1401 |
|
* |
| 1402 |
|
* @return unknown |
| 1403 |
|
*/ |
| 1404 |
function &getMenuTypes () { |
function &getMenuTypes () { |
| 1405 |
$types = array(); |
$types = array(); |
| 1406 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1410 |
return $types; |
return $types; |
| 1411 |
} |
} |
| 1412 |
|
|
| 1413 |
|
/** |
| 1414 |
|
* Enter description here... |
| 1415 |
|
* |
| 1416 |
|
* @param unknown_type $type |
| 1417 |
|
* @param unknown_type $link |
| 1418 |
|
* @return unknown |
| 1419 |
|
*/ |
| 1420 |
function getIDByTypeLink ($type, $link) { |
function getIDByTypeLink ($type, $link) { |
| 1421 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1422 |
if ($menu->published == 1 AND ($type == '*' OR $menu->type == $type) AND $menu->link == $link) return $menu->id; |
if ($menu->published == 1 AND ($type == '*' OR $menu->type == $type) AND $menu->link == $link) return $menu->id; |
| 1424 |
return null; |
return null; |
| 1425 |
} |
} |
| 1426 |
|
|
| 1427 |
|
/** |
| 1428 |
|
* Enter description here... |
| 1429 |
|
* |
| 1430 |
|
* @param unknown_type $link |
| 1431 |
|
* @return unknown |
| 1432 |
|
*/ |
| 1433 |
function getIDLikeLink ($link) { |
function getIDLikeLink ($link) { |
| 1434 |
$exact = $this->getIdByTypeLink('*', $link); |
$exact = $this->getIdByTypeLink('*', $link); |
| 1435 |
if ($exact !== null) return $exact; |
if ($exact !== null) return $exact; |
| 1439 |
return 0; |
return 0; |
| 1440 |
} |
} |
| 1441 |
|
|
| 1442 |
|
/** |
| 1443 |
|
* Enter description here... |
| 1444 |
|
* |
| 1445 |
|
* @param unknown_type $type |
| 1446 |
|
* @param unknown_type $componentid |
| 1447 |
|
* @return unknown |
| 1448 |
|
*/ |
| 1449 |
function getIDByTypeCid ($type, $componentid) { |
function getIDByTypeCid ($type, $componentid) { |
| 1450 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1451 |
if ($menu->published == 1 AND $menu->type == $type AND $menu->componentid == $componentid) return $menu->id; |
if ($menu->published == 1 AND $menu->type == $type AND $menu->componentid == $componentid) return $menu->id; |
| 1453 |
return null; |
return null; |
| 1454 |
} |
} |
| 1455 |
|
|
| 1456 |
|
/** |
| 1457 |
|
* Enter description here... |
| 1458 |
|
* |
| 1459 |
|
* @return unknown |
| 1460 |
|
*/ |
| 1461 |
function getGlobalBlogSectionCount () { |
function getGlobalBlogSectionCount () { |
| 1462 |
$count = 0; |
$count = 0; |
| 1463 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1466 |
return $count; |
return $count; |
| 1467 |
} |
} |
| 1468 |
|
|
| 1469 |
|
/** |
| 1470 |
|
* Enter description here... |
| 1471 |
|
* |
| 1472 |
|
* @param unknown_type $Itemid |
| 1473 |
|
* @param unknown_type $type |
| 1474 |
|
* @param unknown_type $id |
| 1475 |
|
* @param unknown_type $catid |
| 1476 |
|
* @return unknown |
| 1477 |
|
*/ |
| 1478 |
function getContentItemid ($Itemid, $type, $id, $catid=0) { |
function getContentItemid ($Itemid, $type, $id, $catid=0) { |
| 1479 |
if ($Itemid) return $Itemid; |
if ($Itemid) return $Itemid; |
| 1480 |
foreach ($this->_menus as $menu) { |
foreach ($this->_menus as $menu) { |
| 1490 |
return 0; |
return 0; |
| 1491 |
} |
} |
| 1492 |
|
|
| 1493 |
|
/** |
| 1494 |
|
* Enter description here... |
| 1495 |
|
* |
| 1496 |
|
* @return unknown |
| 1497 |
|
*/ |
| 1498 |
function getBestQueryMatch () { |
function getBestQueryMatch () { |
| 1499 |
parse_str($_SERVER['QUERY_STRING'], $qitems); |
parse_str($_SERVER['QUERY_STRING'], $qitems); |
| 1500 |
if (!isset($qitems['option'])) return 0; |
if (!isset($qitems['option'])) return 0; |
| 1516 |
} |
} |
| 1517 |
|
|
| 1518 |
|
|
| 1519 |
|
/** |
| 1520 |
|
* Enter description here... |
| 1521 |
|
* |
| 1522 |
|
* @param unknown_type $link |
| 1523 |
|
* @return unknown |
| 1524 |
|
*/ |
| 1525 |
function &maxAccessLink ($link) { |
function &maxAccessLink ($link) { |
| 1526 |
$selected = null; |
$selected = null; |
| 1527 |
$access = 0; |
$access = 0; |
| 1534 |
return $selected; |
return $selected; |
| 1535 |
} |
} |
| 1536 |
|
|
| 1537 |
|
/** |
| 1538 |
|
* Enter description here... |
| 1539 |
|
* |
| 1540 |
|
* @param unknown_type $Itemid |
| 1541 |
|
* @param unknown_type $menutype |
| 1542 |
|
* @param unknown_type $maxaccess |
| 1543 |
|
* @param unknown_type $noparent |
| 1544 |
|
* @return unknown |
| 1545 |
|
*/ |
| 1546 |
function &getByParentOrder ($Itemid, $menutype, $maxaccess=0, $noparent=false) { |
function &getByParentOrder ($Itemid, $menutype, $maxaccess=0, $noparent=false) { |
| 1547 |
$result = array(); |
$result = array(); |
| 1548 |
if ($this->_byParentOrder !== null) { |
if ($this->_byParentOrder !== null) { |
| 1560 |
} |
} |
| 1561 |
} |
} |
| 1562 |
} |
} |
| 1563 |
|
if ($Itemid == 0 && !count($result)){ |
| 1564 |
|
$result[0] = new stdclass; |
| 1565 |
|
$result[0]->id = 1; |
| 1566 |
|
$result[0]->link = 'index.php?option=com_frontpage'; |
| 1567 |
|
$result[0]->parent = 0; |
| 1568 |
|
$result[0]->type = 'components'; |
| 1569 |
|
$result[0]->browserNav = 0; |
| 1570 |
|
$result[0]->name = 'Home'; |
| 1571 |
|
} |
| 1572 |
return $result; |
return $result; |
| 1573 |
} |
} |
| 1574 |
|
|
| 1575 |
|
/** |
| 1576 |
|
* Enter description here... |
| 1577 |
|
* |
| 1578 |
|
* @param unknown_type $Itemid |
| 1579 |
|
*/ |
| 1580 |
function setPathway ($Itemid) { |
function setPathway ($Itemid) { |
| 1581 |
if ($Itemid) { |
if ($Itemid) { |
| 1582 |
$menu =& $this->getMenuByID($Itemid); |
$menu =& $this->getMenuByID($Itemid); |
| 1617 |
return isset($access) ? $access <= $gid : false; |
return isset($access) ? $access <= $gid : false; |
| 1618 |
} |
} |
| 1619 |
|
|
| 1620 |
|
/** |
| 1621 |
|
* Enter description here... |
| 1622 |
|
* |
| 1623 |
|
* @param unknown_type $mitem |
| 1624 |
|
* @param unknown_type $level |
| 1625 |
|
* @param unknown_type $params |
| 1626 |
|
* @param unknown_type $Itemid |
| 1627 |
|
* @return unknown |
| 1628 |
|
*/ |
| 1629 |
function mosGetMenuLink( &$mitem, $level=0, &$params, $Itemid ) { |
function mosGetMenuLink( &$mitem, $level=0, &$params, $Itemid ) { |
| 1630 |
$txt = ''; |
$txt = ''; |
| 1631 |
|
|
| 1699 |
*/ |
*/ |
| 1700 |
function mosShowVIMenu( &$params ) { |
function mosShowVIMenu( &$params ) { |
| 1701 |
global $my, $cur_template, $Itemid; |
global $my, $cur_template, $Itemid; |
| 1702 |
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 9999999; |
| 1703 |
else $maxaccess = $my->gid; |
else $maxaccess = $my->getAccessGid(); |
| 1704 |
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess); |
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess); |
| 1705 |
foreach ($rows as $i=>$row) $crosslink[$row->id] = $i; |
foreach ($rows as $i=>$row) $crosslink[$row->id] = $i; |
| 1706 |
// indent icons |
// indent icons |
| 1786 |
function mosShowHFMenu( &$params, $style=0 ) { |
function mosShowHFMenu( &$params, $style=0 ) { |
| 1787 |
global $my, $cur_template, $Itemid; |
global $my, $cur_template, $Itemid; |
| 1788 |
|
|
| 1789 |
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 0; |
if (mamboCore::get('mosConfig_shownoauth')) $maxaccess = 9999999; |
| 1790 |
else $maxaccess = $my->gid; |
else $maxaccess = $my->getAccessGid(); |
| 1791 |
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess, true); |
$rows =& $this->getByParentOrder(0, $params->get('menutype'), $maxaccess, true); |
| 1792 |
|
|
| 1793 |
$links = array(); |
$links = array(); |
| 1891 |
$selected = $newbot->register(); |
$selected = $newbot->register(); |
| 1892 |
$this->_botRegister($newbot, $selected, $i); |
$this->_botRegister($newbot, $selected, $i); |
| 1893 |
} |
} |
| 1894 |
|
unset($newbot); |
| 1895 |
} |
} |
| 1896 |
} |
} |
| 1897 |
$total++; |
$total++; |
| 1981 |
if (isset($result[0])) return $result[0]; |
if (isset($result[0])) return $result[0]; |
| 1982 |
return null; |
return null; |
| 1983 |
} |
} |
| 1984 |
|
|
| 1985 |
|
function getBot($element, $folder) { |
| 1986 |
|
$returnBot = ''; |
| 1987 |
|
foreach ($this->_bots as $i=>$bot) { |
| 1988 |
|
if ($bot->folder == $folder && $bot->element == $element){ |
| 1989 |
|
$returnBot = $bot; |
| 1990 |
|
break; |
| 1991 |
|
} |
| 1992 |
|
} |
| 1993 |
|
return $returnBot; |
| 1994 |
|
} |
| 1995 |
} |
} |
| 1996 |
|
|
| 1997 |
/** |
/** |
| 2064 |
$this->grp = mosGetParam( $_SESSION, 'session_grp', 0); |
$this->grp = mosGetParam( $_SESSION, 'session_grp', 0); |
| 2065 |
} |
} |
| 2066 |
/** |
/** |
| 2067 |
|
* User access level |
| 2068 |
|
*/ |
| 2069 |
|
function getAccessGid() { |
| 2070 |
|
static $access; |
| 2071 |
|
if (!isset($access)) { |
| 2072 |
|
$acl = new gacl; |
| 2073 |
|
$access = $this->id > 0 ? 1 : 0; |
| 2074 |
|
$access += $acl->acl_check( 'action', 'access', 'users', $this->usertype, 'frontend', 'special' ); |
| 2075 |
|
} |
| 2076 |
|
return $access; |
| 2077 |
|
} |
| 2078 |
|
/** |
| 2079 |
* Validation and filtering |
* Validation and filtering |
| 2080 |
* @return boolean True is satisfactory |
* @return boolean True is satisfactory |
| 2081 |
*/ |
*/ |
| 2082 |
function check() { |
function check() { |
| 2083 |
|
Global $mosConfig_absolute_path; |
| 2084 |
|
//include $mosConfig_absolute_path . ('/language/english.php'); |
| 2085 |
$this->_error = ''; |
$this->_error = ''; |
| 2086 |
if ($this->name == '') $this->_error = _REGWARN_NAME; |
if ($this->name == '') $this->_error = _REGWARN_NAME; |
| 2087 |
elseif ($this->username == '') $this->_error = _REGWARN_UNAME; |
elseif ($this->username == '') $this->_error = _REGWARN_UNAME; |
| 2252 |
} |
} |
| 2253 |
|
|
| 2254 |
/** |
/** |
| 2255 |
* Singleton get instance |
* @param object |
|
* @param object the mainframe instance (if called internally) |
|
|
* Note that because of the need for creation parameters, this cannot |
|
|
* be called successfully unless the mainframe object is already created |
|
| 2256 |
*/ |
*/ |
| 2257 |
function &getInstance () { |
function &getInstance () { |
| 2258 |
static $mainframe; |
global $mainframe; |
| 2259 |
if (func_num_args()) { |
if (isset($mainframe)) { |
| 2260 |
$args = func_get_args(); |
return $mainframe; |
| 2261 |
$mainframe = $args[0]; |
} else { |
| 2262 |
} |
$result = null; |
|
if (isset($mainframe)) $result =& $mainframe; |
|
|
else $result = null; |
|
| 2263 |
return $result; |
return $result; |
| 2264 |
} |
} |
| 2265 |
|
} |
| 2266 |
|
|
| 2267 |
/** |
/** |
| 2268 |
* @param string |
* @param string |
| 2269 |
*/ |
*/ |
| 2385 |
* @param string The default value for the variable if not found |
* @param string The default value for the variable if not found |
| 2386 |
*/ |
*/ |
| 2387 |
function getUserStateFromRequest( $var_name, $req_name, $var_default=null ) { |
function getUserStateFromRequest( $var_name, $req_name, $var_default=null ) { |
| 2388 |
|
if (is_array($this->_userstate)) { |
| 2389 |
if (isset($_REQUEST[$req_name])) $this->setUserState($var_name, $_REQUEST[$req_name]); |
if (isset($_REQUEST[$req_name])) $this->setUserState($var_name, $_REQUEST[$req_name]); |
| 2390 |
elseif (isset($var_default) AND !isset($this->userstate[$var_name])) $this->setUserState($var_name, $var_default); |
else if (isset($var_default) AND !isset($this->_userstate[$var_name])) $this->setUserState($var_name, $var_default); |
| 2391 |
return $this->getUserState($var_name); |
return $this->_userstate[$var_name]; |
| 2392 |
|
} else { |
| 2393 |
|
return null; |
| 2394 |
|
} |
| 2395 |
} |
} |
| 2396 |
/** |
/** |
| 2397 |
* Initialises the user session |
* Initialises the user session |
| 2555 |
$sql['os'] = "INSERT INTO #__stats_agents (agent,type) VALUES ('$os',1)"; |
$sql['os'] = "INSERT INTO #__stats_agents (agent,type) VALUES ('$os',1)"; |
| 2556 |
$sql['domain'] = "INSERT INTO #__stats_agents (agent,type) VALUES ('$tldomain',2)"; |
$sql['domain'] = "INSERT INTO #__stats_agents (agent,type) VALUES ('$tldomain',2)"; |
| 2557 |
if ($stats) foreach ($stats as $stat) { |
if ($stats) foreach ($stats as $stat) { |
| 2558 |
if ($stat->type == 0) $sql['agents'] = "UPDATE #__stats_agents SET hits=(hits+1) WHERE agent='$browser' AND type=0"; |
if ($stat->type == 0) $sql['browser'] = "UPDATE #__stats_agents SET hits=(hits+1) WHERE agent='$browser' AND type=0"; |
| 2559 |
if ($stat->type == 1) $sql['os'] = "UPDATE #__stats_agents SET hits=(hits+1) WHERE agent='$os' AND type=1"; |
if ($stat->type == 1) $sql['os'] = "UPDATE #__stats_agents SET hits=(hits+1) WHERE agent='$os' AND type=1"; |
| 2560 |
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"; |
| 2561 |
} |
} |
| 2575 |
|
|
| 2576 |
function liveBookMark () { |
function liveBookMark () { |
| 2577 |
// support for Firefox Live Bookmarks ability for site syndication |
// support for Firefox Live Bookmarks ability for site syndication |
| 2578 |
|
$live_bookmark = 0; |
| 2579 |
$c_handler =& mosComponentHandler::getInstance(); |
$c_handler =& mosComponentHandler::getInstance(); |
| 2580 |
$params = $c_handler->getParamsByName('Syndicate'); |
$params =& $c_handler->getParamsByName('Syndicate'); |
| 2581 |
|
if (!is_null($params)){ |
| 2582 |
$live_bookmark = $params->get( 'live_bookmark', 0 ); |
$live_bookmark = $params->get( 'live_bookmark', 0 ); |
| 2583 |
|
} |
| 2584 |
|
|
| 2585 |
if ($live_bookmark) { |
if ($live_bookmark) { |
| 2586 |
// custom bookmark file name |
// custom bookmark file name |
| 2587 |
$bookmark_file = $params->get( 'bookmark_file', $live_bookmark ); |
$bookmark_file = $params->get( 'bookmark_file', $live_bookmark ); |
| 2604 |
<?php |
<?php |
| 2605 |
} |
} |
| 2606 |
} |
} |
| 2607 |
|
/** |
| 2608 |
|
* Render head tags |
| 2609 |
|
* tags are assembled into an associative array with the following elements: |
| 2610 |
|
* - title |
| 2611 |
|
* - meta |
| 2612 |
|
* - mambojavascript |
| 2613 |
|
* - custom (custom head tags) |
| 2614 |
|
* - livebookmark |
| 2615 |
|
* - favicon |
| 2616 |
|
* @param unknown keys - array elements to output (null = output all) |
| 2617 |
|
* @param unknown exclude - array elements to exclude in output |
| 2618 |
|
* |
| 2619 |
|
* Usage: mosShowHead() - to render all tags |
| 2620 |
|
* mosShowHead('title') - to render a single tag |
| 2621 |
|
* mosShowHead(array('title', 'meta')) - to selectively render tags (in order) |
| 2622 |
|
* mosShowHead(null, 'custom') - to exclude a single tag |
| 2623 |
|
* mosShowHead(null, array('custom','favicon')) - to exclude multiple tags |
| 2624 |
|
*/ |
| 2625 |
|
function mosShowHead($keys='', $exclude='') { |
| 2626 |
|
if (!is_array($keys)) |
| 2627 |
|
if ($keys !== '' && !is_null($keys)) |
| 2628 |
|
$keys = array($keys); |
| 2629 |
|
else $keys = array(); |
| 2630 |
|
if (!is_array($exclude)) |
| 2631 |
|
if ($exclude !== '') |
| 2632 |
|
$exclude = array($exclude); |
| 2633 |
|
else $exclude = array(); |
| 2634 |
|
|
| 2635 |
|
$this->_head['output'] = array(); |
| 2636 |
|
|
| 2637 |
|
$head = array();; |
| 2638 |
|
$head['title'] = '<title>'.$this->_head['title'].'</title>'; |
| 2639 |
|
|
|
function mosShowHead () { |
|
|
global $_VERSION; |
|
|
$mosConfig_live_site = mamboCore::get('mosConfig_live_site'); |
|
| 2640 |
$this->appendMetaTag( 'description', mamboCore::get('mosConfig_MetaDesc'), true ); |
$this->appendMetaTag( 'description', mamboCore::get('mosConfig_MetaDesc'), true ); |
| 2641 |
$this->appendMetaTag( 'keywords', mamboCore::get('mosConfig_MetaKeys'), true ); |
$this->appendMetaTag( 'keywords', mamboCore::get('mosConfig_MetaKeys'), true ); |
| 2642 |
echo $this->getHead(); |
$head['meta'] = array(); |
| 2643 |
if (mamboCore::get('mosConfig_sef')) { |
foreach ($this->_head['meta'] as $name=>$meta) { |
| 2644 |
echo "<base href=\"$mosConfig_live_site/\" />\r\n"; |
if ($meta[1]) $head['meta'][] = $meta[1]; |
| 2645 |
|
$head['meta'][] = '<meta name="' . $name . '" content="' . $meta[0] . '" />'; |
| 2646 |
|
if ($meta[2]) $head['meta'][] = $meta[2]; |
| 2647 |
} |
} |
| 2648 |
|
$head['meta'] = implode( "\n", $head['meta'] ); |
| 2649 |
|
|
| 2650 |
$my = mamboCore::get('currentUser'); |
$my = mamboCore::get('currentUser'); |
| 2651 |
if ( $my->id ) { |
$head['mambojavascript'] = $my->id ? '<script type="text/javascript" src="'.mamboCore::get('mosConfig_live_site').'/includes/js/mambojavascript.js"></script>' : ''; |
| 2652 |
?> |
|
| 2653 |
<script language="JavaScript1.2" src="<?php echo $mosConfig_live_site;?>/includes/js/mambojavascript.js" type="text/javascript"></script> |
$head['custom'] = array(); |
| 2654 |
<?php |
foreach ($this->_head['custom'] as $html) |
| 2655 |
} |
if (trim($html) !== '') |
| 2656 |
|
$head['custom'][] = $html; |
| 2657 |
|
if (count($head['custom']) !== 0) |
| 2658 |
|
$head['custom'] = implode( "\n", $head['custom'] ); |
| 2659 |
|
else |
| 2660 |
|
$head['custom'] = ''; |
| 2661 |
|
|
| 2662 |
|
ob_start(); |
| 2663 |
$this->liveBookMark(); |
$this->liveBookMark(); |
| 2664 |
// outputs link tag for page |
$head['livebookmark'] = ob_get_contents(); |
| 2665 |
|
ob_end_clean(); |
| 2666 |
|
|
| 2667 |
$configuration =& mamboCore::getMamboCore(); |
$configuration =& mamboCore::getMamboCore(); |
| 2668 |
?> |
$head['favicon'] = "<link rel=\"shortcut icon\" href=\"".$configuration->getFavIcon()."\" />"; |
| 2669 |
<link rel="shortcut icon" href="<?php echo $configuration->getFavIcon();?>" /> |
|
| 2670 |
<?php |
foreach($head as $key=>$value) |
| 2671 |
|
$this->_head['output'][$key] = "$value"; |
| 2672 |
|
|
| 2673 |
|
$tags = $this->_head['output']; |
| 2674 |
|
if (count($keys) == 0) { |
| 2675 |
|
foreach($tags as $key=>$value) |
| 2676 |
|
if (!in_array($key, $exclude)) |
| 2677 |
|
if ($value !== '') |
| 2678 |
|
echo trim($value)."\n"; |
| 2679 |
|
} else { |
| 2680 |
|
foreach($keys as $key) |
| 2681 |
|
if (isset($tags[$key])) |
| 2682 |
|
if(trim($tags[$key]) !== '') |
| 2683 |
|
echo trim($tags[$key])."\n"; |
| 2684 |
|
} |
| 2685 |
|
} |
| 2686 |
|
|
| 2687 |
|
/** |
| 2688 |
|
* retained for backward compatability |
| 2689 |
|
*/ |
| 2690 |
|
function getBlogSectionCount() { |
| 2691 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2692 |
|
$handler =& new contentHandler(); |
| 2693 |
|
return $handler->getBlogSectionCount(); |
| 2694 |
|
} |
| 2695 |
|
|
| 2696 |
|
function getBlogCategoryCount() { |
| 2697 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2698 |
|
$handler =& new contentHandler(); |
| 2699 |
|
return $handler->getBlogCategoryCount(); |
| 2700 |
|
} |
| 2701 |
|
|
| 2702 |
|
function getGlobalBlogSectionCount() { |
| 2703 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2704 |
|
$handler =& new contentHandler(); |
| 2705 |
|
return $handler->getGlobalBlogSectionCount(); |
| 2706 |
|
} |
| 2707 |
|
|
| 2708 |
|
function getStaticContentCount() { |
| 2709 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2710 |
|
$handler =& new contentHandler(); |
| 2711 |
|
return $handler->getStaticContentCount(); |
| 2712 |
|
} |
| 2713 |
|
|
| 2714 |
|
function getContentItemLinkCount() { |
| 2715 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); |
| 2716 |
|
$handler =& new contentHandler(); |
| 2717 |
|
return $handler->getContentItemLinkCount(); |
| 2718 |
} |
} |
| 2719 |
|
/** |
| 2720 |
|
* retained for backward compatability |
| 2721 |
|
*/ |
| 2722 |
|
|
| 2723 |
} |
} |
| 2724 |
|
|
| 3042 |
return ((float)$usec + (float)$sec); |
return ((float)$usec + (float)$sec); |
| 3043 |
} |
} |
| 3044 |
} |
} |
| 3045 |
|
|
| 3046 |
|
|
| 3047 |
|
/** |
| 3048 |
|
* @author Mikolaj Jedrzejak <mikolajj@op.pl> |
| 3049 |
|
* @copyright Copyright Mikolaj Jedrzejak (c) 2003-2004 |
| 3050 |
|
* @version 1.0 2004-07-27 00:37 |
| 3051 |
|
* @link http://www.unicode.org Unicode Homepage |
| 3052 |
|
* @link http://www.mikkom.pl My Homepage |
| 3053 |
|
* |
| 3054 |
|
**/ |
| 3055 |
|
$PATH_TO_CLASS = dirname(ereg_replace("\\\\","/",__FILE__)) . "/" . "ConvertTables" . "/"; |
| 3056 |
|
@require_once($PATH_TO_CLASS."/charsetmapping.php"); |
| 3057 |
|
define ("CONVERT_TABLES_DIR", $PATH_TO_CLASS); |
| 3058 |
|
define ("DEBUG_MODE", 1); |
| 3059 |
|
|
| 3060 |
|
/** |
| 3061 |
|
* -- 1.0 2004-07-28 -- |
| 3062 |
|
* |
| 3063 |
|
* -- The most important thing -- |
| 3064 |
|
* I want to thank all people who helped me fix all bugs, small and big once. |
| 3065 |
|
* I hope that you don't mind that your names are in this file. |
| 3066 |
|
* |
| 3067 |
|
* -- Some Apache issues -- |
| 3068 |
|
* I get info from Lukas Lisa, that in some cases with special apache configuration |
| 3069 |
|
* you have to put header() function with proper encoding to get your result |
| 3070 |
|
* displayed correctly. |
| 3071 |
|
* If you want to see what I mean, go to demo.php and demo1.php |
| 3072 |
|
* |
| 3073 |
|
* -- BETA 1.0 2003-10-21 -- |
| 3074 |
|
* |
| 3075 |
|
* -- You should know about... -- |
| 3076 |
|
* For good understanding this class you shouls read all this stuff first :) but if you are |
| 3077 |
|
* in a hurry just start the demo.php and see what's inside. |
| 3078 |
|
* 1. That I'm not good in english at 03:45 :) - so forgive me all mistakes |
| 3079 |
|
* 2. This class is a BETA version because I haven't tested it enough |
| 3080 |
|
* 3. Feel free to contact me with questions, bug reports and mistakes in PHP and this documentation (email below) |
| 3081 |
|
* |
| 3082 |
|
* -- In a few words... -- |
| 3083 |
|
* Why ConvertCharset class? |
| 3084 |
|
* |
| 3085 |
|
* I have made this class because I had a lot of problems with diferent charsets. First because people |
| 3086 |
|
* from Microsoft wanted to have thair own encoding, second because people from Macromedia didn't |
| 3087 |
|
* thought about other languages, third because sometimes I need to use text written on MAC, and of course |
| 3088 |
|
* it has its own encoding :) |
| 3089 |
|
* |
| 3090 |
|
* Notice & remember: |
| 3091 |
|
* - When I'm saying 1 byte string I mean 1 byte per char. |
| 3092 |
|
* - When I'm saying multibyte string I mean more than one byte per char. |
| 3093 |
|
* |
| 3094 |
|
* So, this are main FEATURES of this class: |
| 3095 |
|
* - conversion between 1 byte charsets |
| 3096 |
|
* - conversion from 1 byte to multi byte charset (utf-8) |
| 3097 |
|
* - conversion from multibyte charset (utf-8) to 1 byte charset |
| 3098 |
|
* - every conversion output can be save with numeric entities (browser charset independent - not a full truth) |
| 3099 |
|
* |
| 3100 |
|
* This is a list of charsets you can operate with, the basic rule is that a char have to be in both charsets, |
| 3101 |
|
* otherwise you'll get an error. |
| 3102 |
|
* |
| 3103 |
|
* - WINDOWS |
| 3104 |
|
* - windows-1250 - Central Europe |
| 3105 |
|
* - windows-1251 - Cyrillic |
| 3106 |
|
* - windows-1252 - Latin I |
| 3107 |
|
* - windows-1253 - Greek |
| 3108 |
|
* - windows-1254 - Turkish |
| 3109 |
|
* - windows-1255 - Hebrew |
| 3110 |
|
* - windows-1256 - Arabic |
| 3111 |
|
* - windows-1257 - Baltic |
| 3112 |
|
* - windows-1258 - Viet Nam |
| 3113 |
|
* - cp874 - Thai - this file is also for DOS |
| 3114 |
|
* |
| 3115 |
|
* - DOS |
| 3116 |
|
* - cp437 - Latin US |
| 3117 |
|
* - cp737 - Greek |
| 3118 |
|
* - cp775 - BaltRim |
| 3119 |
|
* - cp850 - Latin1 |
| 3120 |
|
* - cp852 - Latin2 |
| 3121 |
|
* - cp855 - Cyrylic |
| 3122 |
|
* - cp857 - Turkish |
| 3123 |
|
* - cp860 - Portuguese |
| 3124 |
|
* - cp861 - Iceland |
| 3125 |
|
* - cp862 - Hebrew |
| 3126 |
|
* - cp863 - Canada |
| 3127 |
|
* - cp864 - Arabic |
| 3128 |
|
* - cp865 - Nordic |
| 3129 |
|
* - cp866 - Cyrylic Russian (this is the one, used in IE "Cyrillic (DOS)" ) |
| 3130 |
|
* - cp869 - Greek2 |
| 3131 |
|
* |
| 3132 |
|
* - MAC (Apple) |
| 3133 |
|
* - x-mac-cyrillic |
| 3134 |
|
* - x-mac-greek |
| 3135 |
|
* - x-mac-icelandic |
| 3136 |
|
* - x-mac-ce |
| 3137 |
|
* - x-mac-roman |
| 3138 |
|
* |
| 3139 |
|
* - ISO (Unix/Linux) |
| 3140 |
|
* - iso-8859-1 |
| 3141 |
|
* - iso-8859-2 |
| 3142 |
|
* - iso-8859-3 |
| 3143 |
|
* - iso-8859-4 |
| 3144 |
|
* - iso-8859-5 |
| 3145 |
|
* - iso-8859-6 |
| 3146 |
|
* - iso-8859-7 |
| 3147 |
|
* - iso-8859-8 |
| 3148 |
|
* - iso-8859-9 |
| 3149 |
|
* - iso-8859-10 |
| 3150 |
|
* - iso-8859-11 |
| 3151 |
|
* - iso-8859-12 |
| 3152 |
|
* - iso-8859-13 |
| 3153 |
|
* - iso-8859-14 |
| 3154 |
|
* - iso-8859-15 |
| 3155 |
|
* - iso-8859-16 |
| 3156 |
|
* |
| 3157 |
|
* - MISCELLANEOUS |
| 3158 |
|
* - gsm0338 (ETSI GSM 03.38) |
| 3159 |
|
* - cp037 |
| 3160 |
|
* - cp424 |
| 3161 |
|
* - cp500 |
| 3162 |
|
* - cp856 |
| 3163 |
|
* - cp875 |
| 3164 |
|
* - cp1006 |
| 3165 |
|
* - cp1026 |
| 3166 |
|
* - koi8-r (Cyrillic) |
| 3167 |
|
* - koi8-u (Cyrillic Ukrainian) |
| 3168 |
|
* - nextstep |
| 3169 |
|
* - us-ascii |
| 3170 |
|
* - us-ascii-quotes |
| 3171 |
|
* |
| 3172 |
|
* - DSP implementation for NeXT |
| 3173 |
|
* - stdenc |
| 3174 |
|
* - symbol |
| 3175 |
|
* - zdingbat |
| 3176 |
|
* |
| 3177 |
|
* - And specially for old Polish programs |
| 3178 |
|
* - mazovia |
| 3179 |
|
* |
| 3180 |
|
* -- Now, to the point... -- |
| 3181 |
|
* Here are main variables. |
| 3182 |
|
* |
| 3183 |
|
* DEBUG_MODE |
| 3184 |
|
* |
| 3185 |
|
* You can set this value to: |
| 3186 |
|
* - -1 - No errors or comments |
| 3187 |
|
* - 0 - Only error messages, no comments |
| 3188 |
|
* - 1 - Error messages and comments |
| 3189 |
|
* |
| 3190 |
|
* Default value is 1, and during first steps with class it should be left as is. |
| 3191 |
|
* |
| 3192 |
|
* CONVERT_TABLES_DIR |
| 3193 |
|
* |
| 3194 |
|
* This is a place where you store all files with charset encodings. Filenames should have |
| 3195 |
|
* the same names as encodings. My advise is to keep existing names, because thay |
| 3196 |
|
* were taken from unicode.org (www.unicode.org), and after update to unicode 3.0 or 4.0 |
| 3197 |
|
* the names of files will be the same, so if you want to save your time...uff, leave the |
| 3198 |
|
* names as thay are for future updates. |
| 3199 |
|
* |
| 3200 |
|
* The directory with edings files should be in a class location directory by default, |
| 3201 |
|
* but of course you can change it if you like. |
| 3202 |
|
* |
| 3203 |
|
* @package All about charset... |
| 3204 |
|
* @author Mikolaj Jedrzejak <mikolajj@op.pl> |
| 3205 |
|
* @copyright Copyright Mikolaj Jedrzejak (c) 2003-2004 |
| 3206 |
|
* @version 1.0 2004-07-27 23:11 |
| 3207 |
|
* @access public |
| 3208 |
|
* |
| 3209 |
|
* @link http://www.unicode.org Unicode Homepage |
| 3210 |
|
**/ |
| 3211 |
|
class ConvertCharset { |
| 3212 |
|
var $RecognizedEncoding; //This value keeps information if string contains multibyte chars. |
| 3213 |
|
var $Entities; // This value keeps information if output should be with numeric entities. |
| 3214 |
|
|
| 3215 |
|
/** |
| 3216 |
|
* CharsetChange::NumUnicodeEntity() |
| 3217 |
|
* |
| 3218 |
|
* Unicode encoding bytes, bits representation. |
| 3219 |
|
* Each b represents a bit that can be used to store character data. |
| 3220 |
|
* - bytes, bits, binary representation |
| 3221 |
|
* - 1, 7, 0bbbbbbb |
| 3222 |
|
* - 2, 11, 110bbbbb 10bbbbbb |
| 3223 |
|
* - 3, 16, 1110bbbb 10bbbbbb 10bbbbbb |
| 3224 |
|
* - 4, 21, 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
| 3225 |
|
* |
| 3226 |
|
* This function is written in a "long" way, for everyone who woluld like to analize |
| 3227 |
|
* the process of unicode encoding and understand it. All other functions like HexToUtf |
| 3228 |
|
* will be written in a "shortest" way I can write tham :) it does'n mean thay are short |
| 3229 |
|
* of course. You can chech it in HexToUtf() (link below) - very similar function. |
| 3230 |
|
* |
| 3231 |
|
* IMPORTANT: Remember that $UnicodeString input CANNOT have single byte upper half |
| 3232 |
|
* extended ASCII codes, why? Because there is a posibility that this function will eat |
| 3233 |
|
* the following char thinking it's miltibyte unicode char. |
| 3234 |
|
* |
| 3235 |
|
* @param string $UnicodeString Input Unicode string (1 char can take more than 1 byte) |
| 3236 |
|
* @return string This is an input string olso with unicode chars, bus saved as entities |
| 3237 |
|
* @see HexToUtf() |
| 3238 |
|
**/ |
| 3239 |
|
function UnicodeEntity ($UnicodeString) |
| 3240 |
|
{ |
| 3241 |
|
$OutString = ""; |
| 3242 |
|
$StringLenght = strlen ($UnicodeString); |
| 3243 |
|
for ($CharPosition = 0; $CharPosition < $StringLenght; $CharPosition++) |
| 3244 |
|
{ |
| 3245 |
|
$Char = $UnicodeString [$CharPosition]; |
| 3246 |
|
$AsciiChar = ord ($Char); |
| 3247 |
|
|
| 3248 |
|
if ($AsciiChar < 128) //1 7 0bbbbbbb (127) |
| 3249 |
|
{ |
| 3250 |
|
$OutString .= $Char; |
| 3251 |
|
} |
| 3252 |
|
else if ($AsciiChar >> 5 == 6) //2 11 110bbbbb 10bbbbbb (2047) |
| 3253 |
|
{ |
| 3254 |
|
$FirstByte = ($AsciiChar & 31); |
| 3255 |
|
$CharPosition++; |
| 3256 |
|
$Char = $UnicodeString [$CharPosition]; |
| 3257 |
|
$AsciiChar = ord ($Char); |
| 3258 |
|
$SecondByte = ($AsciiChar & 63); |
| 3259 |
|
$AsciiChar = ($FirstByte * 64) + $SecondByte; |
| 3260 |
|
$Entity = sprintf ("&#%d;", $AsciiChar); |
| 3261 |
|
$OutString .= $Entity; |
| 3262 |
|
} |
| 3263 |
|
else if ($AsciiChar >> 4 == 14) //3 16 1110bbbb 10bbbbbb 10bbbbbb |
| 3264 |
|
{ |
| 3265 |
|
$FirstByte = ($AsciiChar & 31); |
| 3266 |
|
$CharPosition++; |
| 3267 |
|
$Char = $UnicodeString [$CharPosition]; |
| 3268 |
|
$AsciiChar = ord ($Char); |
| 3269 |
|
$SecondByte = ($AsciiChar & 63); |
| 3270 |
|
$CharPosition++; |
| 3271 |
|
$Char = $UnicodeString [$CharPosition]; |
| 3272 |
|
$AsciiChar = ord ($Char); |
| 3273 |
|
$ThidrByte = ($AsciiChar & 63); |
| 3274 |
|
$AsciiChar = ((($FirstByte * 64) + $SecondByte) * 64) + $ThidrByte; |
| 3275 |
|
|
| 3276 |
|
$Entity = sprintf ("&#%d;", $AsciiChar); |
| 3277 |
|
$OutString .= $Entity; |
| 3278 |
|
} |
| 3279 |
|
else if ($AsciiChar >> 3 == 30) //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb |
| 3280 |
|
{ |
| 3281 |
|
$FirstByte = ($AsciiChar & 31); |
| 3282 |
|
$CharPosition++; |
| 3283 |
|
$Char = $UnicodeString [$CharPosition]; |
| 3284 |
|
$AsciiChar = ord ($Char); |
| 3285 |
|
$SecondByte = ($AsciiChar & 63); |
| 3286 |
|
$CharPosition++; |
| 3287 |
|
$Char = $UnicodeString [$CharPosition]; |
| 3288 |
|
$AsciiChar = ord ($Char); |
| 3289 |
|
$ThidrByte = ($AsciiChar & 63); |
| 3290 |
|
$CharPosition++; |
| 3291 |
|
$Char = $UnicodeString [$CharPosition]; |
| 3292 |
|
$AsciiChar = ord ($Char); |
| 3293 |
|
$FourthByte = ($AsciiChar & 63); |
| 3294 |
|
$AsciiChar = ((((($FirstByte * 64) + $SecondByte) * 64) + $ThidrByte) * 64) + $FourthByte; |
| 3295 |
|
|
| 3296 |
|
$Entity = sprintf ("&#%d;", $AsciiChar); |
| 3297 |
|
$OutString .= $Entity; |
| 3298 |
|
} |
| 3299 |
|
} |
| 3300 |
|
return $OutString; |
| 3301 |
|
} |
| 3302 |
|
|
| 3303 |
|
/** |
| 3304 |
|
* ConvertCharset::HexToUtf() |
| 3305 |
|
* |
| 3306 |
|
* This simple function gets unicode char up to 4 bytes and return it as a regular char. |
| 3307 |
|
* It is very similar to UnicodeEntity function (link below). There is one difference |
| 3308 |
|
* in returned format. This time it's a regular char(s), in most cases it will be one or two chars. |
| 3309 |
|
* |
| 3310 |
|
* @param string $UtfCharInHex Hexadecimal value of a unicode char. |
| 3311 |
|
* @return string Encoded hexadecimal value as a regular char. |
| 3312 |
|
* @see UnicodeEntity() |
| 3313 |
|
**/ |
| 3314 |
|
function HexToUtf ($UtfCharInHex) |
| 3315 |
|
{ |
| 3316 |
|
$OutputChar = ""; |
| 3317 |
|
$UtfCharInDec = hexdec($UtfCharInHex); |
| 3318 |
|
if($UtfCharInDec<128) $OutputChar .= chr($UtfCharInDec); |
| 3319 |
|
else if($UtfCharInDec<2048)$OutputChar .= chr(($UtfCharInDec>>6)+192).chr(($UtfCharInDec&63)+128); |
| 3320 |
|
else if($UtfCharInDec<65536)$OutputChar .= chr(($UtfCharInDec>>12)+224).chr((($UtfCharInDec>>6)&63)+128).chr(($UtfCharInDec&63)+128); |
| 3321 |
|
else if($UtfCharInDec<2097152)$OutputChar .= chr($UtfCharInDec>>18+240).chr((($UtfCharInDec>>12)&63)+128).chr(($UtfCharInDec>>6)&63+128). chr($UtfCharInDec&63+128); |
| 3322 |
|
return $OutputChar; |
| 3323 |
|
} |
| 3324 |
|
|
| 3325 |
|
|
| 3326 |
|
/** |
| 3327 |
|
* CharsetChange::MakeConvertTable() |
| 3328 |
|
* |
| 3329 |
|
* This function creates table with two SBCS (Single Byte Character Set). Every conversion |
| 3330 |
|
* is through this table. |
| 3331 |
|
* |
| 3332 |
|
* - The file with encoding tables have to be save in "Format A" of unicode.org charset table format! This is usualy writen in a header of every charset file. |
| 3333 |
|
* - BOTH charsets MUST be SBCS |
| 3334 |
|
* - The files with encoding tables have to be complet (Non of chars can be missing, unles you are sure you are not going to use it) |
| 3335 |
|
* |
| 3336 |
|
* "Format A" encoding file, if you have to build it by yourself should aplly these rules: |
| 3337 |
|
* - you can comment everything with # |
| 3338 |
|
* - first column contains 1 byte chars in hex starting from 0x.. |
| 3339 |
|
* - second column contains unicode equivalent in hex starting from 0x.... |
| 3340 |
|
* - then every next column is optional, but in "Format A" it should contain unicode char name or/and your own comment |
| 3341 |
|
* - the columns can be splited by "spaces", "tabs", "," or any combination of these |
| 3342 |
|
* - below is an example |
| 3343 |
|
* |
| 3344 |
|
* <code> |
| 3345 |
|
* # |
| 3346 |
|
* # The entries are in ANSI X3.4 order. |
| 3347 |
|
* # |
| 3348 |
|
* 0x00 0x0000 # NULL end extra comment, if needed |
| 3349 |
|
* 0x01 0x0001 # START OF HEADING |
| 3350 |
|
* # Oh, one more thing, you can make comments inside of a rows if you like. |
| 3351 |
|
* 0x02 0x0002 # START OF TEXT |
| 3352 |
|
* 0x03 0x0003 # END OF TEXT |
| 3353 |
|
* next line, and so on... |
| 3354 |
|
* </code> |
| 3355 |
|
* |
| 3356 |
|
* You can get full tables with encodings from http://www.unicode.org |
| 3357 |
|
* |
| 3358 |
|
* @param string $FirstEncoding Name of first encoding and first encoding filename (thay have to be the same) |
| 3359 |
|
* @param string $SecondEncoding Name of second encoding and second encoding filename (thay have to be the same). Optional for building a joined table. |
| 3360 |
|
* @return array Table necessary to change one encoding to another. |
| 3361 |
|
**/ |
| 3362 |
|
function MakeConvertTable ($FirstEncoding, $SecondEncoding = "") |
| 3363 |
|
{ |
| 3364 |
|
$ConvertTable = array(); |
| 3365 |
|
for($i = 0; $i < func_num_args(); $i++) |
| 3366 |
|
{ |
| 3367 |
|
/** |
| 3368 |
|
* Because func_*** can't be used inside of another function call |
| 3369 |
|
* we have to save it as a separate value. |
| 3370 |
|
**/ |
| 3371 |
|
$FileName = func_get_arg($i); |
| 3372 |
|
if (!is_file(CONVERT_TABLES_DIR . $FileName)) |
| 3373 |
|
{ |
| 3374 |
|
print $this->DebugOutput(0, 0, CONVERT_TABLES_DIR . $FileName); //Print an error message |
| 3375 |
|
exit; |
| 3376 |
|
} |
| 3377 |
|
$FileWithEncTabe = fopen(CONVERT_TABLES_DIR . $FileName, "r") or die(); //This die(); is just to make sure... |
| 3378 |
|
while(!feof($FileWithEncTabe)) |
| 3379 |
|
{ |
| 3380 |
|
/** |
| 3381 |
|
* We asume that line is not longer |
| 3382 |
|
* than 1024 which is the default value for fgets function |
| 3383 |
|
**/ |
| 3384 |
|
if($OneLine=trim(fgets($FileWithEncTabe, 1024))) |
| 3385 |
|
{ |
| 3386 |
|
/** |
| 3387 |
|
* We don't need all comment lines. I check only for "#" sign, because |
| 3388 |
|
* this is a way of making comments by unicode.org in thair encoding files |
| 3389 |
|
* and that's where the files are from :-) |
| 3390 |
|
**/ |
| 3391 |
|
if (substr($OneLine, 0, 1) != "#") |
| 3392 |
|
{ |
| 3393 |
|
/** |
| 3394 |
|
* Sometimes inside the charset file the hex walues are separated by |
| 3395 |
|
* "space" and sometimes by "tab", the below preg_split can also be used |
| 3396 |
|
* to split files where separator is a ",", "\r", "\n" and "\f" |
| 3397 |
|
**/ |
| 3398 |
|
$HexValue = preg_split ("/[\s,]+/", $OneLine, 3); //We need only first 2 values |
| 3399 |
|
/** |
| 3400 |
|
* Sometimes char is UNDEFINED, or missing so we can't use it for convertion |
| 3401 |
|
**/ |
| 3402 |
|
if (substr($HexValue[1], 0, 1) != "#") |
| 3403 |
|
{ |
| 3404 |
|
$ArrayKey = strtoupper(str_replace(strtolower("0x"), "", $HexValue[1])); |
| 3405 |
|
$ArrayValue = strtoupper(str_replace(strtolower("0x"), "", $HexValue[0])); |
| 3406 |
|
$ConvertTable[func_get_arg($i)][$ArrayKey] = $ArrayValue; |
| 3407 |
|
} |
| 3408 |
|
} //if (substr($OneLine,... |
| 3409 |
|
} //if($OneLine=trim(f... |
| 3410 |
|
} //while(!feof($FirstFileWi... |
| 3411 |
|
} //for($i = 0; $i < func_... |
| 3412 |
|
/** |
| 3413 |
|
* The last thing is to check if by any reason both encoding tables are not the same. |
| 3414 |
|
* For example, it will happen when you save the encoding table file with a wrong name |
| 3415 |
|
* - of another charset. |
| 3416 |
|
**/ |
| 3417 |
|
if ((func_num_args() > 1) && (count($ConvertTable[$FirstEncoding]) == count($ConvertTable[$SecondEncoding])) && (count(array_diff_assoc($ConvertTable[$FirstEncoding], $ConvertTable[$SecondEncoding])) == 0)) |
| 3418 |
|
{ |
| 3419 |
|
print $this->DebugOutput(1, 1, "$FirstEncoding, $SecondEncoding"); |
| 3420 |
|
} |
| 3421 |
|
return $ConvertTable; |
| 3422 |
|
} |
| 3423 |
|
|
| 3424 |
|
|
| 3425 |
|
|
| 3426 |
|
/** |
| 3427 |
|
* ConvertCharset::Convert() |
| 3428 |
|
* |
| 3429 |
|
* This is a basic function you are using. I hope that you can figure out this function syntax :-) |
| 3430 |
|
* |
| 3431 |
|
* @param string $StringToChange The string you want to change :) |
| 3432 |
|
* @param string $FromCharset Name of $StringToChange encoding, you have to know it. |
| 3433 |
|
* @param string $ToCharset Name of a charset you want to get for $StringToChange. |
| 3434 |
|
* @param boolean $TurnOnEntities Set to true or 1 if you want to use numeric entities insted of regular chars. |
| 3435 |
|
* @return string Converted string in brand new encoding :) |
| 3436 |
|
* @version 1.0 2004-07-27 01:09 |
| 3437 |
|
**/ |
| 3438 |
|
function Convert ($StringToChange, $FromCharset, $ToCharset, $TurnOnEntities = false) |
| 3439 |
|
{ |
| 3440 |
|
/** |
| 3441 |
|
* Check are there all variables |
| 3442 |
|
**/ |
| 3443 |
|
/*if ($StringToChange == "") |
| 3444 |
|
{ |
| 3445 |
|
print $this->DebugOutput(0, 3, "\$StringToChange"); |
| 3446 |
|
} |
| 3447 |
|
else*/ |
| 3448 |
|
if ($FromCharset == "") |
| 3449 |
|
{ |
| 3450 |
|
print $this->DebugOutput(0, 3, "\$FromCharset"); |
| 3451 |
|
} |
| 3452 |
|
else if ($ToCharset == "") |
| 3453 |
|
{ |
| 3454 |
|
print $this->DebugOutput(0, 3, "\$ToCharset"); |
| 3455 |
|
} |
| 3456 |
|
|
| 3457 |
|
/** |
| 3458 |
|
* Now a few variables need to be set. |
| 3459 |
|
**/ |
| 3460 |
|
$NewString = ""; |
| 3461 |
|
$this->Entities = $TurnOnEntities; |
| 3462 |
|
|
| 3463 |
|
/** |
| 3464 |
|
* For all people who like to use uppercase for charset encoding names :) |
| 3465 |
|
**/ |
| 3466 |
|
$FromCharset = strtolower($FromCharset); |
| 3467 |
|
$ToCharset = strtolower($ToCharset); |
| 3468 |
|
|
| 3469 |
|
/** |
| 3470 |
|
* Of course you can make a conversion from one charset to the same one :) |
| 3471 |
|
* but I feel obligate to let you know about it. |
| 3472 |
|
**/ |
| 3473 |
|
if ($FromCharset == $ToCharset) |
| 3474 |
|
{ |
| 3475 |
|
print $this->DebugOutput(1, 0, $FromCharset); |
| 3476 |
|
} |
| 3477 |
|
if (($FromCharset == $ToCharset) AND ($FromCharset == "utf-8")) |
| 3478 |
|
{ |
| 3479 |
|
print $this->DebugOutput(0, 4, $FromCharset); |
| 3480 |
|
exit; |
| 3481 |
|
} |
| 3482 |
|
|
| 3483 |
|
/** |
| 3484 |
|
* This divison was made to prevent errors during convertion to/from utf-8 with |
| 3485 |
|
* "entities" enabled, because we need to use proper destination(to)/source(from) |
| 3486 |
|
* encoding table to write proper entities. |
| 3487 |
|
* |
| 3488 |
|
* This is the first case. We are convertinf from 1byte chars... |
| 3489 |
|
**/ |
| 3490 |
|
if ($FromCharset != "utf-8") |
| 3491 |
|
{ |
| 3492 |
|
/** |
| 3493 |
|
* Now build table with both charsets for encoding change. |
| 3494 |
|
**/ |
| 3495 |
|
if ($ToCharset != "utf-8") |
| 3496 |
|
{ |
| 3497 |
|
$CharsetTable = $this->MakeConvertTable ($FromCharset, $ToCharset); |
| 3498 |
|
} |
| 3499 |
|
else |
| 3500 |
|
{ |
| 3501 |
|
$CharsetTable = $this->MakeConvertTable ($FromCharset); |
| 3502 |
|
} |
| 3503 |
|
/** |
| 3504 |
|
* For each char in a string... |
| 3505 |
|
**/ |
| 3506 |
|
for ($i = 0; $i < strlen($StringToChange); $i++) |
| 3507 |
|
{ |
| 3508 |
|
$HexChar = ""; |
| 3509 |
|
$UnicodeHexChar = ""; |
| 3510 |
|
$HexChar = strtoupper(dechex(ord($StringToChange[$i]))); |
| 3511 |
|
// This is fix from Mario Klingemann, it prevents |
| 3512 |
|
// droping chars below 16 because of missing leading 0 [zeros] |
| 3513 |
|
if (strlen($HexChar)==1) $HexChar = "0".$HexChar; |
| 3514 |
|
//end of fix by Mario Klingemann |
| 3515 |
|
// This is quick fix of 10 chars in gsm0338 |
| 3516 |
|
// Thanks goes to Andrea Carpani who pointed on this problem |
| 3517 |
|
// and solve it ;) |
| 3518 |
|
if (($FromCharset == "gsm0338") && ($HexChar == '1B')) { |
| 3519 |
|
$i++; |
| 3520 |
|
$HexChar .= strtoupper(dechex(ord($StringToChange[$i]))); |
| 3521 |
|
} |
| 3522 |
|
// end of workarround on 10 chars from gsm0338 |
| 3523 |
|
if ($ToCharset != "utf-8") |
| 3524 |
|
{ |
| 3525 |
|
if (in_array($HexChar, $CharsetTable[$FromCharset])) |
| 3526 |
|
{ |
| 3527 |
|
$UnicodeHexChar = array_search($HexChar, $CharsetTable[$FromCharset]); |
| 3528 |
|
$UnicodeHexChars = explode("+",$UnicodeHexChar); |
| 3529 |
|
for($UnicodeHexCharElement = 0; $UnicodeHexCharElement < count($UnicodeHexChars); $UnicodeHexCharElement++) |
| 3530 |
|
{ |
| 3531 |
|
if (array_key_exists($UnicodeHexChars[$UnicodeHexCharElement], $CharsetTable[$ToCharset])) |
| 3532 |
|
{ |
| 3533 |
|
if ($this->Entities == true) |
| 3534 |
|
{ |
| 3535 |
|
$NewString .= $this->UnicodeEntity($this->HexToUtf($UnicodeHexChars[$UnicodeHexCharElement])); |
| 3536 |
|
} |
| 3537 |
|
else |
| 3538 |
|
{ |
| 3539 |
|
$NewString .= chr(hexdec($CharsetTable[$ToCharset][$UnicodeHexChars[$UnicodeHexCharElement]])); |
| 3540 |
|
} |
| 3541 |
|
} |
| 3542 |
|
else |
| 3543 |
|
{ |
| 3544 |
|
print $this->DebugOutput(0, 1, $StringToChange[$i]); |
| 3545 |
|
} |
| 3546 |
|
} //for($UnicodeH... |
| 3547 |
|
} |
| 3548 |
|
else |
| 3549 |
|
{ |
| 3550 |
|
print $this->DebugOutput(0, 2,$StringToChange[$i]); |
| 3551 |
|
} |
| 3552 |
|
} |
| 3553 |
|
else |
| 3554 |
|
{ |
| 3555 |
|
if (in_array("$HexChar", $CharsetTable[$FromCharset])) |
| 3556 |
|
{ |
| 3557 |
|
$UnicodeHexChar = array_search($HexChar, $CharsetTable[$FromCharset]); |
| 3558 |
|
/** |
| 3559 |
|
* Sometimes there are two or more utf-8 chars per one regular char. |
| 3560 |
|
* Extream, example is polish old Mazovia encoding, where one char contains |
| 3561 |
|
* two lettes 007a (z) and 0142 (l slash), we need to figure out how to |
| 3562 |
|
* solve this problem. |
| 3563 |
|
* The letters are merge with "plus" sign, there can be more than two chars. |
| 3564 |
|
* In Mazowia we have 007A+0142, but sometimes it can look like this |
| 3565 |
|
* 0x007A+0x0142+0x2034 (that string means nothing, it just shows the possibility...) |
| 3566 |
|
**/ |
| 3567 |
|
$UnicodeHexChars = explode("+",$UnicodeHexChar); |
| 3568 |
|
for($UnicodeHexCharElement = 0; $UnicodeHexCharElement < count($UnicodeHexChars); $UnicodeHexCharElement++) |
| 3569 |
|
{ |
| 3570 |
|
if ($this->Entities == true) |
| 3571 |
|
{ |
| 3572 |
|
$NewString .= $this->UnicodeEntity($this->HexToUtf($UnicodeHexChars[$UnicodeHexCharElement])); |
| 3573 |
|
} |
| 3574 |
|
else |
| 3575 |
|
{ |
| 3576 |
|
$NewString .= $this->HexToUtf($UnicodeHexChars[$UnicodeHexCharElement]); |
| 3577 |
|
} |
| 3578 |
|
} // for |
| 3579 |
|
} |
| 3580 |
|
else |
| 3581 |
|
{ |
| 3582 |
|
print $this->DebugOutput(0, 2, $StringToChange[$i]); |
| 3583 |
|
} |
| 3584 |
|
} |
| 3585 |
|
} |
| 3586 |
|
} |
| 3587 |
|
/** |
| 3588 |
|
* This is second case. We are encoding from multibyte char string. |
| 3589 |
|
**/ |
| 3590 |
|
else if($FromCharset == "utf-8") |
| 3591 |
|
{ |
| 3592 |
|
$HexChar = ""; |
| 3593 |
|
$UnicodeHexChar = ""; |
| 3594 |
|
$CharsetTable = $this->MakeConvertTable ($ToCharset); |
| 3595 |
|
foreach ($CharsetTable[$ToCharset] as $UnicodeHexChar => $HexChar) |
| 3596 |
|
{ |
| 3597 |
|
if ($this->Entities == true) { |
| 3598 |
|
$EntitieOrChar = $this->UnicodeEntity($this->HexToUtf($UnicodeHexChar)); |
| 3599 |
|
} |
| 3600 |
|
else |
| 3601 |
|
{ |
| 3602 |
|
$EntitieOrChar = chr(hexdec($HexChar)); |
| 3603 |
|
} |
| 3604 |
|
$StringToChange = str_replace($this->HexToUtf($UnicodeHexChar), $EntitieOrChar, $StringToChange); |
| 3605 |
|
} |
| 3606 |
|
$NewString = $StringToChange; |
| 3607 |
|
} |
| 3608 |
|
|
| 3609 |
|
return $NewString; |
| 3610 |
|
} |
| 3611 |
|
|
| 3612 |
|
/** |
| 3613 |
|
* ConvertCharset::DebugOutput() |
| 3614 |
|
* |
| 3615 |
|
* This function is not really necessary, the debug output could stay inside of |
| 3616 |
|
* source code but like this, it's easier to manage and translate. |
| 3617 |
|
* Besides I couldn't find good coment/debug class :-) Maybe I'll write one someday... |
| 3618 |
|
* |
| 3619 |
|
* All messages depend on DEBUG_MODE level, as I was writing before you can set this value to: |
| 3620 |
|
* - -1 - No errors or notces are shown |
| 3621 |
|
* - 0 - Only error messages are shown, no notices |
| 3622 |
|
* - 1 - Error messages and notices are shown |
| 3623 |
|
* |
| 3624 |
|
* @param int $Group Message groupe: error - 0, notice - 1 |
| 3625 |
|
* @param int $Number Following message number |
| 3626 |
|
* @param mix $Value This walue is whatever you want, usualy it's some parameter value, for better message understanding. |
| 3627 |
|
* @return string String with a proper message. |
| 3628 |
|
**/ |
| 3629 |
|
function DebugOutput ($Group, $Number, $Value = false) |
| 3630 |
|
{ |
| 3631 |
|
//$Debug [$Group][$Number] = "Message, can by with $Value"; |
| 3632 |
|
//$Group[0] - Errors |
| 3633 |
|
//$Group[1] - Notice |
| 3634 |
|
$Debug[0][0] = "Error, can NOT read file: " . $Value . "<br />"; |
| 3635 |
|
$Debug[0][1] = "Error, can't find maching char \"". $Value ."\" in destination encoding table!" . "<br />"; |
| 3636 |
|
$Debug[0][2] = "Error, can't find maching char \"". $Value ."\" in source encoding table!" . "<br />"; |
| 3637 |
|
$Debug[0][3] = "Error, you did NOT set variable " . $Value . " in Convert() function." . "<br />"; |
| 3638 |
|
$Debug[0][4] = "You can NOT convert string from " . $Value . " to " . $Value . "!" . "<br />"; |
| 3639 |
|
$Debug[1][0] = "Notice, you are trying to convert string from ". $Value ." to ". $Value .", don't you feel it's strange? ;-)" . "<br />"; |
| 3640 |
|
$Debug[1][1] = "Notice, both charsets " . $Value . " are identical! Check encoding tables files." . "<br />"; |
| 3641 |
|
$Debug[1][2] = "Notice, there is no unicode char in the string you are trying to convert." . "<br />"; |
| 3642 |
|
|
| 3643 |
|
if (DEBUG_MODE >= $Group) |
| 3644 |
|
{ |
| 3645 |
|
return $Debug[$Group][$Number]; |
| 3646 |
|
} |
| 3647 |
|
} // function DebugOutput |
| 3648 |
|
|
| 3649 |
|
} //class ends here |
| 3650 |
|
|
| 3651 |
?> |
?> |