Re: How to use fopen() with protected directory (i.e .htaccess)

From: Date: Tue, 11 Feb 2003 09:04:45 +0000
Subject: Re: How to use fopen() with protected directory (i.e .htaccess)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-135170@lists.php.net to get a copy of this message
At 06:22 11.02.2003, Daevid Vincent said: --------------------[snip]-------------------- >How can I pass in a user/pw to an fopen() (or something similar)? You don't. fopen() doesn't access the server via HTTP. It's PHP that executes this call, sitting at the server, using the servers file system (except when opening a remote site, but that's a different story). If you are allowed (by means of opsys rights and PHP admin limits, such as safe_mode) to open the file it will be opened for you, even if it is not within the virtual web server directory tree. >I am trying to render a dynamic db/php page into a static .html page -- >or more specifically, I'm trying to email me back an html version of a >report page on remote servers. The reports are located behind an >https:// Apache user/pass authenticated directory. > >I tried: >$file = >fopen("https://username:password@www.myserver.com/admin/report.php","r"); > You can't open a remote SSL location using fopen(). Have a look at cUrl to accomplish this. >If I try to do something like: >$file = fopen("/www/htdocs/admin/report.php","r"); > >But then the PHP isn't executed, it just dumps me the straight source >code. If you can open and read the report, there's only one more step to execute it: use eval(): $fname = "/www/htdocs/admin/report.php" $file = fopen($fname,"r"); if ($file) { $code = fread($file, filesize($fname)); fclose($file); @eval($code); } else die "Can't open file $fname\n"; -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#135170) next »