forked from osmbe/osm-welcome-tool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.php
62 lines (54 loc) · 1.63 KB
/
install.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
<?php
// This is a small install script to make it easier for the user to set things up
$verbose=5;
// logging like this makes it readable
// logtrace(3, "Pending updates: " . print_r($updates,true));
$home = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$dirs = array ('users', 'userpics', 'contributors','updatelog');
// Creating dirs (and test)
logtrace(3, "Creating dirs: " . print_r($dirs,true));
foreach ($dirs as $dir) {
if (!file_exists($dir)) {
// mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $context ]]] )
if(!mkdir ($dir, 0775)) {
logtrace(0, "Problem creating dir: " . $php_errormsg);
} else {
logtrace(3, "Directory created : " . $dir);
}
} else {
logtrace(3, "Directory already exists : " . $dir);
}
}
function logtrace($level,$msg) {
global $verbose;
$DateTime=@date('Y-m-d H:i:s', time());
if ( $level <= $verbose ) {
$mylvl=NULL;
switch($level) {
case 0:
$mylvl ="error";
break;
case 1:
$mylvl ="core ";
break;
case 2:
$mylvl ="info ";
break;
case 3:
$mylvl ="notic";
break;
case 4:
$mylvl ="verbs";
break;
case 5:
$mylvl ="dtail";
break;
default :
$mylvl ="exec ";
break;
}
//"posix_getpid()=" . posix_getpid() . ", posix_getppid()=" . posix_getppid();
$content = $DateTime. " [" . posix_getpid() ."]:[" . $level . "]" . $mylvl . " - " . $msg . "\n";
echo $content;
}
}