You will need two files linker.php and disp.php
The reason i created this script is that i have over 300
tabs and lyrics in text format. It would be silly and time consuming to link it all. Try it out.
linker.php ( this page is to autolink textfiles in your directory)
-------------
<table border="1" bordercolor="#000000" align="center" WIDTH="75%"><tr
bgcolor="#999999"><td><font
color="#000000">Name</font></td><td><font color="#000000">Size</font></td></tr>
<?php
exec("ls -la $dir",$lines,$rc);
$count = count($lines) - 1;
for ($i = 1; $i <= $count; $i++) {
$type = substr($lines[$i],0,1);
$name = strrchr($lines[$i]," ");
$name = substr($name,1);
$dire = substr($lines[$i],0,strpos($lines[$i],$name));
// echo "$dire</font>"; //
if ($type == "d") {
if ($name == "." or $name == "..") {
;
} else {
if ($dir == "") {
$size=filesize($name);
echo "<tr bgcolor="#999999"><td><a href="$name">$name</a></td><td>$size</td></tr>";
} else {
$size=filesize($name);
echo "<tr bgcolor="#DDDDDD"><td><a href=$dir/disp?i=$name>$name</a></td><td>$size</td></tr>";
}
}
} else {
if ($dir == "") {
$size=filesize($name);
echo "<tr bgcolor="#999999"><td><a href=disp.php?i=$name>$name</a></td><td>$size</td></tr>";
} else {
echo "<tr bgcolor="#DDDDDD"><td><a href=$dir/?i=$name>$name</a></td></tr>";
}
}
}
?>
</table><br>
disp.php (this page is to display the textfiles in tableized manner)
-----------------
<?php
$text_dir="/usr/home/jiwang/public_html/test"; //the file path of your textfile $text_url="http://www.jiwang.org/test"; //this is the url of your directory
//change this below if you so desire... ?>
<center><table BORDER CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="75%" BGCOLOR="#999999"
bordercolor="#000000">
<tr>
<td><pre>
<?php
//of course you can add errors to this script. this will display them...
function error($what) {
echo "<u>doc error...</u><p>n";
echo $what;
exit;
}
if(!$i) {
echo "<title>docs</title>n</head><table><form action=$PHP_SELF><tr><td valign=top>docs: <input type=text name=i></td><td valign=top><input type=submit value=submit></form></td></tr></table>n";
exit;
}
else {$i=addslashes($i); echo "<title>documents - $i</title>n</head>n";}
$file=$text_dir."/".$i; $url=$text_url."/".$i;
if(is_file($file)) {
include ("$file");
}
else {error('file does not exist');}
?>
</pre>
</td>
</tr>
</table></center>
------------------------
YOu can include linker.php in disp.php to include the menu.
YOu can also call the text file manually
http://yourdomain.com/text/disp.php?i=file.txt
Good luck!
|
|