
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Live web camera</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<script type="text/javascript">

<!-- Begin
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Lee Underwood

Because this is a true refresh, you might want to put a
notice on the page that it refreshes every "X" minutes */

function reFresh() {
  location.reload(true)
}
/* Set the number below to the amount of delay, in milliseconds,
you want between page reloads: 1 minute = 60000 milliseconds. */
window.setInterval("reFresh()",60000);
// End -->
</script>
<?php 
	//  include 'includes/headcosmores.php';
?>

</head>
<?php 

function  get_oldest_file($directory)  { 

       if  ($handle  =  opendir($directory))  { 

               while  (false  !==  ($file  =  readdir($handle)))  { 

                       $files[]  =  $file; 

               } 

               foreach  ($files  as  $val)  { 

                       if  (is_file($directory.$val))  { 

                               $file_date[$val]  =  filemtime($directory.$val); 

                       } 

               } 

       } 

       closedir($handle); 

       arsort($file_date,  SORT_NUMERIC); 

       reset($file_date); 

       $oldest  =  key($file_date); 

       return  $oldest; 

} 

//  example: 

$lastfile=get_oldest_file("/home/olympicv/public_html/webcam/");

$newfile="/home/olympicv/public_html/webcam/oia.jpg";

$oldfile="/home/olympicv/public_html/webcam/".$lastfile;



if (get_oldest_file("/home/olympicv/public_html/webcam/") != "oia.jpg" && get_oldest_file("/home/olympicv/public_html/webcam/") != ".ftpquota" && get_oldest_file("/home/olympicv/public_html/webcam/") != "index.php") {

	if (!copy($oldfile, $newfile)) {

	   echo "failed to copy $oldfile...\n";

	}

}



     define("BY_EXTENSION",  1); 

     define("BY_EXPRESSION",  2); 

      

     function  GetFileList($HowToSearch,  $Condition,  $Directory,  $AddPath) 

     { 

           $hDir  =  opendir($Directory); 

           if  (!$hDir)  return  false; 

            

           $result  =  array(); 

           $index  =  0; 



           //--------------------------------- 

           //  Add  trailing  slash  to  directory. 

           //--------------------------------- 

           if  (!eregi('/${1}',  $Directory))  $Directory  .=  "/"; 



           //-------------------------------------------- 

           //  Loop  while  we  still  have  directory  entries. 

           //-------------------------------------------- 

           while  ($dirEntry  =  readdir($hDir))  { 

                 $new_entry  =  ""; 

                 $add  =  false; 

                  

                 //-------------------------------- 

                 //  Add  entries  based  on  extension. 

                 //-------------------------------- 

                 if  ($HowToSearch  ==  BY_EXTENSION)   

                       if  (eregi($Condition  .  '${1}',  $dirEntry))  $add  =  true; 



                 //--------------------------------------------------------- 

                 //  Add  entries  based  on  Perl-compatible  regular-expression. 

                 //--------------------------------------------------------- 

                 if  ($HowToSearch  ==  BY_EXPRESSION)   

                       if  (preg_match($Condition,  $dirEntry))  $add  =  true; 



                 //------------------------------- 

                 //  Add  the  entry  if  it  qualifies. 

                 //------------------------------- 

                 if  ($add)  {               

                       if  ($AddPath  ==  true)  $new_entry  =  $Directory; 

                              

                       $new_entry  .=  $dirEntry; 

                       $result[$index++]  =  $new_entry; 

                 } 

           } 

            

           closedir($hDir); 

           return  $result; 

     } 



     //------------------------------------- 

     //  Example  1:  Find  files  that  are  JPGs. 

     //------------------------------------- 

     

     $result  =  GetFileList(BY_EXTENSION,  "jpg",  "/home/olympicv/public_html/webcam/",  true); 

               foreach  ($result  as  $val)  { 

                       if  (is_file($directory.$val))  { 

		       		if ($val=='/home/olympicv/public_html/webcam/oia.jpg') {

					//echo "Oia : ";

					//echo $val."<br>";

				} else {

                               		//echo $val."<br>"; 

					

 					$file = $val; 

					if(file_exists($file)) {

						 unlink($file);

					}					

					

			       	}

                       } 

               } 

     

?>
<body style="padding:0px; margin:0px;">
<table width="500" border="0" align="center" cellpadding="4" cellspacing="0" class="text" bgcolor="#999999">
	  <tr> 
		<td> 
		 <div id="map" style="width: 100vw; height: 100vh">
<img src="http://www.olympicvillas.com/webcam/oia.jpg" alt="loading web cam" border="0">
<div id="Container" 
	style="padding-bottom:56.25%; position:relative;
	display:block; width: 100%">
	<iframe width="100%" height="100%" 
		allowfullscreen webkitallowfullscreen
		src="http://admin:12345678a@85.74.187.13330:8081/Streaming/Channels/1/picture" 
		frameborder="0"
		style="position:absolute; top:0; left: 0">
	</iframe>
</div><br />

    </div>
		</td>
	  </tr>
	  <tr>
		<td>
		  <div align="center"><a href="javascript:window.close();" class="linkf">close</a></div>
		</td>
	  </tr>
</table>
</body>
</html>
