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 : Ping a Server and run a command to fix it if it is down
Categories : PHP, Errors and Logging, Regexps Update Picture
Antonio Leal
Date : Aug 13th 2003
Grade : 3 of 5 (graded 3 times)
Viewed : 21139
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Antonio Leal
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 


Autor: Antonio Leal Elizondo 12/Ago/03
e-mail: invasor@hotmail.com
This script pings a machine and checks if it's alive or not.
It can run a command in case the machine is not answering

<?php
// Variables
//-------------------------
   
$unix      1; //Put 1 here if you are using a UNIX machine
   
$windows   0; //Put 1 here if you are using a Windown machine


   
$unix = (bool) $unix;
   
$win  = (bool)  $windows;

   
$count= 3;                            // Number of times to ping
   
$host   = "177.17.31.165";             // IP of the remote server
   
$find = "Tiempo de espera agotado";   // String to look for
   
$shell= "pwd";                          // Command to execute if the machine does not answer.
   
$findUnix="0 packets received";


     
// Replaced nonvalued characters     
     
$host= preg_replace ("/[^A-Za-z0-9.]/","",$host);
      echo(
"Resultados: ");
       
     
//Check the IP
     
if ($unix==1){
         
$comm="ping -t $count $host";
         
$res=shell_exec($comm);
      }else{
         
$comm="ping -n $count $host";
         
$res=shell_exec($comm);
      }
     
//  system("killall ping");// Kill all pings in case they exist.
      //echo $res;

     
$flag= strstr($res,$findUnix);
     
$long=strlen($flag);
     if (
$long<>0){
       echo
"\n An error has occured at $host\n ";
       echo   
date("D F Y  h:i a");
       echo
"\n Executng auxiliary command \n ";
       
$res=shell_exec($shell);
        echo
$res;
      }else{
       echo
"\n There are no problems with $host \n";
      echo   
date("D F Y  h:i a"). "\n" ;
     }
?>




DB Connection Function with error handling and email failure notices
Categories : PHP, MySQL, Errors and Logging, Databases, Errors and Logging
php table decoder used to convert an html table to individual tokens through regular expressions
Categories : PHP, Regexps, HTML and PHP
This script is a contact form between users of a website (kinda like the PM function on the forums)
Categories : PHP, Databases, MySQL, Regexps
Simple way to replace a variable value in a .conf (.ini) file using a webbrowser - the first stage of a complete universal configuration editor
Categories : PHP, Regexps, Code Editors, Filesystem
A Custom Error Handling And Debugging Class
Categories : PHP, PHP Classes, Debugging, Errors and Logging
columned txt file to array()?
Categories : Arrays, Strings, Regexps, PHP
ereg -- Regular expression match
Categories : PHP, PHP Functions, Regexps
Parse html (title :: meta)
Categories : PHP, HTML and PHP, Regexps
Simple PHP program which calls other PHP program you can pass the variables to other PHP program : by Raju
Categories : PHP, PHP Options and Info, Regexps, Program Execution
Parsing Simple Template Files and Data
Categories : PHP, PHP Classes, Templates, Regexps
Clever Email Validation Function - E-Mail validation function with an eregi expression and socket connection.
Categories : Email, PHP, Regexps
Form input return conformance
Categories : HTML and PHP, PHP, Regexps
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Check for functional file links (broken Files)
Categories : PHP, Data Validation, FTP, Regexps, Arrays
Grab links from a page
Categories : PHP, Regexps, HTTP