Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for phpPlatonLib/Platon/Platon.php between version 1.9 and 1.10

version 1.9, 2003/01/13 12:56:26 version 1.10, 2003/01/13 13:24:11
Line 283  class Platon
Line 283  class Platon
         return true;          return true;
     } /* }}} */      } /* }}} */
   
     /** common/rand/fnc.rand_pass.php - returns pronounceable random key      /**
      * Note:    You may edit the $num_letters and $array variables       * Returns pronounceable random password
      * Author:  Sebastien Cevey <seb@cine7.net>       *
      * Project: Web OpenScripts <http://wos.sourceforge.net>       * @param   array   $array          array of sylables or null for default
        * @param   int     $num_letters    minimum number of letters
        * @param   int     $max_letters    maximum number of letters
        * @param   int     $uppercased     if to randomize letter case
        * @author  Sebastien Cevey <seb@cine7.net>
      */       */
     function rand_pass() /* {{{ */      function rand_pass /* {{{ */
           ($array = null, $num_letters = 6, $max_letters = 10, $uppercased = 0)
     {      {
         // Pronounceable pieces of words          // Pronounceable pieces of words
         $array = array(          $array = array(
Line 300  class Platon
Line 305  class Platon
                 'tav', 'peh', 'gil', 'lot', 'kal', 'zan', 'noc',                  'tav', 'peh', 'gil', 'lot', 'kal', 'zan', 'noc',
                 'bat', 'tev', 'lun', 'pal', 'hom', 'cun', 'wos', 'vox');                  'bat', 'tev', 'lun', 'pal', 'hom', 'cun', 'wos', 'vox');
   
         // Minimum number of letters  
         $num_letters = 6;  
         // Maximum number of letters  
         $max_letters = 10;  
         // Fraction of uppercased letters (randomized too...)  
         $uppercased = 0;  
         // Randomize on microseconds          // Randomize on microseconds
         mt_srand ((double)microtime() * 1000000);          mt_srand ((double)microtime() * 1000000);
         // Create random pass (too long for the moment)          // Create random pass (too long for the moment)
         for($i = 0; $i < $num_letters; $i++)          for($i = 0; $i < $num_letters; $i++) {
             $pass .= $array[mt_rand(0, (count($array) - 1))];              $pass .= $array[mt_rand(0, (count($array) - 1))];
           }
         //print "$pass ";  
         // Make sure there is not twice the same letter one after the other          // Make sure there is not twice the same letter one after the other
         for($i = 1; $i < strlen($pass); $i++) {          for($i = 1; $i < strlen($pass); $i++) {
             if(substr($pass, $i, 1) == substr($pass, $i - 1, 1))              if(substr($pass, $i, 1) == substr($pass, $i - 1, 1))
                 $pass = substr($pass, 0, $i) . substr($pass, $i + 1);                  $pass = substr($pass, 0, $i) . substr($pass, $i + 1);
         }          }
         // Randomize the pass case [for each letter]          // Randomize the pass case [for each letter]
         if ($uppercased)          if ($uppercased) {
             for($i = 0; $i < strlen($pass); $i++) {              for($i = 0; $i < strlen($pass); $i++) {
                 if(mt_rand(0, $uppercased) == 0)                  if(mt_rand(0, $uppercased) == 0)
                     $pass = substr($pass,0,$i)                      $pass = substr($pass,0,$i)
                         . strtoupper(substr($pass, $i,1))                          . strtoupper(substr($pass, $i,1))
                         . substr($pass, $i + 1);                          . substr($pass, $i + 1);
             }              }
           }
         // Shorten it now          // Shorten it now
         $pass = substr($pass, 0, $num_letters          $pass = substr($pass, 0, $num_letters
                 + mt_rand(0,$max_letters - $num_letters));                  + mt_rand(0,$max_letters - $num_letters));
Line 333  class Platon
Line 332  class Platon
         return $pass;          return $pass;
     } /* }}} */      } /* }}} */
   
     /** common/rand/fnc.rand_str.php - returns random string of length      /**
      * $len consisting of A-Z and 0-9; first character will always be       * Returns random string of length $len consisting of A-Z and 0-9; first
      * an alphabet; requires srand()       * character will always be an alphabet; requires srand().
        *
        * @param   int     $len    length of string
        * @return  string          generated random string
      */       */
     function rand_str($len = 8) /* {{{ */      function rand_str($len = 8) /* {{{ */
     {      {
Line 355  class Platon
Line 357  class Platon
         return $s;          return $s;
     } /* }}} */      } /* }}} */
   
     /** common/str/fnc.append_slash.php - appends slash at the end of      /**
      * string if it is not empty and slash is not already present at       * Appends slash at the end of string if it is not empty and slash is not
      * the end of string; returns changed string on success, on       * already present at the end of string.
      * failure returns false       *
        * @param   string  $string     string to search
        * @param   char    $char       character to append, slash by default
        * @return                      changed string on success, false on failure
      */       */
     function append_slash($string, $char = '/') /* {{{ */      function append_slash($string, $char = '/') /* {{{ */
     {      {
Line 372  class Platon
Line 377  class Platon
         return $string;          return $string;
     } /* }}} */      } /* }}} */
   
     /** common/str/fnc.set_value_by_substr.php - returns appropriate      /**
      * value from array according to key compared with passed string       * Returns appropriate value from array according to key compared with
      * or empty string when no key contains passed string       * passed string or false when no key contains passed string.
        *
        * @param   string  $string     string to search
        * @param   array   $substr_ar  substring arrays
        * @return  mixed               value from $substr_ar or false
      */       */
     function set_value_by_substr($string, $substr_ar) /* {{{ */      function set_value_by_substr($string, $substr_ar) /* {{{ */
     {      {
Line 385  class Platon
Line 394  class Platon
             if ($key == '' || stristr($string, $key) != false)              if ($key == '' || stristr($string, $key) != false)
                 return $value;                  return $value;
         }          }
         return '';          return false;
     } /* }}} */      } /* }}} */
   
     /** common/str/fnc.str_replace_postfix - replaces postfix of string      /**
        * Replaces postfix of string.
        *
        * @param   string  $search     what to replace
        * @param   string  $replace    replacement string
        * @param   string  $subject    where perform replacement
        * @return  string              string with replaced postfix
      */       */
     function str_replace_postfix($search, $replace, $subject) /* {{{ */      function str_replace_postfix($search, $replace, $subject) /* {{{ */
     {      {
Line 402  class Platon
Line 417  class Platon
         return $subject;          return $subject;
     } /* }}} */      } /* }}} */
   
     /** common/str/fnc.str_replace_prefix - replaces prefix of string      /**
        * Replaces prefix of string.
        *
        * @param   string  $search     what to replace
        * @param   string  $replace    replacement string
        * @param   string  $subject    where perform replacement
        * @return  string              string with replaced prefix
      */       */
     function str_replace_prefix($search, $replace, $subject) /* {{{ */      function str_replace_prefix($search, $replace, $subject) /* {{{ */
     {      {
Line 412  class Platon
Line 433  class Platon
         return $subject;          return $subject;
     } /* }}} */      } /* }}} */
   
     /** common/str/fnc.pretty_substr.php - pretty formated substring      /**
      * Author: Frank Schmitt <frank.schmitt@vista.com> [May-2002]       * Returns pretty formated substring.
        *
        * @param   string  $string     string to format
        * @param   int     $length     maximum length
        * @param   int     $slop       slop
        * @param   int     $use_hellip if use '&hellip;'
        * @return                      pretty formatted substring
        * @author  Frank Schmitt <frank.schmitt@vista.com>
        * @date    May/2002
      */       */
 #      function pretty_substr($string, $length, $slop = 4, $use_hellip = false) /* {{{ */
 # Oracle PL/SQL -- the same author      {
           if (strlen($string) > $length) {
               $string    = substr($string, 0, $length - 1);
               $lastSpace = strrpos($string, ' ');
               if ($lastSpace > $length - $slop) {
                   $string = substr($string, 0, $lastSpace);
               }
               $string .= $use_hellip ? '&hellip;' : '...';
           }
           return $string;
       } /* }}} */
   
   # pretty_substr - Oracle PL/SQL -- the same author {{{
 # warning: code below contains at least one bug  # warning: code below contains at least one bug
 #  
   
 # set define off; -- makes it so SQL*Plus doesn't choke on the '&'  # set define off; -- makes it so SQL*Plus doesn't choke on the '&'
 #  #
Line 449  class Platon
Line 489  class Platon
 #  #
 #    return result;  #    return result;
 # end pretty_substr;  # end pretty_substr;
 # /  # }}}
     function pretty_substr($string, $length, $slop = 4) /* {{{ */  
     {      /**
         if (strlen($string) > $length) {       * Returns english grammar related number.
             $string    = substr($string, 0, $length - 1);       *
             $lastSpace = strrpos($string, ' ');       * @param   int     $number intput number
             if ($lastSpace > $length - $slop) {       * @return  string          output number
                 $string = substr($string, 0, $lastSpace);  
             }  
             $string .= '&hellip;';  
         }  
         return $string;  
     } /* }}} */  
   
     /** common/str/fnc.get_english_num.php - returns english number  
      */       */
     function get_english_num($number) /* {{{ */      function get_english_num($number) /* {{{ */
     {      {
Line 477  class Platon
Line 509  class Platon
         return $number;          return $number;
     } /* }}} */      } /* }}} */
   
     /** common/str/fnc.htmlspecialchars2.php - common HTML special      /**
      * characters substitution with replacing space for '&nbsp;'       * HTML special characters substitution with replacing space for '&nbsp;'.
        *
        * @param   string  $str    string to escape
        * @return  string          HTML escaped string with spaces substitued
      */       */
     function htmlspecialchars2($str) /* {{{ */      function htmlspecialchars2($str) /* {{{ */
     {      {
Line 494  class Platon
Line 529  class Platon
      *                          hypertext_link - creates hypertext link       *                          hypertext_link - creates hypertext link
      * @param   string  $attr   when creating hypertext link, additional       * @param   string  $attr   when creating hypertext link, additional
      *                          attributes may be added       *                          attributes may be added
      * @return  string  escaped e-mail added       * @return  string          escaped e-mail added
      */       */
     function escape_email($email, $mode = 'hypertext_link', $attr = '')/* {{{ */      function escape_email($email, $mode = 'hypertext_link', $attr = '')/* {{{ */
     {      {

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top