berserkpi Posted March 23, 2010 Share Posted March 23, 2010 Hi there, I'm new at php, but I got certain experience in other languages. I'm trying to implement security in one of my applications (not using any framework as zend). I'm just using plain HTML, CSS, jQuery, php 5.2 and Apache Server 2.2. Well here is the idea, I want my users can access a personal directory on the server and download their files when these are available. No user shall view other user's directory and files. So in one word, I need security in a per url/directory basis. I implemented this in Java using acegi (spring security). So my questions are: Is there a framework which implements security in this way? What php functions/libraries could be useful, in case I'd implement it by myself (from scratch)? Also, In case u share a code snippet I'd really appreciate it. Thanks for ur help guys. Link to comment https://forums.phpfreaks.com/topic/196293-php-in-a-per-urldirectory-basis/ Share on other sites More sharing options...
o3d Posted March 23, 2010 Share Posted March 23, 2010 Why not use .htaccess on each directory? You can write an admin page in php to manage users and groups and the htaccess files. Link to comment https://forums.phpfreaks.com/topic/196293-php-in-a-per-urldirectory-basis/#findComment-1030804 Share on other sites More sharing options...
berserkpi Posted March 23, 2010 Author Share Posted March 23, 2010 That sounds good, so, can I manage htaccess files form php? For instance, could I create a new user and his directory? An important thing here is that my app will be hosted in a third party server, the server uses cpanel. So, I'm not sure if I'll be able for creating htaccess file . Link to comment https://forums.phpfreaks.com/topic/196293-php-in-a-per-urldirectory-basis/#findComment-1030807 Share on other sites More sharing options...
teamatomic Posted March 23, 2010 Share Posted March 23, 2010 Depending on the type of file the user will have for download it may be as easy as using a skel folder and copying it over and giving it the users name. Included in it would be an index file that would display the users files available for download so all they have to do is right click and "save as" or similar depending on their browser. The index file would start of with: <?php session_start(); $user=$_SESSION['user']; $current = $_SERVER["SCRIPT_NAME"]; $fn = dirname($current); $fn=ltrim($fn,"/"); if($fn != $user){header("Location: $url/index.php");} HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/196293-php-in-a-per-urldirectory-basis/#findComment-1030824 Share on other sites More sharing options...
berserkpi Posted March 24, 2010 Author Share Posted March 24, 2010 That was an easy one, thank you. By the way, is there another instruction for redirecting to another php/html file? Link to comment https://forums.phpfreaks.com/topic/196293-php-in-a-per-urldirectory-basis/#findComment-1031182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.