RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Secure Internet File-Sharing with PHP, MySQL, and JavaScript : Page 5

Use PHP to create a secure Internet file-sharing application that employs a database abstraction layer and separates HTML design from PHP programming.

overLIB and Pop-Up Menus
The workflow process can be too long sometimes if PHP code has to process every action on the server side. JavaScript pop-ups are a solution for shortening the interactions a little bit, but inserting JavaScript in a configuration can produce unacceptable entropy and significantly decrease the separation between business and template logic. Smarty embeds a very useful and powerful JavaScript library called overLIB. According to its website, overLIB "is a JavaScript library created to enhance websites with small popup information boxes."

Smarty integrates overLIB with a very simple construction, {popup ... }. In the file inc.file_list.tpl, there is an example of overLIB use:

{include file='files.pop.tpl' assign='filePop'}
<a href="{$smarty.server.PHP_SELF}?id={$file.id}&not_crypted=1" 

In this code snippet, you see how you can attach an overLIB pop-up with a single instruction. You can set up all the overLIB parameters listed here and separate HTML code for pop-up in an another file, files.pop.tpl.

Beautify Your PHP Code
It is normally difficult to set a right indentation or good spacing rules during coding, and PEAR PHP_Beautifier can help a lot. Install it as follows:

pear install PHP_Beautifier

Then run this on the command line:

php_beautifier [some_file].php --output new_file.php

The new_file.php file produced will be rearranged with great improvement in readability.

Furthermore, PEAR provides a set of coding standards. With the mechanism of filters, for example, you can format your code accordingly by running this:

php_beautifier --filters "Pear()" [some_file].php --output new_file.php

Because HTML and CSS coding are not my strengths (you may have guessed that already), I looked for a method to separate presentation from logic in a small Internet file-sharing application so I could easily delegate the presentation to an experienced graphic designer. The result was a practical example of using a database abstraction layer and separating HTML design from PHP programming using open source libraries and frameworks. You can leverage my example to create an Internet file-sharing application that lets your users securely share files and classify them with tags and metadata.

Roberto Giorgetti is an IT manager and technical writer based in Italy. He is mainly interested in open source exploitation in business and industrial areas. Roberto holds a degree in Nuclear Engineering.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date