jet8791 Posted February 3, 2007 Share Posted February 3, 2007 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 https://forums.phpfreaks.com/topic/36880-i-need-help-shorting-my-script/ Share on other sites More sharing options...
JasonLewis Posted February 3, 2007 Share Posted February 3, 2007 if your offering stuff for this post it in the freelance section. people in this board are here for helping people for the reason that they can. and why do you want it shortened? Link to comment https://forums.phpfreaks.com/topic/36880-i-need-help-shorting-my-script/#findComment-175938 Share on other sites More sharing options...
jet8791 Posted February 3, 2007 Author Share Posted February 3, 2007 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 https://forums.phpfreaks.com/topic/36880-i-need-help-shorting-my-script/#findComment-175942 Share on other sites More sharing options...
jet8791 Posted February 3, 2007 Author Share Posted February 3, 2007 anyone? Link to comment https://forums.phpfreaks.com/topic/36880-i-need-help-shorting-my-script/#findComment-176005 Share on other sites More sharing options...
alpine Posted February 3, 2007 Share Posted February 3, 2007 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 https://forums.phpfreaks.com/topic/36880-i-need-help-shorting-my-script/#findComment-176009 Share on other sites More sharing options...
jet8791 Posted February 5, 2007 Author Share Posted February 5, 2007 thank you!!!!!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/36880-i-need-help-shorting-my-script/#findComment-177197 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.