User Guide
Appendix C - PHP3 Script Examples
Axis Communications AB does not provide support for application development of any kind. The
information here is provided "as is", and there is no guarantee that any of the examples shown
will work in your particular application.
Revision 0.9 May 2001 46
if(($suffix=="sequence") && $current_counter > $counter_max)
{ // If the loaded index exceeds
//the specified maximum, reset
//index
$current_counter = 1;
if($fd = fopen("/tmp/counter","w"))
{
$buf = fwrite($fd,strval($current_counter));
fclose($fd);
}
}
error_reporting(E_ALL);
$session = ftp_connect($ftp_server, $port);
if($session)
{ // Connection successfully
//established
if(ftp_login($session, $user, $pass))
{ // Successful login attempt
if (!ftp_pasv($session, $passive_mode == "yes"))
{
ftp_quit($session);
error_log("Could not set passive mode",0);
}
else
{ // Passive mode successfully
//set
$start_time = gettimeofday();
$current_time = $start_time;
$session_time = 0;
$inc = 0;
$active_buffer = -1;
$failures=0;
while( ($failures<(strlen($sources)*2)) && (
($session_time<$time)||($time==-1) ))
{ //Upload images as long as
//not too many errors have
//occurred and session time
//hasn't been exceeded
$loop_start = gettimeofday();
$active_buffer++;
if($active_buffer==strlen($sources))
{ // Loop through the indexes
//specified as sources
$active_buffer=0;
}
$source_file="/tmp/".$buffer_prefix.substr($sour
ces,$active_buffer,1)."/".$file_format.".jpg";
// Build the destination name
//according to the suffix
//specified
$dest=$destination.$buffer_prefix.substr($source
s,$active_buffer,1);










