File: ghcc.php

package info (click to toggle)
gallery 1.5.4-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 26,712 kB
  • ctags: 6,567
  • sloc: php: 33,824; sh: 446; xml: 96; makefile: 88; perl: 61
file content (117 lines) | stat: -rw-r--r-- 4,489 bytes parent folder | download
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/*
 * Gallery - a web based photo album viewer and editor
 * Copyright (C) 2000-2006 Bharat Mediratta
 *
 * This file by Andrew Lindeman
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * $Id: ghcc.php 13338 2006-03-27 15:32:14Z jenst $
 */
?>
<?php
require(dirname(__FILE__) . "/init.php");
require(GALLERY_SETUPDIR . "/functions.inc");
configLogin(basename(__FILE__));

/*
desc - A description of the test
test - Boolean value of the result, true = good, false = bad
failmsg - Message to display on fail
sev - Severity of a fail, 0 = warning, 1 = fatal
*/

$tests = array (0 => array ("desc" => "safe mode",
			    "test" => (ini_get ('safe_mode') == ''),
			    "failmsg" => "<b>safe_mode</b> must be disabled in php.ini",
			    "sev" => 1),
		1 => array ("desc" => "exec() enabled",
			    "test" => (! (in_array ('exec', split (',\s*', ini_get ('disable_functions'))))),
			    "failmsg" => "The <b>exec()</b> function must not be disabled by the <b>disabled_functions</b> parameter in php.ini",
			    "sev" => 1),
		2 => array ("desc" => "file_uploads enabled",
			    "test" => (ini_get ('file_uploads') != ''),
			    "failmsg" => "<b>file_uploads</b> must be enabled in php.ini",
			    "sev" => 1),
		3 => array ("desc" => "session.save_path writable",
			    "test" => ( is_dir (session_save_path()) && is_writable (session_save_path()) ),
			    "failmsg" => "<b>session.save_path</b> must be set to a valid directory and be writable by the web server user",
			    "sev" => 1),
		4 => array ("desc" => "session.use_cookies enabled",
			    "test" => (ini_get ('session.use_cookies') != ''),
			    "failmsg" => "<b>session.use_cookies must be enabled in php.ini",
			    "sev" => 1),
		5 => array ("desc" => "allow_url_fopen on",
			    "test" => (ini_get ('allow_url_fopen') != ''),
			    "failmsg" => "Gallery will not be able to fetch pictures from remote hosts",
			    "sev" => 0),
		);

if (ini_get ('upload_tmp_dir')) { // it defaults to a default system location, only test if this is set
	$tests[] = array ("desc" => "upload_tmp_dir writable",
			  "test" => ( is_dir (ini_get ('upload_tmp_dir')) && is_writable (ini_get ('upload_tmp_dir')) ),
			  "failmsg" => "<b>upload_tmp_dir</b> must be set to a valid directory and be writable by the web server user",
			  "sev" => 1);
}

?>
<h1 align="center">Gallery Host Compatability Checker</h1>
This scripts tests many of the basic requirements for Gallery to
run on your system.  It is not a catch all, but does check most
settings that Gallery requires.  <i>It does not check for
ImageMagick and NetPBM (or other programs Gallery can use)</i>
<br><br>
If any of these tests fail with a <b>fatal warning</b>, Gallery
will not run on your host
<hr width="50%">
<table cellpadding="5">
<?php
$warnings = false;
$fatals = false;
foreach ($tests as $arr) {
	print '<tr><th>';
	print $arr['desc'];
	print '</th>';

	print '<td>';
	print str_repeat ('&nbsp;', 10);
	print '<td>';

	if ($arr['test']) {
		print '<font color="#00aa00">Pass</font>';
	} else if (! $arr['sev']) {
		print '<font color="#e0850f">Warning -- '.$arr['failmsg'] . '</font>';
		$warnings = true;
       	} else {
	       	print '<font color="#bb0000">Fatal Warning -- ' . $arr['failmsg'] . '</font>';
		$fatals = true;
       	}

	print '</td></tr>';
}
?>
</table>
<br>
<?php
print '<b>Final Status Report: </b>';
if ($fatals) {
	print '<font color="#bb0000">Your PHP configuration flagged a <b>fatal warning</b>.  <b>Gallery will not run on this host without modifications to your PHP configuration</b>';
} else if ($warnings) {
	print '<font color="#e0850f">Your PHP configuration flagged some warnings (Gallery may lose some functionality)</font>';
} else {
	print '<font color="#00aa00">Your PHP configuration check passed with flying colors!</font>';
}	
?>