weathermap |
Subversion Repositories: |
Rev 1 | Rev 13 | |
---|---|---|
Line 1... | Line 1... | |
<?php |
<?php | |
// get some basics... |
// get some basics... | |
$php_version = phpversion(); |
$php_version = phpversion(); | |
$mem_allowed = ini_get("memory_limit"); |
$mem_allowed = ini_get("memory_limit"); | |
$php_os = php_uname(); |
$php_os = php_uname(); | |
|
| |
$mem_warning = ""; | ||
$mem_allowed_int = return_bytes($mem_allowed); | ||
if(($mem_allowed_int>0) && ($mem_allowed_int < 32000000)) { $mem_warning='You should increase this value to at least 32M. '; } | ||
| ||
// capture the PHP "General Info" table |
// capture the PHP "General Info" table | |
ob_start(); |
ob_start(); | |
phpinfo(INFO_GENERAL); |
phpinfo(INFO_GENERAL); | |
$s = ob_get_contents(); |
$s = ob_get_contents(); | |
ob_end_clean(); |
ob_end_clean(); | |
Line 27... | Line 31... | |
} |
} | |
} |
} | |
|
| |
$ini_file = $php_general['Configuration File (php.ini) Path']; |
$ini_file = $php_general['Configuration File (php.ini) Path']; | |
$extra_ini = php_ini_scanned_files(); |
$extra_ini = php_ini_scanned_files(); | |
if($extra_ini != '') $extra_ini = "The following additional ini files were read: $extra_ini"; |
if($extra_ini != '') | |
|
{ $extra_ini = "The following additional ini files were read: $extra_ini"; } | |
|
else { $extra_ini = "There were no additional ini files, according to PHP."; } | |
| ||
$gdversion = ""; | ||
$gdbuiltin=FALSE; | ||
$gdstring = ""; | ||
if(function_exists('gd_info')) | ||
{ | ||
$gdinfo = gd_info(); | ||
$gdversion=$gdinfo['GD Version']; | ||
if(strpos($gdversion,"bundled") !== FALSE) | ||
{ | ||
$gdbuiltin=TRUE; | ||
$gdstring="This PHP uses the 'bundled' GD library, which doesn't have alpha-blending bugs. That's good!\n"; | ||
} | ||
else | ||
{ | ||
$gdstring="This PHP uses the system GD library, which MIGHT have alpha-blending bugs. Check that you have at least GD 2.0.34 installed, if you see problems with weathermap segfaulting.\n"; | ||
} | ||
} | ||
else | ||
{ | ||
$gdstring = "The gdinfo() function is not available, which means that either the GD extension is not available, not enabled, or not installed.\n"; | ||
} | ||
| ||
if(isset($argv)) |
if(isset($argv)) | |
{ |
{ | |
$environment = "CLI"; |
$environment = "CLI"; | |
print "\n----------------------------------------------------\nWeathermap Pre-Install Checker\n\n"; |
print "\n----------------------------------------------------\nWeathermap Pre-Install Checker\n\n"; | |
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"; |
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"; | |
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"; |
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"; | |
print "\nThis is the PHP version that is responsible for \n* creating maps from the Cacti poller\n* the command-line weathermap tool\n\n"; | ||
print "PHP Basics\n----------\n"; |
print "PHP Basics\n----------\n"; | |
print wordwrap("This is PHP Version $php_version running on \"$php_os\" with a memory_limit of $mem_allowed\n"); |
print wordwrap("This is PHP Version $php_version running on \"$php_os\" with a memory_limit of '$mem_allowed'. $mem_warning\n"); | |
print "\nThe php.ini file was $ini_file\n$extra_ini\n\n"; |
print "\nThe php.ini file was $ini_file\n$extra_ini\n\n"; | |
print ""; | ||
print "PHP Functions\n-------------\n"; |
print "PHP Functions\n-------------\n"; | |
print "Some parts of Weathermap need special support in your PHP\ninstallation to work.\n\n"; |
print "Some parts of Weathermap need special support in your PHP\ninstallation to work.\n\n"; | |
print wordwrap($gdstring)."\n"; | ||
} |
} | |
else |
else | |
{ |
{ | |
$environment = "web"; |
$environment = "web"; | |
?> |
?> | |
Line 65... | Line 95... | |
|
| |
<h1>Weathermap Pre-install Checker</h1> |
<h1>Weathermap Pre-install Checker</h1> | |
|
| |
<p>This page checks for some common problems with your PHP and server environment that may stop Weathermap or the Editor from working.</p> |
<p>This page checks for some common problems with your PHP and server environment that may stop Weathermap or the Editor from working.</p> | |
<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> |
<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> | |
<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> |
<h2>PHP Basics</h2><p>This is the PHP version that is responsible for<ul> | |
<li>The web-based editor<li>Building maps with Rebuild Now from Cacti</ul></p> | ||
<p>This is PHP Version <?php echo $php_version ?> running on "<?php echo $php_os ?>" with a memory_limit of '<?php echo $mem_allowed ?>'. <?php echo $mem_warning ?></p> | ||
<p>The php.ini file was <?php echo $ini_file ?></p> |
<p>The php.ini file was <?php echo $ini_file ?></p> | |
<p><?php echo $extra_ini ?></p> |
<p><?php echo $extra_ini ?></p> | |
<h2>PHP Functions</h2> |
<h2>PHP Functions</h2> | |
<p>Some parts of Weathermap need special support in your PHP installation to work.</p> |
<p>Some parts of Weathermap need special support in your PHP installation to work.</p> | |
<?php echo $gdstring; ?> | ||
<table> |
<table> | |
<?php |
<?php | |
} |
} | |
|
| |
$critical=0; |
$critical=0; | |
$noncritical=0; |
$noncritical=0; | |
| ||
| ||
|
| |
# critical, what-it-affects, what-it-is |
# critical, what-it-affects, what-it-is | |
$functions = array('imagepng' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'), |
$functions = array('imagepng' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'), | |
'imagecreatetruecolor' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'), |
'imagecreatetruecolor' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'), | |
'imagealphablending' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'), |
'imagealphablending' => array(TRUE,FALSE,'all of Weathermap','part of the GD library and the "gd" PHP extension'), | |
Line 96... | Line 131... | |
'memory_get_usage' => array(FALSE,TRUE,'memory-usage debugging','not supported on all PHP versions and platforms') |
'memory_get_usage' => array(FALSE,TRUE,'memory-usage debugging','not supported on all PHP versions and platforms') | |
); |
); | |
|
| |
$results=array(); |
$results=array(); | |
|
| |
if($environment == 'CLI') | ||
{ | ||
// Console_Getopt is only needed by the CLI tool. | ||
$included = @include_once 'Console/Getopt.php'; | ||
| ||
if($included != 1) | ||
{ | ||
$noncritical++; | ||
print wordwrap("The Console_Getopt PEAR module is not available. The CLI weathermap tool will not run without it (that may not be a problem, if you only intend to use Cacti).\n\n"); | ||
} | ||
else | ||
{ | ||
print wordwrap("The Console_Getopt PEAR module is available. That's good!\n\n"); | ||
} | ||
| ||
} | ||
| ||
foreach ($functions as $function=>$details) |
foreach ($functions as $function=>$details) | |
{ |
{ | |
$exists = ""; $notes=""; |
$exists = ""; $notes=""; | |
if($environment=='web') print "<tr><td align=right>$function()</td>"; |
if($environment=='web') print "<tr><td align=right>$function()</td>"; | |
|
| |
Line 183... | Line 235... | |
} |
} | |
else |
else | |
{ |
{ | |
if($noncritical>0) |
if($noncritical>0) | |
{ |
{ | |
if($environment=='web') print "<div class=\"noncritical\">"; |
if($environment=='web') print "<div class=\"noncritical\">"; | |
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"); |
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"); | |
if($environment=='web') print "</div>"; |
if($environment=='web') print "</div>"; | |
|
| |
} |
} | |
else |
else | |
{ |
{ | |
if($environment=='web') print "<div class=\"ok\">"; |
if($environment=='web') print "<div class=\"ok\">"; | |
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"); |
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"); | |
if($environment=='web') print "</div>"; |
if($environment=='web') print "</div>"; | |
|
| |
} |
} | |
} |
} | |
if($environment=='web') print "</body></html>"; |
if($environment=='web') print "</body></html>"; | |
| ||
function return_bytes($val) { | ||
$val = trim($val); | ||
if($val != '') | ||
{ | ||
$last = strtolower($val{strlen($val)-1}); | ||
switch($last) { | ||
// The 'G' modifier is available since PHP 5.1.0 | ||
case 'g': | ||
$val *= 1024; | ||
case 'm': | ||
$val *= 1024; | ||
case 'k': | ||
$val *= 1024; | ||
} | ||
} | ||
else | ||
{ | ||
$val = 0; | ||
} | ||
| ||
return $val; | ||
} | ||
?> |
?> | |
|
|