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])?$';
50 101 =>
'Switching Protocols',
54 203 =>
'Non-Authoritative Information',
56 205 =>
'Reset Content',
57 206 =>
'Partial Content',
58 207 =>
'Multi-Status',
59 208 =>
'Already Reported',
61 300 =>
'Multiple Choices',
62 301 =>
'Moved Permanently',
65 304 =>
'Not Modified',
68 307 =>
'Temporary Redirect',
69 308 =>
'Permanent Redirect',
71 401 =>
'Unauthorized',
72 402 =>
'Payment Required',
75 405 =>
'Method Not Allowed',
76 406 =>
'Not Acceptable',
77 407 =>
'Proxy Authentication Required',
78 408 =>
'Request Timeout',
81 411 =>
'Length Required',
82 412 =>
'Precondition Failed',
83 413 =>
'Request Entity Too Large',
84 414 =>
'Request-URI Too Long',
85 415 =>
'Unsupported Media Type',
86 416 =>
'Requested Range Not Satisfiable',
87 417 =>
'Expectation Failed',
88 420 =>
'Policy Not Fulfilled',
89 421 =>
'Misdirected Request',
90 422 =>
'Unprocessable Entity',
92 424 =>
'Failed Dependency',
93 426 =>
'Upgrade Required',
94 428 =>
'Precondition Required',
95 429 =>
'Too Many Requests',
96 431 =>
'Request Header Fields Too Large',
97 451 =>
'Unavailable For Legal Reasons',
98 500 =>
'Internal Server Error',
99 501 =>
'Not Implemented',
100 502 =>
'Bad Gateway',
101 503 =>
'Service Unavailable',
102 504 =>
'Gateway Timeout',
103 505 =>
'HTTP Version Not Supported',
104 506 =>
'Variant Also Negotiates',
105 507 =>
'Insufficient Storage',
106 508 =>
'Loop Detected',
107 509 =>
'Bandwidth Limit Exceeded',
108 510 =>
'Not Extended',
109 511 =>
'Network Authentication Required'
118 private static $includedHtml = array();
125 private static $fallbackMapping = array();
132 private static $cache = array();
139 private static $devMode =
null;
147 if (self::file_exists($file = $GLOBALS[
'egotec_conf'][
'var_dir'] .
'conf/global.json')) {
148 $global = json_decode(self::file_get_contents($file),
true);
153 if (!empty($global)) {
162 $set_value =
function($meta, $key) {
163 if (isset($meta[
'value'])) {
165 } elseif (isset($meta[
'env'])) {
167 ?? $_SERVER[$meta[
'env']]
168 ?? (getenv($meta[
'env'],
true) ?: getenv($meta[
'env']))
173 if (is_array($global[
'system'])) {
174 foreach ($global[
'system'] as $key => $meta) {
175 if (is_array($meta[
'values'])) {
176 foreach ($meta[
'values'] as $value) {
177 $set_value($value, $key);
180 $set_value($meta, $key);
194 return (
bool) preg_match(
'/'.self::REGEX_EMAIL_ESCAPED.
'/msi', $email);
207 return $default ?:
'User-agent: *';
218 public static function escape($string, $esc_type =
'html', $char_set =
'UTF-8') {
221 return htmlspecialchars($string, ENT_QUOTES, $char_set);
224 return htmlentities($string, ENT_QUOTES, $char_set);
227 return rawurlencode($string);
230 return str_replace(
'%2F',
'/',rawurlencode($string));
234 return preg_replace(
"%(?<!\\\\)'%",
"\\'", $string);
239 for ($x=0; $x < strlen($string); $x++) {
240 $return .=
'%' . bin2hex($string[$x]);
246 for ($x=0; $x < strlen($string); $x++) {
247 $return .=
'&#x' . bin2hex($string[$x]) .
';';
253 for ($x=0; $x < strlen($string); $x++) {
254 $return .=
'&#' . ord($string[$x]) .
';';
260 return strtr($string, array(
'\\'=>
'\\\\',
"'"=>
"\\'",
'"'=>
'\\"',
"\r"=>
'\\r',
"\n"=>
'\\n',
'</'=>
'<\/'));
264 return str_replace(array(
'@',
'.'),array(
' [AT] ',
' [DOT] '), $string);
269 for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
270 $_ord = ord(substr($string, $_i, 1));
273 $_res .=
'&#' . $_ord .
';';
276 $_res .= substr($string, $_i, 1);
294 $cache_dir = dir($GLOBALS[
'egotec_conf'][
'cache_dir']);
296 while ($dir = $cache_dir->read()) {
299 && is_dir($cache_dir->path.$dir)
300 && (!$site_name || $dir == $site_name)
302 $directories = glob($cache_dir->path.$dir.
'/types*');
303 if (is_array($directories)) {
304 foreach ($directories as $file) {
308 @unlink($cache_dir->path.$dir.
'/classes.cache');
322 Ego_System::mkdir($GLOBALS[
'egotec_conf'][
'cache_dir'].
'compiled'.DIRECTORY_SEPARATOR.
'_admin');
324 switch ($GLOBALS[
'egotec_conf'][
'site_cache_type'])
327 require_once(
'base/Ego_Cache_apcu.php');
328 $cache =
new Ego_Cache_apcu($path);
332 require_once($GLOBALS[
'egotec_conf'][
'var_dir'].
'lib/Ego_Cache_custom.php');
333 $cache =
new Ego_Cache_custom($path);
337 require_once(
'base/Ego_Cache_file.php');
338 $cache =
new Ego_Cache_file($path);
360 switch ($GLOBALS[
'egotec_conf'][
'site_cache_type'])
363 require_once(
'base/Ego_Cache_apcu.php');
364 $cache =
new Ego_Cache_apcu($path);
368 require_once($GLOBALS[
'egotec_conf'][
'var_dir'].
'lib/Ego_Cache_custom.php');
369 $cache =
new Ego_Cache_custom($path);
373 require_once(
'base/Ego_Cache_file.php');
374 $cache =
new Ego_Cache_file($path);
385 require_once(
'base/Site.php');
386 $dir = dir($GLOBALS[
'egotec_conf'][
'site_dir']);
387 while ($file = $dir->read())
389 if ($file[
'0']!=
'.' && is_dir($dir->path.$file))
392 $site =
new Site($file);
393 foreach ($site->getLanguages() as $lang)
395 $site->setLanguage($lang);
398 }
catch (Exception $e)
418 $pos = strrpos($string,
'/');
421 $pos = strrpos($string, DIRECTORY_SEPARATOR);
426 $string =
' '.$string;
428 $pos = ((int)$pos)+1;
429 $string = substr($string, 0, $pos).
' '.substr($string, $pos);
433 foreach($result as $key => $value)
435 $result[$key] = ltrim($value);
449 return $pathinfo[
'basename'];
462 return preg_replace([
463 '/\x{2010}|\x{2011}|\x{2012}|\x{2013}|\x{2014}|\x{2015}|–|—/msiu',
464 '/\x{201c}|\x{201d}|\x{201e}|\x{201f}|„|“|”/msiu',
465 '/\x{2018}|\x{2019}|\x{2020}|\x{201a}|\x{201b}|‚|‘|’/msiu'
492 $substitute =
"\xEF\xBF\xBD";
499 |[\xC2-\xDF][\x80-\xBF]
500 | \xE0[\xA0-\xBF][\x80-\xBF]
501 | \xED[\x80-\x9F][\x80-\xBF]
502 |[\xF1-\xF3][\x80-\xBF]{3}
503 | \xF4[\x80-\x8F][\x80-\xBF]{2})
506 |[\xF1-\xF3][\x80-\xBF]{1,2}
507 | \xF4[\x80-\x8F][\x80-\xBF]?)
513 |[\xC2-\xDF][\x80-\xBF]
514 | \xE0[\xA0-\xBF][\x80-\xBF]
515 |[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
516 | \xED[\x80-\x9F][\x80-\xBF]
517 | \xF0[\x90-\xBF][\x80-\xBF]{2}
518 |[\xF1-\xF3][\x80-\xBF]{3}
519 | \xF4[\x80-\x8F][\x80-\xBF]{2})
521 |[\xE1-\xEC\xEE\xEF][\x80-\xBF]
523 | \xF0[\x90-\xBF][\x80-\xBF]?
524 |[\xF1-\xF3][\x80-\xBF]{1,2}
525 | \xF4[\x80-\x8F][\x80-\xBF]?)
533 $s2 = mb_substr($s, 0, 1000);
534 preg_replace_callback($utf8_pattern,
function($matches) use ($substitute, &$utf8_string) {
535 if (isset($matches[2]) || isset($matches[3])) {
536 $utf8_string .= $substitute;
538 $utf8_string .= $matches[1];
541 $s = mb_substr($s, 1000);
544 $utf8_string = str_replace(
"\xe2\x80".chr(168),
" ", $utf8_string);
547 return filter_var($utf8_string, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW);
562 foreach($data as $key => $value)
564 if(is_array($value) || is_string($value))
574 return (is_string($data) ? self::filterNonUtf8($data) : $data);
587 public static function checkEncoding($from=
'CP1252', $to=
'UTF-8', $original, $converted)
589 $converted2 = iconv($to, $from, $converted);
592 if ($original === $converted2)
615 public static function stringEncode($string, $from=
'UTF-8', $to=
'UTF-8')
617 if ($string ==
'')
return $string;
619 $source_encoding = array(
620 'CP1250',
'CP1251',
'CP1252',
'CP1253',
'CP1254',
'CP1255',
'CP1256',
'CP1257',
621 'ISO-8859-2',
'ISO-8859-5',
'ISO-8859-1',
'ISO-8859-7',
'ISO-8859-9',
'ISO-8859-8',
'ISO-8859-6',
'ISO-8859-4',
625 $converted = iconv($from, $to, $string);
632 foreach($source_encoding as $from)
634 $converted = iconv($from, $to, $string);
641 return "Die Zeichenkette konnte leider nicht korrekt in UTF-8 umgewandelt werden.";
652 return strtotime($string);
669 public static function mkdir($dir, $mode = 0755, $recursive =
true) {
670 $mode = !empty($GLOBALS[
'egotec_conf'][
'chmod']) ? octdec($GLOBALS[
'egotec_conf'][
'chmod']) : $mode;
671 $dir = strtr($dir,
'\\/', DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR);
672 $dir = str_replace(
'/./',
'/', $dir);
677 if (@
mkdir($dir, $mode, $recursive)) {
683 if ($GLOBALS[
'egotec_conf'][
'mkdir_warning']) {
684 egotec_warning_log(
'Filesystem-Fehler beim Anlegen von ' . $dir .
"\n\n" . get_backtrace(0));
686 throw new Exception(
'Filesystem-Fehler beim Anlegen von ' . $dir);
732 $parse_url = @parse_url($url);
736 if ($parse_url !==
false) {
737 $info[
'protokoll'] = $parse_url[
'scheme'];
738 $info[
'host'] = $parse_url[
'host'];
739 $info[
'port'] = $parse_url[
'port'];
740 $info[
'pfad'] = dirname($parse_url[
'path']);
741 $info[
'datei'] =
basename($parse_url[
'path']);
742 $info[
'query'] = str_replace(
'&',
'&', $parse_url[
'query']);
743 $info[
'mark'] = $parse_url[
'fragment'];
745 foreach (explode(
'&', $info[
'query']) as $param_pair) {
746 $key = strtok($param_pair,
'=');
747 $value = strtok(
'=');
748 $info[
'parameter'][$key] = $value;
751 $info[
'parse_url'] = $parse_url;
765 preg_match(
'/^.*?([?#]|$)/i', $url, $m1)
766 && preg_match(
'/^(.*\/)(.*)$/', $m1[0], $m2)
768 $pos = mb_strrpos($m2[2],
'.');
769 if ($pos !==
false) {
770 $suffix = rtrim(mb_substr($m2[2], $pos + 1),
'?#');
771 if ($suffix != ($new_suffix = preg_replace(
'/^([a-z0-9]+).*?$/i',
'$1', $suffix))) {
772 $url = $m2[1] . mb_substr($m2[2], 0, $pos) .
'.' . $new_suffix . mb_substr($url, mb_strlen($m1[0]) - mb_strlen($m1[1]));
803 public static function deldir($location, $del=
true, $without=
'',$rename=
true)
807 throw new Exception(
'deldir needs location not to be empty.');
810 if (substr($location,-1) !=
'/')
812 $location = $location.
'/';
814 $location = strtr($location,
'/', DIRECTORY_SEPARATOR);
815 if (is_dir($location))
817 $error =
"Filesystem-Fehler beim Löschen von ".$location;
824 $location = strtr($location,
'/', DIRECTORY_SEPARATOR);
825 if (substr($location,-1) != DIRECTORY_SEPARATOR)
827 $location.= DIRECTORY_SEPARATOR;
836 $tmp = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'deldir_'.md5(microtime()).DIRECTORY_SEPARATOR;
839 $tmp = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'deldir_'.md5(microtime()).DIRECTORY_SEPARATOR;
841 if (@rename($location,$tmp) ===
false)
843 if (is_dir($location))
845 $dir = dir($location);
846 while ($file = $dir->read())
850 if (is_dir($dir->path.$file)) {
853 @unlink($dir->path.$file);
867 $directory = dir($location);
868 $without_nodel =
false;
869 while (is_object($directory) &&
false !== ($file = $directory->read()))
872 if (! ( $without && $without[$file] ))
874 if (is_dir($directory->path.$file) && $file !=
'..' && $file !=
'.')
878 } elseif (is_file($directory->path.DIRECTORY_SEPARATOR.$file))
880 if (unlink($directory->path.$file) ===
false)
throw new Exception($error);
884 $without_nodel =
true;
887 if (is_object($directory)) $directory->close();
888 if ( !$without_nodel &&
false !== $del )
895 chdir($GLOBALS[
'egotec_conf'][
'egotec_dir']);
896 $result = @rmdir($location);
902 throw new Exception($error);
906 } elseif (is_file($location)) {
921 foreach ($headers as $key => $value)
924 $GLOBALS[
'egotec'][
'response_headers'][$key] = $value;
934 public static function flush($string =
'') {
935 if ($GLOBALS[
'live_system_migrate'] || $GLOBALS[
'monitoring']) {
937 $GLOBALS[
'_output'] .= $string;
939 while (ob_get_level()) {
958 public static function endless($string =
'', $flush =
true) {
959 if (php_sapi_name() ==
'fpm-fcgi') {
963 ignore_user_abort(
true);
964 @session_write_close();
986 $clean =
function($array) use (&$clean) {
987 foreach ($array as $key => $value) {
988 if (is_array($value)) {
989 $array[$key] = $clean($value);
991 $value = mb_strtolower($value);
992 if ($value ===
'null' || $value ===
'false') {
994 }
else if ($value ===
'true') {
997 $array[$key] = str_replace(
'"',
'\"', str_replace(
'\"',
'"', $array[$key]));
1002 $assoc_array = $clean($assoc_array);
1004 $path = strtr($path,
'/', DIRECTORY_SEPARATOR);
1005 $single_content = $assoc_content =
'';
1006 foreach ($assoc_array as $key => $item) {
1007 if (is_array($item)) {
1008 $assoc_content.=
"\n[".$key.
"]\n";
1009 foreach ($item as $key2 => $item2) {
1010 if ($item2 !=
'Array') {
1011 $assoc_content.= $key2.
'="'.$item2.
'"'.
"\n";
1015 $single_content.= $key.
'="'.$item.
'"'.
"\n";
1018 $content = $single_content.
"\n".$assoc_content;
1019 if (!$handle = @fopen($path,
'w')) {
1022 if (!@fwrite($handle, $content)) {
1043 public static function header($header, $replace =
true)
1045 if (is_numeric($header)) {
1047 if ($header == 403 && preg_match(
'/(Microsoft Office Word|ms-office)/i', $_SERVER[
'HTTP_USER_AGENT'])) {
1053 if (isset(self::$statusCodes[$header])) {
1054 $GLOBALS[
'stats'][
'status'] = $header;
1055 $GLOBALS[
'_SERVER'][
'REDIRECT_STATUS'] = $header;
1056 $header = ($_SERVER[
'SERVER_PROTOCOL'] ??
'') .
' ' . $header .
' ' . self::$statusCodes[$header];
1058 throw new Exception(
'Unsupported HTTP Status Code');
1062 if ($code == 404 && !empty($_REQUEST[
'id'])) {
1063 $_REQUEST[
'original_id'] = $_REQUEST[
'id'];
1066 header($header, $replace);
1067 $pos = strpos($header,
':');
1068 $key = substr($header, 0, $pos);
1069 $value = trim(substr($header, $pos+1));
1070 if ($pos ===
false) {
1074 if (!$replace && isset($GLOBALS[
'egotec'][
'response_headers'][$key])) {
1075 $GLOBALS[
'egotec'][
'response_headers'][$key] .=
", $value";
1077 $GLOBALS[
'egotec'][
'response_headers'][$key] = $value;
1089 self::header(
'Expires: ' . gmdate(
'D, d M Y H:i:s') .
' GMT');
1090 self::header(
'Cache-Control: no-store, no-cache, must-revalidate');
1091 self::header(
'Cache-Control: post-check=0, pre-check=0',
false);
1093 $GLOBALS[
'no_cache'] =
true;
1104 if (!$_REQUEST[
'doauth']) {
1105 $_SESSION[
'intranet_referer'] = str_replace(
'-doauth-logout',
'', (
1106 $_SESSION[
'redirect_referer'] ?? $_SERVER[
'HTTP_REFERER'] ?? $_SERVER[
'REDIRECT_URL'] ?? $_SERVER[
'REQUEST_URI']
1110 if (in_array($page->extra[
'next_page'], [
'last',
'current' ]) || !$_SESSION[
'intranet_referer']) {
1111 $_SESSION[
'intranet_referer'] = str_replace(
'-doauth-logout',
'', $_SERVER[
'REQUEST_URI']);
1128 public static function redirect($location, $header = 302, $params = []) {
1129 if (!empty($header)) {
1132 if (is_a($location,
'Page')) {
1133 $location = $location->getUrl($params);
1149 unset($_SESSION[
'egotec_licence'][$ini_path]);
1151 if (isset($_SESSION[
'egotec_licence'][$ini_path]))
1153 return $_SESSION[
'egotec_licence'][$ini_path];
1155 $ini_file = rtrim($ini_path,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.
'module.ini';
1158 $module = parse_ini_file($ini_file);
1159 $licence_array = file($GLOBALS[
'egotec_conf'][
'var_dir']
1160 .
'co'.
'nf'.
'/'.
'l'.
'ic'.
'en'.
'ce'.
'.'.
'eg'.
'ot'.
'ec'.
'.'.
'x'.
'ml');
1161 $company = trim($licence_array[4]);
1162 $num_named_users = trim($licence_array[7]);
1163 foreach($licence_array as $key => $value)
1165 if (trim($value) ==
'<module_'.$module[
'name'].
'>')
1167 if (trim($licence_array[$key+1]) == md5(
'2u4z#h76CN~JBSo'.$company.$num_named_users.$module[
'name']))
1169 return $_SESSION[
'egotec_licence'][$ini_path] =
true;
1175 return $_SESSION[
'egotec_licence'][$ini_path] =
false;
1186 public static function setCronLock($expiry_date = 0, $lock_msg =
"") {
1187 if ($GLOBALS[
'cron_fix_services']) {
1191 $original_expiry_date = $expiry_date;
1192 $original_lock_msg = $lock_msg;
1194 $lock_file = $GLOBALS[
'egotec_conf'][
'log_dir'].
'CRON'.((string)$GLOBALS[
'__CRON_LOCK_SUFFIX']).
'.LOCK';
1197 if (empty($lock_msg)) {
1198 $lock_msg = get_backtrace();
1202 if ($expiry_date == 0) {
1203 $expiry_date = time()+60*60;
1205 $expiry_date += time();
1208 $lock_content = array_merge(self::getDefaultCronLock($expiry_date), [
1209 'lock_msg' => $lock_msg
1217 self::file_put_contents($lock_file, json_encode($lock_content, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE));
1219 $lock_content = array_merge($lock_content, json_decode(self::file_get_contents($lock_file),
true) ?? []);
1220 $lock_time = strtotime($lock_content[
'expiry_date']);
1223 if (!empty($lock_content[
'pid']) && function_exists(
'posix_getsid') && @posix_getsid($lock_content[
'pid']) ===
false) {
1229 if ($lock_time > time()) {
1230 $msg =
"Neuer Lock konnte nicht gesetzt werden, da bereits ein Lock seit ".date(
"d.m.Y \u\m H:i:s", strtotime($lock_content[
'start_date'])).
" existiert.";
1231 $msg.=
"<br/>Dieser verfällt am ".date(
"d.m.Y \u\m H:i:s", $lock_time).
".";
1232 $msg.=
"<p>".$lock_msg.
"</p>";
1234 throw new Exception($msg);
1236 self::file_put_contents($lock_file, json_encode($lock_content, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE));
1247 private static function getDefaultCronLock($expiry_date) {
1249 'pid' => @getmypid(),
1250 'start_date' => date(
'Y-m-d H:i:s'),
1251 'expiry_date' => date(
'Y-m-d H:i:s', $expiry_date)
1261 $lock_file = $GLOBALS[
'egotec_conf'][
'log_dir'].
'CRON'.((string)$GLOBALS[
'__CRON_LOCK_SUFFIX']).
'.LOCK';
1263 if (self::file_exists($lock_file)) {
1264 @unlink($lock_file);
1274 $lock_file = $GLOBALS[
'egotec_conf'][
'log_dir'].
'CRON'.((string)$GLOBALS[
'__CRON_LOCK_SUFFIX']).
'.LOCK';
1276 if (!self::file_exists($lock_file)) {
1280 $fp = fopen($lock_file,
"a+");
1285 while (!flock($fp, LOCK_EX | LOCK_NB, $wouldblock)) {
1286 if ($wouldblock && $count++ < $timeout_secs) {
1294 flock($fp, LOCK_UN);
1298 $lock_content = json_decode(self::file_get_contents($lock_file),
true);
1301 if (!isset($lock_content[
'expiry_date']) || strtotime($lock_content[
'expiry_date']) < time()) {
1305 return $lock_content[$cron_variable];
1316 public static function addCronLock($cron_variable, $value, $expiry_date = 0) {
1317 $lock_file = $GLOBALS[
'egotec_conf'][
'log_dir'].
'CRON'.((string)$GLOBALS[
'__CRON_LOCK_SUFFIX']).
'.LOCK';
1318 $fp = fopen($lock_file,
"a+");
1323 while (!flock($fp, LOCK_EX | LOCK_NB, $wouldblock)) {
1324 if ($wouldblock && $count++ < $timeout_secs) {
1332 flock($fp, LOCK_UN);
1336 $lock_content = json_decode(self::file_get_contents($lock_file),
true);
1337 $lock_content[$cron_variable] = $value;
1340 if (!isset($lock_content[
'expiry_date'])) {
1341 if ($expiry_date == 0) {
1342 $expiry_date = time()+60*60;
1344 $expiry_date += time();
1346 $lock_content = array_merge($lock_content, self::getDefaultCronLock($expiry_date));
1350 if (!isset($lock_content[
'lock_msg'])) {
1351 $lock_content[
'lock_msg'] = get_backtrace();
1354 self::file_put_contents($lock_file, json_encode($lock_content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
1364 $lock_file = $GLOBALS[
'egotec_conf'][
'log_dir'].
'CRON'.((string)$GLOBALS[
'__CRON_LOCK_SUFFIX']).
'.LOCK';
1365 if (self::file_exists($lock_file)) {
1366 $fp = fopen($lock_file,
"r");
1371 while (!flock($fp, LOCK_EX | LOCK_NB, $wouldblock)) {
1372 if ($wouldblock && $count++ < $timeout_secs) {
1380 flock($fp, LOCK_UN);
1384 $lock_content = json_decode(self::file_get_contents($lock_file),
true);
1385 if (!isset($lock_content[
'expiry_date']) || strtotime($lock_content[
'expiry_date']) < time()) {
1401 require_once
'cron/Ego_Cron.php';
1402 $cron =
new Ego_Cron();
1403 $cron0_error =
true;
1406 'hourly' => array(
'title' => $GLOBALS[
'auth']->translate(
'stündlich'),
'interval' => 60 * 60),
1407 'daily' => array(
'title' => $GLOBALS[
'auth']->translate(
'täglich'),
'interval' => 60 * 60 * 24),
1408 'weekly' => array(
'title' => $GLOBALS[
'auth']->translate(
'wöchentlich'),
'interval' => 60 * 60 * 24 * 7),
1409 'monthly' => array(
'title' => $GLOBALS[
'auth']->translate(
'monatlich'),
'interval' => 60 * 60 * 24 * 31)
1413 $system_cron = array();
1414 $system_cron_exists =
false;
1415 if (($file = $GLOBALS[
'egotec_conf'][
'log_dir'] .
'cron.system') && self::file_exists($file)) {
1416 $system_cron = @unserialize(self::file_get_contents($file));
1417 if (!is_array($system_cron)) {
1418 $system_cron = array();
1420 $system_cron_exists =
true;
1424 foreach ($cron->crons as $cron_data) {
1425 if (in_array($cron_data[
'section'], array_keys($list))) {
1428 switch ($cron_data[
'function']) {
1429 case 'cron_update_urls':
1430 case 'cron_clean_urls':
1432 $skip_cron = $GLOBALS[
'egotec_conf'][
'rewrite_engine'] !=
'url';
1434 case 'glossary_to_xml':
1436 $skip_cron = !$site->admin[
'enabled_types'][
'glossary'];
1438 case 'cron_kfz_abrechnung':
1440 $skip_cron = !($site->admin[
'enabled_types'][
'kfz_management']
1441 &&
self::checkLicence($GLOBALS[
'egotec_conf'][
'lib_dir'] .
'type/site/kfz_management'));
1443 case 'cron_media_office_index':
1445 $skip_cron = !(!$GLOBALS[
'egotec_conf'][
'liveserver']
1446 && $site->site[
'type'] ==
'media'
1447 && $GLOBALS[
'egotec_conf'][
'openoffice'][
'active']
1450 case 'update_piwik_sites':
1451 case 'import_piwik_logs':
1453 $skip_cron = !
self::isStatistic(($GLOBALS[
'site']->admin[
'piwik'][
'auth_token'] ?: $GLOBALS[
'egotec_conf'][
'piwik'][
'auth_token']));
1455 case 'cron_escalation':
1457 $skip_cron = !($site->admin[
'workflow'][
'enabled']
1465 if ($system_cron_exists) {
1466 if (isset($system_cron[$cron_data[
'function']])) {
1467 $cron_data[
'last_exec'] = $system_cron[$cron_data[
'function']];
1468 $cron_data[
'error'] = $cron_data[
'last_exec'] < (time() - $list[$cron_data[
'section']][
'interval']);
1469 if ($cron_data[
'error']) {
1470 $list[$cron_data[
'section']][
'error'] =
true;
1473 $cron_data[
'warning'] =
true;
1477 $list[$cron_data[
'section']][
'crons'][] = $cron_data;
1482 foreach (array_keys($list) as $interval) {
1483 $file = $GLOBALS[
'egotec_conf'][
'log_dir'] .
"cron.{$interval}";
1484 if (self::file_exists($file)) {
1486 if ($list[$interval][
'date'] >= (time() - $list[$interval][
'interval'])) {
1487 $cron0_error =
false;
1489 $list[$interval][
'error'] =
true;
1495 'error' => $cron0_error,
1508 if (!$GLOBALS[
'egotec_conf'][
'noclearstatcache']) {
1533 public static function parseCsvLine($str, $delimiter=
';', $qualifier=
'"', $qualifierEscape =
'\\')
1536 while (strlen($str) > 0)
1538 if ($str[0] == $delimiter)
1539 $str = substr($str, 1);
1540 if ($str[0] == $qualifier)
1543 for ($i = 1; $i < strlen($str); $i++)
1545 if (($str[$i] == $qualifier) && ($str[$i-1] != $qualifierEscape))
1547 $str = substr($str, (strlen($value) + 2));
1548 $value = str_replace(($qualifierEscape.$qualifier), $qualifier, $value);
1555 $end = strpos($str, $delimiter);
1556 $value = ($end !==
false) ? substr($str, 0, $end) : $str;
1557 $str = substr($str, strlen($value));
1572 return $_SERVER[
'WINDIR'] || $_SERVER[
'windir'] || $_ENV[
'WINDIR'] || $_ENV[
'windir'] || getenv(
'windir');
1583 $parts = explode(
' ', sprintf($format, $cmd));
1584 $return =
self::exec($parts[0], array($parts[1], $parts[2]));
1585 return !empty($return);
1595 foreach ([
'/proc/self/fd',
'/dev/fd'] as $path) {
1596 self::exec(
'touch', [$path], $output, $return,
false);
1598 self::exec(
'ls', [$path,
'|',
'wc',
'-l'], $output, $return,
false);
1599 if ($return === 0 && ($n = (
int) $output[0]) > $fd_size) {
1604 return $fd_size / PHP_FD_SETSIZE;
1616 if ($_SESSION[
'export'])
1618 mb_regex_encoding(
'UTF-8');
1619 $return = mb_eregi_replace(
"[^[a-zA-Z0-9]]",
"_", $url);
1622 $return = strtr($url,
"%\n\r\t,;#-+?:&/'\".\\",
'_________________');
1624 if ($id && $url!=$return)
1626 $return.=
'-p-'.$id;
1628 return urlencode($return);
1650 $db = new_db_connection();
1652 'table' =>
'egotec_page_lock',
1666 $lines = file($file);
1668 foreach ($lines as $entry) {
1669 if (strpos($entry,
';') !== 0) {
1670 $content = explode(
'=', $entry, 2);
1671 $array[rtrim($content[0])] = trim($content[1]);
1686 if ($GLOBALS[
'frontend_admin']) {
1688 $str = preg_replace(
'/<([^ ]+) [^>]*data-edit-type="[^"]+"[^>]*>(.*?)<\/\\1>/msi',
'$2', $str);
1690 $str = strip_tags($str,
'<img><div><input><textarea><form><hr><param><object><video><iframe><embed>');
1691 $str = html_entity_decode($str);
1702 if (strlen($str) == 0)
1725 public static function urltopage($url, $params=array(), $only_site =
false, $error_page =
false, $commit_params =
false)
1727 require_once (
'base/Site.php');
1728 $url = preg_replace(
'/#.*?$/ims',
'', $url);
1733 if (strpos($url,
'index.php?') !==
false || strpos($url,
'admin.php?') !==
false)
1735 return self::_urltopage_index($url, $params);
1739 $url = preg_replace(
'/\/_\/.*?$/ims',
'.html', $url);
1740 return self::_urltopage_sprechend($url, $only_site, $error_page, $commit_params, $params);
1743 catch (Exception $e)
1749 private static function _urltopage_sprechend($url, $only_site, $error_page, $commit_params, $params)
1751 if ($GLOBALS[
'egotec_conf'][
'rewrite_engine'] ==
'url') {
1754 $domain = $info[
'host'] ?? $_SERVER[
'HTTP_HOST'];
1755 $file = ($pos = strpos($info[
'datei'],
'.')) ? substr($info[
'datei'], 0, $pos) : $info[
'datei'];
1756 $dir = ltrim($info[
'pfad'] .
'/' . $file,
'/');
1758 if (strpos($dir,
'%') !==
false) {
1760 $dir = urldecode(str_replace(
'+',
'%2B', $dir));
1763 $db = new_db_connection(array(
1764 'table' =>
'egotec_url',
1765 'where' =>
"domain = :domain AND dir = :dir",
1767 'domain' => $domain,
1771 if ($db->nextRecord()) {
1773 'site' => $db->Record[
'site'],
1774 'lang' => $db->Record[
'lang'],
1775 'id' => $db->Record[
'id']
1776 ]), $params[
'params'][
'param']);
1789 if (preg_match(
"#^http[s]?://([^/]+)#i", $url, $m))
1792 $url = substr($url, strlen($m[0]));
1795 $pos = strpos($url, $GLOBALS[
'egotec_conf'][
'url_dir']);
1798 $url = substr($url, strlen($GLOBALS[
'egotec_conf'][
'url_dir']));
1802 $dot_pos = strrpos($url,
'.');
1803 if ($dot_pos!==
false)
1805 $request_suffix = substr($url, $dot_pos);
1806 $url = substr($url, 0, $dot_pos);
1809 $request_suffix =
'.html';
1816 $dir = dirname($url);
1817 if ($dir && $dir!=
'.')
1819 $dir = explode(
'/', $dir);
1822 $req[
'site'] = array_shift($dir);
1823 $url = substr($url, strlen($req[
'site'])+1);
1825 if ($dir && strlen($dir[0])==2)
1827 $req[
'lang'] = array_shift($dir);
1828 $url = substr($url, 3);
1832 $req[
'skin'] = array_shift($dir);
1833 $url = substr($url, strlen($req[
'skin'])+1);
1841 while ($dir[$path_index])
1843 $num_path+= strlen($dir[$path_index])+1;
1846 $url = ltrim(substr($url, $num_path),
'/');
1849 $url = explode(
'-', $url);
1852 $key = urldecode(next($url));
1853 $value = str_replace(
'%2d',
'-', urldecode(next($url)));
1854 $req[$key] = urldecode($value);
1858 if ($http_host &&
Ego_System::file_exists($GLOBALS[
'egotec_conf'][
'bin_dir'].
'admin/popup_virtual_hosts.php'))
1860 $virtual_hosts = self::getVirtualHosts();
1863 $http_host = strtolower($http_host);
1865 if (!isset($virtual_hosts[$http_host]))
1867 if ($http_host != $_SERVER[
'HTTP_HOST']) {
1872 $req[
'site'] = $GLOBALS[
'egotec_conf'][
'default_site'];
1874 $req[
'site'] = $virtual_hosts[$http_host][
'site'];
1875 $GLOBALS[
'egotec_conf'][
'default_site'] = $req[
'site'];
1877 if (!$req[
'lang'] && $virtual_hosts[$http_host][
'lang'])
1879 $req[
'lang'] = $virtual_hosts[$http_host][
'lang'];
1882 if (isset($virtual_hosts[$http_host]))
1884 $GLOBALS[
'egotec_conf'][
'default_site'] = $virtual_hosts[$http_host];
1891 $req[
'site'] = $GLOBALS[
'egotec_conf'][
'default_site'];
1894 $site =
new Site($req[
'site'], $req[
'lang'], $req[
'skin']);
1895 }
catch (Exception $e) {
1896 switch ($e->getCode()) {
1898 array_unshift($url, $req[
'lang']);
1899 unset($req[
'lang']);
1900 $site =
new Site($req[
'site'],
'', $req[
'skin']);
1905 $req[
'site'] = $GLOBALS[
'egotec_conf'][
'default_site'];
1906 $site =
new Site($GLOBALS[
'egotec_conf'][
'default_site']);
1911 $req[
'p'] = $site->site[
'error_id']?$site->site[
'error_id']:$site->rootId;
1922 $site->setLanguage($req[
'lang']);
1928 unset($req[
'lang']);
1929 switch ($exception->getCode())
1943 $req[
'id'] = $site->site[
'error_id'];
1955 foreach ($req as $k => $v)
1967 $req[
'id'] = $req[
'p'];
1968 if ($req[
'id'] && !is_numeric($req[
'id']))
1972 $req[
'id'] = $site->site[
'error_id'];
1979 $name = urldecode($url[0]);
1980 $lang_name = ($req[
'lang']?$req[
'lang'].
'/':
'').$meta_url;
1981 if (!$meta_url && !$name && !$req[
'id'])
1983 $req[
'id'] = $site->rootId;
1986 $current_path = array();
1995 $req[
'id'] = $site->rootId;
1997 $pages = $site->getPages(array(
'where' =>
'url=\''.$meta_url.
'\''), array(
'auth_or' =>
'1=1',
'inactive' =>
true));
1998 if ($pages && $pages->numRecords() == 1)
2000 $page = $pages->nextPage();
2001 $current_path = $page->getPath(
false, array(),
false);
2006 foreach($dir as $path_name)
2008 $path_name = urldecode($path_name);
2009 if (strpos($path_name,
'-')!==
false)
2011 $path_name = explode(
'-', $path_name);
2012 $parent = $site->getPage((
int)$path_name[2], array(
'auth_or' =>
'1=1',
'inactive' =>
true));
2014 if (!is_object($parent))
2016 $pages = $site->getRoot(array(
'auth_or' =>
'1=1'))->getChildren(
2017 array(
'where' =>
'name=:name OR name LIKE :name',
'bind' => array(
'name' => $path_name)),
2018 array(
'auth_or' =>
'1=1',
'inactive' =>
true)
2020 $parent = $pages->nextPage();
2022 $pages = $parent->getChildren(
2023 array(
'where' =>
'name=:name OR name LIKE :name',
'bind' => array(
'name' => $path_name)),
2024 array(
'auth_or' =>
'1=1',
'inactive' =>
true)
2026 $parent = $pages->nextPage();
2029 if (is_object($parent))
2031 $current_path[] = $parent->field[
'id'];
2036 if (!is_object($parent))
2038 $parent = $site->getRoot(array(
'auth_or' =>
'1=1',
'inactive' =>
true));
2044 if (is_object($page))
2046 $req[
'id'] = $page->field[
'id'];
2049 if (is_object($parent))
2051 $pages = $parent->getChildren(
2052 array(
'where' =>
'url=\''.$name.
'\' OR name=\
''.$name.
'\' OR name like \
''.$name.
'\''),
2053 array(
'auth_or' =>
'1=1')
2055 if (!$pages->numRecords())
2057 $pages = $site->getPages(
2058 array(
'where' =>
'url LIKE \''.$name.
'\' OR name=\
''.$name.
'\' OR name like \
''.$name.
'\''),
2059 array(
'auth_or' =>
'1=1')
2063 $pages = $site->getPages(
2064 array(
'where' =>
'url LIKE \''.$name.
'\' OR name=\
''.$name.
'\' OR name like \
''.$name.
'\''),
2065 array(
'auth_or' =>
'1=1')
2068 $req[
'id'] = $pages->nextPage()->field[
'id'];
2070 if (!$req[
'id'] && $commit_params)
2072 $GLOBALS[
'no_cache'] =
true;
2074 }
else if (!$req[
'id'])
2076 $req[
'id'] = $site->rootId;
2081 $GLOBALS[
'current_path'] = $current_path;
2082 foreach ($req as $k => $v)
2087 $get_page_param = array();
2088 $get_page_param[
'auth_or'] =
'1=1';
2089 $get_page_param[
'inactive'] =
true;
2090 return $site->getPage($req[
'id'], $get_page_param);
2093 private static function _urltopage_index($url, $params=array())
2096 $pattern =
'/id=(\d+)/';
2097 preg_match($pattern, $url, $match);
2101 if(!$params[
'site'])
2103 $pattern =
'/site=([^\?&]+)/';
2104 preg_match($pattern, $url, $match);
2105 $site_id = $match[1];
2109 $site_id = $params[
'site'];
2113 if(!$params[
'lang'])
2115 $pattern =
'/lang=([a-z]+)/';
2116 preg_match($pattern, $url, $match);
2117 $site_lang = $match[1];
2121 $site_lang = $params[
'lang'];
2124 $site =
new Site($site_id, $site_lang);
2125 if (empty($GLOBALS[
'site'])) {
2127 $GLOBALS[
'site'] = $site;
2129 $page = $site->getPage($id, $params[
'params'][
'param']);
2149 public static function copy($src, $dest, $except =
'', $useLinks =
false, $noArchive =
false, $preserveDate =
false) {
2156 while (($entry = $dir->read()) !==
false) {
2157 if ($entry ==
'.svn' || $entry ==
'.' || $entry ==
'..') {
2161 if (!empty($except) && preg_match($except, $entry)) {
2169 preg_match(
'/\d+?_.+?/', $entry)
2171 preg_match(
'/pool\/\d+?$/', $src)
2172 && preg_match(
'/\d+/', $entry)
2179 $path = $src.
'/'.$entry;
2180 self::copy($path, $dest.
'/'.$entry, $except, $useLinks, $noArchive, $preserveDate);
2184 } elseif (empty($except) || !preg_match($except, basename($src))) {
2186 if ($useLinks && @link($src, $dest)) {
2190 $result = @copy($src, $dest);
2193 if ($result && $preserveDate && ($dt = filemtime($src)) !==
false) {
2211 public static function move($src, $dest) {
2214 return @rename($src, $dest);
2226 public static function getAllSites($username =
'', $perm =
'', $table =
false, $type =
'')
2228 require_once
'base/Site.php';
2230 $types = array_filter(array_map(
'trim', explode(
',', $type)));
2232 $unique_key = md5(serialize([$username, $perm, $table, $types]));
2233 if (!empty(self::$allSites[$unique_key])) {
2234 return self::$allSites[$unique_key];
2238 $db = new_db_connection(array(
2239 'fields' =>
'user_id',
2240 'table' =>
'egotec_user',
2241 'where' =>
'username=:username',
2242 'bind' => array(
'username' => $username)
2244 if (!$db->nextRecord())
2248 $user_id = $db->Record[
'user_id'];
2252 $dir = opendir($GLOBALS[
'egotec_conf'][
'site_dir']);
2253 $sites = $sort = array();
2254 while ($file = readdir($dir))
2257 is_dir($GLOBALS[
'egotec_conf'][
'site_dir'].$file) && $file[0] !=
'.' &&
2260 $loop_site =
new Site($file,
'',
'', !$GLOBALS[
'admin_area']);
2262 if (!empty($types) && !in_array($loop_site->site[
'type'], $types)) {
2269 $db = new_db_connection();
2270 if (!$db->tableExists($loop_site->pageTable))
2272 egotec_warning_log(
"Site table {$loop_site->pageTable} does not exist.");
2279 $loop_site->hasRight($perm,
false, $user_id)
2281 $sites[$file] = $loop_site;
2282 $sort[] = mb_strtolower($loop_site->site[
'title']);
2288 array_multisort($sort, SORT_ASC, SORT_NATURAL, $sites);
2290 self::$allSites[$unique_key] = $sites;
2300 $skins = self::getSkins();
2301 foreach ($skins as $type => $list) {
2302 foreach ($list as $skin => $title) {
2303 if ($skin ==
'_empty') {
2304 unset($skins[$type][$skin]);
2307 $skins[$type][$skin] = array();
2311 foreach (array_unique(array_merge(
2312 array($site->conf[
'site'][
'default_skin'], $site->conf[
'site'][
'mobile_skin']),
2313 explode(
',', $site->conf[
'site'][
'skins'])
2317 && isset($skins[
'skins'][$skin])
2318 && !in_array($site->name, $skins[
'skins'][$skin])
2320 $skins[
'skins'][$skin][] = $site;
2325 && (!$skins[
'themes'][$site->theme]
2326 || !in_array($site->name, $skins[
'themes'][$site->theme]))
2328 $skins[
'themes'][$site->theme][] = $site;
2340 public static function getSkins($more_themes = array()) {
2341 $cache = self::getCache();
2342 $cache_key =
'getSkins' . md5(json_encode(func_get_args()));
2343 $result = $cache->get($cache_key);
2345 if ($result ===
null) {
2352 $skin_dir = $GLOBALS[
'egotec_conf'][
'skin_dir'];
2353 if (self::file_exists($skin_dir)) {
2354 $dir = dir($skin_dir);
2355 while ($file = $dir->read()) {
2357 is_dir($skin_dir.$file)
2358 && substr($file, 0, 1) !=
'.'
2362 $result[
'skins'][$file] = $file;
2366 ksort($result[
'skins']);
2370 $result[
'themes'] = array(
'_empty' =>
'--');
2371 $theme_dir = $GLOBALS[
'egotec_conf'][
'egotec_dir'].
'pub/theme/';
2372 if (self::file_exists($theme_dir)) {
2373 $dir = dir($theme_dir);
2374 while ($file = $dir->read()) {
2376 is_dir($theme_dir.$file)
2377 && substr($file, 0, 1) !=
'.'
2381 $conf_file = $theme_dir.$file.
'/conf.ini';
2383 $conf = parse_ini_file($conf_file);
2384 $title = $conf[
'title'];
2392 && ($module_conf = parse_ini_file($module_file))
2393 && in_array(
"pub/theme/$file", explode(
',', $module_conf[
'path']))
2396 $result[
'themes'][$file] =
"[ $title ]";
2398 $result[
'themes'][$file] = $title;
2404 foreach ($more_themes as $name => $theme) {
2405 if (!isset($result[
'themes'][$name])) {
2406 $result[
'themes'][$name] = $theme;
2409 ksort($result[
'themes']);
2411 $cache->set($cache_key, $result);
2426 public static function log($file, $message)
2428 $file = $GLOBALS[
'egotec_conf'][
'log_dir'].$file;
2431 $size = filesize($file);
2432 if ($size > 100*1024*1024)
2434 $new_name = $file.
'_'.date(
"Y-m-d_H-i-s");
2435 rename($file, $new_name);
2439 $min = ($GLOBALS[
'egotec_conf'][
'log_min_disk_free']??10
2441 if (!is_dir($GLOBALS[
'egotec_conf'][
'log_dir'])) {
2442 self::mkdir($GLOBALS[
'egotec_conf'][
'log_dir']);
2444 $bytes_free = disk_free_space($GLOBALS[
'egotec_conf'][
'log_dir']);
2445 if ($min > $bytes_free)
2449 $files = glob($file.
'_*');
2450 foreach ($files as $f)
2454 strpos($f, $file)===0 &&
2455 preg_match(
'/_(\d{4}-\d{2}-\d{2})_(\d{2})-(\d{2})-(\d{2})$/', $f, $m)
2457 $stamp = $m[1].
' '.$m[2].
':'.$m[3].
':'.$m[4];
2458 $times[strtotime($stamp)] = $f;
2462 if (
sizeof($times)>0)
2464 unlink(current($times));
2467 $last_mail_file = $GLOBALS[
'egotec_conf'][
'log_dir'].
'disk_free_mail.date';
2468 $last_mail_date =
'1970-01-01 00:00:00';
2470 $last_mail_date = $date;
2473 !$GLOBALS[
'egotec_conf'][
'no_disk_free_mail']
2474 && $last_mail_date + 3600 < date(
'Y-m-d H:i:s')
2481 $frei = round($bytes_free / (1024*1024));
2482 $text =
"Es ist nicht genügend Speicherplatz auf dem Server vorhanden.\n".
2483 "Aktuell sind auf dem Server $frei MB frei.\n\n".
2484 $_SERVER[
'SERVER_NAME'].$_SERVER[
'REQUEST_URI'];
2485 require_once(
'mail/Ego_Mail.php');
2486 $mail =
new Ego_Mail();
2488 $mail->mail($GLOBALS[
'egotec_conf'][
'admin_mail'],
'Nicht genügend Speicherplatz auf dem Webserver', $text);
2489 }
catch (Exception $e)
2499 error_log($message, 3, $file);
2514 'installed' => array(),
2515 'failed' => array(),
2526 $requirements = array(
2542 'fileinfo' => array(
2563 'mbstring' => array(
2572 $loaded_extensions = get_loaded_extensions();
2575 foreach($requirements as $requirement => $required)
2577 $skip_version_compare =
false;
2578 $installed = $failed =
'';
2580 switch($requirement)
2584 $version = phpversion();
2586 $installed =
"PHP {$required['min']} oder höher ist installiert ($version)";
2587 $failed =
"PHP Version unzureichend ($version). Bitte aktualisieren Sie Ihre PHP Version auf {$required['min']} oder höher";
2594 $db = new_db_connection();
2595 $version = $db->getVersion();
2597 $installed =
"MySQL {$required['min']} oder höher ist installiert ($version)";
2598 $failed =
"MySQL Version unzureichend ($version). Bitte aktualisieren Sie Ihre MySQL Version auf {$required['min']} oder höher";
2601 $installed =
"MySQL wird nicht benötigt";
2609 if ($conn = @oci_connect($GLOBALS[
'egotec_conf'][
'db'][
'user'], $GLOBALS[
'egotec_conf'][
'db'][
'password'], $GLOBALS[
'egotec_conf'][
'db'][
'database'],
'AL32UTF8'))
2611 $version = oci_server_version($conn);
2614 $installed =
"Oracle {$required['min']} oder höher ist installiert ($version)";
2615 $failed =
"Oracle Version unzureichend ($version). Bitte aktualisieren Sie Ihre Oracle Version auf {$required['min']} oder höher";
2620 $failed =
"Oracle ist installiert, die Version konnte aber nicht ermittelt werden. Empfohlene Oracle Version ist {$required['min']} oder höher";
2624 $installed =
"Oracle wird nicht benötigt";
2630 if (function_exists(
'finfo_file')) {
2631 $version = phpversion(
'fileinfo');
2632 $result[
'installed'][$requirement] =
"Fileinfo ist installiert ($version)";
2634 $result[
'failed'][$requirement] =
"Fileinfo ist nicht installiert";
2636 $skip_version_compare =
true;
2641 $installed =
"64 Bit System";
2642 $failed =
"32 Bit System";
2647 $version = phpversion($requirement);
2655 $version = in_array($requirement, $loaded_extensions) ?
'' :
false;
2658 if ($version ===
false)
2661 if (!$required[
'min'])
2666 $result[$type][$requirement] =
"$requirement ist nicht installiert";
2670 $result[
'installed'][$requirement] =
"$requirement ist installiert".($version !=
'' ?
" ($version)" :
'');
2673 $skip_version_compare =
true;
2678 if ($skip_version_compare)
2683 $requirement ==
'oracle'
2684 && preg_match(
'/\d+\.[^ ]*/', $version, $match)
2687 $version = $match[0];
2690 if(!version_compare($version, $required[
'min'],
'>=') && !$required[
'except'])
2692 $result[
'failed'][$requirement] = $failed;
2693 }elseif(version_compare($version, $required[
'min'],
'>=') && !$required[
'except'])
2695 $result[
'installed'][$requirement] = $installed;
2696 }elseif(version_compare($version, $required[
'min'],
'>=') && $required[
'except'])
2698 $exceptions = explode(
',', $required[
'except']);
2700 if (version_compare($version,$exceptions[0],
'>=') && version_compare($version,$exceptions[1],
'<'))
2702 $result[
'failed'][$requirement] = $failed;
2705 $result[
'installed'][$requirement] = $installed;
2708 $result[
'failed'][$requirement] = $failed;
2713 if ($result[
'failed'][
'mysql'] && $result[
'failed'][
'oracle'])
2715 $result[
'failed'][
'_db'] =
"Weder MySQL noch Oracle sind installiert";
2719 if ($result[
'failed'][
'gd'] && $result[
'failed'][
'convert'])
2721 $result[
'failed'][
'_image'] =
"Weder GD noch ImageMagick sind installiert";
2725 foreach($result[
'failed'] as $key => $value)
2727 $set_notice =
false;
2732 if ($result[
'installed'][
'oracle'])
2739 if ($result[
'installed'][
'mysql'])
2746 if ($result[
'installed'][
'convert'])
2753 if ($result[
'installed'][
'gd'])
2762 $result[
'notice'][$key] = $value;
2763 unset($result[
'failed'][$key]);
2767 if (
sizeof($result[
'failed']) > 0)
2769 $result[
'passed'] =
false;
2783 if (is_numeric($byte)) {
2784 if ($byte > 1024*1024*1024) {
2785 return number_format($byte / (1024*1024*1024), 2).
' GB';
2786 } elseif ($byte > 1024*1024) {
2787 return number_format($byte / (1024*1024), 2).
' MB';
2788 } elseif ($byte > 1024) {
2789 return number_format($byte / (1024), 2).
' kB';
2810 self::file_put_contents($GLOBALS[
'egotec_conf'][
'cache_dir'].
'eternal', time()+900);
2812 @unlink($GLOBALS[
'egotec_conf'][
'cache_dir'].
'eternal');
2816 self::clearCacheAllSites();
2819 self::clearNginxCache();
2832 return (
bool) (self::file_get_contents(
'https://'.$_SERVER[
'HTTP_HOST'].$GLOBALS[
'egotec_conf'][
'url_dir']));
2833 }
catch (Exception $e) {
2847 $db = new_db_connection();
2849 return substr(strrchr(get_class($db),
'_'), 1);
2860 require_once(
'MIME/Type/Extension.php');
2861 $mime =
new MIME_Type_Extension();
2863 $types = $mime->extensionToType;
2865 return ($ext ? $types[$ext] : $types);
2878 'site' => $GLOBALS[
'site']->name,
2879 'skin' => $GLOBALS[
'site']->skin
2882 if (file_exists($GLOBALS[
'egotec_conf'][$dir.
'_dir'].$sub_dir[$dir].
'/'.$file))
2884 return $GLOBALS[
'egotec_conf'][
'url_dir'].$dir.
'/'.$sub_dir[$dir].
'/'.$file;
2885 } elseif ($GLOBALS[
'site']->globalAllowed() && file_exists($GLOBALS[
'egotec_conf'][$dir.
'_dir'].
'_global/'.$file))
2887 return $GLOBALS[
'egotec_conf'][
'url_dir'].$dir.
'/_global/'.$file;
2888 } elseif (file_exists($GLOBALS[
'egotec_conf'][
'lib_dir'].
'type/'.$dir.
'/'.$file))
2890 return $GLOBALS[
'egotec_conf'][
'url_dir'].
'lib/'.$dir.
'/'.$file;
2907 if ($handle = opendir ($pfad))
2909 while (
false !== ($file = readdir($handle)))
2911 $nextpath = $pfad .
'/' . $file;
2912 if ($file !=
'.' && $file !=
'..' && !is_link ($nextpath))
2914 if (is_dir ($nextpath))
2918 $totalsize += $result[
'size'];
2919 $totalcount += $result[
'count'];
2920 $dircount += $result[
'dircount'];
2921 }elseif (is_file ($nextpath))
2923 $stat = stat ($nextpath);
2924 if (!isset($links[$stat[
'ino']])) {
2925 $totalsize += $stat[
'size'];
2927 if ($stat[
'nlink'] > 1) {
2928 $links[$stat[
'ino']] = $stat[
'nlink'];
2936 $total[
'size'] = $totalsize;
2937 $total[
'count'] = $totalcount;
2938 $total[
'dircount'] = $dircount;
2952 $host = $GLOBALS[
'egotec_conf'][
'proxy'][
'proxy_host'];
2953 $port = $GLOBALS[
'egotec_conf'][
'proxy'][
'proxy_port'];
2954 $ssl = $GLOBALS[
'egotec_conf'][
'proxy'][
'proxy_ssl'];
2955 $login = $GLOBALS[
'egotec_conf'][
'proxy'][
'proxy_login'];
2956 $password = $GLOBALS[
'egotec_conf'][
'proxy'][
'proxy_password'];
2958 if ($host && $port) {
2961 'proxy' => ($ssl ?
'ssl://' :
'tcp://').$host.
':'.$port,
2962 'request_fulluri' =>
true
2966 $auth = base64_encode($login .
":" . $password);
2967 $options[
'http'][
'header'] =
"Proxy-Authorization: Basic $auth\r\n";
2970 $options = array_merge_recursive(stream_context_get_options($context), $options);
2971 if (is_array($options[
'http'][
'header'])) {
2972 $options[
'http'][
'header'] = implode(
"\r\n", array_map(
'trim', $options[
'http'][
'header']));
2975 $context = stream_context_create($options);
2977 $content = @file_get_contents($filename,
false, $context);
2978 if ($context && $content ===
false) {
2980 $content = @file_get_contents($filename);
2984 if ($utf8 && $content) {
2985 return mb_convert_encoding($content,
'UTF-8', mb_detect_encoding($content,
'UTF-8, ISO-8859-1',
true));
3003 return file_put_contents($filename, $data, $flags, $context);
3014 return filesize($file);
3027 $site = $GLOBALS[
'site'];
3030 $count = range(1, self::MAX_CLUSTER);
3032 foreach ($count as $c) {
3034 $site->admin[
'cluster'][
'cluster_'.$c.
'_aktiv'] == 1
3035 && $site->admin[
'cluster'][
'cluster_'.$c.
'_url'] !=
''
3038 'url' => rtrim($site->admin[
'cluster'][
'cluster_'.$c.
'_url'],
'/') .
'/',
3040 'oneway' => (
bool) $site->admin[
'cluster'][
'cluster_'.$c.
'_oneway']
3057 public static function truncate($string, $length, $etc =
'...', $break_words =
false, $middle =
false)
3059 require_once(
'smarty/plugins/modifier.html_truncate.php');
3060 return smarty_modifier_html_truncate($string, $length, $etc, $break_words, $middle);
3070 switch ($site->site[
'type']) {
3072 $_SESSION[
'_last_desktop'] = array(
3073 'name' => $site->name,
3074 'language' => $site->language
3079 if (is_array($_SESSION[
'_last_desktop'])) {
3081 $_SESSION[
'_last_desktop'][
'name'],
3082 $_SESSION[
'_last_desktop'][
'language']
3084 if ($_site->site[
'media'] == $site->name)
3091 $_site->site[
'media'] == $site->name
3092 && $_site->name != $site->name
3101 if (is_array($_SESSION[
'_last_desktop'])) {
3103 $_SESSION[
'_last_desktop'][
'name'],
3104 $_SESSION[
'_last_desktop'][
'language']
3119 require_once(
'base/Ego_Update.php');
3120 $update =
new Ego_Update();
3121 return $update->getLatestEgocmsVersion();
3132 require_once(
'diff/Ego_Diff.php');
3134 $ignored_elements = array();
3135 foreach (array(
'script',
'svg') as $element) {
3136 while (preg_match(
'/<' . $element .
'[^>]*>(.*?)<\/' . $element .
'>/ims', $diff1, $m)) {
3137 $key =
'__EGOTEC__IGNORE__' . md5($m[0]) .
'__IGNORE__EGOTEC__';
3138 $ignored_elements[$key] = $m[0];
3139 $diff1 = str_replace($m[0], $key, $diff1);
3140 $diff2 = str_replace($m[0], $key, $diff2);
3143 $diff =
new Ego_Diff();
3144 $result = $diff->compare($diff2, $diff1,
false);
3146 foreach ($ignored_elements as $key => $code)
3148 $result = str_replace($key, $code, $result);
3165 if ($GLOBALS[
'is_mail']) {
3168 $media = $GLOBALS[
'egotec_conf'][
'url_dir'] .
'bin/media/error.php';
3171 if ($GLOBALS[
'is_mail']) {
3174 $media = $GLOBALS[
'egotec_conf'][
'url_dir'].
'pub/missing_file.gif';
3178 if ($params[
'site']) {
3180 $site =
new Site($params[
'site'], $params[
'lang']);
3187 $site->site[
'type'] ==
'media'
3188 && ($params[
'width'] || $params[
'height'])
3190 return $media .
'?' . http_build_query([
3191 'width' => $params[
'width'],
3192 'height' => $params[
'height']
3194 }
else if ($site->site[
'error_id'] && $errorPage = $site->getPage($site->site[
'error_id'])) {
3195 return $errorPage->getUrl();
3230 public static function getFallbackFile($type, $name, $path, $skip = array(
'module'), $url =
false, $relative =
false, $parent =
'') {
3231 $cache = self::getCache();
3232 $cache_key =
'fallbackFiles';
3233 $map_key = md5(json_encode(func_get_args()));
3235 if (empty(self::$fallbackMapping)) {
3236 self::$fallbackMapping = $cache->get($cache_key) ?? array();
3239 if (isset(self::$fallbackMapping[$map_key])) {
3240 $result = self::$fallbackMapping[$map_key];
3244 $path = ltrim($path,
'/');
3247 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
3248 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] . $type .
'/',
3249 'file' => $name .
'/' . $path
3251 'parent_custom' => array(
3252 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
3253 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] . $type .
'/',
3254 'file' => $parent .
'/' . $path
3256 'parent_theme' => array(
3257 'path' => $GLOBALS[
'egotec_conf'][
'pub_dir'],
3258 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] .
'pub/',
3259 'file' =>
'theme/' . $parent .
'/' . $type .
'/' . $path
3262 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
3263 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] . $type .
'/',
3264 'file' =>
'_global/' . $path
3267 'path' => $GLOBALS[
'egotec_conf'][
'lib_dir'],
3268 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] .
'lib/',
3269 'files' => [
'type/' . $type .
'/' . $path, $path]
3272 'path' => $GLOBALS[
'egotec_conf'][
'bin_dir'],
3273 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] .
'bin/',
3274 'files' => [
'type/skin/' . $path,
'page/' . $path]
3276 'custom_system' => array(
3277 'path' => $GLOBALS[
'egotec_conf'][
'var_dir'] .
'lib/',
3278 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] .
'var/lib/',
3281 'custom_module' => array(
3282 'path' => $GLOBALS[
'egotec_conf'][
'var_dir'] .
'bin/',
3283 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] .
'var/bin/',
3290 if (empty($parent)) {
3291 $skip[] =
'parent_custom';
3292 $skip[] =
'parent_theme';
3293 } elseif ($type !=
'skin') {
3294 $skip[] =
'parent_custom';
3296 foreach ($files as $key => $file) {
3297 $list = isset($file[
'files']) ? $file[
'files'] : [$file[
'file']];
3298 foreach ($list as $item) {
3299 $path_file = $file[
'path'] . $item;
3300 $url_file = $file[
'url'] . $item;
3302 $pos = strpos($url_file, $GLOBALS[
'egotec_conf'][
'url_dir']);
3304 $url_file = substr_replace(
3308 strlen($GLOBALS[
'egotec_conf'][
'url_dir'])
3312 if (!in_array($key, $skip) && is_file($path_file)) {
3313 $result = $url ? $url_file : $path_file;
3319 self::$fallbackMapping[$map_key] = $result;
3320 $cache->set($cache_key, self::$fallbackMapping);
3341 public static function getFiles($type, $name, $path, $skip = array(), $parent =
'', $return_path =
false, $get_variants =
true) {
3342 $cache = self::getCache();
3343 $cache_key =
'getFiles' . md5(json_encode(func_get_args()));
3344 $result = $cache->get($cache_key);
3346 if ($result ===
null) {
3347 $original_path = $path;
3348 $original_skip = $skip;
3353 $result =
new stdClass();
3354 $result->{
'_empty'} = $GLOBALS[
'auth']->translate(
'Standard');
3358 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
3359 'file' => $name .
'/' . $path
3361 'parent_custom' => array(
3362 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
3363 'file' => $parent .
'/' . $path
3365 'parent_theme' => array(
3366 'path' => $GLOBALS[
'egotec_conf'][
'egotec_dir'] .
'pub/',
3367 'file' =>
'theme/' . $parent .
'/' . $type .
'/' . $path
3370 'path' => $GLOBALS[
'egotec_conf'][$type .
'_dir'],
3371 'file' =>
'_global/' . $path
3374 'path' => $GLOBALS[
'egotec_conf'][
'pub_dir'],
3375 'url' => $GLOBALS[
'egotec_conf'][
'url_dir'] .
'pub/',
3376 'file' =>
'type/' . $type .
'/' . $path
3379 'path' => $GLOBALS[
'egotec_conf'][
'lib_dir'],
3380 'file' =>
'type/' . $type .
'/' . $path
3383 'path' => $GLOBALS[
'egotec_conf'][
'bin_dir'],
3384 'file' =>
'type/skin/' . $path
3390 if (empty($parent)) {
3391 $skip[] =
'parent_custom';
3392 $skip[] =
'parent_theme';
3394 foreach ($files as $key => $file) {
3395 if (!in_array($key, $skip)) {
3396 $list = glob($file[
'path'] . $file[
'file']);
3397 if (!empty($list)) {
3398 foreach ($list as $match) {
3399 if (@is_file($match)) {
3400 $parts = explode(
'.', basename($match));
3401 $i = $get_variants ? count($parts) - 2 : 0;
3402 if ($i >= 0 && $parts[$i]) {
3403 $variant = $parts[$i];
3405 $relative_path = substr($match, strlen($GLOBALS[
'egotec_conf'][
'egotec_dir']));
3406 $result->{$relative_path} = ucfirst($variant);
3408 $result->{$variant} = ucfirst($variant);
3416 $result = (array) $result;
3417 if (strpos($original_path,
'.html') !==
false) {
3419 $result = array_merge($result, self::getFiles($type, $name, str_replace(
'.html',
'.tpl', $original_path), $original_skip, $parent, $return_path, $get_variants));
3422 $cache->set($cache_key, $result);
3441 public static function getVariantFiles($type, $name, $path, $skip = array(), $parent =
'') {
3442 $path = substr_replace($path,
'.*', strrpos($path,
'.'), 0);
3443 return self::getFiles($type, $name, $path, $skip, $parent);
3454 if (!$url && $_REQUEST[
'_url']) {
3455 $url = $_REQUEST[
'_url'];
3456 if ($url[0] ==
'/') {
3457 $url = substr($url, 1);
3459 if ($query_pos = strpos($url,
'?')) {
3460 $url = substr($url, 0, $query_pos);
3462 $dot_pos = strrpos($url,
'.');
3463 if ($dot_pos !==
false) {
3464 $url = substr($url, 0, $dot_pos);
3469 parse_str(parse_url($url, PHP_URL_QUERY), $params);
3471 if (strpos($url,
'index.php') ===
false) {
3473 $url = explode(
'-', parse_url($url, PHP_URL_PATH));
3475 while ($value !==
false)
3477 $value = preg_replace(
'/\..*?$/',
'', $value);
3479 if ($key ===
false || strpos($key,
'/') !==
false)
3483 $params[$key] = $value;
3484 $key = urldecode($key);
3485 $value = prev($url);
3487 $params = array_reverse($params);
3499 if (empty($request)) {
3500 $request = $_REQUEST;
3501 foreach ($_COOKIE as $key => $val) {
3502 unset($request[$key]);
3505 unset($request[
'_url']);
3506 unset($request[
'p']);
3507 unset($request[
'id']);
3508 unset($request[
'site']);
3509 unset($request[
'lang']);
3510 unset($request[
'skin']);
3511 unset($request[
'no301']);
3512 unset($request[
'return_absolute']);
3513 unset($request[
'return_relative']);
3514 unset($request[
'return_original']);
3515 unset($request[
'return_https']);
3540 if (is_array($value)) {
3542 $numeric_keys =
true;
3543 $preserved_keys = [
'old_phase',
'new_phase'];
3544 foreach ($value as $k => $v) {
3545 if (in_array($k, $preserved_keys,
true)) {
3549 $v = self::cleanTypes($v);
3552 !in_array($k, $preserved_keys,
true)
3554 in_array($k, [
'',
'undefined'],
true)
3555 || (empty($v) && $v !== 0)
3560 $new_value[$k] = $v;
3561 if (!is_numeric($k)) {
3562 $numeric_keys =
false;
3565 if ($numeric_keys) {
3569 $value = $new_value;
3570 } elseif (is_string($value)) {
3571 if (preg_match(
'/^[1-9]+[0-9]*$/', $value)) {
3574 $value = $value + 0;
3575 } elseif ($value ===
'0') {
3577 } elseif (in_array($value, [
'true',
'false'],
true)) {
3578 $value = $value ==
'true';
3579 } elseif (in_array($value, [
'null',
'undefined',
'_empty'],
true)) {
3593 if (preg_match(
'/^([^\/:]+:\/\/)?(.*?)$/', $url, $matches)) {
3594 $protocol = $matches[1];
3596 $uri = str_replace(
'//',
'/', $uri);
3597 $url = $protocol.$uri;
3609 if (isset($_SERVER[
'REQUEST_URI'])) {
3611 array(
'url' => ltrim(preg_replace(
'#^https?://.*?/#i',
'', rawurldecode($_SERVER[
'REQUEST_URI'])),
'/')),
3612 array(
'url' => ltrim(preg_replace(
'#^https?://.*?/#i',
'', rawurldecode($url)),
'/'))
3614 if ($data[0][
'url'] != $data[1][
'url']) {
3616 $data[0][
'info'] = self::getUrlInfo($data[0][
'url']);
3617 $data[1][
'info'] = self::getUrlInfo($data[1][
'url']);
3618 unset($data[0][
'info'][
'params'][
'p'], $data[1][
'info'][
'params'][
'p']);
3620 $data[0][
'info'][
'suffix'] == $data[1][
'info'][
'suffix']
3621 &&
sizeof($data[0][
'info'][
'params']) ==
sizeof($data[1][
'info'][
'params'])
3622 &&
sizeof($data[0][
'info'][
'parts']) ==
sizeof($data[1][
'info'][
'parts'])
3625 foreach ($data[0][
'info'][
'params'] as $key => $value) {
3626 if (str_replace(
'+',
' ',$value) != str_replace(
'+',
' ',$data[1][
'info'][
'params'][$key])) {
3631 foreach ($data[0][
'info'][
'parts'] as $key => $value) {
3632 $value = mb_strtoupper($value);
3633 $data[1][
'info'][
'parts'][$key] = mb_strtoupper($data[1][
'info'][
'parts'][$key]);
3635 $value != $data[1][
'info'][
'parts'][$key]
3636 && $value != urldecode($data[1][
'info'][
'parts'][$key])
3658 $url = str_replace(
'&',
'&', $url);
3661 'params' => self::getUrlParams($url),
3662 'query' => (
string) parse_url($url, PHP_URL_QUERY),
3663 'protocol' => ($scheme = parse_url($url, PHP_URL_SCHEME)) ?
"$scheme://" :
null,
3664 'anchor' => parse_url($url, PHP_URL_FRAGMENT)
3668 if (($dot = strrpos($url,
'.')) !==
false) {
3669 $info[
'suffix'] = preg_split(
'/[\/?#]/', substr($url, $dot))[0];
3673 if (preg_match(
'/\/_\/([^?#]+)/', $url, $match)) {
3674 $info[
'params'][
'pool'] = urldecode($match[1]);
3678 $info[
'parts'] = array_filter(explode(
'/', parse_url($url, PHP_URL_PATH)),
function($value) {
3679 return $value !==
'';
3681 $info[
'parts'] = array_map(
function($value) {
3682 if (preg_match(
'/^(.*?)\./', $value, $match)) {
3685 if (substr_count($value,
'-') % 2 == 0) {
3686 $value = preg_replace(
'/^([^-]*).*?$/',
'$1', $value);
3688 $value = preg_replace(
'/^([^-]*-[^-]*).*?$/',
'$1', $value);
3695 $info[
'parts'] = array_map(
'self::encode_path', $info[
'parts']);
3708 if (self::file_exists($file)) {
3709 $cache = self::getCache();
3710 $cache_key =
'getFileInfo' . md5($file);
3711 $info = $cache->get($cache_key);
3713 if ($info ===
null || filemtime($file) > $cache->getLastChanged()) {
3716 $finfo =
new finfo();
3717 $mime_type = $finfo->file($file, FILEINFO_MIME_TYPE);
3719 $info[
'size'] = @filesize($file);
3720 $info[
'mime'] = $mime_type;
3722 if (stripos($mime_type,
'video/') === 0) {
3725 self::exec(
'ffprobe', [
'-v',
'error',
'-select_streams',
'v:0',
'-show_entries',
'stream=height,width',
'-of',
'csv=s=x:p=0', $file], $output);
3726 $s = explode(
'x', $output[0]);
3727 $info[
'width'] = (int)$s[0];
3728 $info[
'height'] = (int)$s[1];
3731 self::exec(
'ffprobe', [
'-v',
'error',
'-show_entries',
'format=duration',
'-of',
'default=nw=1:nk=1', $file], $output);
3732 $s = ceil((
float) $output[0]);
3733 $info[
'duration'] = $s
3734 ? sprintf(
'%02d:%02d:%02d', $s / 3600, $s / 60 % 60, $s % 60)
3736 } elseif (stripos($mime_type,
'image/') === 0) {
3738 require_once
'base/Ego_Image.php';
3742 $cache->set($cache_key, $info);
3755 $virtual_hosts = $h = array();
3757 $file_name = $GLOBALS[
'egotec_conf'][
'var_dir'].
'conf/virtual_hosts.ini';
3758 if (self::file_exists($file_name)) {
3759 $virtual_hosts = parse_ini_file($file_name,1);
3761 foreach($virtual_hosts as $k => $v) {
3762 $h[mb_strtolower($k)] = $v;
3776 return array(
'jpg',
'jpeg',
'gif',
'png',
'bmp',
'svg',
'ico',
'webp',
'avif');
3778 return array(
'image/gif',
'image/png',
'image/jpeg',
'image/jpg');
3780 return array(
'zip',
'rar',
'tar',
'gz',
'bz2',
'7z');
3782 return array(
'mp4',
'ogg',
'webm');
3784 throw new Exception(
'Format type does not exist.');
3798 public static function sortPages($pages, $sorttype =
'field', $sortby =
'id', $sortdirection =
"asc")
3801 if (gettype($pages) ==
'object')
3803 $pagesnew = array();
3804 foreach ($pages as $p)
3811 if (is_array($pages))
3813 usort($pages,
function($a, $b) use ($sorttype, $sortby, $sortdirection) {
3816 array(
'ä',
'ö',
'ü',
'ß'),
3817 array(
'ae',
'oe',
'ue',
'ss'),
3823 return $sortdirection ==
'asc' ? strnatcmp($v1, $v2) : strnatcmp($v2, $v1);
3840 return 'http' . ($https || $_SERVER[
'HTTPS'] ==
'on' || $_SERVER[
'HTTP_X_FORWARDED_PROTO'] ==
'https'
3841 ?
's' :
'') .
'://';
3850 return ($_SERVER[
'HTTP_HOST']
3851 ? self::getProtocol().$_SERVER[
'HTTP_HOST']
3852 : rtrim($GLOBALS[
'egotec_conf'][
'local_server_access'],
'/'))
3853 .$GLOBALS[
'egotec_conf'][
'url_dir'];
3863 $cache_file = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'disk_usage';
3864 if (!$recalc && self::file_exists($cache_file)) {
3865 $usage = unserialize(self::file_get_contents($cache_file));
3870 'elements' => array(
3873 'label' => $GLOBALS[
'auth']->translate(
'System'),
3874 'color' =>
'#f8482b',
3876 $GLOBALS[
'egotec_conf'][
'lib_dir'],
3877 $GLOBALS[
'egotec_conf'][
'bin_dir'],
3878 $GLOBALS[
'egotec_conf'][
'egotec_dir'].
'pub'.DIRECTORY_SEPARATOR
3884 'label' => $GLOBALS[
'auth']->translate(
'Backups'),
3885 'color' =>
'#0e88f0',
3887 $GLOBALS[
'egotec_conf'][
'backup_dir']
3891 'label' => $GLOBALS[
'auth']->translate(
'Cache'),
3892 'color' =>
'#2fedac',
3894 $GLOBALS[
'egotec_conf'][
'cache_dir'],
3895 $GLOBALS[
'egotec_conf'][
'cachemedia_dir']
3899 'label' => $GLOBALS[
'auth']->translate(
'Logs'),
3900 'color' =>
'#edc72f',
3902 $GLOBALS[
'egotec_conf'][
'log_dir']
3906 'label' => $GLOBALS[
'auth']->translate(
'Temporär'),
3907 'color' =>
'#efd2de',
3909 $GLOBALS[
'egotec_conf'][
'tmp_dir']
3913 'label' => $GLOBALS[
'auth']->translate(
'Medien'),
3914 'color' =>
'#4fac0b',
3916 $GLOBALS[
'egotec_conf'][
'var_dir'].
'media'.DIRECTORY_SEPARATOR
3920 'customer' => array(
3922 'label' => $GLOBALS[
'auth']->translate(
'Skripte'),
3923 'color' =>
'#deefd2',
3925 $GLOBALS[
'egotec_conf'][
'site_dir']
3929 'label' => $GLOBALS[
'auth']->translate(
'Designs'),
3930 'color' =>
'#8813f5',
3932 $GLOBALS[
'egotec_conf'][
'skin_dir']
3940 'unknown' => array(),
3943 'time' => microtime(
true),
3948 if (empty($GLOBALS[
'egotec_conf'][
'skip_disk_usage'])) {
3949 $total = (float) @disk_total_space($GLOBALS[
'egotec_conf'][
'egotec_dir']);
3953 $origin = md5($total);
3954 $usage[
'total'][$origin] = $total;
3955 $usage[
'used'][$origin] = 0;
3956 $usage[
'free'][$origin] = 0;
3957 $usage[
'unknown'][$origin] = 0;
3958 $usage[
'dirs'][$origin] = $GLOBALS[
'egotec_conf'][
'egotec_dir'];
3959 $total_values = array($usage[
'total'][$origin]);
3960 foreach ($usage[
'elements'] as $element => $types) {
3961 foreach ($types as $type => $data) {
3962 foreach ($data[
'dirs'] as $dir) {
3963 if (!self::file_exists($dir)) {
3964 egotec_warning_log(
"Path '$dir' doesn't exist.");
3967 if (empty($GLOBALS[
'egotec_conf'][
'skip_disk_usage'])) {
3968 $cms_dir = self::getDirectorySize($dir);
3969 $used = (float) $cms_dir[
'size'];
3973 $usage[
'elements'][$element][$type][
'value'] += $used;
3975 empty($GLOBALS[
'egotec_conf'][
'skip_disk_usage'])
3976 && strpos($dir, $GLOBALS[
'egotec_conf'][
'egotec_dir']) !== 0
3978 $base_dir = substr($dir, 0,
3979 strrpos(rtrim($dir, DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR) + 1
3981 $total = (float) @disk_total_space($base_dir);
3984 foreach ($total_values as $size) {
3985 if ($total == $size) {
3991 $origin = md5($total);
3992 $usage[
'total'][$origin] += $total;
3993 $usage[
'dirs'][$origin] = $base_dir;
3994 $total_values[] = $total;
3998 $origin = md5($total_values[0]);
4000 $usage[
'used'][$origin] += $used;
4001 $usage[
'elements'][$element][$type][
'origin'] = $origin;
4005 foreach ($usage[
'total'] as $origin => $value) {
4006 $usage[
'free'][$origin] = $value - $usage[
'used'][$origin];
4009 if (empty($GLOBALS[
'egotec_conf'][
'skip_disk_usage'])) {
4010 $free = (float)@disk_free_space($usage[
'dirs'][$origin]);
4014 if ($free > 0 && $free < $usage[
'free'][$origin]) {
4015 $usage[
'unknown'][$origin] = $usage[
'free'][$origin] - $free;
4016 $usage[
'used'][$origin] += $usage[
'unknown'][$origin];
4017 $usage[
'free'][$origin] = $free;
4019 $usage[
'unknown'][$origin] = 0;
4022 $usage[
'time'] = microtime(
true) - $usage[
'time'];
4023 @file_put_contents($cache_file, serialize($usage));
4034 if (!self::isWindows()) {
4035 self::exec(
'cat', [
'/proc/cpuinfo',
'|',
'grep processor',
'|',
'wc -l'], $output, $return,
false);
4036 $cpu = ((int) $output[0]) ?: 1;
4037 $load = sys_getloadavg();
4038 return $load[0] / $cpu;
4049 public static function getIp($anonymized =
false) {
4050 $ip = isset($_SERVER[
'HTTP_X_FORWARDED_FOR']) ? $_SERVER[
'HTTP_X_FORWARDED_FOR'] : ($_SERVER[
'REMOTE_ADDR'] ??
'');
4052 $ip = preg_replace(
'/\.\d+$/ims',
'.0', $ip);
4053 $ip = preg_replace(
'/:.*?$/ims',
'::', $ip);
4065 if (function_exists(
'gzdecode')) {
4066 return gzdecode($string);
4068 $tmp = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'gzDecode');
4069 @file_put_contents($tmp, $string);
4072 $output = ob_get_clean();
4090 if (preg_match_all(
'/index\.php\?[^>"\' ]+/msi', $content, $matches)) {
4091 foreach ($matches[0] as $url) {
4092 $info = self::getUrlInfo($url);
4093 if (!empty($info[
'params'])) {
4095 foreach ($search as $param => $value) {
4097 !isset($info[
'params'][$param])
4098 || $info[
'params'][$param] != $value
4101 } elseif (isset($replace[$param])) {
4102 $info[
'params'][$param] = $replace[$param];
4108 $query = http_build_query($info[
'params']);
4109 $content = str_replace($url,
'index.php?'.$query, $content);
4125 return strtr(base64_encode($s),
'+/=',
'-_,');
4136 return base64_decode(strtr($s,
'-_,',
'+/='));
4147 foreach ($array as $value) {
4148 if (is_array($value)) {
4149 $result = array_merge($result, self::arrayValuesRecursive($value));
4154 return array_unique($result);
4167 array_walk_recursive($array,
function($a, $k) use (&$result, $callback) {
4168 if (!is_array($result[$k])) {
4169 $result[$k] = array();
4171 if (!empty($callback)) {
4172 $a = call_user_func_array($callback, array($a));
4174 array_push($result[$k], $a);
4175 $result[$k] = array_values(array_unique($result[$k]));
4187 if ($ignore && !empty($GLOBALS[
'egotec_conf'][
'dev_ignore'])) {
4191 if (self::$devMode ===
null) {
4192 self::$devMode = ($GLOBALS[
'egotec_conf'][
'devserver'] ??
false)
4193 || self::file_exists($GLOBALS[
'egotec_conf'][
'egotec_dir'].
'.svn')
4194 || self::file_exists($GLOBALS[
'egotec_conf'][
'egotec_dir'].
'.git');
4196 return self::$devMode;
4207 return self::checkLicence($GLOBALS[
'egotec_conf'][
'lib_dir'].
'stats')
4208 && ($GLOBALS[
'site']->admin[
'piwik'][
'auth_url'] || $GLOBALS[
'egotec_conf'][
'piwik'][
'auth_url'])
4212 || !empty($GLOBALS[
'egotec_conf'][
'dev'][
'enable_stats'])
4224 if (($p = strstr($k,
'.',
true)) !==
false) {
4225 if (($j = strstr($p,
'{')) !==
false) {
4227 $kj = ltrim(str_replace($p, $j, substr($k, 0, strrpos($k,
'}'))),
'{');
4228 $s = self::getAssocValue($a, str_replace($j,
'', $p));
4229 if (is_string($s)) {
4230 $aj = json_decode($s,
true);
4231 if (is_array($aj)) {
4232 return self::getAssocValue($aj, $kj);
4236 } elseif (is_array($a)) {
4238 return self::getAssocValue($a[$p], ltrim(strstr($k,
'.'),
'.'));
4254 if (($p = strstr($k,
'.',
true)) !==
false) {
4255 if (($j = strstr($p,
'{')) !==
false) {
4257 $kj = ltrim(str_replace($p, $j, substr($k, 0, strrpos($k,
'}'))),
'{');
4258 $s = self::getAssocValue($a, ($pj = str_replace($j,
'', $p)));
4259 if (is_string($s)) {
4260 $aj = json_decode($s,
true);
4261 if (is_array($aj)) {
4262 self::setAssocValue($aj, $kj, $v);
4263 self::setAssocValue($a, $pj, json_encode($aj, JSON_UNESCAPED_UNICODE));
4271 return self::setAssocValue($a[$p], ltrim(strstr($k,
'.'),
'.'), $v);
4287 ($p = strstr($k,
'.',
true)) !==
false
4288 || (strpos($k,
'?') !==
false && ($p = $k))
4292 ($j = strstr($p,
'{')) !==
false
4293 && (($jh = strstr($p,
'#')) ===
false || $jh > $j)
4296 $kj = ltrim(str_replace($p, $j, substr($k, 0, strrpos($k,
'}'))),
'{');
4297 $s = self::getAssocValue($a, ($pj = str_replace($j,
'', $p)));
4301 $aj = json_decode($s,
true);
4303 if (is_array($aj)) {
4304 $ar = self::getAssocValues($aj, $kj);
4305 if (is_array($ar)) {
4307 foreach ($ar as $rk => $rv) {
4308 $r[$o . $pj .
'{' . $rk .
'}'] = $rv;
4316 } elseif (strpos($p,
'?') !==
false) {
4319 $pattern = preg_replace_callback(
'/\?(#.*?#)?/',
function($m) {
4320 return isset($m[1]) ? trim($m[1],
'#') :
'.+';
4322 foreach ($a as $kn => $v) {
4323 if (preg_match(
'#^' . $pattern .
'$#i', $kn)) {
4324 if (strpos($kn,
'.') !==
false) {
4325 if ($a[$kn] !==
null) {
4329 $vn = self::getAssocValues($a, $kn . strstr($k,
'.'), $o);
4331 foreach ($vn as $k2 => $v2) {
4345 $kn = ltrim(strstr($k,
'.'),
'.');
4346 $on = substr($k, 0, -mb_strlen($kn));
4347 return self::getAssocValues($a[$p], $kn, $o . $on);
4351 } elseif (is_array($a)) {
4352 return [($o . $k) => $a[$k]];
4368 foreach ($array as $key => $value) {
4369 if (is_array($value)) {
4370 $converted[$key] = self::convertAssocArray($value);
4371 } elseif (($new_key = str_replace(
'__',
'.', $key)) != $key) {
4372 $keys = explode(
'.', $new_key);
4373 self::setAssocValue($converted[array_shift($keys)], implode(
'.', $keys), $value);
4375 $converted[$key] = $value;
4393 public static function getJSON($path, $values = [], $combine =
false, $ignore = [], $replace =
true, $no_cache =
false) {
4394 $cache = self::getCache();
4395 $cache_key =
'getJSON' . md5(json_encode(func_get_args()));
4396 $result = $cache->get($cache_key);
4398 if ($result ===
null || $no_cache) {
4399 $file = self::file_get_contents($path);
4400 if (!empty($file) && is_array($values2 = json_decode(trim($file),
true))) {
4401 $combined_values = !empty($values)
4404 ? array_replace_recursive($values, $values2)
4405 : array_replace_recursive($values2, $values)
4409 $recursive =
function($value, $keys = []) use (&$recursive, $combined_values, $values, $ignore) {
4410 if (!empty($keys) && in_array(implode(
'.', $keys), $ignore)) {
4412 } elseif (is_array($value)) {
4413 foreach ($value as $k => $v) {
4414 $value[$k] = $recursive($v, array_merge($keys, [$k]));
4418 && in_array($value[0], [
'+',
'-'])
4421 if ($old_value ===
null) {
4424 $array_value = explode(
',', substr($value, 1));
4425 switch ($value[0]) {
4427 $value = implode(
',', array_unique(array_merge(explode(
',', $old_value), $array_value)));
4430 $value = implode(
',', array_unique(array_diff(explode(
',', $old_value), $array_value)));
4432 return trim($value,
',');
4436 $result = $recursive($combined_values);
4438 $result = $combined_values;
4444 $cache->set($cache_key, $result);
4457 public static function setJSON($path, $values = array()) {
4458 return self::file_put_contents($path, str_replace(
" ",
"\t", json_encode($values, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)));
4468 return md5(is_array($value) ? json_encode($value, JSON_FORCE_OBJECT) : $value);
4479 $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
4481 if (array_key_exists($path, self::$cache)) {
4482 return self::$cache[$path];
4485 switch ($GLOBALS[
'egotec_conf'][
'site_cache_type']) {
4487 require_once(
'base/Ego_Cache_apcu.php');
4488 $cache =
new Ego_Cache_apcu($path);
4491 require_once($GLOBALS[
'egotec_conf'][
'var_dir'].
'lib/Ego_Cache_custom.php');
4492 $cache =
new Ego_Cache_custom($path);
4495 require_once(
'base/Ego_Cache_file.php');
4496 $cache =
new Ego_Cache_file($path);
4498 return (self::$cache[$path] = $cache);
4513 public static function setCookie($name, $value, $expires = 0, $path =
'/', $cross_domain =
true, $secure =
false, $httponly =
true) {
4515 if ($cross_domain) {
4518 isset($GLOBALS[
'egotec_conf'][
'auth'][
'cookie_domains'])
4519 && !empty($GLOBALS[
'egotec_conf'][
'auth'][
'cookie_domains'])
4521 foreach (explode(
',', $GLOBALS[
'egotec_conf'][
'auth'][
'cookie_domains']) as $d) {
4522 if (preg_match(
'/\.' . preg_quote(ltrim($d,
'.'),
'/') .
'$/i', $_SERVER[
'HTTP_HOST'])) {
4530 setcookie($name, $value, $expires, $path, $domain, $secure, $httponly);
4531 $_COOKIE[$name] = $value;
4545 public static function removeCookie($name, $expires = -1, $path =
'/', $cross_domain =
true, $secure =
false, $httponly =
true) {
4546 if (isset($_COOKIE[$name])) {
4547 self::setCookie($name,
null, $expires, $path, $cross_domain, $secure, $httponly);
4548 unset($_COOKIE[$name]);
4560 return md5(serialize($a)) == md5(serialize($b));
4579 public static function createCSV($path, $data, $delimiter =
',', $enclosure =
'"', $escape_char =
'\'') {
4580 $fp = fopen($path,
'w');
4581 foreach ($data as $line) {
4582 fputcsv($fp, $line, $delimiter, $enclosure, $escape_char);
4607 public static function createXML($path, $data, $root =
'root', $version =
'1.0', $encoding =
'UTF-8') {
4608 $xml =
'<?xml version="' . $version .
'" encoding="' . $encoding .
'"?>';
4609 $recursive =
function($data) use (&$recursive) {
4611 foreach ($data as $key => $value) {
4612 if (is_array($value)) {
4613 $result .=
"<{$key}>" . $recursive($value) .
"</{$key}>";
4615 if (is_string($value)) {
4616 $value =
"<![CDATA[{$value}]]>";
4618 $result .=
"<{$key}>{$value}</{$key}>";
4623 self::file_put_contents($path,
"{$xml}<{$root}>" . $recursive($data) .
"</{$root}>");
4636 public static function getContrastColor($color, $dark =
'#000000', $light =
'#ffffff',
int $minDiff = 0) {
4637 $backgroundRGB = self::hexToRGB($color, $color);
4638 $backgroundLuminance = self::getLuminance($backgroundRGB[
'r'], $backgroundRGB[
'g'], $backgroundRGB[
'b']);
4640 $darkRGB = self::hexToRGB($dark, $color);
4641 $darkLuminance = self::getLuminance($darkRGB[
'r'], $darkRGB[
'g'], $darkRGB[
'b']);
4643 $lightRGB = self::hexToRGB($light, $color);
4644 $lightLuminance = self::getLuminance($lightRGB[
'r'], $lightRGB[
'g'], $lightRGB[
'b']);
4647 $darkRatio = $backgroundLuminance >= $darkLuminance ? (($backgroundLuminance + 0.05) / ($darkLuminance + 0.05)) : (($darkLuminance + 0.05) / ($backgroundLuminance + 0.05));
4648 $lightRatio = $backgroundLuminance >= $lightLuminance ? (($backgroundLuminance + 0.05) / ($lightLuminance + 0.05)) : (($lightLuminance + 0.05) / ($backgroundLuminance + 0.05));
4650 return (($darkRatio >= $lightRatio) && (empty($minDiff) || $minDiff < abs(round($darkRatio - $lightRatio)))) ? $dark : $light;
4662 private static function getLuminance(
int $r,
int $g,
int $b): float {
4667 $rFinal = $rs <= 0.03928 ? $rs / 12.92 : pow(($rs + 0.055) / 1.055, 2.4);
4668 $gFinal = $gs <= 0.03928 ? $gs / 12.92 : pow(($gs + 0.055) / 1.055, 2.4);
4669 $bFinal = $bs <= 0.03928 ? $bs / 12.92 : pow(($bs + 0.055) / 1.055, 2.4);
4671 return 0.2126 * $rFinal + 0.7152 * $gFinal + 0.0722 * $bFinal;
4681 public static function hexToRGB(
string $hex,
string $background =
'#ffffff'): array {
4682 $hex = str_replace(
'#',
'', $hex);
4684 if (strlen($hex) != 3 && strlen($hex) != 6 && strlen($hex) !== 4 && strlen($hex) !== 8) {
4686 } elseif (strlen($hex) == 3) {
4687 $hex = str_split($hex);
4688 $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2];
4689 } elseif (strlen($hex) == 4) {
4690 $hex = str_split($hex);
4691 $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2];
4693 return self::getOpaqueColor([
4694 hexdec(substr($hex,0,2)),
4695 hexdec(substr($hex,2,2)),
4696 hexdec(substr($hex,4,2)),
4697 hexdec(
"$hex[3]$hex[3]") / 255.0
4698 ], self::hexToRGB($background));
4699 } elseif (strlen($hex) == 8) {
4700 return self::getOpaqueColor([
4701 hexdec(substr($hex,0,2)),
4702 hexdec(substr($hex,2,2)),
4703 hexdec(substr($hex,4,2)),
4704 hexdec(substr($hex, 6, 2)) / 255.0
4705 ], self::hexToRGB($background));
4709 'r' => hexdec(substr($hex,0,2)),
4710 'g' => hexdec(substr($hex,2,2)),
4711 'b' => hexdec(substr($hex,4,2)),
4716 $foregroundAlpha = floatval($color[3]);
4719 'r' => round(($color[0] * $foregroundAlpha) + ($background[0] * (1 - $foregroundAlpha))),
4720 'g' => round(($color[1] * $foregroundAlpha) + ($background[1] * (1 - $foregroundAlpha))),
4721 'b' => round(($color[2] * $foregroundAlpha) + ($background[2] * (1 - $foregroundAlpha)))
4735 if (!$once || !in_array($src, self::$includedHtml)) {
4736 $type = mb_strtolower(ltrim(strrchr($src,
'.'),
'.'));
4739 $html =
'<link rel="stylesheet" property="stylesheet" href="' . $src .
'" type="text/css">';
4742 $html =
'<script src="' . $src .
'"></script>';
4744 self::$includedHtml[] = $src;
4756 return $_SESSION[
'auth_id'] ===
null;
4766 return $GLOBALS[
'egotec_conf'][
'admin_mail'] ? $GLOBALS[
'egotec_conf'][
'admin_mail'] :
'support@egotec.com';
4780 !preg_match(
'#\.php$#', $path)
4791 private static function shell(String $php_command, String $command, Array $params = array(), &$output =
null, &$return_var =
null, $log =
true) {
4793 strpos($command,
" ") ===
false
4794 || ($command[0] ==
'"' && $command[-1] ==
'"' && strpos(substr($command, 1, -1),
'"') ===
false)
4795 ))
throw new RuntimeException(
'Please use parameter binding for security reasons!');
4800 foreach ($params as $value) {
4801 $value = (string) $value;
4802 if ($value[0]==
'-') {
4803 $pos = strpos($value,
' ');
4804 $pos2 = strpos($value,
'=');
4810 } elseif ($value[1]==
'-' && $pos>$pos2) {
4817 $command.=
" ".substr($value, 0, $pos).($eq?
"=":
" ").escapeshellarg(substr($value, $pos+1));
4819 $command.=
" ".$value;
4822 $command.=
" ".($pipe || in_array($value, array(
'|',
'<',
'<<',
'>',
'>>',
'2>>',
'&',
'&&',
'2>&1',
'2>&1 | tee')) ? $value : escapeshellarg($value));
4824 if ($value ==
'|') {
4832 egotec_warning_log($php_command.
' executing '.$command);
4835 switch ($php_command) {
4837 return exec($command, $output, $return_var);
4839 return system($command, $return_var);
4857 public static function exec(String $command, Array $params = array(), &$output =
null, &$return_var =
null, $log =
true) {
4858 return Ego_System::shell(
'exec', $command, $params, $output, $return_var, $log);
4874 public static function system(String $command, Array $params = array(), &$return_var =
null, $log =
true) {
4876 return Ego_System::shell(
'system', $command, $params, $output, $return_var, $log);
4889 public static function scan(
string $path,
bool $remove =
false,
bool $recursive =
true, ?array &$summary = []): void {
4890 $params = [$path,
'-m',
'--infected'];
4892 $params[] =
'--remove';
4895 $params[] =
'--recursive';
4898 $GLOBALS[
'egotec_conf'][
'files'][
'validate_command']
4899 ? $GLOBALS[
'egotec_conf'][
'files'][
'validate_command']
4907 if ($return_var !== 0) {
4908 switch ($return_var) {
4911 $message = $GLOBALS[
'auth']->translate(
'Die angegebene Ressource ist nicht sicher und wird verweigert.');
4916 $message = $GLOBALS[
'auth']->translate(
'Die Überprüfung der angegebenen Ressource ist fehlgeschlagen.');
4921 $message = $GLOBALS[
'auth']->translate(
'Bei der Überprüfung der Ressource ist ein unerwarteter Fehler aufgetreten.');
4923 throw new Exception($message, is_numeric($return_var) ? (
int) $return_var : -1);
4933 $ip = self::getIp();
4936 $GLOBALS[
'egotec_conf'][
'local_server_ips']
4937 ? explode(
',', $GLOBALS[
'egotec_conf'][
'local_server_ips'])
4938 : self::getDefaultLocalServerIps()
4943 isset($GLOBALS[
'egotec_conf'][
'local_server_mask']) &&
4944 substr($ip, 0, strlen($GLOBALS[
'egotec_conf'][
'local_server_mask'])) == $GLOBALS[
'egotec_conf'][
'local_server_mask']
4957 return array(
"127.0.0.1",
"localhost",
"::1",
"0:0:0:0:0:0:0:1", $_SERVER[
'SERVER_ADDR']);
4969 $original_array = $array;
4970 $recursive =
function($array, $keys = []) use (&$recursive, &$original_array) {
4971 foreach ($array as $key => $value) {
4972 if (is_array($value)) {
4973 foreach ($value as $key2 => $value2) {
4974 unset($original_array[$key]);
4975 if (is_array($value2)) {
4976 $recursive($value2, array_merge($keys, [$key], [$key2]));
4978 $original_array[array_merge($keys, [$key])[0].
'['.implode(
'][', array_slice(array_merge($keys, [$key], [$key2]), 1)).
']'] = $value2;
4981 } elseif (!empty($keys)) {
4982 $original_array[$keys[0].
'['.implode(
'][', array_slice(array_merge($keys, [$key]), 1)).
']'] = $value;
4986 $recursive($original_array);
4987 return $original_array;
4996 return implode(
'', (
4997 array_map(
function() {
4998 return dechex(rand(0, 15));
4999 }, array_fill(0, 32,
''))
5011 public static function convert(
string $src,
string $dest): void {
5046 foreach (self::VIDEO_RESOLUTIONS as $height => $scale) {
5047 if ($origHeight >= $height) {
5048 $tmp = tempnam($GLOBALS[
'egotec_conf'][
'tmp_dir'],
'video');
5049 $scale = preg_replace(
'/^\d+:/',
'-2:', $scale);
5066 [$origName, $suffix] = explode(
'.', $name, 2);
5067 $name =
"{$origName}_{$height}p.$suffix";
5070 if ($mediapool->
get(
"$origName.$suffix")) {
5071 $mediapool->
put($tmp, $name,
'_compress');
static getDimensions($file)
static filterNonUtf8($s, $substitute="", $strict=false)
static convertAssocArray($array)
static urltopage($url, $params=array(), $only_site=false, $error_page=false, $commit_params=false)
static clearCacheAllSites()
static getCache($path='_system')
static getUrlParams($url='')
static system(String $command, Array $params=array(), &$return_var=null, $log=true)
static truncate($string, $length, $etc='...', $break_words=false, $middle=false)
static exec(String $command, Array $params=array(), &$output=null, &$return_var=null, $log=true)
static addCronLock($cron_variable, $value, $expiry_date=0)
static getDirectorySize($pfad, &$links=array())
static getMimeTypes($ext='')
static file_put_contents($filename, $data, $flags=0, $context=null)
static encode_path($url, $id=0)
static convert(string $src, string $dest)
static getAssocValue($a, $k)
static getAssocValues($a, $k, $o='')
static getProtocol($https=false)
static parseCsvLine($str, $delimiter=';', $qualifier='"', $qualifierEscape = '\\')
static setJSON($path, $values=array())
static parseIniFile($file)
static write_ini_file($path, $assoc_array=array())
static getIp($anonymized=false)
static cleanTypes($value)
static getChecksum($value)
static readCronLock($cron_variable)
static getFallbackFile($type, $name, $path, $skip=array('module'), $url=false, $relative=false, $parent='')
static removeCookie($name, $expires=-1, $path='/', $cross_domain=true, $secure=false, $httponly=true)
static replaceLinks($content, $search, $replace)
static flushHeaders($headers)
static getVariantFiles($type, $name, $path, $skip=array(), $parent='')
static eternalCache($active, $clear=true)
static getDefaultLocalServerIps()
static compressMediapoolVideo(Mediapool $mediapool, string $file, string $name)
static deldir($location, $del=true, $without='', $rename=true)
static getFileDescriptorUsage()
static createCSV($path, $data, $delimiter=',', $enclosure='"', $escape_char = '\'')
static header($header, $replace=true)
const REGEX_EMAIL_OPTIONAL
static createXML($path, $data, $root='root', $version='1.0', $encoding='UTF-8')
static setIntranetReferer($page)
static getRequest($request=array())
static checkLicence($ini_path)
static dateEncode($string)
static getCluster($site=null)
static getFileInfo($file)
static sortPages($pages, $sorttype='field', $sortby='id', $sortdirection="asc")
static getOpaqueColor(array $color, array $background)
static includeHtml($src, $once=true)
static isDevMode($ignore=true)
const REGEX_EMAIL_ESCAPED
static isStatistic($token_auth)
static isCurrentUrl($url)
static getFiles($type, $name, $path, $skip=array(), $parent='', $return_path=false, $get_variants=true)
static getDefaultRobots($default='')
static arrayFlatRecursive($array, $callback=null)
static getDiff($diff1, $diff2)
static getUrlInfo($url, $encode=false)
static getAllSites($username='', $perm='', $table=false, $type='')
static arrayValuesRecursive($array)
static getContrastColor($color, $dark='#000000', $light='#ffffff', int $minDiff=0)
static hexToRGB(string $hex, string $background='#ffffff')
static file_exists($file)
static getDesktopSite($site)
static setAssocValue(&$a, $k, $v)
static getExceptionURL($params=array(), $placeholder=false)
static mkdir($dir, $mode=0755, $recursive=true)
static isEmptyContent($str)
static getLatestEgotecVersion()
static getFilePath($dir, $file)
static file_get_contents($filename, $utf8=true, $context=null)
static loadGlobalConfig()
static checkRequirements()
static decode_path( $url)
static commandExists($cmd)
static getJSON($path, $values=[], $combine=false, $ignore=[], $replace=true, $no_cache=false)
static scan(string $path, bool $remove=false, bool $recursive=true, ?array &$summary=[])
static redirect($location, $header=302, $params=[])
static setCronLock($expiry_date=0, $lock_msg="")
static getDbDriver($db=null)
static checkRequirePath($path)
static stringEncode($string, $from='UTF-8', $to='UTF-8')
static escape($string, $esc_type='html', $char_set='UTF-8')
static copy($src, $dest, $except='', $useLinks=false, $noArchive=false, $preserveDate=false)
static checkEncoding($from='CP1252', $to='UTF-8', $original, $converted)
static getSkins($more_themes=array())
static endless($string='', $flush=true)
static byte_format($byte)
static clearTypeCache($site_name='')
static setCookie($name, $value, $expires=0, $path='/', $cross_domain=true, $secure=false, $httponly=true)
static getDiskUsage($recalc=false)
static log($file, $message)
static createIdentity($params)
static byIdentity($identity, $param=array(), $site=null)