Save DB information in separate table

This commit is contained in:
Daniel Winzen
2018-10-17 21:50:20 +02:00
parent 6eb068222c
commit 1f2ff2176b
4 changed files with 31 additions and 16 deletions

View File

@ -10,25 +10,27 @@ try{
exec('find /home -path "/home/*.onion/tmp/*" -cmin +1440 -delete');
//delete unused accounts older than 30 days
$all=scandir('/home');
$stmt=$db->prepare('UPDATE users SET todelete=1 WHERE onion=?;');
$del=$db->prepare('UPDATE users SET todelete=1 WHERE onion=?;');
$stmt=$db->prepare('SELECT onion FROM users WHERE dateadded<?;');
$stmt->execute([time()-60*60*24*30]);
$all=$stmt->fetchAll(PDO::FETCH_NUM);
foreach($all as $tmp){
if(!preg_match('~^[a-z2-7]{16}\.onion$~', $tmp)){
continue;
}
$tmp=$tmp[0].'.onion';
if(filemtime("/home/$tmp")>time()-60*60*24*30){
continue;
}
$count_www=count(scandir("/home/$tmp/www/"));
//check data empty and www no more than 1 file
if(count(scandir("/home/$tmp/data/"))>2 || count(scandir("/home/$tmp/www/"))>3){
if($count_www>3 || count(scandir("/home/$tmp/data/"))>2){
continue;
}
//check www empty or index unmodified
if(count(scandir("/home/$tmp/www/"))===3){
if($count_www===3){
if(!file_exists("/home/$tmp/www/index.hosting.html") || !in_array(md5_file("/home/$tmp/www/index.hosting.html"), INDEX_MD5S)){
continue;
}
}
//no data found, safe to delete
$stmt->execute([substr($tmp, 0, 16)]);
// $del->execute([substr($tmp, 0, 16)]);
var_dump($tmp);
}