function ScanSize() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timefile = "/etc/artica-postfix/pids/tests." . __FUNCTION__ . ".time"; $pid = @file_get_contents("{$pidfile}"); if ($unix->process_exists($pid, basename(__FILE__))) { system_admin_events("Already executed PID {$pid}", __FUNCTION__, __FILE__, __LINE__, "freewebs"); die; } @file_put_contents($pidfile, getmypid()); $time = $unix->file_time_min($timefile); if ($time < 15) { system_admin_events("No less than 15mn or delete {$timefile} file", __FUNCTION__, __FILE__, __LINE__, "freewebs"); die; } @unlink($timefile); @file_put_contents($timefile, time()); $t = time(); $q = new mysql(); $sql = "SELECT servername FROM freeweb"; $results = $q->QUERY_SQL($sql, 'artica_backup'); $GLobalSize = 0; if (mysql_num_rows($results) == 0) { return; } $sitesNumber = mysql_num_rows($results); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $free = new freeweb($ligne["servername"]); if ($free->IsGroupWareFromArtica()) { $q->QUERY_SQL("UPDATE freeweb SET DirectorySize=0 WHERE servername='{$ligne["servername"]}'", "artica_backup"); continue; } $free->CheckWorkingDirectory(); if (is_link($free->WORKING_DIRECTORY)) { $free->WORKING_DIRECTORY = @readlink($free->WORKING_DIRECTORY); } if (!is_dir($free->WORKING_DIRECTORY)) { $q->QUERY_SQL("UPDATE freeweb SET DirectorySize=0 WHERE servername='{$ligne["servername"]}'", "artica_backup"); if (!$q->ok) { system_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "freewebs"); } continue; } $size = $unix->DIRSIZE_BYTES($free->WORKING_DIRECTORY); $GLobalSize = $GLobalSize + $size; if ($GLOBALS["VERBOSE"]) { echo "{$ligne["servername"]} {$size} Bytes\n"; } $q->QUERY_SQL("UPDATE freeweb SET DirectorySize={$size} WHERE servername='{$ligne["servername"]}'", "artica_backup"); if (!$q->ok) { system_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "freewebs"); } } if ($GLobalSize > 0) { $took = $unix->distanceOfTimeInWords($t, time(), true); $GLobalSize = round($GLobalSize / 1024, 2); $GLobalSize = $GLobalSize / 1000; system_admin_events("{$sitesNumber} web site(s) scanned {$GLobalSize}M took:{$took}", __FUNCTION__, __FILE__, __LINE__, "freewebs"); } }
function remove_host($hostname){ $freeweb=new freeweb($hostname); if($freeweb->IsGroupWareFromArtica()){ $freeweb->delete(); return; } if($freeweb->groupware=="Z-PUSH"){$freeweb->delete();return;} if($freeweb->groupware=="POWERADMIN"){$freeweb->delete();return;} if($hostname=="_default_"){$freeweb->delete();return;} if($freeweb->Forwarder==0){$freeweb->delete();return;} if(is_dir($freeweb->WORKING_DIRECTORY)){shell_exec("/bin/rm -rf $freeweb->WORKING_DIRECTORY");} $freeweb->delete(); }
function remove_host($hostname) { $freeweb = new freeweb($hostname); if (is_dir("/var/www/{$hostname}")) { shell_exec("/bin/rm -rf /var/www/{$hostname}"); } if ($freeweb->IsGroupWareFromArtica()) { $freeweb->delete(); return; } $mysql_database = $freeweb->mysql_database; $q = new mysql(); if ($q->DATABASE_EXISTS($mysql_database)) { $q->DELETE_DATABASE($mysql_database); } if ($freeweb->groupware == "Z-PUSH") { $freeweb->delete(); return; } if ($freeweb->groupware == "POWERADMIN") { $freeweb->delete(); return; } if ($hostname == "_default_") { $freeweb->delete(); return; } if ($freeweb->Forwarder == 0) { $freeweb->delete(); return; } if (is_dir($freeweb->WORKING_DIRECTORY)) { shell_exec("/bin/rm -rf {$freeweb->WORKING_DIRECTORY}"); } $freeweb->delete(); }