00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 function T_($message) {
00051 return defined('_ALIRO_LANGUAGE') ? PHPGettext::getInstance()->gettext($message) : $message;
00052 }
00053 function Tn_($msg1, $msg2, $count) {
00054 return defined('_ALIRO_LANGUAGE') ? PHPGettext::getInstance()->ngettext($msg1, $msg2, $count) : $msg1;
00055 }
00056 function Td_($domain, $message) {
00057 return defined('_ALIRO_LANGUAGE') ? PHPGettext::getInstance()->dgettext($domain, $message) : $message;
00058 }
00059 function Tdn_($domain, $msg1, $msg2, $count) {
00060 return defined('_ALIRO_LANGUAGE') ? PHPGettext::getInstance()->dngettext($domain, $msg1, $msg2, $count) : $msg1;
00061 }
00062
00063
00064 class aliroRequest {
00065 private static $instance = null;
00066
00067 public static function getInstance () {
00068 if (null == self::$instance) {
00069 $info = criticalInfo::getInstance();
00070 if ($info->isAdmin) self::$instance = aliroAdminRequest::getInstance();
00071 else self::$instance = aliroUserRequest::getInstance();
00072 }
00073 return self::$instance;
00074 }
00075
00076 public static function mosMakeHtmlSafe( &$mixed, $quote_style=ENT_QUOTES, $exclude_keys='' ) {
00077 if (is_object($mixed)) foreach (get_object_vars( $mixed ) as $k => $v) {
00078 if (is_array($v) OR is_object($v) OR $v == NULL OR substr($k, 1, 1) == '_' OR (is_string($exclude_keys) AND $k == $exclude_keys) OR (is_array( $exclude_keys ) AND in_array( $k, $exclude_keys )));
00079 else $mixed->$k = htmlspecialchars($v, $quote_style);
00080 }
00081 }
00082
00083 public static function trace ($error=true) {
00084 static $counter = 0;
00085 $html = '';
00086 foreach(debug_backtrace() as $back) {
00087 if (isset($back['file']) AND $back['file']) {
00088 $html .= '<br />'.$back['file'].':'.$back['line'];
00089 }
00090 }
00091 if ($error) $counter++;
00092 if (1000 < $counter) {
00093 echo $html;
00094 die (T_('Program killed - Probably looping'));
00095 }
00096 return $html;
00097 }
00098
00099 }
00100
00101 class mosRequest extends aliroRequest {
00102
00103 }