gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

PhraseBuilder.php (685B)


      1 <?php
      2 
      3 namespace Gregwar\Captcha;
      4 
      5 /**
      6  * Generates random phrase
      7  *
      8  * @author Gregwar <g.passault@gmail.com>
      9  */
     10 class PhraseBuilder implements PhraseBuilderInterface
     11 {
     12     /**
     13      * Generates  random phrase of given length with given charset
     14      */
     15     public function build($length = 5, $charset = 'abcdefghijklmnpqrstuvwxyz123456789')
     16     {
     17         $phrase = '';
     18         $chars = str_split($charset);
     19 
     20         for ($i = 0; $i < $length; $i++) {
     21             $phrase .= $chars[array_rand($chars)];
     22         }
     23 
     24         return $phrase;
     25     }
     26 
     27     /**
     28      * "Niceize" a code
     29      */
     30     public function niceize($str)
     31     {
     32         return strtr(strtolower($str), '01', 'ol');
     33     }
     34 }