NogDog
All websites I find pull the data from 1 website i.e.
$website = "www.example.com"; << This is not one website but about 160, this data is pulled from a database
if( !url_test( $website ) ) {
echo $website ." is down!";
}
else { echo $website ." functions correctly."; }
Weedpacket
My old code looks like this:
<?php
$tests = array
(
`array list`
);
// Set counter
$i = 1;
// For each test create a tr
foreach($tests as $test => $testProperties){
echo "<tr>";
// Display test ID
echo "<td>$i</td>";
echo "<td>".$testProperties[0]."</td>";
echo "<td>".$testProperties[1]."</td>";
if($socket =@ fsockopen($testProperties[1], 80, $errno, $errstr, 1)) {
echo "<td><span class='badge badge-success'>LIVE</span></td>";
fclose($socket);
}
else {
echo "<td><span class='badge badge-danger'>DOWN</span></td>";
}
echo "</tr>";
// Increase counter
$i++;
}
?>
I changed this code to the following but the fsock suddenly didn't ping the servers any longer (this code isn't including the curl ping bit of code it's just the way the page is showing):
<?php
require_once "config/config.php";
$sql = "SELECT * FROM deployments";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)){
?>
<tr>
<td> <?php echo $row['id'] ?></td>
<td> <?php echo $row['server'] ?></td>
<td> <?php echo $row['name'] ?></td>
<td> <?php echo $row['url'] ?></td>
<td> <?php echo $row['port'] ?></td>
<td><span class='badge badge-warning'>LIVE</span></td>
<td><a href="config/remove.php?id=<?php echo $row['id']; ?>"><span class="fa fa-trash"></span></a></td>
</tr>
<?php
}
// Free result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
?>
How do I make the fsock or curl ping all the servers shown in the database under the "url" table, as I can't get them to show.