Home arrow PHP arrow Page 3 - Cracking The Vault (part 2)

Room With A View - PHP

The first part of this article discussed the basic design andarchitecture for an intranet document management system. In this concludingpart, get to the good stuff with a discussion of the "check in" and "checkout" process, and add a simple search engine to the system.

TABLE OF CONTENTS:
  1. Cracking The Vault (part 2)
  2. Checking It Out
  3. Room With A View
  4. All Revved Up
  5. Looking For Something?
  6. Oops!
  7. Endgame
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 2
May 16, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
You'll remember that users also have the ability to view the most current version of a document, regardless of whether or not they can check it out.

<!-- from details.php --> <td align="center"><a href="view.php?id=<? echo $id; ?> "><img src="images/view.jpg" width=40 height=40 alt="" border="0"><br><font size="-1">View Document</font></a></td>

The manner in which this is handled is almost identical to the check-out process, except that this time, I'm calling "view.php" instead of "check-out.php". And "view.php" does the same thing as "check-out.php", initiating an immediate file download. However, since downloading a file for viewing should not render it inaccessible to other users, "view.php" does not UPDATE the database, leaving the file status field as is.

Here's "view.php".

<? // view.php - performs download without updating database // checks and includes // verify again that user has view rights $connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!"); $query = "SELECT id, realname FROM data, perms WHERE id = '$id' AND perms.rights = '1' AND perms.uid = '$SESSION_UID' AND perms.fid = data.id"; // all checks completed // form not yet submitted // display information on how to initiate download if (!$submit) { ?> <html> <head> <basefont face="Verdana"> </head> <body bgcolor="white"> <? include("menu.inc");?> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td bgcolor="#0000A0"> <b><font face="Arial" color="White">View Document</font></b> </td> </tr> </table> <p> <form action="<? echo $PHP_SELF?>" method="post"> <input type="hidden" name="id" value="<? echo $id; ?>"> <input type="submit" name="submit" value="Click here"> to begin downloading the selected document to your local workstation. </form> Once the document has completed downloading, you may <a href="out.php">continue browsing</a> The Vault. </body> </html> <? } // form submitted - begin download else { list($id, $realname) = mysql_fetch_row($result); mysql_free_result($result); // get the filename $filename = $dataDir . $id . ".dat"; // send headers to browser to initiate file download header ("Content-Type: application/octet-stream"); header ("Content-Disposition: attachment; filename=$realname"); readfile($filename); } } // clean up mysql_close($connection); ?>



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
   

PHP ARTICLES

- 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: