"Fossies" - the Fresh Open Source Software Archive

Member "proma-0.8.3/libs/common.lib.php" (25 Oct 2007, 1689 Bytes) of package /linux/privat/old/proma-0.8.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 
    3 /* ProMA (ProFTPd MySQL Admin), Copyright (C) 2002-2007 Stein Magnus Jodal
    4  * ProMA comes with ABSOLUTELY NO WARRANTY.
    5  * This is free software, and you are welcome to redistribute it
    6  * under the terms of the GNU General Public License.
    7  * Read 'COPYING' for further information.
    8  */
    9 
   10 /* ProMA Common Library
   11  * $Id: common.lib.php,v 1.4 2007/10/25 19:13:35 jodal Exp $
   12  */
   13 
   14 function rot13($ascii) {
   15 // Scrambles the password hash for new/closed accounts.
   16 //
   17 // str_rot13(), which is included in PHP >= 4.2.0, does about what we need. But
   18 // I'm using PHP 4.1.2 from Debian woody, so I wrote my own implementation. As
   19 // a mather of fact, I wrote it for another project before PHP 4.2.0 was
   20 // released.
   21 
   22     for ($i = 0; $i < strlen($ascii); $i++) {
   23         $ascii_array[] = substr($ascii, $i, 1);
   24     }
   25 
   26     for ($i = 0; $i < sizeof($ascii_array); $i++) {
   27         $x = ord($ascii_array[$i]);
   28 
   29         // Uppercase
   30         if ($x >= 65 && $x <= 90) {
   31             $y = $x + 13;
   32             $z = $y - 90;
   33             if ($z > 0)
   34                 $y = 64 + $z;
   35             $rot13 .= chr($y);
   36 
   37         // Lowercase
   38         } elseif ($x >= 97 && $x <= 122) {
   39             $y = $x + 13;
   40             $z = $y - 122;
   41             if ($z > 0)
   42                 $y = 96 + $z;
   43             $rot13 .= chr($y);
   44 
   45         // Other
   46         } else {
   47             $rot13 .= chr($x);
   48         }
   49     }
   50 
   51     return $rot13;
   52 }
   53 
   54 function admin_mail() {
   55 // Returns list of admin mail adresses for which we send notices when new users
   56 // register.
   57 
   58     global $table_users, $users_mail, $users_admin;
   59 
   60     $query = "SELECT
   61             $users_mail
   62         FROM
   63             $table_users
   64         WHERE
   65             $users_admin = 1";
   66     $result = mysql_query($query) or die("Failed to query database.");
   67 
   68     while ($row = mysql_fetch_array($result)) {
   69         $mail_array[] = $row[0];
   70     }
   71 
   72     $mail = implode(", ", $mail_array);
   73 
   74     return $mail;
   75 }
   76 
   77 ?>