mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-24 02:36:16 +00:00
Working on temp ban system
This commit is contained in:
parent
76826e5e41
commit
6f39ca7759
6 changed files with 299 additions and 83 deletions
32
app/app.php
32
app/app.php
|
@ -137,5 +137,35 @@ class Image {
|
|||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Diff {
|
||||
function time($past_time, $full_date = false) {
|
||||
$now = new \DateTime;
|
||||
$ago = new \DateTime($past_time);
|
||||
$diff = $now->diff($ago);
|
||||
|
||||
$diff->w = floor($diff->d / 7);
|
||||
$diff->d -= $diff->w * 7;
|
||||
|
||||
$string = array(
|
||||
'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_date) $string = array_slice($string, 0, 1);
|
||||
return $string ? implode(', ', $string) . ' ago' : 'just now';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue