File Manipulation Code

  Home arrow File Manipulation Code arrow Document Auto Linker And Display
FILE MANIPULATION CODE

Document Auto Linker And Display
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-01-18

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    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

    blog comments powered by Disqus

    FILE MANIPULATION CODE ARTICLES

    - Bandwidth Control with pure PHP
    - Eazy Gallery
    - file_get_contents for PHP < 4.3.0
    - PHP Class: Image Snapshot 1.3
    - Universal downloader
    - Image Gallery v2.0
    - Free/Used Disk Space
    - Directory Lister
    - Directory image view, with selective hidden
    - Move or Copy a Directory (and files and sub ...
    - Ensure_Sub_Directory_Exists
    - Wedit
    - Form Examples Text Boxes to Drop Downs
    - myFiles
    - List files in a directory, no subdirectories


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap