Example #1
0
    $string = substr($string, 1, strlen($string) - 2);
    if ($string == $data['lastname_main']) {
        return true;
    }
    if ($string != $data['pseudonym']) {
        if ($has_ordinary) {
            $update[] = XDB::format('pseudonym = {?}', $string);
        } else {
            $update[] = XDB::format('lastname_main = {?}', $string);
        }
        return true;
    }
    return false;
}
$res = XDB::rawIterator('SELECT  pd.pid, pd.private_name, pn.lastname_main, pn.lastname_marital, pn.lastname_ordinary,
                                 pn.firstname_main, pn.firstname_ordinary, pn.pseudonym
                           FROM  profile_display      AS pd
                     INNER JOIN  profile_public_names AS pn ON (pd.pid = pn.pid)');
$pattern = '/^([^\\(\\)]+)(?: (\\([^\\(\\)]+\\)))?(?: (\\([^\\(\\)]+\\)))?(?: (\\([^\\(\\)]+\\)))?$/';
while ($data = $res->next()) {
    preg_match($pattern, $data['private_name'], $matches);
    $has_ordinary = false;
    $count = count($matches);
    $update = array();
    $has_ordinary = update_main($data, $matches[1], $update);
    for ($i = 2; $i < $count; ++$i) {
        if (preg_match('/^\\((?:M|Mme) (.+)\\)$/', $matches[$i], $pieces)) {
            update_marital($data, $pieces[1], $update);
        } elseif (preg_match('/^\\((?:alias|autres prénoms :|autres noms :) .+\\)$/', $matches[$i], $pieces)) {
            update_private($data, $matches[$i], $data['pid'], $aliases, $perform_updates);
        } else {
            $has_ordinary = update_plain($data, $matches[$i], $update, $has_ordinary);
Example #2
0
            ++$skipped;
        }
    }
    ++$i;
    printf("\r%u / %u", $i, $total);
}
printf("\r%u / %u", $i, $total);
if ($skipped != 0) {
    printf("\n%u addresses skipped.\n", $skipped);
}
if ($fixed != 0) {
    printf("\n%u addresses fixed.\n", $fixed);
}
print "\nAddress formating done.\n\n";
print "Formats non formated phones. (3/4)\n";
$it = XDB::rawIterator("SELECT  search_tel AS search, display_tel AS display, comment, link_id,\n                                tel_type AS type, link_type, tel_id AS id, pid, pub\n                          FROM  profile_phones\n                         WHERE  search_tel = '' OR search_tel IS NULL\n                      ORDER BY  pid, link_id, tel_id");
$total = $it->total();
$i = 0;
$j = 0;
while ($item = $it->next()) {
    $phone = new Phone($item);
    $phone->delete();
    $phone->save();
    ++$i;
    ++$j;
    if ($j == 100) {
        $j = 0;
        printf("\r%u / %u", $i, $total);
    }
}
printf("\r%u / %u", $i, $total);
Example #3
0
 function handler_corps($page)
 {
     $page->changeTpl('fusionax/corps.tpl');
     $missingCorps = XDB::rawIterator('SELECT  DISTINCT(f.corps_sortie) AS name
                                         FROM  fusionax_anciens AS f
                                        WHERE  NOT EXISTS (SELECT  *
                                                             FROM  profile_corps_enum AS c
                                                            WHERE  f.corps_sortie = c.abbreviation)');
     $missingGrade = XDB::rawIterator('SELECT  DISTINCT(f.grade) AS name
                                         FROM  fusionax_anciens AS f
                                        WHERE  NOT EXISTS (SELECT  *
                                                             FROM  profile_corps_rank_enum AS c
                                                            WHERE  f.grade = c.name)');
     $page->assign('missingCorps', $missingCorps);
     $page->assign('missingGrade', $missingGrade);
     $page->assign('missingCorpsCount', $missingCorps->total());
     $page->assign('missingGradeCount', $missingGrade->total());
 }
Example #4
0
#!/usr/bin/php5
<?php 
require_once 'connect.db.inc.php';
$globals->debug = 0;
// Do not store backtraces.
$MAX_X = 200;
$MAX_Y = 100;
$it = XDB::rawIterator('SELECT  id, diminutif, logo, logo_mime
                          FROM  groups
                         WHERE  logo IS NOT NULL AND logo != ""');
while ($row = $it->next()) {
    $group_id = $row['id'];
    $group_name = $row['diminutif'];
    $logo = $row['logo'];
    $mime = $row['mime'];
    $img = imagecreatefromstring($logo);
    if ($img === false) {
        print "\n\nError reading image for:\n     {$group_name}\n\n";
        continue;
    }
    $x = imagesx($img);
    $y = imagesy($img);
    $nx = $x;
    $ny = $y;
    if ($x > $MAX_X || $y > $MAX_Y) {
        if ($x > $MAX_X) {
            $ny = intval($y * $MAX_X / $x);
            $nx = $MAX_X;
        }
        if ($y > $MAX_Y) {
            $nx = intval($x * $MAX_Y / $y);
Example #5
0
// Do not store backtraces.
$it = XDB::iterator('SELECT  gl.language, gc.country, gc.iso_3166_1_a2
                       FROM  geoloc_languages AS gl
                 INNER JOIN  geoloc_countries AS gc ON (gl.iso_3166_1_a2 = gc.iso_3166_1_a2)');
echo $it->total() . " pays à remplir.\n";
while ($item = $it->next()) {
    if ($item['language'] != 'fr') {
        $address = new Address(array('text' => $item['country']));
        $gmapsGeocoder = new GMapsGeocoder();
        $gmapsGeocoder->getGeocodedAddress($address, $item['language'], true);
        $country = $address->country;
    } else {
        $country = $item['country'];
    }
    $countryPlain = mb_strtoupper(replace_accent($country));
    XDB::execute('UPDATE  geoloc_languages
                     SET  country = {?}, countryPlain = {?}
                   WHERE  iso_3166_1_a2 = {?} AND language = {?}', $country, $countryPlain, $item['iso_3166_1_a2'], $item['language']);
    sleep(1);
}
$it = XDB::rawIterator('SELECT  country, iso_3166_1_a2
                          FROM  geoloc_countries');
echo $it->total() . " pays à simplifier.\n";
while ($item = $it->next()) {
    XDB::execute('UPDATE  geoloc_countries
                     SET  countryPlain = {?}
                   WHERE  iso_3166_1_a2 = {?}', mb_strtoupper(replace_accent($item['country'])), $item['iso_3166_1_a2']);
}
// Fixes geocoding errors.
XDB::rawExecute("REPLACE INTO  geoloc_languages (iso_3166_1_a2, language, country, countryPlain)\n                       VALUES  ('FM', 'en', 'Federated States of Micronesia', 'FEDERATED STATES OF MICRONESIA'),\n                               ('MH', 'en', 'Republic of the Marshall Islands', 'REPUBLIC OF THE MARSHALL ISLANDS'),\n                               ('PS', 'ar', 'دولة فلسطين', 'دولة فلسطين'),\n                               ('SB', 'en', 'Solomon Islands', 'SOLOMON ISLANDS'),\n                               ('TW', 'zh-CN', '台湾', '台湾'),\n                               ('TW', 'zh-TW', '台灣', '台灣'),\n                               ('CZ', 'cs', 'Česká Republika', 'CESKA REPUBLIKA'),\n                               ('CZ', 'sk', 'Česká Republika', 'CESKA REPUBLIKA'),\n                               ('DO', 'es', 'República Dominicana', 'REPUBLICA DOMINICANA'),\n                               ('GD', 'en', 'Grenada', 'GRENADA'),\n                               ('MD', 'ro', 'Republica Moldova', 'REPUBLICA MOLDOVA'),\n                               ('RU', 'ru', 'Россия', 'Россия'),\n                               ('SK', 'sk', 'Slovenská Republika', 'SLOVENSKA REPUBLIKA'),\n                               ('TZ', 'en', 'United Republic of Tanzania', 'UNITED REPUBLIC OF TANZANIA')");
/* vim:set et sw=4 sts=4 ts=4: */
Example #6
0
#!/usr/bin/php5
<?php 
require_once 'connect.db.inc.php';
$globals->debug = 0;
// Do not store backtraces.
$it = XDB::rawIterator('SELECT  uid, full_name, email, type
                          FROM  accounts
                         WHERE  type NOT IN (\'x\', \'master\', \'phd\')');
$total = $it->total();
$done = 0;
while ($item = $it->next()) {
    if ($item['type'] == 'virtual') {
        $firstname = '';
        $lastname = $item['full_name'];
    } elseif ($item['full_name'] && strpos(' ', $item['full_name'])) {
        list($firstname, $lastname) = explode(' ', $item['full_name']);
    } else {
        list($local_part, ) = explode('@', strtolower($item['email']));
        $parts = explode('.', $local_part);
        if (count($parts) == 1) {
            $lastname = ucfirst($local_part);
            $firstname = '';
        } else {
            $firstname = ucfirst($parts[0]);
            $lastname = ucwords(implode(' ', array_slice($parts, 1)));
        }
    }
    XDB::execute('UPDATE  accounts
                     SET  firstname = {?}, lastname = {?}
                   WHERE  uid = {?}', $firstname, $lastname, $item['uid']);
    ++$done;