Source for file common.php

Documentation is available at common.php

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

Documentation generated on Mon, 05 May 2008 16:18:01 +0400 by phpDocumentor 1.4.0