<?php
/**
 * All script from here are under the GNU GPL
 *
 * Quick writed in order to display all my projects files.
 *
 * Any question : Sulphur.Eagle@gmail.com
 */

//Path prevent
require_once("fonc.php");

//Session
session_start();
session_name("file_explorator_projectf");

//Select the folder to explode
if(!isset($_SESSION['rep']))
	$_SESSION['rep'] = './';
//Selecte moving folder
if(!isset($_GET['fold']))
	$_GET['fold'] = "./";

//+------------------------------------------------------------+
//| Check the path (someone can try to change $_SESSION['rep'] |
//+------------------------------------------------------------+
//Check path
$path = path_prevent($_SESSION['rep'].$_GET['fold'], "dir");

//If it's a valid path
if($path)
{
	//Change to valid folder
	$_SESSION['rep'] = $path;
}
//Someone made a mistake
else
	$_SESSION['rep'] = "./";
//Xml
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
	<head>
		<meta http-equiv="Content-Type" content="application/xhtml+xml" />
		<link rel="stylesheet" type="text/css" href="../style.css" media="screen" />
		<title>Page de test de l'installation d'Apache</title>
	</head>
	<body class="explode">
		<h1>Explorateur de fichier</h1>
		<hr />
		<h2>PHP 5 :</h2>
		<p>Server : <?php echo $_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT']; ?></p>
		<p>Administrator : <?php echo $_SERVER['SERVER_ADMIN']; ?></p>
		<p>Script : <?php echo $_SERVER['PHP_SELF']; ?></p>
		<hr />
		<h2>Local folders : <?php echo $_SESSION['rep']; ?></h2>
		<table>
			<tr>
				<th> Directory : </th>
				<th> Elements : </th>
				<th> Date : </th>
				<th> Action : </th>
			</tr>
			<?php
			$class_mod = false;
			$dir = @opendir($_SESSION['rep']);
			if($dir)
				while($file = readdir($dir))
					if(($file != ".." || $_SESSION['rep'] != "./") && $file != "." && is_dir($_SESSION['rep'].$file))
					{
						$class_mod = !$class_mod;
						if($class_mod)
							$class="line1";
						else
							$class="line2";
						echo "<tr class=\"".$class."\">";
						echo "<td><a href=\"".$_SESSION['rep'].$file."\">".$file."</a></td>";

						$NbFS = 0;
						$_dir = @opendir($_SESSION['rep'].$file);
						while($f = readdir($_dir))
							if($f != ".." && $f != ".")
								$NbFS++;
						echo "<td>".$NbFS."</td>";
						echo "<td>".date("d-m-Y H:i:s",filemtime($_SESSION['rep'].$file))."</td>";
						echo "<td><a href=\"index.php?fold=".$file."\">Open</a></td>";
						echo "</tr>";
					}
			?>
		</table>
		<hr />
		<h2>Local files : <?php echo $_SESSION['rep']; ?></h2>
		<table>
			<tr>
				<th> File : </th>
				<th> Size : </th>
				<th> Date : </th>
				<th> Action : </th>
			</tr>
			<?php
			$class_mod = 0;
			$dir = @opendir($_SESSION['rep']);
			if($dir)
				while($file = readdir($dir))
					if($file != ".." && $file != "." && !is_dir($_SESSION['rep'].$file))
					{
						$class_mod = !$class_mod;
						if($class_mod)
							$class="line1";
						else
							$class="line2";
						echo "<tr class=\"".$class."\">";
						echo "<td><a href=\"".$_SESSION['rep'].$file."\">".$file."</a></td>";
						echo "<td>".filesize($_SESSION['rep'].$file)."</td>";
						echo "<td>".date("d-m-Y H:i:s",filemtime($_SESSION['rep'].$file))."</td>";
						echo "<td>";
						echo "<a href=\"".dirname($_SERVER['PHP_SELF'])."/download.php?path=".$_SESSION['rep'].$file."\">Download</a>";
						echo " | ";
						echo "<a href=\"".dirname($_SERVER['PHP_SELF'])."/display.php?path=" .$_SESSION['rep'].$file."\">Display</a>";
						echo "</td>";
						echo "</tr>";
					}
			?>
		</table>
		<hr />
		<h2>Informations légales :</h2>
		<p class="info">
			La totalité des documents présent dans ce répertoire on pour auteur moi
			même, auteur de cette page. Elles sont toute sous licence
			<a href="http://www.gnu.org/licenses/gpl.html">GPL</a>
			/
			<a href="http://www.gnu.org/licenses/lgpl.html">LGPL</a>
			(dans le cas où aucune licence est explicitement mentionner, vous pouvez
			considérer l'une des deux.)
		</p>
		<p class="info">
			Nombre de ces bouts de code on été réaliser il y a plusieurs années,
			aussi il est fort probable que vous trouviez dans certains des erreurs,
			diverses failles de sécurité plus ou moins importante.
		</p>
		<p class="info">
			Ces portions de code sont uniquement là à titre informatif. Vous pouvez
			tout à fait vous en inspirer pour vos divers projet, open ou closed
			source. Notez toute fois que la réutilisation du code, même après
			modification, est soumise aux conditions de la/les licenses.
		</p>
		<p class="info">
			Parfois, certaines portions de code sont signer JC ou JC_Master.<br/>
			Il s'agit d'un alias.
		</p>
		<p class="info">
			Pour toute question, demande d'information, ou correction, vous pouvez me contacter
			à Sulphur.Eagle@gmail.com
		</p>
		<p class="info">
			Je vous souhaite une bonne visite.<br/>
			S.E.
		</p>
		<hr />
		<p class="info">
		Dernière mise à jours : 28/02/2008
		</p>
		<hr />
		<p>
			<a href="http://validator.w3.org/check?uri=referer">
				<img src="http://www.w3.org/Icons/valid-xhtml11-blue"
        alt="Valid XHTML 1.1" height="31" width="88" />
			</a>
		</p>
	</body>
</html>
