<?php $url = "http://10.10.10.1:8080/"; $storage = "./storage/"; /** mjpg-streamer stop**/ $cmd = "sudo pkill mjpg"; exec( $cmd ); if( isset( $_GET["n"] ) ) { $n = $_GET["n"]; $n++; /** snap photo **/ $file_name = date( "Ymd_His" ); $cmd = "raspistill -o ./storage/".$file_name.".jpg"; exec( $cmd ); } else { $n = 0; } /** mjpg-streamer start**/ $cmd = "/home/pi/mjpg.sh 800 800 1 100"; $cmd = $cmd." > /dev/null &"; exec( $cmd ); /** count files in storage **/ if( $dh = opendir( $storage ) ) { $fn = -2; while ( readdir($dh) !== false) { $fn++; } closedir($dh); } else { print "opendir error : storage"; exit; } print " <html> <head> <meta charset=\"UTF-8\"> <title>Raspberry Pi Cemara</title> </head> <body> <center> <a href=\"./index.phtml?n=".$n."\"><img src=\"".$url."?action=stream\" /></a> <br><br> <font size=7><b>".$fn."</b></font> </center> </body> </html> "; ?>