projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'xorg/maint' into xorg/master
[platal.git]
/
bin
/
cron
/
phones.check.php
diff --git
a/bin/cron/phones.check.php
b/bin/cron/phones.check.php
index
6f8e14d
..
92707ee
100755
(executable)
--- a/
bin/cron/phones.check.php
+++ b/
bin/cron/phones.check.php
@@
-1,16
+1,10
@@
#!/usr/bin/php5
<?php
#!/usr/bin/php5
<?php
-require('./connect.db.inc.php');
-
-//next two are required to include 'profil.func.inc.php'
-require_once('xorg.inc.php');
-$page = new XorgPage(null);
-
-require_once('profil.func.inc.php');
-
-$globals->debug = 0; //do not store backtraces
+require './connect.db.inc.php';
+$globals->debug = 0; // do not store backtraces
+// TODO: Improve this using Phone::iterate.
function do_update_by_block($values)
{
function do_update_by_block($values)
{
@@
-18,17
+12,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
// 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 (
u
id, link_type, link_id, tel_id ,tel_type,
+ XDB::execute("INSERT INTO profile_phones (
p
id, 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)");
}
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) {
$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();
$prefix);
if ($res->numRows() > 0) {
$format = $res->fetchOneCell();
@@
-67,7
+64,7
@@
foreach ($prefixes as $i => $prefix) {
$regexp .= ')?';
}
$regexp .= '$';
$regexp .= ')?';
}
$regexp .= '$';
- $res = XDB::iterator("SELECT
u
id, link_type, link_id, tel_id, tel_type, search_tel,
+ $res = XDB::iterator("SELECT
p
id, 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 {?}",
display_tel, pub, comment
FROM profile_phones
WHERE search_tel LIKE {?} AND display_tel NOT REGEXP {?}",
@@
-78,14
+75,15
@@
foreach ($prefixes as $i => $prefix) {
$values = '';
$i = 0;
while ($phone = $res->next()) {
$values = '';
$i = 0;
while ($phone = $res->next()) {
- $disp = format_display_number($phone['search_tel'], $error, array('format' => $format, 'phoneprf' => $prefix));
+ $phone = new Phone(array('display' => $phone['display_tel']));
+ $phone->format(array('format' => $format, 'phoneprf' => $prefix));
if ($values != '') {
$values .= ",\n";
}
if ($values != '') {
$values .= ",\n";
}
- $values .= "('" . addslashes($phone['
u
id']) . "', '" . addslashes($phone['link_type'])
+ $values .= "('" . addslashes($phone['
p
id']) . "', '" . addslashes($phone['link_type'])
. "', '" . addslashes($phone['link_id'])
. "', '" . addslashes($phone['tel_id']) . "', '" . addslashes($phone['tel_type'])
. "', '" . addslashes($phone['link_id'])
. "', '" . addslashes($phone['tel_id']) . "', '" . addslashes($phone['tel_type'])
- . "', '" . addslashes($phone['search_tel']) . "', '" . addslashes($
disp
)
+ . "', '" . addslashes($phone['search_tel']) . "', '" . addslashes($
phone->display
)
. "', '" . addslashes($phone['pub']) . "', '" . addslashes($phone['comment']) . "')";
$i++;
if ($i == 1000) {
. "', '" . addslashes($phone['pub']) . "', '" . addslashes($phone['comment']) . "')";
$i++;
if ($i == 1000) {