Short PHP script to get and display files

In Progress Posted Nov 30, 2013 Paid on delivery
In Progress Paid on delivery

Hello,

I am looking for someone who could write a small PHP 5 script for me to get and display files hosted on my server.

I am running a dedicated LAMP server.

On the one hand I have a directory containing different websites, like:

/home/www/myproject/sites/site1/

/home/www/myproject/sites/site2/

/home/www/myproject/sites/site3/

etc.

The contents of these folders is NOT visible from the web.

On the other hand, I have a page like

/home/www/myproject/sites/[login to view URL]

which IS visible from the web.

I would need a PHP script I could call from my [login to view URL] page to get and display the contents of any file from my "sites" directoty, exactly as it would appear as if it would have directly been accessed from the web.

For example, if:

$path = "/home/www/myproject/sites/site2/folder1/[login to view URL]",

the script running from my [login to view URL] file should return the contents of [login to view URL] contained in "folder1" from "site2" exactly as if the file would have been accessed from the web (browser).

I have tried doing this with function "readfile($path)" but I did not achieve a satisfactory result.

The script should:

- Return to the browser the appropriate HTTP headers, depending on the file type

- Be safe, especially with regards to code injection (So the contents of the retrieved files can't be a sefety risk)

- Be stable and efficient (It should be able to handle any hosted file, including large files).

Can anyone do that for me? It should only be a few lines of code!

Thanks

Right, thank you for all your replies, but let me clarify my request:

1) I do speak french as well, so you may reply in french.

2) I guess this is a pretty simple job for anyone fluent int PHP. If you are fluent in PHP this should be done in a matter of minutes, and definitely within less than an hour, so don't come with $150 quotes, you are just loosing your time and mine.

3) If you are still interested in this job, here are a few more details:

In fact I have set Apache to forward any HTTP request to my index.php file, so that:

www.site1.com
www.site2.com
www.site3.com
etc.

all go to my index.php file.

Now, I need my index.php file to get and output the files, just as they would have been served from Apache.

I.e. a request to http://www.site2.com/folder1/file2.php should get the file located at /home/www/myproject/sites/site2/folder1/file2.php.and outupt it just as if it would actually be located at http://www.site2.com/folder1/file2.php.

I already have the code to identify the requested host and path, but I miss the part to actually get the requested file and serve it in the browser with the propper HTML headers etc.

4) This is a tiny part of a much larger project, if you can help me on this for a realistic price, chances are that I will get back to you for other similatr jobs...

PHP Software Architecture

Project ID: #5183260

About the project

16 proposals Remote project Active Dec 2, 2013

16 freelancers are bidding on average $130 for this job

gyaseen1986

Hi there, I have over 7 years experience working on HTML, Wordpress, Magento, Database administration, OpenCart, Website Design, Logo / Banner Design Joomla, CSS and Linux Administration. I have read the project descri More

$159 USD in 1 day
(939 Reviews)
8.7
toinnisfree

I have read your project details, and I am interested in offering my services. I provide 100% satisfaction guaranteed on all my work. Milestone is required to begin; to be released when the job has been satisfactor More

$185 USD in 3 days
(767 Reviews)
8.3
tlchung

skilled php developer here, have done over 500+ php project for my clients, i can do the task for you, let start now.

$84 USD in 2 days
(449 Reviews)
7.4
Meagan26

Hello, I have read through your project and I am incredibly interested in taking on your project. I am an experienced developer with a diploma in the field of web develment. I have been working in the field of web d More

$257 USD in 3 days
(229 Reviews)
7.4
sunilexpert

I am an expert web developer with 8+ years of developing dynamic web applications and websites. I have experience in PHP, MySQL, Ajax, Javascript etc. You can see feedback against my profile they are always awes More

$94 USD in 2 days
(73 Reviews)
6.0
tanveerjavaid

Hi I am experienced programmer and let me do it right away.. please feel free to ask any question. thanks

$79 USD in 3 days
(49 Reviews)
6.2
mbenchekroun

HEllo, I'm ready to have it done for you within the next hours (2-4). You can check my feedbacks for more information. I might need acccess to the server to check users rtights (www-data) specially. regards More

$105 USD in 0 days
(27 Reviews)
5.7
prasy8

Hi there, Our preferred technology: PHP/Mysql, JavaScript, AJAX Let us discuss about the project in detail. Ready to start asap. Let me know if you have any questions. Thanks, prasy

$111 USD in 1 day
(18 Reviews)
5.4
phpopensource

A proposal has not yet been provided

$222 USD in 4 days
(50 Reviews)
4.9
sunsriinfosys

Hi, I have over 13 years of Experience in software design, development and implementation of various commercial applications in Client/Server environment, Web and ERP applications using C# 1.1/2.0/3.5, ASP.Net, VB.N More

$111 USD in 2 days
(18 Reviews)
4.3
saunghikmah

I have good experience in develop web-based applications, I will complete your project with the best results as your requested, just trust me to handle your projects.

$111 USD in 10 days
(0 Reviews)
0.0
dus3d

I can do this for you easily, hence the low bid amount. I have done many similar projects in the past.

$45 USD in 1 day
(0 Reviews)
0.0