Re: endless loop / running as a service?

From: Date: Tue, 13 Jul 2004 12:15:40 +0000
Subject: Re: endless loop / running as a service?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-35210@lists.php.net to get a copy of this message
Hi, maybe something like this would do: ( warning: it is just a sketch,and probably will not run ) 1. there are 4 files on the server: a) check-flag b) start-watch.php c) stop-watch.php d) watch.php 2. watch.php: // in the check-flag file we have a flag which turns off/on the checker $flag_file = 'check-flag'; $fd = fopen($flag_file, 'r'); $go = fread($fd); // we shall get 0 - stop, 1 - go // the loop runs as long as there is 1 in 'check-flag' file while ( $go ) { $dir_state = get_the_state_of_the_dir(); $old_dir_state = get_previous_state_of_the_dir(); if( compare_the_dirs( $dir_state, $old_dir_state)) { // the state is different - something has been uploaded // do somethnig .... } $result = write_previous_dir_state($old_dir_state); rewind_the_file_position_to_start($fd); $go = fread($fd); } // end of the loop 3. start-watch.php if( check_the_identity_and_privileges_of_the_user() ) { set_flag_in_the_file( 'check-flag', 1); } 4. stop-watch.php if( check_the_identity_and_privileges_of_the_user() ) { set_flag_in_the_file( 'check-flag', 0); } it is just a rough idea written down with pseudo-php, but You shall get the idea greetings. Marcin

« previous php.db (#35210) next »