29 if (isset($assets) && (!empty($assets) && (is_array($assets))))
35 $assetItems = count($assets);
47 foreach ($assets as $asset =>
$type)
50 if (
$res =
$db->query((
"SELECT asset FROM {assets}
51 WHERE asset = '" . $asset .
"'
52 AND templateID = '".$templateID.
"'")))
54 if ($row = (mysqli_fetch_row(
$res)))
64 if (isset($switch) && ($switch ==
'true'))
66 if (
$res =
$db->query(
"SELECT * FROM {assets_types} WHERE asset = '".$asset.
"'"))
68 while ($row = (mysqli_fetch_assoc(
$res)))
71 if (isset($row[
'internal']) && (!empty($row[
'internal'])))
73 $row[
'link'] = $row[
'internal'];
75 elseif (isset($row[
'url1']) && (!empty($row[
'url1'])))
77 $row[
'link'] = $row[
'url1'];
81 if (
$db->query(
"INSERT INTO {assets} (templateID, type, sortation, asset, link) VALUES ('" .
$templateID .
"', '" .
$type .
"', '" . $row[
'sortation'].
"','" . $row[
'asset'] .
"', '" . $row[
'link'] .
"')"))
87 return \YAWK\alert::draw(
"danger",
"ERROR",
"Unable to insert Asset into Assets database. Please add this asset $asset manually.",
"", 12000);
95 return \YAWK\alert::draw(
"danger",
"ERROR",
"Required Asset is not in the database! Please check, if this asset is registered!",
"", 12000);
101 return \YAWK\alert::draw(
"warning",
"Warning - please check this!",
"Unable to load asset! $asset Please check required template assets manually!",
"", 12000);
107 return \YAWK\alert::draw(
"warning",
"Warning - this widget requires an additional asset!",
"Asset $asset not loaded! Please load this asset within system/asset settings.",
"", 12000);
112 if ($assetItems === $successful)
115 return \YAWK\alert::draw(
"success",
"Asset System Information",
"I have found out that the required asset was not loaded. I've successfully fixed this for you.",
"", 6200);
120 return \YAWK\alert::draw(
"warning",
"Warning - please check this!",
"Unable to load asset! $asset Please check required template assets manually!",
"", 12000);
137 if (!isset($array) || (!isset($property)))
139 echo
'array or property not set';
142 if (isset($array) && (isset($array[$property]) && (isset($property))))
144 echo
"<h2 class=\"myClass\">$property</h2>";
145 foreach ($array[$property] as
$item => $key)
147 $linkProperty = str_replace(
" ",
"+",
$item);
150 echo
"<li class=\"list-group-item\"><a href=\"https://www.google.at/search?q=php.net+$linkProperty\" title=\"google this: $item setting\" target=\"_blank\"><b>$item</b> = $key[0]</a></li>";
154 echo
"<li class=\"list-group-item\"><a href=\"https://www.google.at/search?q=php.net+$linkProperty\" title=\"google this: $item setting\" target=\"_blank\"><b>$item</b> = $key</a></li>";
172 function myFunction() {
174 var input, filter, ul, li, a, i;
175 input = document.getElementById('myInput');
176 filter = input.value.toUpperCase();
177 ul = document.getElementById(\"phpinfoList\");
178 li = ul.getElementsByTagName('li');
180 // Loop through all list items, hide those who don't match the search query
181 for (i = 0; i < li.length; i++) {
182 a = li[i].getElementsByTagName(\"a\")[0];
183 if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {
184 li[i].style.display = \"\";
185 $('.myClass').show();
187 li[i].style.display = \"none\";
188 $('.myClass').hide();
195 echo
"<input type=\"text\" id=\"myInput\" class=\"form-control\" onkeyup=\"myFunction()\" placeholder=\"$lang[SEARCH_DOTDOTDOT]\">";
196 echo
"<ul id=\"phpinfoList\" class=\"list-group\">";
259 echo
"<h2><small>".strtoupper($property).
"</small></h2>";
260 foreach ($array[$property] as
$item => $key)
262 echo
"<b>$item</b> = $key[0]<br>";
275 ob_start(); phpinfo(INFO_MODULES); $s = ob_get_contents(); ob_end_clean();
276 $s = strip_tags($s,
'<h2><th><td>');
277 $s = preg_replace(
'/<th[^>]*>([^<]+)<\/th>/',
'<info>\1</info>', $s);
278 $s = preg_replace(
'/<td[^>]*>([^<]+)<\/td>/',
'<info>\1</info>', $s);
279 $t = preg_split(
'/(<h2[^>]*>[^<]+<\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE);
280 $r = array(); $count = count($t);
281 $p1 =
'<info>([^<]+)<\/info>';
282 $p2 =
'/'.$p1.
'\s*'.$p1.
'\s*'.$p1.
'/';
283 $p3 =
'/'.$p1.
'\s*'.$p1.
'/';
284 for (
$i = 1;
$i < $count;
$i++) {
285 if (preg_match(
'/<h2[^>]*>([^<]+)<\/h2>/', $t[
$i], $matchs)) {
286 $name = trim($matchs[1]);
287 $vals = explode(
"\n", $t[
$i + 1]);
288 foreach ($vals AS $val) {
289 if (preg_match($p2, $val, $matchs)) {
290 $r[
$name][trim($matchs[1])] = array(trim($matchs[2]), trim($matchs[3]));
291 } elseif (preg_match($p3, $val, $matchs)) {
292 $r[
$name][trim($matchs[1])] = trim($matchs[2]);
306 return substr($_SERVER[
'SCRIPT_NAME'], 0, strpos($_SERVER[
'SCRIPT_NAME'],basename($_SERVER[
'SCRIPT_NAME'])));
317 if (!isset($length) || (empty($length) || (!is_int($length))))
322 $chars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
324 $password = substr(str_shuffle($chars), 0, $length);
336 $robotsText =
"$path/robots.txt";
337 $file = file_get_contents($robotsText);
366 if (file_put_contents(
"$filename",
"$content"))
385 $handle = opendir($path);
388 while (
false !== ($file = readdir($handle)))
390 if ($file !=
"." && $file !=
"..")
394 $files_count = $files_count + 1;
396 $name = $path .
"/" . $file;
409 $files_count = $files_count + 1;
432 if (substr(
$value, -4) ===
"$fileType") {
434 $i_lines = count($lines);
435 $linesCount += $i_lines;
436 unset($lines, $i_lines);
442 "files" => $filesCount,
443 "lines" => $linesCount,
453 if(extension_loaded(
'zlib'))
473 static function xcopy($source, $dest, $permissions = 0755)
475 if (is_link($source))
477 return symlink(readlink($source), $dest);
480 if (is_file($source))
482 if (copy($source, $dest) ===
false)
490 if (!@mkdir($dest, $permissions)) {
504 while (
false !== $entry = $dir->read())
507 if ($entry ==
'.' || $entry ==
'..')
512 if (self::xcopy(
"$source/$entry",
"$dest/$entry", $permissions))
535 $content = str_replace(array(
"\r\n",
"\r",
"\n",
"\t",
' ',
' ',
' '),
'',
$content);
549 if(trim($input) ===
"")
return $input;
551 $input = preg_replace_callback(
'#<([^\/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(\/?)>#s',
function($matches) {
552 return '<' . $matches[1] . preg_replace(
'#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s',
' $1$2', $matches[2]) . $matches[3] .
'>';
553 }, str_replace(
"\r",
"", $input));
555 if(strpos($input,
' style=') !==
false) {
556 $input = preg_replace_callback(
'#<([^<]+?)\s+style=([\'"])(.*?)\2(?=[\/\s>])#s',
function($matches) {
557 return '<' . $matches[1] .
' style=' . $matches[2] .
self::minifyCSS($matches[3]) . $matches[2];
560 if(strpos($input,
'</style>') !==
false) {
561 $input = preg_replace_callback(
'#<style(.*?)>(.*?)</style>#is',
function($matches) {
562 return '<style' . $matches[1] .
'>'.
self::minifyCSS($matches[2]) .
'</style>';
565 if(strpos($input,
'</script>') !==
false) {
566 $input = preg_replace_callback(
'#<script(.*?)>(.*?)</script>#is',
function($matches) {
567 return '<script' . $matches[1] .
'>'.
self::minifyJs($matches[2]) .
'</script>';
576 '#<(img|input)(>| .*?>)#s',
578 '#(<!--.*?-->)|(>)(?:\n*|\s{2,})(<)|^\s*|\s*$#s',
579 '#(<!--.*?-->)|(?<!>)\s+(<\/.*?>)|(<[^\/]*?>)\s+(?!<)#s',
580 '#(<!--.*?-->)|(<[^\/]*?>)\s+(<[^\/]*?>)|(<\/.*?>)\s+(<\/.*?>)#s',
581 '#(<!--.*?-->)|(<\/.*?>)\s+(\s)(?!<)|(?<!>)\s+(\s)(<[^\/]*?\/?>)|(<[^\/]*?\/?>)\s+(\s)(?!<)#s',
582 '#(<!--.*?-->)|(<[^\/]*?>)\s+(<\/.*?>)#s',
583 '#<(img|input)(>| .*?>)<\/\1>#s',
584 '#( ) (?![<\s])#',
585 '#(?<=>)( )(?=<)#',
587 '#\s*<!--(?!\[if\s).*?-->\s*|(?<!>)\n+(?=<[^!])#s'
615 if(trim($input) ===
"")
return $input;
619 '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
621 '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~+]|\s*+-(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
623 '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
625 '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
627 '#(background-position):0(?=[;\}])#si',
629 '#(?<=[\s:,\-])0+\.(\d+)#s',
631 '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
632 '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
634 '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
636 '#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
638 '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
665 if(trim($input) ===
"")
return $input;
669 '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
671 '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
675 '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
677 '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
700 while (FALSE !== ($entry = $d->read()))
702 if ($entry ==
'.' || $entry ==
'..')
706 $Entry = $source.
'/'.$entry;
712 copy($Entry, $target.
'/'.$entry);
718 copy( $source, $target );
735 if (!isset($on) || (empty($on)))
740 if (!isset($off) || (empty($off)))
754 $status =
"error: \$i status undefined";
772 return str_replace(array(
"\n\r",
"\n",
"\r"), $replace, $string);
786 $preOpen =
"<pre style=\"word-wrap: break-word; white-space: pre-wrap;\">";
787 $preClose =
"</pre>";
801 return str_replace(array(
"<p>",
"</p>",
"<br />",
"</pre>",
"<pre style=\"word-wrap: break-word; white-space: pre-wrap;\">"),
"",
$customCSS);
809 static function isOffline(
$db)
814 if (\
YAWK\user::isAdmin(
$db) ==
false)
833 static function drawOfflineMessage(
$db)
840 echo
"<script src=\"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.min.js\"></script>";
842 echo
"<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css\">";
844 echo
"<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js\"></script>";
846 echo
"<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css\" />";
849 echo
"<div class=\"row\">";
850 echo
"<div class=\"col-md-12 text-center\">
851 <img src=\"".$offlineimg.
"\" class=\"img-responsive img-fluid mx-auto mt-5 mb-5 animated flipInX\" title=\"This website is under construction. Come back again later.\">
852 <div class=\"animated fadeIn\">".$offlinemsg.
"</div>
866 print
"<script type=\"text/javascript\">
867 setTimeout(\"self.location.href='" . $location .
"'\"," . $wait .
");
870 <h1>Im Browser muss javascript aktiviert sein, um die Seite richtig nutzen zu können.</h1>
883 if (ini_get(
'browscap'))
885 $browscapFile = ini_get(
'browscap');
887 echo
"<pre>"; print_r(get_browser(
$useragent)); echo
"</pre>";
891 \YAWK\alert::draw(
"info",
"Warning!",
"Browscap file not set in your php.ini",
"", 7500);
893 if (ini_set(
'browscap',
'browscap.ini'))
895 echo
"<pre>"; print_r(get_browser(
$useragent)); echo
"</pre>";
919 $u_agent = $_SERVER[
'HTTP_USER_AGENT'];
922 $platform =
'Unknown';
927 if (preg_match(
'/linux/i', $u_agent)) {
930 elseif (preg_match(
'/macintosh|mac os x/i', $u_agent)) {
933 elseif (preg_match(
'/windows|win32/i', $u_agent)) {
934 $platform =
'windows';
936 elseif(preg_match(
'/linux|android/i',$u_agent))
940 $platform =
"Android";
944 if(preg_match(
'/MSIE/i',$u_agent) && !preg_match(
'/Opera/i',$u_agent))
946 $bname =
'Internet Explorer';
949 if(preg_match(
'/Edge/i',$u_agent) && !preg_match(
'/Opera/i',$u_agent))
954 elseif(preg_match(
'/Trident/i',$u_agent))
956 $bname =
'Internet Explorer';
959 elseif(preg_match(
'/Firefox/i',$u_agent))
961 $bname =
'Mozilla Firefox';
964 elseif(preg_match(
'/Chrome/i',$u_agent))
966 $bname =
'Google Chrome';
969 elseif(preg_match(
'/Safari/i',$u_agent))
971 $bname =
'Apple Safari';
974 elseif(preg_match(
'/Opera/i',$u_agent))
979 elseif(preg_match(
'/Netscape/i',$u_agent))
987 $known = array(
'Version', $ub,
'other');
988 $pattern =
'#(?<browser>' . join(
'|', $known) .
989 ')[/|: ]+(?<version>[0-9.|a-zA-Z.]*)#';
990 if (!preg_match_all($pattern, $u_agent, $matches)) {
995 $i = count($matches[
'browser']);
999 if (strripos($u_agent,
"Version") < strripos($u_agent,$ub)){
1000 $version= $matches[
'version'][0];
1003 $version= $matches[
'version'][1];
1007 $version= $matches[
'version'][0];
1011 if ($version==
null || $version==
"") {$version=
"?";}
1014 'userAgent' => $u_agent,
1016 'version' => $version,
1017 'platform' => $platform,
1018 'pattern' => $pattern
1034 $u_agent = $_SERVER[
'HTTP_USER_AGENT'];
1038 '/Sec-CH-UA-Platform/i' =>
'Windows 11',
1039 '/Windows NT 10.0/i' =>
'Windows 10',
1040 '/windows nt 6.2/i' =>
'Windows 8',
1041 '/windows nt 6.1/i' =>
'Windows 7',
1042 '/windows nt 6.0/i' =>
'Windows Vista',
1043 '/windows nt 5.2/i' =>
'Windows Server 2003/XP x64',
1044 '/windows nt 5.1/i' =>
'Windows XP',
1045 '/windows xp/i' =>
'Windows XP',
1046 '/windows nt 5.0/i' =>
'Windows 2000',
1047 '/windows me/i' =>
'Windows ME',
1048 '/win98/i' =>
'Windows 98',
1049 '/win95/i' =>
'Windows 95',
1050 '/win16/i' =>
'Windows 3.11',
1051 '/macintosh|mac os x/i' =>
'Mac OS X',
1052 '/mac_powerpc/i' =>
'Mac OS 9',
1053 '/linux/i' =>
'Linux',
1054 '/ubuntu/i' =>
'Ubuntu',
1055 '/iphone/i' =>
'iPhone',
1056 '/ipod/i' =>
'iPod',
1057 '/ipad/i' =>
'iPad',
1058 '/android/i' =>
'Android',
1059 '/blackberry/i' =>
'BlackBerry',
1060 '/webos/i' =>
'Mobile'
1063 foreach ($os_array as $regex =>
$value) {
1064 if (preg_match($regex, $u_agent)) {
1068 return $os_platform;
1079 $debugTime = microtime(
true) - $debugTime;
1080 $debugTime = number_format($debugTime, 3);
1081 return "<small> script execution time: $debugTime Sek.</small>";
1092 $chars = array(
"ö" =>
"ö",
"ä" =>
"ä",
"ü" =>
"ü",
1093 "Ö" =>
"Ö",
"Ä" =>
"Ä",
"Ü" =>
"Ü",
1096 return strtr($string, $chars);
1128 if (is_dir(dirname($dir)))
1130 $files = array_diff(scandir($dir), array(
'.',
'..'));
1131 foreach ($files as $file) {
1132 (is_dir(
"$dir/$file")) ? self::recurseRmdir(
"$dir/$file") : unlink(
"$dir/$file");
1149 if (substr(
$url, -1, 1) !==
"/")
1167 if (
$res =
$db->query(
"SELECT " . $property .
" FROM {$table}
1168 WHERE id = '" .
$id .
"'"))
1170 if ($row = mysqli_fetch_row(
$res))
1194 if (
$res =
$db->query(
"SELECT cg.id
1195 FROM {".$table.
"} as cp
1196 JOIN {user_groups} as cg on cg.id = cp.gid
1197 WHERE cp.id = $id"))
1199 $row = mysqli_fetch_row(
$res);
1204 \YAWK\alert::draw(
"warning",
"Warning",
"Could not fetch Group ID from $table",
"",
"2000");
1220 if (
$res =
$db->query(
"SELECT cp.gid, cg.value
1221 FROM {".$table.
"} as cp
1222 JOIN {user_groups} as cg on cg.id = cp.gid
1223 WHERE cp.id = $id"))
1225 while ($row = mysqli_fetch_row(
$res))
1232 \YAWK\alert::draw(
"warning",
"Warning",
"Could not fetch Group from page ID $id",
"",
"2000");
1247 $groupsArray = array();
1248 if (
$res =
$db->query(
"SELECT id, value, (
1251 WHERE gid = {user_groups.id}
1253 FROM {user_groups} ORDER by id ASC"))
1255 while ($row =
$res->fetch_assoc())
1257 $groupsArray[] = $row;
1259 return $groupsArray;
1270 static function includeHeader(
$db,
$host)
1272 global $currentpage;
1274 echo
"<title>" . $currentpage->title .
"</title>
1275 <base href=\"".$host.
"\">
1276 <meta http-equiv=\"Content-Type\" content=\"text/html\">
1277 <link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/x-icon\">";
1286 if (isset($_SESSION[
'username'])) {
1287 return $_SESSION[
'username'];
1303 if (
$res =
$db->query(
"SELECT m.id
1305 JOIN {menu_names} as m on m.id = p.menu
1306 WHERE p.id = $id")){
1307 $row = mysqli_fetch_row(
$res);
1308 if (!isset($row[0]) ||(empty($row[0])))
1332 if ($row =
$db->query(
"SELECT p.menu, m.name
1334 JOIN {menu_names} as m on m.id = p.menu
1337 $res = mysqli_fetch_row($row);
1338 if (isset(
$res[1])){
1356 static function getMenus(
$db)
1359 $menusArray = array();
1360 if (
$res =
$db->query(
"SELECT id, name, published, (
1363 WHERE menuID = {menu_names.id}
1364 ) count FROM {menu_names}"))
1366 while ($row =
$res->fetch_assoc())
1368 $menusArray[] = $row;
1386 if (
$res =
$db->query(
"SELECT name
1390 $row = mysqli_fetch_row(
$res);
1407 if (
$res =
$db->query(
"SELECT menuLanguage
1411 $row = mysqli_fetch_row(
$res);
1425 static function getPages(
$db)
1427 if ($row =
$db->query(
"SELECT id, title
1428 FROM {pages} ORDER BY title"))
1430 $PagesArray = array();
1431 while (
$res = $row->fetch_assoc())
1433 $pagesArray[] =
$res;
1451 static function getRole(
$db,
$id, $table)
1453 $mysqlRes =
$db->query(
"SELECT cp.gid, cg.value
1454 FROM {".$table.
"} as cp
1455 JOIN {user_groups} as cg on cg.id = cp.gid
1456 WHERE cp.id = '".
$id.
"'");
1458 while ($row = mysqli_fetch_row($mysqlRes)) {
1471 static function getRoleId(
$db,
$id, $table)
1473 $mysqlRes =
$db->query(
"SELECT cg.id
1474 FROM {".$table.
"} as cp
1475 JOIN {user_groups} as cg on cg.id = cp.gid
1476 WHERE cp.id = $id");
1478 if ($row = mysqli_fetch_row($mysqlRes))
1494 return date(
"Y-m-d H:i:s");
1504 $year = substr(
$date, 0, 4);
1505 $day = substr(
$date, 8, 2);
1506 $month = substr(
$date, 5, 2);
1507 $time = substr(
$date, 11, 5);
1519 $month =
"February";
1547 $month =
"September";
1555 $month =
"November";
1559 $month =
"December";
1563 return $splitDate = array(
"year" =>
"$year",
"day" =>
"$day",
"month" =>
"$month",
"time" =>
"$time");
1574 $year = substr(
$date, 0, 4);
1575 $day = substr(
$date, 8, 2);
1576 $month = substr(
$date, 5, 2);
1577 $time = substr(
$date, 11, 5);
1621 return $splitDate = array(
"year" =>
"$year",
"day" =>
"$day",
"month" =>
"$month",
"time" =>
"$time");
1634 $date = new \DateTime($userdate);
1635 $diff =
$date->diff(
new \DateTime(
'now'));
1637 if ($t = $diff->format(
"%y"))
1641 $time_ago = (int)$t .
' '.
$lang[
'YEARS'].
'';
1645 $time_ago = (int)$t .
' '.
$lang[
'YEAR'].
'';
1649 elseif ($t = $diff->format(
"%m"))
1653 $time_ago = (int)$t .
' '.
$lang[
'MONTHS'].
'';
1657 $time_ago = (int)$t .
' '.
$lang[
'MONTH'].
'';
1660 elseif ($t = $diff->format(
"%d"))
1663 if ($t >= 7 && $t < 13)
1665 $time_ago =
$lang[
'A_WEEK_AGO'];
1667 elseif ($t >= 14 && $t < 20)
1669 $time_ago =
$lang[
'TWO_WEEKS_AGO'];
1671 elseif ($t >= 21 && $t < 27)
1673 $time_ago =
$lang[
'THREE_WEEKS_AGO'];
1675 elseif ($t >= 28 && $t < 31)
1677 $time_ago =
$lang[
'FOUR_WEEKS_AGO'];
1681 $time_ago = (int)$t .
' '.
$lang[
'DAYS_P'].
'';
1685 $time_ago = (int)$t .
' '.
$lang[
'DAY'].
'';
1689 elseif ($t = $diff->format(
"%h"))
1693 $time_ago = (int)$t .
' '.
$lang[
'HOURS'].
'';
1697 $time_ago = (int)$t .
' '.
$lang[
'HOUR'].
'';
1701 elseif ($t = $diff->format(
"%i"))
1705 $time_ago = (int)$t .
' '.
$lang[
'MINUTES'].
'';
1709 $time_ago = (int)$t .
' '.
$lang[
'MINUTE'].
'';
1713 elseif ($t = $diff->format(
"%s"))
1717 $time_ago =
$lang[
'LESS_THAN_A_MINUTE'];
1724 return $lang[
'AGO'] .
' '.$time_ago.
'';
1727 return $time_ago .
' '.$lang[
'AGO'].
'';
1745 case "$lang[MONDAY]":
1746 $weekday =
"$lang[MONDAY]";
1748 case "$lang[TUESDAY]":
1749 $weekday =
"$lang[TUESDAY]";
1751 case "$lang[WEDNESDAY]":
1752 $weekday =
"$lang[WEDNESDAY]";
1754 case "$lang[THURSDAY]":
1755 $weekday =
"$lang[THURSDAY]";
1757 case "$lang[FRIDAY]":
1758 $weekday =
"$lang[FRIDAY]";
1760 case "$lang[SATURDAY]":
1761 $weekday =
"$lang[SATURDAY]";
1763 case "$lang[SUNDAY]":
1764 $weekday =
"$lang[SUNDAY]";
1781 static function isSysLogCategoryActive(
$db, $syslogCategoryID)
1783 $syslogSettings = arraY();
1784 if(isset($syslogCategoryID) && (!empty($syslogCategoryID)))
1786 if (
$sql = (
$db->query(
"SELECT active, notify from {syslog_categories} WHERE id = '".$syslogCategoryID.
"'")))
1789 while ($row = mysqli_fetch_assoc(
$sql))
1791 $syslogSettings[] = $row;
1794 if (isset($syslogSettings[
'active']) && (!empty($active[
'active']) && ($active[
'active'] ===
"1")))
1796 $syslogSettings[
'active'] = 1;
1800 $syslogSettings[
'active'] = 0;
1803 if (isset($syslogSettings[
'notify']) && (!empty($active[
'notify']) && ($active[
'notify'] ===
"1")))
1805 $syslogSettings[
'notify'] = 1;
1809 $syslogSettings[
'notify'] = 0;
1814 $syslogSettings[
'active'] = 1;
1815 $syslogSettings[
'notify'] = 1;
1816 return $syslogSettings;
1818 return $syslogSettings;
1822 $syslogSettings[
'active'] = 1;
1823 $syslogSettings[
'notify'] = 1;
1824 return $syslogSettings;
1835 $logfile =
'debug_log.txt';
1836 $timestamp =
date(
'Y-m-d H:i:s');
1837 file_put_contents($logfile,
"[$timestamp] $message\n", FILE_APPEND);
1852 static function setSyslog(
$db, $log_category, $log_type, $message,
$fromUID,
$toUID, $toGID, $seen)
1864 if (!isset($log_category) || (empty($log_category) || ($log_category ===
"0")))
1869 if (!isset($message) || (empty($message) || ($message ===
"0")))
1872 $message =
"something happened, but no text was set for logging. $page";
1876 if (!isset($log_type) ||(empty($log_type)))
1884 if (isset($_SESSION[
'uid']))
1896 $syslogSettings = self::isSysLogCategoryActive(
$db, $log_category);
1898 if (isset($syslogSettings[0][
'notify']) && ($syslogSettings[0][
'notify'] == 1))
1908 if (isset($syslogSettings[0][
'active']) && ($syslogSettings[0][
'active'] == 1))
1911 if (
$db->query(
"INSERT INTO {syslog} (log_date, log_category, log_type, message, fromUID, toUID, toGID, seen)
1912 VALUES ('".$log_date.
"',
1913 '".$log_category.
"',
1944 static function getSyslog(
$db)
1947 $syslogResults = array();
1948 if (
$res =
$db->query(
"SELECT * FROM {syslog} AS log
1949 LEFT JOIN {syslog_categories} AS category ON log.log_category=category.id
1950 LEFT JOIN {users} AS u ON log.fromUID=u.id
1952 ORDER BY log.log_date DESC"))
1954 while ($row = mysqli_fetch_assoc(
$res))
1957 $syslogResults[] = $row;
1960 if (is_array($syslogResults) && (!empty($syslogResults)))
1962 return $syslogResults;
1980 static function getSyslogCategories(
$db)
1984 if (
$res =
$db->query(
"SELECT * FROM {syslog_categories} ORDER BY property"))
1986 while ($row = mysqli_fetch_assoc(
$res))
2025 if (
$db->query(
"INSERT INTO {notifications} (log_type,msg_id,fromUID,toUID,toGID,seen)
2026 VALUES ('".$log_category.
"',
2049 static function markNotification(
$db,
$id, $seen)
2055 if (
$db->query(
"UPDATE {notifications} SET seen = '".$seen.
"' WHERE log_id = '".
$id.
"'"))
2070 $objects = get_defined_vars();
2071 if (isset($objects) && (is_array($objects)))
2073 echo
"ALL DECLARED OBJECTS IN THIS SCOPE:<hr>";
2074 echo
"<pre>";print_r($objects);echo
"</pre><hr>";
2088 foreach($array as $key => $val)
2093 foreach($val as $skey => $sval)
$res[] =
"$skey = ".(is_numeric($sval) ? $sval :
'"'.$sval.
'"');
2095 else $res[] =
"$key = ".(is_numeric($val) ? $val :
'"'.$val.
'"');
2097 if (self::safeFileReWrite($file, implode(
"\r\n",
$res)))
2115 if ($fp = fopen($fileName,
'w'))
2117 $startTime = microtime(TRUE);
2120 $canWrite = flock($fp, LOCK_EX);
2122 if(!$canWrite) usleep(round(rand(0, 100)*1000));
2124 while ((!$canWrite)and((microtime(TRUE)-$startTime) < 5));
2129 fwrite($fp, $dataToSave);
2130 flock($fp, LOCK_UN);
2134 if (is_file($fileName))
print $lang['FILEMAN_UPLOAD']
if(!isset($language)||(!isset($lang))) $item
static draw($type, $title, $text, $redirect, $delay)
static getCurrentLanguageStatic()
returns the currently set backend language, but is static callable
static getSetting($db, $property)
Get and return value for property from settings database.
static getLongSetting($db, $property)
Get and return longValue for property from settings database.
The sys class - handles yawk's system core functions.
static splitDate($date)
split a date to month, day, year and time
static minify($content)
Minify any string: removes spaces, tabs and linebreaks.
static xcopy($source, $dest, $permissions=0755)
Copy a file, or recursively copy a folder and its contents.
static getGroupId($db, $id, $table)
get requested group ID for given page ID (used in page-edit)
static minifyCSS($input)
Minify any string: removes spaces, tabs and linebreaks.
static replacePreTags($replace, $customCSS)
removes all unnecessary HTML tags from custom.css
static getWeekday($date, $lang)
return weekday from given date
static time_ago($userdate, $lang)
how many time is been gone since given date
static minifyHTML($input)
HTML Minifier - minify any string: removes spaces, tabstops and linebreaks.
static recurseRmdir($dir)
remove a directory recurse
static generateRandomPassword($length)
Generate a random password with given length.
static safeFileReWrite($fileName, $dataToSave)
Safe way to open a file and update data.
static read_recursive($path)
Read a directory recursively.
static getSubMenu($db, $id)
get submenu ID for given page ID
static drawPhpInfo($lang)
Display a complete PHPinfo()
static getDirPrefix($db)
if yawk is installed into a subdirectory, use this to get this prefix directory
static setTimeout($location, $wait)
set a timeout and force page reload via JS
static outputObjects($template, $lang, $controller, $page, $user, $stats)
check if objects exists and display their data
static getLoadingTime($debugTime)
measure script loading time
static getMenuName($db, $id)
returns menu name for given menu ID
static full_copy($source, $target)
copy an entire folder including subdirectories
static multiarray2lines($array, $property)
Display a multidimensional array line per line. Expects an array and property.
static splitDateShort($date)
split a date to month, day, year and time this is the same as splitDate() but keep the months short
static minifyJs($input)
Minify any string: removes spaces, tabs and linebreaks.
static getHost($db)
get hostname (url where yawk is installed) from database
static getRobotsText($db, $path)
Return the content of /robots.txt.
static array2lines($array, $property)
Display a multidimensional array line per line. Expects an array and property.
static iStatusToString($i, $on, $off)
convert a integer status to string variable (0|1) to online / offline
static checkIfAssetsAreLoaded($db, $assets, $switch)
Check if assets are loaded, load if switch is true.
static countCodeLines($path, $fileType)
Count code lines and output a small overview.
static writeIniFile($array, $file)
write ini file
static addPreTags($customCSS)
THIS SEEMS OUTDATED - obviously not needed anymore....
static addTrailingSlash($url)
sometimes it is necessary to add a slash to a url.
static getCurrentUserName()
returns the current user name, if set
static getMenuLanguage($db, $id)
returns menu language for given menu ID
static getBrowser($useragent)
extract browser from useragent
static checkZlib()
Check if zlib is available.
static getGroups($db, $table)
get all user groups from database
static getGroupFromId($db, $id, $table)
get requested group ID for given page ID
static replaceCarriageReturns($replace, $string)
replace all carriage returns with linebreaks
static isBrowscapSet($useragent)
check if browscap file is set
static getProperty($db, $property, $table, $id)
get any property from any table where id is given ID
static getMenuItem($db, $id)
get menu item for given page ID
static getBaseDir()
Return current base directory.
static encodeChars($string)
convert german special chars and vowels into legal html
static parse_phpinfo()
Read phpinfo() into multidimensional array and return it.
static getOS($useragent)
get operating system from useragent string
static now()
returns the current datetime
logMessage($message)
log message to debug_log.txt
static setRobotsText($path, $content)
Set the content of /robots.txt (overwrite)
static getCurrentTemplateId(object $db)
return ID of current (active) template
This class serves methods to create backup from files.
if(!isset($page)) if(!isset($db)) if(!isset($lang)) if(isset($_GET['id'])) if(isset($_POST['save'])) $dirprefix