C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\netspot\_installation\common.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* @version $Id: common.php,v 1.5 2005/01/23 03:24:16 kochp Exp $
* @package Mambo
* @copyright (C) 2000 - 2005 Miro International Pty Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Mambo is Free Software
*/

error_reportingE_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=) {
    
$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

?>