Currently without the cron I'm running it like this:
<?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']?> <a href="http://<?php echo $row['url']?>" target="_blank" style="color: grey;"><span class="fa fa-external-link"></span></a></td>
<td></td>
<?php
$url = $row['url'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if (200==$retcode) {
echo "<td><span class='badge badge-success'>LIVE</span></td>";
} else {
echo "<td><span class='badge badge-danger'>DOWN</span></td>";
$path_to_file = './emailtemplate.html';
$file_contents = file_get_contents($path_to_file);
$file_contents = str_replace("depplaceholder","$url",$file_contents);
$to = "---";
$subject = "$url down";
$headers = "From:Deployment Monitor <--->" . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = $file_contents;
mail($to,$subject,$message,$headers);
}
?>
<td><a href="config/remove.php?id=<?php echo $row['id']; ?>" style="color: grey;"><span class="fa fa-trash"></span></a></td>
</tr>
<?php
}
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);
}
?>
I'm still new tot php, getting the hang of it but I'm not sure on how to make the cron script run the curl ping, post the data to a row that applies to:
<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['status']?> </td><<<<< cron would push data to this table per url after pinging to either LIVE or DOWN and would post the data in this <td>
</tr>
Sorry for asking a lot lol I'm just confused and google isn't helping since there seems no answer to my specific question.