PHP: Download unparsed .PHP files?

LeetestUnleet

Senior member
Aug 16, 2002
680
0
0
So I'm working on a project that basically needs to download a cloned copy of some PHP source files in a directory. I *could* rename the extensions on the server side then rename them on the client side, but that seems highly inefficient.

I was thinking I could use an SSH socket within PHP and send commands that way, but I have no idea how to go about working out that communication. I notice that fopen() can support SSH wrappers with an extension, but we're running the client on standalone Windows/Apache machines so we can't exactly recompile PHP.

Any thoughts?
 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
couldn't it be as simple as fopening the .php file and writing it's contents to the browser with a txt or .php mime type?
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Can't you use FTP?

Some alternatives:
a. Client grab using FTP
b. server package files into an archive (zip, tar) and send that as HTTP response
c. one script page sends another as a HTTP response, as text/plain

If you control both the client and server, FTP is probably easiest and programs like CuteFTP allow setting up batch jobs.
 

LeetestUnleet

Senior member
Aug 16, 2002
680
0
0
I have full control over the client and the server. Both are setup with Apache/PHP (the client is actually just running a simple xampp installation). As part of the synchronization process between the server and the client, the client clicks a link within one of its own pages, which connects to the server and pulls down the database and updated .php files located in the directory. So it needs to be done *within* PHP code. I'll look into the MIME headers and perhaps maybe an FTP connection later, though that doesn't mean I won't mind more suggestions
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: troytime
couldn't it be as simple as fopening the .php file and writing it's contents to the browser with a txt or .php mime type?
This makes the most sense to me as it looks pretty simple. Just have a page that takes other pages as an arg:
getcode.php?file=/some/other/script.php

Be careful of the myriad of security issues with that of course.

Like others have said too, if you can keep a differently packaged version of the source on the server, then you can download it via http without anything fancy on the server side. Eg. keep a copy of all the source in a tarball on the server or make a copy of each file, renamed to foo.php.txt.

Involving a second protocol, like ftp or scp seems needlessly complex, imho.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Yeah, just send the content by setting the mime type and headers. No need to make it overly complex like others have said.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |