This commit is contained in:
ArthurHoaro 2014-01-04 11:44:50 +01:00
parent 8f3f91ea62
commit fbb381ff5b
2 changed files with 37 additions and 25 deletions

1
.gitignore vendored
View file

@ -11,3 +11,4 @@ autoblogs/*
docs/* docs/*
!docs/docs.txt !docs/docs.txt
robots.txt robots.txt
.idea

View file

@ -376,36 +376,47 @@ if (isset($_GET['sitemap']))
* Update ALL autblogs (except .disabled) * Update ALL autblogs (except .disabled)
* This action can be very slow and consume CPU if you have a lot of autoblogs * This action can be very slow and consume CPU if you have a lot of autoblogs
**/ **/
if( isset($_GET['updateall']) && ALLOW_FULL_UPDATE) { if( isset($_GET['updateall']) ) {
$max_exec_time=time()+4; // scipt have 4 seconds to update autoblogs if( !isset( $_GET['force']) ) {
$expire = time() - 84600 ; // 23h30 en secondes $max_exec_time=time()+4; // scipt have 4 seconds to update autoblogs
$lockfile = ".updatealllock"; $expire = time() - 5 ; // 5 seconds
$lockfile_contents = array(); $lockfile = ".updatealllock";
if (file_exists($lockfile)){ $lockfile_contents = array();
$lockfile_contents = file_get_contents($lockfile); if (file_exists($lockfile)){
if( !isset($lockfile_contents[0]) || $lockfile_contents[0] != "a") { // détection d'une serialisation $lockfile_contents = file_get_contents($lockfile);
if( filemtime($lockfile) > $expire){ if( !isset($lockfile_contents[0]) || $lockfile_contents[0] != "a") { // détection d'une serialisation
echo "too early"; if( filemtime($lockfile) > $expire){
die; echo "too early";
}else{ die;
// need update of all autoblogs }else{
unlink($lockfile); // need update of all autoblogs
unlink($lockfile);
}
} }
// else we need to update some autoblogs
}
if( file_put_contents($lockfile, date(DATE_RFC822)) ===FALSE) {
echo "Merci d'ajouter des droits d'écriture sur le fichier.";
die;
}
if(!empty($lockfile_contents)) {
$subdirs = unserialize($lockfile_contents);
unset($lockfile_contents);
}else{
$subdirs = glob(AUTOBLOGS_FOLDER . "*");
} }
// else we need to update some autoblogs
} }
if( file_put_contents($lockfile, date(DATE_RFC822)) ===FALSE) { elseif (ALLOW_FULL_UPDATE) {
echo "Merci d'ajouter des droits d'écriture sur le fichier."; $subdirs = glob(AUTOBLOGS_FOLDER . "*");
$max_exec_time=time() * 2; // workaround to disable max exec time
}
else {
echo "You're not allowed to force full update.";
die; die;
} }
if(!empty($lockfile_contents)) {
$subdirs = unserialize($lockfile_contents);
unset($lockfile_contents);
}else{
$subdirs = glob(AUTOBLOGS_FOLDER . "*");
}
$todo_subdirs = $subdirs; $todo_subdirs = $subdirs;
foreach($subdirs as $key => $unit) { foreach($subdirs as $key => $unit) {
if(is_dir($unit)) { if(is_dir($unit)) {
if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) { if( !file_exists(ROOT_DIR . '/' . $unit . '/.disabled')) {