Last active
October 7, 2015 10:18
-
-
Save bedeabza/3150162 to your computer and use it in GitHub Desktop.
Capabilities test for Webstars CMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Webstars Application | |
* | |
* This file tests the capabilities of the web server to insure that a Zend Framework CMS will run smoothly | |
* | |
* @category WS | |
* @package WS | |
* @copyright 2005-2010 WebstarsLTD (http://www.webstarsltd.com/) | |
*/ | |
//error reporting | |
error_reporting(E_ALL^E_NOTICE); | |
ini_set('display_errors', 'Off'); | |
function warning_handler($a, $e){ | |
throw new Exception('Warning: ' . $e); | |
} | |
function error_handler($a, $e){ | |
throw new Exception('Error: ' . $e); | |
} | |
set_error_handler('warning_handler', E_WARNING); | |
set_error_handler('error_handler', E_ERROR); | |
//results | |
$results = array( | |
'apache' => array( | |
'status' => false, | |
'version' => '2.2.3', | |
'error' => 'Your apache version is %s. The required version is %s' | |
), | |
'mod_rewrite' => array( | |
'status' => false, | |
'error' => 'mod_rewrite is not enabled as an apache module' | |
), | |
'mod_expires' => array( | |
'status' => false, | |
'error' => 'mod_expires is used by the application to serve cached content. If this module is not available your application will be less responsive and will consume more bandwidth' | |
), | |
'mod_deflate' => array( | |
'status' => false, | |
'error' => 'mod_deflate is used by the application to serve packed content. If this module is not available your application will consume more bandwidth' | |
), | |
'php' => array( | |
'status' => false, | |
'version' => '5.3.6', | |
'error' => 'The PHP version is %s, but %s is required' | |
), | |
'gd' => array( | |
'status' => false, | |
'error' => 'The php GD library is required for image processing to work' | |
), | |
'magic_quotes_gpc' => array( | |
'status' => false, | |
'error' => 'The magic quotes gpc option must be switched off' | |
), | |
'register_globals' => array( | |
'status' => false, | |
'error' => 'The register_globals option must be switched off' | |
), | |
'file_uploads' => array( | |
'status' => false, | |
'error' => 'File uploads must be enabled' | |
), | |
'open_basedir' => array( | |
'status' => false, | |
'error' => 'Open basedir restriction must be switched off' | |
), | |
'safe_mode' => array( | |
'status' => false, | |
'error' => 'PHP safe mode must be turned off' | |
), | |
'short_open_tag'=> array( | |
'status' => false, | |
'error' => 'The PHP short open tag must be enabled' | |
), | |
'pdo' => array( | |
'status' => false, | |
'error' => 'php-pdo must be installed with the mysql driver' | |
), | |
'mysql' => array( | |
'status' => false, | |
'version' => '5.0.0', | |
'error' => 'MySql %s was found but at least %s must be installed', | |
) | |
); | |
?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<title>Webstars Ltd | Webstars CMS server capabilities test</title> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | |
<meta http-equiv="expire" content="Sun, 15 Dec 1975 00:00:00 GMT" /> | |
<meta http-equiv="revision" content="01" /> | |
<meta http-equiv="Pragma" content="no-cache" /> | |
<meta http-equiv="Window-target" content="_top" /> | |
<meta name="author" content="WebstarsLtd.com // [email protected]" /> | |
<meta name="keywords" content="" /> | |
<meta name="description" content="" /> | |
<script type="text/javascript" src="http://use.typekit.com/xqt3ymi.js"></script> | |
<script type="text/javascript">try { | |
Typekit.load(); | |
} catch(e) { | |
}</script> | |
<link href="http://dragos.dev4.clientproof.co.uk/testsupport/css/main.css" media="screen" rel="stylesheet" type="text/css" /> | |
<!--[if IE 6]><link href="http://dragos.dev4.clientproof.co.uk/css/ie6.css" media="screen" rel="stylesheet" type="text/css" /><![endif]--> | |
<link href="http://dragos.dev4.clientproof.co.uk/testsupport/images/misc/favicon.ico" rel="shortcut icon" /> | |
<script type="text/javascript" src="http://dragos.dev4.clientproof.co.uk/testsupport/js/libraries.js"></script> | |
<script type="text/javascript" src="http://dragos.dev4.clientproof.co.uk/testsupport/js/main.js"></script> | |
<!--[if IE 6]> | |
<script type="text/javascript" src="http://dragos.dev4.clientproof.co.uk/testsupport/js/ie6.js"></script><![endif]--> | |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&amp;region=GB"></script> | |
<style type="text/css"> | |
#header{ position:relative; } | |
a#contact{ position:absolute; top:18px; right:0; } | |
h1{ font-family: "purista-web-1","purista-web-2",sans-serif; } | |
.testtable td{ padding:10px 8px; } | |
td.red{ background:url("http://dragos.dev4.clientproof.co.uk/testsupport/images/reicons/no.png") no-repeat 9px 4px;color:#000;font-weight:bold; padding-left:50px; } | |
td.yellow{ background:url("http://dragos.dev4.clientproof.co.uk/testsupport/images/reicons/info.png") no-repeat 9px center;;color:#000;font-weight:bold; padding-left:50px; } | |
td.lightgreen{ background:url("http://dragos.dev4.clientproof.co.uk/testsupport/images/reicons/ok.png") no-repeat 9px center;;color:#000;font-weight:bold; padding-left:50px; } | |
</style> | |
</head> | |
<body class="index-page"> | |
<div id="header" class="page-wrapper"> | |
<a id="logo" href=""><img src="http://dragos.dev4.clientproof.co.uk/testsupport/images/misc/logo.jpg" alt="WebstarsLtd" /></a> | |
<ul id="main-menu" class="clearfix shorcut-hotkey-menu"> | |
<li class="first"><a href="http://webstarsltd.com/">Home</a></li> | |
<li class=""><a href="http://webstarsltd.com/work">Work</a></li> | |
<li class=""><a href="http://webstarsltd.com/blog">Blog</a></li> | |
<li class="last contact-lightbox"><a href="http://webstarsltd.com/contact-us">Contact</a></li> | |
</ul> | |
</div> | |
<div class="page-wrapper"> | |
<h1>Webstars CMS server capabilities test</h1> | |
<table width="100%" border="1" class="testtable"> | |
<?php | |
//Start test | |
if(function_exists('apache_get_modules')){ | |
try { | |
$modules = (array)apache_get_modules(); | |
} catch (Exception $e) { | |
$noModules = true; | |
} | |
}else{ | |
$noModules = true; | |
} | |
foreach($results as $key => &$options){ | |
switch($key){ | |
case 'apache': | |
$version_arr = explode('/', $_SERVER['SERVER_SOFTWARE']); | |
$version_arr = explode(' ', $version_arr[1]); | |
$options['currentVersion'] = $version_arr[0]; | |
$options['status'] = version_compare($options['currentVersion'], $options['version']) >= 0; | |
break; | |
case 'mod_rewrite': | |
$options['status'] = $noModules ? 0 : in_array($key, $modules); | |
if($noModules) | |
$options['error'] = 'Can\'t check for active apache modules'; | |
break; | |
case 'mod_expires': | |
case 'mod_deflate': | |
$options['status'] = $noModules ? 0 : (in_array($key, $modules) ? true : 0); | |
if($noModules) | |
$options['error'] = 'Can\'t check for active apache modules'; | |
break; | |
case 'php': | |
$options['currentVersion'] = phpversion(); | |
$options['status'] = version_compare($options['currentVersion'], $options['version']) >= 0; | |
break; | |
case 'gd': | |
$options['status'] = extension_loaded('gd') && function_exists('gd_info'); | |
break; | |
case 'magic_quotes_gpc': | |
case 'register_globals': | |
case 'open_basedir': | |
case 'safe_mode': | |
$options['status'] = (bool)ini_get($key) == false; | |
break; | |
case 'file_uploads': | |
case 'short_open_tag': | |
$options['status'] = (bool)ini_get($key) == true; | |
break; | |
case 'pdo': | |
$options['status'] = defined('PDO::ATTR_DRIVER_NAME') && defined('PDO::MYSQL_ATTR_LOCAL_INFILE'); | |
break; | |
case 'mysql': | |
if(!function_exists('mysql_get_server_info')){ | |
$options['status'] = 0; | |
$options['error'] = 'Function mysql_get_server_info() does not exist. Cannot check for mysql version'; | |
}else{ | |
try{ | |
$version = mysql_get_server_info(); | |
if($version === false){ | |
$options['error'] = 'Can\'t check for mysql version'; | |
$options['status'] = 0; | |
}else{ | |
$options['currentVersion'] = $version; | |
$options['status'] = version_compare($version, $options['version']) >= 0; | |
} | |
}catch(Exception $e){ | |
$options['status'] = 0; | |
$options['error'] = 'Can\'t check for mysql version'; | |
} | |
} | |
break; | |
case 'java': | |
exec("java", $output); | |
$options['status'] = count($output) > 20; | |
break; | |
} | |
//display result | |
$class = $options['status'] === false ? 'red' : ($options['status'] === 0 ? 'yellow' : 'lightgreen'); | |
$colour = $options['status'] === false ? 'white' : 'black'; | |
$message = $options['status'] === true ? 'OK' : sprintf($options['error'], $options['currentVersion'], $options['version']); | |
echo '<tr>'; | |
echo '<td style="background-color:#eee;">'.$key.'</td>'; | |
echo '<td class="'.$class.'">'.$message.'</td>'; | |
echo '</tr>'; | |
} | |
?> | |
</table> | |
<br /> | |
<table width="100%" border="1" class="testtable"> | |
<tr> | |
<td colspan="2" style="background-color:#eee;">Install one of the following versioning systems on CentOS</td> | |
</tr> | |
<tr> | |
<td>Subversion:</td> | |
<td><strong>yum install subversion</strong></td> | |
</tr> | |
<tr> | |
<td>Git:</td> | |
<td><strong>yum install git-core</strong></td> | |
</tr> | |
</table> | |
</div> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment