From 7697e7f8ee9be0d6a5f96b8d856ea8674ba76a44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Mon, 3 Mar 2008 09:56:05 +0000
Subject: [PATCH] Adding a new check your php configuration section on the
 frontpage of the installation

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@341 44740490-163a-0410-bde0-09ae8108e29a
---
 templates/default/en/frontpage.php | 24 +++++++++++++++++++++++-
 www/index.php                      | 20 ++++++++++++++++++++
 www/resources/default.css          |  5 ++++-
 3 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/templates/default/en/frontpage.php b/templates/default/en/frontpage.php
index 909e4cfe1..8ae064e7b 100644
--- a/templates/default/en/frontpage.php
+++ b/templates/default/en/frontpage.php
@@ -5,7 +5,7 @@
 
 	<div id="content">
 
-<div class="enablebox">
+<div class="enablebox mini">
 <table>
 
 <?php
@@ -76,6 +76,28 @@ $icon_disabled = '<img src="/' . $data['baseurlpath'] . 'resources/icons/delete.
 			}
 		?>
 		
+		<h2>Checking your PHP installation</h2>
+		
+		
+		<div class="enablebox">
+		<table>
+		
+		<?php
+		
+		$icon_enabled  = '<img src="/' . $data['baseurlpath'] . 'resources/icons/accept.png" alt="enabled" />';
+		$icon_disabled = '<img src="/' . $data['baseurlpath'] . 'resources/icons/delete.png" alt="disabled" />';
+		
+		
+		foreach ($this->data['funcmatrix'] AS $func) {
+			echo '<tr class="' . ($func['enabled'] ? 'enabled' : 'disabled') . '"><td>' . ($func['enabled'] ? $icon_enabled : $icon_disabled) . '</td>
+			<td>' . $func['required'] . '</td><td>' . $func['descr'] . '</td></tr>';
+		}
+		
+		?>
+
+		</table>
+		</div>
+		
 
 	<h2>About simpleSAMLphp</h2>
 		<p>Hey! This simpleSAMLphp thing is pretty cool, where can I read more about it? You can find more information about <a href="http://rnd.feide.no/simplesamlphp">simpleSAMLphp at the Feide RnD blog</a> over at <a href="http://uninett.no">UNINETT</a>.</p>
diff --git a/www/index.php b/www/index.php
index e86224236..51521117d 100644
--- a/www/index.php
+++ b/www/index.php
@@ -127,6 +127,25 @@ $enablematrix = array(
 );
 
 
+$functionchecks = array(
+	'hash'             => array('required',  'Hashing function'),
+	'gzinflate'        => array('required',  'ZLib'),
+	'openssl_sign'     => array('required',  'OpenSSL'),
+	'simplexml_import_dom' => array('required', 'SimpleXML'),
+	'dom_import_simplexml' => array('required', 'XML DOM'),
+	'preg_match'       => array('required',  'RegEx support'),
+	'ldap_bind'        => array('required for LDAP auth module',  'LDAP Extension'),
+	'radius_auth_open' => array('required for Radius auth module',  'Radius Extension'),
+	'mcrypt_module_open'=> array('optional',  'MCrypt'),
+);
+$funcmatrix = array();
+$funcmatrix[] = array('required' => 'required', 'descr' => 'PHP Version >= 5.1.2. You run: ' . phpversion(), 'enabled' => version_compare(phpversion(), '5.1.2', '>='));
+$funcmatrix[] = array('required' => 'reccomended', 'descr' => 'PHP Version >= 5.2', 'enabled' => version_compare(phpversion(), '5.2', '>='));
+foreach ($functionchecks AS $func => $descr) {
+	$funcmatrix[] = array('descr' => $descr[1], 'required' => $descr[0], 'enabled' => function_exists($func));
+}
+
+
 $t = new SimpleSAML_XHTML_Template($config, 'frontpage.php');
 $t->data['header'] = 'simpleSAMLphp installation page';
 $t->data['icon'] = 'compass_l.png';
@@ -135,6 +154,7 @@ $t->data['links'] = $links;
 $t->data['links_meta'] = $linksmeta;
 $t->data['links_doc'] = $linksdoc;
 $t->data['enablematrix'] = $enablematrix;
+$t->data['funcmatrix'] = $funcmatrix;
 
 $t->show();
 
diff --git a/www/resources/default.css b/www/resources/default.css
index d03ca4c68..770f3c60c 100644
--- a/www/resources/default.css
+++ b/www/resources/default.css
@@ -219,9 +219,12 @@ th.rowtitle {
 }
 .enablebox table {
 	border: 1px solid #eee;
-	float: right;
+
 	margin-left: 1em;
 }
+.enablebox.mini table {
+	float: right;
+}
 .enablebox tr td {
 	padding: .5px 1em 1px .5em;
 	margin: 0px;
-- 
GitLab