php-general Digest 20 Dec 2009 12:47:42 -0000 Issue 6497

Topics (messages 300592 through 300600):

Re: Checking for internet connection.
        300592 by: Ashley Sheridan
        300593 by: Angus Mann
        300594 by: Ashley Sheridan
        300595 by: John Corry
        300596 by: Phpster
        300598 by: Andy Shellam
        300599 by: LinuxManMikeC

PHP and SEO Workarounds
        300597 by: Gautam Bhatia
        300600 by: Ashley Sheridan

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Sun, 2009-12-20 at 10:13 +1000, Angus Mann wrote:

> Hi all.
> 
> I'w writing a PHP app that is designed to run over a LAN, so internet 
> connection for the server is not really essential. Some users may 
> deliberately not connect it to the internet as a security precaution.
> 
> But I'd like the app to make use of an internet connection if it exists to 
> check for an update, and notify the user.
> 
> Is there a simple way for a PHP script to check if it has an internet 
> connection?
> 
> I thought of this :
> 
> if(fsockopen("www.google.com", 80)){
>     // we are connected
> }
> 
> Is this OK or is there something better for the purpose?
> 
> 
> 


Why can't you put the update on the same LAN server that the app
resides?

If that is not possible, what about using CURL, and update if it can
connect successfully, but don't if it cannot?

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Why can't you put the update on the same LAN server that the app resides?

If that is not possible, what about using CURL, and update if it can connect 
successfully, but don't if it cannot?

      Thanks,
      Ash
      http://www.ashleysheridan.co.uk

      Since the LAN is remote (many hundreds of miles away) from the source of 
the update, the only practical way to deliver an update every month or week to 
multiple users is to make it available for download from a central "update 
server".

      I'm just trying to maximize efficiency by checking if an internet 
connection exists, and abandoning further attempts to check for update 
availability if it does not.

      The idea to use CURL seems valid, but it pre-supposes that I know the 
answer to my own question. To use your suggestion, I'd have to have some 
mechanism to detect if it "can connect successfully". I'm asking what that 
mechanism should be, and if the one I've suggested is good, or flawed in some 
way. 



     

--- End Message ---
--- Begin Message ---
On Sun, 2009-12-20 at 10:36 +1000, Angus Mann wrote:

> Why can't you put the update on the same LAN server that the app resides?
> 
> If that is not possible, what about using CURL, and update if it can connect 
> successfully, but don't if it cannot?
> 
>       Thanks,
>       Ash
>       http://www.ashleysheridan.co.uk
> 
>       Since the LAN is remote (many hundreds of miles away) from the source 
> of the update, the only practical way to deliver an update every month or 
> week to multiple users is to make it available for download from a central 
> "update server".
> 
>       I'm just trying to maximize efficiency by checking if an internet 
> connection exists, and abandoning further attempts to check for update 
> availability if it does not.
> 
>       The idea to use CURL seems valid, but it pre-supposes that I know the 
> answer to my own question. To use your suggestion, I'd have to have some 
> mechanism to detect if it "can connect successfully". I'm asking what that 
> mechanism should be, and if the one I've suggested is good, or flawed in some 
> way. 
> 
> 
> 
>      


I think the only way to detect if it can connect to the Internet is to
see if you can grab a file from somewhere on the Internet. I'd hazard a
guess that when operating systems are able to tell you they can "connect
to the Internet" they are actually saying they can ping a predetermined
remote host. I think checking if PHP can grab a remote file with Curl
would be sufficient in this case.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message --- Curl_init() will return a resource or false if it fails, like it would if no Internet connection were present.

J Corry
Sent from my iPhone

On Dec 19, 2009, at 5:36 PM, "Angus Mann" <angusm...@pobox.com> wrote:


Why can't you put the update on the same LAN server that the app resides?

If that is not possible, what about using CURL, and update if it can connect successfully, but don't if it cannot?

     Thanks,
     Ash
     http://www.ashleysheridan.co.uk

Since the LAN is remote (many hundreds of miles away) from the source of the update, the only practical way to deliver an update every month or week to multiple users is to make it available for download from a central "update server".

I'm just trying to maximize efficiency by checking if an internet connection exists, and abandoning further attempts to check for update availability if it does not.

The idea to use CURL seems valid, but it pre-supposes that I know the answer to my own question. To use your suggestion, I'd have to have some mechanism to detect if it "can connect successfully". I'm asking what that mechanism should be, and if the one I've suggested is good, or flawed in some way.





--- End Message ---
--- Begin Message --- The next way to handle this might be to code an AIR app. Then it's a simple js trap to see if connectivity exists.

Bastien

Sent from my iPod

On Dec 19, 2009, at 7:13 PM, "Angus Mann" <angusm...@pobox.com> wrote:

Hi all.

I'w writing a PHP app that is designed to run over a LAN, so internet connection for the server is not really essential. Some users may deliberately not connect it to the internet as a security precaution.

But I'd like the app to make use of an internet connection if it exists to check for an update, and notify the user.

Is there a simple way for a PHP script to check if it has an internet connection?

I thought of this :

if(fsockopen("www.google.com", 80)){
  // we are connected
}

Is this OK or is there something better for the purpose?



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


--- End Message ---
--- Begin Message ---
> 
> I think the only way to detect if it can connect to the Internet is to
> see if you can grab a file from somewhere on the Internet. I'd hazard a
> guess that when operating systems are able to tell you they can "connect
> to the Internet" they are actually saying they can ping a predetermined
> remote host. I think checking if PHP can grab a remote file with Curl
> would be sufficient in this case.

Personally, I'd do a DNS lookup - even connecting to a server is a lot more 
overhead than a simple DNS request.  You could force the DNS server to be one 
external to your network - e.g. dig @a.root-servers.net www.google.co.uk.  If 
the dig command fails, you're not connected.

Or just try and get the update anyway - if the download fails, you're not 
connected (or there's something wrong with the update server.)

--- End Message ---
--- Begin Message ---
On Sun, Dec 20, 2009 at 2:32 AM, Andy Shellam <andy-li...@networkmail.eu> wrote:
>>
>> I think the only way to detect if it can connect to the Internet is to
>> see if you can grab a file from somewhere on the Internet. I'd hazard a
>> guess that when operating systems are able to tell you they can "connect
>> to the Internet" they are actually saying they can ping a predetermined
>> remote host. I think checking if PHP can grab a remote file with Curl
>> would be sufficient in this case.
>
> Personally, I'd do a DNS lookup - even connecting to a server is a lot more 
> overhead than a simple DNS request.  You could force the DNS server to be one 
> external to your network - e.g. dig @a.root-servers.net www.google.co.uk.  If 
> the dig command fails, you're not connected.
>
> Or just try and get the update anyway - if the download fails, you're not 
> connected (or there's something wrong with the update server.)

By attempting to connect you will implicitly query DNS (which itself
is a connection to server).  If you're not online you won't be able to
resolve the domain name.  Hence no overhead of actually connecting,
because that won't even start to happen until the hostname is resolved
to an IP.  If it happens to resolve from some cache, oh well.  Not
like its that much overhead.  You're nitpicking over the number of
packets it takes to SYN/ACK.

--- End Message ---
--- Begin Message ---
hey folks,
                This is in regards to SEO and PHP, From what i have
read , most (Not all) the PHP Contents is dynamic , which makes it so
powerfull , but it also means that chances of it being indexed in search
engines are less , am i right in saying this ? . If so how do i optimize
my site  for search engines which is being powered by PHP and content is
Dynamic. Please guide in this regard. Thank you.

Regards,
Gautam Bhatia
mail2gautambha...@gmail.com

--- End Message ---
--- Begin Message ---
On Sun, 2009-12-20 at 12:15 -0500, Gautam Bhatia wrote:

> hey folks,
>                 This is in regards to SEO and PHP, From what i have
> read , most (Not all) the PHP Contents is dynamic , which makes it so
> powerfull , but it also means that chances of it being indexed in search
> engines are less , am i right in saying this ? . If so how do i optimize
> my site  for search engines which is being powered by PHP and content is
> Dynamic. Please guide in this regard. Thank you.
> 
> Regards,
> Gautam Bhatia
> mail2gautambha...@gmail.com


This is a point you'll see mentioned by most SEO 'experts' none of whom
I've seen can provide any evidence of this. Just think about the last
time you searched for the answer to a question online. I'd hazard a
guess that the most popular results had dynamic URL's such as forum
posts, etc.

While it is true that the URL of a page has some weight to the pages
ranking, it's miniscule compared to the actual content of the page.
There might be an issue with blogs though, the ones where new old posts
get pushed to other pages. So a story that appears on blog.php?page=1
might tomorrow appear on page=2, and then page=3 the day after. If you
have a setup like this, then you could benefit from making more static
type links for the posts, like Wordpress does.

More important for your SEO is getting the content correctly marked up,
i.e. headings in <h_> tags, alt text for images, etc. There's a good
tool for checking these sorts of things at http://nibbler.silktide.com 

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---

Reply via email to