<?php
########################################
#This  comes with absolutley NO WARRENTY and I assume NO RESPONSABILITY if this does any damage to any #system running it.
#
#This code is released under gnu.
#
#By [NICK] http://www.linickx.com
#
#Further info about this project/code might be avilable at http://www.linickx.com
#
####################################
#
#Copyright: 2005
#
#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; either version 2 of the License, or 
#(at your option) any later version
#
#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 with
#this program.  If not, write to the Free Software Foundation, Inc., 675
#Mass Ave, Cambridge, MA 02139, USA.
#
# or http://www.linickx.com (I will always keep a copy there !)
#########################################################################

# This file was also ripped off another poject I have done ;-) notice the arry name mpeg ??!?!?!

# Where do we submit stuff ?
$self=$_SERVER["PHP_SELF"];

$mpeg=$_POST['mpeg'];
$path=$_POST['path'];
$lines=$_POST['lines'];


echo "<h2>Current Path: $path</h2>";
?>
<form enctype="multipart/form-data" action="<?php echo "$self"; ?>" method="POST" >
<?php

foreach ($mpeg as $files) {

	?><input type=hidden name="mpeg[]" value="<?php echo $files;?>" /><?php
	
	echo "<h2>Current File: $files</h2>";

	# Fix spaces for dir traversal
	$files = str_replace(" ", "\ ", $files);
	# Read in file
	$text = file("$path$files");
	$numberoflines = count($text);

	if ($lines == "ALL") {
		# Print the while array ;-)
		foreach ($text as $line_num => $line) {
 					echo "$line<br>";
				}
	} elseif ( $lines == "") {
		# Set our Start Line ;-)
		$firstline = ($numberoflines - 10);
		# & Print from there onwards.
		for($n=$firstline; $n<$numberoflines; $n++)
		  echo "$text[$n]<br>";
			

	} else {
		# Set our Start Line ;-)
		$firstline = ($numberoflines - $lines);
		# & Print from there onwards.
		for($n=$firstline; $n<$numberoflines; $n++)
		  echo "$text[$n]<br>";
	}

}


?>
<input type=hidden name="path" value="<?php echo "$path"; ?>" />
<select name="lines" size=1>
<option value=10>10</option>
<option value=20>20</option>>
<option value=50>50</option>
<option value=100>100</option>
<option value=200>200</option>
<option value=500>500</option>
<option value=ALL>ALL</option>
</select>

<input type="submit" value="Refresh"> 
</form>

