Outils pour utilisateurs

Outils du site


informatique:php:tips

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
informatique:php:tips [15/03/2011 11:45] – [RegEx] Validation adresse email cyrilleinformatique:php:tips [25/02/2021 20:08] (Version actuelle) – [Php side] cyrille
Ligne 29: Ligne 29:
 =====Sécurité===== =====Sécurité=====
  
-[[http://www.zimuel.it/blog/2011/01/strong-cryptography-in-php/|Strong cryptography in PHP]]: Use standard algorithms, Key space, Kerchoof’s principle, Don’t use rand() or mt_rand(), Use a salt value in hash functions,  Size and strength of the passwords, Don’t use plaintext passwords as key for ciphers, Use Base64 to encode encrypted data.+[[http://www.zimuel.it/blog/2011/01/strong-cryptography-in-php/|Strong cryptography in PHP]]: Use standard algorithms, Key space, Kerchoof’s principle, Don’t use rand() or mt_rand(), Use a salt value in hash functions,  Size and strength of the passwords, Don’t use plaintext passwords as key for ciphers.
  
  
Ligne 44: Ligne 44:
 ==== RegEx ==== ==== RegEx ====
  
-Validation syntaxe adresse email :+=== syntaxe adresse email ===
  
 <code php> <code php>
Ligne 59: Ligne 59:
  
 Voir aussi [[http://www.developpez.com/actu/29195/Vos-applications-valident-elles-correctement-les-adresses-e-mail-Retour-sur-les-details-des-specifications/|Vos applications valident-elles correctement les adresses e-mail ?]], [[http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html|Mail::RFC822::Address: regexp-based address validation]] Voir aussi [[http://www.developpez.com/actu/29195/Vos-applications-valident-elles-correctement-les-adresses-e-mail-Retour-sur-les-details-des-specifications/|Vos applications valident-elles correctement les adresses e-mail ?]], [[http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html|Mail::RFC822::Address: regexp-based address validation]]
 +
 +=== Collation caractères unicode ===
 +
 +Pour prendre les caractères accentués ou autres de la langue française: é, è, ê, ù, ç, É, À, ... Utiliser la classe de caractères ''[:word:]'' et le modifier ''u'' (pour activer la collation unicode).
 +
 +<code>
 + // match les caractères français et espace et tiret:
 + /^[[:word:] \-]+$/u
 +</code>
 +
 +Pour comparer des mots avec caractères accentués (diacritics) sans tenir compte des accents:
 +<code php>$s1 = 'en été ça va là' ;
 +$s2 = 'en ÉTE Ça va Là' ;
 +$s1 = strtolower( iconv( 'UTF-8', 'ASCII//TRANSLIT//IGNORE',$s1) );
 +$s2 = strtolower( iconv( 'UTF-8', 'ASCII//TRANSLIT//IGNORE',$s2) );
 +echo 'compare = ', var_export( ($s1==$s2), true),"\n" ;</code>
 ====Cross Platform ==== ====Cross Platform ====
  
Ligne 93: Ligne 109:
 ==== Manipulation fichier Excel ==== ==== Manipulation fichier Excel ====
  
-[[http://g-ernaelsten.developpez.com/tutoriels/excel2007/|Introduction à PHPExcel]] par Ernaelsten Gérard (05/02/2009)+  * [[https://gist.github.com/r-sal/4313500|PHPExcel Notes and code snippets]] 
 +  * [[http://g-ernaelsten.developpez.com/tutoriels/excel2007/|Introduction à PHPExcel]] par Ernaelsten Gérard (05/02/2009)
  
 Le package Spreadsheet_Excel_Writer Le package Spreadsheet_Excel_Writer
Ligne 107: Ligne 124:
 [[http://blog.ulf-wendel.de/?p=298|PHP: Transparent load balancing and sharding with mysqlnd]]: You want some client-side MySQL load balancing with and without sharding for your PHP application? PHP 5.3 has something to offer for you. It is free. It requires no to very little changes to your applications. [[http://blog.ulf-wendel.de/?p=298|PHP: Transparent load balancing and sharding with mysqlnd]]: You want some client-side MySQL load balancing with and without sharding for your PHP application? PHP 5.3 has something to offer for you. It is free. It requires no to very little changes to your applications.
  
 +==== Network ====
 +
 +=== Wake On Lan (WOL) ===
 +
 +<code php>
 +      # Wake on LAN - (c) HotKey@spr.at, upgraded by Murzik
 +      # Modified by Allan Barizo http://www.hackernotcracker.com
 +      flush();
 +      function WakeOnLan($addr, $mac,$socket_number) {
 +        $addr_byte = explode(':', $mac);
 +        $hw_addr = '';
 +        for ($a=0; $a <6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a]));
 +        $msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);
 +        for ($a = 1; $a <= 16; $a++) $msg .= $hw_addr;
 +        // send it to the broadcast address using UDP
 +        // SQL_BROADCAST option isn't help!!
 +        $s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
 +        if ($s == false) {
 +          echo "Error creating socket!\n";
 +          echo "Error code is '".socket_last_error($s)."' - " . socket_strerror(socket_last_error($s));
 +          return FALSE;
 +          }
 +        else {
 +          // setting a broadcast option to socket:
 +          $opt_ret = socket_set_option($s, 1, 6, TRUE);
 +          if($opt_ret <0) {
 +            echo "setsockopt() failed, error: " . strerror($opt_ret) . "\n";
 +            return FALSE;
 +            }
 +          if(socket_sendto($s, $msg, strlen($msg), 0, $addr, $socket_number)) {
 +            echo "Magic Packet sent successfully!";
 +            socket_close($s);
 +            return TRUE;
 +            }
 +          else {
 +            echo "Magic packet failed!";
 +            return FALSE;
 +            }
 +        
 +          }
 +        }
 +      // Port number where the computer is listening. Usually, any number between 1-50000 will do. Normally people choose 7 or 9.
 +      $socket_number = "7";
 +      // MAC Address of the listening computer's network device
 +      $mac_addy = "00:12:4G:SF:12:13";
 +      // IP address of the listening computer. Input the domain name if you are using a hostname (like when under Dynamic DNS/IP)
 +      $ip_addy = gethostbyname("myhomeserver.dynamicdns.org");
 +      
 +      WakeOnLan($ip_addy, $mac_addy,$socket_number)
 +
 +</code>
 +
 +=== Import gros fichier ===
 +
 +Upload large file.
 +
 +== Php side ==
 +
 +  * memory_limit
 +  * upload_max_filesize
 +  * post_max_size
 +
 +To use with Laravel and JS libraries look at [[https://github.com/pionl/laravel-chunk-upload|laravel-chunk-upload]]
 +== Nginx side ==
 +
 +
 +== Client side (chunking) ==
 +
 +  * javascript
 +    * https://www.plupload.com
 +    * https://github.com/blueimp/jQuery-File-Upload/wiki/Chunked-file-uploads
 +
 +Cross-site chunked uploads: by default, browsers don't allow all headers used for cross-site file uploads, if they are not explicitly defined as allowed with the following server-side headers:
 +<code>
 +Access-Control-Allow-Headers Content-Type, Content-Range, Content-Disposition
 +</code>
  
informatique/php/tips.1300185930.txt.gz · Dernière modification : 19/05/2012 00:15 (modification externe)

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki