1<?php
2
3// Sanity check, install should only be checked from index.php
4defined('SYSPATH') or exit('Install tests must be loaded from within index.php!');
5
6if (version_compare(PHP_VERSION, '5.3', '<'))
7{
8	// Clear out the cache to prevent errors. This typically happens on Windows/FastCGI.
9	clearstatcache();
10}
11else
12{
13	// Clearing the realpath() cache is only possible PHP 5.3+
14	clearstatcache(TRUE);
15}
16
17?>
18<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
19	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
20
21<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
22<head>
23
24	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
25	<title>Kohana Installation</title>
26
27	<style type="text/css">
28	body { width: 42em; margin: 0 auto; font-family: sans-serif; background: #fff; font-size: 1em; }
29	h1 { letter-spacing: -0.04em; }
30	h1 + p { margin: 0 0 2em; color: #333; font-size: 90%; font-style: italic; }
31	code { font-family: monaco, monospace; }
32	table { border-collapse: collapse; width: 100%; }
33		table th,
34		table td { padding: 0.4em; text-align: left; vertical-align: top; }
35		table th { width: 12em; font-weight: normal; }
36		table tr:nth-child(odd) { background: #eee; }
37		table td.pass { color: #191; }
38		table td.fail { color: #911; }
39	#results { padding: 0.8em; color: #fff; font-size: 1.5em; }
40	#results.pass { background: #191; }
41	#results.fail { background: #911; }
42	</style>
43
44</head>
45<body>
46
47	<h1>Environment Tests</h1>
48
49	<p>
50		The following tests have been run to determine if <a href="http://kohanaframework.org/">Kohana</a> will work in your environment.
51		If any of the tests have failed, consult the <a href="http://kohanaframework.org/guide/about.install">documentation</a>
52		for more information on how to correct the problem.
53	</p>
54
55	<?php $failed = FALSE ?>
56
57	<table cellspacing="0">
58		<tr>
59			<th>PHP Version</th>
60			<?php if (version_compare(PHP_VERSION, '5.3.3', '>=')): ?>
61				<td class="pass"><?php echo PHP_VERSION ?></td>
62			<?php else: $failed = TRUE ?>
63				<td class="fail">Kohana requires PHP 5.3.3 or newer, this version is <?php echo PHP_VERSION ?>.</td>
64			<?php endif ?>
65		</tr>
66		<tr>
67			<th>System Directory</th>
68			<?php if (is_dir(SYSPATH) AND is_file(SYSPATH.'classes/Kohana'.EXT)): ?>
69				<td class="pass"><?php echo SYSPATH ?></td>
70			<?php else: $failed = TRUE ?>
71				<td class="fail">The configured <code>system</code> directory does not exist or does not contain required files.</td>
72			<?php endif ?>
73		</tr>
74		<tr>
75			<th>Application Directory</th>
76			<?php if (is_dir(APPPATH) AND is_file(APPPATH.'bootstrap'.EXT)): ?>
77				<td class="pass"><?php echo APPPATH ?></td>
78			<?php else: $failed = TRUE ?>
79				<td class="fail">The configured <code>application</code> directory does not exist or does not contain required files.</td>
80			<?php endif ?>
81		</tr>
82		<tr>
83			<th>Cache Directory</th>
84			<?php if (is_dir(APPPATH) AND is_dir(APPPATH.'cache') AND is_writable(APPPATH.'cache')): ?>
85				<td class="pass"><?php echo APPPATH.'cache/' ?></td>
86			<?php else: $failed = TRUE ?>
87				<td class="fail">The <code><?php echo APPPATH.'cache/' ?></code> directory is not writable.</td>
88			<?php endif ?>
89		</tr>
90		<tr>
91			<th>Logs Directory</th>
92			<?php if (is_dir(APPPATH) AND is_dir(APPPATH.'logs') AND is_writable(APPPATH.'logs')): ?>
93				<td class="pass"><?php echo APPPATH.'logs/' ?></td>
94			<?php else: $failed = TRUE ?>
95				<td class="fail">The <code><?php echo APPPATH.'logs/' ?></code> directory is not writable.</td>
96			<?php endif ?>
97		</tr>
98		<tr>
99			<th>PCRE UTF-8</th>
100			<?php if ( ! @preg_match('/^.$/u', 'ñ')): $failed = TRUE ?>
101				<td class="fail"><a href="http://php.net/pcre">PCRE</a> has not been compiled with UTF-8 support.</td>
102			<?php elseif ( ! @preg_match('/^\pL$/u', 'ñ')): $failed = TRUE ?>
103				<td class="fail"><a href="http://php.net/pcre">PCRE</a> has not been compiled with Unicode property support.</td>
104			<?php else: ?>
105				<td class="pass">Pass</td>
106			<?php endif ?>
107		</tr>
108		<tr>
109			<th>SPL Enabled</th>
110			<?php if (function_exists('spl_autoload_register')): ?>
111				<td class="pass">Pass</td>
112			<?php else: $failed = TRUE ?>
113				<td class="fail">PHP <a href="http://www.php.net/spl">SPL</a> is either not loaded or not compiled in.</td>
114			<?php endif ?>
115		</tr>
116		<tr>
117			<th>Reflection Enabled</th>
118			<?php if (class_exists('ReflectionClass')): ?>
119				<td class="pass">Pass</td>
120			<?php else: $failed = TRUE ?>
121				<td class="fail">PHP <a href="http://www.php.net/reflection">reflection</a> is either not loaded or not compiled in.</td>
122			<?php endif ?>
123		</tr>
124		<tr>
125			<th>Filters Enabled</th>
126			<?php if (function_exists('filter_list')): ?>
127				<td class="pass">Pass</td>
128			<?php else: $failed = TRUE ?>
129				<td class="fail">The <a href="http://www.php.net/filter">filter</a> extension is either not loaded or not compiled in.</td>
130			<?php endif ?>
131		</tr>
132		<tr>
133			<th>Iconv Extension Loaded</th>
134			<?php if (extension_loaded('iconv')): ?>
135				<td class="pass">Pass</td>
136			<?php else: $failed = TRUE ?>
137				<td class="fail">The <a href="http://php.net/iconv">iconv</a> extension is not loaded.</td>
138			<?php endif ?>
139		</tr>
140		<?php if (extension_loaded('mbstring')): ?>
141		<tr>
142			<th>Mbstring Not Overloaded</th>
143			<?php if (ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING): $failed = TRUE ?>
144				<td class="fail">The <a href="http://php.net/mbstring">mbstring</a> extension is overloading PHP's native string functions.</td>
145			<?php else: ?>
146				<td class="pass">Pass</td>
147			<?php endif ?>
148		</tr>
149		<?php endif ?>
150		<tr>
151			<th>Character Type (CTYPE) Extension</th>
152			<?php if ( ! function_exists('ctype_digit')): $failed = TRUE ?>
153				<td class="fail">The <a href="http://php.net/ctype">ctype</a> extension is not enabled.</td>
154			<?php else: ?>
155				<td class="pass">Pass</td>
156			<?php endif ?>
157		</tr>
158		<tr>
159			<th>URI Determination</th>
160			<?php if (isset($_SERVER['REQUEST_URI']) OR isset($_SERVER['PHP_SELF']) OR isset($_SERVER['PATH_INFO'])): ?>
161				<td class="pass">Pass</td>
162			<?php else: $failed = TRUE ?>
163				<td class="fail">Neither <code>$_SERVER['REQUEST_URI']</code>, <code>$_SERVER['PHP_SELF']</code>, or <code>$_SERVER['PATH_INFO']</code> is available.</td>
164			<?php endif ?>
165		</tr>
166	</table>
167
168	<?php if ($failed === TRUE): ?>
169		<p id="results" class="fail">✘ Kohana may not work correctly with your environment.</p>
170	<?php else: ?>
171		<p id="results" class="pass">✔ Your environment passed all requirements.<br />
172			Remove or rename the <code>install<?php echo EXT ?></code> file now.</p>
173	<?php endif ?>
174
175	<h1>Optional Tests</h1>
176
177	<p>
178		The following extensions are not required to run the Kohana core, but if enabled can provide access to additional classes.
179	</p>
180
181	<table cellspacing="0">
182		<tr>
183			<th>PECL HTTP Enabled</th>
184			<?php if (extension_loaded('http')): ?>
185				<td class="pass">Pass</td>
186			<?php else: ?>
187				<td class="fail">Kohana can use the <a href="http://php.net/http">http</a> extension for the Request_Client_External class.</td>
188			<?php endif ?>
189		</tr>
190		<tr>
191			<th>cURL Enabled</th>
192			<?php if (extension_loaded('curl')): ?>
193				<td class="pass">Pass</td>
194			<?php else: ?>
195				<td class="fail">Kohana can use the <a href="http://php.net/curl">cURL</a> extension for the Request_Client_External class.</td>
196			<?php endif ?>
197		</tr>
198		<tr>
199			<th>mcrypt Enabled</th>
200			<?php if (extension_loaded('mcrypt')): ?>
201				<td class="pass">Pass</td>
202			<?php else: ?>
203				<td class="fail">Kohana requires <a href="http://php.net/mcrypt">mcrypt</a> for the Encrypt class.</td>
204			<?php endif ?>
205		</tr>
206		<tr>
207			<th>GD Enabled</th>
208			<?php if (function_exists('gd_info')): ?>
209				<td class="pass">Pass</td>
210			<?php else: ?>
211				<td class="fail">Kohana requires <a href="http://php.net/gd">GD</a> v2 for the Image class.</td>
212			<?php endif ?>
213		</tr>
214		<tr>
215			<th>MySQL Enabled</th>
216			<?php if (function_exists('mysql_connect')): ?>
217				<td class="pass">Pass</td>
218			<?php else: ?>
219				<td class="fail">Kohana can use the <a href="http://php.net/mysql">MySQL</a> extension to support MySQL databases.</td>
220			<?php endif ?>
221		</tr>
222		<tr>
223			<th>PDO Enabled</th>
224			<?php if (class_exists('PDO')): ?>
225				<td class="pass">Pass</td>
226			<?php else: ?>
227				<td class="fail">Kohana can use <a href="http://php.net/pdo">PDO</a> to support additional databases.</td>
228			<?php endif ?>
229		</tr>
230	</table>
231
232</body>
233</html>
234