Home arrow PHP arrow Page 12 - Cracking The Vault (part 1)

The D Word - PHP

Electronic documents are all well and good - but when you work onthem collaboratively, they can end up being more difficult to handle thanordinary pieces of paper. Multiple versions, competing standards, accesspermissions and revision history tracking are just some of the issues thatarise in a paperless office. This article discusses building and deployinga document management system across your network - and also teachesbeginnners a little bit about designing Web-based applications with PHP andmySQL in the process.

  1. Cracking The Vault (part 1)
  2. Just Another Day At The Office
  3. An Evil Plan Is Born
  4. Setting The Ground Rules
  5. Design Time
  6. Start Me Up
  7. Entry Points
  8. Seeding The System
  9. Red And Green Clouds
  10. Digging Deeper
  11. Basic Maintenance
  12. The D Word
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 2
May 14, 2001

print this article


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.

>>> More PHP Articles          >>> More By Vikram Vaswani, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: