File Manipulation Code
  Home arrow File Manipulation Code arrow file.php
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FILE MANIPULATION CODE

file.php
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-01-18

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    This is a early version of a filesystem editor we wrote for our developers kit. It allows you do view a directory, create files, erase files, edit files, create directories, remove directories, and upload files from your browser directly into the directory.

    By : bleach

    <? session_register("GlimpseDir");
    if(!$GlimpseDir) $GlimpseDir="/";

    /* This software was written 2000 by Derek Young at GSData Design */
    /* Please Use some type of auth system for this file, if it got in the
    wrong hands, you could be seriously messed with. You can put it in
    a protected directory via .htaccess, or use your own auth system in
    php, either way, be carefull, I take no responsibility for any
    damages that this file causes. */

    /* Set this directory to the physical location on your filesystem for
    the document root. */

    $basedir="/usr/httpd/html/glimpse";

    function reloadnow() {
    global $PHP_SELF;
    global $addons;
    header("Status: 302 Moved");
    header("Location: $PHP_SELF".$addons);
    exit(); }

    if($cancel) $action="";
    if($action=="root") $GlimpseDir="/";
    if($action=="chdr") $GlimpseDir=$file."/";
    if($action=="dele" && $confirm==1) { unlink($basedir.$file); $action="";}
    if($action=="move" && $confirm && $newfile) {
    rename($basedir.$file,$basedir.$newfile); $action=""; }
    if($action=="rmdr") rmdir($basedir.$file);
    if($action=="edit" && $confirm && $file) {
    $fp=fopen($basedir.$file,"w");
    fputs($fp,stripslashes($code));
    fclose($fp);
    $addons="?action=edit&file=".rawurlencode($file);
    reloadnow(); }
    if($upload) { copy($userfile,$basedir.$GlimpseDir.$userfile_name);
    reloadnow(); }
    if($touch) { touch($basedir.$GlimpseDir.$touchfile); reloadnow(); }
    if($mkdir) { mkdir($basedir.$GlimpseDir.$mkdirfile,0700); reloadnow(); }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3c.org/TR/REC-html40/loose.dtd">
    <HTML>
    <HEAD>
    <TITLE>Filesystem Browser-Current Directory="<?=$GlimpseDir;?>"</TITLE>
    </HEAD>
    <BODY> <?

    if ($action=="dele") {
    echo "Are you sure you want to delete $file ?<BR>";
    echo "<A HREF=\"$PHP_SELF?action=dele&file=" . rawurlencode($file) . "&confirm=1\">YES</A><BR>";
    echo "<A HREF=\"$PHP_SELF\">NO</A><BR>";
    echo "</BODY></HTML>";
    exit(); }

    if ($action=="move") {
    echo "Current Filename is: ".$file . "<BR>\n";
    echo "<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">\n";
    echo "<INPUT TYPE=\"TEXT\" NAME=\"newfile\">Newfile Name<BR>\n";
    echo "<INPUT TYPE=\"SUBMIT\" NAME=\"confirm\" VALUE=\"Change\">\n";
    echo "<INPUT TYPE=\"SUBMIT\" NAME=\"cancel\" VALUE=\"Cancel\">\n";
    echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"move\">\n";
    echo "<INPUT TYPE=\"HIDDEN\" NAME=\"file\" VALUE=\"$file\">\n";
    echo "</FORM></BODY></HTML>";
    exit(); }

    if ($action=="edit") {
    echo "<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">\n";
    echo "Current Filename is: ".$file ." ";
    echo "<INPUT TYPE=\"HIDDEN\" NAME=\"file\" VALUE=\"$file\">\n";
    echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"edit\">\n";
    echo "<INPUT TYPE=\"SUBMIT\" NAME=\"confirm\" VALUE=\"Save\">\n";
    echo "<INPUT TYPE=\"SUBMIT\" NAME=\"cancel\" VALUE=\"Exit\"><BR>\n";
    $fp=fopen($basedir.$file,"r");
    $contents=fread($fp,filesize($basedir.$file));
    echo "<TEXTAREA NAME=\"code\" rows=\"20\" cols=\"80\">\n";
    echo htmlspecialchars($contents);
    echo "</TEXTAREA><BR>\n";

    echo "</FORM></BODY></HTML>";
    exit(); }

    ?>
    <A HREF="<?=$PHP_SELF;?>?action=root">Back to root</A><BR>

    <TABLE BORDER="1">
    <TR><TD>Filename</TD><TD>Type</TD><TD>Size</TD><TD>Action</TD></TR>
    <? $handle=opendir($basedir . $GlimpseDir);
    while($file = readdir($handle)) {
    if ($file != "." && $file != "..") {
    $filename=$basedir.$GlimpseDir.$file;
    $fileurl=rawurlencode($GlimpseDir.$file);
    echo "<TR>";
    echo "<TD>" . htmlspecialchars($file) . "</TD>\n";
    echo "<TD>" . filetype($filename) . "</TD>\n";
    echo "<TD>" . filesize($filename) . "</TD>\n";
    echo "<TD>";
    if(filetype($filename)=="file") {
    echo "<A HREF=\"$GlimpseDir$file\">View</A> ";
    echo "<A HREF=\"$PHP_SELF?action=edit&file=$fileurl\">Edit</A> ";
    echo "<A HREF=\"$PHP_SELF?action=dele&file=$fileurl\">Dele</A> ";
    echo "<A HREF=\"$PHP_SELF?action=move&file=$fileurl\">Move</A> ";
    } if(filetype($filename)=="dir") {
    echo "<A HREF=\"$PHP_SELF?action=chdr&file=$fileurl\">ChDr</A> ";
    echo "<A HREF=\"$PHP_SELF?action=rmdr&file=$fileurl\">RmDr</A> ";
    }
    echo "</TD>";
    echo "</TR>\n";
    }
    }
    closedir($handle);
    ?>
    </TABLE>

    <BR>
    <FORM ENCTYPE="multipart/form-data" METHOD="POST" ACTION="<?=$PHP_SELF;?>">
    <INPUT NAME="userfile" TYPE="file">
    <INPUT TYPE="SUBMIT" NAME="upload" VALUE="Upload"><BR>
    <INPUT TYPE="TEXT" NAME="touchfile">
    <INPUT TYPE="SUBMIT" NAME="touch" VALUE="Touch"><BR>
    <INPUT TYPE="TEXT" NAME="mkdirfile">
    <INPUT TYPE="SUBMIT" NAME="mkdir" VALUE="Mkdir"><BR>
    </FORM>

    </BODY>
    </HTML>
    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

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! The dirty dozen: preventing common application-level hack attacks

    As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications.
    FREE! Go There Now!


    NEW! Download DB2 9.5 for Linux, Unix, and Windows

    Download a free trial version of IBM DB2 9.5 for Linux, UNIX, and Windows. DB2 9 is the result of a five-year development project that transformed traditional (static) database technology into an interactive data server that merges the high performance and ease of use of DB2 with the self-describing benefits of XML.
    FREE! Go There Now!


    NEW! Rational Modeling Extension for Microsoft.Net

    Rational Modeling Extension for Microsoft .NET enhances usability for code generation supporting a more intelligent refactoring. The latest enhancements enable organizations with Java and .NET systems and software development maintain architectural integrity across heterogeneous platforms.
    FREE! Go There Now!


    NEW! Hello World: Learn how to install and use the Rational Asset Manager Eclipse client

    In this tutorial, you can learn how to install and configure the IBM Rational Asset Manager Eclipse client, explore the different views in the Asset Management perspective, learn various search techniques, work with existing assets, and submit a new asset.
    FREE! Go There Now!


    NEW! Addressing software-as-a-service challenges using Tivoli security and WebSphere solutions

    Building a software-as-a-service solution requires addressing a few key technical challenges. In this webcast, we'll focus on the role of IBM Tivoli Directory Server and WebSphere Portlet Factory in creating a Software as a Service solution. We will demonstrate how to use Tivoli Directory Server to prevent the user population of one tenant from accessing the virtual portal and portlet components of another tenant. We will also use the dynamic profile capability of WebSphere Portlet Factory to create multiple highly customized applications from one code base.
    FREE! Go There Now!


    NEW! IBM Rational Systems Development e-Kit

    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!


    Role of Integrated Requirements Management in Software Delivery

    As organizations integrate software into every aspect of business, they are constantly pressured to deliver faster, better, and cheaper results. Unfortunately, a “dis-integrated” software delivery approach reduces returns while increasing costs. This IBM Rational White Paper shows how Integrated Requirements Management aligns organizations around maximizing value and keeping pace with change.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Method Composer V7.2

    Get a free trial download of the latest version of IBM Rational Method Composer V7.2 which helps you deliver customized yet consistent process guidance to your project teams and IT organization, and includes the latest version of IBM Rational Unified Process (RUP), which has provided process guidance to teams since 1996.
    FREE! Go There Now!


    NEW! Hello World: WebSphere Service Registry and Repository

    Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services.
    FREE! Go There Now!


    NEW! IBM Enterprise Modernization Sandbox for System z

    IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    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-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek