if (isset($_GET['logout'])) {
logout();
}
// Logout Function -->
function logout()
{
session_destroy();
header('Location: ../');
exit();
}
// Template admin header
function template_admin_header($title, $selected = 'dashboard', $selected_child = '')
{
// Admin HTML links
$admin_links = '
Dashboard
Files
Settings
';
// Indenting the below code may cause an error
echo <<
$title
EOT;
}
// Template admin footer
function template_admin_footer()
{
// Indenting the below code may cause an error
echo <<
EOT;
}
// Convert date to elapsed string function
function time_elapsed_string($datetime, $full = false)
{
$now = new DateTime();
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = ['y' => 'year', 'm' => 'month', 'w' => 'week', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', 's' => 'second'];
foreach ($string as $k => &$v) {
if ($diff->$k) {
$v = $diff->$k.' '.$v.($diff->$k > 1 ? 's' : '');
} else {
unset($string[$k]);
}
}
if (!$full) {
$string = array_slice($string, 0, 1);
}
return $string ? implode(', ', $string).' ago' : 'just now';
}
function str_to_version_info($string)
{
$latest_version = false;
if (preg_match('/^\s*?(\d+\.\d+\.\d+)/i', $string, $match)) {
$latest_version = $match[1];
}
return $latest_version;
}