first init
This commit is contained in:
144
func.php
Normal file
144
func.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
function timeelapsed ($time){
|
||||
$time = time() - $time; // to get the time since that moment
|
||||
$tokens = array (
|
||||
31536000 => 'year',
|
||||
2592000 => 'month',
|
||||
604800 => 'week',
|
||||
86400 => 'day',
|
||||
3600 => 'hour',
|
||||
60 => 'minute',
|
||||
1 => 'second'
|
||||
);
|
||||
|
||||
foreach ($tokens as $unit => $text) {
|
||||
if ($time < $unit) continue;
|
||||
$numberOfUnits = floor($time / $unit);
|
||||
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cvFakultas($fakultas){
|
||||
switch($fakultas){
|
||||
case 'Teknik' :
|
||||
return "Telkom Engineering School";
|
||||
break;
|
||||
case 'Manajemen' :
|
||||
return "Telkom Bussiness School";
|
||||
break;
|
||||
case 'Desain' :
|
||||
return "Telkom Creative Industries School";
|
||||
break;
|
||||
case 'Ilmu terapan' :
|
||||
return "Telkom Applied Science School";
|
||||
break;
|
||||
default :
|
||||
return "Unknown";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function waktu($time){
|
||||
$time = explode(' ',$time);
|
||||
$jam = $time[1];
|
||||
$date = explode('-',$time[0]);
|
||||
$tahun = $date[0];
|
||||
$tanggal = $date[2];
|
||||
switch($date[1]){
|
||||
case '01':
|
||||
$bulan = 'January';
|
||||
break;
|
||||
case '02':
|
||||
$bulan = 'February';
|
||||
break;
|
||||
case '03':
|
||||
$bulan = 'March';
|
||||
break;
|
||||
case '04':
|
||||
$bulan = 'April';
|
||||
break;
|
||||
case '05':
|
||||
$bulan = 'Mei';
|
||||
break;
|
||||
case '06':
|
||||
$bulan = 'June';
|
||||
break;
|
||||
case '07':
|
||||
$bulan = 'July';
|
||||
break;
|
||||
case '08':
|
||||
$bulan = 'August';
|
||||
break;
|
||||
case '09':
|
||||
$bulan = 'September';
|
||||
break;
|
||||
case '10':
|
||||
$bulan = 'October';
|
||||
break;
|
||||
case '11':
|
||||
$bulan = 'November';
|
||||
break;
|
||||
case '12':
|
||||
$bulan = 'December';
|
||||
break;
|
||||
}
|
||||
return $tanggal.' '.$bulan.' '.$tahun.' '.$jam;
|
||||
|
||||
}
|
||||
|
||||
function time_passed($timestamp){
|
||||
$time = time();
|
||||
$diff = $time - (int)$timestamp;
|
||||
|
||||
if ($diff == 0)
|
||||
return 'just now';
|
||||
|
||||
$intervals = array
|
||||
(
|
||||
1 => array('year', 31556926),
|
||||
$diff < 31556926 => array('month', 2628000),
|
||||
$diff < 2629744 => array('week', 604800),
|
||||
$diff < 604800 => array('day', 86400),
|
||||
$diff < 86400 => array('hour', 3600),
|
||||
$diff < 3600 => array('minute', 60),
|
||||
$diff < 60 => array('second', 1)
|
||||
);
|
||||
|
||||
$value = floor($diff/$intervals[1][1]);
|
||||
return $value.' '.$intervals[1][0].($value > 1 ? 's' : '');
|
||||
}
|
||||
|
||||
function hasPassed($time){
|
||||
if (time() > strtotime($time))return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
function rrmdir($dir) {
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
|
||||
}
|
||||
}
|
||||
reset($objects);
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
function delete_files($target) {
|
||||
if(is_dir($target)){
|
||||
$files = glob( $target . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned
|
||||
|
||||
foreach( $files as $file )
|
||||
{
|
||||
delete_files( $file );
|
||||
}
|
||||
|
||||
rmdir( $target );
|
||||
} elseif(is_file($target)) {
|
||||
unlink( $target );
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user