PHP
  Home arrow PHP arrow Page 12 - Cracking The Vault (part 1)
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
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? 
PHP

Cracking The Vault (part 1)
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2001-05-14

    Table of Contents:
  • Cracking The Vault (part 1)
  • Just Another Day At The Office
  • An Evil Plan Is Born
  • Setting The Ground Rules
  • Design Time
  • Start Me Up
  • Entry Points
  • Seeding The System
  • Red And Green Clouds
  • Digging Deeper
  • Basic Maintenance
  • The D Word

  • 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


    Cracking The Vault (part 1) - The D Word


    (Page 12 of 12 )

    Finally, we come to "delete.php", which takes care of removing a document from the file system and the database.

    <? // checks and includes // query to ensure that the logged-in user is the owner of this file and the file is not checked out $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); $query = "SELECT status FROM data WHERE id = '$id' AND owner = '$SESSION_UID' AND status = '0'"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); // error check // all ok, proceed! mysql_free_result($result); // delete from db $query = "DELETE FROM data WHERE id = '$id'"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); $query = "DELETE FROM perms WHERE fid = '$id'"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); $query = "DELETE FROM log WHERE id = '$id'"; $result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error()); // delete from directory $filename = $id . ".dat"; unlink($dataDir . $filename); // clean up and back to main page mysql_close($connection); $message = "Document successfully deleted"; header("Location: out.php?message=$message"); ?>

    Nothing too complex here - verify that the file can be deleted, DELETE all records containing the file ID from the various tables, delete the file (this will fail if your Web server doesn't have the right permissions) and go back to the main page.

    At this point, I've built the foundation for the system, although I have not yet addressed the scripts which actually take care of checking documents in and out. That, together with an explanation of how I plan to implement the revision history mechanism and the search feature, will be addressed in the second part of this article. Download the code, play with it, send me your thoughts/flames/savings...and come back next time for more!

    This article copyright Melonfire 2001. All rights reserved.
    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.

     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway