<?php

if(stristr(htmlentities($_SERVER['PHP_SELF']), "admin.php")){
	die("You cannot access this file directly!");
}

# Copyright (C) 2010 - onwards. The Napata CMS Project.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# http://www.gnu.org/copyleft/gpl.html

if($_SESSION['logged'] != true)
{
	echo '<script type="text/javascript">
	<!--
	window.location.replace("index.php?page=Login");
	//-->
	</script>>';
}

$cms = new NapataFileCMS;
$cms->title = 'Admin';
$cms->SpecHeader();

?>
<h2>Checks</h2>
<div id="admin-table">
<table>
<tbody>
<tr>
<th>Check</th><th>Remarks</th><th>Results</th>
</tr>
<tr>
<td>
Is the articles folder present?
</td>
<td>
<?php

	if(!file_exists(DIRPATH."articles"))
		{
			echo "<img src='img/face-surprise-2.png' alt='surprised-face-warning' title='Some Problem!' /></td><td>The articles directory does not exist! Please recreate it.</td>";
			
		}
		else
		{
		
			echo "<img src='img/face-smile-big-3.png' alt='big-smile-correct' title='Yay! Everything is fine' /></td><td>The articles folder is present.</td>";
			
		}
	
?>
</td>
</tr>
<tr>
<td>
Is the articles folder writeable?
</td>
<td>
<?php
	
	if(!is_writeable(DIRPATH."articles"))
		{
		
			echo "<img src='img/face-surprise-2.png' alt='surprised-face-warning' title='Some Problem!' /></td><td> The articles directory is not writeable. Please chmod the file permissions to 0755 or 0775.</td>";
			
		}
		else
		{
		
			echo "<img src='img/face-smile-big-3.png' alt='big-smile-correct' title='Yay! Everything is fine' /></td><td> The articles directory is writeable.</td>";
			
		}
?>
</td>
</tr>
<tr>
<td>
What are the file permissions to the articles directory?
</td>
<td>
<?php
if(file_exists(DIRPATH."articles"))
{
	echo '<img src=\'img/applications-system-3.png\' alt=\'system-gear-fix-it\' title=\'Todo? Fix me!\'/></td><td> Directory permissions: '.substr(sprintf('%o', fileperms(DIRPATH.'articles')), -4).'.</td>';
}	
?>
</td>
</tr>
<tr>
<td>
Is the sec directory writeable?
</td>
<td>
<?php
	
	if(!is_writeable(DIRPATH."sec"))
	{
		
		echo "<img src='img/face-surprise-2.png' alt='surprised-face-warning' title='Some Problem!' /></td><td> The sec directory is not writeable. Please chmod the file permissions to 0755.</td>";
			
	}
	else
	{
		
		echo "<img src='img/face-smile-big-3.png' alt='big-smile-correct' title='Yay! Everything is fine' /></td><td> The sec directory is writeable.</td>";
			
	}
?>
</td>
</tr>
<tr>
<td>
What are the file permissions of the sec directory?
</td>
<td>
<?php
if(file_exists(DIRPATH."sec"))
{

	echo '<img src=\'img/applications-system-3.png\' alt=\'system-gear-fix-it\' title=\'Todo? Fix me!\'/></td><td> Directory permissions: '.substr(sprintf('%o', fileperms(DIRPATH.'sec')), -4).'.</td>';
	
}
?>
</td>
</tr>
<tr>
<td>
Is the PHP version you are using greater than 5.0.0?
</td>
<td>
<?php
if(version_compare(phpversion(), '5.0', '>'))
{

	echo '<img src=\'img/face-smile-big-3.png\' alt=\'big-smile-correct\' title=\'Yay! Everything is fine\' /></td><td> You are running PHP '. phpversion() .'. This is greater than the minimum requirements for running Napata Flat File CMS.</td>';
		
}
else
{
	
	echo '<img src=\'img/face-surprise-2.png\' alt=\'surprised-face-warning\' title=\'Some Problem!\' /></td><td> You are running PHP '. phpversion() .'. Napata Flat File CMS requires PHP 5.0 and above to run.';
		
}
?>
</td>
</tr>
<tr>
<td>
Is PHP's register globals on?
</td>
<td>
<?php

	if(ini_get("register globals") == 1)
	{
		
		echo "<img src='img/face-surprise-2.png' alt='surprised-face-warning' title='Some Problem!' /></td><td> Register globals is on. Please set it off (or contact your host to set it off) for security reasons.</td>";
			
	}
	else
	{
		
		echo "<img src='img/face-smile-big-3.png' alt='big-smile-correct' title='Yay! Everything is fine' /></td><td>SAFE: Register globals is set to 'off'.</td>";
			
	}
	
?>
</td>
</tr>
<tr>
<td>
Check for PHP Hash function....
</td>
<td>
<?php

	if(!function_exists("hash"))
	{

		echo "<img src='img/face-surprise-2.png' alt='surprised-face-warning' title='Some Problem!' /></td><td> It seems PHP's Hash function is not supported by this server. You cannot create hashes for your passwords.</td>";
			
	}
	else
	{
		
		echo "<img src='img/face-smile-big-3.png' alt='big-smile-correct' title='Yay! Everything is fine' /></td><td>PHP's Hash functions found!</td>";
			
	}
?>
</td>
</tr>
</tbody>
</table>
</div>
</div><!-- Closes Content DIV -->
<div id="footer"><?php include_once("./footer.php"); echo footer($copyright);?></div>
</body>
</html>