WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Check for an internet connection
Categories : PHP, HTTP
bastien koert
Date : Oct 15th 2004
Grade : 2 of 5 (graded 5 times)
Viewed : 14195
File : No file for this code example.
Images : No Images for this code example.
Search : More code by bastien koert
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

In writing a recent distributed db application (using AMP) I needed to find a way to check if the local machine had access to the internet, to be able to update the db at the master site. So I wrote this.

It uses fsockopen() to open a connection to a remote website, substitute yours in, and looks on ports 80 for http connections or 443 for SSL connections.

When called the function returns true id connected or false if not.




//-----------------------------------------------------------------------------
// is_connected function to check for internet connection
//-----------------------------------------------------------------------------

<?php
function is_connected()
{
   
//check to see if the local machine is connected to the web
    //uses sockets to open a connection to apisonline.com
   
$connected = @fsockopen("www.some_domain.com", [80|443]);
    if (
$connected){
       
$is_conn = true;
       
fclose($connected);
    }else{
       
$is_conn = false;
    }
    return
$is_conn;
   
}
//end is_connected function
?>



Pseudo Non Parsed Header. Output to the the browser as the script runs.
Categories : PHP, HTTP, HTML and PHP
Upload Script, Upload File Script, Input Type="File"
Categories : PHP, HTML and PHP, HTTP
This script shows you the 7th latest php items from the mailing list archive on zend.com
Categories : HTML, HTML and PHP, HTTP, PHP
Request Method Class - seful for situations like form processing or API development. Requires PHP5 for the magic __call() method.
Categories : PHP, PHP Classes, HTTP, Headers
Inserting data to a MySQL Database using AJAX
Categories : AJAX, HTTP, PHP, Databases, MySQL
The simple counter with use MySql and gd.
Categories : MySQL, HTTP, Graphics, PHP, Databases
HTTP Basic Authentication via POP3.
Categories : Authentication, HTTP, Email, PHP
Simple Password example
Categories : PHP, Authentication, Security, HTTP
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Grab links from a page
Categories : PHP, Regexps, HTTP
Forcing a proxy to not cache a document
Categories : HTTP, PHP
redirect redirection ip address authentication authenticate addr
Categories : Authentication, HTTP, Network, PHP
Gonx Proxy - This class is meant to act as an HTTP proxy to serve pages of a remote server as if they were local pages.
Categories : PHP, PHP Classes, HTTP
Easy upload class
Categories : PHP Classes, Filesystem, HTTP, PHP
Simple pipe delimited file export program that downloads to a local machine
Categories : PHP, Filesystem, Databases, MySQL, HTTP
 vikas agrawal wrote :1219
You can better check the internet connection using 
system("ifconfig"); and check for the ppp part of the output and find out the ip address allocated by the isp