[ PHPXref.com ] [ Generated: Sun Jul 20 18:23:33 2008 ] [ Journalness 4.0.1 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/installation/ -> common.php (source)

   1  <?php
   2  
   3  error_reporting( E_ALL );
   4  
   5  header ("Cache-Control: no-cache, must-revalidate");    // HTTP/1.1

   6  header ("Pragma: no-cache");    // HTTP/1.0

   7  
   8  /**

   9  * Utility function to return a value from a named array or a specified default

  10  */
  11  define( "_NOTRIM", 0x0001 );
  12  define( "_ALLOWHTML", 0x0002 );
  13  function getParam( &$arr, $name, $def=null, $mask=0 ) {
  14      $return = null;
  15      if (isset( $arr[$name] )) {
  16          if (is_string( $arr[$name] )) {
  17              if (!($mask&_NOTRIM)) {
  18                  $arr[$name] = trim( $arr[$name] );
  19              }
  20              if (!($mask&_ALLOWHTML)) {
  21                  $arr[$name] = strip_tags( $arr[$name] );
  22              }
  23              if (!get_magic_quotes_gpc()) {
  24                  $arr[$name] = addslashes( $arr[$name] );
  25              }
  26          }
  27          return $arr[$name];
  28      } else {
  29          return $def;
  30      }
  31  }
  32  
  33  function mosMakePassword($length) {
  34      $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  35      $len = strlen($salt);
  36      $makepass="";
  37      mt_srand(10000000*(double)microtime());
  38      for ($i = 0; $i < $length; $i++)
  39      $makepass .= $salt[mt_rand(0,$len - 1)];
  40      return $makepass;
  41  }
  42  
  43  /**

  44  * Chmods files and directories recursivel to given permissions

  45  * @param path The starting file or directory (no trailing slash)

  46  * @param filemode Integer value to chmod files. NULL = dont chmod files.

  47  * @param dirmode Integer value to chmod directories. NULL = dont chmod directories.

  48  * @return TRUE=all succeeded FALSE=one or more chmods failed

  49  */
  50  function mosChmodRecursive($path, $filemode=NULL, $dirmode=NULL)
  51  {
  52      $ret = TRUE;
  53      if (is_dir($path)) {
  54          $dh = opendir($path);
  55          while ($file = readdir($dh)) {
  56              if ($file != '.' && $file != '..') {
  57                  $fullpath = $path.'/'.$file;
  58                  if (is_dir($fullpath)) {
  59                      if (!mosChmodRecursive($fullpath, $filemode, $dirmode))
  60                          $ret = FALSE;
  61                  } else {
  62                      if (isset($filemode))
  63                          if (!@chmod($fullpath, $filemode))
  64                              $ret = FALSE;
  65                  } // if

  66              } // if

  67          } // while

  68          closedir($dh);
  69          if (isset($dirmode))
  70              if (!@chmod($path, $dirmode))
  71                  $ret = FALSE;
  72      } else {
  73          if (isset($filemode))
  74              $ret = @chmod($path, $filemode);
  75      } // if

  76      return $ret;
  77  } // mosChmodRecursive

  78  
  79  
  80  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]