Browse Source

init commit

gine 8 years ago
parent
commit
0fe07de7eb
1 changed files with 46 additions and 0 deletions
  1. 46 0
      delete_apteryx_alias.php

+ 46 - 0
delete_apteryx_alias.php

@@ -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;
+    }
+}
+
+?>