init commit
This commit is contained in:
parent
81b1692483
commit
0fe07de7eb
1 changed files with 46 additions and 0 deletions
46
delete_apteryx_alias.php
Normal file
46
delete_apteryx_alias.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
include('config/config.php');
|
||||
global $sock;
|
||||
$sock=mysql_connect($host,$user,$passwd);
|
||||
mysql_select_db($db);
|
||||
//fine sql
|
||||
|
||||
$alias_dom = '24h.indivia.net';
|
||||
|
||||
function dom($name) {
|
||||
$zon=explode(".",$name);
|
||||
return implode(".",array_slice($zon,-3));
|
||||
}
|
||||
|
||||
$alias_dom2lvl = dom($alias_dom);
|
||||
$alias_tab = str_replace(".","_",$alias_dom2lvl);
|
||||
|
||||
$date_query = "SELECT user,modified FROM $alias_tab WHERE active = 'Y' AND domain = '$alias_dom'";
|
||||
$result=mysql_query($date_query);
|
||||
|
||||
$ventiquatro_ore_in_sec=86400;
|
||||
//$ventiquatro_ore_in_sec=200;
|
||||
|
||||
$counter=-1;
|
||||
$timo=time();
|
||||
while($row=mysql_fetch_row($result)) {
|
||||
$elapsed=$timo-$row[1];
|
||||
if($elapsed > $ventiquatro_ore_in_sec){
|
||||
$counter++;
|
||||
$toDelete[$counter]=$row[0];
|
||||
}
|
||||
}
|
||||
|
||||
while ($counter >= 0){
|
||||
$delquery="DELETE FROM $alias_tab WHERE user = '$toDelete[$counter]'";
|
||||
//DEBUG: echo "$delquery\n";
|
||||
mysql_query($delquery);
|
||||
if (mysql_affected_rows()==1) {
|
||||
$counter--;
|
||||
} else {
|
||||
echo "error\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in a new issue