git-svn-id: https://192.168.0.254/svn/Proyectos.MatritumCantat_Web/trunk@2 8e3496fd-7892-4c45-be36-0ff06e9dacc6
93 lines
2.6 KiB
PHP
93 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* @version $Id: common.php 4677 2006-08-23 16:55:24Z stingrey $
|
|
* @package Joomla
|
|
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
|
|
* Joomla! is free software. This version may have been modified pursuant
|
|
* to the GNU General Public License, and as distributed it includes or
|
|
* is derivative of works licensed under the GNU General Public License or
|
|
* other free or open source software licenses.
|
|
* See COPYRIGHT.php for copyright notices and details.
|
|
*/
|
|
|
|
// no direct access
|
|
defined( '_VALID_MOS' ) or die( 'Restricted access' );
|
|
|
|
error_reporting( E_ALL );
|
|
|
|
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
|
header ("Pragma: no-cache"); // HTTP/1.0
|
|
|
|
/**
|
|
* Utility function to return a value from a named array or a specified default
|
|
*/
|
|
define( "_MOS_NOTRIM", 0x0001 );
|
|
define( "_MOS_ALLOWHTML", 0x0002 );
|
|
function mosGetParam( &$arr, $name, $def=null, $mask=0 ) {
|
|
$return = null;
|
|
if (isset( $arr[$name] )) {
|
|
if (is_string( $arr[$name] )) {
|
|
if (!($mask&_MOS_NOTRIM)) {
|
|
$arr[$name] = trim( $arr[$name] );
|
|
}
|
|
if (!($mask&_MOS_ALLOWHTML)) {
|
|
$arr[$name] = strip_tags( $arr[$name] );
|
|
}
|
|
if (!get_magic_quotes_gpc()) {
|
|
$arr[$name] = addslashes( $arr[$name] );
|
|
}
|
|
}
|
|
return $arr[$name];
|
|
} else {
|
|
return $def;
|
|
}
|
|
}
|
|
|
|
function mosMakePassword($length) {
|
|
$salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
$len = strlen($salt);
|
|
$makepass="";
|
|
mt_srand(10000000*(double)microtime());
|
|
for ($i = 0; $i < $length; $i++)
|
|
$makepass .= $salt[mt_rand(0,$len - 1)];
|
|
return $makepass;
|
|
}
|
|
|
|
/**
|
|
* Chmods files and directories recursivel to given permissions
|
|
* @param path The starting file or directory (no trailing slash)
|
|
* @param filemode Integer value to chmod files. NULL = dont chmod files.
|
|
* @param dirmode Integer value to chmod directories. NULL = dont chmod directories.
|
|
* @return TRUE=all succeeded FALSE=one or more chmods failed
|
|
*/
|
|
function mosChmodRecursive($path, $filemode=NULL, $dirmode=NULL)
|
|
{
|
|
$ret = TRUE;
|
|
if (is_dir($path)) {
|
|
$dh = opendir($path);
|
|
while ($file = readdir($dh)) {
|
|
if ($file != '.' && $file != '..') {
|
|
$fullpath = $path.'/'.$file;
|
|
if (is_dir($fullpath)) {
|
|
if (!mosChmodRecursive($fullpath, $filemode, $dirmode))
|
|
$ret = FALSE;
|
|
} else {
|
|
if (isset($filemode))
|
|
if (!@chmod($fullpath, $filemode))
|
|
$ret = FALSE;
|
|
} // if
|
|
} // if
|
|
} // while
|
|
closedir($dh);
|
|
if (isset($dirmode))
|
|
if (!@chmod($path, $dirmode))
|
|
$ret = FALSE;
|
|
} else {
|
|
if (isset($filemode))
|
|
$ret = @chmod($path, $filemode);
|
|
} // if
|
|
return $ret;
|
|
} // mosChmodRecursive
|
|
|
|
?>
|