Return to Snippet

Revision: 12721
at March 25, 2009 23:23 by fackz


Initial Code
<?php
 /* set required extensions */
 $my_required_extensions = array(
  'gd',  //graphics library
  'xml',  //xml
  'mysql', //database
  'curl',  //networking
  'openssl', //site will need SSL
  'pecl'  //pear
 );
 natcasesort($my_required_extensions);
 
 //get loaded modules
 $loaded_extensions = get_loaded_extensions();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
 <title><?php echo $source_article; ?> Example</title>
 <meta name="description" value="<?php echo htmlentities($meta_description); ?>" />
 <style type="text/css">
  body  { font-size:12px; }
  h2   { border-bottom:1px solid #ccc; font-weight:normal; font-size:18px; margin-bottom:5px; padding-bottom:2px; }
  p   { line-height:20px; margin-top:0; }
  .found  { background:lightgreen; padding:5px 10px; margin:0 0 10px 0; }
  .miss  { background:pink; padding:5px 10px; margin:0 0 10px 0; }
  .extra  { background:lightblue; padding:5px 10px; margin:0 0 10px 0; }
 </style>
</head>
<body>

<h1><?php echo $_SERVER['HTTP_HOST']; ?></h1>

<h2>General Information</h2>
<p>
 <strong>Server Software:</strong>  <?php echo $_SERVER['SERVER_SOFTWARE']; ?><br />
 <strong>Document Root:</strong> <?php echo $_SERVER['DOCUMENT_ROOT']; ?><br />
 <strong>PHP Version:</strong> <?php echo phpversion(); ?>
</p>

<h2>Extension Check</h2>
<?php 
 /* print out */
 //analyze results
 foreach($my_required_extensions as $ext)
 {
  if(in_array($ext,$loaded_extensions))
  {
   $matches[] = strtolower($ext);
  }
  else
  {
   $missings[] = strtolower($ext);
  }
  unset($loaded_extensions[$ext]);
 }
 //print out results
 natcasesort($matches); natcasesort($missings); natcasesort($loaded_extensions);
 foreach($matches as $match) { echo '<div class="found"><strong>',$match,'</strong> found!</div>'; }
 foreach($missings as $miss) { echo '<div class="miss"><strong>',$miss,'</strong> missing!</div>'; }
 foreach($loaded_extensions as $e) { if(!in_array($e,$matches) && !in_array($e,$missings)) { echo '<div class="extra"><strong>',$e,'</strong> is available.</div>'; } }
?><br />

</body>
</html>

Initial URL
http://blog.jeremymartin.name/2008/04/know-your-environment-php-server-module.html

Initial Description
A basic PHP script that I simply FTP to the server and use to evaluate extensions on the server. I simply supply the extensions I require and the script does the rest of the work.

Initial Title
Php Server module Report

Initial Tags
server

Initial Language
PHP