Jump to content

I need help shorting my script


jet8791

Recommended Posts

i need help shorting this script asap

i need all the fsockopen's the combined into one and if the optional varables arnt set then dont include them.

i am willing to offer 10GB of online storage with unlimited bandwidth

 
//the variables
/*
$line[0] is the address
$line[1] is a port (required)
$line[2] is a port (optional)
$line[3] is a port (optional)
$line[4] is a port (optional)
*/
$fp = fsockopen ($line[0],$line[1], $errno, $errstr, 10);
    if (!$fp) {
    echo "<br><b>Checking $line[0]...</b><br>\n";
    echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
        echo "<td>Status: Down, Domain: $line[0], Port: $line[1]</td>\n";
           echo "</tr>\n<tr>\n";
   echo "</tr></table>\n";
    } else {
        echo "<br><b>Checking $line[0]...</b><br>\n";
    echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
        echo "<td>Status: Up, Domain: $line[0], Port: $line[1]$a</td>\n";
                   echo "</tr>\n<tr>\n";
   echo "</tr></table>\n";
    }
    fclose($fp);
    if($line[2] != ""){
$fp = fsockopen ($line[0], $line[2], $errno, $errstr, 10);
    if ($fp) {
    echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
        echo "<td>Status: Up, Domain: $line[0], Port: $line[2]$a</td>\n";
                   echo "</tr>\n<tr>\n";
   echo "</tr></table>\n";
} else {
    echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
        echo "<td>Status: Down, Domain: $line[0], Port: $line[2]$a</td>\n";
                   echo "</tr>\n<tr>\n";
   echo "</tr></table>\n";
    }
    fclose($fp);
}
if($line[3] != ""){
$fp = fsockopen ($line[0], $line[3], $errno, $errstr, 10);
    if ($fp) {
    echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
        echo "<td>Status: Up, Domain: $line[0], Port: $line[3]$a</td>\n";
                   echo "</tr>\n<tr>\n";
   echo "</tr></table>\n";
} else {
    echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
        echo "<td>Status: Down, Domain: $line[0], Port: $line[3]$a</td>\n";
                   echo "</tr>\n<tr>\n";
   echo "</tr></table>\n";
    }
    fclose($fp);
}
if($line[4] != ""){
$fp = fsockopen ($line[0], $line[4], $errno, $errstr, 10);
    if ($fp) {
    echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
        echo "<td>Status: Up, Domain: $line[0], Port: $line[4]$a</td>\n";
                   echo "</tr>\n<tr>\n";
   echo "</tr></table>\n";
} else {
    echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
        echo "<td>Status: Down, Domain: $line[0], Port: $line[4]$a</td>\n";
                   echo "</tr>\n<tr>\n";
   echo "</tr></table>\n";
    }
    fclose($fp);
}

Link to comment
Share on other sites

because its going to be exicued thousands of times and it needs to be alot smaller. and i was just offering the hosting if someone takes their time to help me i want to give them something in return bbut if you dont want it it all good.

 

Christian

Link to comment
Share on other sites

Dunno if this is what you are looking for, but it checks whether the required one is present and walks throug all - included optional ones

Not tested.


<?php

//the variables
/*
$line[0] is the address
$line[1] is a port (required)
$line[2] is a port (optional)
$line[3] is a port (optional)
$line[4] is a port (optional)
*/

$check = array_slice($line, 1);
if(!empty($line) && !empty($check)){
foreach($check as $port){

$fp = fsockopen ($line[0],$port, $errno, $errstr, 10);
    if (!$fp) {
    echo "<br><b>Checking $line[0]...</b><br>\n";
    echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
    echo "<td>Status: Down, Domain: $line[0], Port: $port</td>\n";
    echo "</tr>\n<tr>\n";
    echo "</tr></table>\n";
    }
    else {
    echo "<br><b>Checking $line[0]...</b><br>\n";
    echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n";
    echo "<td>Status: Up, Domain: $line[0], Port: {$port}$a</td>\n";
    echo "</tr>\n<tr>\n";
    echo "</tr></table>\n";
    }
fclose($fp);
}
}
else{
  echo "Required port is not selected";
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.