Re: [PHP] fopen and load balancing

2013-02-12 Thread ma...@behnke.biz


Adam Tong adam.to...@gmail.com hat am 11. Februar 2013 um 16:11 geschrieben:
 I think this is what happened. As the application was trying to open
 our url domain the request was sent to the load balancer, and as it
 does not accept internal requests, the connection was timed out.

 The only way we could avoid that is to not use fopen our url, is that right?

You know the thing is: LoadBalancers are to balance the load from outside not
the other way around. If you need to make server requests, use the internal
server name. But accessing the file directly is much smarter and faster.




 On Mon, Feb 11, 2013 at 4:26 AM, ma...@behnke.biz ma...@behnke.biz wrote:
 
 
  Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41
  geschrieben:
  Hi,
 
  We had an issue with the code of a junior php developer that used
  fopen to load images using the url of the companies website that is
  load balanced.
 
  We could not the detect the problem in dev and test because the dev
  and test servers are not load balanced.
 
  I know that he could load the images using just the filesystem, but I
  am curious to know why it failed and if the load balancer is really
  the source of the problem or it is a limitation on the function
  itself.
 
  Do you have any error messages for us?
  If the load balancer accessable from the internal servers? Normally it is
  not.
 
 
 
  Thank you
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  --
  Marco Behnke
  Dipl. Informatiker (FH), SAE Audio Engineer Diploma
  Zend Certified Engineer PHP 5.3
 
  Tel.: 0174 / 9722336
  e-Mail: ma...@behnke.biz
 
  Softwaretechnik Behnke
  Heinrich-Heine-Str. 7D
  21218 Seevetal
 
  http://www.behnke.biz
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and load balancing

2013-02-11 Thread ma...@behnke.biz


Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41 geschrieben:
 Hi,

 We had an issue with the code of a junior php developer that used
 fopen to load images using the url of the companies website that is
 load balanced.

 We could not the detect the problem in dev and test because the dev
 and test servers are not load balanced.

 I know that he could load the images using just the filesystem, but I
 am curious to know why it failed and if the load balancer is really
 the source of the problem or it is a limitation on the function
 itself.

Do you have any error messages for us?
If the load balancer accessable from the internal servers? Normally it is not.



 Thank you

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and load balancing

2013-02-11 Thread Adam Tong
I think this is what happened. As the application was trying to open
our url domain the request was sent to the load balancer, and as it
does not accept internal requests, the connection was timed out.

The only way we could avoid that is to not use fopen our url, is that right?


On Mon, Feb 11, 2013 at 4:26 AM, ma...@behnke.biz ma...@behnke.biz wrote:


 Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41 geschrieben:
 Hi,

 We had an issue with the code of a junior php developer that used
 fopen to load images using the url of the companies website that is
 load balanced.

 We could not the detect the problem in dev and test because the dev
 and test servers are not load balanced.

 I know that he could load the images using just the filesystem, but I
 am curious to know why it failed and if the load balancer is really
 the source of the problem or it is a limitation on the function
 itself.

 Do you have any error messages for us?
 If the load balancer accessable from the internal servers? Normally it is not.



 Thank you

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 --
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3

 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz

 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal

 http://www.behnke.biz

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and load balancing

2013-02-11 Thread Sean Greenslade
On Mon, Feb 11, 2013 at 10:11 AM, Adam Tong adam.to...@gmail.com wrote:
 On Mon, Feb 11, 2013 at 4:26 AM, ma...@behnke.biz ma...@behnke.biz
 wrote:
 
 
  Adam Tong adam.to...@gmail.com hat am 10. Februar 2013 um 23:41
  geschrieben:
  Hi,
 
  We had an issue with the code of a junior php developer that used
  fopen to load images using the url of the companies website that is
  load balanced.
 
  We could not the detect the problem in dev and test because the dev
  and test servers are not load balanced.
 
  I know that he could load the images using just the filesystem, but I
  am curious to know why it failed and if the load balancer is really
  the source of the problem or it is a limitation on the function
  itself.
 
  Do you have any error messages for us?
  If the load balancer accessable from the internal servers? Normally it
  is not.


 I think this is what happened. As the application was trying to open
 our url domain the request was sent to the load balancer, and as it
 does not accept internal requests, the connection was timed out.

 The only way we could avoid that is to not use fopen our url, is that
 right?



Yeah, sure. That's as good of a guess as any of us will be able to
conjure up. Since you've given us no details, no code and no error
messages, we're basically relegated to blind guessing. I don't think
that's what you want, so if you still have a question, I suggest you
start by investigating the relevant logs. If you can't figure out the
issue from there, post _relevant_ snippets to the list.

Also remember that this is the PHP mailing list. (Even though we tend
to masquerade as the MySQL list from time to time) If it's an issue
with your very likely non-PHP load balancer, we can't really help you
out.

--Sean Greenslade

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and load balancing

2013-02-10 Thread Adam Richardson
On Sun, Feb 10, 2013 at 5:41 PM, Adam Tong adam.to...@gmail.com wrote:

 Hi,

 We had an issue with the code of a junior php developer that used
 fopen to load images using the url of the companies website that is
 load balanced.

 We could not the detect the problem in dev and test because the dev
 and test servers are not load balanced.

 I know that he could load the images using just the filesystem, but I
 am curious to know why it failed and if the load balancer is really
 the source of the problem or it is a limitation on the function
 itself.

 Thank you

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


I'm not sure it sounds like an issue with the load balancer, as a load
balancer shouldn't have any qualm with passing through the image data
associated with an http request (which is what the fopen wrapper
essentially performs behind the scenes.) It's possible that the prod
servers (those making the call to fopen) aren't configured to allow the
http wrapper. It could just be as simple as allow_url_fopen being set to
false, in contrast to the configuration of the dev server(s).

http://php.net/manual/en/function.fopen.php
http://php.net/manual/en/wrappers.php
http://www.php.net/manual/en/wrappers.http.php

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


RE: [PHP] fopen() on a network share?

2009-06-16 Thread jenai tomaka

Hi, wht dont you try it with IP, ex: 
fopen('http://11.12.13.14/sharename/folder/file.xml', 'w');

 Date: Mon, 15 Jun 2009 22:51:09 -0400
 From: aball...@gmail.com
 To: nos...@mckenzies.net
 CC: php-general@lists.php.net
 Subject: Re: [PHP] fopen() on a network share?
 
 On Mon, Jun 15, 2009 at 7:24 PM, Shawn McKenzienos...@mckenzies.net wrote:
  Brian Dunning wrote:
  Extra info, in case needed: my code says
 
  fopen('\\servername\sharename\folder\file.xml', 'w');
 
  and it returns Failed to open stream, no such file or directory. I've
  verified that the PHP machine does have unrestricted permissions to that
  share and to the directory. Thanks.
 
 
  On Jun 15, 2009, at 1:39 PM, Brian Dunning wrote:
 
  Running on Windows... I have a network share, \\sharename\foldername,
  and I want to write a file. How do I format the pathname with fopen()
  for this?
 
 
 
  As I remember, you either have to double slash or use the other slash.
 
  servername\\sharename\\folder\\file.xml
 
  or
 
  //servername/sharename/folder/file.xml
 
  --
  Thanks!
  -Shawn
  http://www.spidean.com
 
 
 I think 'servername\sharename\folder\file.xml' will work if you're
 using single quotes around the string. The only slashes that would
 need escaped are the first two since the first slash in '\\' escapes
 the second.
 
 Andrew
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

_
ConheƧa os novos produtos Windows Live! Clique aqui.
http://www.windowslive.com.br

Re: [PHP] fopen() on a network share?

2009-06-15 Thread Brian Dunning

Extra info, in case needed: my code says

fopen('\\servername\sharename\folder\file.xml', 'w');

and it returns Failed to open stream, no such file or directory.  
I've verified that the PHP machine does have unrestricted permissions  
to that share and to the directory. Thanks.



On Jun 15, 2009, at 1:39 PM, Brian Dunning wrote:

Running on Windows... I have a network share, \\sharename 
\foldername, and I want to write a file. How do I format the  
pathname with fopen() for this?





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen() on a network share?

2009-06-15 Thread Shawn McKenzie
Brian Dunning wrote:
 Extra info, in case needed: my code says
 
 fopen('\\servername\sharename\folder\file.xml', 'w');
 
 and it returns Failed to open stream, no such file or directory. I've
 verified that the PHP machine does have unrestricted permissions to that
 share and to the directory. Thanks.
 
 
 On Jun 15, 2009, at 1:39 PM, Brian Dunning wrote:
 
 Running on Windows... I have a network share, \\sharename\foldername,
 and I want to write a file. How do I format the pathname with fopen()
 for this?
 
 
 
As I remember, you either have to double slash or use the other slash.

servername\\sharename\\folder\\file.xml

or

//servername/sharename/folder/file.xml

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen() on a network share?

2009-06-15 Thread Andrew Ballard
On Mon, Jun 15, 2009 at 7:24 PM, Shawn McKenzienos...@mckenzies.net wrote:
 Brian Dunning wrote:
 Extra info, in case needed: my code says

 fopen('\\servername\sharename\folder\file.xml', 'w');

 and it returns Failed to open stream, no such file or directory. I've
 verified that the PHP machine does have unrestricted permissions to that
 share and to the directory. Thanks.


 On Jun 15, 2009, at 1:39 PM, Brian Dunning wrote:

 Running on Windows... I have a network share, \\sharename\foldername,
 and I want to write a file. How do I format the pathname with fopen()
 for this?



 As I remember, you either have to double slash or use the other slash.

 servername\\sharename\\folder\\file.xml

 or

 //servername/sharename/folder/file.xml

 --
 Thanks!
 -Shawn
 http://www.spidean.com


I think 'servername\sharename\folder\file.xml' will work if you're
using single quotes around the string. The only slashes that would
need escaped are the first two since the first slash in '\\' escapes
the second.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen not working corectly on remote IIS

2008-11-11 Thread Andrew Ballard
On Tue, Nov 11, 2008 at 9:10 AM, Yeti [EMAIL PROTECTED] wrote:
 As PHP says ... there seems to be something wrong with file
 permissions. Make sure the IIS-user (if there is one on windows) can
 read intekendb.php.
 I don't know if you checked [1] yet. It's alot of useful info about php on 
 IIS.

 Quote out of that article:
 The IIS user (usually IUSR_MACHINENAME) needs permission to read
 various files and directories, such as php.ini, docroot, and the
 session tmp directory.


The message is pretty clear. The IIS user needs Modify permission to
the file 'intekendb.txt'.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen not working corectly on remote IIS

2008-11-11 Thread Yeti
As PHP says ... there seems to be something wrong with file
permissions. Make sure the IIS-user (if there is one on windows) can
read intekendb.php.
I don't know if you checked [1] yet. It's alot of useful info about php on IIS.

Quote out of that article:
The IIS user (usually IUSR_MACHINENAME) needs permission to read
various files and directories, such as php.ini, docroot, and the
session tmp directory.

Maybe [2] can help you out too.

[1] http://www.php.net/manual/en/install.windows.iis.php
[2] http://at.php.net/manual/en/function.fopen.php#50601

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen() for http:// sometimes working, sometimes not

2007-12-27 Thread Daniel Brown
On Dec 27, 2007 11:31 AM, Albert Wiersch [EMAIL PROTECTED] wrote:

 I noticed my script at http://onlinewebcheck.com was sometimes (fairly
 often) failing to open some URLs that users have entered. fopen() returns
 false very quickly, but when tried again with the same URL, sometimes it
 works. What would cause this behavior? Why does fopen() occasionally fail to
 open valid http addresses but works at other times?

Are the URLs being passed to fopen() properly escaped?  Are they
valid, complete with http:// placed before the domain?  Try keeping a
log of all URLs entered for a bit, and see which ones fail.

-- 
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen() for http:// sometimes working, sometimes not

2007-12-27 Thread Albert Wiersch

Daniel Brown [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Dec 27, 2007 11:31 AM, Albert Wiersch [EMAIL PROTECTED] 
 wrote:

Are the URLs being passed to fopen() properly escaped?  Are they
 valid, complete with http:// placed before the domain?  Try keeping a
 log of all URLs entered for a bit, and see which ones fail.

It's not the URL because the same URL will not work one time but will work 
another time.

What needs to be escaped for a URL anyway? I am just changing spaces to 
'%20' now.

I will try upgrading to 5.2.5. I'm using 5.2.3 now.

Thanks,
Albert

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen() for http:// sometimes working, sometimes not

2007-12-27 Thread Daniel Brown
On Dec 27, 2007 12:57 PM, Albert Wiersch [EMAIL PROTECTED] wrote:
 What needs to be escaped for a URL anyway? I am just changing spaces to
 '%20' now.

Arbitrary code can still be injected unless it's properly
sanitized, but that's beyond the scope here.

Mainly, make sure quotes (single and double) are being converted.

-- 
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen function and charset

2007-10-02 Thread Jay Blanchard
[snip]
I want to know, what charset is applied to every file when is created
with
the fopen function and how can I to manage the charset when I use the
fopen
function?

For example: If i want to create an ISO-8859-2 file, how can I to force,
the
fopen function to create it?
[/snip]

This may start to shed some light http://us2.php.net/mbstring

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and fwrite r+

2007-01-13 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-13 17:32:00 -0500:
 I can write to the bottom of the file, no problem, but if I want to  
 put new entries at the top of the file I have problems:
 the previous entry is partially overwritten and mangled..
 
you cannot prepend to a file. to do that you need to create a new
file, write the new data in it, and append data from the old file.

class newLiner extends IteratorIterator
{
function current()
{
return $this-getInnerIterator()-current() . \n;
}
}

$lines = array('line 1', 'line 2', 'line 3');
$data = new newLiner(new ArrayObject($lines));
$file = new SPLFileObject('file', 'r');
$temp = new SPLFileObject('temp', 'w');

$all = new AppendIterator;
$all-append($data);
$all-append($file);

foreach ($all as $line) {
$temp-fwrite($line);
}

$file-fflush();
$temp-fflush();
unset($file); unset($temp);

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen failed to open pipe file in Linux+Apache environment

2006-12-08 Thread Ryan Creaser

mike xu wrote:

Thanks a lot forr your reply.

Here is the error msg:
*Warning*: fopen(/dev/pmsg)
[function.fopenhttp://localhost/Source/test/function.fopen]:
failed to open stream: Permission denied in *
/var/www/html/Source/test/register_user.php* on line *31

It still doesn't work even if I move pmsg to /tmp/ directory and 
change its

own to appache...



I don't really know Fedora or SELinux, but since your permissions seem 
ok could it be the SELinux policy for httpd causing you grief?


- rjc

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen failed to open pipe file in Linux+Apache environment

2006-12-08 Thread mike xu

Hi Ryan,

I just did another test, if I start the httpd by root user manually (the
httpd daemon program still owns apache user by the result of `ps -aux`), the
php script works fine. So, it seems the httpd start script
(/etc/rc.d/init.d/httpd) did something specially which cause the permission
problem...
I'll continue checking it ...

Thanks,
Mike

On 12/8/06, Ryan Creaser [EMAIL PROTECTED] wrote:


mike xu wrote:
 Thanks a lot forr your reply.

 Here is the error msg:
 *Warning*: fopen(/dev/pmsg)
 [function.fopenhttp://localhost/Source/test/function.fopen]:
 failed to open stream: Permission denied in *
 /var/www/html/Source/test/register_user.php* on line *31

 It still doesn't work even if I move pmsg to /tmp/ directory and
 change its
 own to appache...


I don't really know Fedora or SELinux, but since your permissions seem
ok could it be the SELinux policy for httpd causing you grief?

- rjc



Re: [PHP] fopen failed to open pipe file in Linux+Apache environment

2006-12-08 Thread mike xu

Its so strange, when I runing /etc/rc.d/rc3.d/S85httpd restart, the php
script couldn't fopen pipe file.
But if I copy /etc/rc.d/rc3.d/S85httpd to some other place (for example
/root), and execute `/root/S85httpd restart`, the php script could fopen
file successfully!

Its so confusing ...

On 12/8/06, mike xu [EMAIL PROTECTED] wrote:


Hi Ryan,

I just did another test, if I start the httpd by root user manually (the
httpd daemon program still owns apache user by the result of `ps -aux`), the
php script works fine. So, it seems the httpd start script
(/etc/rc.d/init.d/httpd) did something specially which cause the permission
problem...
I'll continue checking it ...

Thanks,
Mike

On 12/8/06, Ryan Creaser [EMAIL PROTECTED] wrote:

 mike xu wrote:
  Thanks a lot forr your reply.
 
  Here is the error msg:
  *Warning*: fopen(/dev/pmsg)
  [function.fopenhttp://localhost/Source/test/function.fopen ]:
  failed to open stream: Permission denied in *
  /var/www/html/Source/test/register_user.php* on line *31
 
  It still doesn't work even if I move pmsg to /tmp/ directory and
  change its
  own to appache...
 

 I don't really know Fedora or SELinux, but since your permissions seem
 ok could it be the SELinux policy for httpd causing you grief?

 - rjc





Re: [PHP] fopen failed to open pipe file in Linux+Apache environment

2006-12-07 Thread Chris

mike xu wrote:

Hi, I have problem of open named pipe file in linux.

Here is my sample code:

 $fifo_file = /dev/pmsg;
 @ $fp = fopen($fifo_file, 'w+b');


It's wb+ not w+b

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen failed to open pipe file in Linux+Apache environment

2006-12-07 Thread Ryan Creaser


mike xu wrote:

Hi, I have problem of open named pipe file in linux.

Here is my sample code:

 $fifo_file = /dev/pmsg;
 @ $fp = fopen($fifo_file, 'w+b');
 if(!$fp) {
   echo open .$fifo_file. failed;
 }
 else {
   $msg_cmd = ttt;
   fwrite($fp, $msg_cmd, strlen($msg_cmd));
   fclose($fp);
 }

There is an other program which is waiting for messages from /dev/pmsg
forever. You could also test it by running `cat /dev/pmsg` in shell 
console.

Every one have permissions of read and write for /dev/pmsg
prw-rw-rw- 1 root root 0 12-08 10:13 /dev/pmsg

Environment info: php-5.1.2-5, httpd-2.2.0-5.1.2, OS: Redhat FC5

Thanks in advance,
Mike


Are you getting any errors? What if you remove the @ from the start of 
line 2, any errors now?


- rjc

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen failed to open pipe file in Linux+Apache environment

2006-12-07 Thread mike xu

Thanks a lot forr your reply.

Here is the error msg:
*Warning*: fopen(/dev/pmsg)
[function.fopenhttp://localhost/Source/test/function.fopen]:
failed to open stream: Permission denied in *
/var/www/html/Source/test/register_user.php* on line *31

It still doesn't work even if I move pmsg to /tmp/ directory and change its
own to appache...
*
On 12/8/06, Ryan Creaser [EMAIL PROTECTED] wrote:



mike xu wrote:
 Hi, I have problem of open named pipe file in linux.

 Here is my sample code:

  $fifo_file = /dev/pmsg;
  @ $fp = fopen($fifo_file, 'w+b');
  if(!$fp) {
echo open .$fifo_file. failed;
  }
  else {
$msg_cmd = ttt;
fwrite($fp, $msg_cmd, strlen($msg_cmd));
fclose($fp);
  }

 There is an other program which is waiting for messages from /dev/pmsg
 forever. You could also test it by running `cat /dev/pmsg` in shell
 console.
 Every one have permissions of read and write for /dev/pmsg
 prw-rw-rw- 1 root root 0 12-08 10:13 /dev/pmsg

 Environment info: php-5.1.2-5, httpd-2.2.0-5.1.2, OS: Redhat FC5

 Thanks in advance,
 Mike

Are you getting any errors? What if you remove the @ from the start of
line 2, any errors now?

- rjc



Re: [PHP] fopen: space character in filename

2006-07-28 Thread Robert Cummings
On Fri, 2006-07-28 at 16:55, Christian Calloway wrote:
 Hello all,
 
 this seems like an easy question, but I could sure as hell couldn't find any 
 responces to it through initial searched. I am running php on an XP system 
 and I need to open a file contained with a set of directories which may or 
 may not have a space character; so for example:
 
 fopen (X:\Dont Talk\About\My Momma\please.txt, x);
 
 I tried using \ characters, no luck (even attempted to cancel out the 
 backspace characters ala \\ and http space code %20, and still nothing.) Any 
 ideas? 

RTFM -- you need to double backslash when using double quotes. Otherwise
use single quotes.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen: space character in filename

2006-07-28 Thread Robert Cummings
On Fri, 2006-07-28 at 17:27, Robert Cummings wrote:
 On Fri, 2006-07-28 at 16:55, Christian Calloway wrote:
  Hello all,
  
  this seems like an easy question, but I could sure as hell couldn't find 
  any 
  responces to it through initial searched. I am running php on an XP system 
  and I need to open a file contained with a set of directories which may or 
  may not have a space character; so for example:
  
  fopen (X:\Dont Talk\About\My Momma\please.txt, x);
  
  I tried using \ characters, no luck (even attempted to cancel out the 
  backspace characters ala \\ and http space code %20, and still nothing.) 
  Any 
  ideas? 
 
 RTFM -- you need to double backslash when using double quotes. Otherwise
 use single quotes.

And after writing that I re-read and realized you did *hah*. Make sure
the file exists on the hard drive where you think it does. Also make
sure you have read permissions. And hwile you're at it, make sure you
have error reporting enabled so you can see any special errors that
might be issued for various violations.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen: space character in filename

2006-07-28 Thread Stut
Christian Calloway wrote:
 this seems like an easy question, but I could sure as hell couldn't find any 
 responces to it through initial searched. I am running php on an XP system 
 and I need to open a file contained with a set of directories which may or 
 may not have a space character; so for example:
 
 fopen (X:\Dont Talk\About\My Momma\please.txt, x);
 
 I tried using \ characters, no luck (even attempted to cancel out the 
 backspace characters ala \\ and http space code %20, and still nothing.) Any 
 ideas? 

Spaces aren't your problem here, the \'s are. You need to escape them...

fopen (X:\\Dont Talk\\About\\My Momma\\please.txt, x);

-Stut

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen failing, permission denied

2006-02-28 Thread Chris

Dan Baker wrote:

I have the following code snippet:
$h = fopen($path/file.txt, 'x+');

And it generates the following error:
Warning: fopen(/home/./myarea/file.txt): failed to open stream: 
Permission denied


The path is correct, but the php process doesn't seem to have file 
permissions in the folder.
Is there some magic I can do to allow php to have file rights to the 
myarea folder?  (This is on a purchased ISP site)


Go in through ftp or ssh and fix the permissions.

If you only want to read the file, then it only needs to be 644.

If you need to write the file it will either need to be 646 or 664.

That's your only option apart from deleting the file (through ftp) and 
recreating it through your php script ... or getting your host to change 
to the CGI version of php which is most unlikely to happen.


--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen/fwrite and owner/group settings

2006-01-05 Thread Silvio Porcellana [tradeOver]
Mathijs wrote:
 Hello there,
 
 I Have a problem with some file writeing.
 
 I Use fopen to create a new file, but that file gets the owner and group
 the same as the apache owner and group.
 
 How can i change it so that the file gets the same owner/group as the
 files i upload with FTP?
 
 Thx in advanced
 

You can use FTP functions to create the file (for example 'ftp_put')
http://php.net/ftp

HTH, cheers
Silvio

-- 
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen on windows

2005-11-14 Thread Ford, Mike
On 11 November 2005 20:52, Jay Blanchard wrote:

 $theFile = fopen(docs/InstallationInstructionMaster.txt, r) ||
 die;

You need or not || here.  The operator priorities are such that the above 
means

  $theFile = (fopen(docs/InstallationInstructionMaster.txt, r) || die);

which assigns TRUE to $the File when the fopen() succeeds, rather than the file 
handle.  You can't have error reporting turned up very high, or this:
 
 while(!feof($theFile)){
   $theLine = fgets($theFile, 4096);
   echo $theLine . br\n;
 }

would be throwing all sorts of warnings about the invalid file handle.  I'm 
guessing that feof(TRUE) returns NULL as well as throwing the warning, so this 
should be an infinite loop echoing just linebreaks.  Oh, wait! ;)

On the other hand, the version using or works out to be:

   ($theFile = fopen(docs/InstallationInstructionMaster.txt, r)) or die;

which assigns the result of fopen() to $theFile, and then executes die if it's 
false -- which is much more satisfactory. ;)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen on windows

2005-11-14 Thread Ford, Mike
On 11 November 2005 21:21, Nathan Tobik wrote:

 I've always used:
 
 fopen(C:\\dir\\dir\\file.txt);
 
 on windows, I'm not sure how PHP interprets the slashes internally
 though... 

On Windows, / in filenames is internally translated by PHP to \ -- which 
means you can write code that works on both Windows and *n*x using /.  
*Really* portable code uses the DIRECTORY_SEPARATOR constant, however.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen on windows

2005-11-14 Thread Jay Blanchard
[snip]
You need or not || here.  The operator priorities are such that the above
means
...
which assigns the result of fopen() to $theFile, and then executes die if
it's false -- which is much more satisfactory. ;)
[/snip]

Originally I did not have any '||' or 'or' in the conditional check, with
the same results. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen on windows

2005-11-14 Thread Richard Lynch
On Fri, November 11, 2005 2:51 pm, Jay Blanchard wrote:
 $theFile = fopen(docs/InstallationInstructionMaster.txt, r) ||
 die;

Don't use || when you mean 'or' :-)

Nor sure it really matters here, but better to follow the crowd and
use 'or' here.

 while(!feof($theFile)){
   $theLine = fgets($theFile, 4096);

4096 is longer than any line in the file?

   echo $theLine . br\n;
 }
 fclose($theFile);

 The above code appears to work, but all that is output is lines of
 line
 breaksno data. The file is a tab delimited test file;

View Source?

 Am I missing something other than an ice cold beer?

Are you 100% certain you don't have an empty file in
docs/InstallationInstructionMaster.txt sitting right next to your
script, while the REAL file you want is somewhere else?

Been there.  Done that.  Smacked the forehead.

Use the full path to the file to be SURE you are reading the file you
think you are reading.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen on windows

2005-11-14 Thread Richard Lynch
On Fri, November 11, 2005 3:23 pm, Jay Blanchard wrote:
 // Left off the b because it ain't binary :)

I think you will find this is the crucial difference if you go back to
your original and take it out.

Your file is text.

It's not binary.

On Windowz, that matters, for some odd reason.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen on windows

2005-11-14 Thread Jay Blanchard
[snip]
On Fri, November 11, 2005 2:51 pm, Jay Blanchard wrote:
 $theFile = fopen(docs/InstallationInstructionMaster.txt, r) ||
 die;

Don't use || when you mean 'or' :-)

Nor sure it really matters here, but better to follow the crowd and
use 'or' here.
[/snip]

Okie dokie. Found there to be no change in behavior at this point. Perhaps I
need to set the error checking higher, say E_ALL.

[snip]
 while(!feof($theFile)){
   $theLine = fgets($theFile, 4096);

4096 is longer than any line in the file?
[/snip]

Yes, it accounts for every line in the file.

[snip]
   echo $theLine . br\n;
 }
 fclose($theFile);

 The above code appears to work, but all that is output is lines of
 line
 breaksno data. The file is a tab delimited test file;

View Source?
[/snip]


Looks like;

br
br
br
br
br


[snip]
Are you 100% certain you don't have an empty file in
docs/InstallationInstructionMaster.txt sitting right next to your
script, while the REAL file you want is somewhere else?

Been there.  Done that.  Smacked the forehead.

Use the full path to the file to be SURE you are reading the file you
think you are reading.
[/snip]

Did that too. Still no joy.

Several other methods have been provided and I will use one of those.
However, when I get to the point that fopen would be my only choice I will
likely encounter these same problems. C'est la vie!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen on windows

2005-11-11 Thread Jasper Bryant-Greene

Jay Blanchard wrote:

$theFile = fopen(docs/InstallationInstructionMaster.txt, r) || die;


I'm not sure if it would make any difference, but I usually use or in 
this case rather than ||, and I know they have different operator 
precedence.



while(!feof($theFile)){
$theLine = fgets($theFile, 4096);
echo $theLine . br\n;
}
fclose($theFile);

The above code appears to work, but all that is output is lines of line
breaksno data. The file is a tab delimited test file;
[snip] 
Am I missing something other than an ice cold beer?


Well, it's a pretty model example of a line-by-line file read. I can't 
see anything wrong with it, so perhaps the problem lies elsewhere. 
There's no other files with the same name in your include_path?


Maybe something to do with auto_detect_line_endings or whatever it's 
called, in php.ini? (I know, probably a long shot.)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen on windows

2005-11-11 Thread Jay Blanchard
[snip]
Well, it's a pretty model example of a line-by-line file read. I can't 
see anything wrong with it, so perhaps the problem lies elsewhere. 
There's no other files with the same name in your include_path?

Maybe something to do with auto_detect_line_endings or whatever it's 
called, in php.ini? (I know, probably a long shot.)
[/snip]

The output now looks like
Array
(
[0] = 
)
Array
(
[0] = 
)
Array
(
[0] = 
)

based on the following code;

$theFile = fopen(docs/InstallationInstructionMaster.txt, rb) || die;

while(!feof($theFile)){
$theLine = fgets($theFile);
$lineArray = explode(\t, $theLine);
print_r($lineArray);
}
fclose($theFile);

It appears that something is getting read, but what?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen on windows

2005-11-11 Thread Jasper Bryant-Greene

Jay Blanchard wrote:

[snip]
Well, it's a pretty model example of a line-by-line file read. I can't 
see anything wrong with it, so perhaps the problem lies elsewhere. 
There's no other files with the same name in your include_path?


Maybe something to do with auto_detect_line_endings or whatever it's 
called, in php.ini? (I know, probably a long shot.)

[/snip]

The output now looks like
[snip] 
based on the following code;


$theFile = fopen(docs/InstallationInstructionMaster.txt, rb) || die;

while(!feof($theFile)){
$theLine = fgets($theFile);
$lineArray = explode(\t, $theLine);
print_r($lineArray);
}
fclose($theFile);

It appears that something is getting read, but what?


Blank lines. Just to see if the problem is fgets(), try this:

// Left off the b because it ain't binary :)
$theFile = file_get_contents( docs/InstallationInstructionMaster.txt, 
r ) or die;

$lines = explode( \n, $theFile );

foreach( $lines as $line ) {

$line = explode( \t, $line );
print_r( $line );

}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen on windows

2005-11-11 Thread Nathan Tobik
I've always used:

fopen(C:\\dir\\dir\\file.txt);

on windows, I'm not sure how PHP interprets the slashes internally
though...

Nate Tobik
(412)661-5700 x206
VigilantMinds



 $theFile = fopen(docs/InstallationInstructionMaster.txt, rb) ||
die;

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen on windows

2005-11-11 Thread Jay Blanchard
[snip]
Blank lines. Just to see if the problem is fgets(), try this:

// Left off the b because it ain't binary :)
$theFile = file_get_contents( docs/InstallationInstructionMaster.txt, 
r ) or die;
$lines = explode( \n, $theFile );

foreach( $lines as $line ) {
$line = explode( \t, $line );
print_r( $line );
}
[/snip]

That works, as does the following;

$lines = file('docs/InstallationInstructionMaster.txt');

foreach ($lines as $line){
   echo $line . br /\n;
}

So, I am perplexed. fgets() seems to have a problem of some sort. Any clues?
Not that what I want to do requires fgets(), just curious now as I will use
one of the other two methods.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen

2005-10-26 Thread Jochem Maas

John Taylor-Johnston wrote:
It does what I want, but I worry 4096 may not be big enough. Possible? 


4096 is the number of bytes fgets() will get, but the fgets()
call is inside a while loop which keeps running until the 'filepointer'
(as denoted by the handle $dataFile) in question has reached the end of the
given file. so if 4096 is not big enough the loop merely grabs another 4096
bytes until its grabbed it all.

so actually you have a handy bit of code which will allow you to 'eat' through
massive files without the requirement of being able to store the
whole file in memory.


Is there a way to detect the filesize and insert a value for 4096?


filesize()


$buffer = fgets($dataFile, $filesize);
Is this what it is for?
John


?php
#http://ca3.php.net/fopen
$filename = /var/www/html2/assets/about.htm ;
$dataFile = fopen( $filename, r ) ;
  while (!feof($dataFile))
  {
  $buffer = fgets($dataFile, 4096);
  echo $buffer;
  }
$sql = insert into table ... $buffer;
?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen

2005-10-25 Thread Stephen Leaf
if all you want to do is read the entire file try
$contents = file_get_contents($filename);

On Tuesday 25 October 2005 11:54 pm, John Taylor-Johnston wrote:
 It does what I want, but I worry 4096 may not be big enough. Possible?
 Is there a way to detect the filesize and insert a value for 4096?
 $buffer = fgets($dataFile, $filesize);
 Is this what it is for?
 John


 ?php
 #http://ca3.php.net/fopen
 $filename = /var/www/html2/assets/about.htm ;
 $dataFile = fopen( $filename, r ) ;
while (!feof($dataFile))
{
$buffer = fgets($dataFile, 4096);
echo $buffer;
}
 $sql = insert into table ... $buffer;
 ?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen

2005-10-25 Thread Joe Wollard


On Oct 26, 2005, at 12:54 AM, John Taylor-Johnston wrote:

It does what I want, but I worry 4096 may not be big enough.  
Possible? Is there a way to detect the filesize and insert a value  
for 4096?

$buffer = fgets($dataFile, $filesize);
Is this what it is for?
John


?php
#http://ca3.php.net/fopen
$filename = /var/www/html2/assets/about.htm ;
$dataFile = fopen( $filename, r ) ;
  while (!feof($dataFile))
  {
  $buffer = fgets($dataFile, 4096);
  echo $buffer;
  }
$sql = insert into table ... $buffer;
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




fgets

(PHP 3, PHP 4, PHP 5)

fgets -- Gets line from file pointer
Description

string fgets ( resource handle [, int length] )

Returns a string of up to length - 1 bytes read from the file pointed  
to by handle. Reading ends when length - 1 bytes have been read, on a  
newline (which is included in the return value), or on EOF (whichever  
comes first). If no length is specified, the length defaults to 1k,  
or 1024 bytes.


If an error occurs, returns FALSE.

RE: [PHP] fopen problem

2005-06-24 Thread Shaw, Chris - Accenture

Are you using the a or a+ modes on fopen, because I have a sneaky feeling the
file doesn't exist.

-Original Message-
From: Ross [mailto:[EMAIL PROTECTED]
Sent: 24 June 2005 00:33
To: php-general@lists.php.net
Subject: [PHP] fopen problem


*

This e-mail has been received by the Revenue Internet e-mail service.

*

I have a bit of a problem when using fopen, fwrite and fclose locally I get
the flowing warnings

Warning: fopen(counterlog.txt) [function.fopen]: failed to open stream:
Permission denied in c:\Inetpub\wwwroot\pillars\index.php on line 30

Warning: fwrite(): supplied argument is not a valid stream resource in
c:\Inetpub\wwwroot\pillars\index.php on line 33

Warning: fclose(): supplied argument is not a valid stream resource in
c:\Inetpub\wwwroot\pillars\index.php on line 36


Any ideas??


R.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php







This message has been delivered to the Internet by the Revenue Internet e-mail 
service

*

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen problem

2005-06-23 Thread Esteamedpw
can you show the code? did you chmod the files?


Re: [PHP] fopen problem

2005-06-23 Thread Richard Lynch
On Thu, June 23, 2005 4:33 pm, Ross said:
 Warning: fopen(counterlog.txt) [function.fopen]: failed to open stream:
 Permission denied in c:\Inetpub\wwwroot\pillars\index.php on line 30

The PHP user does *NOT* have permission to open the counterlog.txt file.

Exactly *HOW* you change permissions changed in every Windoze version,
which suck, but there it is.

You should A) post *which* Windows OS you are using and B) try the Windows
list and C) poke around with Windows Explorer first to see if you can't
make the counterlog.txt file be owned by the User PHP is running as, which
you can find out from http://php.net/phpinfo

Actually, do ABC) in reverse order :-)

 Warning: fwrite(): supplied argument is not a valid stream resource in
 c:\Inetpub\wwwroot\pillars\index.php on line 33

 Warning: fclose(): supplied argument is not a valid stream resource in
 c:\Inetpub\wwwroot\pillars\index.php on line 36

These are a direct result of the first error.

Your script should NOT have even *TRIED* to run these functions, once it
failed to open the file in the first place.

Add a lot more error-checking to your script.

Once you fix the first error, these errors will go away

In Reality, they are just waiting to re-surface when something else goes
wrong with your file access.

So, actually, fix your script to skip these lines *FIRST* then fix the
error above.  Consider it part of the learning to write Good Code.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen for http://

2005-05-27 Thread Rory Browne
On 5/27/05, Jay Paulson [EMAIL PROTECTED] wrote:
 Hello all-
 
 I was wondering if anyone knew of a way to call a web site using fopen.
   Let me tell you how things are set up and what I'm trying to do.  I
 can call fopen to read a site and then echo it back out.  That's not a
 problem.  The problem I run into is when I try to go to a restricted
 area of a site.
Define restricted area. How is it restricted? Using Login Forms?
Using HTTP Authentication? Using .htaccess to filter using IP
Addresses?

 
 For example, in my Apache httpd.conf file I have it set up to where I
 have a directory that is only accessible from certain IP addresses, one
 of which is 127. (the localhost).  The script I'm running is located on
 the server and the web site I'm trying to access via fopen() is on the
 same server.  Therefore, I'm thinking that the php script should have
 access to read the site's restricted directory.  For some reason it
 does not have access.
What errors are you getting? Do you get the same errors, when you
access the site using a Browser? Are you accessing the site via
someurl.com or localhost? If you're using someurl.com, and the ip
address of someurl.com is 1.2.3.4, then you'll need to add 1.2.3.4 to
the list of allowed ip addresses. Your server probably doesn't
recognise that 1.2.3.4 is actually the same as 127.x.x.x when deciding
to allow or deny.

 
 I was wondering if there was a way around this or am I just doomed to
 never be able to access the directory via
 fopen(http://someurl.com/somedirectory,r;); ??
 
 Thanks.
 Jay
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen for http://

2005-05-27 Thread Philip Hallstrom
I was wondering if anyone knew of a way to call a web site using fopen.  Let 
me tell you how things are set up and what I'm trying to do.  I can call 
fopen to read a site and then echo it back out.  That's not a problem.  The 
problem I run into is when I try to go to a restricted area of a site.


For example, in my Apache httpd.conf file I have it set up to where I have a 
directory that is only accessible from certain IP addresses, one of which is 
127. (the localhost).  The script I'm running is located on the server and 
the web site I'm trying to access via fopen() is on the same server. 
Therefore, I'm thinking that the php script should have access to read the 
site's restricted directory.  For some reason it does not have access.


I was wondering if there was a way around this or am I just doomed to never 
be able to access the directory via 
fopen(http://someurl.com/somedirectory,r;); ??


Why can't you just do...

fopen(http://127.0.0.1/somedirectory;, r);

?

Odds are when you do it the other way your IP address is *NOT* 
127.0.0.1, but whatever your Internet IP address is.


-philip

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen

2005-03-20 Thread Kim Madsen
-Original Message-
From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] 
Sent: Saturday, March 19, 2005 7:03 AM
To: php-general@lists.php.net
Subject: [PHP] fopen

 What can I add to get more info from the die? Do I have to specify a

 pathname in $defaultfile?

Start by _removing_ @ to get warnings?

$defaultfile = ffmail.txt; #default file to write to
@ $results = fopen($datafilename, a);  #open file and supress errors

You set $defaultfile, but tries to open $datafilename?

-- 
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen 
Systemudvikler/systemdeveloper

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and redirects

2005-02-25 Thread Richard Lynch
Warren Vail wrote:
 I am using fopen with a url to open a remote file (read only of course).
 The url I am providing results in a redirect and the fopen seems to be
 smart
 enough to follow the redirect to return the actual file contents.  How can
 I
 get at the redirected filename?

 The problem is the file contains html and relative references in href's
 buried in the html are relative to the redirected location and not my
 original location, and I would like to subsequently open some of those
 files
 (like a crawler does).

http://php.net/curl
will give you the control to follow or not follow re-directs, as well as
access to all the headers that are coming in to figure out what's going
on.

If it's an IIS/ASP site, count on three or four re-directs for no apparent
reason, other than to waste resources and sell more hardware/software. :-p

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen and http://

2005-02-25 Thread Warren Vail
Just a wild guess, but try url;

http://localhost/zed/htdocs/rgfindingaids/series594.html

or

file://zed/htdocs/rgfindingaids/series594.html to bypass your web server

I am struggling with the section of the manual that deals with this as well.

http://us3.php.net/manual/en/ref.stream.php

hope this helps,

Warren Vail

 -Original Message-
 From: Mulley, Nikhil [mailto:[EMAIL PROTECTED]
 Sent: Friday, October 08, 2004 6:58 AM
 To: Adam Williams; php-general@lists.php.net
 Subject: RE: [PHP] fopen and http://


 May be the path is not the correct ,just check with the Web
 Directory you configured to be and if its htdocs then I would say
 that its better to remove the htdocs from the path in fopen statement.

 -Original Message-
 From: Adam Williams [mailto:[EMAIL PROTECTED]
 Sent: Friday, October 08, 2004 6:22 PM
 To: php-general@lists.php.net
 Subject: [PHP] fopen and http://


 Hi, I'm having a problem with fopen and http files.  I keep getting the
 error:

 Warning: fopen(http://zed/htdocs/rgfindingaids/series594.html )
 [function.fopen]: failed to open stream: HTTP request failed!
 HTTP/1.1 404
 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
 http://zed/htdocs/rgfindingaids/series594.html does not exist

 Warning: fopen(http://zed/htdocs/rgfindingaids/ser391.html )
 [function.fopen]: failed to open stream: HTTP request failed!
 HTTP/1.1 404
 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
 http://zed/htdocs/rgfindingaids/ser391.html does not exist

 Warning: fopen(http://zed/htdocs/rgfindingaids/ser392.html )
 [function.fopen]: failed to open stream: HTTP request failed!
 HTTP/1.1 404
 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
 http://zed/htdocs/rgfindingaids/ser392.html does not exist



 I have a text file /home/awilliam/public_html/rgfaids containing
 URLs such
 as:

 http://zed/htdocs/rgfindingaids/series594.html
 http://zed/htdocs/rgfindingaids/ser391.html
 http://zed/htdocs/rgfindingaids/ser392.html

 and I can bring up these URLs fine in a browser on the PC i'm running the
 script on.

 The following is my code:

 ?

 $filelist = fopen(/home/awilliam/public_html/rgfaids, r);

 if (!$filelist)
 {
 echo error opening rgfaids;
 exit;
 }

 while ( !feof($filelist))
 {
 $line = fgets($filelist, 9);

 $filetotest = fopen($line, r);

 if (!$filetotest)
 {
 echo $line does not existbr;
 }
 elseif ($filetotest)
 {
 echo $line does exist;
 }
 }

 ?



 But I don't understand why I am getting that error about failed to open
 strem: HTTP request failed, when I can bring up the links fine in a
 browser on the server running the php script.  So can anyone help
 me out?
 Thanks

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen and http://

2005-02-25 Thread Richard Lynch
Warren Vail wrote:
 Hi, I'm having a problem with fopen and http files.  I keep getting the
 error:

 Warning: fopen(http://zed/htdocs/rgfindingaids/series594.html )
 [function.fopen]: failed to open stream: HTTP request failed!
 HTTP/1.1 404
 Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
 http://zed/htdocs/rgfindingaids/series594.html does not exist

 I have a text file /home/awilliam/public_html/rgfaids containing
 URLs such
 as:

 http://zed/htdocs/rgfindingaids/series594.html
 http://zed/htdocs/rgfindingaids/ser391.html
 http://zed/htdocs/rgfindingaids/ser392.html

 and I can bring up these URLs fine in a browser on the PC i'm running
 the
 script on.

Here's the thing though:

Does your SERVER know anything about 'zed'?

Maybe you've configured your PC's 'hosts' file so it knows that 'zed'
means 192.168.1.47 (or whatever) but did you configure your server's
'hosts' files to know that?

Log in to the server with SSH and do:
nslookup zed
and see what you get.

If the operating system has no idea where 'zed' is, then PHP sure won't be
able to figure it out.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] FOPEN

2005-02-17 Thread Mikey
http://uk.php.net/header should help you.

BTW, you should address your replies to the list and not to individual ppl.

Mikey

 -Original Message-
 From: Diana Castillo [mailto:[EMAIL PROTECTED] 
 Sent: 17 February 2005 12:36
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] FOPEN
 
 how do I send headers with php?
 - Original Message -
 From: Mikey [EMAIL PROTECTED]
 To: 'Diana Castillo' [EMAIL PROTECTED]
 Sent: Thursday, February 17, 2005 1:32 PM
 Subject: RE: [PHP] FOPEN
 
 
 How can I read the contents of a web page that uses basic
  authentication?
  I want to use fopen() but dont know how to do this and also
  send the username and password
 
  I don't know exactly what they are, but it should just be a case of 
  sending
  the correct HTTP headers at the start of your request
  http://www.w3.org/Protocols/#Specs should give you the 
 information you
  need...
 
  HTH,
 
  Mikey
  
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] FOPEN

2005-02-17 Thread Richard Lynch




Diana Castillo wrote:
How can I read the contents of a web page that uses basic
 authentication?
 I want to use fopen() but dont know how to do this and also send the
 username and password

You may be able to do embed the username/password in your URL:

$file = fopen(http://username:[EMAIL PROTECTED]) or die(Could not
open remote page);

You may want to actually store the username/password in a different file,
and try to make it slightly less easy to read/find that file to avoid
exposing passwords, the same way you would do with MySQL
username/password.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen problem using ftp

2005-02-15 Thread Richard Lynch
Giulio wrote:
 HI all,

 I have a script that uses fopen to acces for read a file using ftp:

 $filepointer = fopen($address,'r');

 having $address string formed this way:

 $address =
 ftp:/
 /.$FTPuser.:.$FTPpassword.@.$FTPserver./.$FileFolder./.$FileNa
 me;

You really don't need all those '.' in there:P

$address = ftp://$FTPuser:[EMAIL PROTECTED]/$FileFolder/$FileName;

will work just fine.

Not any faster or anything, just more readable.

 This script always worked for me, it has now stopped working trying it
 on the server of a different provider, returning an error 'failed to
 open stream...'

 I have the suspect that the funcion is failing due to the particular
 account name ( used also as FTP username ) this italian provider gived
 me when I sibscribed: It contains a @ symbol ( I.E., [EMAIL PROTECTED] ),
   and I believe that this confuses the parsing of the
 ftp://User:[EMAIL PROTECTED]/filepath string.

 Can you confirm this, or do you believe that the problem could be
 caused by other factors ( like server settings ) ?

 Could you suggest me e workaround?

Try using just the 123456 of the username...  Probably won't work, but
worth a shot.

Or do this:
$FTPuserURL = urlencode($FTPuser);
before you compose the $address, and use $FTPuserURL instead of $FTPuser.

That will replace the @ with %40 which will almost for sure be the kosher
way have @ in an FTP username in a URL.

Technically, you could/should also urlencode() the password and FilePath
and FileName, I think.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen problem using ftp

2005-02-15 Thread The Disguised Jedi
Why not use the built in FTP functions instead of fopen?

us2.php.net/ftp

Those should be able to handle any of the address problems you have,
seeing as they don't use the ftp://username:[EMAIL PROTECTED] syntax,
they open a connection and work with the FTP system.


-- 
The Disguised Jedi
[EMAIL PROTECTED]

Now you have my $0.02.  Or .01 Pounds, .014 Euros, or $0.025 CAN.  I'm
already internationally compatible!
PHP rocks!
Knowledge is Power.  Power Corrupts.  Go to school, become evil

Disclaimer: Any disclaimer attached to this message may be ignored. 
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.

This message is Certified Virus Free

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen, fsockopen on my virtual host

2005-02-01 Thread Al
Richard Lynch wrote:
Al wrote:
Richard Lynch wrote:
Al wrote:

I've got a script that fetches a stream from a file on our virtual host.
Its
been working fine; but, yesterday they changed something and it no
longer
works.
Can you define no longer works a bit more clearly...
Error messages?
Just times out?
What?

$fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30);
I can use any remote site and fscockopen works fine.
Anyone have a suggestion as to how I deal with this problem?

if ($errno){
 error_log(fsockopen errored out with # $errno: $errstr);
}
Here is my error report:

Warning: fsockopen(): unable to connect to www.restonrunners.org:80 in
/www/r/reston/htdocs/phpList/PQ/PQutility.php on line 364
Operation timed out (60)
fsockopen() works fine with remote URLs and even localhost; but, not
with our
own URL.
I'd use localhost but, I need to attach some GET arguments and I can't
figure
out a way to do it. e.g.,
$str=
file_get_contents(localhost?page=processqueuelogin=Pminpassword=x)

Put some quotes on that, and http:// on the front, and it should work as-is.
Your own domain not working is a symptom of something else though...
Can you ping restonrunners.org?
What happens if you try to do this in a shell:
telnet restonrunners.org 80
GET / HTTP/1.0
Host: restonrunners.org
Hit 'return' twice after the 'Host:' line.
You should get your homepage.
You may have some firewall mis-configured, or DNS issues, or /etc/hosts
might be messed up or...
Many things *could* be wrong to cause this, but none of them are really
PHP-related.
You are correct, the problem is due to the host switching to load balancing 
servers.

Required syntax is now fsockopen(localhost.domain.com, port, time) and
$string= file_get_contents(http://localhost.domain.com/path;).
Thanks again
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen, fsockopen on my virtual host

2005-01-31 Thread Richard Lynch
Al wrote:
 I've got a script that fetches a stream from a file on our virtual host.
 Its
 been working fine; but, yesterday they changed something and it no longer
 works.

Can you define no longer works a bit more clearly...

Error messages?

Just times out?

What?

 $fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30);

 I can use any remote site and fscockopen works fine.

 Anyone have a suggestion as to how I deal with this problem?

if ($errno){
  error_log(fsockopen errored out with # $errno: $errstr);
}

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen, fsockopen on my virtual host

2005-01-31 Thread Al
Richard Lynch wrote:
Al wrote:
I've got a script that fetches a stream from a file on our virtual host.
Its
been working fine; but, yesterday they changed something and it no longer
works.

Can you define no longer works a bit more clearly...
Error messages?
Just times out?
What?

$fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30);
I can use any remote site and fscockopen works fine.
Anyone have a suggestion as to how I deal with this problem?

if ($errno){
  error_log(fsockopen errored out with # $errno: $errstr);
}
Here is my error report:
Warning: fsockopen(): unable to connect to www.restonrunners.org:80 in 
/www/r/reston/htdocs/phpList/PQ/PQutility.php on line 364
Operation timed out (60)
fsockopen() works fine with remote URLs and even localhost; but, not with our 
own URL.

I'd use localhost but, I need to attach some GET arguments and I can't figure 
out a way to do it. e.g.,

$str= file_get_contents(localhost?page=processqueuelogin=Pminpassword=x)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen, fsockopen on my virtual host

2005-01-31 Thread Al
Richard Lynch wrote:
Al wrote:
I've got a script that fetches a stream from a file on our virtual host.
Its
been working fine; but, yesterday they changed something and it no longer
works.

Can you define no longer works a bit more clearly...
Error messages?
Just times out?
What?

$fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30);
I can use any remote site and fscockopen works fine.
Anyone have a suggestion as to how I deal with this problem?

if ($errno){
  error_log(fsockopen errored out with # $errno: $errstr);
}
Same, only a minor typo correction
Here is my error report:
Warning: fsockopen(): unable to connect to www.restonrunners.org:80 in 
/www/r/restonrunners/htdocs/phpList/PQ/PQutility.php on line 364
Operation timed out (60)
fsockopen() works fine with remote URLs and even localhost; but, not with 
our
own URL.
I'd use localhost but, I need to attach some GET arguments and I can't figure
out a way to do it. e.g.,
$str= file_get_contents(localhost?page=processqueuelogin=Pminpassword=x)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen, fsockopen on my virtual host

2005-01-31 Thread Jochem Maas
Al wrote:
Richard Lynch wrote:
...
$str= 
file_get_contents(localhost?page=processqueuelogin=Pminpassword=x)

$str = 
file_get_contents('http://localhost/?page=processqueuelogin=Pminpassword=x');

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen, fsockopen on my virtual host

2005-01-31 Thread Richard Lynch
Al wrote:
 Richard Lynch wrote:
 Al wrote:

I've got a script that fetches a stream from a file on our virtual host.
Its
been working fine; but, yesterday they changed something and it no
 longer
works.

 Can you define no longer works a bit more clearly...

 Error messages?

 Just times out?

 What?

$fp= fsockopen(www.oursite.org, 80, $errno, $errstr, 30);

I can use any remote site and fscockopen works fine.

Anyone have a suggestion as to how I deal with this problem?


 if ($errno){
   error_log(fsockopen errored out with # $errno: $errstr);
 }


 Here is my error report:

 Warning: fsockopen(): unable to connect to www.restonrunners.org:80 in
 /www/r/reston/htdocs/phpList/PQ/PQutility.php on line 364
 Operation timed out (60)

 fsockopen() works fine with remote URLs and even localhost; but, not
 with our
 own URL.

 I'd use localhost but, I need to attach some GET arguments and I can't
 figure
 out a way to do it. e.g.,

 $str=
 file_get_contents(localhost?page=processqueuelogin=Pminpassword=x)

Put some quotes on that, and http:// on the front, and it should work as-is.

Your own domain not working is a symptom of something else though...

Can you ping restonrunners.org?

What happens if you try to do this in a shell:
telnet restonrunners.org 80
GET / HTTP/1.0
Host: restonrunners.org


Hit 'return' twice after the 'Host:' line.

You should get your homepage.

You may have some firewall mis-configured, or DNS issues, or /etc/hosts
might be messed up or...

Many things *could* be wrong to cause this, but none of them are really
PHP-related.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen/fpassthur

2004-12-14 Thread John Holmes
Sebastian wrote:
Q I hope you have some good data validation going on too :)
I am not too sure about how secure it is. basically, the files are called by
an ID
eg, download?type=fileid=3
so i query the db to get check if its a valid id and get the filename from
the db as well.
if its not found it errors out.. i was under the impression that is more
secure to get files by an id from db than doing something like
download?file=filename.zip
i am worried about security as i am not even sure if this method would allow
people to download any file from the server.
maybe if you have time you can look at the script for me and find any flaws
While this method may not present a clear security danger, how does the 
data get into the database? If I can feed a filename of anything on 
your system that you blindly put in the database, then I can call it 
with an appropriate URL.

So... you can trust data coming from your database only if it was 
trusted/validated/sanitized going in. :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen/fpassthur

2004-12-14 Thread Richard Lynch




Sebastian wrote:
 Hi all,
 I have created a download manger to handle files, when a user clicks a
 link
 the file is sent though fopen() and fpassthru()
 like this:

fopen() + fpassthru() == http://php.net/readfile

 is this the most practical way of doing it? i don't want to display file
 location.. the script seems to be working okay, but i was just looking for
 opinions on the method. also, is it possible to insert a txt file on the
 fly
 if the file they're downloading is a ZIP file? if so, any ideas how?

Probably.

http://php.net/zlib should give you some ideas in that direction.

It would maybe be easier to start with all unzipped files, and zip them
with your text file when you send them out...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen/fpassthur

2004-12-14 Thread Richard Davey
Hello Sebastian,

Tuesday, December 14, 2004, 4:19:31 PM, you wrote:

S header(Content-type: application/octet-stream);
S header(Content-disposition: attachment; filename= . $file['filename']);
S header(Content-transfer-encoding: binary);
S header(Content-length:  . filesize($file['path'] . $file['filename']));

I use something almost identical, except I upper-case the second words
(Content-Type, Content-Disposition, etc). Not that I've found a
browser in active use yet that cares less, but there we go.

I'd fclose() when done, and no need to exit() - it's the last line of
your script anyway.

I hope you have some good data validation going on too :)

S is this the most practical way of doing it? i don't want to display
S file location.. the script seems to be working okay, but i was just

It is the way to do it, yes. You may get some varying suggestions re:
the correct headers to use though. But what you have will actually
work just fine (as you've found).

S also, is it possible to insert a txt file on the fly if the file
S they're downloading is a ZIP file? if so, any ideas how?

No, you cannot interrupt the stream. Or do anything after it for that
matter - you are simulating an HTTP request for a file, that is what
you're sending back. There is no way to inject something else into
this single transmission. Think of another way around it.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I am not young enough to know everything. - Oscar Wilde

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen/fpassthur

2004-12-14 Thread Richard Lynch
Richard Davey wrote:
 no need to exit() - it's the last line of
 your script anyway.

There was a bug in PHP for a very brief period of time where scripts were
not ending under some conditions after all the content was delivered.

If one is running that version of PHP, exit; at the end of a script is a
Good Thing.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen/fpassthur

2004-12-14 Thread Richard Lynch
Sebastian wrote:
 Q I hope you have some good data validation going on too :)

 I am not too sure about how secure it is. basically, the files are called
 by
 an ID
 eg, download?type=fileid=3

 so i query the db to get check if its a valid id and get the filename from
 the db as well.
 if its not found it errors out.. i was under the impression that is more
 secure to get files by an id from db than doing something like
 download?file=filename.zip

 i am worried about security as i am not even sure if this method would
 allow
 people to download any file from the server.
 maybe if you have time you can look at the script for me and find any
 flaws
 ;)

If you mean any of the potential downloads, you've got big problems. :-)

What's to stop somebody from trying id=4 and id=5 and so on and getting
*ALL* the files?

If you mean they could download *any* file, even the ones you're not
trying to let somebody download, it would be more efficient to see the
script itself to point out flaws, rather than just surfing to the site and
trying to break it.  Though that can be instructive too, especially if you
have acquired the same sort of tools your average script kiddie uses to
try to break in and steal stuff.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen/fpassthur

2004-12-14 Thread Sebastian
Q I hope you have some good data validation going on too :)

I am not too sure about how secure it is. basically, the files are called by
an ID
eg, download?type=fileid=3

so i query the db to get check if its a valid id and get the filename from
the db as well.
if its not found it errors out.. i was under the impression that is more
secure to get files by an id from db than doing something like
download?file=filename.zip

i am worried about security as i am not even sure if this method would allow
people to download any file from the server.
maybe if you have time you can look at the script for me and find any flaws
;)

thanks.

- Original Message - 
From: Richard Davey [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, December 14, 2004 12:27 PM
Subject: Re: [PHP] fopen/fpassthur


 Hello Sebastian,

 Tuesday, December 14, 2004, 4:19:31 PM, you wrote:

 S header(Content-type: application/octet-stream);
 S header(Content-disposition: attachment; filename= .
$file['filename']);
 S header(Content-transfer-encoding: binary);
 S header(Content-length:  . filesize($file['path'] .
$file['filename']));

 I use something almost identical, except I upper-case the second words
 (Content-Type, Content-Disposition, etc). Not that I've found a
 browser in active use yet that cares less, but there we go.

 I'd fclose() when done, and no need to exit() - it's the last line of
 your script anyway.

 I hope you have some good data validation going on too :)

 S is this the most practical way of doing it? i don't want to display
 S file location.. the script seems to be working okay, but i was just

 It is the way to do it, yes. You may get some varying suggestions re:
 the correct headers to use though. But what you have will actually
 work just fine (as you've found).

 S also, is it possible to insert a txt file on the fly if the file
 S they're downloading is a ZIP file? if so, any ideas how?

 No, you cannot interrupt the stream. Or do anything after it for that
 matter - you are simulating an HTTP request for a file, that is what
 you're sending back. There is no way to inject something else into
 this single transmission. Think of another way around it.

 Best regards,

 Richard Davey
 -- 
  http://www.launchcode.co.uk - PHP Development Services
  I am not young enough to know everything. - Oscar Wilde

 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen/fpassthur

2004-12-14 Thread Matt M.
 Hi all,
 I have created a download manger to handle files, when a user clicks a link
 the file is sent though fopen() and fpassthru()

you could try http://us3.php.net/readfile

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen by URL is disabled, is there another way of reading a remote webpage?

2004-10-20 Thread Greg Donald
On Wed, 20 Oct 2004 10:46:34 -0500, Chuck Barnett
[EMAIL PROTECTED] wrote:
 Hi, my new server has fopen by url disabled.  My ISP doesn't want to turn it
 on.  So is there a way to do an equivilant function some other way?  I need
 to read a remote webpage and manipulate it.

#!/usr/bin/php
?php
`wget http://yahoo.com`
?


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen by URL is disabled, is there another way of reading a remote webpage?

2004-10-20 Thread Jennifer Goodie
-- Original message from Chuck Barnett : -- 

 Hi, my new server has fopen by url disabled. My ISP doesn't want to turn it 
 on. So is there a way to do an equivilant function some other way? I need 
 to read a remote webpage and manipulate it. 
 
 Thanks, 
 Chuck 

You could use sockets. Here's an example from the archives
http://marc.theaimsgroup.com/?l=php-generalm=105052005332001w=2

The example is sending a POST, but you can easily change it to a GET.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen by URL is disabled, is there another way of readi ng a remote webpage?

2004-10-20 Thread Vail, Warren
CURL?

http://www.php.net/manual/en/ref.curl.php

Warren Vail
 


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 20, 2004 10:25 AM
To: Chuck Barnett
Cc: PHP General List
Subject: Re: [PHP] fopen by URL is disabled, is there another way of reading
a remote webpage?


-- Original message from Chuck Barnett : -- 

 Hi, my new server has fopen by url disabled. My ISP doesn't want to 
 turn it
 on. So is there a way to do an equivilant function some other way? I need 
 to read a remote webpage and manipulate it. 
 
 Thanks,
 Chuck 

You could use sockets. Here's an example from the archives
http://marc.theaimsgroup.com/?l=php-generalm=105052005332001w=2

The example is sending a POST, but you can easily change it to a GET.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and http://

2004-10-08 Thread Matt M.
 But I don't understand why I am getting that error about failed to open
 strem: HTTP request failed, when I can bring up the links fine in a
 browser on the server running the php script.  So can anyone help me out?
 Thanks

do you have allow_url_fopen enabled? 

http://us4.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and http://

2004-10-08 Thread Adam Williams
On Fri, 8 Oct 2004, Matt M. wrote:

  But I don't understand why I am getting that error about failed to open
  strem: HTTP request failed, when I can bring up the links fine in a
  browser on the server running the php script.  So can anyone help me out?
  Thanks
 
 do you have allow_url_fopen enabled? 
 
 http://us4.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen
 
 

Yes I do, in my php.ini I have:

;;
; Fopen wrappers ;
;;

; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and http://

2004-10-08 Thread Hendrik Schmieder
Adam Williams schrieb:
Hi, I'm having a problem with fopen and http files.  I keep getting the 
error:

Warning: fopen(http://zed/htdocs/rgfindingaids/series594.html ) 
[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 
Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
http://zed/htdocs/rgfindingaids/series594.html does not exist

But I don't understand why I am getting that error about failed to open 
strem: HTTP request failed, when I can bring up the links fine in a 
browser on the server running the php script.  So can anyone help me out?  
Thanks

 

What say phpinfo about Registered PHP Streams ?
  Hendrik
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen and http://

2004-10-08 Thread Adam Williams
On Fri, 8 Oct 2004, Hendrik Schmieder wrote:

 What say phpinfo about Registered PHP Streams ?
 
Hendrik
 
 

Hi, I think I just figured out my problem...I had to use rtrim($line) 
because I think there was a \n or an invisible character at the end of the 
line that was being passed to the http:// server from looking at the 
server's access_log and error_log files.  So now it works except on the 
very last line it processes, it prints does not exist, so there is still 
some sort of a hidden character but its not affecting fetching the URLs 
from the web server.  so i'm still trying to figure that last line out, 
but everything else works.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen and http://

2004-10-08 Thread Mulley, Nikhil
May be the path is not the correct ,just check with the Web Directory you configured 
to be and if its htdocs then I would say that its better to remove the htdocs from the 
path in fopen statement.

-Original Message-
From: Adam Williams [mailto:[EMAIL PROTECTED]
Sent: Friday, October 08, 2004 6:22 PM
To: [EMAIL PROTECTED]
Subject: [PHP] fopen and http://


Hi, I'm having a problem with fopen and http files.  I keep getting the 
error:

Warning: fopen(http://zed/htdocs/rgfindingaids/series594.html ) 
[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 
Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
http://zed/htdocs/rgfindingaids/series594.html does not exist

Warning: fopen(http://zed/htdocs/rgfindingaids/ser391.html ) 
[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 
Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
http://zed/htdocs/rgfindingaids/ser391.html does not exist

Warning: fopen(http://zed/htdocs/rgfindingaids/ser392.html ) 
[function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 
Not Found in /home/awilliam/public_html/rgfaidstest.php on line 15
http://zed/htdocs/rgfindingaids/ser392.html does not exist



I have a text file /home/awilliam/public_html/rgfaids containing URLs such 
as:

http://zed/htdocs/rgfindingaids/series594.html
http://zed/htdocs/rgfindingaids/ser391.html
http://zed/htdocs/rgfindingaids/ser392.html

and I can bring up these URLs fine in a browser on the PC i'm running the 
script on.

The following is my code:

?

$filelist = fopen(/home/awilliam/public_html/rgfaids, r);

if (!$filelist)
{
echo error opening rgfaids;
exit;
}

while ( !feof($filelist))
{
$line = fgets($filelist, 9);

$filetotest = fopen($line, r);

if (!$filetotest)
{
echo $line does not existbr;
}
elseif ($filetotest)
{
echo $line does exist;
}
}

?



But I don't understand why I am getting that error about failed to open 
strem: HTTP request failed, when I can bring up the links fine in a 
browser on the server running the php script.  So can anyone help me out?  
Thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen and http://

2004-10-08 Thread Andrew Kreps
On Fri, 8 Oct 2004 08:33:11 -0500 (CDT), Adam Williams
[EMAIL PROTECTED] wrote:
 So now it works except on the
 very last line it processes, it prints does not exist, so there is still
 some sort of a hidden character but its not affecting fetching the URLs
 from the web server.  so i'm still trying to figure that last line out,
 but everything else works.
 

That new problem you're having might just be an extra newline in the
file.  Make sure you don't have any blank lines at the end, or check
to make sure you actually have a URL to fetch before trying to grab
it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen problem, 5 line script

2004-09-16 Thread Chris Dowell
Irrelevant, Warren
Mag,
the point is that you're trying to use a function (filesize) that uses 
the stat() system call. This function is not supported using the http 
wrapper to fopen (because HTTP doesn't support it at all)

So regardless of whether you should be using the file name or the handle 
(it's the name, btw), the call will fail because you're trying to stat() 
a file which isn't supported.

Thus filesize() is failing (with a warning), and fread() is then failing 
because filesize() returns false, which evaluates to 0.

Hope this has made things clearer, if not, a quick check of the manual 
entries for stat, filesize and Appendix L 
(http://uk.php.net/manual/en/wrappers.php) may help

Cheers
chris
Vail, Warren wrote:
I thought filesize required the file name, and not the fileptr???
Warren Vail
-Original Message-
From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 15, 2004 10:17 AM
To: php php
Subject: Re: [PHP] fopen problem, 5 line script

* Thus wrote Mag:
 

Hi,
Can someone tell me what I am doing wrong here please?
?php
$fileptr =
fopen(http://www.google.com/index.html,r;);
$contents = fread($fileptr, filesize($fileptr));
...
This is the error I get:
Warning: filesize(): Stat failed for Resource id #1
(errno=2 - No such file or directory) in 
/home/quickxxx/public_html/tpg/ check- remote.php on line 4

Warning: fread(): Length parameter must be greater
than 0. in /
home/quickxxx/public_html/tpg/check-remote.php on line
   

filesize() relies on the fact that the file you opened has support for
stat(). the http wrapper does not have such a thing.
see:
 http://php.net/filesize
 http://php.net/wrappers.http
Curt
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen problem, 5 line script

2004-09-15 Thread Mark

--- Mag [EMAIL PROTECTED] wrote:

 Hi,
 Can someone tell me what I am doing wrong here please?
 
 ?php
 $fileptr =
 fopen(http://www.google.com/index.html,r;);
 
 $contents = fread($fileptr, filesize($fileptr));

http://us2.php.net/filesize
int filesize ( string filename)


 
 if(strstr($contents,
 href=\/froogle?hl=entab=wf\))
 { $result = 1;}else{ $result = 2;}
 
 echo $result;
 ?
 
 This is the error I get:
 Warning: filesize(): Stat failed for Resource id #1
 (errno=2 - No such file or directory) in
 /home/quickxxx/public_html/tpg/ check- remote.php on
 line 4
 
 Warning: fread(): Length parameter must be greater
 than 0. in /
 home/quickxxx/public_html/tpg/check-remote.php on line
 4
 2
 
 
 
 Any ideas?
 
 Thanks,
 Mag
 
 =
 --
 - The faulty interface lies between the chair and the keyboard.
 - Creativity is great, but plagiarism is faster!
 - Smile, everyone loves a moron. :-)
 
 
   
 __
 Do you Yahoo!?
 Yahoo! Mail - 50x more storage than other providers!
 http://promotions.yahoo.com/new_mail
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


=
Mark Weinstock
[EMAIL PROTECTED]
***
You can't demand something as a right unless you are willing to fight to death to 
defend everyone else's right to the same thing.
***



__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen problem, 5 line script

2004-09-15 Thread Curt Zirzow
* Thus wrote Mag:
 Hi,
 Can someone tell me what I am doing wrong here please?
 
 ?php
 $fileptr =
 fopen(http://www.google.com/index.html,r;);
 
 $contents = fread($fileptr, filesize($fileptr));
...
 
 This is the error I get:
 Warning: filesize(): Stat failed for Resource id #1
 (errno=2 - No such file or directory) in
 /home/quickxxx/public_html/tpg/ check- remote.php on
 line 4
 
 Warning: fread(): Length parameter must be greater
 than 0. in /
 home/quickxxx/public_html/tpg/check-remote.php on line

filesize() relies on the fact that the file you opened has support
for stat(). the http wrapper does not have such a thing.

see:
  http://php.net/filesize
  http://php.net/wrappers.http


Curt
-- 
The above comments may offend you. flame at will.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] fopen problem, 5 line script

2004-09-15 Thread Vail, Warren
I thought filesize required the file name, and not the fileptr???

Warren Vail


-Original Message-
From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 15, 2004 10:17 AM
To: php php
Subject: Re: [PHP] fopen problem, 5 line script


* Thus wrote Mag:
 Hi,
 Can someone tell me what I am doing wrong here please?
 
 ?php
 $fileptr =
 fopen(http://www.google.com/index.html,r;);
 
 $contents = fread($fileptr, filesize($fileptr));
...
 
 This is the error I get:
 Warning: filesize(): Stat failed for Resource id #1
 (errno=2 - No such file or directory) in 
 /home/quickxxx/public_html/tpg/ check- remote.php on line 4
 
 Warning: fread(): Length parameter must be greater
 than 0. in /
 home/quickxxx/public_html/tpg/check-remote.php on line

filesize() relies on the fact that the file you opened has support for
stat(). the http wrapper does not have such a thing.

see:
  http://php.net/filesize
  http://php.net/wrappers.http


Curt
-- 
The above comments may offend you. flame at will.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen problem, 5 line script

2004-09-15 Thread Mag

--- Curt Zirzow [EMAIL PROTECTED] wrote:

 * Thus wrote Mag:
  Hi,
  Can someone tell me what I am doing wrong here
 please?
  
  ?php
  $fileptr =
  fopen(http://www.google.com/index.html,r;);
  
  $contents = fread($fileptr, filesize($fileptr));
 ...
  
  This is the error I get:
  Warning: filesize(): Stat failed for Resource id
 #1
  (errno=2 - No such file or directory) in
  /home/quickxxx/public_html/tpg/ check- remote.php
 on
  line 4
  
  Warning: fread(): Length parameter must be greater
  than 0. in /
  home/quickxxx/public_html/tpg/check-remote.php on
 line
 
 filesize() relies on the fact that the file you
 opened has support
 for stat(). the http wrapper does not have such a
 thing.
 
 see:
   http://php.net/filesize
   http://php.net/wrappers.http
 
 


Thanks for your replies guys but you have left me even
more confused...can someone correct my 5 line script
and tell me what was wrong THEN give me the php.net
manual urls? like this am just getting more
confused...

Thanks,
Mag

=
--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)




__
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen problem, 5 line script [SOLVED!]

2004-09-15 Thread Mag
Got it,
'case anybody else needs this:

$page =
file_get_contents('http://www.google.se/index.html');
if(strstr($page,
'href=/imghp?hl=svtab=wiie=UTF-8'))
{
  $resultt = 1;
}
else
{
  $resultt = 2;
}

echo $resultt;

Cheers,
Mag

=
--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)



___
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen with login credentials being an email address

2004-07-09 Thread Curt Zirzow
* Thus wrote Gunter Sammet:
 Hi all:
 Tried to use fopen like this:
 
 fopen([EMAIL PROTECTED]:[EMAIL PROTECTED]);

I hope you have some sort of quotes around that.

 
 Didn't work and I couldn't find anything out on the search engines.

You simply cant have @ or : in the username, it violates the URL
specifications. A quick reading of your fopen would tell me to:

open a connection to 'mydomain.com' on port
'[EMAIL PROTECTED]', and send the username
'myname'.


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen with login credentials being an email address

2004-07-09 Thread Justin Patrin
Try using urlencode on the e-mail address.

On Thu, 8 Jul 2004 23:30:33 -0600, Gunter Sammet
[EMAIL PROTECTED] wrote:
 Hi all:
 Tried to use fopen like this:
 
 fopen([EMAIL PROTECTED]:[EMAIL PROTECTED]);
 
 Didn't work and I couldn't find anything out on the search engines.
 
 Any suggestions how to get this working?
 
 TIA
 
 Gunter
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 !DSPAM:40ee2b89115861429779826!
 
 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen with login credentials being an email address

2004-07-09 Thread Gunter Sammet
I tried that before manually with %40 and it didn't work. It's now valid but
Apache seems to not recognize the login credentials and sends me to the
login page. And that's the one I need to skip.

Thanks!

G.


Justin Patrin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Try using urlencode on the e-mail address.

 On Thu, 8 Jul 2004 23:30:33 -0600, Gunter Sammet
 [EMAIL PROTECTED] wrote:
  Hi all:
  Tried to use fopen like this:
 
  fopen([EMAIL PROTECTED]:[EMAIL PROTECTED]);
 
  Didn't work and I couldn't find anything out on the search engines.
 
  Any suggestions how to get this working?
 
  TIA
 
  Gunter
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
  !DSPAM:40ee2b89115861429779826!
 
 


 -- 
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder

 paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen with login credentials being an email address

2004-07-09 Thread Gunter Sammet
Yes I had quotes. And you're right the interpretation of the URL is as you
laid it out.

Unfortunatelly I don't have control on the login credentials. Tried %40 to
replace the @ but then it won't be accepted as a login.

Thanks for your reply!

G.



Curt Zirzow [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 * Thus wrote Gunter Sammet:
  Hi all:
  Tried to use fopen like this:
 
  fopen([EMAIL PROTECTED]:[EMAIL PROTECTED]);

 I hope you have some sort of quotes around that.

 
  Didn't work and I couldn't find anything out on the search engines.

 You simply cant have @ or : in the username, it violates the URL
 specifications. A quick reading of your fopen would tell me to:

 open a connection to 'mydomain.com' on port
 '[EMAIL PROTECTED]', and send the username
 'myname'.


 Curt
 -- 
 First, let me assure you that this is not one of those shady pyramid
schemes
 you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen with login credentials being an email address

2004-07-09 Thread Justin Patrin
Is your login page a real HTML page? In that case you could use PEAR's
HTTP_Client package to do the login and move on.

http://pear.php.net/package/HTTP_Client

On Fri, 9 Jul 2004 10:17:25 -0600, Gunter Sammet
[EMAIL PROTECTED] wrote:
 I tried that before manually with %40 and it didn't work. It's now valid but
 Apache seems to not recognize the login credentials and sends me to the
 login page. And that's the one I need to skip.
 
 Thanks!
 
 G.
 
 Justin Patrin [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Try using urlencode on the e-mail address.
 
  On Thu, 8 Jul 2004 23:30:33 -0600, Gunter Sammet
  [EMAIL PROTECTED] wrote:
   Hi all:
   Tried to use fopen like this:
  
   fopen([EMAIL PROTECTED]:[EMAIL PROTECTED]);
  
   Didn't work and I couldn't find anything out on the search engines.
  
   Any suggestions how to get this working?
  
   TIA
  
   Gunter
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
  
 
 
  --
  DB_DataObject_FormBuilder - The database at your fingertips
  http://pear.php.net/package/DB_DataObject_FormBuilder
 
  paperCrane --Justin Patrin--
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 !DSPAM:40eec33d305441786320709!
 
 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen with login credentials being an email address

2004-07-09 Thread raditha dissanayake
Gunter Sammet wrote:
Yes I had quotes. And you're right the interpretation of the URL is as you
laid it out.
Unfortunatelly I don't have control on the login credentials. Tried %40 to
replace the @ but then it won't be accepted as a login.
Thanks for your reply!
 

You need to use CHAP authentication, chap authentication in it's 
simplest form requires that the username password combination has to be 
sent as a base 64 encoded header. More details are available in RFC 2616 
but rather than reinventing the wheel you might want to use an available 
HTTP class or curl.

To elaborate futher you have to open a socket as curt suggested and when 
you get the 40x (can't remember the number) header saying authentication 
required, you need to respond by sending the header described above.

open a connection to 'mydomain.com' on port
'[EMAIL PROTECTED]', and send the username
'myname'.
   


--
Raditha Dissanayake.
-
http://www.raditha.com/megaupload/upload.php
Sneak past the PHP file upload limits.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen newbie question

2004-07-06 Thread Josh Close
Can you post your code so we can see what might be going on?

-Josh


On Mon, 5 Jul 2004 13:06:58 -0400, Joe Carey [EMAIL PROTECTED] wrote:
 I'm trying to read a text file from one server from another.  When I read
 from server A to B it works fine and I get the text output that I'm looking
 for.  But when I read from B to A I get Failed to open stream: FTP server
 reports 550 Can't check for file existence  I'm sure that its something how
 the server is configured but I can't figure out what I need to ask my host
 to change.  Any ideas please?
 
 Joe Carey
 
 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.712 / Virus Database: 468 - Release Date: 6/29/2004
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen successful..cant write to the file though permissions are ok..

2004-06-11 Thread Matt Matijevich
[snip]
$filename/tmp/newfile);
$filehandle=fopen($filename,w);
fclose($filehandle);
[/snip]

is this the exact code you are trying to use?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen errors

2004-02-19 Thread John Nichel
Hunter, Jess wrote:
Thanks for the reply, you are right, the file is going on a Linux box, but
the source file is located on the client computer (windoze).
You cannot open a remote file by using it's directory path on the remote 
system.  The two ways to do this would be to a) (recommended) open it 
with a URL, thus the 'client' computer would need to be running a web 
server, or b) mount the remote drive as a share on the *nix box, and 
access the file thru the share.

http://us4.php.net/manual/en/function.fopen.php

The addslashes was part of the original sample script.
It was probably made for text to be entered in a db, and in that case 
(if you are using MySQL), the function mysql_escape_string() would be a 
better choice...

http://us4.php.net/manual/en/function.mysql-escape-string.php

The storage would only be temporary, I intend to make it so when the file is
viewed, there will be an option to delete it.  The binary images would only
reside in the DB for 2-4 weeks tops.
Most seem to think (including myself) that it is better to store binary 
files in the file system, and put the text url/path to them in the db.

As for your suggestion to modify the script to meet my needs, that is what I
am trying to do...  Thanks for the assistance
Look in the manual for explanations of the functions you're trying to 
use.  Copying an example will rarely do what YOU need/want it to do, and 
you'll have a better understanding how to modify it by reading how the 
individual functions work.

-Original Message-
From:   John Nichel [SMTP:[EMAIL PROTECTED]
Please don't reply directly to me (or anyone else on the list) unless 
asked to do so.  When you just reply to an individual, your message does 
not make it into the list archives, and won't be searchable by the next 
person who comes along with the same problem (that is IF people would 
actually search the archives).
snip

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen errors

2004-02-18 Thread John Nichel
admin wrote:
I have a PHP front end with a MySQL back end with a longblob field.
Okay?

I am thinking the problem exists in the PHP part.
Probably not.

Here is the code I am using:

$fileHandle = fopen($fileUpload, r);
$fileContent = fread($fileHandle, $fileUpload_size);
$fileContent = addslashes($fileContent);
Then it goes into the Db connection part.

When I run the script I get the following error:

Warning: fopen(C:\\0-temp\\100_0078.jpg, r) -No such file or
directory in /var/www/testbed/httpdocs/blob/grabfile.php on line 41
Pretty self explanatory.

Warning Supplied argument is not a valid File-Handle resource in
/var/www/testbed/httpdocs/blob/grabfile.php on line 45
Direct result of the first error.

Then only thing that really jumps out at me in the file source path of
C:\\0-temp\\100_0078.jpg  there is a couple of extra Backslashes (\)
in the path statement.
This really should be quite obvious.  First, looks as if your script is 
running on a *nix box, yet you're trying to open a file using a Windoze 
directory structure.  I'm going to say that this won't work.  Two, it 
looks as if you're trying to read in an image...binary file...to enter 
it into a blob field in MySQL, so why are you going to 'addslashes()' to 
it?  Third.well, I won't open that can of worms about storing your 
images in the DB

I am using a sample script that pulled from one of the websites.
You need to modify the script to fit your environment.

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] fopen() Problems

2004-02-06 Thread Jason Wong
On Saturday 07 February 2004 07:08, [EMAIL PROTECTED] wrote:
 I am using the below code (kind of sloppy..).  I have tried for fopen r+,
 w, and w+, but no matter what I do, the file is always truncated, and
 previously entered data is erased.  I have been unable to fix this.

Assuming that you're trying to add something to the end of an existing file:

either fopen() using mode 'a' or use fseek().

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
In short, _N is Richardian if, and only if, _N is not Richardian.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Fopen and streams

2004-01-29 Thread firephreek
Ok, so, I solved the problem, but haven't necessarily figured it out.
I was using fopen() on a unique device, and getting a stream error.
Rewrote the func using the basic example for fsockopen.  I can now get
the data I need without the errors, but now, a new question:

If indeed there was some sort of incompatiblity between the scheme that
fopen() was using to get at my device, where do I start to find out what
kind of scheme I could be using?  Do I hunt down the manufacturer and
get some tech papers on their device?  Or could I / should I use
something like nmap, if that would work at all.   It just now occurred
to me, and I haven't tried it yet.

Secondly, where is a good place to read on the standards and formats
used by these different schemes.  In the fsockopen() func, I made some
writes to 'GET / ' and 'HTTP 1.1' etc... After reading the script, I
understand what these imply, but not the importance, also, what other
commmands are available to me.  Does that all make sense?  
I guess more simply put: How do I know what commands are availble to me
in the different protocals.  HTTP, FTP, UDP, etc...what if I wanted to
get at the data through straight TCP, is that possible?

Lastly, where should I go to read up on how to make my scripts run
faster?  I haven't written anything to large, but I'm generalyy paranoid
about overhead, esp in areas I probably don't need to be worried about.
Silly questions I suppose, like, is it more efficient to echo one long
string or echo parts of it on separate lines.  The latter is easier when
creating tables and such, because I can comment out individual lines to
hunt down bugs.  But does it make a difference in the runtime of the
script?  Etc

Stryder way too early right now Crown

-if God had meant for me to sleep right now, he wouldn't have invented
penguin mints.  Now in Cinnamon!



-Original Message-
From: stryder [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 28, 2004 7:54 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Fopen and streams


Hi, first time poster here.  

Having some trouble with a line that used to work, but doesn't now.

$pg = fopen(http://$ip/mypage;, r);

Gets me:

Warning: fopen(http://10.1.1.233/mypage): failed to open stream: HTTP
request failed! 

And then it spits out the data from that page anyways.  What's going on
here?  This was working on my other box a few days ago.  
And I've tried it with and without the variable for the ip address/url.

--Stryder

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Fopen and streams

2004-01-29 Thread Mike Migurski
Secondly, where is a good place to read on the standards and formats used
by these different schemes.  In the fsockopen() func, I made some writes
to 'GET / ' and 'HTTP 1.1' etc... After reading the script, I understand
what these imply, but not the importance, also, what other commmands are
available to me.  Does that all make sense?  I guess more simply put: How
do I know what commands are availble to me in the different protocals.
HTTP, FTP, UDP, etc...what if I wanted to get at the data through
straight TCP, is that possible?

Most protocols are documented in RFC's, such as these:
http://www.w3.org/Protocols/rfc2616/rfc2616.html
http://ftp.ics.uci.edu/pub/ietf/http/rfc1945.html
http://www.ietf.org/rfc/rfc0959.txt
http://www.faqs.org/rfcs/rfc768.html
http://www.ibiblio.org/pub/docs/rfc/rfc793.txt

Lastly, where should I go to read up on how to make my scripts run
faster?  I haven't written anything to large, but I'm generalyy paranoid
about overhead, esp in areas I probably don't need to be worried about.
Silly questions I suppose, like, is it more efficient to echo one long
string or echo parts of it on separate lines.  The latter is easier when
creating tables and such, because I can comment out individual lines to
hunt down bugs.  But does it make a difference in the runtime of the
script?  Etc

Knuth's quote, We should forget about small efficiencies, say about 97%
of the time:  premature optimization is the root of all evil, was
probably intended to refer to optimizations like those. I wouldn't worry
about them, especially if shaving a few milliseconds off your script is
going to make it a nightmare to debug or revisit.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen

2003-12-29 Thread Cesar Aracena
Now it gives me the following error message:

Warning: fopen(websitename/esp/files/welcome.txt): failed to open stream: No
such file or directory in d:\wwwroot\websitename\esp\lib\functions.php on
line 6

But the file exists and so does the folder it is into. What can be wrong? I
also uploaded the file to my Unix web server for testing purposes, CHMOD the
folder to 777 and linked to the file but then other error appeared. When I
tried with rb for fopen it gave me the same error saying that the file was
missing... ???

Thanks,

Gerard Samuel [EMAIL PROTECTED] escribiĆ³ en el mensaje
news:[EMAIL PROTECTED]
 On Sunday 28 December 2003 11:17 pm, Cesar Aracena wrote:
   $fp = fopen(../files/welcome.txt, a+);
 

 Change to
 $fp = fopen(../files/welcome.txt, r);

 Use r to read, when you use a it appends (or adds) to the file
 Its also suggested to use the b option to so it would look like
 $fp = fopen(../files/welcome.txt, rb);

 That is done for portability between *nix and windows.

 More info is at the manual
 http://us2.php.net/manual/en/function.fopen.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen

2003-12-29 Thread Gerard Samuel
On Monday 29 December 2003 09:50 am, Cesar Aracena wrote:
 Now it gives me the following error message:

 Warning: fopen(websitename/esp/files/welcome.txt): failed to open stream:
 No such file or directory in d:\wwwroot\websitename\esp\lib\functions.php
 on line 6

 But the file exists and so does the folder it is into. What can be wrong? I
 also uploaded the file to my Unix web server for testing purposes, CHMOD
 the folder to 777 and linked to the file but then other error appeared.
 When I tried with rb for fopen it gave me the same error saying that the
 file was missing... ???

 Thanks,


I cant say why you may be experiencing this error.
The only thing wrong with your original code was you were trying to read a 
file, with fopen in append mode which is wrong.
Maybe start with reading files that live in the same directory as the calling 
script, and work your way out from there...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen

2003-12-28 Thread Gerard Samuel
On Sunday 28 December 2003 11:17 pm, Cesar Aracena wrote:
  $fp = fopen(../files/welcome.txt, a+);


Change to
$fp = fopen(../files/welcome.txt, r);

Use r to read, when you use a it appends (or adds) to the file
Its also suggested to use the b option to so it would look like
$fp = fopen(../files/welcome.txt, rb);

That is done for portability between *nix and windows.

More info is at the manual
http://us2.php.net/manual/en/function.fopen.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen url

2003-12-10 Thread prashant
Dear Friends

These is my sample code

test1.html

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
HTML
HEAD
TITLE New Document /TITLE
META NAME=Generator CONTENT=EditPlus
META NAME=Author CONTENT=
META NAME=Keywords CONTENT=
META NAME=Description CONTENT=
/HEAD

BODY

form name=frm1 method=POST action=test1.php3
enctype=multipart/form-data
input type=text name=text1 value=
input type=file name=file1
input type=submit name=btnsubmit value=Submit
/form

/BODY
/HTML


test1.php3

html
headtitleTest Page/title/head
body

form

?
echo $text1;
echo $file1;
echo $file1_name;
copy($file1,d:\prashant\$file1);
?

/form
/body
/html

I am Facing the problem that if i use enctype=multipart/form-data in form
object
then i am unable to retrieve the values passed from .html form.

So if i am using a File Upload control in my form without the enctype
attribute,then i get a warning message

Unable to open '' for reading: No such file or directory in
/home/httpd/html/fai/test1.php3 on line 12

i.e My HTML Form with Post Method and enctype
attribute=multipart/form-data is not working for passing data to the web
server.

The problem can be solved without the enctype attribute in the Form Tag
where i can send the Data to the
Web Server and the values getting retrieved in another Php Page, but what
about if i have to upload
a File using the File Upload control input type=file name=file1 in my HTML
Form.

It Fails in this case where i get the warning message.

Can somebody help me in this regard as soon as possible ???

Thanks,
Prashant S Akerkar



- Original Message -
From: Jason Wong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, November 08, 2003 3:37 PM
Subject: Re: [PHP] fopen url


 On Saturday 08 November 2003 08:21, John Hagstrand wrote:

  Thanks for your snot.

 They were surplus to requirements so you're welcome to them.

   The code you wrote below,
 
 echo fopen(http://www.google.com;, 'r');
 echo fopen(http://news.google.com;, 'r');
 
  I've implmented at this url.
  http://www.globalscoop.com/gs/feeds/testUrl.php
 
  You can see the error I'm getting.  Would you take a look?

 No. Would you mind posting the error you're getting so that everyone can
see?
 And please confirm that whatever error you're getting is in response to
the
 exact code as above.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Caution: Keep out of reach of children.
 */

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fopen custom 404 issue

2003-12-10 Thread Jason Wong
On Thursday 11 December 2003 08:48, Mike D wrote:
 I am trying to read in a particular page to a variable. How do you handle
 if the page is a 404 and then redirects to a custom error page? Am I
 supposed to use fsockopen and read headers or ?? Ideally I need to pull the
 end-result page to search for a string in it.

Or you try using Amazon's web services API.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
All is fear in love and war.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  1   2   3   >