jablonka.czprosek.czf

weathermap

Subversion Repositories:
[/] [check.php] - Blame information for rev 4

 

Line No. Rev Author Line
11simandl<?php
2 // get some basics...
3 $php_version = phpversion();
4 $mem_allowed = ini_get("memory_limit");
5 $php_os = php_uname();
6 
7 // capture the PHP "General Info" table
8 ob_start();
9 phpinfo(INFO_GENERAL);
10 $s = ob_get_contents();
11 ob_end_clean();
12 
13 // <tr><td class="e">System </td><td class="v">Windows NT BLINKYZERO 6.0 build 6000 </td></tr>
14 // since preg_* are potentially missing, we'll have to do this without regexps.
15 foreach (explode("\n",$s) as $line)
16 {
17 $line = str_replace('<tr><td class="e">','',$line);
18 $line = str_replace('</td></tr>','',$line);
19 $line = str_replace(' </td><td class="v">',' => ',$line);
20 $sep_pos = strpos($line," => ");
21 if($sep_pos!==FALSE)
22 {
23 // by here, it should be a straight "name => value"
24 $name = substr($line,0,$sep_pos);
25 $value = substr($line,$sep_pos+4);
26 $php_general[$name] = $value;
27 }
28 }
29 
30 $ini_file = $php_general['Configuration File (php.ini) Path'];
31 $extra_ini = php_ini_scanned_files();
32 if($extra_ini != '') $extra_ini = "The following additional ini files were read: $extra_ini";
33 
34 
35 if(isset($argv))
36 {
37 $environment = "CLI";
38 print "\n----------------------------------------------------\nWeathermap Pre-Install Checker\n\n";
39 print "This script checks for some common problems with your PHP and server\nenvironment that may stop Weathermap or the Editor from working.\n\n";
40 print "NOTE: You should run this script as both a web page AND from the\ncommand-line, as the environment can be different in each.\n\n";
41 print "PHP Basics\n----------\n";
42 print wordwrap("This is PHP Version $php_version running on \"$php_os\" with a memory_limit of $mem_allowed\n");
43 print "\nThe php.ini file was $ini_file\n$extra_ini\n\n";
44 print "PHP Functions\n-------------\n";
45 print "Some parts of Weathermap need special support in your PHP\ninstallation to work.\n\n";
46 }
47 else
48 {
49 $environment = "web";
50?>
51<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
52<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
53<head>
54 <title>Weathermap Pre-Install Checker</title>
55 <style>
56 body { font-family: Lucida Grande,Arial,sans-serif; font-size: 10pt; }
57 p {margin-bottom: 10px; margin-top: 10px;}
58 table { margin: 20px;}
59 .critical { width: 400px; padding: 10px; background: #fee; border: 1px solid #f88; padding-left: 20px; background-image: left no-repeat url(images/exclamation.png); }
60 .noncritical { width: 400px; padding: 10px; background: #ffe; border: 1px solid #fb8; }
61 .ok { width: 400px; padding: 10px; background: #efe; border: 1px solid #8f8; }
62 </style>
63</head>
64<body>
65 
66 <h1>Weathermap Pre-install Checker</h1>
67 
68 <p>This page checks for some common problems with your PHP and server environment that may stop Weathermap or the Editor from working.</p>
69 <p>NOTE: You should run this script as a web page AND from the command-line, as the environment can be different in each.</p>
70 <h2>PHP Basics</h2><p>This is PHP Version <?php echo $php_version ?> running on "<?php echo $php_os ?>" with a memory_limit of <?php echo $mem_allowed ?></p>
71 <p>The php.ini file was <?php echo $ini_file ?></p>
72 <p><?php echo $extra_ini ?></p>
73 <h2>PHP Functions</h2>
74 <p>Some parts of Weathermap need special support in your PHP installation to work.</p>
75 <table>
76<?php
77 }
78 
79 $critical=0;
80 $noncritical=0;
81 
82 # critical, what-it-affects, what-it-is
83 $functions = array('imagepng' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'),
84 'imagecreatetruecolor' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'),
85 'imagealphablending' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'),
86 'imageSaveAlpha' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'),
87 'preg_match'=> array(TRUE,FALSE,'configuration reading','provided by the "pcre" extension') ,
88 'imagecreatefrompng' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'),
89 
90 'imagecreatefromjpeg' => array(FALSE,FALSE,'JPEG input support for ICON and BACKGROUND','an optional part of the GD library and the "gd" PHP extension'),
91 'imagecreatefromgif' => array(FALSE,FALSE,'GIF input support for ICON and BACKGROUND','an optional part of the GD library and the "gd" PHP extension'),
92 'imagejpeg' => array(FALSE,FALSE,'JPEG output support','an optional part of the GD library and the "gd" PHP extension'),
93 'imagegif' => array(FALSE,FALSE,'GIF output support','an optional part of the GD library and the "gd" PHP extension'),
94 'imagecopyresampled' => array(FALSE,FALSE,'Thumbnail creation in the Cacti plugin','an optional part of the GD library and the "gd" PHP extension'),
95 'imagettfbbox' => array(FALSE,FALSE,'TrueType font support','an optional part of the GD library and the "gd" PHP extension'),
96 'memory_get_usage' => array(FALSE,TRUE,'memory-usage debugging','not supported on all PHP versions and platforms')
97 );
98 
99 $results=array();
100 
101 foreach ($functions as $function=>$details)
102 {
103 $exists = ""; $notes="";
104 if($environment=='web') print "<tr><td align=right>$function()</td>";
105 
106 if(function_exists($function))
107 {
108 $exists = "YES";
109 if($environment=='web') print "<td><img alt=\"YES\" src=\"images/tick.png\" /></td>";
110 }
111 else
112 {
113 $exists = "NO";
114 if($details[0])
115 {
116 $notes .= "CRITICAL. ";
117 if($environment=='web') print "<td><img alt=\"NO\" src=\"images/exclamation.png\" /><b>CRITICAL</b> ";
118 $critical++;
119 } else {
120 if(!$details[1])
121 {
122 $notes .= "Non-Critical. ";
123 if($environment=='web') print "<td><img alt=\"NO\" src=\"images/cross.png\" /><i>non-critical</i> ";
124 $noncritical++;
125 }
126 else
127 {
128 $notes .= "Minor. ";
129 if($environment=='web') print "<td><img alt=\"NO\" src=\"images/cross.png\" /><i>minor</i> ";
130 }
131 }
132 $explanation = "This is required for ".$details[2].". It is ".$details[3].".";
133 $notes .= $explanation;
134 
135 if($environment=='web') print "$explanation</td>";
136 }
137 if($environment=='web') print "</tr>\n";
138 else
139 {
140 $wnotes = wordwrap($notes,50);
141 $lines = split("\n",$wnotes);
142 $i=0;
143 foreach ($lines as $noteline)
144 {
145 if($i==0)
146 {
147 print sprintf("%20s %5s %-52s\n",$function,$exists,$noteline);
148 $i++;
149 }
150 else
151 {
152 print sprintf("%20s %5s %-52s\n","","",$noteline);
153 $i++;
154 }
155 }
156 }
157 }
158 
159 if($environment=='web') print "</table>";
160 
161 if( ($critical + $noncritical) > 0)
162 {
163 if($environment=='web')
164 {
165 print "<p>If these functions are not found, you may need to <ul><li>check that the 'extension=' line for that extension is uncommented in your php.ini file (then restart your webserver), or<li>install the extension, if it isn't installed already</ul>";
166 }
167 else
168 {
169 print "\nIf these functions are not found, you may need to\n * check that the 'extension=' line for that extension is uncommented in\n your php.ini file (then restart your webserver), or\n * install the extension, if it isn't installed already\n\n";
170 }
171 
172 print wordwrap("The details of how this is done will depend on your operating system, and on where you installed (or compiled) your PHP from originally. Usually, you would install an RPM, or other package on Linux systems, a port on *BSD, or a DLL on Windows. If you build PHP from source, you need to add extra options to the './configure' line. Consult your PHP documention for more information.\n");
173 if($environment=='web') print "</p>";
174 }
175 
176 if($environment=="CLI") print "\n---------------------------------------------------------------------\n";
177 
178 if($critical>0)
179 {
180 if($environment=='web') print "<div class=\"critical\">";
181 print wordwrap("There are problems with your PHP or server environment that will stop Weathermap from working. You need to correct this issues if you wish to use Weathermap.\n");
182 if($environment=='web') print "</div>";
183 }
184 else
185 {
186 if($noncritical>0)
187 {
188 if($environment=='web') print "<div class=\"noncritical\">";
189 print wordwrap("Some features of Weathermap will not be available to you, due to lack of support in your PHP installation. You can still proceed with Weathermap though.\n");
190 if($environment=='web') print "</div>";
191 
192 }
193 else
194 {
195 if($environment=='web') print "<div class=\"ok\">";
196 print wordwrap("OK! Your PHP and server environment seems to have support for ALL of the Weathermap features. Make sure you have run this script BOTH as a web page and from the CLI to be sure, however.\n");
197 if($environment=='web') print "</div>";
198 
199 }
200 }
201 if($environment=='web') print "</body></html>";
202?>

Powered by WebSVN 2.2.1