Jump to content

php in a per url/directory basis.


berserkpi

Recommended Posts

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

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

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.