Adapts plat/al crons to the new database.
[platal.git] / bin / cron / phones.check.php
index 077e2fe..ffea56d 100755 (executable)
@@ -1,10 +1,10 @@
 #!/usr/bin/php5
 <?php
 
-require('./connect.db.inc.php');
-require_once('profil.func.inc.php');
+require './connect.db.inc.php';
+require_once 'profil.func.inc.php';
 
-$globals->debug = 0; //do not store backtraces
+$globals->debug = 0; // do not store backtraces
 
 
 function do_update_by_block($values)
@@ -13,17 +13,20 @@ function do_update_by_block($values)
     // Because there is no mysql update syntax for multiple updates in one query
     // we use a multiple insert syntax which will fail because the key already exist
     // and then update the display_tel
-    XDB::execute("INSERT INTO  profile_phones (uid, link_type, link_id, tel_id ,tel_type,
+    XDB::execute("INSERT INTO  profile_phones (pid, link_type, link_id, tel_id ,tel_type,
                                           search_tel, display_tel, pub, comment)
                        VALUES  " . $values . "
       ON DUPLICATE KEY UPDATE  display_tel = VALUES(display_tel)");
 }
 
-$res = XDB::query("SELECT DISTINCT g.phoneprf FROM geoloc_pays AS g WHERE g.phoneprf IS NOT NULL");
+$res = XDB::query("SELECT DISTINCT  phonePrefix
+                              FROM  geoloc_countries
+                             WHERE  phonePrefix IS NOT NULL");
 $prefixes = $res->fetchColumn();
 foreach ($prefixes as $i => $prefix) {
-    $res = XDB::query("SELECT g.phoneformat FROM geoloc_pays AS g
-                        WHERE g.phoneprf = {?} AND g.phoneformat != '' LIMIT 1",
+    $res = XDB::query("SELECT  phoneFormat
+                         FROM  geoloc_countries
+                        WHERE  phonePrefix = {?} AND phoneFormat != '' LIMIT 1",
                       $prefix);
     if ($res->numRows() > 0) {
         $format = $res->fetchOneCell();
@@ -62,7 +65,7 @@ foreach ($prefixes as $i => $prefix) {
             $regexp .= ')?';
         }
         $regexp .= '$';
-        $res = XDB::iterator("SELECT uid, link_type, link_id, tel_id, tel_type, search_tel,
+        $res = XDB::iterator("SELECT pid, link_type, link_id, tel_id, tel_type, search_tel,
                                      display_tel, pub, comment
                                 FROM profile_phones
                                WHERE search_tel LIKE {?} AND display_tel NOT REGEXP {?}",
@@ -77,7 +80,7 @@ foreach ($prefixes as $i => $prefix) {
                 if ($values != '') {
                     $values .= ",\n";
                 }
-                $values .= "('"   . addslashes($phone['uid']) . "', '" . addslashes($phone['link_type'])
+                $values .= "('"   . addslashes($phone['pid']) . "', '" . addslashes($phone['link_type'])
                     . "', '" . addslashes($phone['link_id'])
                     . "', '" . addslashes($phone['tel_id']) . "', '" . addslashes($phone['tel_type'])
                     . "', '" . addslashes($phone['search_tel']) . "', '" . addslashes($disp)