OK guys,

Just in case you are interested, I found a faster solution than fopen()

--------------------------------------------------------------------------------------------------
<?
function url_exists($strURL) {
   $resURL = curl_init();
   curl_setopt($resURL, CURLOPT_URL, $strURL);
   curl_setopt($resURL, CURLOPT_BINARYTRANSFER, 1);
   curl_setopt($resURL, CURLOPT_HEADERFUNCTION, 'curlHeaderCallback');
   curl_setopt($resURL, CURLOPT_FAILONERROR, 1);

   curl_exec ($resURL);

   $intReturnCode = curl_getinfo($resURL, CURLINFO_HTTP_CODE);
   curl_close ($resURL);

   if ($intReturnCode != 200 && $intReturnCode != 302 && $intReturnCode !=
304) {
      return false;
   }Else{
       return true ;
   }
}

//need here because it spills all kinds of crap
ob_start();

//Usage Example :
If(url_exists("http://www.weberdev.com/addexample.php3";)) {
   ob_end_clean();   // need to clean returned crap and start printing your
stuff
   Echo"URL Exists";
}Else{
   Echo"URL doesnot exist";
}
?>
-----------------------------------------------------------------


Thanks,

Néstor :-)


On 1/4/07, Néstor <[EMAIL PROTECTED]> wrote:

file_exists() still returns false when using the local network name

 Thanks,

Néstor :-)

On 1/4/07, Andy Dirnberger < [EMAIL PROTECTED]> wrote:
>
>  If the server is on a local network, are you able to access the files
> through the network?  Something like file_exists
> ("\\sharename\path\to\file")
>
>
>  ------------------------------
>
> *From:* [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] *On Behalf Of *Néstor
> *Sent:* Thursday, January 04, 2007 2:21 PM
> *To:* NYPHP Talk
> *Subject:* Re: [nyphp-talk] Accessing a file in another web server
>
>
>
> It is an internal intranet page and I am accessing word(.doc) or pdf
> files that are open when I type the url on the address bar on my browser.
>
> :-)
>
> On 1/4/07, *Néstor* <[EMAIL PROTECTED]> wrote:
>
> Tom,
>
> I had just tried this and it works but it makes the entire web page very
> slow to render.
> See the page that I am dealing with needs to do this check in several
> places.
>
> One thing is that you need to use the fopen() with an '@' to suppress
> warnings when
> the file does not exist.
>
> The fopen() fixes my problem but it is slow rendering. I will try to
> find another solution.
>
> Thanks,
>
> néstor :-)
>
>
>
> On 1/4/07, *Tom Melendez* <[EMAIL PROTECTED]> wrote:
>
> Hi Néstor,
>
> What happens if you do a basic fopen on the file (assuming that
> allow_open_url is set to On in php.ini)?
>
> Tom
> http://www.liphp.org
>
>
> On 1/4/07, Néstor < [EMAIL PROTECTED]> wrote:
> > I have tried all of those and they return false weather the file is
> exist
> > and is readable or not
> > I have tried file_exists()
> >                 stat()
> >                 is_readable()
> >
> > Wow, I never thought that this would be a problem.....
> >
> > Thanks,
> >
> > Néstor :-)
> >
> > On 1/4/07, Andy Dirnberger < [EMAIL PROTECTED]> wrote:
> > > There are a few url_exists functions in the manual:
> > > http://us3.php.net/file_exists
> > >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> ]
> > On
> > > Behalf Of Jonathan Face
> > > Sent: Thursday, January 04, 2007 1:34 PM
> > > To: NYPHP Talk
> > > Subject: Re: [nyphp-talk] Accessing a file in another web server
> > >
> > > I haven't had a reason to experiment with this before, but you might
> try
> > > out:
> > > file_exists($url);
> > >
> > > Néstor wrote:
> > >
> > > > People,
> > > >
> > > > I am trying to determine if a file exist in a another web server
> > > > and if it does exist then I will display the link of the file.
> > > >
> > > > I tried is_readable() and stat() and they both say that the file
> does
> > not
> > > > exist, but the file does exist.
> > > >
> > > > What function should I use to check for existance of a file
> > > > on a different web server???
> > > >
> > > > Thanks,
> > > >
> > > > Néstor :-)
> > > >
> > >
> >
> >------------------------------------------------------------------------
> > > >
> > > >_______________________________________________
> > > >New York PHP Community Talk Mailing List
> > > >http://lists.nyphp.org/mailman/listinfo/talk
> > > >
> > > >NYPHPCon 2006 Presentations Online
> > > > http://www.nyphpcon.com
> > > >
> > > >Show Your Participation in New York PHP
> > > > http://www.nyphp.org/show_participation.php
> > > >
> > >
> > > _______________________________________________
> > > New York PHP Community Talk Mailing List
> > > http://lists.nyphp.org/mailman/listinfo/talk
> > >
> > > NYPHPCon 2006 Presentations Online
> > > http://www.nyphpcon.com
> > >
> > > Show Your Participation in New York PHP
> > > http://www.nyphp.org/show_participation.php
> > >
> > > _______________________________________________
> > > New York PHP Community Talk Mailing List
> > > http://lists.nyphp.org/mailman/listinfo/talk
> > >
> > > NYPHPCon 2006 Presentations Online
> > > http://www.nyphpcon.com
> > >
> > > Show Your Participation in New York PHP
> > > http://www.nyphp.org/show_participation.php
> > >
> >
> >
> > _______________________________________________
> > New York PHP Community Talk Mailing List
> > http://lists.nyphp.org/mailman/listinfo/talk
> >
> > NYPHPCon 2006 Presentations Online
> > http://www.nyphpcon.com
> >
> > Show Your Participation in New York PHP
> > http://www.nyphp.org/show_participation.php
> >
> >
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>
>
>
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to