示例#1
0
 function prepareform($pay, $user)
 {
     // Documentation:
     // https://www.paypal.com/developer
     // Warning: the automatic return only works if we force the
     // users to create a paypal account. We do not use it; thus
     // the user must come back on the site.
     global $globals, $platal;
     $this->urlform = 'https://' . $globals->money->paypal_site . '/cgi-bin/webscr';
     $roboturl = str_replace("https://", "http://", $globals->baseurl) . '/' . $platal->ns . "payment/paypal_return/" . $user->id() . "?comment=" . urlencode(Env::v('comment')) . '&display=' . Post::i('display');
     $this->infos = array('commercant' => array('business' => $globals->money->paypal_compte, 'rm' => 2, 'return' => $roboturl, 'cn' => 'Commentaires', 'no_shipping' => 1, 'cbt' => empty($GLOBALS['IS_XNET_SITE']) ? 'Revenir sur polytechnique.org.' : 'Revenir sur polytechnique.net.'));
     $info_client = array('first_name' => $user->firstName(), 'last_name' => $user->lastName(), 'email' => $user->bestEmail());
     if ($user->hasProfile()) {
         $res = XDB::query("SELECT  pa.text, GROUP_CONCAT(pace2.short_name) AS city,\n                                       GROUP_CONCAT(pace3.short_name) AS zip, GROUP_CONCAT(pace1.short_name) AS country,\n                                       IF(pp1.display_tel != '', pp1.display_tel, pp2.display_tel) AS night_phone_b\n                                 FROM  profile_addresses                 AS pa\n                            LEFT JOIN  profile_phones                    AS pp1   ON (pp1.pid = pa.pid AND pp1.link_type = 'address' AND pp1.link_id = pa.id)\n                            LEFT JOIN  profile_phones                    AS pp2   ON (pp2.pid = pa.pid AND pp2.link_type = 'user' AND pp2.link_id = 0)\n                            LEFT JOIN  profile_addresses_components      AS pc    ON (pa.pid = pc.pid AND pa.jobid = pc.jobid AND pa.groupid = pc.groupid\n                                                                                      AND pa.type = pc.type AND pa.id = pc.id)\n                            LEFT JOIN  profile_addresses_components_enum AS pace1 ON (FIND_IN_SET('country', pace1.types) AND pace1.id = pc.component_id)\n                            LEFT JOIN  profile_addresses_components_enum AS pace2 ON (FIND_IN_SET('locality', pace2.types) AND pace2.id = pc.component_id)\n                            LEFT JOIN  profile_addresses_components_enum AS pace3 ON (FIND_IN_SET('postal_code', pace3.types) AND pace3.id = pc.component_id)\n                                WHERE  pa.pid = {?} AND FIND_IN_SET('current', pa.flags)\n                             GROUP BY  pa.pid, pa.jobid, pa.groupid, pa.id, pa.type\n                                LIMIT  1", $user->profile()->id());
         if (is_array($res)) {
             $this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
             list($this->infos['client']['address1'], $this->infos['client']['address2']) = explode("\n", Geocoder::getFirstLines($this->infos['client']['text'], $this->infos['client']['zip'], 2));
             unset($this->infos['client']['text']);
         } else {
             $this->infos['client'] = array_map('replace_accent', $info_client);
         }
     } else {
         $this->infos['client'] = array_map('replace_accent', $info_client);
     }
     // We build the transaction's reference
     $prefix = rand_url_id();
     $fullref = substr("{$prefix}-xorg-{$pay->id}", -15);
     $this->infos['commande'] = array('item_name' => replace_accent($pay->text), 'amount' => $this->val_number, 'currency_code' => 'EUR', 'custom' => $fullref);
     $this->infos['divers'] = array('cmd' => '_xclick');
 }
示例#2
0
 public function __construct(User $_user, Profile $_profile, $_id, $_name, $_acronym, $_url, $_email, $_tel, $_fax, $_address, $_stamp = 0)
 {
     parent::__construct($_user, $_profile, false, 'entreprise', $_stamp);
     $this->id = $_id;
     $this->name = $_name;
     $this->acronym = $_acronym;
     $this->url = $_url;
     $this->email = $_email;
     $this->tel = $_tel;
     $this->fax = $_fax;
     $this->address = $_address;
     $_name = preg_replace('/[^0-9a-z]/i', ' ', strtolower(replace_accent($_name)));
     $name = explode(" ", $_name);
     $name_array = array_map("trim", $name);
     $length = count($name_array);
     $where = "";
     for ($i = 0; $i < $length; $i++) {
         if (strlen($name_array[$i]) > 2) {
             if ($where !== "") {
                 $where .= " OR ";
             }
             $where .= "name LIKE '%" . $name_array[$i] . "%'";
         }
     }
     if ($where != '') {
         $res = XDB::iterator('SELECT  name
                                 FROM  profile_job_enum
                                WHERE  ' . $where);
         $this->suggestions = "| ";
         while ($sug = $res->next()) {
             $this->suggestions .= $sug['name'] . " | ";
         }
     }
 }
示例#3
0
 public function accept()
 {
     // no text [AI JMIAJM IJA MIJ]
     if (preg_match('/\\[[-\'"a-zA-Z ]+\\]/', replace_accent($this->msg_reponse))) {
         $this->trigError("La demande de paiement n'est pas valide. Merci de compléter le texte avant de la soumettre");
         return false;
     }
     if (!preg_match('/<montant>/', $this->msg_reponse)) {
         $this->trigError("Le demande de paiement ne contient pas la balise obligatoire &lt;montant&gt;");
         return false;
     }
     return true;
 }
function display_address_isIdentity($idt, $value, $test_reverse = true)
{
    $value = strtolower(replace_accent($value));
    $idt = strtolower(replace_accent($idt));
    $idt = preg_replace('/[^a-z]/', '', $idt);
    $value = preg_replace('/[^a-z]/', '', $value);
    if (strpos($value, $idt) !== false || strpos($idt, $value) !== false || levenshtein($value, $idt) < strlen($idt) / 3) {
        return true;
    }
    if ($test_reverse) {
        return display_address_isIdentity($idt, implode(' ', array_reverse(explode(' ', $value))), false);
    }
    return false;
}
示例#5
0
 function prepareform($pay, $user)
 {
     global $globals, $platal;
     $log = S::v('log');
     // Transaction's reference computation.
     $prefix = rand_url_id();
     $fullref = substr("{$prefix}-{$pay->id}", -12);
     // FIXME : check for duplicates
     $ts = time();
     $trans_date = gmdate("YmdHis", $ts);
     $trans_id = gmdate("His", $ts);
     // FIXME : check for duplicates
     // Form's content.
     $this->urlform = "https://systempay.cyberpluspaiement.com/vads-payment/";
     $this->infos['commercant'] = array('vads_site_id' => $globals->money->cyperplus_account, 'vads_return_mode' => 'NONE', 'vads_url_return' => $pay->url ? $pay->url : $globals->baseurl . '/' . $platal->ns);
     $this->infos['client'] = array('vads_cust_email' => $user->bestEmail(), 'vads_cust_id' => $user->id(), 'vads_cust_name' => substr(self::replaceNonAlpha(replace_accent($user->shortName())), 0, 127));
     $this->infos['commande'] = array('vads_amount' => $this->val, 'vads_currency' => '978', 'vads_payment_config' => 'SINGLE', 'vads_trans_date' => $trans_date, 'vads_trans_id' => $trans_id, 'vads_order_id' => $fullref, 'vads_order_info' => substr(self::replaceNonAlpha(replace_accent(Env::v('comment'))), 0, 255), 'vads_order_info2' => Post::i('display'));
     $this->infos['divers'] = array('vads_version' => 'V2', 'vads_ctx_mode' => $globals->money->cyperplus_prod, 'vads_page_action' => 'PAYMENT', 'vads_action_mode' => 'INTERACTIVE');
     // Entry key computation.
     $all_params = array_merge($this->infos['commercant'], $this->infos['client'], $this->infos['commande'], $this->infos['divers']);
     ksort($all_params);
     $this->infos['divers']['signature'] = sha1(join('+', $all_params) . '+' . $globals->money->cyperplus_key);
 }
示例#6
0
 function handler_names($page, $action = '', $csv = false)
 {
     $page->changeTpl('fusionax/names.tpl');
     if ($action == 'first') {
         $res = $this->retrieve_firstnames();
         if ($csv) {
             pl_cached_content_headers('text/x-csv', 'utf-8', 1, 'firstnames.csv');
             $csv = fopen('php://output', 'w');
             fputcsv($csv, array('pid', 'ax_id', 'hrpid', 'AX', 'initial', 'principal', 'ordinaire'), ';');
             foreach ($res as $item) {
                 fputcsv($csv, $item, ';');
             }
             fclose($csv);
             exit;
         } else {
             $page->assign('firstnameIssues', $res);
         }
     } elseif ($action == 'last' || $action == 'last3' || $action == 'last2' || $action == 'last1') {
         // Define some variables to build queries
         function sql_trim_partic($sqlstring)
         {
             $sqlstring = 'TRIM(LEADING \'d\\\'\' FROM ' . $sqlstring . ')';
             $sqlstring = 'TRIM(LEADING \'D\\\'\' FROM ' . $sqlstring . ')';
             $sqlstring = 'TRIM(LEADING \'de \' FROM ' . $sqlstring . ')';
             $sqlstring = 'TRIM(LEADING \'De \' FROM ' . $sqlstring . ')';
             $sqlstring = 'TRIM(LEADING \'du \' FROM ' . $sqlstring . ')';
             $sqlstring = 'TRIM(LEADING \'Du \' FROM ' . $sqlstring . ')';
             return $sqlstring;
         }
         //$field_ax_patro = 'IF(f.partic_patro, CONCAT(f.partic_patro, CONCAT(\' \', f.Nom_patronymique)), f.Nom_patronymique)';
         //$field_ax_usuel = 'IF(f.partic_nom, CONCAT(f.partic_nom, CONCAT(\' \', f.Nom_usuel)), f.Nom_usuel)';
         $fields_p_list = '(' . \sql_trim_partic('ppn.lastname_initial') . ', ' . \sql_trim_partic('ppn.lastname_main') . ', ' . \sql_trim_partic('ppn.lastname_marital') . ', ' . \sql_trim_partic('ppn.lastname_ordinary') . ')';
         $ax_patro = '(' . sql_trim_partic('f.Nom_patronymique') . ' NOT IN ' . $fields_p_list . ')';
         $ax_ordinary = '(' . sql_trim_partic('f.Nom_usuel') . ' NOT IN ' . $fields_p_list . ')';
         $ax_full = '(' . sql_trim_partic('f.Nom_complet') . ' NOT IN ' . $fields_p_list . ')';
         switch ($action) {
             case 'last':
                 $where = $ax_patro . ' OR ' . $ax_ordinary . ' OR ' . $ax_full;
                 break;
             case 'last3':
                 $where = $ax_patro . ' AND ' . $ax_ordinary . ' AND ' . $ax_full;
                 break;
             case 'last2':
                 $where = '(' . $ax_patro . ' AND ' . $ax_ordinary . ' AND NOT ' . $ax_full . ') OR (' . $ax_patro . ' AND NOT ' . $ax_ordinary . ' AND ' . $ax_full . ') OR (' . 'NOT ' . $ax_patro . ' AND ' . $ax_ordinary . ' AND ' . $ax_full . ')';
                 break;
             case 'last1':
                 $where = '(' . $ax_patro . ' AND NOT ' . $ax_ordinary . ' AND NOT ' . $ax_full . ') OR (' . 'NOT ' . $ax_patro . ' AND NOT ' . $ax_ordinary . ' AND ' . $ax_full . ') OR (' . 'NOT ' . $ax_patro . ' AND ' . $ax_ordinary . ' AND NOT ' . $ax_full . ')';
                 break;
         }
         $res = XDB::rawFetchAllAssoc('SELECT  p.pid, p.ax_id, p.hrpid,
                                               f.Nom_patronymique, f.Nom_usuel, f.Nom_complet,
                                               ppn.lastname_initial, ppn.lastname_main, ppn.lastname_marital, ppn.lastname_ordinary,
                                               ' . $ax_patro . ' AS cond_patro,
                                               ' . $ax_ordinary . ' AS cond_ordinary,
                                               ' . $ax_full . ' AS cond_full
                                         FROM  fusionax_anciens     AS f
                                   INNER JOIN  profiles             AS p   ON (f.ax_id = p.ax_id)
                                   INNER JOIN  profile_public_names AS ppn ON (p.pid = ppn.pid)
                                        WHERE  ' . $where . '
                                     ORDER BY  p.ax_id');
         if ($csv) {
             function format($string)
             {
                 $string = preg_replace('/\\-/', ' ', $string);
                 return preg_replace('/\\s+/', ' ', $string);
             }
             pl_cached_content_headers('text/x-csv', 'utf-8', 1, 'lastnames.csv');
             $csv = fopen('php://output', 'w');
             fputcsv($csv, array('pid', 'ax_id', 'hrpid', 'AX patro', 'AX usuel', 'AX complet', 'initial', 'principal', 'marital', 'ordinaire', 'pb patro', 'pb usuel', 'pb complet'), ';');
             foreach ($res as $item) {
                 $ax = array('Nom_patronymique' => format(mb_strtolower(replace_accent($item['Nom_patronymique']))), 'Nom_usuel' => format(mb_strtolower(replace_accent($item['Nom_usuel']))), 'Nom_complet' => format(mb_strtolower(replace_accent($item['Nom_complet']))));
                 $xorg = array('lastname_initial' => format(mb_strtolower(replace_accent($item['lastname_initial']))), 'lastname_main' => format(mb_strtolower(replace_accent($item['lastname_main']))), 'lastname_ordinary' => format(mb_strtolower(replace_accent($item['lastname_ordinary']))));
                 if (!in_array($ax['Nom_patronymique'], $xorg) || !in_array($ax['Nom_usuel'], $xorg) || !in_array($ax['Nom_complet'], $xorg)) {
                     fputcsv($csv, $item, ';');
                 }
             }
             fclose($csv);
             exit;
         } else {
             $page->assign('lastnameIssues', $res);
             $page->assign('total', count($res));
             $page->assign('issuesTypes', array('last' => "1, 2 ou 3 noms de l'AX manquant", 'last1' => "1 nom de l'AX manquant", 'last2' => "2 noms de l'AX manquant", 'last3' => "3 noms de l'AX manquant"));
         }
     } else {
         $res = XDB::query('SELECT  COUNT(*)
                              FROM  fusionax_anciens AS f
                        INNER JOIN  profiles         AS p    ON (f.ax_id = p.ax_id)');
         $page->assign('total', $res->fetchOneCell());
         $res = XDB::rawFetchOneCell("SELECT  COUNT(*)\n                                           FROM  fusionax_anciens     AS f\n                                     INNER JOIN  profiles             AS p   ON (f.ax_id = p.ax_id)\n                                     INNER JOIN  profile_public_names AS ppn ON (p.pid = ppn.pid)\n                                          WHERE  IF(f.partic_patro, CONCAT(f.partic_patro, CONCAT(' ', f.Nom_patronymique)), f.Nom_patronymique) NOT IN (ppn.lastname_initial, ppn.lastname_main, ppn.lastname_marital, ppn.lastname_ordinary)\n                                                 OR IF(f.partic_nom, CONCAT(f.partic_nom, CONCAT(' ', f.Nom_usuel)), f.Nom_usuel) NOT IN (ppn.lastname_initial, ppn.lastname_main, ppn.lastname_marital, ppn.lastname_ordinary)\n                                                 OR f.Nom_complet NOT IN (ppn.lastname_initial, ppn.lastname_main, ppn.lastname_marital, ppn.lastname_ordinary)");
         $page->assign('lastnameIssues', $res);
         $res = XDB::rawFetchOneCell('SELECT  COUNT(*)
                                        FROM  fusionax_anciens     AS f
                                  INNER JOIN  profiles             AS p   ON (f.ax_id = p.ax_id)
                                  INNER JOIN  profile_public_names AS ppn ON (p.pid = ppn.pid)
                                       WHERE  f.prenom NOT IN (ppn.firstname_initial, ppn.firstname_main, ppn.firstname_ordinary)');
         $page->assign('firstnameIssues', count($this->retrieve_firstnames()));
     }
     $page->assign('action', $action);
 }
示例#7
0
文件: admin.php 项目: Ekleog/platal
 private static function updateCountry(array $item)
 {
     XDB::execute('UPDATE  geoloc_countries
                      SET  countryPlain = {?}
                    WHERE  iso_3166_1_a2 = {?}', mb_strtoupper(replace_accent($item['country'])), $item['iso_3166_1_a2']);
 }
示例#8
0
文件: address.php 项目: Ekleog/platal
 public function formatPostalAddress()
 {
     // Performs rough formatting.
     $text = mb_strtoupper(replace_accent($this->text));
     $text = str_replace(array(',', ';', '.', ':', '!', '?', '"', '«', '»'), '', $text);
     $text = preg_replace('/( |\\t)+/', ' ', $text);
     $arrayText = explode("\n", $text);
     $arrayText = array_map('trim', $arrayText);
     // Formats according to country rules. Thus we first identify the
     // country, then apply corresponding formatting or translate country
     // into default language.
     $count = count($arrayText);
     list($countryId, $country) = XDB::fetchOneRow('SELECT  gc.iso_3166_1_a2, gc.country
                                                      FROM  geoloc_countries AS gc
                                                INNER JOIN  geoloc_languages AS gl ON (gc.iso_3166_1_a2 = gl.iso_3166_1_a2)
                                                     WHERE  gl.countryPlain = {?} OR gc.countryPlain = {?}', $arrayText[$count - 1], $arrayText[$count - 1]);
     if (is_null($countryId)) {
         $text = $this->formatPostalAddressFR($arrayText);
     } elseif (in_array(strtoupper($countryId), Address::$formattings)) {
         $text = call_user_func(array($this, 'formatPostalAddress' . strtoupper($countryId)), $arrayText);
     } else {
         $arrayText[$count - 1] = mb_strtoupper(replace_accent($country));
         $text = implode("\n", $arrayText);
     }
     $this->postalText = $text;
 }
示例#9
0
 /**
  * Extract search token from term
  * @param $term a utf-8 string that can contain any char
  * @return an array of elementary tokens
  */
 public static function tokenize($term)
 {
     $term = mb_strtoupper(replace_accent($term));
     $term = str_replace(array('/', ',', '(', ')', '"', '&', '»', '«'), ' ', $term);
     $tokens = explode(' ', $term);
     static $not_tokens = array('ET', 'AND', 'DE', 'DES', 'DU', 'D\'', 'OU', 'L\'', 'LA', 'LE', 'LES', 'PAR', 'AU', 'AUX', 'EN', 'SUR', 'UN', 'UNE', 'IN');
     foreach ($tokens as &$t) {
         $t = preg_replace(array('/^-+/', '/-+$/'), '', $t);
         if (substr($t, 1, 1) == '\'' && in_array(substr($t, 0, 2), $not_tokens)) {
             $t = substr($t, 2);
         }
         if (strlen($t) == 1 || in_array($t, $not_tokens)) {
             $t = false;
             continue;
         }
     }
     return array_filter($tokens);
 }
示例#10
0
/** Transform a name to its canonical value so it can be compared
 * to another form (different case, with accents or with - instead
 * of blanks).
 * @see compare_basename to compare
 */
function name_to_basename($value)
{
    $value = mb_strtoupper(replace_accent($value));
    return preg_replace('/[^A-Z]/', ' ', $value);
}
示例#11
0
function fix_xorg_ordinary_name($ax, $xorg, $item)
{
    $new_name = '';
    if (!in_array($ax['Nom_usuel'], $xorg) && $xorg['lastname_ordinary'] == '') {
        XDB::execute("UPDATE  profile_public_names\n                         SET  lastname_ordinary = {?}\n                       WHERE  pid = {?}", $item['Nom_usuel'], $item['pid']);
        return 1;
    }
    return 0;
}
function format($string)
{
    $string = preg_replace('/\\-/', ' ', $string);
    return preg_replace('/\\s+/', ' ', $string);
}
$updates_count = 0;
$count = 0;
$total = count($res);
foreach ($res as $item) {
    array_map('trim', $item);
    $ax = array('Nom_patronymique' => format(mb_strtolower(replace_accent($item['Nom_patronymique']))), 'Nom_usuel' => format(mb_strtolower(replace_accent($item['Nom_usuel']))), 'Nom_complet' => format(mb_strtolower(replace_accent($item['Nom_complet']))));
    $xorg = array('lastname_initial' => format(mb_strtolower(replace_accent($item['lastname_initial']))), 'lastname_main' => format(mb_strtolower(replace_accent($item['lastname_main']))), 'lastname_ordinary' => format(mb_strtolower(replace_accent($item['lastname_ordinary']))));
    $updates_count += fix_ax_particles($ax, $xorg, $item);
    $updates_count += fix_xorg_particles($ax, $xorg, $item);
    $updates_count += fix_xorg_full_name($ax, $xorg, $item);
    $updates_count += fix_xorg_ordinary_name($ax, $xorg, $item);
    printf("\r%u / %u", $count, $total);
    ++$count;
}
printf("\r%u / %u\n\n", $count, $total);
echo "Nombre de mises à jour effectuées : " . $updates_count . ".\n";
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
示例#12
0
 function handler_lists($page, $order_by = null, $order = null)
 {
     require_once 'emails.inc.php';
     if (!$this->get_lists_domain()) {
         return PL_NOT_FOUND;
     }
     $page->changeTpl('xnetlists/index.tpl');
     if (Get::has('del')) {
         S::assert_xsrf_token();
         $mlist = $this->prepare_list(Get::v('del'));
         $mlist->unsubscribe();
         pl_redirect('lists');
     }
     if (Get::has('add')) {
         S::assert_xsrf_token();
         $mlist = $this->prepare_list(Get::v('add'));
         $mlist->subscribe();
         pl_redirect('lists');
     }
     if (Post::has('del_alias') && may_update()) {
         S::assert_xsrf_token();
         $alias = Post::t('del_alias');
         list($local_part, ) = explode('@', $alias);
         delete_list_alias($local_part, $this->get_lists_domain());
         $page->trigSuccess($alias . ' supprimé&nbsp;!');
     }
     $client = $this->prepare_client();
     $listes = $client->get_lists();
     // Default ordering is by ascending names.
     if (is_null($order_by) || is_null($order) || !in_array($order_by, array('list', 'desc', 'nbsub')) || !in_array($order, array('asc', 'desc'))) {
         $order_by = 'list';
         $order = 'asc';
     }
     $compare = function ($a, $b) use($order_by, $order) {
         switch ($order_by) {
             case 'desc':
                 $a[$order_by] = replace_accent($a[$order_by]);
                 $b[$order_by] = replace_accent($b[$order_by]);
             case 'list':
                 $res = strcasecmp($a[$order_by], $b[$order_by]);
                 break;
             case 'nbsub':
                 $res = $a[$order_by] - $b[$order_by];
                 break;
             default:
                 $res = 0;
         }
         if ($order == 'asc') {
             return $res;
         }
         return $res * -1;
     };
     usort($listes, $compare);
     $page->assign('listes', $listes);
     $page->assign('order_by', $order_by);
     $page->assign('order', $order);
     $page->assign('aliases', iterate_list_alias($this->get_lists_domain()));
     $page->assign('may_update', may_update());
     if (S::suid()) {
         $page->trigWarning("Attention&nbsp;: l'affichage des listes de diffusion ne tient pas compte de l'option « Voir le site comme&hellip; ».");
     }
     global $globals;
     if (count($listes) > 0 && !$globals->asso('has_ml')) {
         XDB::execute("UPDATE  groups\n                             SET  flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'has_ml')\n                           WHERE  id = {?}", $globals->asso('id'));
     }
 }
示例#13
0
 protected function check(UserFilterBuilder $ufb)
 {
     if ($ufb->blank($this->envfield)) {
         $this->empty = true;
         return true;
     }
     $this->val = str_replace('*', '%', replace_accent($ufb->t($this->envfield)));
     return true;
 }
示例#14
0
 public static function compareDirectoryName($a, $b)
 {
     return strcasecmp(replace_accent($a->directoryName()), replace_accent($b->directoryName()));
 }
示例#15
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: */
示例#16
0
}
print "Deletes duplicated addresses. (1/4)\n";
$pids = XDB::rawFetchColumn("SELECT  DISTINCT(pid)\n                               FROM  profile_addresses AS a1\n                              WHERE  type = 'home' AND EXISTS (SELECT  *\n                                                                 FROM  profile_addresses AS a2\n                                                                WHERE  a2.type = 'home' AND a2.pid = a1.pid AND a2.id != a1.id)\n                           ORDER BY  pid");
$total = count($pids);
$done = 0;
$aux = 0;
$deleted = 0;
$addresses = array();
$rawAddresses = array();
$duplicates = array();
foreach ($pids as $pid) {
    $count = 0;
    $it = Address::iterate(array($pid), array(Address::LINK_PROFILE), array(0), Visibility::get(Visibility::VIEW_PRIVATE));
    while ($item = $it->next()) {
        $addresses[$count] = $item;
        $rawAddress = preg_replace('/[^a-z0-9]/', ' ', mb_strtolower(replace_accent($item->text)));
        $rawAddresses[$count] = array('long' => preg_replace('/\\s+/', '', $rawAddress), 'short' => preg_replace('/\\s+/', '', preg_replace($patterns, $replacements, $rawAddress)));
        ++$count;
    }
    for ($i = 0; $i < $count; ++$i) {
        for ($j = $i + 1; $j < $count; ++$j) {
            if (check($rawAddresses[$i], $rawAddresses[$j])) {
                $duplicates[$j] = true;
                if (Visibility::isLessRestrictive($addresses[$i]->pub, $addresses[$j]->pub)) {
                    $addresses[$i]->pub = $addresses[$j]->pub;
                }
                if ($addresses[$j]->hasFlag('mail') && !$addresses[$i]->hasFlag('mail')) {
                    $addresses[$i]->addFlag('mail');
                }
            }
        }
示例#17
0
文件: search.php 项目: Ekleog/platal
 /** 
  * $model: The way of presenting the results: minifiche, trombi, geoloc.
  * $byletter: Show only names beginning with this letter
  */
 function handler_quick($page, $model = null, $byletter = null)
 {
     global $globals;
     if (Env::has('quick') || $model == 'geoloc') {
         $quick = Env::t('quick');
         if (S::logged() && !Env::has('page')) {
             S::logger()->log('search', 'quick=' . $quick);
         }
         if ($quick == '') {
             $page->trigWarning('Aucun critère de recherche n\'est spécifié.');
             $page->changeTpl('search/index.tpl');
             $page->setTitle('Annuaire');
             $page->assign('formulaire', 1);
             return;
         }
         $list = 'profile|prf|fiche|fic|referent|ref|mentor';
         if (S::admin()) {
             $list .= '|admin|adm|ax';
         }
         $suffixes = array_keys(DirEnum::getOptions(DirEnum::ACCOUNTTYPES));
         $suffixes = implode('|', $suffixes);
         if (preg_match('/^(' . $list . '):([-a-z]+(\\.[-a-z]+(\\.(?:[md]?\\d{2,4}|' . $suffixes . '))?)?)$/', replace_accent($quick), $matches)) {
             $login = $matches[2];
             switch ($matches[1]) {
                 case 'admin':
                 case 'adm':
                     $base = 'admin/user/';
                     break;
                 case 'ax':
                     $base = 'profile/ax/';
                     break;
                 case 'profile':
                 case 'prf':
                 case 'fiche':
                 case 'fic':
                     $base = 'profile/';
                     break;
                 case 'referent':
                 case 'ref':
                 case 'mentor':
                     $base = 'referent/';
                     break;
             }
             $user = User::getSilent($login);
             if ($user) {
                 pl_redirect($base . $user->login());
             }
             Get::set('quick', $login);
         } elseif (strpos($quick, 'doc:') === 0) {
             $url = 'Docs/Recherche?';
             $url .= 'action=search&q=' . urlencode(substr($quick, 4));
             $url .= '&group=' . urlencode('-Equipe,-Main,-PmWiki,-Site,-Review');
             pl_redirect($url);
         } elseif (strpos($quick, 'trombi:') === 0) {
             $promo = substr($quick, 7);
             $res = XDB::query("SELECT  diminutif\n                                     FROM  groups\n                                    WHERE  cat = 'Promotions' AND diminutif = {?}", $promo);
             if ($res->numRows() == 0) {
                 $page->trigWarning("La promotion demandée n'est pas valide: {$promo}");
             } else {
                 http_redirect('http://www.polytechnique.net/login/' . $promo . '/annuaire/trombi');
             }
         }
         $page->assign('formulaire', 0);
         require_once 'userset.inc.php';
         $view = new QuickSearchSet();
         $view->addMod('minifiche', 'Mini-fiches', true, array('with_score' => true, 'starts_with' => $byletter));
         $view->addMod('map', 'Planisphère');
         if (S::logged() && !Env::i('nonins')) {
             $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true, 'with_score' => true));
         }
         $view->apply('search', $page, $model);
         $nb_tot = $view->count();
         $page->assign('search_results_nb', $nb_tot);
         if (!S::logged() && $nb_tot > $globals->search->public_max) {
             $page->trigError('Votre recherche a généré trop de résultats pour un affichage public.');
         } elseif ($nb_tot > $globals->search->private_max) {
             $page->trigError('Recherche trop générale. Une <a href="search/adv">recherche avancée</a> permet de préciser la recherche.');
         } elseif (empty($nb_tot)) {
             $page->trigError('Il n\'existe personne correspondant à ces critères dans la base !');
         }
     } else {
         $page->assign('formulaire', 1);
     }
     $page->changeTpl('search/index.tpl');
     $page->setTitle('Annuaire');
 }