$value) { if (is_array($value)) $input[$key] = array_htmlspecialchars($value); else $input[$key] = mysql_real_escape_string(htmlspecialchars(($value))); // else $input[$key] = mysql_real_escape_string(htmlspecialchars(utf8_decode($value))); } return $input; } return htmlspecialchars($input); }; // htmlspecialchars_decode version. function array_htmlspecialchars_decode(&$input) { if (is_array($input)) { foreach ($input as $key => $value) { if (is_array($value)) $input[$key] = array_htmlspecialchars_decode($value); else $input[$key] = htmlspecialchars_decode($value); } return $input; } return htmlspecialchars_decode($input); }; function getTheDate($format) { if( $format == 'datetime' ) $date = date('Y-m-d H:i:s'); else $date = date('Y-m-d'); return $date; }; function humanTiming ($time) { $time = strtotime($time); $time = time() - $time; // to get the time since that moment $tokens = array ( 31536000 => 'année', 2592000 => 'mois', 604800 => 'semaine', 86400 => 'jour', 3600 => 'heure', 60 => 'minute', 1 => 'seconde' ); foreach ($tokens as $unit => $text) { if ($time < $unit) continue; $numberOfUnits = floor($time / $unit); return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'').''; } }; function CustomCutString ($str, $nb) { if( strlen($str)>$nb ) { $wrapped = wordwrap($str, $nb); $lines = explode("\n", $wrapped); $str = $lines[0] . '...'; } return $str; }; function convertDate($start_time,$end_time) { $now = mktime( date("H, i, s, m, d, Y") ); list($date, $time) = explode(' ', $start_time); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $start = mktime($hour, $minute, $second, $month, $day, $year); list($date, $time) = explode(' ', $end_time); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $end = mktime($hour, $minute, $second, $month, $day, $year); if( ($now>=$start) && ($now<=$end) ) { return 'Le chat est ouvert'; } else if($now>$end) { return 'Le chat est terminé'; } else { $jour = array(1 => "Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"); $mois = array(1 => "janvier","février","mars","avril","mai","juin","juillet","aout","septembre","octobre","novembre","décembre"); $return= $jour[date('N',strtotime($start_time))]; $return.= date(' d ', strtotime($start_time)); $return.= $mois[date('n',strtotime($start_time))]; $return.= date(' à H:i', strtotime($start_time)); // return date('l d F à H:i', strtotime($start_time)); return $return; /* // Configure le script en français setlocale (LC_TIME, 'fr_FR','fra'); //Définit le décalage horaire par défaut de toutes les fonctions date/heure date_default_timezone_set("Europe/Paris"); //Definit l'encodage interne mb_internal_encoding("UTF-8"); $strDate = mb_convert_encoding('%A %d %B %Y à %Hh%M','ISO-8859-9','UTF-8'); return iconv("ISO-8859-9","UTF-8",strftime($strDate ,strtotime($start_time))); */ } } function ChatOpen($start_time,$end_time) { $now = mktime( date("H, i, s, m, d, Y") ); list($date, $time) = explode(' ', $start_time); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $start = mktime($hour, $minute, $second, $month, $day, $year); list($date, $time) = explode(' ', $end_time); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $end = mktime($hour, $minute, $second, $month, $day, $year); if( ($now>=$start) && ($now<=$end) ) { return 'true'; } else if($now<$start) { return 'before'; } else { return 'after'; } // if( ($now>=$start) && ($now<=$end) ) { // return true; // } else { // return false; // } } function before_OR_after_Chat($start_time,$end_time) { $now = mktime( date("H, i, s, m, d, Y") ); list($date, $time) = explode(' ', $start_time); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $start = mktime($hour, $minute, $second, $month, $day, $year); list($date, $time) = explode(' ', $end_time); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $end = mktime($hour, $minute, $second, $month, $day, $year); if( ($now>=$start) && ($now<=$end) ) { return 'chat'; } else if($now<$start) { return 'before'; } else { return 'after'; } } function show_form_before($show_form_before,$start_time) { $now = mktime( date("H, i, s, m, d, Y") ); list($date, $time) = explode(' ', $start_time); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $start = mktime($hour, $minute, $second, $month, $day, $year); if( ($now<$start) && ($show_form_before==='true') ) { return true; } else { return false; } } function show_form_after($show_form_after,$end_time) { $now = mktime( date("H, i, s, m, d, Y") ); list($date, $time) = explode(' ', $end_time); list($year, $month, $day) = explode('-', $date); list($hour, $minute, $second) = explode(':', $time); $end = mktime($hour, $minute, $second, $month, $day, $year); if( ($now>$end) && ($show_form_after==='true') ) { return true; } else { return false; } } ?>