Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 14 | class Context |
||
| 15 | { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Allow rewrite |
||
| 19 | * @var bool TRUE: using rewrite mod, FALSE: otherwise |
||
| 20 | */ |
||
| 21 | public $allow_rewrite = FALSE; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Request method |
||
| 25 | * @var string GET|POST|XMLRPC |
||
| 26 | */ |
||
| 27 | public $request_method = 'GET'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * js callback function name. |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | public $js_callback_func = ''; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Response method.If it's not set, it follows request method. |
||
| 37 | * @var string HTML|XMLRPC |
||
| 38 | */ |
||
| 39 | public $response_method = ''; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Conatins request parameters and environment variables |
||
| 43 | * @var object |
||
| 44 | */ |
||
| 45 | public $context = NULL; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * DB info |
||
| 49 | * @var object |
||
| 50 | */ |
||
| 51 | public $db_info = NULL; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * FTP info |
||
| 55 | * @var object |
||
| 56 | */ |
||
| 57 | public $ftp_info = NULL; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * ssl action cache file |
||
| 61 | * @var array |
||
| 62 | */ |
||
| 63 | public $sslActionCacheFile = './files/cache/sslCacheFile.php'; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * List of actions to be sent via ssl (it is used by javascript xml handler for ajax) |
||
| 67 | * @var array |
||
| 68 | */ |
||
| 69 | public $ssl_actions = array(); |
||
| 70 | |||
| 71 | /** |
||
| 72 | * obejct oFrontEndFileHandler() |
||
| 73 | * @var object |
||
| 74 | */ |
||
| 75 | public $oFrontEndFileHandler; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * script codes in <head>..</head> |
||
| 79 | * @var string |
||
| 80 | */ |
||
| 81 | public $html_header = NULL; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * class names of <body> |
||
| 85 | * @var array |
||
| 86 | */ |
||
| 87 | public $body_class = array(); |
||
| 88 | |||
| 89 | /** |
||
| 90 | * codes after <body> |
||
| 91 | * @var string |
||
| 92 | */ |
||
| 93 | public $body_header = NULL; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * class names before </body> |
||
| 97 | * @var string |
||
| 98 | */ |
||
| 99 | public $html_footer = NULL; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * path of Xpress Engine |
||
| 103 | * @var string |
||
| 104 | */ |
||
| 105 | public $path = ''; |
||
| 106 | // language information - it is changed by HTTP_USER_AGENT or user's cookie |
||
| 107 | /** |
||
| 108 | * language type |
||
| 109 | * @var string |
||
| 110 | */ |
||
| 111 | public $lang_type = ''; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * contains language-specific data |
||
| 115 | * @var object |
||
| 116 | */ |
||
| 117 | public $lang = NULL; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * list of loaded languages (to avoid re-loading them) |
||
| 121 | * @var array |
||
| 122 | */ |
||
| 123 | public $loaded_lang_files = array(); |
||
| 124 | |||
| 125 | /** |
||
| 126 | * site's browser title |
||
| 127 | * @var string |
||
| 128 | */ |
||
| 129 | public $site_title = ''; |
||
| 130 | |||
| 131 | /** |
||
| 132 | * variables from GET or form submit |
||
| 133 | * @var mixed |
||
| 134 | */ |
||
| 135 | public $get_vars = NULL; |
||
| 136 | |||
| 137 | /** |
||
| 138 | * Checks uploaded |
||
| 139 | * @var bool TRUE if attached file exists |
||
| 140 | */ |
||
| 141 | public $is_uploaded = FALSE; |
||
| 142 | /** |
||
| 143 | * Pattern for request vars check |
||
| 144 | * @var array |
||
| 145 | */ |
||
| 146 | public $patterns = array( |
||
| 147 | '/<\?/iUsm', |
||
| 148 | '/<\%/iUsm', |
||
| 149 | '/<script\s*?language\s*?=\s*?("|\')?\s*?php\s*("|\')?/iUsm' |
||
| 150 | ); |
||
| 151 | /** |
||
| 152 | * Check init |
||
| 153 | * @var bool FALSE if init fail |
||
| 154 | */ |
||
| 155 | public $isSuccessInit = TRUE; |
||
| 156 | |||
| 157 | /** |
||
| 158 | * returns static context object (Singleton). It's to use Context without declaration of an object |
||
| 159 | * |
||
| 160 | * @return object Instance |
||
| 161 | */ |
||
| 162 | function &getInstance() |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Cunstructor |
||
| 175 | * |
||
| 176 | * @return void |
||
| 177 | */ |
||
| 178 | function Context() |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Initialization, it sets DB information, request arguments and so on. |
||
| 197 | * |
||
| 198 | * @see This function should be called only once |
||
| 199 | * @return void |
||
| 200 | */ |
||
| 201 | function init() |
||
| 202 | { |
||
| 203 | // fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above |
||
| 204 | if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE) |
||
| 205 | { |
||
| 206 | $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input"); |
||
| 207 | |||
| 208 | // If content is not XML JSON, unset |
||
| 209 | if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE) |
||
| 210 | { |
||
| 211 | unset($GLOBALS['HTTP_RAW_POST_DATA']); |
||
| 212 | } |
||
| 213 | } |
||
| 214 | |||
| 215 | // set context variables in $GLOBALS (to use in display handler) |
||
| 216 | $this->context = &$GLOBALS['__Context__']; |
||
| 217 | $this->context->lang = &$GLOBALS['lang']; |
||
| 218 | $this->context->_COOKIE = $_COOKIE; |
||
| 219 | |||
| 220 | // 20140429 editor/image_link |
||
| 221 | $this->_checkGlobalVars(); |
||
| 222 | |||
| 223 | $this->setRequestMethod(''); |
||
| 224 | |||
| 225 | $this->_setXmlRpcArgument(); |
||
| 226 | $this->_setJSONRequestArgument(); |
||
| 227 | $this->_setRequestArgument(); |
||
| 228 | $this->_setUploadedArgument(); |
||
| 229 | |||
| 230 | $this->loadDBInfo(); |
||
| 231 | if($this->db_info->use_sitelock == 'Y') |
||
| 232 | { |
||
| 233 | if(is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist; |
||
| 234 | |||
| 235 | if(!IpFilter::filter($whitelist)) |
||
| 236 | { |
||
| 237 | $title = ($this->db_info->sitelock_title) ? $this->db_info->sitelock_title : 'Maintenance in progress...'; |
||
| 238 | $message = $this->db_info->sitelock_message; |
||
| 239 | |||
| 240 | define('_XE_SITELOCK_', TRUE); |
||
| 241 | define('_XE_SITELOCK_TITLE_', $title); |
||
| 242 | define('_XE_SITELOCK_MESSAGE_', $message); |
||
| 243 | |||
| 244 | header("HTTP/1.1 403 Forbidden"); |
||
| 245 | if(FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html')) |
||
| 246 | { |
||
| 247 | include _XE_PATH_ . 'common/tpl/sitelock.user.html'; |
||
| 248 | } |
||
| 249 | else |
||
| 250 | { |
||
| 251 | include _XE_PATH_ . 'common/tpl/sitelock.html'; |
||
| 252 | } |
||
| 253 | exit; |
||
| 254 | } |
||
| 255 | } |
||
| 256 | |||
| 257 | // If XE is installed, get virtual site information |
||
| 258 | if(self::isInstalled()) |
||
| 259 | { |
||
| 260 | $oModuleModel = getModel('module'); |
||
| 261 | $site_module_info = $oModuleModel->getDefaultMid(); |
||
| 262 | |||
| 263 | if(!isset($site_module_info)) |
||
| 264 | { |
||
| 265 | $site_module_info = new stdClass(); |
||
| 266 | } |
||
| 267 | |||
| 268 | // if site_srl of site_module_info is 0 (default site), compare the domain to default_url of db_config |
||
| 269 | if($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url) |
||
| 270 | { |
||
| 271 | $site_module_info->domain = $this->db_info->default_url; |
||
| 272 | } |
||
| 273 | |||
| 274 | $this->set('site_module_info', $site_module_info); |
||
| 275 | if($site_module_info->site_srl && isSiteID($site_module_info->domain)) |
||
| 276 | { |
||
| 277 | $this->set('vid', $site_module_info->domain, TRUE); |
||
| 278 | } |
||
| 279 | |||
| 280 | if(!isset($this->db_info)) |
||
| 281 | { |
||
| 282 | $this->db_info = new stdClass(); |
||
| 283 | } |
||
| 284 | |||
| 285 | $this->db_info->lang_type = $site_module_info->default_language; |
||
| 286 | if(!$this->db_info->lang_type) |
||
| 287 | { |
||
| 288 | $this->db_info->lang_type = 'en'; |
||
| 289 | } |
||
| 290 | if(!$this->db_info->use_db_session) |
||
| 291 | { |
||
| 292 | $this->db_info->use_db_session = 'N'; |
||
| 293 | } |
||
| 294 | } |
||
| 295 | |||
| 296 | // Load Language File |
||
| 297 | $lang_supported = $this->loadLangSelected(); |
||
| 298 | |||
| 299 | // Retrieve language type set in user's cookie |
||
| 300 | if($this->lang_type = $this->get('l')) |
||
| 301 | { |
||
| 302 | if($_COOKIE['lang_type'] != $this->lang_type) |
||
| 303 | { |
||
| 304 | setcookie('lang_type', $this->lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000, '/'); |
||
| 305 | } |
||
| 306 | } |
||
| 307 | elseif($_COOKIE['lang_type']) |
||
| 308 | { |
||
| 309 | $this->lang_type = $_COOKIE['lang_type']; |
||
| 310 | } |
||
| 311 | |||
| 312 | // If it's not exists, follow default language type set in db_info |
||
| 313 | if(!$this->lang_type) |
||
| 314 | { |
||
| 315 | $this->lang_type = $this->db_info->lang_type; |
||
| 316 | } |
||
| 317 | |||
| 318 | // if still lang_type has not been set or has not-supported type , set as English. |
||
| 319 | if(!$this->lang_type) |
||
| 320 | { |
||
| 321 | $this->lang_type = 'en'; |
||
| 322 | } |
||
| 323 | if(is_array($lang_supported) && !isset($lang_supported[$this->lang_type])) |
||
| 324 | { |
||
| 325 | $this->lang_type = 'en'; |
||
| 326 | } |
||
| 327 | |||
| 328 | $this->set('lang_supported', $lang_supported); |
||
| 329 | $this->setLangType($this->lang_type); |
||
| 330 | |||
| 331 | // load module module's language file according to language setting |
||
| 332 | $this->loadLang(_XE_PATH_ . 'modules/module/lang'); |
||
| 333 | |||
| 334 | // set session handler |
||
| 335 | if(self::isInstalled() && $this->db_info->use_db_session == 'Y') |
||
| 336 | { |
||
| 337 | $oSessionModel = getModel('session'); |
||
| 338 | $oSessionController = getController('session'); |
||
| 339 | session_set_save_handler( |
||
| 340 | array(&$oSessionController, 'open'), array(&$oSessionController, 'close'), array(&$oSessionModel, 'read'), array(&$oSessionController, 'write'), array(&$oSessionController, 'destroy'), array(&$oSessionController, 'gc') |
||
| 341 | ); |
||
| 342 | } |
||
| 343 | |||
| 344 | if($sess = $_POST[session_name()]) session_id($sess); |
||
| 345 | session_start(); |
||
| 346 | |||
| 347 | // set authentication information in Context and session |
||
| 348 | if(self::isInstalled()) |
||
| 349 | { |
||
| 350 | $oModuleModel = getModel('module'); |
||
| 351 | $oModuleModel->loadModuleExtends(); |
||
| 352 | |||
| 353 | $oMemberModel = getModel('member'); |
||
| 354 | $oMemberController = getController('member'); |
||
| 355 | |||
| 356 | if($oMemberController && $oMemberModel) |
||
| 357 | { |
||
| 358 | // if signed in, validate it. |
||
| 359 | if($oMemberModel->isLogged()) |
||
| 360 | { |
||
| 361 | $oMemberController->setSessionInfo(); |
||
| 362 | } |
||
| 363 | // check auto sign-in |
||
| 364 | elseif($_COOKIE['xeak']) |
||
| 365 | { |
||
| 366 | $oMemberController->doAutologin(); |
||
| 367 | } |
||
| 368 | |||
| 369 | $this->set('is_logged', $oMemberModel->isLogged()); |
||
| 370 | $this->set('logged_info', $oMemberModel->getLoggedInfo()); |
||
| 371 | } |
||
| 372 | } |
||
| 373 | |||
| 374 | // load common language file |
||
| 375 | $this->lang = &$GLOBALS['lang']; |
||
| 376 | $this->loadLang(_XE_PATH_ . 'common/lang/'); |
||
| 377 | |||
| 378 | // check if using rewrite module |
||
| 379 | $this->allow_rewrite = ($this->db_info->use_rewrite == 'Y' ? TRUE : FALSE); |
||
| 380 | |||
| 381 | // set locations for javascript use |
||
| 382 | $url = array(); |
||
| 383 | $current_url = self::getRequestUri(); |
||
| 384 | if($_SERVER['REQUEST_METHOD'] == 'GET') |
||
| 385 | { |
||
| 386 | if($this->get_vars) |
||
| 387 | { |
||
| 388 | $url = array(); |
||
| 389 | View Code Duplication | foreach($this->get_vars as $key => $val) |
|
| 390 | { |
||
| 391 | if(is_array($val) && count($val) > 0) |
||
| 392 | { |
||
| 393 | foreach($val as $k => $v) |
||
| 394 | { |
||
| 395 | $url[] = $key . '[' . $k . ']=' . urlencode($v); |
||
| 396 | } |
||
| 397 | } |
||
| 398 | elseif($val) |
||
| 399 | { |
||
| 400 | $url[] = $key . '=' . urlencode($val); |
||
| 401 | } |
||
| 402 | } |
||
| 403 | |||
| 404 | $current_url = self::getRequestUri(); |
||
| 405 | if($url) $current_url .= '?' . join('&', $url); |
||
| 406 | } |
||
| 407 | else |
||
| 408 | { |
||
| 409 | $current_url = $this->getUrl(); |
||
| 410 | } |
||
| 411 | } |
||
| 412 | else |
||
| 413 | { |
||
| 414 | $current_url = self::getRequestUri(); |
||
| 415 | } |
||
| 416 | |||
| 417 | $this->set('current_url', $current_url); |
||
| 418 | $this->set('request_uri', self::getRequestUri()); |
||
| 419 | |||
| 420 | if(strpos($current_url, 'xn--') !== FALSE) |
||
| 421 | { |
||
| 422 | $this->set('current_url', self::decodeIdna($current_url)); |
||
| 423 | } |
||
| 424 | |||
| 425 | if(strpos(self::getRequestUri(), 'xn--') !== FALSE) |
||
| 426 | { |
||
| 427 | $this->set('request_uri', self::decodeIdna(self::getRequestUri())); |
||
| 428 | } |
||
| 429 | } |
||
| 430 | |||
| 431 | /** |
||
| 432 | * Finalize using resources, such as DB connection |
||
| 433 | * |
||
| 434 | * @return void |
||
| 435 | */ |
||
| 436 | function close() |
||
| 440 | |||
| 441 | /** |
||
| 442 | * Load the database information |
||
| 443 | * |
||
| 444 | * @return void |
||
| 445 | */ |
||
| 446 | function loadDBInfo() |
||
| 447 | { |
||
| 448 | $self = self::getInstance(); |
||
| 449 | |||
| 450 | if(!$self->isInstalled()) |
||
| 451 | { |
||
| 452 | return; |
||
| 453 | } |
||
| 454 | |||
| 455 | $config_file = $self->getConfigFile(); |
||
| 456 | if(is_readable($config_file)) |
||
| 457 | { |
||
| 458 | include($config_file); |
||
| 459 | } |
||
| 460 | |||
| 461 | // If master_db information does not exist, the config file needs to be updated |
||
| 462 | if(!isset($db_info->master_db)) |
||
| 463 | { |
||
| 464 | $db_info->master_db = array(); |
||
| 465 | $db_info->master_db["db_type"] = $db_info->db_type; |
||
| 466 | unset($db_info->db_type); |
||
| 467 | $db_info->master_db["db_port"] = $db_info->db_port; |
||
| 468 | unset($db_info->db_port); |
||
| 469 | $db_info->master_db["db_hostname"] = $db_info->db_hostname; |
||
| 470 | unset($db_info->db_hostname); |
||
| 471 | $db_info->master_db["db_password"] = $db_info->db_password; |
||
| 472 | unset($db_info->db_password); |
||
| 473 | $db_info->master_db["db_database"] = $db_info->db_database; |
||
| 474 | unset($db_info->db_database); |
||
| 475 | $db_info->master_db["db_userid"] = $db_info->db_userid; |
||
| 476 | unset($db_info->db_userid); |
||
| 477 | $db_info->master_db["db_table_prefix"] = $db_info->db_table_prefix; |
||
| 478 | unset($db_info->db_table_prefix); |
||
| 479 | |||
| 480 | if(isset($db_info->master_db["db_table_prefix"]) && substr_compare($db_info->master_db["db_table_prefix"], '_', -1) !== 0) |
||
| 481 | { |
||
| 482 | $db_info->master_db["db_table_prefix"] .= '_'; |
||
| 483 | } |
||
| 484 | |||
| 485 | $db_info->slave_db = array($db_info->master_db); |
||
| 486 | $self->setDBInfo($db_info); |
||
| 487 | |||
| 488 | $oInstallController = getController('install'); |
||
| 489 | $oInstallController->makeConfigFile(); |
||
| 490 | } |
||
| 491 | |||
| 492 | if(!$db_info->use_prepared_statements) |
||
| 493 | { |
||
| 494 | $db_info->use_prepared_statements = 'Y'; |
||
| 495 | } |
||
| 496 | |||
| 497 | if(!$db_info->time_zone) |
||
| 498 | $db_info->time_zone = date('O'); |
||
| 499 | $GLOBALS['_time_zone'] = $db_info->time_zone; |
||
| 500 | |||
| 501 | if($db_info->qmail_compatibility != 'Y') |
||
| 502 | $db_info->qmail_compatibility = 'N'; |
||
| 503 | $GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility; |
||
| 504 | |||
| 505 | if(!$db_info->use_db_session) |
||
| 506 | $db_info->use_db_session = 'N'; |
||
| 507 | if(!$db_info->use_ssl) |
||
| 508 | $db_info->use_ssl = 'none'; |
||
| 509 | $this->set('_use_ssl', $db_info->use_ssl); |
||
| 510 | |||
| 511 | $self->set('_http_port', ($db_info->http_port) ? $db_info->http_port : NULL); |
||
| 512 | $self->set('_https_port', ($db_info->https_port) ? $db_info->https_port : NULL); |
||
| 513 | |||
| 514 | if(!$db_info->sitelock_whitelist) { |
||
| 515 | $db_info->sitelock_whitelist = '127.0.0.1'; |
||
| 516 | } |
||
| 517 | |||
| 518 | if(is_string($db_info->sitelock_whitelist)) { |
||
| 519 | $db_info->sitelock_whitelist = explode(',', $db_info->sitelock_whitelist); |
||
| 520 | } |
||
| 521 | |||
| 522 | $self->setDBInfo($db_info); |
||
| 523 | } |
||
| 524 | |||
| 525 | /** |
||
| 526 | * Get DB's db_type |
||
| 527 | * |
||
| 528 | * @return string DB's db_type |
||
| 529 | */ |
||
| 530 | function getDBType() |
||
| 535 | |||
| 536 | /** |
||
| 537 | * Set DB information |
||
| 538 | * |
||
| 539 | * @param object $db_info DB information |
||
| 540 | * @return void |
||
| 541 | */ |
||
| 542 | function setDBInfo($db_info) |
||
| 547 | |||
| 548 | /** |
||
| 549 | * Get DB information |
||
| 550 | * |
||
| 551 | * @return object DB information |
||
| 552 | */ |
||
| 553 | function getDBInfo() |
||
| 558 | |||
| 559 | /** |
||
| 560 | * Return ssl status |
||
| 561 | * |
||
| 562 | * @return object SSL status (Optional - none|always|optional) |
||
| 563 | */ |
||
| 564 | function getSslStatus() |
||
| 569 | |||
| 570 | /** |
||
| 571 | * Return default URL |
||
| 572 | * |
||
| 573 | * @return string Default URL |
||
| 574 | */ |
||
| 575 | function getDefaultUrl() |
||
| 580 | |||
| 581 | /** |
||
| 582 | * Find supported languages |
||
| 583 | * |
||
| 584 | * @return array Supported languages |
||
| 585 | */ |
||
| 586 | function loadLangSupported() |
||
| 601 | |||
| 602 | /** |
||
| 603 | * Find selected languages to serve in the site |
||
| 604 | * |
||
| 605 | * @return array Selected languages |
||
| 606 | */ |
||
| 607 | function loadLangSelected() |
||
| 639 | |||
| 640 | /** |
||
| 641 | * Single Sign On (SSO) |
||
| 642 | * |
||
| 643 | * @return bool True : Module handling is necessary in the control path of current request , False : Otherwise |
||
| 644 | */ |
||
| 645 | function checkSSO() |
||
| 646 | { |
||
| 647 | // pass if it's not GET request or XE is not yet installed |
||
| 648 | if($this->db_info->use_sso != 'Y' || isCrawler()) |
||
| 649 | { |
||
| 650 | return TRUE; |
||
| 651 | } |
||
| 652 | $checkActList = array('rss' => 1, 'atom' => 1); |
||
| 653 | if(self::getRequestMethod() != 'GET' || !self::isInstalled() || isset($checkActList[self::get('act')])) |
||
| 654 | { |
||
| 655 | return TRUE; |
||
| 656 | } |
||
| 657 | |||
| 658 | // pass if default URL is not set |
||
| 659 | $default_url = trim($this->db_info->default_url); |
||
| 660 | if(!$default_url) |
||
| 661 | { |
||
| 662 | return TRUE; |
||
| 663 | } |
||
| 664 | |||
| 665 | if(substr_compare($default_url, '/', -1) !== 0) |
||
| 666 | { |
||
| 667 | $default_url .= '/'; |
||
| 668 | } |
||
| 669 | |||
| 670 | // for sites recieving SSO valdiation |
||
| 671 | if($default_url == self::getRequestUri()) |
||
| 672 | { |
||
| 673 | if(self::get('url')) |
||
| 674 | { |
||
| 675 | $url = base64_decode(self::get('url')); |
||
| 676 | $url_info = parse_url($url); |
||
| 677 | View Code Duplication | if(!Password::checkSignature($url, self::get('sig'))) |
|
| 678 | { |
||
| 679 | echo self::get('lang')->msg_invalid_request; |
||
| 680 | return false; |
||
| 681 | } |
||
| 682 | |||
| 683 | $url_info['query'].= ($url_info['query'] ? '&' : '') . 'SSOID=' . urlencode(session_id()) . '&sig=' . urlencode(Password::createSignature(session_id())); |
||
| 684 | $redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':' . $url_info['port'] : '', $url_info['path'], $url_info['query']); |
||
| 685 | header('location:' . $redirect_url); |
||
| 686 | |||
| 687 | return FALSE; |
||
| 688 | } |
||
| 689 | // for sites requesting SSO validation |
||
| 690 | } |
||
| 691 | else |
||
| 692 | { |
||
| 693 | // result handling : set session_name() |
||
| 694 | if($session_name = self::get('SSOID')) |
||
| 695 | { |
||
| 696 | View Code Duplication | if(!Password::checkSignature($session_name, self::get('sig'))) |
|
| 697 | { |
||
| 698 | echo self::get('lang')->msg_invalid_request; |
||
| 699 | return false; |
||
| 700 | } |
||
| 701 | |||
| 702 | setcookie(session_name(), $session_name); |
||
| 703 | |||
| 704 | $url = preg_replace('/[\?\&]SSOID=.+$/', '', self::getRequestUrl()); |
||
| 705 | header('location:' . $url); |
||
| 706 | return FALSE; |
||
| 707 | // send SSO request |
||
| 708 | } |
||
| 709 | else if(!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri())) |
||
| 710 | { |
||
| 711 | setcookie('sso', md5(self::getRequestUri()), 0, '/'); |
||
| 712 | $origin_url = self::getRequestUrl(); |
||
| 713 | $origin_sig = Password::createSignature($origin_url); |
||
| 714 | $url = sprintf("%s?url=%s&sig=%s", $default_url, urlencode(base64_encode($origin_url)), urlencode($origin_sig)); |
||
| 715 | header('location:' . $url); |
||
| 716 | return FALSE; |
||
| 717 | } |
||
| 718 | } |
||
| 719 | |||
| 720 | return TRUE; |
||
| 721 | } |
||
| 722 | |||
| 723 | /** |
||
| 724 | * Check if FTP info is registered |
||
| 725 | * |
||
| 726 | * @return bool True: FTP information is registered, False: otherwise |
||
| 727 | */ |
||
| 728 | function isFTPRegisted() |
||
| 732 | |||
| 733 | /** |
||
| 734 | * Get FTP information |
||
| 735 | * |
||
| 736 | * @return object FTP information |
||
| 737 | */ |
||
| 738 | function getFTPInfo() |
||
| 739 | { |
||
| 740 | $self = self::getInstance(); |
||
| 741 | |||
| 742 | if(!$self->isFTPRegisted()) |
||
| 743 | { |
||
| 744 | return null; |
||
| 745 | } |
||
| 746 | |||
| 747 | include($self->getFTPConfigFile()); |
||
| 748 | |||
| 749 | return $ftp_info; |
||
| 750 | } |
||
| 751 | |||
| 752 | /** |
||
| 753 | * Add string to browser title |
||
| 754 | * |
||
| 755 | * @param string $site_title Browser title to be added |
||
| 756 | * @return void |
||
| 757 | */ |
||
| 758 | function addBrowserTitle($site_title) |
||
| 759 | { |
||
| 760 | if(!$site_title) |
||
| 761 | { |
||
| 762 | return; |
||
| 763 | } |
||
| 764 | $self = self::getInstance(); |
||
| 765 | |||
| 766 | if($self->site_title) |
||
| 767 | { |
||
| 768 | $self->site_title .= ' - ' . $site_title; |
||
| 769 | } |
||
| 770 | else |
||
| 771 | { |
||
| 772 | $self->site_title = $site_title; |
||
| 773 | } |
||
| 774 | } |
||
| 775 | |||
| 776 | /** |
||
| 777 | * Set string to browser title |
||
| 778 | * |
||
| 779 | * @param string $site_title Browser title to be set |
||
| 780 | * @return void |
||
| 781 | */ |
||
| 782 | function setBrowserTitle($site_title) |
||
| 783 | { |
||
| 784 | if(!$site_title) |
||
| 785 | { |
||
| 786 | return; |
||
| 787 | } |
||
| 788 | $self = self::getInstance(); |
||
| 789 | $self->site_title = $site_title; |
||
| 790 | } |
||
| 791 | |||
| 792 | /** |
||
| 793 | * Get browser title |
||
| 794 | * |
||
| 795 | * @return string Browser title(htmlspecialchars applied) |
||
| 796 | */ |
||
| 797 | function getBrowserTitle() |
||
| 798 | { |
||
| 799 | $self = self::getInstance(); |
||
| 800 | |||
| 801 | $oModuleController = getController('module'); |
||
| 802 | $oModuleController->replaceDefinedLangCode($self->site_title); |
||
| 803 | |||
| 804 | return htmlspecialchars($self->site_title, ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE); |
||
| 805 | } |
||
| 806 | |||
| 807 | /** |
||
| 808 | * Return layout's title |
||
| 809 | * @return string layout's title |
||
| 810 | */ |
||
| 811 | public function getSiteTitle() |
||
| 822 | |||
| 823 | /** |
||
| 824 | * Get browser title |
||
| 825 | * @deprecated |
||
| 826 | */ |
||
| 827 | function _getBrowserTitle() |
||
| 831 | |||
| 832 | /** |
||
| 833 | * Load language file according to language type |
||
| 834 | * |
||
| 835 | * @param string $path Path of the language file |
||
| 836 | * @return void |
||
| 837 | */ |
||
| 838 | function loadLang($path) |
||
| 839 | { |
||
| 840 | global $lang; |
||
| 841 | |||
| 842 | $self = self::getInstance(); |
||
| 843 | if(!$self->lang_type) |
||
| 844 | { |
||
| 845 | return; |
||
| 846 | } |
||
| 847 | if(!is_object($lang)) |
||
| 848 | { |
||
| 849 | $lang = new stdClass; |
||
| 850 | } |
||
| 851 | |||
| 852 | if(!($filename = $self->_loadXmlLang($path))) |
||
| 853 | { |
||
| 854 | $filename = $self->_loadPhpLang($path); |
||
| 855 | } |
||
| 856 | |||
| 857 | if(!is_array($self->loaded_lang_files)) |
||
| 858 | { |
||
| 859 | $self->loaded_lang_files = array(); |
||
| 860 | } |
||
| 861 | if(in_array($filename, $self->loaded_lang_files)) |
||
| 862 | { |
||
| 863 | return; |
||
| 864 | } |
||
| 865 | |||
| 866 | if($filename && is_readable($filename)) |
||
| 867 | { |
||
| 868 | $self->loaded_lang_files[] = $filename; |
||
| 869 | include($filename); |
||
| 870 | } |
||
| 871 | else |
||
| 872 | { |
||
| 873 | $self->_evalxmlLang($path); |
||
| 874 | } |
||
| 875 | } |
||
| 876 | |||
| 877 | /** |
||
| 878 | * Evaluation of xml language file |
||
| 879 | * |
||
| 880 | * @param string Path of the language file |
||
| 881 | * @return void |
||
| 882 | */ |
||
| 883 | function _evalxmlLang($path) |
||
| 910 | |||
| 911 | /** |
||
| 912 | * Load language file of xml type |
||
| 913 | * |
||
| 914 | * @param string $path Path of the language file |
||
| 915 | * @return string file name |
||
| 916 | */ |
||
| 917 | function _loadXmlLang($path) |
||
| 924 | |||
| 925 | /** |
||
| 926 | * Load language file of php type |
||
| 927 | * |
||
| 928 | * @param string $path Path of the language file |
||
| 929 | * @return string file name |
||
| 930 | */ |
||
| 931 | function _loadPhpLang($path) |
||
| 954 | |||
| 955 | /** |
||
| 956 | * Set lang_type |
||
| 957 | * |
||
| 958 | * @param string $lang_type Language type. |
||
| 959 | * @return void |
||
| 960 | */ |
||
| 961 | function setLangType($lang_type = 'ko') |
||
| 962 | { |
||
| 963 | $self = self::getInstance(); |
||
| 964 | |||
| 965 | $self->lang_type = $lang_type; |
||
| 966 | $self->set('lang_type', $lang_type); |
||
| 967 | |||
| 968 | $_SESSION['lang_type'] = $lang_type; |
||
| 969 | } |
||
| 970 | |||
| 971 | /** |
||
| 972 | * Get lang_type |
||
| 973 | * |
||
| 974 | * @return string Language type |
||
| 975 | */ |
||
| 976 | function getLangType() |
||
| 981 | |||
| 982 | /** |
||
| 983 | * Return string accoring to the inputed code |
||
| 984 | * |
||
| 985 | * @param string $code Language variable name |
||
| 986 | * @return string If string for the code exists returns it, otherwise returns original code |
||
| 987 | */ |
||
| 988 | function getLang($code) |
||
| 1000 | |||
| 1001 | /** |
||
| 1002 | * Set data to lang variable |
||
| 1003 | * |
||
| 1004 | * @param string $code Language variable name |
||
| 1005 | * @param string $val `$code`s value |
||
| 1006 | * @return void |
||
| 1007 | */ |
||
| 1008 | function setLang($code, $val) |
||
| 1016 | |||
| 1017 | /** |
||
| 1018 | * Convert strings of variables in $source_object into UTF-8 |
||
| 1019 | * |
||
| 1020 | * @param object $source_obj Conatins strings to convert |
||
| 1021 | * @return object converted object |
||
| 1022 | */ |
||
| 1023 | function convertEncoding($source_obj) |
||
| 1054 | |||
| 1055 | /** |
||
| 1056 | * Check flag |
||
| 1057 | * |
||
| 1058 | * @param mixed $val |
||
| 1059 | * @param string $key |
||
| 1060 | * @param mixed $charset charset |
||
| 1061 | * @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5 |
||
| 1062 | * @return void |
||
| 1063 | */ |
||
| 1064 | function checkConvertFlag(&$val, $key = null, $charset = null) |
||
| 1081 | |||
| 1082 | /** |
||
| 1083 | * Convert array type variables into UTF-8 |
||
| 1084 | * |
||
| 1085 | * @param mixed $val |
||
| 1086 | * @param string $key |
||
| 1087 | * @param string $charset character set |
||
| 1088 | * @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5 |
||
| 1089 | * @return object converted object |
||
| 1090 | */ |
||
| 1091 | function doConvertEncoding(&$val, $key = null, $charset) |
||
| 1099 | |||
| 1100 | /** |
||
| 1101 | * Convert strings into UTF-8 |
||
| 1102 | * |
||
| 1103 | * @param string $str String to convert |
||
| 1104 | * @return string converted string |
||
| 1105 | */ |
||
| 1106 | function convertEncodingStr($str) |
||
| 1114 | |||
| 1115 | function decodeIdna($domain) |
||
| 1126 | |||
| 1127 | /** |
||
| 1128 | * Force to set response method |
||
| 1129 | * |
||
| 1130 | * @param string $method Response method. [HTML|XMLRPC|JSON] |
||
| 1131 | * @return void |
||
| 1132 | */ |
||
| 1133 | function setResponseMethod($method = 'HTML') |
||
| 1134 | { |
||
| 1135 | $self = self::getInstance(); |
||
| 1136 | |||
| 1137 | $methods = array('HTML' => 1, 'XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1); |
||
| 1138 | $self->response_method = isset($methods[$method]) ? $method : 'HTML'; |
||
| 1139 | } |
||
| 1140 | |||
| 1141 | /** |
||
| 1142 | * Get reponse method |
||
| 1143 | * |
||
| 1144 | * @return string Response method. If it's not set, returns request method. |
||
| 1145 | */ |
||
| 1146 | function getResponseMethod() |
||
| 1147 | { |
||
| 1148 | $self = self::getInstance(); |
||
| 1149 | |||
| 1150 | if($self->response_method) |
||
| 1151 | { |
||
| 1152 | return $self->response_method; |
||
| 1153 | } |
||
| 1154 | |||
| 1155 | $method = $self->getRequestMethod(); |
||
| 1156 | $methods = array('HTML' => 1, 'XMLRPC' => 1, 'JSON' => 1, 'JS_CALLBACK' => 1); |
||
| 1157 | |||
| 1158 | return isset($methods[$method]) ? $method : 'HTML'; |
||
| 1159 | } |
||
| 1160 | |||
| 1161 | /** |
||
| 1162 | * Determine request method |
||
| 1163 | * |
||
| 1164 | * @param string $type Request method. (Optional - GET|POST|XMLRPC|JSON) |
||
| 1165 | * @return void |
||
| 1166 | */ |
||
| 1167 | function setRequestMethod($type = '') |
||
| 1168 | { |
||
| 1169 | $self = self::getInstance(); |
||
| 1170 | |||
| 1171 | $self->js_callback_func = $self->getJSCallbackFunc(); |
||
| 1172 | |||
| 1173 | ($type && $self->request_method = $type) or |
||
| 1174 | ((strpos($_SERVER['CONTENT_TYPE'], 'json') || strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json')) && $self->request_method = 'JSON') or |
||
| 1175 | ($GLOBALS['HTTP_RAW_POST_DATA'] && $self->request_method = 'XMLRPC') or |
||
| 1176 | ($self->js_callback_func && $self->request_method = 'JS_CALLBACK') or |
||
| 1177 | ($self->request_method = $_SERVER['REQUEST_METHOD']); |
||
| 1178 | } |
||
| 1179 | |||
| 1180 | /** |
||
| 1181 | * handle global arguments |
||
| 1182 | * |
||
| 1183 | * @return void |
||
| 1184 | */ |
||
| 1185 | function _checkGlobalVars() |
||
| 1195 | |||
| 1196 | /** |
||
| 1197 | * handle request arguments for GET/POST |
||
| 1198 | * |
||
| 1199 | * @return void |
||
| 1200 | */ |
||
| 1201 | function _setRequestArgument() |
||
| 1243 | |||
| 1244 | function _recursiveCheckVar($val) |
||
| 1265 | |||
| 1266 | /** |
||
| 1267 | * Handle request arguments for JSON |
||
| 1268 | * |
||
| 1269 | * @return void |
||
| 1270 | */ |
||
| 1271 | function _setJSONRequestArgument() |
||
| 1286 | |||
| 1287 | /** |
||
| 1288 | * Handle request arguments for XML RPC |
||
| 1289 | * |
||
| 1290 | * @return void |
||
| 1291 | */ |
||
| 1292 | function _setXmlRpcArgument() |
||
| 1322 | |||
| 1323 | /** |
||
| 1324 | * Filter xml variables |
||
| 1325 | * |
||
| 1326 | * @param string $key Variable key |
||
| 1327 | * @param object $val Variable value |
||
| 1328 | * @return mixed filtered value |
||
| 1329 | */ |
||
| 1330 | function _filterXmlVars($key, $val) |
||
| 1373 | |||
| 1374 | /** |
||
| 1375 | * Filter request variable |
||
| 1376 | * |
||
| 1377 | * @see Cast variables, such as _srl, page, and cpage, into interger |
||
| 1378 | * @param string $key Variable key |
||
| 1379 | * @param string $val Variable value |
||
| 1380 | * @param string $do_stripslashes Whether to strip slashes |
||
| 1381 | * @return mixed filtered value. Type are string or array |
||
| 1382 | */ |
||
| 1383 | function _filterRequestVar($key, $val, $do_stripslashes = 1) |
||
| 1384 | { |
||
| 1385 | if(!($isArray = is_array($val))) |
||
| 1432 | |||
| 1433 | /** |
||
| 1434 | * Check if there exists uploaded file |
||
| 1435 | * |
||
| 1436 | * @return bool True: exists, False: otherwise |
||
| 1437 | */ |
||
| 1438 | function isUploaded() |
||
| 1443 | |||
| 1444 | /** |
||
| 1445 | * Handle uploaded file |
||
| 1446 | * |
||
| 1447 | * @return void |
||
| 1448 | */ |
||
| 1449 | function _setUploadedArgument() |
||
| 1487 | |||
| 1488 | /** |
||
| 1489 | * Return request method |
||
| 1490 | * @return string Request method type. (Optional - GET|POST|XMLRPC|JSON) |
||
| 1491 | */ |
||
| 1492 | function getRequestMethod() |
||
| 1497 | |||
| 1498 | /** |
||
| 1499 | * Return request URL |
||
| 1500 | * @return string request URL |
||
| 1501 | */ |
||
| 1502 | function getRequestUrl() |
||
| 1519 | |||
| 1520 | /** |
||
| 1521 | * Return js callback func. |
||
| 1522 | * @return string callback func. |
||
| 1523 | */ |
||
| 1524 | function getJSCallbackFunc() |
||
| 1538 | |||
| 1539 | /** |
||
| 1540 | * Make URL with args_list upon request URL |
||
| 1541 | * |
||
| 1542 | * @param int $num_args Arguments nums |
||
| 1543 | * @param array $args_list Argument list for set url |
||
| 1544 | * @param string $domain Domain |
||
| 1545 | * @param bool $encode If TRUE, use url encode. |
||
| 1546 | * @param bool $autoEncode If TRUE, url encode automatically, detailed. Use this option, $encode value should be TRUE |
||
| 1547 | * @return string URL |
||
| 1548 | */ |
||
| 1549 | function getUrl($num_args = 0, $args_list = array(), $domain = null, $encode = TRUE, $autoEncode = FALSE) |
||
| 1783 | |||
| 1784 | /** |
||
| 1785 | * Return after removing an argument on the requested URL |
||
| 1786 | * |
||
| 1787 | * @param string $ssl_mode SSL mode |
||
| 1788 | * @param string $domain Domain |
||
| 1789 | * @retrun string converted URL |
||
| 1790 | */ |
||
| 1791 | function getRequestUri($ssl_mode = FOLLOW_REQUEST_SSL, $domain = null) |
||
| 1881 | |||
| 1882 | /** |
||
| 1883 | * Set a context value with a key |
||
| 1884 | * |
||
| 1885 | * @param string $key Key |
||
| 1886 | * @param string $val Value |
||
| 1887 | * @param mixed $set_to_get_vars If not FALSE, Set to get vars. |
||
| 1888 | * @return void |
||
| 1889 | */ |
||
| 1890 | function set($key, $val, $set_to_get_vars = 0) |
||
| 1908 | |||
| 1909 | /** |
||
| 1910 | * Return key's value |
||
| 1911 | * |
||
| 1912 | * @param string $key Key |
||
| 1913 | * @return string Key |
||
| 1914 | */ |
||
| 1915 | function get($key) |
||
| 1925 | |||
| 1926 | /** |
||
| 1927 | * Get one more vars in object vars with given arguments(key1, key2, key3,...) |
||
| 1928 | * |
||
| 1929 | * @return object |
||
| 1930 | */ |
||
| 1931 | function gets() |
||
| 1948 | |||
| 1949 | /** |
||
| 1950 | * Return all data |
||
| 1951 | * |
||
| 1952 | * @return object All data |
||
| 1953 | */ |
||
| 1954 | function getAll() |
||
| 1959 | |||
| 1960 | /** |
||
| 1961 | * Return values from the GET/POST/XMLRPC |
||
| 1962 | * |
||
| 1963 | * @return Object Request variables. |
||
| 1964 | */ |
||
| 1965 | function getRequestVars() |
||
| 1974 | |||
| 1975 | /** |
||
| 1976 | * Register if an action is to be encrypted by SSL. Those actions are sent to https in common/js/xml_handler.js |
||
| 1977 | * |
||
| 1978 | * @param string $action act name |
||
| 1979 | * @return void |
||
| 1980 | */ |
||
| 1981 | function addSSLAction($action) |
||
| 1998 | |||
| 1999 | /** |
||
| 2000 | * Register if actions are to be encrypted by SSL. Those actions are sent to https in common/js/xml_handler.js |
||
| 2001 | * |
||
| 2002 | * @param string $action act name |
||
| 2003 | * @return void |
||
| 2004 | */ |
||
| 2005 | function addSSLActions($action_array) |
||
| 2026 | |||
| 2027 | /** |
||
| 2028 | * Delete if action is registerd to be encrypted by SSL. |
||
| 2029 | * |
||
| 2030 | * @param string $action act name |
||
| 2031 | * @return void |
||
| 2032 | */ |
||
| 2033 | function subtractSSLAction($action) |
||
| 2045 | |||
| 2046 | /** |
||
| 2047 | * Get SSL Action |
||
| 2048 | * |
||
| 2049 | * @return string acts in array |
||
| 2050 | */ |
||
| 2051 | function getSSLActions() |
||
| 2059 | |||
| 2060 | /** |
||
| 2061 | * Check SSL action are existed |
||
| 2062 | * |
||
| 2063 | * @param string $action act name |
||
| 2064 | * @return bool If SSL exists, return TRUE. |
||
| 2065 | */ |
||
| 2066 | function isExistsSSLAction($action) |
||
| 2071 | |||
| 2072 | /** |
||
| 2073 | * Normalize file path |
||
| 2074 | * |
||
| 2075 | * @deprecated |
||
| 2076 | * @param string $file file path |
||
| 2077 | * @return string normalized file path |
||
| 2078 | */ |
||
| 2079 | function normalizeFilePath($file) |
||
| 2093 | |||
| 2094 | /** |
||
| 2095 | * Get abstract file url |
||
| 2096 | * |
||
| 2097 | * @deprecated |
||
| 2098 | * @param string $file file path |
||
| 2099 | * @return string Converted file path |
||
| 2100 | */ |
||
| 2101 | function getAbsFileUrl($file) |
||
| 2116 | |||
| 2117 | /** |
||
| 2118 | * Load front end file |
||
| 2119 | * |
||
| 2120 | * @param array $args array |
||
| 2121 | * case js : |
||
| 2122 | * $args[0]: file name, |
||
| 2123 | * $args[1]: type (head | body), |
||
| 2124 | * $args[2]: target IE, |
||
| 2125 | * $args[3]: index |
||
| 2126 | * case css : |
||
| 2127 | * $args[0]: file name, |
||
| 2128 | * $args[1]: media, |
||
| 2129 | * $args[2]: target IE, |
||
| 2130 | * $args[3]: index |
||
| 2131 | * |
||
| 2132 | */ |
||
| 2133 | function loadFile($args) |
||
| 2139 | |||
| 2140 | /** |
||
| 2141 | * Unload front end file |
||
| 2142 | * |
||
| 2143 | * @param string $file File name with path |
||
| 2144 | * @param string $targetIe Target IE |
||
| 2145 | * @param string $media Media query |
||
| 2146 | * @return void |
||
| 2147 | */ |
||
| 2148 | function unloadFile($file, $targetIe = '', $media = 'all') |
||
| 2153 | |||
| 2154 | /** |
||
| 2155 | * Unload front end file all |
||
| 2156 | * |
||
| 2157 | * @param string $type Unload target (optional - all|css|js) |
||
| 2158 | * @return void |
||
| 2159 | */ |
||
| 2160 | function unloadAllFiles($type = 'all') |
||
| 2165 | |||
| 2166 | /** |
||
| 2167 | * Add the js file |
||
| 2168 | * |
||
| 2169 | * @deprecated |
||
| 2170 | * @param string $file File name with path |
||
| 2171 | * @param string $optimized optimized (That seems to not use) |
||
| 2172 | * @param string $targetie target IE |
||
| 2173 | * @param string $index index |
||
| 2174 | * @param string $type Added position. (head:<head>..</head>, body:<body>..</body>) |
||
| 2175 | * @param bool $isRuleset Use ruleset |
||
| 2176 | * @param string $autoPath If path not readed, set the path automatically. |
||
| 2177 | * @return void |
||
| 2178 | */ |
||
| 2179 | function addJsFile($file, $optimized = FALSE, $targetie = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null) |
||
| 2199 | |||
| 2200 | /** |
||
| 2201 | * Remove the js file |
||
| 2202 | * |
||
| 2203 | * @deprecated |
||
| 2204 | * @param string $file File name with path |
||
| 2205 | * @param string $optimized optimized (That seems to not use) |
||
| 2206 | * @param string $targetie target IE |
||
| 2207 | * @return void |
||
| 2208 | */ |
||
| 2209 | function unloadJsFile($file, $optimized = FALSE, $targetie = '') |
||
| 2214 | |||
| 2215 | /** |
||
| 2216 | * Unload all javascript files |
||
| 2217 | * |
||
| 2218 | * @return void |
||
| 2219 | */ |
||
| 2220 | function unloadAllJsFiles() |
||
| 2225 | |||
| 2226 | /** |
||
| 2227 | * Add javascript filter |
||
| 2228 | * |
||
| 2229 | * @param string $path File path |
||
| 2230 | * @param string $filename File name |
||
| 2231 | * @return void |
||
| 2232 | */ |
||
| 2233 | function addJsFilter($path, $filename) |
||
| 2238 | |||
| 2239 | /** |
||
| 2240 | * Same as array_unique but works only for file subscript |
||
| 2241 | * |
||
| 2242 | * @deprecated |
||
| 2243 | * @param array $files File list |
||
| 2244 | * @return array File list |
||
| 2245 | */ |
||
| 2246 | function _getUniqueFileList($files) |
||
| 2262 | |||
| 2263 | /** |
||
| 2264 | * Returns the list of javascripts that matches the given type. |
||
| 2265 | * |
||
| 2266 | * @param string $type Added position. (head:<head>..</head>, body:<body>..</body>) |
||
| 2267 | * @return array Returns javascript file list. Array contains file, targetie. |
||
| 2268 | */ |
||
| 2269 | function getJsFile($type = 'head') |
||
| 2274 | |||
| 2275 | /** |
||
| 2276 | * Add CSS file |
||
| 2277 | * |
||
| 2278 | * @deprecated |
||
| 2279 | * @param string $file File name with path |
||
| 2280 | * @param string $optimized optimized (That seems to not use) |
||
| 2281 | * @param string $media Media query |
||
| 2282 | * @param string $targetie target IE |
||
| 2283 | * @param string $index index |
||
| 2284 | * @return void |
||
| 2285 | * |
||
| 2286 | */ |
||
| 2287 | function addCSSFile($file, $optimized = FALSE, $media = 'all', $targetie = '', $index = 0) |
||
| 2292 | |||
| 2293 | /** |
||
| 2294 | * Remove css file |
||
| 2295 | * |
||
| 2296 | * @deprecated |
||
| 2297 | * @param string $file File name with path |
||
| 2298 | * @param string $optimized optimized (That seems to not use) |
||
| 2299 | * @param string $media Media query |
||
| 2300 | * @param string $targetie target IE |
||
| 2301 | * @return void |
||
| 2302 | */ |
||
| 2303 | function unloadCSSFile($file, $optimized = FALSE, $media = 'all', $targetie = '') |
||
| 2308 | |||
| 2309 | /** |
||
| 2310 | * Unload all css files |
||
| 2311 | * |
||
| 2312 | * @return void |
||
| 2313 | */ |
||
| 2314 | function unloadAllCSSFiles() |
||
| 2319 | |||
| 2320 | /** |
||
| 2321 | * Return a list of css files |
||
| 2322 | * |
||
| 2323 | * @return array Returns css file list. Array contains file, media, targetie. |
||
| 2324 | */ |
||
| 2325 | function getCSSFile() |
||
| 2330 | |||
| 2331 | /** |
||
| 2332 | * Returns javascript plugin file info |
||
| 2333 | * @param string $pluginName |
||
| 2334 | * @return stdClass |
||
| 2335 | */ |
||
| 2336 | function getJavascriptPluginInfo($pluginName) |
||
| 2385 | /** |
||
| 2386 | * Load javascript plugin |
||
| 2387 | * |
||
| 2388 | * @param string $plugin_name plugin name |
||
| 2389 | * @return void |
||
| 2390 | */ |
||
| 2391 | function loadJavascriptPlugin($plugin_name) |
||
| 2442 | |||
| 2443 | /** |
||
| 2444 | * Add html code before </head> |
||
| 2445 | * |
||
| 2446 | * @param string $header add html code before </head>. |
||
| 2447 | * @return void |
||
| 2448 | */ |
||
| 2449 | function addHtmlHeader($header) |
||
| 2454 | |||
| 2455 | function clearHtmlHeader() |
||
| 2460 | |||
| 2461 | /** |
||
| 2462 | * Returns added html code by addHtmlHeader() |
||
| 2463 | * |
||
| 2464 | * @return string Added html code before </head> |
||
| 2465 | */ |
||
| 2466 | function getHtmlHeader() |
||
| 2471 | |||
| 2472 | /** |
||
| 2473 | * Add css class to Html Body |
||
| 2474 | * |
||
| 2475 | * @param string $class_name class name |
||
| 2476 | */ |
||
| 2477 | function addBodyClass($class_name) |
||
| 2482 | |||
| 2483 | /** |
||
| 2484 | * Return css class to Html Body |
||
| 2485 | * |
||
| 2486 | * @return string Return class to html body |
||
| 2487 | */ |
||
| 2488 | function getBodyClass() |
||
| 2495 | |||
| 2496 | /** |
||
| 2497 | * Add html code after <body> |
||
| 2498 | * |
||
| 2499 | * @param string $header Add html code after <body> |
||
| 2500 | */ |
||
| 2501 | function addBodyHeader($header) |
||
| 2506 | |||
| 2507 | /** |
||
| 2508 | * Returns added html code by addBodyHeader() |
||
| 2509 | * |
||
| 2510 | * @return string Added html code after <body> |
||
| 2511 | */ |
||
| 2512 | function getBodyHeader() |
||
| 2517 | |||
| 2518 | /** |
||
| 2519 | * Add html code before </body> |
||
| 2520 | * |
||
| 2521 | * @param string $footer Add html code before </body> |
||
| 2522 | */ |
||
| 2523 | function addHtmlFooter($footer) |
||
| 2528 | |||
| 2529 | /** |
||
| 2530 | * Returns added html code by addHtmlHeader() |
||
| 2531 | * |
||
| 2532 | * @return string Added html code before </body> |
||
| 2533 | */ |
||
| 2534 | function getHtmlFooter() |
||
| 2539 | |||
| 2540 | /** |
||
| 2541 | * Get config file |
||
| 2542 | * |
||
| 2543 | * @retrun string The path of the config file that contains database settings |
||
| 2544 | */ |
||
| 2545 | function getConfigFile() |
||
| 2549 | |||
| 2550 | /** |
||
| 2551 | * Get FTP config file |
||
| 2552 | * |
||
| 2553 | * @return string The path of the config file that contains FTP settings |
||
| 2554 | */ |
||
| 2555 | function getFTPConfigFile() |
||
| 2559 | |||
| 2560 | /** |
||
| 2561 | * Checks whether XE is installed |
||
| 2562 | * |
||
| 2563 | * @return bool True if the config file exists, otherwise FALSE. |
||
| 2564 | */ |
||
| 2565 | function isInstalled() |
||
| 2569 | |||
| 2570 | /** |
||
| 2571 | * Transforms codes about widget or other features into the actual code, deprecatred |
||
| 2572 | * |
||
| 2573 | * @param string Transforms codes |
||
| 2574 | * @return string Transforms codes |
||
| 2575 | */ |
||
| 2576 | function transContent($content) |
||
| 2580 | |||
| 2581 | /** |
||
| 2582 | * Check whether it is allowed to use rewrite mod |
||
| 2583 | * |
||
| 2584 | * @return bool True if it is allowed to use rewrite mod, otherwise FALSE |
||
| 2585 | */ |
||
| 2586 | function isAllowRewrite() |
||
| 2591 | |||
| 2592 | /** |
||
| 2593 | * Converts a local path into an URL |
||
| 2594 | * |
||
| 2595 | * @param string $path URL path |
||
| 2596 | * @return string Converted path |
||
| 2597 | */ |
||
| 2598 | function pathToUrl($path) |
||
| 2648 | |||
| 2649 | /** |
||
| 2650 | * Get meta tag |
||
| 2651 | * @return array The list of meta tags |
||
| 2652 | */ |
||
| 2653 | function getMetaTag() |
||
| 2671 | |||
| 2672 | /** |
||
| 2673 | * Add the meta tag |
||
| 2674 | * |
||
| 2675 | * @param string $name name of meta tag |
||
| 2676 | * @param string $content content of meta tag |
||
| 2677 | * @param mixed $is_http_equiv value of http_equiv |
||
| 2678 | * @return void |
||
| 2679 | */ |
||
| 2680 | function addMetaTag($name, $content, $is_http_equiv = FALSE) |
||
| 2685 | |||
| 2686 | } |
||
| 2687 | /* End of file Context.class.php */ |
||
| 2689 |