spirit posteets tagged php  [ Profile ]

Sort by: Date / Title /

  1. 9 years ago
    Prevents jobs to collide if they take longer to run than the frequency itself
    1. $fp = fopen('/tmp/lock.txt', 'r+')
    2.  
    3. if(!flock($fp, LOCK_EX | LOCK_NB)) { 
    4.    echo 'Unable to obtain lock'
    5.    exit(-1)
    6. } 
    7.    
    8. /* ... */ 
    9.  
    10. fclose($fp);
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2040"></script>
  2. 9 years ago
    it's also possibl with a .htaccess file and "deny from all " in that file
    1. if (isset($_SERVER['REMOTE_ADDR'])) die('Permission denied.');
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2039"></script>
  3. 9 years ago
    1. msgfmt -o output_file.mo input_file.po
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1755"></script>
  4. sponsorised links
  5. 10 years ago
    Ça parait simple comme ça mais ça m'a pris du temps de trouver, donc pas la peine de le perdre :)
    1. rand(0,1)*2-1
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1559"></script>
  6. 10 years ago
    1. function distance($lat1, $lon1, $lat2, $lon2, $unit) {
    2.  
    3.   $theta = $lon1 - $lon2;
    4.   $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2))cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
    5.   $dist = acos($dist);
    6.   $dist = rad2deg($dist);
    7.   $miles = $dist * 60 * 1.1515;
    8.   $unit = strtoupper($unit);
    9.  
    10.   if ($unit == "K") {
    11.     return ($miles * 1.609344);
    12.   } else if ($unit == "N") {
    13.       return ($miles * 0.8684);
    14.     } else {
    15.         return $miles;
    16.       }
    17. }
    18.  
    19. echo distance(32.9697, -96.80322, 29.46786, -98.53506, "m") . " miles<br>";
    20. echo distance(32.9697, -96.80322, 29.46786, -98.53506, "k") . " kilometers<br>";
    21. echo distance(32.9697, -96.80322, 29.46786, -98.53506, "n") . " nautical miles<br>";
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1554"></script>
  7. 10 years ago
    1. /etc/apache2/apache2.conf
    2. > ServerTokens Prod
    3. > ServerSignature Off
    4.  
    5. /etc/php5/apache2/php.ini
    6. > expose_php = Off
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1405"></script>
  8. 10 years ago
    1. $start = microtime(TRUE);
    2. // Code PHP à bencher
    3. for ($i = 0; $i < 10000; $i++)
    4. {
    5.     isset($array['id']);
    6. }
    7.  
    8. echo number_format(microtime(TRUE) - $start, 6)." seconds: isset\n";
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1310"></script>
  9. 10 years ago
    1. if (PHP_SAPI === 'cli')
    2.     // In CLI mode
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1034"></script>
  10. 10 years ago
    Permet par exemple de laisser des internautes déposer des fichiers dans un répertoire. Si on ne veut pas qu'ils puissent déposer un fichier PHP et l'exécuter, on peut vouloir empêcher l'exécution de PHP dans ce répertoire.
    1. # ajouter la conf suivante dans votre VirtualHost
    2.  
    3. <Location /upload/>
    4.    AddType text/plain .php .php4 .php5 .phtml .py .pl .cgi .rb
    5. </Location>
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1014"></script>
  11. 11 years ago and saved by 1 other
    1. // Call a class method outside the class
    2. call_user_func(array($myclass, $mymethod), $args);
    3.  
    4. // Call a class method inside the class
    5. call_user_func(array($this, $mymethod), $args);
    6. //or
    7. $this->{$mymethod}($args);
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/849"></script>

First / Previous / Next / Last / Page 1 of 2 (17 posteets)