Volkova

PHP Check Online V0.01

Jun 26th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. <?php
  2. /*
  3. *    +--------------------------------------------------------------+
  4. *    | Volkova Online Checking                                      |
  5. *    +--------------------------------------------------------------+
  6. *    |                                                              |
  7. *    | Author: Ryan                                                 |
  8. *    | Version: 0.01                                                |
  9. *    |                                                              |
  10. *    |                                                              |
  11. *    |                                                              |
  12. *    +--------------------------------------------------------------+
  13. */
  14. error_reporting(0); //If you can not connect to the url you get an error, so by turning error reporting off, you avoid this.
  15.  
  16. $name = "Ryan";
  17. $url = "2.126.10.113:80";
  18.  
  19. function get_url_contents($url){
  20.     $crl = curl_init();
  21.     $timeout = 3;
  22.     curl_setopt ($crl, CURLOPT_URL,$url);
  23.     curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
  24.     curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
  25.     $ret = curl_exec($crl);
  26.     curl_close($crl);
  27.     return $ret;
  28. }
  29.  
  30. $str = get_url_contents($url);
  31.  
  32. $im = imagecreatetruecolor(125, 25);
  33. $colour = imagecolorallocate($im, 255, 255, 255);
  34.  
  35. imagefill($im, 0, 0, $colour); //Fill the image with white
  36.  
  37. $black = imagecolorallocate($im, 0, 0, 0);
  38. $green = imagecolorallocate($im, 121, 212, 121);
  39. $red = imagecolorallocate($im, 209, 62, 62);
  40.  
  41. imagestring($im, 3, 5, 5,  "$name is: ", $black);
  42.  
  43. if ( $str ) {
  44.     imagestring($im, 3, 65, 5,  "Online", $green);
  45. } else {
  46.     imagestring($im, 3, 65, 5,  "Offline", $red);
  47. }
  48.  
  49. header('Content-Type: image/jpeg');
  50.  
  51. imagejpeg($im, NULL, 100);
  52.  
  53. imagedestroy($im);
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment