Page 1 of 1

Binary request To A Text File On HTTP Server

Posted: Thu Dec 07, 2006 9:46 am
by neel_basu
Hello Everybody
Can Anyone Please tell Me
How Can I Place A Binary Request To A Text File On A http Server Through php ?

Posted: Thu Dec 07, 2006 9:54 am
by Chris Corbyn
I'm not sure what you mean?

Posted: Thu Dec 07, 2006 9:57 am
by neel_basu
Suppose There Is A File Named file.php on a http server
if I Use fread To Read file.php File The It gets The HTML Thats Generated By The
php File
But If I Want The RAW php File How Can I Do It ??

Posted: Thu Dec 07, 2006 10:03 am
by John Cartwright
You won't be able to do it through a standard http request, unless you have some sort of script which serves files. If you wanted to use the file system functions to serve the file, they must reside on the same server as the file, or else the php will be parsed.

Otherwise, you can use http://php.net/ftp

p.s: how come you capitalize every word, it makes reading difficult :wink:

Posted: Thu Dec 07, 2006 10:13 am
by neel_basu
Then Arn't There Any Way To Copy A File From A Server To localhost
without a http Request ??

Posted: Thu Dec 07, 2006 10:21 am
by John Cartwright
neel_basu wrote:Then Arn't There Any Way To Copy A File From A Server To localhost
without a http Request ??
unless you configure apache to not run .php files through the php parser, no. If you could, this would be a massive security risk. You should consider using subversion if your wanting to synchronize your codebase among several machines.

Posted: Thu Dec 07, 2006 10:31 am
by neel_basu
I Have Heard That Hackers Can get The Raw php File From A Server
How They Do It ??

Posted: Thu Dec 07, 2006 10:35 am
by John Cartwright
there are tons of ways one might compromise a server, none of which I will publicly discuss.

Posted: Thu Dec 07, 2006 10:36 am
by onion2k
neel_basu wrote:I Have Heard That Hackers Can get The Raw php File From A Server
How They Do It ??
We won't be discussing that here, it's very naughty, even illegal in some countries.

Posted: Thu Dec 07, 2006 4:29 pm
by Chris Corbyn
Why not just use subversion or ftp? If this is your code I don't see why you can't do that. If it's not your code then it's suspicious at best.

Posted: Thu Dec 07, 2006 10:53 pm
by neel_basu
Whats subversion

Posted: Thu Dec 07, 2006 11:31 pm
by feyd
Google is amazing at finding things sometimes.

Posted: Fri Dec 08, 2006 12:02 am
by volka
I guess you want to build some sort of coding site with examples.
When you install the apache php module you (usually) add the line AddType application/x-httpd-php .php to httpd.conf telling the apache all files with the suffix .php are of the mime type application/x-httpd-php. The php module registered as handling this mime type, therefore apache lets php handle requests for .php files.
The module registers another type, application/x-httpd-php-source, see http://www.php.net/manual/en/install.unix.apache2.php step 15
Let's say you have the directory /home/www/htdocs/php_scripts containing all your example scripts. Now you can add an alias to httpd.conf and set .php to the mime type for source highlighting

Code: Select all

Alias /php_source /home/www/htdocs/php_scripts
<Location /php_source>
	AddType application/x-httpd-php-source .php
</Location>
While accessing the file via http://your.serv.er/php_scripts/test.php gets the script executed http://your.serv.er/php_source/test.php will print/highlight the same file.
Make sure you understand what this is all about before you try it on a "real" webserver.
see http://httpd.apache.org/docs/2.2/mod/qu ... rence.html