cron.apteryx.indivia.net/delete_apteryx_alias.php

43 行
946 B
PHP

<?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);
$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;
}
}
?>