0) { usleep(1000); } $essais++; } while (!flock($log, LOCK_EX) and $essais <= $essaismax); if ($essais==$essaismax) { return false; } foreach ($adressesout as $ligne) { fwrite($log,$ligne."\n"); } fclose($log); return true; } function in_array_multi($needle, $haystack) { if(!is_array($haystack)) return $needle == $haystack; foreach($haystack as $value) if(in_array_multi($needle, $value)) return true; return false; } function unespace($chaine) { $chaine = preg_replace('@ +@', ' ', $chaine); return $chaine; } function headerjs($page) { print ""; } /************************************************** * * GetDirsList * Laurent Lacroix, 03/02/2001 20:00 * * Récupère dans un tableau, la liste des sous répertoires d'un * répertoire, jusqu'à une profondeur spécifiée dans MaxDeep et * dont les noms respectent l'expression régulière DirRegEx * * @param BasDir Nom complêt du répertoire à parcourir sans "/" final * @param MaxDeep Profondeur maximale de répertoire à scanner * @param Arr Le tableau dans lequel les noms des répertoires sont stockés * @param DirRegEx Expression régulière que les répertoires doivent vérifier * @return TRUE ou FALSE suivant le résultat d'exécution * * @see DelCarIf * **************************************************/ Function GetDirsList( $BasDir, $MaxDeep, &$Arr, $DirRegEx = "" ) { if( ! is_dir( $BasDir ) ) return ""; // // Premier passage (pour trier à la fin du traitement) $bFirstPass = FALSE; // // Création du tableau de résultats if( ! is_array( $Arr ) ) { $Arr = array(); $bFirstPass = TRUE; } // // Scanner répertoire source $BasDir .= "/"; if ( ! ( $d = dir( $BasDir ) ) ) return ""; while( $f = $d->read() ) { if ( $f == "" || $f == "." || $f == ".." ) continue; if ( ! is_dir( $BasDir . $f ) ) continue; if ( $DirRegEx != "" && ! ereg( $DirRegEx, $f ) ) continue; $Arr[] = $BasDir . $f . "/"; // // Appel récursif if ( $MaxDeep != 0 ) { GetDirsList( $BasDir . $f, $MaxDeep - 1, $Arr, $DirRegEx ); } } $d->Close(); if( $bFirstPass ) ASort( $Arr ); return TRUE; } function voirvignettes($dir) { $idximg = 0; foreach (glob($dir."/vignettes/*.jpg") as $filename) { print ""; $idximg++; } $idximg = 0; print "\r\n\r\n"; if ($idximg>0) { print "\r\n\r\n"; } } function headerpdf($lefichier,$lenom) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename=".$lenom.".pdf;"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($lefichier)); readfile($lefichier); } function formattechaine($machaine) { $machaine = strtr($machaine,"ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ", "aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn"); return ereg_replace("[^a-zA-Z0-9.]", "_", $machaine); } function trouveid($table,$nomid = "id") { $sql = "SELECT ".$nomid." FROM ".$table." ORDER BY ".$nomid; $result = mysql_query( $sql ) or die ($errquery); $idxpreced = 0; $nouvelid = 1; $idmanquant = false; for ($i=0;$i 1) { $nouvelid = 1; $idmanquant = true; break; } } if ($i!=0) { if ($ligne[0] > ($idxpreced + 1)) { $nouvelid = $idxpreced + 1; $idmanquant = true; break; } else { $idxpreced = $ligne[0]; } } } if (mysql_num_rows($result)==0) { $nouvelid = 1; } mysql_free_result($result); if (!$idmanquant) { $nouvelid = $idxpreced + 1; } return $nouvelid; } function affichetableau ($letableau) { print " 
"; print "
";
  print_r($letableau);
  print "
"; } function generemotdepasse($id) { $acceptedChars = 'zertyupqsdfghkmwxcvbnAZERTYUPQSDFGHJKLMWXCVBN23456789'; $max = strlen($acceptedChars)-1; $password = null; for($i=0; $i < 6; $i++) { $password .= $acceptedChars{mt_rand(0, $max)}; } if ((isset($id))&&($id!="")) { $nouveaupass = crypt($password,CRYPT_STD_DES); $sql = "UPDATE anrusers SET pass='$nouveaupass' WHERE id='$id' ;"; $result = mysql_query( $sql ) or die ( "Erreur d'accès à la base de donnée !" ); } return $password; } function sqlpropre($chaine) { if ((eregi("MIME-Version:|passwd|Content-Type:|Content-Transfer-Encoding:|bcc:|cc:|header|write|windows|web-inf|xss", $chaine))||strstr($chaine,'|')||strstr($chaine,'email.tst')) { exit(); } if ($chaine != null) { return str_replace("'","''",str_replace("\'" ,"'",$chaine)); } else { return " NULL "; } } function recupereparam($parametre, $convertisseur, $valeurdefaut) { $tempo = $valeurdefaut ; if (array_key_exists($parametre, $_POST)) { $tempo = sqlpropre($_POST[$parametre]) ; } if ($convertisseur == "chaine") { $tempo = "" . $tempo ; } if ($convertisseur == "nombre") { $tempo = 0 + $tempo ; } return $tempo ; } function cmp3($a,$b) { if ($a["nom"] == $b["nom"]) return 0; return ($a["nom"] < $b["nom"]) ? -1 : 1; } function cmp2($a,$b) { if ($a["prenom"] == $b["prenom"]) return cmp3($a,$b); return ($a["prenom"] < $b["prenom"]) ? -1 : 1; } function cmp1($a,$b) { if ($a["roleidposition"] == $b["roleidposition"]) return cmp2($a,$b); return ($a["roleidposition"] < $b["roleidposition"]) ? -1 : 1; } /* Unsharp masking is a traditional darkroom technique that has proven very suitable for digital imaging. The principle of unsharp masking is to create a blurred copy of the image and compare it to the underlying original. The difference in colour values between the two images is greatest for the pixels near sharp edges. When this difference is subtracted from the original image, the edges will be accentuated. The Amount parameter simply says how much of the effect you want. 100 is 'normal'. Radius is the radius of the blurring circle of the mask. 'Threshold' is the least difference in colour values that is allowed between the original and the mask. In practice this means that low-contrast areas of the picture are left unrendered whereas edges are treated normally. This is good for pictures of e.g. skin or blue skies. Any suggenstions for improvement of the algorithm, expecially regarding the speed and the roundoff errors in the Gaussian blur process, are welcome. */ function UnsharpMask($img, $amount, $radius, $threshold) { //////////////////////////////////////////////////////////////////////////////////////////////// //// //// p h p U n s h a r p M a s k //// //// Unsharp mask algorithm by Torstein Hønsi 2003. //// thoensi_at_netcom_dot_no. //// Please leave this notice. //// /////////////////////////////////////////////////////////////////////////////////////////////// // $img is an image that is already created within php using // imgcreatetruecolor. No url! $img must be a truecolor image. // Attempt to calibrate the parameters to Photoshop: if ($amount > 500) $amount = 500; $amount = $amount * 0.016; if ($radius > 50) $radius = 50; $radius = $radius * 2; if ($threshold > 255) $threshold = 255; $radius = abs(round($radius)); // Only integers make sense. if ($radius == 0) { return $img; imagedestroy($img); break; } $w = imagesx($img); $h = imagesy($img); $imgCanvas = imagecreatetruecolor($w, $h); $imgCanvas2 = imagecreatetruecolor($w, $h); $imgBlur = imagecreatetruecolor($w, $h); $imgBlur2 = imagecreatetruecolor($w, $h); imagecopy ($imgCanvas, $img, 0, 0, 0, 0, $w, $h); imagecopy ($imgCanvas2, $img, 0, 0, 0, 0, $w, $h); // Gaussian blur matrix: // // 1 2 1 // 2 4 2 // 1 2 1 // ////////////////////////////////////////////////// // Move copies of the image around one pixel at the time and merge them with weight // according to the matrix. The same matrix is simply repeated for higher radii. for ($i = 0; $i < $radius; $i++) { imagecopy ($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left imagecopymerge ($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left imagecopymerge ($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center imagecopy ($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h); // During the loop above the blurred copy darkens, possibly due to a roundoff // error. Therefore the sharp picture has to go through the same loop to // produce a similar image for comparison. This is not a good thing, as processing // time increases heavily. imagecopy ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20 ); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667); imagecopymerge ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50); imagecopy ($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h); } // Calculate the difference between the blurred pixels and the original // and set the pixels for ($x = 0; $x < $w; $x++) { // each row for ($y = 0; $y < $h; $y++) { // each pixel $rgbOrig = ImageColorAt($imgCanvas2, $x, $y); $rOrig = (($rgbOrig >> 16) & 0xFF); $gOrig = (($rgbOrig >> 8) & 0xFF); $bOrig = ($rgbOrig & 0xFF); $rgbBlur = ImageColorAt($imgCanvas, $x, $y); $rBlur = (($rgbBlur >> 16) & 0xFF); $gBlur = (($rgbBlur >> 8) & 0xFF); $bBlur = ($rgbBlur & 0xFF); // When the masked pixels differ less from the original // than the threshold specifies, they are set to their original value. $rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig; $gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig; $bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig; if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) { $pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew); ImageSetPixel($img, $x, $y, $pixCol); } } } imagedestroy($imgCanvas); imagedestroy($imgCanvas2); imagedestroy($imgBlur); imagedestroy($imgBlur2); return $img; } ?> ANR - The Meetings of Digital Technologies - April 17 and 18, 2013, Paris Cité des sciences
The Meetings of Digital Technologies
April 17 and 18, 2013, Paris Cité des sciences