[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/installation/ -> common.php (source)

   1  <?php
   2  /**
   3  * Install instructions
   4  * @package Mambo
   5  * @author Mambo Foundation Inc see README.php
   6  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   7  * See COPYRIGHT.php for copyright notices and details.
   8  * @license GNU/GPL Version 2, see LICENSE.php
   9  *
  10  * Redistributions of files must retain the above copyright notice.
  11  *
  12  * Mambo is free software; you can redistribute it and/or
  13  * modify it under the terms of the GNU General Public License
  14  * as published by the Free Software Foundation; version 2 of the License.
  15  */
  16  
  17  error_reporting( E_ALL );
  18  
  19  header ("Cache-Control: no-cache, must-revalidate");    // HTTP/1.1
  20  header ("Pragma: no-cache");    // HTTP/1.0
  21  
  22  
  23  require_once ('../includes/phpgettext/phpgettext.class.php');
  24  
  25  /**
  26  * Utility function to return a value from a named array or a specified default
  27  */
  28  define( "_MOS_NOTRIM", 0x0001 );
  29  define( "_MOS_ALLOWHTML", 0x0002 );
  30  function mosGetParam( &$arr, $name, $def=null, $mask=0 ) {
  31      $return = null;
  32      if (isset( $arr[$name] )) {
  33          if (is_string( $arr[$name] )) {
  34              if (!($mask&_MOS_NOTRIM)) {
  35                  $arr[$name] = trim( $arr[$name] );
  36              }
  37              if (!($mask&_MOS_ALLOWHTML)) {
  38                  $arr[$name] = strip_tags( $arr[$name] );
  39              }
  40              if (!get_magic_quotes_gpc()) {
  41                  $arr[$name] = addslashes( $arr[$name] );
  42              }
  43          }
  44          return $arr[$name];
  45      } else {
  46          return $def;
  47      }
  48  }
  49  
  50  function mosMakePassword($length) {
  51      $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  52      $len = strlen($salt);
  53      $makepass="";
  54      mt_srand(10000000*(double)microtime());
  55      for ($i = 0; $i < $length; $i++)
  56      $makepass .= $salt[mt_rand(0,$len - 1)];
  57      return $makepass;
  58  }
  59  
  60  /**
  61  * Chmods files and directories recursivel to given permissions
  62  * @param path The starting file or directory (no trailing slash)
  63  * @param filemode Integer value to chmod files. NULL = dont chmod files.
  64  * @param dirmode Integer value to chmod directories. NULL = dont chmod directories.
  65  * @return TRUE=all succeeded FALSE=one or more chmods failed
  66  */
  67  function mosChmodRecursive($path, $filemode=NULL, $dirmode=NULL)
  68  {
  69      $ret = TRUE;
  70      if (is_dir($path)) {
  71          $dh = opendir($path);
  72          while ($file = readdir($dh)) {
  73              if ($file != '.' && $file != '..') {
  74                  $fullpath = $path.'/'.$file;
  75                  if (is_dir($fullpath)) {
  76                      if (!mosChmodRecursive($fullpath, $filemode, $dirmode))
  77                          $ret = FALSE;
  78                  } else {
  79                      if (isset($filemode))
  80                          if (!@chmod($fullpath, $filemode))
  81                              $ret = FALSE;
  82                  } // if
  83              } // if
  84          } // while
  85          closedir($dh);
  86          if (isset($dirmode))
  87              if (!@chmod($path, $dirmode))
  88                  $ret = FALSE;
  89      } else {
  90          if (isset($filemode))
  91              $ret = @chmod($path, $filemode);
  92      } // if
  93      return $ret;
  94  } // mosChmodRecursive
  95  
  96  ?>