Dallas Clymer
Dallas Clymer

Reputation: 105

port check Error?

Hey everyone i just got my port checker to work with a dynamic image but a bad error occurs if the server is offline any help?

Here is what it says: image too small: http://3nerds1site.com/test/finalimage.php?ip=blacknscape.no-ip.biz&port=80 enter image description here

this is how it should look but only works when it's online? enter image description here

but anyways heres my code i do not believe its a code problem maybe my webhost which is hostgator?

<?php
    $ip      = $_GET["ip"];
    $port    = $_GET["port"];
    $online  = "Online";
    $offline = "Offline";

    $status = fsockopen($ip, $port) ? $online : $offline;

    // Create a blank image and add some text
    $im         = imagecreatetruecolor(215, 86);
    $text_color = imagecolorallocate($im, 233, 14, 91);

    // sets background to Light Blue
    $LightBlue = imagecolorallocate($im, 95, 172, 230);
    imagefill($im, 0, 0, $LightBlue);

    //Server Information
    imagestring($im, 7, 5, 5, '3Nerds1Site.com', $text_color);
    imagestring($im, 2, 40, 30, $ip, $text_color);
    imagestring($im, 2, 40, 40, $port, $text_color);
    imagestring($im, 2, 40, 70, $status, $text_color);

    // Set the content type header - in this case image/jpeg
    header('Content-Type: image/png');

    // Output the image
    imagepng($im);

    // Free up memory
    imagedestroy($im);
?>

Upvotes: 0

Views: 124

Answers (1)

Sammitch
Sammitch

Reputation: 32242

  1. Post your code here, not on pastebin.
  2. Change:

    $status = (fsockopen($ip, $port));
    

    To:

    $status = (@fsockopen($ip, $port));
    

    The @ suppresses error messages when you're doing something ridiculous like this.

  3. Alternatively, just turn off error reporting with error_reporting(0);.

Upvotes: 1

Related Questions