This script will auto link any text file in table manners in selected directory, and auto link them. Great for website like Olga, lyrics and tabs
By : jiwang
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!
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More File Manipulation Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
Achieving true agility is a never-ending effort. We will showcase how you can become agile incrementally, a few practices at the time.Which practices should any agile team strive to adopt? What additional practices should you consider based on your needs to scale? Adopting practices are however made much easier with the right tool support. What about if your tools adapt to your practices? We will take a look at how the Jazz technology can be leveraged to make your process change the behavior of your tools. FREE! Go There Now!
|
|
|
|
WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies. FREE! Go There Now!
|
|
|
|
Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial version of IBM Rational Business Developer V7.1. Rational Business Developer offers rapid and simplified development of business applications and services through Enterprise Generation Language (EGL) tools, generating Java or mainframe solutions while shielding developers from technical complexities. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points. FREE! Go There Now!
|
|
|
|
Join this webcast to see how IBM Data Studio Developer and pureQuery can take the pain out of Java data access. uApplications developed using both Java and SQL have become a common requirement. Database connectivity using Java Database Connectivity (JDBC) to create an application is a multi-step tedious process, and tooling that covers both SQL and Java has been unavailable, until now. IBM Data Studio introduces the pureQuery platform: a high-performance, Java data access platform focused on simplifying the tasks of developing, managing, and optimizing database applications and services. FREE! Go There Now!
|
|
|
|
This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product. FREE! Go There Now!
|
|
|
|
As systems increase in complexity, communication between systems and software teams becomes more and more difficult. Now, there’s a way to improve product quality and communication.<br />Read the “Model Driven Systems Development” white paper to see how. Also included in this kit are more educational white papers, customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems.<br /> FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity. FREE! Go There Now!
|
|
|
|
User communities play an important role in communication and collaboration around products, solutions and other areas of special interest to members. Successful communities are able to provide the right mix of content and services to deliver a value proposition that resonates with each audience. Join Tom Inman, VP of Marketing for Information and Platform Solutions as he introduces the new LeverageINFORMATION community. During this webcast, learn about the value provided by the community and how customers and partners derive value from the community in addressing their own technical and business challenges. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |