21 const REGEX_EMAIL =
'^[a-zA-Z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$';
23 const REGEX_EMAIL_OPTIONAL =
'^(|[a-zA-Z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)$';
25 const REGEX_EMAIL_ESCAPED =
'^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$';
49 private static $includedHtml = array();
58 return (
bool) preg_match(
'/'.self::REGEX_EMAIL_ESCAPED.
'/msi', $email);
69 public static function escape($string, $esc_type =
'html', $char_set =
'UTF-8') {
72 return htmlspecialchars($string, ENT_QUOTES, $char_set);
75 return htmlentities($string, ENT_QUOTES, $char_set);
78 return rawurlencode($string);
81 return str_replace(
'%2F',
'/',rawurlencode($string));
85 return preg_replace(
"%(?<!\\\\)'%",
"\\'", $string);
90 for ($x=0; $x < strlen($string); $x++) {
91 $return .=
'%' . bin2hex($string[$x]);
97 for ($x=0; $x < strlen($string); $x++) {
98 $return .=
'&#x' . bin2hex($string[$x]) .
';';
104 for ($x=0; $x < strlen($string); $x++) {
105 $return .=
'&#' . ord($string[$x]) .
';';
111 return strtr($string, array(
'\\'=>
'\\\\',
"'"=>
"\\'",
'"'=>
'\\"',
"\r"=>
'\\r',
"\n"=>
'\\n',
'</'=>
'<\/'));
115 return str_replace(array(
'@',
'.'),array(
' [AT] ',
' [DOT] '), $string);
120 for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
121 $_ord = ord(substr($string, $_i, 1));
124 $_res .=
'&#' . $_ord .
';';
127 $_res .= substr($string, $_i, 1);
145 $cache_dir = dir($GLOBALS[
'egotec_conf'][
'cache_dir']);
147 while ($dir = $cache_dir->read()) {
150 && is_dir($cache_dir->path.$dir)
151 && (!$site_name || $dir == $site_name)
153 foreach (glob($cache_dir->path.$dir.
'/types*') as $file) {
156 @unlink($cache_dir->path.$dir.
'/classes.cache');
170 Ego_System::mkdir($GLOBALS[
'egotec_conf'][
'cache_dir'].
'compiled'.DIRECTORY_SEPARATOR.
'_admin');
172 switch ($GLOBALS[
'egotec_conf'][
'site_cache_type'])
175 require_once(
'base/Ego_Cache_apcu.php');
176 $cache =
new Ego_Cache_apcu($path);
181 require_once(
'base/Ego_Cache_apc.php');
182 $cache =
new Ego_Cache_apc($path);
187 require_once(
'base/Ego_Cache_shm.php');
188 $cache =
new Ego_Cache_shm($path);
192 require_once(
'base/Ego_Cache_file.php');
193 $cache =
new Ego_Cache_file($path);
198 $cache = self::getCache();
215 switch ($GLOBALS[
'egotec_conf'][
'site_cache_type'])
218 require_once(
'base/Ego_Cache_apc.php');
219 $cache =
new Ego_Cache_apc($path);
223 require_once(
'base/Ego_Cache_apcu.php');
224 $cache =
new Ego_Cache_apcu($path);
228 require_once(
'base/Ego_Cache_shm.php');
229 $cache =
new Ego_Cache_shm($path);
233 require_once(
'base/Ego_Cache_file.php');
234 $cache =
new Ego_Cache_file($path);
245 require_once(
'base/Site.php');
246 $dir = dir($GLOBALS[
'egotec_conf'][
'site_dir']);
247 while ($file = $dir->read())
249 if ($file[
'0']!=
'.' && is_dir($dir->path.$file))
252 $site =
new Site($file);
253 foreach ($site->getLanguages() as $lang)
255 $site->setLanguage($lang);
258 }
catch (Exception $e)
278 $pos = strrpos($string,
'/');
281 $pos = strrpos($string, DIRECTORY_SEPARATOR);
286 $string =
' '.$string;
288 $pos = ((int)$pos)+1;
289 $string = substr($string, 0, $pos).
' '.substr($string, $pos);
293 foreach($result as $key => $value)
295 $result[$key] = ltrim($value);
309 return $pathinfo[
'basename'];
323 $substitute =
"\xEF\xBF\xBD";
329 || $GLOBALS[
'egotec_conf'][
'noutf8filter'] == 1
338 |[\xC2-\xDF][\x80-\xBF] 339 | \xE0[\xA0-\xBF][\x80-\xBF] 340 | \xED[\x80-\x9F][\x80-\xBF] 341 |[\xF1-\xF3][\x80-\xBF]{3} 342 | \xF4[\x80-\x8F][\x80-\xBF]{2}) 345 |[\xF1-\xF3][\x80-\xBF]{1,2} 346 | \xF4[\x80-\x8F][\x80-\xBF]?) 352 |[\xC2-\xDF][\x80-\xBF] 353 | \xE0[\xA0-\xBF][\x80-\xBF] 354 |[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} 355 | \xED[\x80-\x9F][\x80-\xBF] 356 | \xF0[\x90-\xBF][\x80-\xBF]{2} 357 |[\xF1-\xF3][\x80-\xBF]{3} 358 | \xF4[\x80-\x8F][\x80-\xBF]{2}) 360 |[\xE1-\xEC\xEE\xEF][\x80-\xBF] 362 | \xF0[\x90-\xBF][\x80-\xBF]? 363 |[\xF1-\xF3][\x80-\xBF]{1,2} 364 | \xF4[\x80-\x8F][\x80-\xBF]?) 372 $s2 = mb_substr($s, 0, 1000);
373 preg_replace_callback($utf8_pattern,
function($matches) use ($substitute, &$utf8_string) {
374 if (isset($matches[2]) || isset($matches[3])) {
375 $utf8_string .= $substitute;
377 $utf8_string .= $matches[1];
380 $s = mb_substr($s, 1000);
382 return str_replace(
"\xe2\x80".chr(168),
" ", $utf8_string);
395 foreach($data as $key => $value)
397 if(is_array($value) || is_string($value))
399 $data[$key] = is_array($value) ? self::filterData($value) : self::filterNonUtf8($value);
407 return (is_string($data) ? self::filterNonUtf8($data) : $data);
420 public static function checkEncoding($from=
'CP1252', $to=
'UTF-8', $original, $converted)
422 $converted2 = iconv($to, $from, $converted);
425 if ($original === $converted2)
448 public static function stringEncode($string, $from=
'UTF-8', $to=
'UTF-8')
450 if ($string ==
'')
return $string;
452 $source_encoding = array(
453 'CP1250',
'CP1251',
'CP1252',
'CP1253',
'CP1254',
'CP1255',
'CP1256',
'CP1257',
454 'ISO-8859-2',
'ISO-8859-5',
'ISO-8859-1',
'ISO-8859-7',
'ISO-8859-9',
'ISO-8859-8',
'ISO-8859-6',
'ISO-8859-4',
458 $converted = iconv($from, $to, $string);
465 foreach($source_encoding as $from)
467 $converted = iconv($from, $to, $string);
474 return "Die Zeichenkette konnte leider nicht korrekt in UTF-8 umgewandelt werden.";
485 return strtotime($string);
497 public static function mkdir($dir, $mode = 0755, $recursive =
true)
499 $mode = $GLOBALS[
'egotec_conf'][
'chmod'] ? octdec($GLOBALS[
'egotec_conf'][
'chmod']) : $mode;
500 $dir = strtr($dir,
'\\/', DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR);
501 $dir = str_replace(
'/./',
'/', $dir);
505 if (@
mkdir($dir, $mode, $recursive))
511 if ($GLOBALS[
'egotec_conf'][
'mkdir_warning']) {
512 egotec_warning_log(
'Filesystem-Fehler beim Anlegen von '.$dir.
"\n\n".get_backtrace(0));
514 throw new Exception(
'Filesystem-Fehler beim Anlegen von '.$dir);
550 $parse_url = @parse_url($url);
551 $info[
'protokoll'] = $parse_url[
'scheme'];
552 $info[
'host'] = $parse_url[
'host'];
553 $info[
'port'] = $parse_url[
'port'];
554 $info[
'pfad'] = dirname($parse_url[
'path']);
555 $info[
'datei'] =
basename($parse_url[
'path']);
556 $info[
'query'] = str_replace(
'&',
'&',$parse_url[
'query']);
557 $info[
'mark'] = $parse_url[
'fragment'];
558 foreach (explode(
'&',$info[
'query']) as $param_pair)
560 $key = strtok($param_pair,
'=');
561 $value = strtok(
'=');
562 $info[
'parameter'][$key] = $value;
564 $info[
'parse_url'] = $parse_url;
593 public static function deldir($location, $del=
true, $without=
'',$rename=
true)
597 throw new Exception(
'deldir needs location not to be empty.');
600 if (substr($location,-1) !=
'/')
602 $location = $location.
'/';
604 $location = strtr($location,
'/', DIRECTORY_SEPARATOR);
605 if (is_dir($location))
607 $error =
"Filesystem-Fehler beim Löschen von ".$location;
614 $location = strtr($location,
'/', DIRECTORY_SEPARATOR);
615 if (substr($location,-1) != DIRECTORY_SEPARATOR)
617 $location.= DIRECTORY_SEPARATOR;
626 $tmp = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'deldir_'.md5(microtime()).DIRECTORY_SEPARATOR;
629 $tmp = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'deldir_'.md5(microtime()).DIRECTORY_SEPARATOR;
631 if (@rename($location,$tmp) ===
false)
633 if (is_dir($location))
635 $dir = dir($location);
636 while ($file = $dir->read())
640 if (is_dir($dir->path.$file)) {
641 self::deldir($dir->path.$file,
true,
'',
false);
643 @unlink($dir->path.$file);
657 $directory = dir($location);
658 $without_nodel =
false;
659 while (is_object($directory) &&
false !== ($file = $directory->read()))
662 if (! ( $without && $without[$file] ))
664 if (is_dir($directory->path.$file) && $file !=
'..' && $file !=
'.')
668 } elseif (is_file($directory->path.DIRECTORY_SEPARATOR.$file))
670 if (unlink($directory->path.$file) ===
false)
throw new Exception($error);
674 $without_nodel =
true;
677 if (is_object($directory)) $directory->close();
678 if ( !$without_nodel &&
false !== $del )
685 chdir($GLOBALS[
'egotec_conf'][
'egotec_dir']);
686 $result = @rmdir($location);
692 throw new Exception($error);
696 } elseif (is_file($location)) {
711 foreach ($headers as $key => $value)
714 $GLOBALS[
'egotec'][
'response_headers'][$key] = $value;
724 public static function flush($string =
'') {
725 if ($GLOBALS[
'live_system_migrate']) {
727 $GLOBALS[
'_output'] .= $string;
729 while (ob_get_level()) {
748 public static function endless($string =
'', $flush =
true) {
749 if (php_sapi_name() ==
'fpm-fcgi') {
750 @self::header(
'X-Accel-Buffering: no');
753 ignore_user_abort(
true);
754 @session_write_close();
756 self::flush($string);
776 $clean =
function($array) use (&$clean) {
777 foreach ($array as $key => $value) {
778 if (is_array($value)) {
779 $array[$key] = $clean($value);
781 $value = mb_strtolower($value);
782 if ($value ===
'null' || $value ===
'false') {
784 }
else if ($value ===
'true') {
787 $array[$key] = str_replace(
'"',
'\"', str_replace(
'\"',
'"', $array[$key]));
792 $assoc_array = $clean($assoc_array);
794 $path = strtr($path,
'/', DIRECTORY_SEPARATOR);
795 $single_content = $assoc_content =
'';
796 foreach ($assoc_array as $key => $item) {
797 if (is_array($item)) {
798 $assoc_content.=
"\n[".$key.
"]\n";
799 foreach ($item as $key2 => $item2) {
800 if ($item2 !=
'Array') {
801 $assoc_content.= $key2.
'="'.$item2.
'"'.
"\n";
805 $single_content.= $key.
'="'.$item.
'"'.
"\n";
808 $content = $single_content.
"\n".$assoc_content;
809 if (!$handle = @fopen($path,
'w')) {
812 if (!@fwrite($handle, $content)) {
833 public static function header($header, $replace =
true)
835 if (is_numeric($header)) {
839 101 =>
'Switching Protocols',
843 203 =>
'Non-Authoritative Information',
845 205 =>
'Reset Content',
846 206 =>
'Partial Content',
847 207 =>
'Multi-Status',
848 208 =>
'Already Reported',
850 300 =>
'Multiple Choices',
851 301 =>
'Moved Permanently',
854 304 =>
'Not Modified',
857 307 =>
'Temporary Redirect',
858 308 =>
'Permanent Redirect',
859 400 =>
'Bad Request',
860 401 =>
'Unauthorized',
861 402 =>
'Payment Required',
864 405 =>
'Method Not Allowed',
865 406 =>
'Not Acceptable',
866 407 =>
'Proxy Authentication Required',
867 408 =>
'Request Timeout',
870 411 =>
'Length Required',
871 412 =>
'Precondition Failed',
872 413 =>
'Request Entity Too Large',
873 414 =>
'Request-URI Too Long',
874 415 =>
'Unsupported Media Type',
875 416 =>
'Requested Range Not Satisfiable',
876 417 =>
'Expectation Failed',
877 420 =>
'Policy Not Fulfilled',
878 421 =>
'Misdirected Request',
879 422 =>
'Unprocessable Entity',
881 424 =>
'Failed Dependency',
882 426 =>
'Upgrade Required',
883 428 =>
'Precondition Required',
884 429 =>
'Too Many Requests',
885 431 =>
'Request Header Fields Too Large',
886 451 =>
'Unavailable For Legal Reasons',
887 500 =>
'Internal Server Error',
888 501 =>
'Not Implemented',
889 502 =>
'Bad Gateway',
890 503 =>
'Service Unavailable',
891 504 =>
'Gateway Timeout',
892 505 =>
'HTTP Version Not Supported',
893 506 =>
'Variant Also Negotiates',
894 507 =>
'Insufficient Storage',
895 508 =>
'Loop Detected',
896 509 =>
'Bandwidth Limit Exceeded',
897 510 =>
'Not Extended',
898 511 =>
'Network Authentication Required' 900 if (isset($codes[$header])) {
901 $GLOBALS[
'stats'][
'status'] = $header;
902 $GLOBALS[
'_SERVER'][
'REDIRECT_STATUS'] = $header;
903 $header = $_SERVER[
'SERVER_PROTOCOL'].
' '.$header.
' '.$codes[$header];
905 throw new Exception(
'Unsupported HTTP Status Code');
908 header($header, $replace);
909 $pos = strpos($header,
':');
910 $key = substr($header, 0, $pos);
911 $value = trim(substr($header, $pos+1));
912 if ($pos ===
false) {
916 if (!$replace && isset($GLOBALS[
'egotec'][
'response_headers'][$key])) {
917 $GLOBALS[
'egotec'][
'response_headers'][$key] .=
", $value";
919 $GLOBALS[
'egotec'][
'response_headers'][$key] = $value;
931 self::header(
'Expires: ' . gmdate(
'D, d M Y H:i:s') .
' GMT');
932 self::header(
'Cache-Control: no-store, no-cache, must-revalidate');
933 self::header(
'Cache-Control: post-check=0, pre-check=0',
false);
934 self::header(
'Pragma: no-cache');
944 public static function redirect($location, $header = 302) {
945 if (!empty($header)) {
946 self::header($header);
948 if (is_a($location,
'Page')) {
949 $location = $location->getUrl();
951 self::header(
"Location: $location");
965 if (isset($_SESSION[
'egotec_licence'][$ini_path]))
967 return $_SESSION[
'egotec_licence'][$ini_path];
969 $ini_file = rtrim($ini_path,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.
'module.ini';
972 $module = parse_ini_file($ini_file);
973 $licence_array = file($GLOBALS[
'egotec_conf'][
'var_dir']
974 .
'co'.
'nf'.
'/'.
'l'.
'ic'.
'en'.
'ce'.
'.'.
'eg'.
'ot'.
'ec'.
'.'.
'x'.
'ml');
975 $company = trim($licence_array[4]);
976 $num_named_users = trim($licence_array[7]);
977 foreach($licence_array as $key => $value)
979 if (trim($value) ==
'<module_'.$module[
'name'].
'>')
981 if (trim($licence_array[$key+1]) == md5(
'2u4z#h76CN~JBSo'.$company.$num_named_users.$module[
'name']))
983 return $_SESSION[
'egotec_licence'][$ini_path] =
true;
989 return $_SESSION[
'egotec_licence'][$ini_path] =
false;
1002 if ($GLOBALS[
'cron_fix_services']) {
1006 $lock_file = $GLOBALS[
'egotec_conf'][
'log_dir'].
'CRON.LOCK';
1009 if(empty($lock_msg))
1011 $tmp = debug_backtrace();
1013 $lock_msg = $lock_file;
1015 foreach($tmp[0] as $k => $v)
1017 $lock_msg.=
"<li><b>$k</b>: ";
1021 $lock_msg.= join(
"," , $v);
1028 $lock_msg.=
"</ul>";
1032 if ($expiry_date == 0) {
1033 $expiry_date = time()+60*60;
1037 $expiry_date += time();
1046 self::file_put_contents($lock_file, $expiry_date .
";". $lock_msg);
1050 $lock_content = explode(
";" , self::file_get_contents($lock_file));
1051 $lock_time = intval($lock_content[0]);
1053 if ($lock_time > time()) {
1054 $msg =
"Neuer Lock konnte nicht gesetzt werden, da bereits ein Lock existiert.";
1055 $msg.=
"<br/>Dieser verfällt am ".date(
"d. m. Y", $lock_time).
" um ".date(
"H:i:s", $lock_time).
".";
1056 $msg.=
"<p>".$lock_msg.
"</p>";
1058 throw new Exception($msg);
1062 self::file_put_contents($lock_file, $expiry_date .
";". $lock_msg);
1074 $lock_file = $GLOBALS[
'egotec_conf'][
'log_dir'].
'CRON.LOCK';
1075 if (self::file_exists($lock_file))
1077 @unlink($lock_file);
1090 if (!$GLOBALS[
'egotec_conf'][
'noclearstatcache']) {
1113 public static function parseCsvLine($str, $delimiter=
';', $qualifier=
'"', $qualifierEscape =
'\\')
1116 while (strlen($str) > 0)
1118 if ($str{0} == $delimiter)
1119 $str = substr($str, 1);
1120 if ($str{0} == $qualifier)
1123 for ($i = 1; $i < strlen($str); $i++)
1125 if (($str{$i} == $qualifier) && ($str{$i-1} != $qualifierEscape))
1127 $str = substr($str, (strlen($value) + 2));
1128 $value = str_replace(($qualifierEscape.$qualifier), $qualifier, $value);
1135 $end = strpos($str, $delimiter);
1136 $value = ($end !==
false) ? substr($str, 0, $end) : $str;
1137 $str = substr($str, strlen($value));
1152 return $_SERVER[
'WINDIR'] || $_SERVER[
'windir'] || $_ENV[
'WINDIR'] || $_ENV[
'windir'] || getenv(
'windir');
1162 $format = self::isWindows() ?
"where %s" :
"command -v %s";
1163 $parts = explode(
' ', sprintf($format, $cmd));
1164 $return = self::exec($parts[0], array($parts[1], $parts[2]));
1165 return !empty($return);
1177 if ($_SESSION[
'export'])
1179 mb_regex_encoding(
'UTF-8');
1180 $return = mb_eregi_replace(
"[^[a-zA-Z0-9]]",
"_", $url);
1183 $return = strtr($url,
"%\n\r\t,;#-+?:&/'\".\\",
'_________________');
1185 if ($id && $url!=$return)
1187 $return.=
'-p-'.$id;
1189 return urlencode($return);
1211 $db = new_db_connection();
1213 'table' =>
'egotec_page_lock',
1227 $lines = file($file);
1229 foreach ($lines as $entry) {
1230 if (strpos($entry,
';') !== 0) {
1231 $content = explode(
'=', $entry, 2);
1232 $array[rtrim($content[0])] = trim($content[1]);
1247 if ($GLOBALS[
'frontend_admin']) {
1249 $str = preg_replace(
'/<([^ ]+) [^>]*data-edit-type="[^"]+"[^>]*>(.*?)<\/\\1>/msi',
'$2', $str);
1251 $str = strip_tags($str,
'<img><div><input><textarea><form><hr><param><object><video><iframe><embed>');
1252 $str = html_entity_decode($str);
1263 if (strlen($str) == 0)
1286 public static function urltopage($url, $params=array(), $only_site =
false, $error_page =
false, $commit_params =
false)
1288 require_once (
'base/Site.php');
1289 $url = preg_replace(
'/#.*?$/ims',
'', $url);
1294 if (strpos($url,
'index.php?') !==
false)
1296 return self::_urltopage_index($url, $params);
1300 $url = preg_replace(
'/\/_\/.*?$/ims',
'.html', $url);
1301 return self::_urltopage_sprechend($url, $only_site, $error_page, $commit_params);
1304 catch (Exception $e)
1310 private static function _urltopage_sprechend($url, $only_site, $error_page, $commit_params)
1312 if ($GLOBALS[
'egotec_conf'][
'rewrite_engine'] ==
'url') {
1315 $domain = $info[
'host'] ?? $_SERVER[
'HTTP_HOST'];
1316 $file = ($pos = strpos($info[
'datei'],
'.')) ? substr($info[
'datei'], 0, $pos) : $info[
'datei'];
1317 if (strpos($file,
'%') !==
false) {
1319 $file = urldecode(str_replace(
'+',
'%2B', $file));
1321 $dir = ltrim($info[
'pfad'] .
'/' . $file,
'/');
1322 $db = new_db_connection(array(
1323 'table' =>
'egotec_url',
1324 'where' =>
"domain = :domain AND dir = :dir",
1326 'domain' => $domain,
1330 if ($db->nextRecord()) {
1332 'site' => $db->Record[
'site'],
1333 'lang' => $db->Record[
'lang'],
1334 'id' => $db->Record[
'id']
1348 if (preg_match(
"#^http[s]?://([^/]+)#i", $url, $m))
1351 $url = substr($url, strlen($m[0]));
1354 $pos = strpos($url, $GLOBALS[
'egotec_conf'][
'url_dir']);
1357 $url = substr($url, strlen($GLOBALS[
'egotec_conf'][
'url_dir']));
1361 $dot_pos = strrpos($url,
'.');
1362 if ($dot_pos!==
false)
1364 $request_suffix = substr($url, $dot_pos);
1365 $url = substr($url, 0, $dot_pos);
1368 $request_suffix =
'.html';
1375 $dir = dirname($url);
1376 if ($dir && $dir!=
'.')
1378 $dir = explode(
'/', $dir);
1381 $req[
'site'] = array_shift($dir);
1382 $url = substr($url, strlen($req[
'site'])+1);
1384 if ($dir && strlen($dir[0])==2)
1386 $req[
'lang'] = array_shift($dir);
1387 $url = substr($url, 3);
1391 $req[
'skin'] = array_shift($dir);
1392 $url = substr($url, strlen($req[
'skin'])+1);
1400 while ($dir[$path_index])
1402 $num_path+= strlen($dir[$path_index])+1;
1405 $url = ltrim(substr($url, $num_path),
'/');
1408 $url = explode(
'-', $url);
1411 $key = urldecode(next($url));
1412 $value = str_replace(
'%2d',
'-', urldecode(next($url)));
1413 $req[$key] = urldecode($value);
1417 if ($http_host &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'bin_dir'].
'admin/popup_virtual_hosts.php'))
1419 $virtual_hosts = self::getVirtualHosts();
1422 $http_host = strtolower($http_host);
1424 if (!isset($virtual_hosts[$http_host]))
1426 if ($http_host != $_SERVER[
'HTTP_HOST']) {
1431 $req[
'site'] = $GLOBALS[
'egotec_conf'][
'default_site'];
1433 $req[
'site'] = $virtual_hosts[$http_host][
'site'];
1434 $GLOBALS[
'egotec_conf'][
'default_site'] = $req[
'site'];
1436 if (!$req[
'lang'] && $virtual_hosts[$http_host][
'lang'])
1438 $req[
'lang'] = $virtual_hosts[$http_host][
'lang'];
1441 if (isset($virtual_hosts[$http_host]))
1443 $GLOBALS[
'egotec_conf'][
'default_site'] = $virtual_hosts[$http_host];
1450 $req[
'site'] = $GLOBALS[
'egotec_conf'][
'default_site'];
1453 $site =
new Site($req[
'site'], $req[
'lang'], $req[
'skin']);
1454 }
catch (Exception $e) {
1455 switch ($e->getCode()) {
1457 array_unshift($url, $req[
'lang']);
1458 unset($req[
'lang']);
1459 $site =
new Site($req[
'site'],
'', $req[
'skin']);
1464 $req[
'site'] = $GLOBALS[
'egotec_conf'][
'default_site'];
1465 $site =
new Site($GLOBALS[
'egotec_conf'][
'default_site']);
1470 $req[
'p'] = $site->site[
'error_id']?$site->site[
'error_id']:$site->rootId;
1481 $site->setLanguage($req[
'lang']);
1487 unset($req[
'lang']);
1488 switch ($exception->getCode())
1502 $req[
'id'] = $site->site[
'error_id'];
1514 foreach ($req as $k => $v)
1526 $req[
'id'] = $req[
'p'];
1527 if ($req[
'id'] && !is_numeric($req[
'id']))
1531 $req[
'id'] = $site->site[
'error_id'];
1538 $name = urldecode($url[0]);
1539 $lang_name = ($req[
'lang']?$req[
'lang'].
'/':
'').$meta_url;
1540 if (!$meta_url && !$name && !$req[
'id'])
1542 $req[
'id'] = $site->rootId;
1545 $current_path = array();
1554 $req[
'id'] = $site->rootId;
1556 $pages = $site->getPages(array(
'where' =>
'url=\''.$meta_url.
'\''), array(
'auth_or' =>
'1=1',
'inactive' =>
true));
1557 if ($pages && $pages->numRecords() == 1)
1559 $page = $pages->nextPage();
1560 $current_path = $page->getPath(
false, array(),
false);
1565 foreach($dir as $path_name)
1567 $path_name = urldecode($path_name);
1568 if (strpos($path_name,
'-')!==
false)
1570 $path_name = explode(
'-', $path_name);
1571 $parent = $site->getPage((
int)$path_name[2], array(
'auth_or' =>
'1=1',
'inactive' =>
true));
1573 if (!is_object($parent))
1575 $pages = $site->getRoot(array(
'auth_or' =>
'1=1'))->getChildren(
1576 array(
'where' =>
'name=:name OR name LIKE :name',
'bind' => array(
'name' => $path_name)),
1577 array(
'auth_or' =>
'1=1',
'inactive' =>
true)
1579 $parent = $pages->nextPage();
1581 $pages = $parent->getChildren(
1582 array(
'where' =>
'name=:name OR name LIKE :name',
'bind' => array(
'name' => $path_name)),
1583 array(
'auth_or' =>
'1=1',
'inactive' =>
true)
1585 $parent = $pages->nextPage();
1588 if (is_object($parent))
1590 $current_path[] = $parent->field[
'id'];
1595 if (!is_object($parent))
1597 $parent = $site->getRoot(array(
'auth_or' =>
'1=1',
'inactive' =>
true));
1603 if (is_object($page))
1605 $req[
'id'] = $page->field[
'id'];
1608 if (is_object($parent))
1610 $pages = $parent->getChildren(
1611 array(
'where' =>
'url=\''.$name.
'\' OR name=\
''.$name.
'\' OR name like \
''.$name.
'\''),
1612 array(
'auth_or' =>
'1=1')
1614 if (!$pages->numRecords())
1616 $pages = $site->getPages(
1617 array(
'where' =>
'url LIKE \''.$name.
'\' OR name=\
''.$name.
'\' OR name like \
''.$name.
'\''),
1618 array(
'auth_or' =>
'1=1')
1622 $pages = $site->getPages(
1623 array(
'where' =>
'url LIKE \''.$name.
'\' OR name=\
''.$name.
'\' OR name like \
''.$name.
'\''),
1624 array(
'auth_or' =>
'1=1')
1627 $req[
'id'] = $pages->nextPage()->field[
'id'];
1629 if (!$req[
'id'] && $commit_params)
1631 $GLOBALS[
'no_cache'] =
true;
1633 }
else if (!$req[
'id'])
1635 $req[
'id'] = $site->rootId;
1640 $GLOBALS[
'current_path'] = $current_path;
1641 foreach ($req as $k => $v)
1646 $get_page_param = array();
1647 $get_page_param[
'auth_or'] =
'1=1';
1648 $get_page_param[
'inactive'] =
true;
1649 return $site->getPage($req[
'id'], $get_page_param);
1652 private static function _urltopage_index($url, $params=array())
1655 $pattern =
'/id=(\d+)/';
1656 preg_match($pattern, $url, $match);
1660 if(!$params[
'site'])
1662 $pattern =
'/site=([^\?&]+)/';
1663 preg_match($pattern, $url, $match);
1664 $site_id = $match[1];
1668 $site_id = $params[
'site'];
1672 if(!$params[
'lang'])
1674 $pattern =
'/lang=([a-z]+)/';
1675 preg_match($pattern, $url, $match);
1676 $site_lang = $match[1];
1680 $site_lang = $params[
'lang'];
1683 $site =
new Site($site_id, $site_lang);
1684 if (empty($GLOBALS[
'site'])) {
1686 $GLOBALS[
'site'] = $site;
1688 $page = $site->getPage($id, $params[
'params'][
'param']);
1706 public static function copy($src, $dest, $except =
'', $useLinks=
false)
1713 while(($entry = $dir->read()) !==
false)
1715 if ($entry ==
'.svn' || $entry ==
'.' || $entry ==
'..')
continue;
1718 && preg_match($except, $entry)
1723 $path = $src.
'/'.$entry;
1724 self::copy($path, $dest.
'/'.$entry, $except, $useLinks);
1728 } elseif (empty($except) || !preg_match($except,
basename($src)))
1730 if ($useLinks && @link($src, $dest)) {
1733 return @
copy($src, $dest);
1748 public static function getAllSites($username =
'', $perm =
'', $table =
false, $type =
'')
1750 $unique_key = $username.$perm.(int)$table.(string)$type;
1751 if (!empty(self::$allSites[$unique_key])) {
1752 return self::$allSites[$unique_key];
1756 $db = new_db_connection(array(
1757 'fields' =>
'user_id',
1758 'table' =>
'egotec_user',
1759 'where' =>
'username=:username',
1760 'bind' => array(
'username' => $username)
1762 if (!$db->nextRecord())
1766 $user_id = $db->Record[
'user_id'];
1770 $dir = opendir($GLOBALS[
'egotec_conf'][
'site_dir']);
1771 $sites = $sort = array();
1772 while ($file = readdir($dir))
1775 is_dir($GLOBALS[
'egotec_conf'][
'site_dir'].$file) && $file[0] !=
'.' &&
1778 $loop_site =
new Site($file,
'',
'', !$GLOBALS[
'admin_area']);
1780 if ($type && $loop_site->site[
'type'] != $type) {
1787 $db = new_db_connection();
1788 if (!$db->tableExists($loop_site->pageTable))
1790 egotec_warning_log(
"Site table {$loop_site->pageTable} does not exist.");
1797 $loop_site->hasRight($perm,
false, $user_id)
1799 $sites[$file] = $loop_site;
1800 $sort[] = mb_strtolower($loop_site->site[
'title']);
1806 array_multisort($sort, SORT_ASC, SORT_NATURAL, $sites);
1808 self::$allSites[$unique_key] = $sites;
1818 $skins = self::getSkins();
1819 foreach ($skins as $type => $list) {
1820 foreach ($list as $skin => $title) {
1821 if ($skin ==
'_empty') {
1822 unset($skins[$type][$skin]);
1825 $skins[$type][$skin] = array();
1829 foreach (array_unique(array_merge(
1830 array($site->conf[
'site'][
'default_skin'], $site->conf[
'site'][
'mobile_skin']),
1831 explode(
',', $site->conf[
'site'][
'skins'])
1835 && isset($skins[
'skins'][$skin])
1836 && !in_array($site->name, $skins[
'skins'][$skin])
1838 $skins[
'skins'][$skin][] = $site;
1843 && (!$skins[
'themes'][$site->theme]
1844 || !in_array($site->name, $skins[
'themes'][$site->theme]))
1846 $skins[
'themes'][$site->theme][] = $site;
1858 public static function getSkins($more_themes = array()) {
1859 $cache = self::getCache();
1860 $cache_key =
'getSkins' . md5(json_encode(func_get_args()));
1861 $result = $cache->get($cache_key);
1863 if ($result === null) {
1870 $skin_dir = $GLOBALS[
'egotec_conf'][
'skin_dir'];
1871 if (self::file_exists($skin_dir)) {
1872 $dir = dir($skin_dir);
1873 while ($file = $dir->read()) {
1875 is_dir($skin_dir.$file)
1876 && substr($file, 0, 1) !=
'.' 1880 $result[
'skins'][$file] = $file;
1884 ksort($result[
'skins']);
1888 $result[
'themes'] = array(
'_empty' =>
'--');
1889 $theme_dir = $GLOBALS[
'egotec_conf'][
'egotec_dir'].
'pub/theme/';
1890 if (self::file_exists($theme_dir)) {
1891 $dir = dir($theme_dir);
1892 while ($file = $dir->read()) {
1894 is_dir($theme_dir.$file)
1895 && substr($file, 0, 1) !=
'.' 1899 $conf_file = $theme_dir.$file.
'/conf.ini';
1901 $conf = parse_ini_file($conf_file);
1902 $title = $conf[
'title'];
1907 $result[
'themes'][$file] =
"[ $title ]";
1909 $result[
'themes'][$file] = $title;
1915 foreach ($more_themes as $name => $theme) {
1916 if (!isset($result[
'themes'][$name])) {
1917 $result[
'themes'][$name] = $theme;
1920 ksort($result[
'themes']);
1922 $cache->set($cache_key, $result);
1937 public static function log($file, $message)
1939 $file = $GLOBALS[
'egotec_conf'][
'log_dir'].$file;
1943 if ($size > 100*1024*1024)
1945 $new_name = $file.
'_'.date(
"Y-m-d_H-i-s");
1946 rename($file, $new_name);
1950 $min = ($GLOBALS[
'egotec_conf'][
'log_min_disk_free']?
1951 $GLOBALS[
'egotec_conf'][
'log_min_disk_free']:10
1953 if (!is_dir($GLOBALS[
'egotec_conf'][
'log_dir'])) {
1954 self::mkdir($GLOBALS[
'egotec_conf'][
'log_dir']);
1956 $bytes_free = disk_free_space($GLOBALS[
'egotec_conf'][
'log_dir']);
1957 if ($min > $bytes_free)
1961 $files = glob($file.
'_*');
1962 foreach ($files as $f)
1966 strpos($f, $file)===0 &&
1967 preg_match(
'/_(\d{4}-\d{2}-\d{2})_(\d{2})-(\d{2})-(\d{2})$/', $f, $m)
1969 $stamp = $m[1].
' '.$m[2].
':'.$m[3].
':'.$m[4];
1970 $times[strtotime($stamp)] = $f;
1974 if (
sizeof($times)>0)
1976 unlink(current($times));
1979 $last_mail_file = $GLOBALS[
'egotec_conf'][
'log_dir'].
'disk_free_mail.date';
1980 $last_mail_date =
'1970-01-01 00:00:00';
1982 $last_mail_date = $date;
1985 !$GLOBALS[
'egotec_conf'][
'no_disk_free_mail']
1986 && $last_mail_date + 3600 < date(
'Y-m-d H:i:s')
1993 $frei = round($bytes_free / (1024*1024));
1994 $text =
"Es ist nicht genügend Speicherplatz auf dem Server vorhanden.\n".
1995 "Aktuell sind auf dem Server $frei MB frei.\n\n".
1996 $_SERVER[
'SERVER_NAME'].$_SERVER[
'REQUEST_URI'];
1997 require_once(
'mail/Ego_Mail.php');
1998 $mail =
new Ego_Mail();
2000 $mail->mail($GLOBALS[
'egotec_conf'][
'admin_mail'],
'Nicht genügend Speicherplatz auf dem Webserver', $text);
2001 }
catch (Exception $e)
2011 error_log($message, 3, $file);
2026 'installed' => array(),
2027 'failed' => array(),
2038 $requirements = array(
2054 'fileinfo' => array(
2075 'mbstring' => array(
2084 $loaded_extensions = get_loaded_extensions();
2087 foreach($requirements as $requirement => $required)
2089 $skip_version_compare =
false;
2090 $installed = $failed =
'';
2092 switch($requirement)
2096 $version = phpversion();
2098 $installed =
"PHP {$required['min']} oder höher ist installiert ($version)";
2099 $failed =
"PHP Version unzureichend ($version). Bitte aktualisieren Sie Ihre PHP Version auf {$required['min']} oder höher";
2106 $db = new_db_connection();
2107 $version = $db->getVersion();
2109 $installed =
"MySQL {$required['min']} oder höher ist installiert ($version)";
2110 $failed =
"MySQL Version unzureichend ($version). Bitte aktualisieren Sie Ihre MySQL Version auf {$required['min']} oder höher";
2113 $installed =
"MySQL wird nicht benötigt";
2121 if ($conn = @oci_connect($GLOBALS[
'egotec_conf'][
'db'][
'user'], $GLOBALS[
'egotec_conf'][
'db'][
'password'], $GLOBALS[
'egotec_conf'][
'db'][
'database'],
'AL32UTF8'))
2123 $version = oci_server_version($conn);
2126 $installed =
"Oracle {$required['min']} oder höher ist installiert ($version)";
2127 $failed =
"Oracle Version unzureichend ($version). Bitte aktualisieren Sie Ihre Oracle Version auf {$required['min']} oder höher";
2132 $failed =
"Oracle ist installiert, die Version konnte aber nicht ermittelt werden. Empfohlene Oracle Version ist {$required['min']} oder höher";
2136 $installed =
"Oracle wird nicht benötigt";
2142 if (function_exists(
'finfo_file')) {
2143 $version = phpversion(
'fileinfo');
2144 $result[
'installed'][$requirement] =
"Fileinfo ist installiert ($version)";
2146 $result[
'failed'][$requirement] =
"Fileinfo ist nicht installiert";
2148 $skip_version_compare =
true;
2153 $installed =
"64 Bit System";
2154 $failed =
"32 Bit System";
2159 $version = phpversion($requirement);
2167 $version = in_array($requirement, $loaded_extensions) ?
'' :
false;
2170 if ($version ===
false)
2173 if (!$required[
'min'])
2178 $result[$type][$requirement] =
"$requirement ist nicht installiert";
2182 $result[
'installed'][$requirement] =
"$requirement ist installiert".($version !=
'' ?
" ($version)" :
'');
2185 $skip_version_compare =
true;
2190 if ($skip_version_compare)
2195 $requirement ==
'oracle' 2196 && preg_match(
'/\d+\.[^ ]*/', $version, $match)
2199 $version = $match[0];
2202 if(!version_compare($version, $required[
'min'],
'>=') && !$required[
'except'])
2204 $result[
'failed'][$requirement] = $failed;
2205 }elseif(version_compare($version, $required[
'min'],
'>=') && !$required[
'except'])
2207 $result[
'installed'][$requirement] = $installed;
2208 }elseif(version_compare($version, $required[
'min'],
'>=') && $required[
'except'])
2210 $exceptions = explode(
',', $required[
'except']);
2212 if (version_compare($version,$exceptions[0],
'>=') && version_compare($version,$exceptions[1],
'<'))
2214 $result[
'failed'][$requirement] = $failed;
2217 $result[
'installed'][$requirement] = $installed;
2220 $result[
'failed'][$requirement] = $failed;
2225 if ($result[
'failed'][
'mysql'] && $result[
'failed'][
'oracle'])
2227 $result[
'failed'][
'_db'] =
"Weder MySQL noch Oracle sind installiert";
2231 if ($result[
'failed'][
'gd'] && $result[
'failed'][
'convert'])
2233 $result[
'failed'][
'_image'] =
"Weder GD noch ImageMagick sind installiert";
2237 foreach($result[
'failed'] as $key => $value)
2239 $set_notice =
false;
2244 if ($result[
'installed'][
'oracle'])
2251 if ($result[
'installed'][
'mysql'])
2258 if ($result[
'installed'][
'convert'])
2265 if ($result[
'installed'][
'gd'])
2274 $result[
'notice'][$key] = $value;
2275 unset($result[
'failed'][$key]);
2279 if (
sizeof($result[
'failed']) > 0)
2281 $result[
'passed'] =
false;
2295 if ($byte > 1024*1024*1024) {
2296 return number_format($byte / (1024*1024*1024), 1).
' GB';
2297 } elseif ($byte > 1024*1024) {
2298 return number_format($byte / (1024*1024), 1).
' MB';
2299 } elseif ($byte > 1024) {
2300 return number_format($byte / (1024), 1).
' kB';
2318 self::file_put_contents($GLOBALS[
'egotec_conf'][
'cache_dir'].
'eternal', time()+900);
2320 @unlink($GLOBALS[
'egotec_conf'][
'cache_dir'].
'eternal');
2323 self::clearCacheAllSites();
2335 return (
bool) (self::file_get_contents(
'https://'.$_SERVER[
'HTTP_HOST'].$GLOBALS[
'egotec_conf'][
'url_dir']));
2336 }
catch (Exception $e) {
2346 return substr(strrchr(get_class(new_db_connection()),
'_'), 1);
2357 require_once(
'MIME/Type/Extension.php');
2358 $mime =
new MIME_Type_Extension();
2360 $types = $mime->extensionToType;
2362 return ($ext ? $types[$ext] : $types);
2375 'site' => $GLOBALS[
'site']->name,
2376 'skin' => $GLOBALS[
'site']->skin
2379 if (
file_exists($GLOBALS[
'egotec_conf'][$dir.
'_dir'].$sub_dir[$dir].
'/'.$file))
2381 return $GLOBALS[
'egotec_conf'][
'url_dir'].$dir.
'/'.$sub_dir[$dir].
'/'.$file;
2382 } elseif ($GLOBALS[
'site']->globalAllowed() &&
file_exists($GLOBALS[
'egotec_conf'][$dir.
'_dir'].
'_global/'.$file))
2384 return $GLOBALS[
'egotec_conf'][
'url_dir'].$dir.
'/_global/'.$file;
2385 } elseif (
file_exists($GLOBALS[
'egotec_conf'][
'lib_dir'].
'type/'.$dir.
'/'.$file))
2387 return $GLOBALS[
'egotec_conf'][
'url_dir'].
'lib/'.$dir.
'/'.$file;
2404 if ($handle = opendir ($pfad))
2406 while (
false !== ($file = readdir($handle)))
2408 $nextpath = $pfad .
'/' . $file;
2409 if ($file !=
'.' && $file !=
'..' && !is_link ($nextpath))
2411 if (is_dir ($nextpath))
2415 $totalsize += $result[
'size'];
2416 $totalcount += $result[
'count'];
2417 $dircount += $result[
'dircount'];
2418 }elseif (is_file ($nextpath))
2420 $stat = stat ($nextpath);
2421 if (!isset($links[$stat[
'ino']])) {
2422 $totalsize += $stat[
'size'];
2424 if ($stat[
'nlink'] > 1) {
2425 $links[$stat[
'ino']] = $stat[
'nlink'];
2433 $total[
'size'] = $totalsize;
2434 $total[
'count'] = $totalcount;
2435 $total[
'dircount'] = $dircount;
2449 $host = $GLOBALS[
'egotec_conf'][
'proxy'][
'proxy_host'];
2450 $port = $GLOBALS[
'egotec_conf'][
'proxy'][
'proxy_port'];
2451 $ssl = $GLOBALS[
'egotec_conf'][
'proxy'][
'proxy_ssl'];
2452 $login = $GLOBALS[
'egotec_conf'][
'proxy'][
'proxy_login'];
2453 $password = $GLOBALS[
'egotec_conf'][
'proxy'][
'proxy_password'];
2455 if ($host && $port) {
2458 'proxy' => ($ssl ?
'ssl://' :
'tcp://').$host.
':'.$port,
2459 'request_fulluri' =>
true 2463 $auth = base64_encode($login .
":" . $password);
2464 $options[
'http'][
'header'] =
"Proxy-Authorization: Basic $auth\r\n";
2467 $options = array_merge_recursive(stream_context_get_options($context), $options);
2468 if (is_array($options[
'http'][
'header'])) {
2469 $options[
'http'][
'header'] = implode(
"\r\n", array_map(
'trim', $options[
'http'][
'header']));
2472 $context = stream_context_create($options);
2475 if ($context && $content ===
false) {
2481 if ($utf8 && $content) {
2482 return mb_convert_encoding($content,
'UTF-8', mb_detect_encoding($content,
'UTF-8, ISO-8859-1',
true));
2524 $site = $GLOBALS[
'site'];
2527 $count = range(1, self::MAX_CLUSTER);
2529 foreach ($count as $c) {
2531 $site->admin[
'cluster'][
'cluster_'.$c.
'_aktiv'] == 1
2532 && $site->admin[
'cluster'][
'cluster_'.$c.
'_url'] !=
'' 2535 'url' => rtrim($site->admin[
'cluster'][
'cluster_'.$c.
'_url'],
'/') .
'/',
2537 'oneway' => (
bool) $site->admin[
'cluster'][
'cluster_'.$c.
'_oneway']
2554 public static function truncate($string, $length, $etc =
'...', $break_words =
false, $middle =
false)
2556 require_once(
'smarty/plugins/modifier.html_truncate.php');
2557 return smarty_modifier_html_truncate($string, $length, $etc, $break_words, $middle);
2567 switch ($site->site[
'type']) {
2569 $_SESSION[
'_last_desktop'] = array(
2570 'name' => $site->name,
2571 'language' => $site->language
2576 if (is_array($_SESSION[
'_last_desktop'])) {
2578 $_SESSION[
'_last_desktop'][
'name'],
2579 $_SESSION[
'_last_desktop'][
'language']
2581 if ($_site->site[
'media'] == $site->name)
2588 $_site->site[
'media'] == $site->name
2589 && $_site->name != $site->name
2597 if (is_array($_SESSION[
'_last_desktop'])) {
2599 $_SESSION[
'_last_desktop'][
'name'],
2600 $_SESSION[
'_last_desktop'][
'language']
2615 require_once(
'base/Ego_SVN.php');
2616 require_once(
'base/SVN_Updater.php');
2617 require_once(
'base/Ego_Licence.php');
2619 $licence =
new Ego_Licence();
2620 if ($licence->licence[
'soap'][
'login'] && $licence->licence[
'soap']) {
2621 $lokale_version = explode(
' ', $GLOBALS[
'egotec_version']);
2622 $path = SVN_Updater::$svnPath;
2623 $svn =
new Ego_SVN(SVN_Updater::$svnServer, SVN_Updater::$svnRepository, $path);
2624 $svn->setAuth($licence->licence[
'soap'][
'login'], $licence->licence[
'soap'][
'password']);
2625 $versionen = $svn->getFileList();
2626 $_versionen = array();
2627 foreach ($versionen as $v)
2629 $v = trim($v[
'name'],
'/');
2632 natsort($_versionen);
2633 $_versionen = array_reverse($_versionen);
2634 return $_versionen[0];
2648 require_once(
'diff/Ego_Diff.php');
2650 $jscripts = array();
2651 while (preg_match(
'/<script[^>]+type="text\/javascript"[^>]*>(.*?)<\/script>/ims', $diff1, $m))
2653 $key =
'__EGOTEC__JS__'.md5($m[0]).
'__JS__EGOTEC__';
2654 $jscripts[$key] = $m[0];
2655 $diff1 = str_replace($m[0], $key, $diff1);
2656 $diff2 = str_replace($m[0], $key, $diff2);
2658 $diff =
new Ego_Diff();
2659 $result = $diff->compare($diff2, $diff1,
false);
2661 foreach ($jscripts as $key => $js)
2663 $result = str_replace($key, $js, $result);
2678 $media = $GLOBALS[
'egotec_conf'][
'url_dir'].
'bin/media/error.php';
2680 $media = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/missing_file.gif';
2682 if ($params[
'site']) {
2684 $site =
new Site($params[
'site']);
2690 $site->site[
'type'] ==
'media' 2691 && ($params[
'width'] || $params[
'height'])
2693 return $media.
'?'.http_build_query(
2695 'width' => $params[
'width'],
2696 'height' => $params[
'height']
2732 public static function getFallbackFile($type, $name, $path, $skip = array(
'module'), $url =
false, $relative =
false, $parent =
'') {
2733 $cache = self::getCache();
2734 $cache_key =
'getFallbackFile' . md5(json_encode(func_get_args()));
2735 $result = $cache->get($cache_key);
2737 if ($result === null) {
2740 $path = ltrim($path,
'/');
2743 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
2744 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] . $type .
'/',
2745 'file' => $name .
'/' . $path
2747 'parent_custom' => array(
2748 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
2749 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] . $type .
'/',
2750 'file' => $parent .
'/' . $path
2752 'parent_theme' => array(
2753 'path' => $GLOBALS[
'egotec_conf'][
'pub_dir'],
2754 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] .
'pub/',
2755 'file' =>
'theme/' . $parent .
'/' . $type .
'/' . $path
2758 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
2759 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] . $type .
'/',
2760 'file' =>
'_global/' . $path
2763 'path' => $GLOBALS[
'egotec_conf'][
'lib_dir'],
2764 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] .
'lib/',
2765 'file' =>
'type/' . $type .
'/' . $path
2768 'path' => $GLOBALS[
'egotec_conf'][
'bin_dir'],
2769 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] .
'bin/',
2770 'file' =>
'type/skin/' . $path
2776 if (empty($parent)) {
2777 $skip[] =
'parent_custom';
2778 $skip[] =
'parent_theme';
2779 } elseif ($type !=
'skin') {
2780 $skip[] =
'parent_custom';
2782 foreach ($files as $key => $file) {
2783 $path_file = $file[
'path'] . $file[
'file'];
2784 $url_file = $file[
'url'] . $file[
'file'];
2786 $pos = strpos($url_file, $GLOBALS[
'egotec_conf'][
'url_dir']);
2788 $url_file = substr_replace(
2792 strlen($GLOBALS[
'egotec_conf'][
'url_dir'])
2796 if (!in_array($key, $skip) && is_file($path_file)) {
2797 $result = $url ? $url_file : $path_file;
2802 $cache->set($cache_key, $result);
2823 public static function getFiles($type, $name, $path, $skip = array(), $parent =
'', $return_path =
false, $get_variants =
true) {
2824 $cache = self::getCache();
2825 $cache_key =
'getFiles' . md5(json_encode(func_get_args()));
2826 $result = $cache->get($cache_key);
2828 if ($result === null) {
2829 $original_path = $path;
2830 $original_skip = $skip;
2835 $result =
new stdClass();
2836 $result->{
'_empty'} = $GLOBALS[
'auth']->translate(
'Standard');
2840 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
2841 'file' => $name .
'/' . $path
2843 'parent_custom' => array(
2844 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
2845 'file' => $parent .
'/' . $path
2847 'parent_theme' => array(
2848 'path' => $GLOBALS[
'egotec_conf'][
'egotec_dir'] .
'pub/',
2849 'file' =>
'theme/' . $parent .
'/' . $type .
'/' . $path
2852 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
2853 'file' =>
'_global/' . $path
2856 'path' => $GLOBALS[
'egotec_conf'][
'pub_dir'],
2857 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] .
'pub/',
2858 'file' =>
'type/' . $type .
'/' . $path
2861 'path' => $GLOBALS[
'egotec_conf'][
'lib_dir'],
2862 'file' =>
'type/' . $type .
'/' . $path
2865 'path' => $GLOBALS[
'egotec_conf'][
'bin_dir'],
2866 'file' =>
'type/skin/' . $path
2872 if (empty($parent)) {
2873 $skip[] =
'parent_custom';
2874 $skip[] =
'parent_theme';
2876 foreach ($files as $key => $file) {
2877 if (!in_array($key, $skip)) {
2878 $list = glob($file[
'path'] . $file[
'file']);
2879 if (!empty($list)) {
2880 foreach ($list as $match) {
2881 if (@is_file($match)) {
2882 $parts = explode(
'.',
basename($match));
2883 $i = $get_variants ? count($parts) - 2 : 0;
2884 if ($i >= 0 && $parts[$i]) {
2885 $variant = $parts[$i];
2887 $relative_path = substr($match, strlen($GLOBALS[
'egotec_conf'][
'egotec_dir']));
2888 $result->{$relative_path} = ucfirst($variant);
2890 $result->{$variant} = ucfirst($variant);
2898 $result = (array) $result;
2899 if (strpos($original_path,
'.html') !==
false) {
2901 $result = array_merge($result, self::getFiles($type, $name, str_replace(
'.html',
'.tpl', $original_path), $original_skip, $parent, $return_path, $get_variants));
2904 $cache->set($cache_key, $result);
2923 public static function getVariantFiles($type, $name, $path, $skip = array(), $parent =
'') {
2924 $path = substr_replace($path,
'.*', strrpos($path,
'.'), 0);
2925 return self::getFiles($type, $name, $path, $skip, $parent);
2936 if (!$url && $_REQUEST[
'_url']) {
2937 $url = $_REQUEST[
'_url'];
2938 if ($url[0] ==
'/') {
2939 $url = substr($url, 1);
2941 if ($query_pos = strpos($url,
'?')) {
2942 $url = substr($url, 0, $query_pos);
2944 $dot_pos = strrpos($url,
'.');
2945 if ($dot_pos !==
false) {
2946 $url = substr($url, 0, $dot_pos);
2951 parse_str(parse_url($url, PHP_URL_QUERY), $params);
2953 if (strpos($url,
'index.php') ===
false) {
2955 $url = explode(
'-', parse_url($url, PHP_URL_PATH));
2957 while ($value !==
false)
2959 $value = preg_replace(
'/\..*?$/',
'', $value);
2961 if ($key ===
false || strpos($key,
'/') !==
false)
2965 $params[$key] = $value;
2966 $key = urldecode($key);
2967 $value = prev($url);
2969 $params = array_reverse($params);
2981 if (empty($request)) {
2982 $request = $_REQUEST;
2983 foreach ($_COOKIE as $key => $val) {
2984 unset($request[$key]);
2987 unset($request[
'_url']);
2988 unset($request[
'p']);
2989 unset($request[
'id']);
2990 unset($request[
'site']);
2991 unset($request[
'lang']);
2992 unset($request[
'skin']);
2993 unset($request[
'no301']);
2994 unset($request[
'return_absolute']);
2995 unset($request[
'return_relative']);
2996 unset($request[
'return_original']);
2997 unset($request[
'return_https']);
3008 if (preg_match(
'/^([^\/:]+:\/\/)?(.*?)$/', $url, $matches)) {
3009 $protocol = $matches[1];
3011 $uri = str_replace(
'//',
'/', $uri);
3012 $url = $protocol.$uri;
3024 if (isset($_SERVER[
'REQUEST_URI'])) {
3026 array(
'url' => ltrim(preg_replace(
'#^https?://.*?/#i',
'', rawurldecode($_SERVER[
'REQUEST_URI'])),
'/')),
3027 array(
'url' => ltrim(preg_replace(
'#^https?://.*?/#i',
'', rawurldecode($url)),
'/'))
3029 if ($data[0][
'url'] != $data[1][
'url']) {
3031 $data[0][
'info'] = self::getUrlInfo($data[0][
'url']);
3032 $data[1][
'info'] = self::getUrlInfo($data[1][
'url']);
3033 unset($data[0][
'info'][
'params'][
'p'], $data[1][
'info'][
'params'][
'p']);
3035 $data[0][
'info'][
'suffix'] == $data[1][
'info'][
'suffix']
3036 &&
sizeof($data[0][
'info'][
'params']) ==
sizeof($data[1][
'info'][
'params'])
3037 &&
sizeof($data[0][
'info'][
'parts']) ==
sizeof($data[1][
'info'][
'parts'])
3040 foreach ($data[0][
'info'][
'params'] as $key => $value) {
3041 if ($value != $data[1][
'info'][
'params'][$key]) {
3046 foreach ($data[0][
'info'][
'parts'] as $key => $value) {
3047 $value = mb_strtoupper($value);
3048 $data[1][
'info'][
'parts'][$key] = mb_strtoupper($data[1][
'info'][
'parts'][$key]);
3050 $value != $data[1][
'info'][
'parts'][$key]
3051 && $value != urldecode($data[1][
'info'][
'parts'][$key])
3073 $url = str_replace(
'&',
'&', $url);
3076 'params' => self::getUrlParams($url),
3077 'query' => (
string) parse_url($url, PHP_URL_QUERY),
3078 'protocol' => ($scheme = parse_url($url, PHP_URL_SCHEME)) ?
"$scheme://" : null,
3079 'anchor' => parse_url($url, PHP_URL_FRAGMENT)
3083 if (($dot = strrpos($url,
'.')) !==
false) {
3084 $info[
'suffix'] = preg_split(
'/[\/?#]/', substr($url, $dot))[0];
3088 if (preg_match(
'/\/_\/([^?#]+)/', $url, $match)) {
3089 $info[
'params'][
'pool'] = urldecode($match[1]);
3093 $info[
'parts'] = array_filter(explode(
'/', parse_url($url, PHP_URL_PATH)),
function($value) {
3094 return $value !==
'';
3096 $info[
'parts'] = array_map(
function($value) {
3097 if (preg_match(
'/^(.*?)\./', $value, $match)) {
3100 if (substr_count($value,
'-') % 2 == 0) {
3101 $value = preg_replace(
'/^([^-]*).*?$/',
'$1', $value);
3103 $value = preg_replace(
'/^([^-]*-[^-]*).*?$/',
'$1', $value);
3110 $info[
'parts'] = array_map(
'self::encode_path', $info[
'parts']);
3123 if (self::file_exists($file)) {
3124 $cache = self::getCache();
3125 $cache_key =
'getFileInfo' . md5($file);
3126 $info = $cache->get($cache_key);
3128 if ($info === null || filemtime($file) > $cache->getLastChanged()) {
3131 $finfo =
new finfo();
3132 $mime_type = $finfo->file($file, FILEINFO_MIME_TYPE);
3135 $info[
'mime'] = $mime_type;
3137 if (stripos($mime_type,
'video/') === 0) {
3140 self::exec(
'ffprobe', [
'-v',
'error',
'-select_streams',
'v:0',
'-show_entries',
'stream=height,width',
'-of',
'csv=s=x:p=0', $file], $output);
3141 $s = explode(
'x', $output[0]);
3142 $info[
'width'] = (int)$s[0];
3143 $info[
'height'] = (int)$s[1];
3146 self::exec(
'ffprobe', [
'-v',
'error',
'-show_entries',
'format=duration',
'-of',
'default=nw=1:nk=1', $file], $output);
3147 $s = ceil((
float) $output[0]);
3148 $info[
'duration'] = $s
3149 ? sprintf(
'%02d:%02d:%02d', $s / 3600, $s / 60 % 60, $s % 60)
3151 } elseif ($size = @getimagesize($file)) {
3153 $info[
'width'] = $size[0];
3154 $info[
'height'] = $size[1];
3157 $cache->set($cache_key, $info);
3170 $virtual_hosts = $h = array();
3172 $file_name = $GLOBALS[
'egotec_conf'][
'var_dir'].
'conf/virtual_hosts.ini';
3173 if (self::file_exists($file_name)) {
3174 $virtual_hosts = parse_ini_file($file_name,1);
3176 foreach($virtual_hosts as $k => $v) {
3177 $h[mb_strtolower($k)] = $v;
3191 return array(
'jpg',
'jpeg',
'gif',
'png',
'bmp',
'svg',
'ico');
3193 return array(
'image/gif',
'image/png',
'image/jpeg',
'image/jpg');
3195 return array(
'zip',
'rar',
'tar',
'gz',
'bz2',
'7z');
3197 return array(
'mp4',
'ogg',
'webm');
3199 throw new Exception(
'Format type does not exist.');
3213 public static function sortPages($pages, $sorttype =
'field', $sortby =
'id', $sortdirection =
"asc")
3216 if (gettype($pages) ==
'object')
3218 $pagesnew = array();
3219 foreach ($pages as $p)
3226 if (is_array($pages))
3228 usort($pages,
function($a, $b) use ($sorttype, $sortby, $sortdirection) {
3231 array(
'ä',
'ö',
'ü',
'ß'),
3232 array(
'ae',
'oe',
'ue',
'ss'),
3238 return $sortdirection ==
'asc' ? strnatcmp($v1, $v2) : strnatcmp($v2, $v1);
3255 return 'http' . ($https || $_SERVER[
'HTTPS'] ==
'on' || $_SERVER[
'HTTP_X_FORWARDED_PROTO'] ==
'https' 3256 ?
's' :
'') .
'://';
3265 return ($_SERVER[
'HTTP_HOST']
3266 ? self::getProtocol().$_SERVER[
'HTTP_HOST']
3267 : rtrim($GLOBALS[
'egotec_conf'][
'local_server_access'],
'/'))
3268 .$GLOBALS[
'egotec_conf'][
'url_dir'];
3278 $cache_file = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'disk_usage';
3279 if (!$recalc && self::file_exists($cache_file)) {
3280 $usage = unserialize(self::file_get_contents($cache_file));
3285 'elements' => array(
3288 'label' => $GLOBALS[
'auth']->translate(
'System'),
3289 'color' =>
'#f8482b',
3291 $GLOBALS[
'egotec_conf'][
'lib_dir'],
3292 $GLOBALS[
'egotec_conf'][
'bin_dir'],
3293 $GLOBALS[
'egotec_conf'][
'egotec_dir'].
'pub'.DIRECTORY_SEPARATOR
3299 'label' => $GLOBALS[
'auth']->translate(
'Backups'),
3300 'color' =>
'#0e88f0',
3302 $GLOBALS[
'egotec_conf'][
'backup_dir']
3306 'label' => $GLOBALS[
'auth']->translate(
'Cache'),
3307 'color' =>
'#2fedac',
3309 $GLOBALS[
'egotec_conf'][
'cache_dir'],
3310 $GLOBALS[
'egotec_conf'][
'cachemedia_dir']
3314 'label' => $GLOBALS[
'auth']->translate(
'Logs'),
3315 'color' =>
'#edc72f',
3317 $GLOBALS[
'egotec_conf'][
'log_dir']
3321 'label' => $GLOBALS[
'auth']->translate(
'Temporär'),
3322 'color' =>
'#efd2de',
3324 $GLOBALS[
'egotec_conf'][
'tmp_dir']
3328 'label' => $GLOBALS[
'auth']->translate(
'Medien'),
3329 'color' =>
'#4fac0b',
3331 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media'.DIRECTORY_SEPARATOR
3335 'customer' => array(
3337 'label' => $GLOBALS[
'auth']->translate(
'Skripte'),
3338 'color' =>
'#deefd2',
3340 $GLOBALS[
'egotec_conf'][
'site_dir']
3344 'label' => $GLOBALS[
'auth']->translate(
'Designs'),
3345 'color' =>
'#8813f5',
3347 $GLOBALS[
'egotec_conf'][
'skin_dir']
3355 'unknown' => array(),
3358 'time' => microtime(
true),
3363 $total = (float) @disk_total_space($GLOBALS[
'egotec_conf'][
'egotec_dir']);
3364 $origin = md5($total);
3365 $usage[
'total'][$origin] = $total;
3366 $usage[
'used'][$origin] = 0;
3367 $usage[
'free'][$origin] = 0;
3368 $usage[
'unknown'][$origin] = 0;
3369 $usage[
'dirs'][$origin] = $GLOBALS[
'egotec_conf'][
'egotec_dir'];
3370 $total_values = array($usage[
'total'][$origin]);
3371 foreach ($usage[
'elements'] as $element => $types) {
3372 foreach ($types as $type => $data) {
3373 foreach ($data[
'dirs'] as $dir) {
3374 if (!self::file_exists($dir)) {
3375 egotec_warning_log(
"Path '$dir' doesn't exist.");
3378 $cms_dir = self::getDirectorySize($dir);
3379 $used = (float) $cms_dir[
'size'];
3380 $usage[
'elements'][$element][$type][
'value'] += $used;
3381 if (strpos($dir, $GLOBALS[
'egotec_conf'][
'egotec_dir']) !== 0) {
3382 $base_dir = substr($dir, 0,
3383 strrpos(rtrim($dir, DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR) + 1
3385 $total = (float) @disk_total_space($base_dir);
3388 foreach ($total_values as $size) {
3389 if ($total == $size) {
3395 $origin = md5($total);
3396 $usage[
'total'][$origin] += $total;
3397 $usage[
'dirs'][$origin] = $base_dir;
3398 $total_values[] = $total;
3402 $origin = md5($total_values[0]);
3404 $usage[
'used'][$origin] += $used;
3405 $usage[
'elements'][$element][$type][
'origin'] = $origin;
3409 foreach ($usage[
'total'] as $origin => $value) {
3410 $usage[
'free'][$origin] = $value - $usage[
'used'][$origin];
3413 $free = (float) @disk_free_space($usage[
'dirs'][$origin]);
3414 if ($free > 0 && $free < $usage[
'free'][$origin]) {
3415 $usage[
'unknown'][$origin] = $usage[
'free'][$origin] - $free;
3416 $usage[
'used'][$origin] += $usage[
'unknown'][$origin];
3417 $usage[
'free'][$origin] = $free;
3419 $usage[
'unknown'][$origin] = 0;
3422 $usage[
'time'] = microtime(
true) - $usage[
'time'];
3434 return isset($_SERVER[
'HTTP_X_FORWARDED_FOR']) ? $_SERVER[
'HTTP_X_FORWARDED_FOR'] : $_SERVER[
'REMOTE_ADDR'];
3444 if (function_exists(
'gzdecode')) {
3447 $tmp = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'gzDecode');
3451 $output = ob_get_clean();
3469 if (preg_match_all(
'/index\.php\?[^>"\' ]+/msi', $content, $matches)) {
3470 foreach ($matches[0] as $url) {
3471 $info = self::getUrlInfo($url);
3472 if (!empty($info[
'params'])) {
3474 foreach ($search as $param => $value) {
3476 !isset($info[
'params'][$param])
3477 || $info[
'params'][$param] != $value
3480 } elseif (isset($replace[$param])) {
3481 $info[
'params'][$param] = $replace[$param];
3487 $query = http_build_query($info[
'params']);
3488 $content = str_replace($url,
'index.php?'.$query, $content);
3504 return strtr(base64_encode($s),
'+/=',
'-_,');
3515 return base64_decode(strtr($s,
'-_,',
'+/='));
3526 foreach ($array as $value) {
3527 if (is_array($value)) {
3528 $result = array_merge($result, self::arrayValuesRecursive($value));
3533 return array_unique($result);
3546 array_walk_recursive($array,
function($a, $k) use (&$result, $callback) {
3547 if (!is_array($result[$k])) {
3548 $result[$k] = array();
3550 if (!empty($callback)) {
3551 $a = call_user_func_array($callback, array($a));
3553 array_push($result[$k], $a);
3554 $result[$k] = array_values(array_unique($result[$k]));
3565 return $GLOBALS[
'egotec_conf'][
'devserver'] || self::file_exists($GLOBALS[
'egotec_conf'][
'egotec_dir'].
'.svn');
3576 return self::checkLicence($GLOBALS[
'egotec_conf'][
'lib_dir'].
'stats') && $GLOBALS[
'egotec_conf'][
'piwik'][
'auth_url'] && $token_auth;
3587 if (($p = strstr($k,
'.',
true)) !==
false) {
3589 return self::getAssocValue($a[$p], ltrim(strstr($k,
'.'),
'.'));
3605 if (($p = strstr($k,
'.',
true)) !==
false) {
3606 return self::setAssocValue($a[$p], ltrim(strstr($k,
'.'),
'.'), $v);
3621 public static function getJSON($path, $values = array(), $combine =
false, $ignore = []) {
3622 $file = self::file_get_contents($path);
3623 if (!empty($file) && is_array($values2 = json_decode(trim($file),
true))) {
3624 $new_values = array_replace_recursive($values, $values2);
3626 $recursive =
function($value, $keys = []) use (&$recursive, $values, $ignore) {
3627 if (!empty($keys) && in_array(implode(
'.', $keys), $ignore)) {
3629 } elseif (is_array($value)) {
3630 foreach ($value as $k => $v) {
3631 $value[$k] = $recursive($v, array_merge($keys, [$k]));
3635 && in_array($value[0], [
'+',
'-'])
3638 if ($old_value === null) {
3641 $array_value = explode(
',', substr($value, 1));
3642 switch ($value[0]) {
3644 $value = implode(
',', array_unique(array_merge(explode(
',', $old_value), $array_value)));
3647 $value = implode(
',', array_unique(array_diff(explode(
',', $old_value), $array_value)));
3649 return trim($value,
',');
3653 return $recursive($new_values);
3667 public static function setJSON($path, $values = array()) {
3668 return self::file_put_contents($path, str_replace(
" ",
"\t", json_encode($values, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)));
3678 return md5(is_array($value) ? json_encode($value, JSON_FORCE_OBJECT) : $value);
3689 $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
3690 switch ($GLOBALS[
'egotec_conf'][
'site_cache_type']) {
3692 require_once(
'base/Ego_Cache_apc.php');
3693 $cache =
new Ego_Cache_apc($path);
3696 require_once(
'base/Ego_Cache_apcu.php');
3697 $cache =
new Ego_Cache_apcu($path);
3700 require_once(
'base/Ego_Cache_shm.php');
3701 $cache =
new Ego_Cache_shm($path);
3704 require_once(
'base/Ego_Cache_file.php');
3705 $cache =
new Ego_Cache_file($path);
3718 return md5(serialize($a)) == md5(serialize($b));
3737 public static function createCSV($path, $data, $delimiter =
',', $enclosure =
'"', $escape_char =
'\'') {
3738 $fp = fopen($path,
'a');
3739 foreach ($data as $line) {
3740 fputcsv($fp, $line, $delimiter, $enclosure, $escape_char);
3765 public static function createXML($path, $data, $root =
'root', $version =
'1.0', $encoding =
'UTF-8') {
3766 $xml =
'<?xml version="' . $version .
'" encoding="' . $encoding .
'"?>';
3767 $recursive =
function($data) use (&$recursive) {
3769 foreach ($data as $key => $value) {
3770 if (is_array($value)) {
3771 $result .=
"<{$key}>" . $recursive($value) .
"</{$key}>";
3773 if (is_string($value)) {
3774 $value =
"<![CDATA[{$value}]]>";
3776 $result .=
"<{$key}>{$value}</{$key}>";
3781 self::file_put_contents($path,
"{$xml}<{$root}>" . $recursive($data) .
"</{$root}>");
3791 $hex = str_replace(
"#",
"",$color);
3793 if (strlen($hex) != 3 && strlen($hex) != 6) {
3795 } elseif (strlen($hex) == 3) {
3796 $hex = str_split($hex);
3797 $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2];
3800 $r = hexdec(substr($hex,0,2));
3801 $g = hexdec(substr($hex,2,2));
3802 $b = hexdec(substr($hex,4,2));
3803 $yiq = (($r*299)+($g*587)+($b*114))/1000;
3804 return ($yiq >= 128) ?
'#000000' :
'#ffffff';
3817 if (!$once || !in_array($src, self::$includedHtml)) {
3818 $type = mb_strtolower(ltrim(strrchr($src,
'.'),
'.'));
3821 $html =
'<link rel="stylesheet" property="stylesheet" href="' . $src .
'" type="text/css" />';
3824 $html =
'<script type="text/javascript" src="' . $src .
'"></script>';
3826 self::$includedHtml[] = $src;
3838 return $_SESSION[
'auth_id'] === null;
3848 return $GLOBALS[
'egotec_conf'][
'admin_mail'] ? $GLOBALS[
'egotec_conf'][
'admin_mail'] :
'support@egotec.com';
3862 !preg_match(
'#\.php$#', $path)
3873 private static function shell(String $php_command, String $command, Array $params = array(), Array &$output = null, &$return_var = null) {
3875 strpos($command,
" ") ===
false 3876 || ($command[0] ==
'"' && $command[-1] ==
'"' && strpos(substr($command, 1, -1),
'"') ===
false)
3877 ))
throw new RuntimeException(
'Please use parameter binding for security reasons!');
3881 foreach ($params as $value) {
3882 if ($value[0]==
'-') {
3883 $pos = strpos($value,
' ');
3884 $pos2 = strpos($value,
'=');
3885 if ($pos2 && $pos2>$pos) {
3889 $command.=
" ".substr($value, 0, $pos).
" ".escapeshellarg(substr($value, $pos+1));
3891 $command.=
" ".$value;
3894 $command.=
" ".(in_array($value, array(
'<',
'<<',
'>',
'>>',
'&&',
'2>&1')) ? $value : escapeshellarg($value));
3898 egotec_warning_log($php_command.
' executing '.$command);
3900 switch ($php_command) {
3902 return exec($command, $output, $return_var);
3904 return system($command, $return_var);
3921 public static function exec(String $command, Array $params = array(), Array &$output = null, &$return_var = null) {
3922 return Ego_System::shell(
'exec', $command, $params, $output, $return_var);
3937 public static function system(String $command, Array $params = array(), &$return_var = null) {
3939 return Ego_System::shell(
'system', $command, $params, $output, $return_var);
3950 $GLOBALS[
'egotec_conf'][
'local_server_ips']
3951 ? explode(
',', $GLOBALS[
'egotec_conf'][
'local_server_ips'])
3952 : self::getDefaultLocalServerIps()
3962 return array(
"127.0.0.1",
"localhost",
"::1",
"0:0:0:0:0:0:0:1", $_SERVER[
'SERVER_ADDR']);
static includeHtml($src, $once=true)
static endless($string='', $flush=true)
static getFilePath($dir, $file)
static redirect($location, $header=302)
static getChecksum($value)
static getVariantFiles($type, $name, $path, $skip=array(), $parent='')
static checkLicence($ini_path)
static file_put_contents($filename, $data, $flags=0, $context=null)
static stringEncode($string, $from='UTF-8', $to='UTF-8')
static eternalCache($active)
static deldir($location, $del=true, $without='', $rename=true)
static checkRequirePath($path)
static getLatestEgotecVersion()
static urltopage($url, $params=array(), $only_site=false, $error_page=false, $commit_params=false)
static encode_path($url, $id=0)
static getDefaultLocalServerIps()
static arrayFlatRecursive($array, $callback=null)
static getJSON($path, $values=array(), $combine=false, $ignore=[])
static getAllSites($username='', $perm='', $table=false, $type='')
const REGEX_EMAIL_OPTIONAL
static getUrlParams($url='')
static sortPages($pages, $sorttype='field', $sortby='id', $sortdirection="asc")
static flushHeaders($headers)
static file_exists($file)
static system(String $command, Array $params=array(), &$return_var=null)
static getSkins($more_themes=array())
static parseCsvLine($str, $delimiter=';', $qualifier='"', $qualifierEscape = '\)
static isEmptyContent($str)
static parseIniFile($file)
static decode_path( $url)
static replaceLinks($content, $search, $replace)
static isCurrentUrl($url)
static byte_format($byte)
static checkRequirements()
static getCache($path='_system')
static escape($string, $esc_type='html', $char_set='UTF-8')
static setCronLock($expiry_date=0, $lock_msg="")
static getMimeTypes($ext='')
static clearCacheAllSites()
static createCSV($path, $data, $delimiter=',', $enclosure='"', $escape_char = '\)
static mkdir($dir, $mode=0755, $recursive=true)
static getCluster($site=null)
static clearTypeCache($site_name='')
static write_ini_file($path, $assoc_array=array())
static getContrastColor($color)
static createIdentity($params)
static setAssocValue(&$a, $k, $v)
static getDiff($diff1, $diff2)
static getRequest($request=array())
static getExceptionURL($params=array(), $placeholder=false)
static getAssocValue($a, $k)
static getUrlInfo($url, $encode=false)
static log($file, $message)
static createXML($path, $data, $root='root', $version='1.0', $encoding='UTF-8')
static file_get_contents($filename, $utf8=true, $context=null)
static copy($src, $dest, $except='', $useLinks=false)
static setJSON($path, $values=array())
static byIdentity($identity, $param=array())
static getDesktopSite($site)
const REGEX_EMAIL_ESCAPED
static checkEncoding($from='CP1252', $to='UTF-8', $original, $converted)
static getProtocol($https=false)
static getFallbackFile($type, $name, $path, $skip=array('module'), $url=false, $relative=false, $parent='')
static getFileInfo($file)
static dateEncode($string)
static commandExists($cmd)
static getDirectorySize($pfad, &$links=array())
static arrayValuesRecursive($array)
static filterNonUtf8($s, $substitute="", $strict=false)
static header($header, $replace=true)
static exec(String $command, Array $params=array(), Array &$output=null, &$return_var=null)
static isStatistic($token_auth)
static getDiskUsage($recalc=false)
static getFiles($type, $name, $path, $skip=array(), $parent='', $return_path=false, $get_variants=true)
static truncate($string, $length, $etc='...', $break_words=false, $middle=false)