This is the source code for the website of Serenum.
https://serenum.org
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
257 lines
12 KiB
257 lines
12 KiB
<?php |
|
|
|
use ChrisUllyott\FileSize; |
|
use WideImage\WideImage; |
|
use h4kuna\Number; |
|
|
|
|
|
|
|
function url($string, $pure = false) { |
|
global $host, $latitude_shorten, $longitude_shorten, $settings_gps, $settings_unit, $settings_language, $settings_decimal, $settings_time, $settings_theme, $settings_updategps, $settings_apikey; |
|
|
|
$prefix = (($host == 'localhost' OR strpos($host, '192.168') !== false) ? '/'.basename(__DIR__).'/' : '/beta/'); |
|
$settings = ($pure == true ? null : 'lat:'.$latitude_shorten.',lng:'.$longitude_shorten.'/settings:'.$settings_unit.','.$settings_language.','.$settings_decimal.','.$settings_time.','.$settings_theme.'/fine-tune:'.$settings_updategps . ($settings_apikey == null ? null : '/apikey:'.$settings_apikey)); |
|
$suffix = (empty($string) ? null : ($pure == true ? null : '/') . $string); |
|
|
|
return $prefix . $settings . $suffix; |
|
} |
|
|
|
function link_($string, $link) { |
|
return '<a href="'.$link.'" target="_blank" rel="noreferrer">'.$string.'</a>'; |
|
} |
|
|
|
function check_permissions($string) { |
|
return substr(sprintf('%o', fileperms($string)), -4); |
|
} |
|
|
|
function format_number($string, $decimals = 1, $decimal = 'comma') { |
|
$numberFormat = new Number\NumberFormatState([ |
|
'decimals' => $decimals, |
|
'zeroClear' => true, |
|
'decimalPoint' => ($decimal == 'comma' ? ',' : '.') |
|
]); |
|
|
|
return $numberFormat->format($string); |
|
} |
|
|
|
function create_folder($string) { |
|
if(!file_exists($string)) { |
|
$oldmask = umask(0); |
|
mkdir($string, 0777); |
|
umask($oldmask); |
|
} |
|
} |
|
|
|
function die_content($title, $string) { |
|
global $config_development, $cdnurl; |
|
|
|
$content = '<head>'; |
|
$content .= '<title>'.$title.'</title>'; |
|
$content .= '<link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon">'; |
|
$content .= '<link type="text/css" rel="stylesheet preload" as="style" href="//brick.freetls.fastly.net/Ubuntu:300,400,700/Roboto+Mono,400">'; |
|
$content .= '<link type="text/css" rel="stylesheet preload" as="style" href="'.($config_development == true ? url('stylesheets/theme-dark.css?'.time(), true) : $cdnurl.'/css/theme-dark.min.css').'">'; |
|
$content .= '<link type="text/css" rel="stylesheet preload" as="style" href="'.($config_development == true ? url('stylesheets/die-content.css?'.time(), true) : $cdnurl.'/css/die-content.min.css').'">'; |
|
$content .= '</head>'; |
|
$content .= '<body>'; |
|
$content .= $string; |
|
$content .= '</body>'; |
|
|
|
die($content); |
|
} |
|
|
|
function dayname($string) { |
|
global $lang; |
|
|
|
$name = [ |
|
'Mon' => $lang->various->days->mon, |
|
'Tue' => $lang->various->days->tue, |
|
'Wed' => $lang->various->days->wed, |
|
'Thu' => $lang->various->days->thu, |
|
'Fri' => $lang->various->days->fri, |
|
'Sat' => $lang->various->days->sat, |
|
'Sun' => $lang->various->days->sun |
|
]; |
|
|
|
return $name[$string]; |
|
} |
|
|
|
|
|
|
|
function getip() { |
|
if(isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { |
|
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; |
|
$_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; |
|
} |
|
|
|
$client = @$_SERVER['HTTP_CLIENT_IP']; |
|
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; |
|
$remote = $_SERVER['REMOTE_ADDR']; |
|
|
|
if(filter_var($client, FILTER_VALIDATE_IP)) { |
|
$ip = $client; |
|
} elseif(filter_var($forward, FILTER_VALIDATE_IP)) { |
|
$ip = $forward; |
|
} else { |
|
$ip = $remote; |
|
} |
|
|
|
return $ip; |
|
} |
|
|
|
|
|
|
|
function svgicon($string) { |
|
global $settings_theme; |
|
|
|
$size = 24; |
|
$array_icons = Array( |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M12.917 13A6.002 6.002 0 0 1 1 12a6 6 0 0 1 11.917-1H23v2h-2v4h-2v-4h-2v4h-2v-4h-2.083zM7 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8z"/></svg>' => 'key', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M7.105 15.21A3.001 3.001 0 1 1 5 15.17V8.83a3.001 3.001 0 1 1 2 0V12c.836-.628 1.874-1 3-1h4a3.001 3.001 0 0 0 2.895-2.21 3.001 3.001 0 1 1 2.032.064A5.001 5.001 0 0 1 14 13h-4a3.001 3.001 0 0 0-2.895 2.21z"/></svg>' => 'git', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M3.783 2.826L12 1l8.217 1.826a1 1 0 0 1 .783.976v9.987a6 6 0 0 1-2.672 4.992L12 23l-6.328-4.219A6 6 0 0 1 3 13.79V3.802a1 1 0 0 1 .783-.976zM12 11a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5zm-4.473 5h8.946a4.5 4.5 0 0 0-8.946 0z"/></svg>' => 'shield', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M17.084 15.812a7 7 0 1 0-10.168 0A5.996 5.996 0 0 1 12 13a5.996 5.996 0 0 1 5.084 2.812zM12 23.728l-6.364-6.364a9 9 0 1 1 12.728 0L12 23.728zM12 12a3 3 0 1 1 0-6 3 3 0 0 1 0 6z"/></svg>' => 'gps', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M9.954 2.21a9.99 9.99 0 0 1 4.091-.002A3.993 3.993 0 0 0 16 5.07a3.993 3.993 0 0 0 3.457.261A9.99 9.99 0 0 1 21.5 8.876 3.993 3.993 0 0 0 20 12c0 1.264.586 2.391 1.502 3.124a10.043 10.043 0 0 1-2.046 3.543 3.993 3.993 0 0 0-3.456.261 3.993 3.993 0 0 0-1.954 2.86 9.99 9.99 0 0 1-4.091.004A3.993 3.993 0 0 0 8 18.927a3.993 3.993 0 0 0-3.457-.26A9.99 9.99 0 0 1 2.5 15.121 3.993 3.993 0 0 0 4 11.999a3.993 3.993 0 0 0-1.502-3.124 10.043 10.043 0 0 1 2.046-3.543A3.993 3.993 0 0 0 8 5.071a3.993 3.993 0 0 0 1.954-2.86zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/></svg>' => 'settings', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M11 2c4.968 0 9 4.032 9 9s-4.032 9-9 9-9-4.032-9-9 4.032-9 9-9zm0 16c3.867 0 7-3.133 7-7 0-3.868-3.133-7-7-7-3.868 0-7 3.132-7 7 0 3.867 3.132 7 7 7zm8.485.071l2.829 2.828-1.415 1.415-2.828-2.829 1.414-1.414z"/></svg>' => 'search', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-1-7v2h2v-2h-2zm0-8v6h2V7h-2z"/></svg>' => 'error', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-1-11v6h2v-6h-2zm0-4v2h2V7h-2z"/></svg>' => 'info', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M12 2a1 1 0 0 1 1 1v3a1 1 0 0 1-2 0V3a1 1 0 0 1 1-1zm0 15a1 1 0 0 1 1 1v3a1 1 0 0 1-2 0v-3a1 1 0 0 1 1-1zm8.66-10a1 1 0 0 1-.366 1.366l-2.598 1.5a1 1 0 1 1-1-1.732l2.598-1.5A1 1 0 0 1 20.66 7zM7.67 14.5a1 1 0 0 1-.366 1.366l-2.598 1.5a1 1 0 1 1-1-1.732l2.598-1.5a1 1 0 0 1 1.366.366zM20.66 17a1 1 0 0 1-1.366.366l-2.598-1.5a1 1 0 0 1 1-1.732l2.598 1.5A1 1 0 0 1 20.66 17zM7.67 9.5a1 1 0 0 1-1.366.366l-2.598-1.5a1 1 0 1 1 1-1.732l2.598 1.5A1 1 0 0 1 7.67 9.5z"/></svg>' => 'loading', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M3 3h18a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm9.06 8.683L5.648 6.238 4.353 7.762l7.72 6.555 7.581-6.56-1.308-1.513-6.285 5.439z"/></svg>' => 'contact', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></svg>' => 'clear', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M7 11.5a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9zm0 10a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9zm10-10a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9zm0 10a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z"/></svg>' => 'using', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M4 3h14l2.707 2.707a1 1 0 0 1 .293.707V20a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zm3 1v5h9V4H7zm-1 8v7h12v-7H6zm7-7h2v3h-2V5z"/></svg>' => 'save', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M11 2v5H8l4 4 4-4h-3V2h7a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h7zm8 14H5v4h14v-4zm-2 1v2h-2v-2h2z"/></svg>' => 'install', |
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '.$size.' '.$size.'" width="'.$size.'" height="'.$size.'"><path fill="none" d="M0 0h'.$size.'v'.$size.'H0z"/><path d="M6.17 18a3.001 3.001 0 0 1 5.66 0H22v2H11.83a3.001 3.001 0 0 1-5.66 0H2v-2h4.17zm6-7a3.001 3.001 0 0 1 5.66 0H22v2h-4.17a3.001 3.001 0 0 1-5.66 0H2v-2h10.17zm-6-7a3.001 3.001 0 0 1 5.66 0H22v2H11.83a3.001 3.001 0 0 1-5.66 0H2V4h4.17z"/></svg>' => 'finetune' |
|
); |
|
|
|
return array_search($string, $array_icons, true); |
|
} |
|
|
|
|
|
|
|
# Open up configs/default-language.php to see the names of the weather codes. |
|
function weathericon($string) { |
|
$icon_prefix = 'pe-7w-'; |
|
$array = Array( |
|
'01d800' => 'sun', |
|
'01n800' => 'moon', |
|
|
|
'02d801' => 'cloud-sun', |
|
'02n801' => 'cloud-moon', |
|
|
|
'03d802' => 'cloud-sun', |
|
'03n802' => 'cloud-moon', |
|
|
|
'04d803' => 'cloud', |
|
'04d804' => 'cloud', |
|
'04n803' => 'cloud', |
|
'04n804' => 'cloud', |
|
|
|
'09d300' => 'drizzle-alt', |
|
'09d301' => 'drizzle', |
|
'09d302' => 'drizzle', |
|
'09d310' => 'drizzle-alt', |
|
'09d311' => 'drizzle', |
|
'09d312' => 'drizzle', |
|
'09d313' => 'drizzle', |
|
'09d314' => 'drizzle', |
|
'09d321' => 'drizzle', |
|
'09d520' => 'rain-alt', |
|
'09d521' => 'rain-alt', |
|
'09d522' => 'rain-alt', |
|
'09d531' => 'rain-alt', |
|
'09n300' => 'drizzle-alt', |
|
'09n301' => 'drizzle', |
|
'09n302' => 'drizzle', |
|
'09n310' => 'drizzle-alt', |
|
'09n311' => 'drizzle', |
|
'09n312' => 'drizzle', |
|
'09n313' => 'drizzle', |
|
'09n314' => 'drizzle', |
|
'09n321' => 'drizzle', |
|
'09n520' => 'rain-alt', |
|
'09n521' => 'rain-alt', |
|
'09n522' => 'rain-alt', |
|
'09n531' => 'rain-alt', |
|
|
|
'10d500' => 'rain', |
|
'10d501' => 'rain', |
|
'10d502' => 'rain', |
|
'10d503' => 'rain-alt', |
|
'10d504' => 'rain-alt', |
|
'10n500' => 'rain', |
|
'10n501' => 'rain', |
|
'10n502' => 'rain', |
|
'10n503' => 'rain-alt', |
|
'10n504' => 'rain-alt', |
|
|
|
'11d200' => 'lightning-rain', |
|
'11d201' => 'lightning-rain', |
|
'11d202' => 'lightning-rain', |
|
'11d210' => 'lightning', |
|
'11d211' => 'lightning', |
|
'11d212' => 'lightning', |
|
'11d221' => 'lightning', |
|
'11d230' => 'lightning-rain', |
|
'11d231' => 'lightning-rain', |
|
'11d232' => 'lightning-rain', |
|
'11n200' => 'lightning-rain', |
|
'11n201' => 'lightning-rain', |
|
'11n202' => 'lightning-rain', |
|
'11n210' => 'lightning', |
|
'11n211' => 'lightning', |
|
'11n212' => 'lightning', |
|
'11n221' => 'lightning', |
|
'11n230' => 'lightning-rain', |
|
'11n231' => 'lightning-rain', |
|
'11n232' => 'lightning-rain', |
|
|
|
'13d511' => 'rain', |
|
'13d600' => 'snow-alt', |
|
'13d601' => 'snow-alt', |
|
'13d602' => 'snow-alt', |
|
'13d611' => 'snow', |
|
'13d612' => 'snow', |
|
'13d613' => 'snow', |
|
'13d615' => 'snow', |
|
'13d616' => 'snow', |
|
'13d620' => 'snow', |
|
'13d621' => 'snow', |
|
'13d622' => 'snow', |
|
'13n511' => 'rain', |
|
'13n600' => 'snow-alt', |
|
'13n601' => 'snow-alt', |
|
'13n602' => 'snow-alt', |
|
'13n611' => 'snow', |
|
'13n612' => 'snow', |
|
'13n613' => 'snow', |
|
'13n615' => 'snow', |
|
'13n616' => 'snow', |
|
'13n620' => 'snow', |
|
'13n621' => 'snow', |
|
'13n622' => 'snow', |
|
|
|
'50d701' => 'fog', |
|
'50d711' => 'fog', |
|
'50d721' => 'fog', |
|
'50d731' => 'fog', |
|
'50d741' => 'fog', |
|
'50d751' => 'fog', |
|
'50d761' => 'fog', |
|
'50d762' => 'fog', |
|
'50d771' => 'fog', |
|
'50d781' => 'hurricane', |
|
'50n701' => 'fog', |
|
'50n711' => 'fog', |
|
'50n721' => 'fog', |
|
'50n731' => 'fog', |
|
'50n741' => 'fog', |
|
'50n751' => 'fog', |
|
'50n761' => 'fog', |
|
'50n762' => 'fog', |
|
'50n771' => 'fog', |
|
'50n781' => 'hurricane' |
|
); |
|
|
|
return $icon_prefix . (!isset($array[$string]) ? '-' : $array[$string]); |
|
} |
|
|
|
?>
|
|
|