I'm woking in a mobile friendly monitoring tool based on rrdtool.
All working fine but when I have the webpage opened for more that 1 hour freezes my computer.
I use this snippet for refresh the images.
<?php
if(!isset($includeCheck))
{
exit ("No tienes permisos para ver directamente el archivo");
}
//echo "
//<script language='JavaScript'>
// function refreshIt(element) {
// setTimeout(function() {
// element.src = element.src.split('?')[0] + '?' + new Date().getTime();
// refreshIt(element);
// }, 50000);
// }
//</script>";
echo "
<script language='JavaScript'>
function refreshIt(element){
setInterval(function() {
element.src = element.src.split('?')[0] + '?' + new Date().getTime();
}, 50000);
}
</script>";
?>
I include this php file in the pages what I have images and I want to refresh.
I tried the 2 options but as I said, freezes my browser.
Anyone have idea what can I do? Because I need refresh the images only, I don't want to refres the whole page.
EDIT
Here is the PHP script for print all images in database.
<?php
if(!isset($includeCheck))
{
exit ("No tienes permisos para ver directamente el archivo");
}
if(isset($_GET['freq'])){
$freq = $_GET['freq'];
$title = 'Gráficas';
} else {
exit ("No has especificado la frecuencia");
}
if($freq == "hourly"){
$title = 'Tráfico última hora';
}
if($freq == "daily"){
$title = 'Tráfico último dia';
}
if($freq == "weekly"){
$title = 'Tráfico última semana';
}
if($freq == "monthly"){
$title = 'Tráfico último mes';
}
if($freq == "yearly"){
$title = 'Tráfico último año';
}
if(isset($_GET['limit'])){
$limit = $_GET['limit'];
} else {
$limit="10";
}
if(isset($_GET['inicio'])){
$inicio = $_GET['inicio'];
}
if(isset($_GET['subpage'])){
$subpage = $_GET['subpage'];
if ($subpage==1) {
$inicio=0;
}
} else {
$subpage = "1";
$inicio="0";
}
$total_records = $conn->query("SELECT graph_id FROM graph_".$freq)->num_rows;
$total_pages = ceil($total_records / $limit);
$sql = "SELECT graph_desc,graph_id,graph_name FROM graph_".$freq." ORDER BY graph_desc ASC LIMIT ".$limit." OFFSET ".$inicio.";";
$result = $conn->query($sql);
include_once 'adm/includes/pagination.php';
echo "<h1 id='titulo' class=\"page-header\">".$title."</h1>";
include_once 'adm/includes/refresh.php';
if ($total_pages != '1') {
echo "<div id='pager1' class='col-md-12'>";
echo $pagLink;
echo "</div>";
}
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "
<div class='graphSize' style='float:left; position:relative; z-index: 10;'>
<a href='?page=GraphDetail&graph_id=".$row['graph_id']."&graph_desc=".$row['graph_desc']."'>
<img style='width:100%' src='/graficas/".$freq."/".$row['graph_name']."' onload='refreshIt(this)'></img>
</a>
</div>
";
}
}
else {
echo "<p>No hay ninguna gráfica para mostrar</p>"; }
if ($total_pages != '1') {
echo "<div id='pager2' class='col-md-12'>";
echo $pagLink;
echo "</div>";
}
echo "</body>";
if(isset($_GET['fullscreen'])){
echo "<style>";
echo ".graphSize {";
echo "width:500px;";
echo "}";
echo "</style>";
}
$conn->close();