151 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			151 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| if (!function_exists('duree')) {
 | |
| 	function duree($time)
 | |
| 	{
 | |
| 		$tabTemps = array("jours" => 86400,
 | |
| 			"h" => 3600,
 | |
| 			"m" => 60,
 | |
| 			"s" => 1);
 | |
| 		$result = "";
 | |
| 
 | |
| 		foreach ($tabTemps as $uniteTemps => $nombreSecondesDansUnite) {
 | |
| 
 | |
| 			$$uniteTemps = floor($time / $nombreSecondesDansUnite);
 | |
| 
 | |
| 			$time = $time % $nombreSecondesDansUnite;
 | |
| 
 | |
| 			if ($$uniteTemps > 0 || !empty($result)) {
 | |
| 
 | |
| 				$result .= $$uniteTemps . " $uniteTemps ";
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		return $result;
 | |
| 
 | |
| 	}
 | |
| 
 | |
| }
 | |
| 
 | |
| if (!function_exists('dateDiff')) {
 | |
| 	function dateDiff($date1, $date2, $class = null)
 | |
| 	{
 | |
| 		$diff = abs($date1 - $date2); // abs pour avoir la valeur absolute, ainsi éviter d'avoir une différence négative
 | |
| 		$retour = array();
 | |
| 
 | |
| 		$tmp = $diff;
 | |
| 		$second = $tmp % 60;
 | |
| 
 | |
| 		$tmp = floor(($tmp - $second) / 60);
 | |
| 		$minute = $tmp % 60;
 | |
| 
 | |
| 		$tmp = floor(($tmp - $minute) / 60);
 | |
| 		$heure = $tmp % 24;
 | |
| 
 | |
| 		$tmp = floor(($tmp - $heure) / 24);
 | |
| 		$jour = $tmp;
 | |
| 
 | |
| 		return $class->lang->line('since') . ' ' . $jour . ' ' . $class->lang->line('days') . ' ' . $heure . ' ' . $class->lang->line('hours') . ' ' . $minute . ' ' . $class->lang->line('minutes') . ' ' . $second . ' ' . $class->lang->line('seconds');
 | |
| 	}
 | |
| }
 | |
| 
 | |
| 
 | |
| if (!function_exists('traitementTemps')) {
 | |
| 	function traitementTemps($time, $dateAjout, $class = null)
 | |
| 	{
 | |
| 		if ($time == null) {
 | |
| 			$now = time();
 | |
| 			$date2 = strtotime($dateAjout);
 | |
| 
 | |
| 			return dateDiff($now, $date2, $class);
 | |
| 		} else {
 | |
| 			return duree($time);
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| 
 | |
| if (!function_exists('getDelayOfTreatmentInSeconds')) {
 | |
| 	function getDelayOfTreatmentInSeconds($time, $dateAjout)
 | |
| 	{
 | |
| 		if ($time == null) {
 | |
| 			$now = time();
 | |
| 			$date2 = strtotime($dateAjout);
 | |
| 			return abs($now - $date2);
 | |
| 		} else {
 | |
| 			return $time;
 | |
| 		}
 | |
| 
 | |
| 	}
 | |
| }
 | |
| 
 | |
| if (!function_exists('line_with_arguments'))
 | |
| {
 | |
| 	function line_with_arguments($line, $args = array())
 | |
| 	{
 | |
| 		return vsprintf($line, $args);
 | |
| //		return str_replace('%s', $swap, $line);
 | |
| 	}
 | |
| }
 | |
| 
 | |
| if (!function_exists('convertDate')) {
 | |
| 	function convertDate($date)
 | |
| 	{
 | |
| 		$month = null;
 | |
| 		switch ($date) {
 | |
| 			case "Jan":
 | |
| 				$month = 1;
 | |
| 				break;
 | |
| 			case "Feb":
 | |
| 				$month = 2;
 | |
| 				break;
 | |
| 			case "Mar":
 | |
| 				$month = 3;
 | |
| 				break;
 | |
| 			case "Apr":
 | |
| 				$month = 4;
 | |
| 				break;
 | |
| 			case "May":
 | |
| 				$month = 5;
 | |
| 				break;
 | |
| 			case "Jun":
 | |
| 				$month = 6;
 | |
| 				break;
 | |
| 			case "Jul":
 | |
| 				$month = 7;
 | |
| 				break;
 | |
| 			case "Aug":
 | |
| 				$month = 8;
 | |
| 				break;
 | |
| 			case "Sep":
 | |
| 				$month = 9;
 | |
| 				break;
 | |
| 			case "Oct":
 | |
| 				$month = 10;
 | |
| 				break;
 | |
| 			case "Nov":
 | |
| 				$month = 11;
 | |
| 				break;
 | |
| 			case "Dec":
 | |
| 				$month = 12;
 | |
| 				break;
 | |
| 		}
 | |
| 		return $month;
 | |
| 	}
 | |
| }
 | |
| 
 | |
| if (!function_exists('hashSSHA')) {
 | |
| 	function hashSSHA($password) {
 | |
| 		$salt = sha1(rand());
 | |
| 		$salt = substr($salt, 0, 10);
 | |
| 		$encrypted = base64_encode(sha1($password . $salt, true) . $salt);
 | |
| 		return array("salt" => $salt, "encrypted" => $encrypted);
 | |
| 	}
 | |
| }
 | |
| 
 | |
| if (!function_exists('checkhashSSHA')) {
 | |
| 	function checkhashSSHA($salt, $password) {
 | |
| 		return base64_encode(sha1($password . $salt, true) . $salt);
 | |
| 	}
 | |
| }
 |