"; } }elseif($validatefor=="date"){ if(strlen($text)!=10){ $ret= $field. " invalid date !
"; }elseif(substr($text,4,1)!="-"){ $ret= $field. " invalid date !
"; }elseif(substr($text,7,1)!="-"){ $ret= $field. " invalid date !
"; } return $ret; }elseif($validatefor=="one"){ if(strlen($field)==0 && strlen($text)==0){ return "Enter either Tél. or GSM !
"; } }else{ if(strlen($field)==0 && strlen($text)==0 && strlen($validatefor)==0){ return "Type de projet can not be blank !
"; } } } // convert an input string into it's binary equivalent. function asc2bin($inputString, $byteLength=8) { $binaryOutput = ''; $strSize = strlen($inputString); for($x=0; $x<$strSize; $x++) { $charBin = decbin(ord($inputString{$x})); $charBin = str_pad($charBin, $byteLength, '0', STR_PAD_LEFT); $binaryOutput .= $charBin; } return $binaryOutput; } // convert a binary representation of a string back into it's original form. function bin2asc($binaryInput, $byteLength=8){ if (strlen($binaryInput) % $byteLength) { return false; } // why run strlen() so many times in a loop? Use of constants = speed increase. $strSize = strlen($binaryInput); $origStr = ''; // jump between bytes. for($x=0; $x<$strSize; $x += $byteLength) { // extract character's binary code $charBinary = substr($binaryInput, $x, $byteLength); $origStr .= chr(bindec($charBinary)); // conversion to ASCII. } return $origStr; } function remove_dir($current_dir) { if($dir = @opendir($current_dir)) { while (($f = readdir($dir)) !== false) { if($f > '0' and filetype($current_dir.$f) == "file") { unlink($current_dir.$f); } elseif($f > '0' and filetype($current_dir.$f) == "dir") { remove_dir($current_dir.$f."\\"); } } closedir($dir); rmdir($current_dir); } } function filterInput($var) { if(get_magic_quotes_gpc()) $cleanInput = stripslashes($var); $cleanInput = mysql_real_escape_string($var); return $cleanInput; } function formatDate($date, $separator = "-") { if (strlen($date) > 0 && $date != 0) { list($year, $month, $day) = explode("-", $date); if ($separator == "/") $sDate = "d/m/Y"; else $sDate = "d-m-Y"; $formattedDate = date($sDate, mktime(0, 0, 0, $month, $day, $year)); return $formattedDate; } else return 0; } function formatDateStd($date) { if (strlen($date) > 0 && $date != 0) { list($day, $month, $year) = explode("-", $date); $formattedDate = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year)); return $formattedDate; } else return 0; } function getFilePath($value) { switch ($value) { case 'doc_fr': case 'doc_fr_edit': $path = "/pdf/fr/"; break; case 'doc_en': case 'doc_en_edit': $path = "/pdf/en/"; break; case 'doc_es': case 'doc_es_edit': $path = "/pdf/es/"; break; case 'doc_de': case 'doc_de_edit': $path = "/pdf/de/"; break; default: $path = "/image/"; } return $path; } function getThumbnailData($image, $path, $mwidth, $mheight, $type=1) { if ($type == 1) $S_Photo = "thumb_" . substr($image, 0, -4) . ".jpg"; else if ($type == 2) $S_Photo = "lthumb_" . substr($image, 0, -4) . ".jpg"; else if ($type == 3) $S_Photo = $image; $imagePath = $path .$S_Photo; list($width, $height, $type, $attr) = getimagesize($imagePath); $maxWidth = $mwidth; $maxHeight = $mheight; $newWidth = $mwidth; $newHeight = $mheight; if($width < $maxWidth) $leftPadding = ($maxWidth - $width)/2; else $leftPadding = "0"; if($height < $maxHeight) $topPadding = ($maxHeight - $height)/2; else $topPadding = "0"; $size = "padding:".$topPadding."px ".$leftPadding."px;"; $size .= "width:".($newWidth - $leftPadding*2)."px; height:".($newHeight-$topPadding*2)."px;"; $thumbArr['name'] = $S_Photo; $thumbArr['size'] = $size; return $thumbArr; } ?>

Our other references