mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-16 16:21:01 +00:00
Fix for infinite refreshing
This commit is contained in:
+14
-12
@@ -19,21 +19,23 @@
|
|||||||
// make sure we only run the automation script once and wait until it's done,
|
// make sure we only run the automation script once and wait until it's done,
|
||||||
// so concurrent AJAX calls from many different users won't overload the server
|
// so concurrent AJAX calls from many different users won't overload the server
|
||||||
if ( !defined('AUTOMATION_MANUAL_RUN') ) {
|
if ( !defined('AUTOMATION_MANUAL_RUN') ) {
|
||||||
if ( file_exists( AUTOMATION_LOCK_FILE_NAME ) ) {
|
if(defined('AUTOMATION_LOCK_FILE_NAME')){
|
||||||
// check that the file is not too old, in which case our PHP script hung
|
if ( file_exists( AUTOMATION_LOCK_FILE_NAME ) ) {
|
||||||
// and we need to remove the lock and run automation again
|
// check that the file is not too old, in which case our PHP script hung
|
||||||
$fileTime = filemtime( AUTOMATION_LOCK_FILE_NAME );
|
// and we need to remove the lock and run automation again
|
||||||
|
$fileTime = filemtime( AUTOMATION_LOCK_FILE_NAME );
|
||||||
|
|
||||||
// allow for 60 seconds of old automation script processing time, which is still way too plenty
|
// allow for 60 seconds of old automation script processing time, which is still way too plenty
|
||||||
if ( ! $fileTime || time() - $fileTime > 60 ) {
|
if ( ! $fileTime || time() - $fileTime > 60 ) {
|
||||||
@unlink( AUTOMATION_LOCK_FILE_NAME );
|
@unlink( AUTOMATION_LOCK_FILE_NAME );
|
||||||
|
} else {
|
||||||
|
// automation file exists and is valid, don't run another automation
|
||||||
|
exit;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// automation file exists and is valid, don't run another automation
|
// create automation lock file
|
||||||
exit;
|
file_put_contents( AUTOMATION_LOCK_FILE_NAME, '' );
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// create automation lock file
|
|
||||||
file_put_contents( AUTOMATION_LOCK_FILE_NAME, '' );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user