• Any version of MySQL from the last few years will do. This was writtenusing MySQL V4.1.15.You'll also need a database and database user ready for your application to use.The tutorial will provide syntax for creating any necessary tables in MySQL.Additionally, to save time, we will be developing Criki using a PHP framework calledCakePHP. Download CakePHP by visitingCakeForge.organd downloading thelatest stable version. This tutorial was written using V1.1.13. For information aboutinstalling and configuring CakePHP, check out the tutorial series titled "Cook up Websites fast with CakePHP" (seeResources).In addition, you may find it helpful to download and installphpMyAdmin, abrowser-based administration console for your MySQL Database.
Section 2. Criki so far
At the end ofPart 3, you were given a few things to work on. You needed to add
accesscControl
to uploaded files. There was some cleanup work to be done inthe controllers and the views. You should have experimented with using accesschecks to display or hide links and content. There were a couple problems with theaccess control system to be worked out. And you never defined any wiki markup forlinking up uploaded files. How did you do?
Uploaded file access control
Defining permissions and access controls for file uploads should look much like it didfor entries. In the uploads controller, you want to add code to the fetch action toverify the user's access level before serving the file.
Listing 1. Access control in the uploads fetch action
...$upload = $this->Upload->read(null, $id);if ($upload) {$user = $this->Session->read('User');$user = $this->Upload->User->read(null, $user['id']);if ($user['User']['access'] < $upload['Upload']['access']) {$this->Session->setFlash('Access Denied.');$this->redirect('/uploads/index');exit;}header('Content-Type: application/octet-stream');...
You also need some promote/demote code added to the uploads controller to allowthe user to protect the files. The promote and demote actions look almost identical to
Add a Comment
akhil406left a comment