From 08cce2ff528b38bde27cdec6d6bc28d6af4a42d4 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sun, 16 Jul 2006 22:09:30 +0000 Subject: [PATCH] rework XOrgDB -> XDB (shorter, easier to use). make the damn class be static $globals->xdb is now gone, long live XDB:: this should allow us to remove a *lot* of : global $globals; statements everywhere, which is good git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@527 839d8a87-29fc-0310-9880-83ba4fa771e5 --- bin/cron/clean.php | 2 +- bin/cron/cron_validations.php | 2 +- bin/cron/homonymes.php | 4 +- bin/cron/rapports_inscription.php | 6 +- bin/cron/recherche.php | 4 +- bin/emails.broken.php | 4 +- bin/newsletter.send.php | 4 +- bin/search.rebuild_db.php | 4 +- hooks/banana.inc.php | 6 +- htdocs.net/groupe/getCityInfos.php | 2 +- htdocs/admin/admin_trombino.php | 6 +- htdocs/admin/ax-xorg.php | 6 +- htdocs/admin/deces_promo.php | 6 +- htdocs/admin/emails_bounces_re.php | 4 +- htdocs/admin/evenements.php | 16 ++-- htdocs/admin/geoloc.php | 4 +- htdocs/admin/geoloc_dynamap.php | 8 +- htdocs/admin/gerer_decos.php | 8 +- htdocs/admin/homonymes.php | 6 +- htdocs/admin/index.php | 2 +- htdocs/admin/postfix_delayed.php | 6 +- htdocs/admin/synchro_ax.php | 2 +- htdocs/admin/utilisateurs.php | 20 ++--- include/applis.func.inc.php | 6 +- include/banana.inc.php | 16 ++-- include/contacts.pdf.inc.php | 2 +- include/emails.inc.php | 22 +++--- include/fonction.emploi.inc.php | 2 +- include/geoloc.inc.php | 34 ++++----- include/homonymes.inc.php | 8 +- include/lists.inc.php | 4 +- include/marketing.inc.php | 14 ++-- include/money.inc.php | 6 +- include/money/cyberpaiement.inc.php | 2 +- include/money/paypal.inc.php | 4 +- include/money/trezo.inc.php | 4 +- include/newsletter.inc.php | 32 ++++---- include/nomusage.inc.php | 12 +-- include/notifs.inc.php | 50 ++++++------- include/platal/database.inc.php | 29 ++------ include/profil/assign_deco.inc.php | 4 +- include/profil/assign_poly.inc.php | 4 +- include/profil/get_adresses.inc.php | 10 +-- include/profil/get_deco.inc.php | 10 +-- include/profil/get_emploi.inc.php | 8 +- include/profil/get_general.inc.php | 6 +- include/profil/get_mentor.inc.php | 14 ++-- include/profil/get_poly.inc.php | 10 +-- include/profil/get_skill.inc.php | 16 ++-- include/profil/update_adresses.inc.php | 10 +-- include/profil/update_deco.inc.php | 2 +- include/profil/update_emploi.inc.php | 4 +- include/profil/update_general.inc.php | 14 ++-- include/profil/update_mentor.inc.php | 2 +- include/profil/update_poly.inc.php | 2 +- include/register.inc.php | 22 +++--- include/rss.inc.php | 2 +- include/secteur.emploi.inc.php | 4 +- include/user.func.inc.php | 106 +++++++++++++-------------- include/validations.inc.php | 16 ++-- include/validations/aliases.inc.php | 10 +-- include/validations/evts.inc.php | 2 +- include/validations/homonymes.inc.php | 4 +- include/validations/listes.inc.php | 2 +- include/validations/marketing.inc.php | 2 +- include/validations/nomusage.inc.php | 2 +- include/validations/orange.inc.php | 4 +- include/validations/paiements.inc.php | 12 +-- include/validations/photos.inc.php | 2 +- include/webservices/manageurs.server.inc.php | 8 +- include/xnet/globals.inc.php | 9 +-- include/xnet/mail.inc.php | 6 +- include/xnet/session.inc.php | 6 +- include/xnet/smarty.plugins.inc.php | 2 +- include/xorg/globals.inc.php | 1 - include/xorg/session.inc.php | 12 +-- modules/auth.php | 6 +- modules/auth/auth.inc.php | 8 +- modules/banana.php | 4 +- modules/carnet.php | 18 ++--- modules/email.php | 32 ++++---- modules/events.php | 14 ++-- modules/geoloc.php | 4 +- modules/lists.php | 6 +- modules/marketing.php | 38 +++++----- modules/payment.php | 16 ++-- modules/platal.php | 40 +++++----- modules/profile.php | 54 +++++++------- modules/register.php | 26 +++---- modules/search.php | 24 +++--- modules/stats.php | 14 ++-- modules/trezo.php | 10 +-- modules/xnet.php | 28 +++---- modules/xnetevents.php | 56 +++++++------- modules/xnetevents/xnetevents.inc.php | 36 ++++----- modules/xnetgrp.php | 56 +++++++------- modules/xnetlists.php | 38 +++++----- plugins/function.select_db_table.php | 2 +- plugins/function.select_nat.php | 2 +- plugins/insert.getName.php | 2 +- plugins/insert.getNbIns.php | 2 +- plugins/insert.getUserName.php | 4 +- plugins/insert.mkStats.php | 2 +- scripts/listes_redirect.php | 2 +- scripts/webredirect.php | 2 +- 105 files changed, 628 insertions(+), 647 deletions(-) diff --git a/bin/cron/clean.php b/bin/cron/clean.php index 04b9694..f1a5058 100755 --- a/bin/cron/clean.php +++ b/bin/cron/clean.php @@ -24,7 +24,7 @@ require('./connect.db.inc.php'); function query ($sql) { global $globals; - $globals->xdb->execute($sql); + XDB::execute($sql); if (mysql_errno() != 0) { echo "error in \"$sql\" :\n", mysql_error(),"\n"; } diff --git a/bin/cron/cron_validations.php b/bin/cron/cron_validations.php index 1e00a16..621242a 100755 --- a/bin/cron/cron_validations.php +++ b/bin/cron/cron_validations.php @@ -29,7 +29,7 @@ $R_PERIOD = "INTERVAL 6 HOUR"; // p require('./connect.db.inc.php'); require('diogenes/diogenes.hermes.inc.php'); -$res = $globals->xdb->query("SELECT count(stamp), sum(stamp < NOW() - $M_PERIOD), sum(stamp < NOW() - $R_PERIOD) FROM x4dat.requests"); +$res = XDB::query("SELECT count(stamp), sum(stamp < NOW() - $M_PERIOD), sum(stamp < NOW() - $R_PERIOD) FROM x4dat.requests"); list($nb,$nbold,$nbveryold) = $res->fetchOneRow(); if (empty($nb)) { diff --git a/bin/cron/homonymes.php b/bin/cron/homonymes.php index fb8d50a..5fffa76 100755 --- a/bin/cron/homonymes.php +++ b/bin/cron/homonymes.php @@ -28,12 +28,12 @@ $W_PERIOD = "INTERVAL 7 DAY"; // temps d'envoi du warning avant la deadline require('./connect.db.inc.php'); -$resRobot = $globals->xdb->iterator("SELECT id, alias, expire FROM aliases WHERE (expire = NOW() + $W_PERIOD OR expire <= NOW()) AND type = 'alias'"); +$resRobot = XDB::iterator("SELECT id, alias, expire FROM aliases WHERE (expire = NOW() + $W_PERIOD OR expire <= NOW()) AND type = 'alias'"); if ($resRobot->total()) { require_once('validations/homonymes.inc.php'); while ($old = $resRobot->next()) { - $res = $globals->xdb->query("SELECT alias AS forlife FROM homonymes INNER JOIN aliases ON(user_id = id) WHERE homonyme_id = {?} AND type='a_vie'", $old['id']); + $res = XDB::query("SELECT alias AS forlife FROM homonymes INNER JOIN aliases ON(user_id = id) WHERE homonyme_id = {?} AND type='a_vie'", $old['id']); $forlifes = $res->fetchColumn(); $req = new HomonymeReq($old['id'], $old['alias'], $forlifes, $old['expire'] > date("Y-m-d")); $req->submit(); diff --git a/bin/cron/rapports_inscription.php b/bin/cron/rapports_inscription.php index f567ed5..c9d09fd 100755 --- a/bin/cron/rapports_inscription.php +++ b/bin/cron/rapports_inscription.php @@ -5,7 +5,7 @@ $MESSAGE = ''; // --------------------------------------- -$res = $globals->xdb->iterRow( +$res = XDB::iterRow( "SELECT a.alias, u.promo, email FROM auth_user_md5 AS u LEFT JOIN aliases AS a ON( u.user_id=a.id AND a.type='a_vie' ) @@ -22,7 +22,7 @@ if ($a = $res->total()) { // --------------------------------------- -$res = $globals->xdb->iterRow( +$res = XDB::iterRow( "SELECT forlife, email, date FROM register_pending WHERE hash != 'INSCRIT' @@ -36,7 +36,7 @@ if ($b = $res->total()) { // --------------------------------------- -$res = $globals->xdb->query('SELECT COUNT(DISTINCT uid), COUNT(*) FROM register_marketing'); +$res = XDB::query('SELECT COUNT(DISTINCT uid), COUNT(*) FROM register_marketing'); list($a, $b) = $res->fetchOneRow(); $MESSAGE .= "\n$c INSCRIPTIONS SOLICITÉES :\n"; $MESSAGE .= " $a utilisateurs\n $b adresses mails\n"; diff --git a/bin/cron/recherche.php b/bin/cron/recherche.php index 71157f2..58fafd1 100644 --- a/bin/cron/recherche.php +++ b/bin/cron/recherche.php @@ -22,10 +22,10 @@ require('./connect.db.inc.php'); -$res = $globals->xdb->iterRow('SELECT matricule,nom1,nom2,nom3,prenom1,prenom2,promo FROM recherche'); +$res = XDB::iterRow('SELECT matricule,nom1,nom2,nom3,prenom1,prenom2,promo FROM recherche'); while (list($matricule,$nom1,$nom2,$nom3,$prenom1,$prenom2,$promo) = $res->next()) { - $globals->xdb->execute( + XDB::execute( "INSERT INTO recherche_soundex (matricule,nom1_soundex,nom2_soundex,nom3_soundex,prenom1_soundex,prenom2_soundex,promo) VALUES ({?},{?},{?},{?},{?},{?},{?})", $matricule, soundex_fr($nom1), soundex_fr($nom2), soundex_fr($nom3), soundex_fr($prenom1), soundex_fr($prenom2), $promo); diff --git a/bin/emails.broken.php b/bin/emails.broken.php index e5a7021..d713c89 100755 --- a/bin/emails.broken.php +++ b/bin/emails.broken.php @@ -38,7 +38,7 @@ foreach ($emails as $_email) { continue; } - $sel = $globals->xdb->query( + $sel = XDB::query( "SELECT e1.uid, e1.panne != 0 AS panne, count(e2.uid) AS nb_mails, u.nom, u.prenom, u.promo, a.alias FROM emails AS e1 LEFT JOIN emails AS e2 ON (e1.uid = e2.uid AND FIND_IN_SET('active', e2.flags) AND e1.email != e2.email) @@ -48,7 +48,7 @@ foreach ($emails as $_email) { GROUP BY e1.uid", $email); if ($x = $sel->fetchOneAssoc()) { if (!$x['panne']) { - $globals->xdb->execute("UPDATE emails SET panne=NOW() WHERE email = {?}", $email); + XDB::execute("UPDATE emails SET panne=NOW() WHERE email = {?}", $email); } if (empty($x['nb_mails'])) { diff --git a/bin/newsletter.send.php b/bin/newsletter.send.php index 15b3359..e2466e8 100755 --- a/bin/newsletter.send.php +++ b/bin/newsletter.send.php @@ -38,7 +38,7 @@ $nl = new NewsLetter($id); $nl->setSent(); while(true) { - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT ni.user_id, a.alias, u.prenom, IF(u.nom_usage='', u.nom, u.nom_usage), FIND_IN_SET('femme', u.flags), @@ -56,7 +56,7 @@ while(true) { $sent[] = "user_id='$uid'"; $nl->sendTo($prenom, $nom, $bestalias, $sexe, $fmt=='html'); } - $globals->xdb->execute('UPDATE newsletter_ins SET last={?} WHERE '.implode(' OR ', $sent), $id); + XDB::execute('UPDATE newsletter_ins SET last={?} WHERE '.implode(' OR ', $sent), $id); sleep(60); } diff --git a/bin/search.rebuild_db.php b/bin/search.rebuild_db.php index baa738f..ad8d3b3 100755 --- a/bin/search.rebuild_db.php +++ b/bin/search.rebuild_db.php @@ -24,9 +24,9 @@ require('./connect.db.inc.php'); require('user.func.inc.php'); ini_set('memory_limit', "16M"); -$globals->xdb->execute('DELETE FROM search_name'); +XDB::execute('DELETE FROM search_name'); -$res = $globals->xdb->iterRow('SELECT auth_user_md5.user_id, nom, prenom, nom_usage, profile_nick FROM auth_user_md5 LEFT JOIN auth_user_quick USING(user_id)'); +$res = XDB::iterRow('SELECT auth_user_md5.user_id, nom, prenom, nom_usage, profile_nick FROM auth_user_md5 LEFT JOIN auth_user_quick USING(user_id)'); $i = 0; $muls = array(1,1,1,0.2); while ($tmp = $res->next()) { diff --git a/hooks/banana.inc.php b/hooks/banana.inc.php index cd1a9bf..d008532 100644 --- a/hooks/banana.inc.php +++ b/hooks/banana.inc.php @@ -62,11 +62,11 @@ function banana_subscribe($forlife, $uid, $promo, $password) $p_for = "xorg.promo.x$promo"; // récupération de l'id du forum promo - $res = $globals->xdb->query("SELECT fid FROM forums.list WHERE nom={?}", $p_for); + $res = XDB::query("SELECT fid FROM forums.list WHERE nom={?}", $p_for); if ($res->numRows()) { $cible[] = $p_for; } else { // pas de forum promo, il faut le créer - $res = $globals->xdb->query("SELECT SUM(perms IN ('admin','user') AND deces=0),COUNT(*) + $res = XDB::query("SELECT SUM(perms IN ('admin','user') AND deces=0),COUNT(*) FROM auth_user_md5 WHERE promo={?}", $promo); list($effau, $effid) = $res->fetchOneRow(); if (5*$effau>$effid) { // + de 20% d'inscrits @@ -78,7 +78,7 @@ function banana_subscribe($forlife, $uid, $promo, $password) } while (list ($key, $val) = each ($cible)) { - $globals->xdb->execute("INSERT INTO forums.abos (fid,uid) + XDB::execute("INSERT INTO forums.abos (fid,uid) SELECT fid,{?} FROM forums.list WHERE nom={?}", $uid, $val); } } diff --git a/htdocs.net/groupe/getCityInfos.php b/htdocs.net/groupe/getCityInfos.php index 80d8032..abfb114 100644 --- a/htdocs.net/groupe/getCityInfos.php +++ b/htdocs.net/groupe/getCityInfos.php @@ -38,7 +38,7 @@ $fields = new SFieldGroup(true, array($assoField, $cityIdField)); $where = $fields->get_where_statement(); if ($where) $where = "WHERE ".$where; -$users = $globals->xdb->iterator(" +$users = XDB::iterator(" SELECT u.user_id AS id, u.prenom, u.nom, u.promo FROM adresses AS a INNER JOIN auth_user_md5 AS u ON(u.user_id = a.uid) diff --git a/htdocs/admin/admin_trombino.php b/htdocs/admin/admin_trombino.php index 4211b24..4261842 100644 --- a/htdocs/admin/admin_trombino.php +++ b/htdocs/admin/admin_trombino.php @@ -24,7 +24,7 @@ new_admin_page('admin/admin_trombino.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration - Trombino'); $uid = Env::getInt('uid'); -$q = $globals->xdb->query( +$q = XDB::query( "SELECT a.alias,promo FROM auth_user_md5 AS u INNER JOIN aliases AS a ON ( u.user_id = a.id AND type='a_vie' ) @@ -44,13 +44,13 @@ switch (Env::get('action')) { list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']); $mimetype = substr($_FILES['userfile']['type'], 6); unlink($_FILES['userfile']['tmp_name']); - $globals->xdb->execute( + XDB::execute( "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}", $uid, $mimetype, $data, $x, $y); break; case "supprimer": - $globals->xdb->execute('DELETE FROM photo WHERE uid = {?}', $uid); + XDB::execute('DELETE FROM photo WHERE uid = {?}', $uid); break; } diff --git a/htdocs/admin/ax-xorg.php b/htdocs/admin/ax-xorg.php index f95b951..d6218f6 100644 --- a/htdocs/admin/ax-xorg.php +++ b/htdocs/admin/ax-xorg.php @@ -24,7 +24,7 @@ new_admin_page('admin/ax-xorg.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration - AX/X.org'); // liste des différences -$res = $globals->xdb->query( +$res = XDB::query( 'SELECT u.promo,u.nom AS nom,u.prenom AS prenom,ia.nom AS nomax,ia.prenom AS prenomax,u.matricule AS mat,ia.matricule_ax AS matax FROM auth_user_md5 AS u INNER JOIN identification_ax AS ia ON u.matricule_ax = ia.matricule_ax @@ -35,7 +35,7 @@ $res = $globals->xdb->query( $page->assign('diffs', $res->fetchAllAssoc()); // gens à l'ax mais pas chez nous -$res = $globals->xdb->query( +$res = XDB::query( 'SELECT ia.promo,ia.nom,ia.nom_patro,ia.prenom FROM identification_ax as ia LEFT JOIN auth_user_md5 AS u ON u.matricule_ax = ia.matricule_ax @@ -43,7 +43,7 @@ $res = $globals->xdb->query( $page->assign('mank', $res->fetchAllAssoc()); // gens chez nous et pas à l'ax -$res = $globals->xdb->query('SELECT promo,nom,prenom FROM auth_user_md5 WHERE matricule_ax IS NULL'); +$res = XDB::query('SELECT promo,nom,prenom FROM auth_user_md5 WHERE matricule_ax IS NULL'); $page->assign('plus', $res->fetchAllAssoc()); diff --git a/htdocs/admin/deces_promo.php b/htdocs/admin/deces_promo.php index 7479c08..debfe55 100644 --- a/htdocs/admin/deces_promo.php +++ b/htdocs/admin/deces_promo.php @@ -33,11 +33,11 @@ $page->assign('promo',$promo); if (Env::get('valider') == "Valider") { $new_deces = array(); - $res = $globals->xdb->iterRow("SELECT user_id,matricule,nom,prenom,deces FROM auth_user_md5 WHERE promo = {?}", $promo); + $res = XDB::iterRow("SELECT user_id,matricule,nom,prenom,deces FROM auth_user_md5 WHERE promo = {?}", $promo); while (list($uid,$mat,$nom,$prenom,$deces) = $res->next()) { $val = Env::get($mat); if($val == $deces || empty($val)) continue; - $globals->xdb->execute('UPDATE auth_user_md5 SET deces={?} WHERE matricule = {?}', $val, $mat); + XDB::execute('UPDATE auth_user_md5 SET deces={?} WHERE matricule = {?}', $val, $mat); $new_deces[] = array('name' => "$prenom $nom", 'date' => "$val"); if($deces=='0000-00-00' or empty($deces)) { require_once('notifs.inc.php'); @@ -49,7 +49,7 @@ if (Env::get('valider') == "Valider") { $page->assign('new_deces',$new_deces); } -$res = $globals->xdb->iterator('SELECT matricule, nom, prenom, deces FROM auth_user_md5 WHERE promo = {?} ORDER BY nom,prenom', $promo); +$res = XDB::iterator('SELECT matricule, nom, prenom, deces FROM auth_user_md5 WHERE promo = {?} ORDER BY nom,prenom', $promo); $page->assign('decedes', $res); $page->run(); diff --git a/htdocs/admin/emails_bounces_re.php b/htdocs/admin/emails_bounces_re.php index 21b2356..8a934b1 100644 --- a/htdocs/admin/emails_bounces_re.php +++ b/htdocs/admin/emails_bounces_re.php @@ -25,14 +25,14 @@ $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Regex if (Post::has('submit')) { foreach (Env::getMixed('lvl') as $id=>$val) { - $globals->xdb->query( + XDB::query( "REPLACE INTO emails_bounces_re (id,pos,lvl,re,text) VALUES ({?}, {?}, {?}, {?}, {?})", $id, $_POST['pos'][$id], $_POST['lvl'][$id], $_POST['re'][$id], $_POST['text'][$id] ); } } -$page->assign('bre', $globals->xdb->iterator("SELECT * FROM emails_bounces_re ORDER BY pos")); +$page->assign('bre', XDB::iterator("SELECT * FROM emails_bounces_re ORDER BY pos")); $page->run(); ?> diff --git a/htdocs/admin/evenements.php b/htdocs/admin/evenements.php index cafe7d4..dc27ecd 100644 --- a/htdocs/admin/evenements.php +++ b/htdocs/admin/evenements.php @@ -29,32 +29,32 @@ $page->assign('arch', $arch); switch(Post::get('action')) { case "Proposer": - $globals->xdb->execute('UPDATE evenements SET titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?} WHERE id = {?}', + XDB::execute('UPDATE evenements SET titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?} WHERE id = {?}', Post::get('titre'), Post::get('texte'), Post::get('peremption'), Post::get('promo_min'), Post::get('promo_max'), $evid); break; case "Valider": - $globals->xdb->execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",valide") WHERE id = {?}', $evid); + XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",valide") WHERE id = {?}', $evid); break; case "Invalider": - $globals->xdb->execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"valide", "") WHERE id = {?}', $evid); + XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"valide", "") WHERE id = {?}', $evid); break; case "Supprimer": - $globals->xdb->execute('DELETE from evenements WHERE id = {?}', $evid); + XDB::execute('DELETE from evenements WHERE id = {?}', $evid); break; case "Archiver": - $globals->xdb->execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",archive") WHERE id = {?}', $evid); + XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",archive") WHERE id = {?}', $evid); break; case "Desarchiver": - $globals->xdb->execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"archive","") WHERE id = {?}', $evid); + XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"archive","") WHERE id = {?}', $evid); break; case "Editer": - $res = $globals->xdb->query('SELECT titre, texte, peremption, promo_min, promo_max FROM evenements WHERE id={?}', $evid); + $res = XDB::query('SELECT titre, texte, peremption, promo_min, promo_max FROM evenements WHERE id={?}', $evid); list($titre, $texte, $peremption, $promo_min, $promo_max) = $res->fetchOneRow(); $page->assign('mode', 'edit'); $page->assign('titre',$titre); @@ -91,7 +91,7 @@ if ($action != "Editer") { INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie') WHERE ".($arch ? "" : "!")."FIND_IN_SET('archive',e.flags) ORDER BY FIND_IN_SET('valide',e.flags), peremption"; - $page->assign('evs', $globals->xdb->iterator($sql)); + $page->assign('evs', XDB::iterator($sql)); } $page->run(); diff --git a/htdocs/admin/geoloc.php b/htdocs/admin/geoloc.php index b4149fa..fa027b7 100644 --- a/htdocs/admin/geoloc.php +++ b/htdocs/admin/geoloc.php @@ -31,14 +31,14 @@ if (Env::has('id') && is_numeric(Env::get('id'))) { } if (Env::has('missinglat')) { - $res = $globals->xdb->iterRow("SELECT id FROM geoloc_city WHERE lat = 0 AND lon = 0"); + $res = XDB::iterRow("SELECT id FROM geoloc_city WHERE lat = 0 AND lon = 0"); while ($a = $res->next()) if (synchro_city($a[0])) $nb_synchro++; } if ($nb_synchro) $page->trig(($nb_synchro > 1)?($nb_synchro." villes ont été synchronisées"):"Une ville a été synchronisée"); -$res = $globals->xdb->query("SELECT COUNT(*) FROM geoloc_city WHERE lat = 0 AND lon = 0"); +$res = XDB::query("SELECT COUNT(*) FROM geoloc_city WHERE lat = 0 AND lon = 0"); $page->assign("nb_missinglat", $res->fetchOneCell()); $page->run(); diff --git a/htdocs/admin/geoloc_dynamap.php b/htdocs/admin/geoloc_dynamap.php index 88827f9..22841de 100644 --- a/htdocs/admin/geoloc_dynamap.php +++ b/htdocs/admin/geoloc_dynamap.php @@ -36,7 +36,7 @@ if (Env::get('fix') == 'smallest_maps') { } if (Env::get('fix') == 'precise_coordinates') { - $globals->xdb->execute("UPDATE adresses AS a INNER JOIN geoloc_city AS c ON(a.cityid = c.id) SET a.glat = c.lat / 100000, a.glng = c.lon / 100000"); + XDB::execute("UPDATE adresses AS a INNER JOIN geoloc_city AS c ON(a.cityid = c.id) SET a.glat = c.lat / 100000, a.glng = c.lon / 100000"); } if (Env::has('new_maps')) { @@ -45,13 +45,13 @@ if (Env::has('new_maps')) { $page->trig("Impossible d'accéder aux nouvelles cartes"); } -$countMissing = $globals->xdb->query("SELECT COUNT(*) FROM geoloc_city AS c LEFT JOIN geoloc_city_in_maps AS m ON(c.id = m.city_id) WHERE m.city_id IS NULL"); +$countMissing = XDB::query("SELECT COUNT(*) FROM geoloc_city AS c LEFT JOIN geoloc_city_in_maps AS m ON(c.id = m.city_id) WHERE m.city_id IS NULL"); $missing = $countMissing->fetchOneCell(); -$countNoSmallest = $globals->xdb->query("SELECT SUM(IF(infos = 'smallest',1,0)) AS n FROM geoloc_city_in_maps GROUP BY city_id ORDER BY n"); +$countNoSmallest = XDB::query("SELECT SUM(IF(infos = 'smallest',1,0)) AS n FROM geoloc_city_in_maps GROUP BY city_id ORDER BY n"); $noSmallest = $countNoSmallest->fetchOneCell() == 0; -$countNoCoordinates = $globals->xdb->query("SELECT COUNT(*) FROM adresses WHERE cityid IS NOT NULL AND glat = 0 AND glng = 0"); +$countNoCoordinates = XDB::query("SELECT COUNT(*) FROM adresses WHERE cityid IS NOT NULL AND glat = 0 AND glng = 0"); $noCoordinates = $countNoCoordinates->fetchOneCell(); if (isset($refresh) && $missing) { diff --git a/htdocs/admin/gerer_decos.php b/htdocs/admin/gerer_decos.php index 4b29337..ec90d95 100644 --- a/htdocs/admin/gerer_decos.php +++ b/htdocs/admin/gerer_decos.php @@ -35,16 +35,16 @@ if (Post::get('frm_id')) { $mid = Post::getInt('frm_id'); if (Post::get('act') == 'del') { - $globals->xdb->execute('DELETE FROM profile_medals_grades WHERE mid={?} AND gid={?}', $mid, Post::getInt('gid')); + XDB::execute('DELETE FROM profile_medals_grades WHERE mid={?} AND gid={?}', $mid, Post::getInt('gid')); } elseif (Post::get('act') == 'new') { - $globals->xdb->execute('INSERT INTO profile_medals_grades (mid,gid) VALUES({?},{?})', + XDB::execute('INSERT INTO profile_medals_grades (mid,gid) VALUES({?},{?})', $mid, max(array_keys(Post::getMixed('grades', Array(0))))+1); } else { foreach (Post::getMixed('grades', Array()) as $gid=>$text) { - $globals->xdb->execute('UPDATE profile_medals_grades SET pos={?}, text={?} WHERE gid={?}', $_POST['pos'][$gid], $text, $gid); + XDB::execute('UPDATE profile_medals_grades SET pos={?}, text={?} WHERE gid={?}', $_POST['pos'][$gid], $text, $gid); } } - $res = $globals->xdb->iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid); + $res = XDB::iterator('SELECT gid, text, pos FROM profile_medals_grades WHERE mid={?} ORDER BY pos', $mid); $page->assign('grades', $res); } diff --git a/htdocs/admin/homonymes.php b/htdocs/admin/homonymes.php index 7c2ba81..ff2d3f0 100644 --- a/htdocs/admin/homonymes.php +++ b/htdocs/admin/homonymes.php @@ -54,8 +54,8 @@ if ($target) { break; case 'correct': switch_bestalias($target, $loginbis); - $globals->xdb->execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $loginbis); - $globals->xdb->execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $target, $target); + XDB::execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $loginbis); + XDB::execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $target, $target); send_robot_homonyme($prenom, $nom, $forlife, $loginbis); $op = 'list'; break; @@ -63,7 +63,7 @@ if ($target) { } if ($op == 'list') { - $res = $globals->xdb->iterator( + $res = XDB::iterator( "SELECT a.alias AS homonyme,s.id AS user_id,s.alias AS forlife, promo,prenom,nom, IF(h.homonyme_id=s.id, a.expire, NULL) AS expire, diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index b7f9f2d..0b50e49 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -23,7 +23,7 @@ require_once("xorg.inc.php"); new_admin_page('admin/index.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration'); -$res = $globals->xdb->iterRow(" +$res = XDB::iterRow(" SELECT h1, h2, texte, url FROM admin_a AS a INNER JOIN admin_h2 AS h2 USING(h2id) diff --git a/htdocs/admin/postfix_delayed.php b/htdocs/admin/postfix_delayed.php index 476556a..0277ddb 100644 --- a/htdocs/admin/postfix_delayed.php +++ b/htdocs/admin/postfix_delayed.php @@ -26,15 +26,15 @@ $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retar if (Env::has('del')) { $crc = Env::get('crc'); - $globals->xdb->execute("UPDATE postfix_mailseen SET release = 'del' WHERE crc = {?}", $crc); + XDB::execute("UPDATE postfix_mailseen SET release = 'del' WHERE crc = {?}", $crc); $page->trig($crc." verra tous ses mails supprimés !"); } elseif (Env::has('ok')) { $crc = Env::get('crc'); - $globals->xdb->execute("UPDATE postfix_mailseen SET release = 'ok' WHERE crc = {?}", $crc); + XDB::execute("UPDATE postfix_mailseen SET release = 'ok' WHERE crc = {?}", $crc); $page->trig($crc." a le droit de passer !"); } -$sql = $globals->xdb->iterator( +$sql = XDB::iterator( "SELECT crc, nb, update_time, create_time, FIND_IN_SET('del', release) AS del, FIND_IN_SET('ok', release) AS ok diff --git a/htdocs/admin/synchro_ax.php b/htdocs/admin/synchro_ax.php index dccb972..574e844 100644 --- a/htdocs/admin/synchro_ax.php +++ b/htdocs/admin/synchro_ax.php @@ -41,7 +41,7 @@ if (Env::has('user')) { } if (Env::has('mat')) { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT alias FROM aliases AS a INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie') diff --git a/htdocs/admin/utilisateurs.php b/htdocs/admin/utilisateurs.php index 044e67e..0d47a54 100644 --- a/htdocs/admin/utilisateurs.php +++ b/htdocs/admin/utilisateurs.php @@ -48,7 +48,7 @@ if (Env::has('ax_button') && $login) { if(Env::has('suid_button') && $login) { $_SESSION['log']->log("suid_start", "login by ".Session::get('forlife')); $_SESSION['suid'] = $_SESSION; - $r = $globals->xdb->query("SELECT id FROM aliases WHERE alias={?}", $login); + $r = XDB::query("SELECT id FROM aliases WHERE alias={?}", $login); if($uid = $r->fetchOneCell()) { start_connexion($uid,true); redirect("../"); @@ -56,7 +56,7 @@ if(Env::has('suid_button') && $login) { } if ($login) { - $r = $globals->xdb->query("SELECT *, a.alias AS forlife, u.flags AS sexe + $r = XDB::query("SELECT *, a.alias AS forlife, u.flags AS sexe FROM auth_user_md5 AS u INNER JOIN aliases AS a ON ( a.id = u.user_id AND a.alias={?} AND type!='homonyme' )", $login); $mr = $r->fetchOneAssoc(); @@ -84,7 +84,7 @@ if ($login) { case "del_alias": if (!empty($val)) { - $globals->xdb->execute("DELETE FROM aliases WHERE id={?} AND alias={?} + XDB::execute("DELETE FROM aliases WHERE id={?} AND alias={?} AND type!='a_vie' AND type!='homonyme'", $mr['user_id'], $val); fix_bestalias($mr['user_id']); $page->trig($val." a été supprimé"); @@ -101,15 +101,15 @@ if ($login) { } break; case "add_alias": - $globals->xdb->execute("INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, 'alias')", + XDB::execute("INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, 'alias')", $mr['user_id'], Env::get('email')); break; case "best": // 'bestalias' is the first bit of the set : 1 // 255 is the max for flags (8 sets max) - $globals->xdb->execute("UPDATE aliases SET flags= flags & (255 - 1) WHERE id={?}", $mr['user_id']); - $globals->xdb->execute("UPDATE aliases + XDB::execute("UPDATE aliases SET flags= flags & (255 - 1) WHERE id={?}", $mr['user_id']); + XDB::execute("UPDATE aliases SET flags= flags | 1 WHERE id={?} AND alias={?}", $mr['user_id'], $val); break; @@ -137,7 +137,7 @@ if ($login) { promo = $promo, comment = '".addslashes($comm)."' WHERE user_id = '{$mr['user_id']}'"; - if ($globals->xdb->execute($query)) { + if (XDB::execute($query)) { user_reindex($mr['user_id']); require_once("diogenes/diogenes.hermes.inc.php"); @@ -154,7 +154,7 @@ if ($login) { require_once('nomusage.inc.php'); set_new_usage($mr['user_id'], Env::get('nomusageN'), make_username(Env::get('prenomN'), Env::get('nomusageN'))); } - $r = $globals->xdb->query("SELECT *, a.alias AS forlife, u.flags AS sexe + $r = XDB::query("SELECT *, a.alias AS forlife, u.flags AS sexe FROM auth_user_md5 AS u INNER JOIN aliases AS a ON (u.user_id=a.id) WHERE user_id = {?}", $mr['user_id']); @@ -176,7 +176,7 @@ if ($login) { } } - $res = $globals->xdb->query("SELECT UNIX_TIMESTAMP(start), host + $res = XDB::query("SELECT UNIX_TIMESTAMP(start), host FROM logger.sessions WHERE uid={?} AND suid=0 ORDER BY start DESC @@ -185,7 +185,7 @@ if ($login) { $page->assign('lastlogin', $lastlogin); $page->assign('host', $host); - $page->assign('aliases', $globals->xdb->iterator( + $page->assign('aliases', XDB::iterator( "SELECT alias, type='a_vie' AS for_life,FIND_IN_SET('bestalias',flags) AS best,expire FROM aliases WHERE id = {?} AND type!='homonyme' diff --git a/include/applis.func.inc.php b/include/applis.func.inc.php index 6f317ff..c3360ef 100644 --- a/include/applis.func.inc.php +++ b/include/applis.func.inc.php @@ -24,7 +24,7 @@ global $page; function applis_options($current=0) { global $globals; $html = ''; - $res = $globals->xdb->iterator("select * from applis_def order by text"); + $res = XDB::iterator("select * from applis_def order by text"); while ($arr_appli = $res->next()) { $html .= '\n"; - $res = $globals->xdb->iterRow("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) from fonctions_def ORDER BY id"); + $res = XDB::iterRow("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) from fonctions_def ORDER BY id"); while(list($fid, $flabel, $ftitre) = $res->next()){ if($ftitre) $html.= "\n"; diff --git a/include/geoloc.inc.php b/include/geoloc.inc.php index a8d2c08..a371f5b 100644 --- a/include/geoloc.inc.php +++ b/include/geoloc.inc.php @@ -26,7 +26,7 @@ */ function geoloc_country($current) { global $globals; - $res = $globals->xdb->iterRow('SELECT a2,pays FROM geoloc_pays ORDER BY pays'); + $res = XDB::iterRow('SELECT a2,pays FROM geoloc_pays ORDER BY pays'); $html = ""; while (list($my_id, $my_pays) = $res->next()) { $html .= sprintf("\n", @@ -48,7 +48,7 @@ $GLOBALS['page']->register_function('geoloc_country', '_geoloc_country_smarty'); */ function geoloc_region($country,$current) { global $globals; - $res = $globals->xdb->iterRow('SELECT region,name FROM geoloc_region where a2={?} ORDER BY name', $country); + $res = XDB::iterRow('SELECT region,name FROM geoloc_region where a2={?} ORDER BY name', $country); $html = ""; while (list($regid, $regname) = $res->next()) { $html .= sprintf("\n", @@ -81,9 +81,9 @@ function get_address_infos($txt) { $infos = array(); foreach ($keys as $i=>$key) if($vals[$i]) $infos[$key] = ($key == 'sql')?$vals[$i]:utf8_decode(strtr($vals[$i], array(chr(197).chr(147) => "œ"))); if ($infos['sql']) - $globals->xdb->execute("REPLACE INTO geoloc_city VALUES ".$infos['sql']); + XDB::execute("REPLACE INTO geoloc_city VALUES ".$infos['sql']); if ($infos['display']) - $globals->xdb->execute("UPDATE geoloc_pays SET display = {?} WHERE a2 = {?}", $infos['display'], $infos['country']); + XDB::execute("UPDATE geoloc_pays SET display = {?} WHERE a2 = {?}", $infos['display'], $infos['country']); return $infos; } // }}} @@ -115,14 +115,14 @@ function get_new_maps($url) { if (!($f = @fopen($url, 'r'))) return false; global $globals; - $globals->xdb->query('TRUNCATE TABLE geoloc_maps'); + XDB::query('TRUNCATE TABLE geoloc_maps'); $s = ''; while (!feof($f)) { $l = fgetcsv($f, 1024, ';', '"'); foreach ($l as $i => $val) if ($val != 'NULL') $l[$i] = '\''.addslashes($val).'\''; $s .= ',('.implode(',',$l).')'; } - $globals->xdb->execute('INSERT INTO geoloc_maps VALUES '.substr($s, 1)); + XDB::execute('INSERT INTO geoloc_maps VALUES '.substr($s, 1)); return true; } @@ -160,7 +160,7 @@ function get_address_text($adr) { if ($l) $t .= "\n".trim($l); if ($adr['country'] != '00' && (!$adr['countrytxt'] || $adr['countrytxt'] == strtoupper($adr['countrytxt']))) { global $globals; - $res = $globals->xdb->query("SELECT pays FROM geoloc_pays WHERE a2 = {?}", $adr['country']); + $res = XDB::query("SELECT pays FROM geoloc_pays WHERE a2 = {?}", $adr['country']); $adr['countrytxt'] = $res->fetchOneCell(); } if ($adr['countrytxt']) $t .= "\n".$adr['countrytxt']; @@ -215,13 +215,13 @@ function cut_address($txt) { */ function localize_addresses($uid) { global $globals; - $res = $globals->xdb->iterator("SELECT * FROM adresses WHERE uid = {?} and (cityid IS NULL OR cityid = 0)", $uid); + $res = XDB::iterator("SELECT * FROM adresses WHERE uid = {?} and (cityid IS NULL OR cityid = 0)", $uid); $erreur = Array(); while ($a = $res->next()) { $new = get_address_infos($ta = get_address_text($a)); if (compare_addresses_text($ta, get_address_text($new))) { - $globals->xdb->execute("UPDATE adresses SET + XDB::execute("UPDATE adresses SET adr1 = {?}, adr2 = {?}, adr3 = {?}, cityid = {?}, city = {?}, postcode = {?}, region = {?}, regiontxt = {?}, country = {?}, @@ -253,7 +253,7 @@ function localize_addresses($uid) { if (!($f = @fopen($url, 'r'))) return false; $s = fgets($f); if ($s) - return $globals->xdb->execute("REPLACE INTO geoloc_city VALUES ".$s) > 0; + return XDB::execute("REPLACE INTO geoloc_city VALUES ".$s) > 0; } // }}} @@ -261,7 +261,7 @@ function localize_addresses($uid) { function fix_cities_not_on_map($limit=false) { global $globals; - $missing = $globals->xdb->query("SELECT c.id FROM geoloc_city AS c LEFT JOIN geoloc_city_in_maps AS m ON(c.id = m.city_id) WHERE m.city_id IS NULL".($limit?" LIMIT $limit":"")); + $missing = XDB::query("SELECT c.id FROM geoloc_city AS c LEFT JOIN geoloc_city_in_maps AS m ON(c.id = m.city_id) WHERE m.city_id IS NULL".($limit?" LIMIT $limit":"")); $maps = get_cities_maps($missing->fetchColumn()); if ($maps) { @@ -269,7 +269,7 @@ function fix_cities_not_on_map($limit=false) foreach ($maps as $cityid => $maps_c) foreach ($maps_c as $map_id) $values .= ",($cityid, $map_id, '')"; - $globals->xdb->execute("REPLACE INTO geoloc_city_in_maps VALUES ".substr($values, 1)); + XDB::execute("REPLACE INTO geoloc_city_in_maps VALUES ".substr($values, 1)); } else return false; @@ -278,14 +278,14 @@ function fix_cities_not_on_map($limit=false) function set_smallest_levels() { global $globals; - $maxlengths = $globals->xdb->iterRow("SELECT MAX(LENGTH(gm.path)), gcim.city_id + $maxlengths = XDB::iterRow("SELECT MAX(LENGTH(gm.path)), gcim.city_id FROM geoloc_city_in_maps AS gcim INNER JOIN geoloc_maps AS gm USING ( map_id ) GROUP BY gcim.city_id "); while (list($length, $id) = $maxlengths->next()) { - $globals->xdb->execute("UPDATE geoloc_city_in_maps AS gcim + XDB::execute("UPDATE geoloc_city_in_maps AS gcim INNER JOIN geoloc_maps AS gm USING(map_id) SET gcim.infos = IF(LENGTH(gm.path) = {?}, 'smallest', '') WHERE gcim.city_id = {?}", $length, $id); @@ -315,7 +315,7 @@ function geoloc_getData_subcities($mapid, $SFields, &$cities, $direct=true) { $where = $fields->get_where_statement(); if ($where) $where = " AND ".$where; - $cityres = $globals->xdb->iterator(" + $cityres = XDB::iterator(" SELECT gc.id, gc.lon / 100000 AS x, gc.lat/100000 AS y, gc.name, @@ -348,7 +348,7 @@ function geoloc_getData_subcountries($mapid, $SFields, $minentities) { $wheremapid = "WHERE gm.parent IS NULL"; else $wheremapid = "WHERE gm.parent = {?}"; - $submapres = $globals->xdb->iterator( + $submapres = XDB::iterator( "SELECT gm.map_id AS id, gm.name, gm.x, gm.y, gm.xclip, gm.yclip, gm.width, gm.height, gm.scale, 1 AS rat FROM geoloc_maps AS gm @@ -376,7 +376,7 @@ function geoloc_getData_subcountries($mapid, $SFields, $minentities) { $where = $fields->get_where_statement(); if ($where) $where = " WHERE ".$where; - $countryres = $globals->xdb->iterator(" + $countryres = XDB::iterator(" SELECT map.map_id AS id, COUNT(u.user_id) AS nbPop, SUM(u.promo % 2) AS yellow, diff --git a/include/homonymes.inc.php b/include/homonymes.inc.php index c6bf25c..2777b2a 100644 --- a/include/homonymes.inc.php +++ b/include/homonymes.inc.php @@ -21,7 +21,7 @@ function select_if_homonyme($uid) { global $globals; - $res = $globals->xdb->query("SELECT prenom,nom,a.alias AS forlife,h.alias AS loginbis + $res = XDB::query("SELECT prenom,nom,a.alias AS forlife,h.alias AS loginbis FROM auth_user_md5 AS u INNER JOIN aliases AS a ON (a.id=u.user_id AND a.type='a_vie') INNER JOIN aliases AS h ON (h.id=u.user_id AND h.expire!='') @@ -58,15 +58,15 @@ function send_robot_homonyme($prenom, $nom, $forlife, $loginbis) { function switch_bestalias($uid, $loginbis) { global $globals; // check if loginbis was the bestalias - $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", $uid); + $res = XDB::query("SELECT alias FROM aliases WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", $uid); $bestalias = $res->fetchOneCell(); if ($bestalias && $bestalias != $loginbis) return false; // select the shortest alias still alive - $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id = {?} AND alias != {?} AND expire IS NULL ORDER BY LENGTH(alias) LIMIT 1", $uid, $loginbis); + $res = XDB::query("SELECT alias FROM aliases WHERE id = {?} AND alias != {?} AND expire IS NULL ORDER BY LENGTH(alias) LIMIT 1", $uid, $loginbis); $newbest = $res->fetchOneCell(); // change the bestalias flag - $globals->xdb->execute("UPDATE aliases SET flags = (flags & (255 - 1)) | IF(alias = {?}, 1, 0) WHERE id = {?}", $newbest, $uid); + XDB::execute("UPDATE aliases SET flags = (flags & (255 - 1)) | IF(alias = {?}, 1, 0) WHERE id = {?}", $newbest, $uid); return $newbest; } diff --git a/include/lists.inc.php b/include/lists.inc.php index 844d0de..d86b3f3 100644 --- a/include/lists.inc.php +++ b/include/lists.inc.php @@ -47,7 +47,7 @@ function list_sort_owners(&$members, $tri_promo = true) { foreach($members as $mem) { list($m, $dom) = explode('@',$mem); if ($dom == $globals->mail->domain || $dom == $globals->mail->domain2) { - $res = $globals->xdb->query('SELECT prenom,IF(nom_usage="", nom, nom_usage), promo + $res = XDB::query('SELECT prenom,IF(nom_usage="", nom, nom_usage), promo FROM auth_user_md5 AS u INNER JOIN aliases AS a ON u.user_id = a.id WHERE a.alias = {?}', $m); @@ -58,7 +58,7 @@ function list_sort_owners(&$members, $tri_promo = true) { $membres[0][] = Array('l' => $mem); } } else { - $res = $globals->xdb->query('SELECT prenom, nom FROM groupex.membres WHERE email={?}', $mem); + $res = XDB::query('SELECT prenom, nom FROM groupex.membres WHERE email={?}', $mem); if (list($prenom, $nom) = $res->fetchOneRow()) { $key = $tri_promo ? 0 : strtoupper($nom{0}); $membres[$key][$nom.$m] = Array('n' => "$prenom $nom", 'l' => $mem); diff --git a/include/marketing.inc.php b/include/marketing.inc.php index 74f7312..920b432 100644 --- a/include/marketing.inc.php +++ b/include/marketing.inc.php @@ -25,7 +25,7 @@ require_once("xorg.misc.inc.php"); function mark_from_mail($uid, $email) { global $globals; - $res = $globals->xdb->query( + $res = XDB::query( "SELECT u.nom, u.prenom, a.alias FROM register_marketing AS r INNER JOIN auth_user_md5 AS u ON (r.sender = u.user_id) @@ -45,10 +45,10 @@ function mark_text_mail($uid, $email) global $globals; $title = "Annuaire en ligne des Polytechniciens"; - $res = $globals->xdb->query("SELECT COUNT(*) FROM auth_user_md5 WHERE perms IN ('admin', 'user') and deces = 0"); + $res = XDB::query("SELECT COUNT(*) FROM auth_user_md5 WHERE perms IN ('admin', 'user') and deces = 0"); $num_users = $res->fetchOneCell(); - $res = $globals->xdb->query("SELECT flags, nom, prenom, promo FROM auth_user_md5 WHERE user_id = {?}", $uid); + $res = XDB::query("SELECT flags, nom, prenom, promo FROM auth_user_md5 WHERE user_id = {?}", $uid); $u = $res->fetchOneAssoc(); $mailorg = make_forlife($u['prenom'],$u['nom'],$u['promo']); @@ -84,7 +84,7 @@ function mark_send_mail($uid, $email, $perso, $to='', $title='', $text='') global $globals; $hash = rand_url_id(12); - $globals->xdb->execute('UPDATE register_marketing SET nb=nb+1,hash={?},last=NOW() WHERE uid={?} AND email={?}', $hash, $uid, $email); + XDB::execute('UPDATE register_marketing SET nb=nb+1,hash={?},last=NOW() WHERE uid={?} AND email={?}', $hash, $uid, $email); if ($to == '') list($to, $title, $text) = mark_text_mail($uid, $email); @@ -114,11 +114,11 @@ function relance($uid, $nbx = -1) global $globals; if ($nbx < 0) { - $res = $globals->xdb->query("SELECT COUNT(*) FROM auth_user_md5 WHERE deces=0"); + $res = XDB::query("SELECT COUNT(*) FROM auth_user_md5 WHERE deces=0"); $nbx = $res->fetchOneCell(); } - $res = $globals->xdb->query( + $res = XDB::query( "SELECT r.date, u.promo, u.nom, u.prenom, r.email, r.bestalias FROM register_pending AS r INNER JOIN auth_user_md5 AS u ON u.user_id = r.uid @@ -144,7 +144,7 @@ function relance($uid, $nbx = -1) $mymail->assign('lemail', $email); $mymail->assign('subj', $alias.'@'.$globals->mail->domain); $mymail->send(); - $globals->xdb->execute('UPDATE register_pending SET hash={?}, password={?}, relance=NOW() WHERE uid={?}', $hash, $pass_encrypted, $uid); + XDB::execute('UPDATE register_pending SET hash={?}, password={?}, relance=NOW() WHERE uid={?}', $hash, $pass_encrypted, $uid); return "$prenom $nom ($promo)"; } diff --git a/include/money.inc.php b/include/money.inc.php index c67c2a9..400019c 100644 --- a/include/money.inc.php +++ b/include/money.inc.php @@ -44,7 +44,7 @@ class Payment { global $globals; $r = $ref==-1 ? $globals->money->mpay_def_id : $ref; - $res = $globals->xdb->query("SELECT id, text, url, flags, mail, montant_min, montant_max, montant_def, asso_id + $res = XDB::query("SELECT id, text, url, flags, mail, montant_min, montant_max, montant_def, asso_id FROM {$globals->money->mpay_tprefix}paiements WHERE id={?}", $r); list($this->id, $this->text, $this->url, $flags, $this->mail, $this->montant_min, $this->montant_max, $this->montant_def, $this->asso_id) = $res->fetchOneRow(); @@ -93,7 +93,7 @@ class Payment global $globals; if ($this->asso_id) { - $res = $globals->xdb->query("SELECT eid, a.diminutif FROM groupex.evenements AS e, groupex.asso AS a WHERE e.asso_id = {?} AND a.id = {?}", $this->asso_id, $this->asso_id); + $res = XDB::query("SELECT eid, a.diminutif FROM groupex.evenements AS e, groupex.asso AS a WHERE e.asso_id = {?} AND a.id = {?}", $this->asso_id, $this->asso_id); return $res->fetchOneAssoc(); } return null; @@ -118,7 +118,7 @@ class PayMethod { global $globals; $i = $id==-1 ? $globals->money->mpay_def_meth : $id; - $res = $globals->xdb->query("SELECT id,text,include FROM {$globals->money->mpay_tprefix}methodes WHERE id={?}", $i); + $res = XDB::query("SELECT id,text,include FROM {$globals->money->mpay_tprefix}methodes WHERE id={?}", $i); list($this->id, $this->text, $this->inc) = $res->fetchOneRow(); } diff --git a/include/money/cyberpaiement.inc.php b/include/money/cyberpaiement.inc.php index 4e20288..2acb3ea 100644 --- a/include/money/cyberpaiement.inc.php +++ b/include/money/cyberpaiement.inc.php @@ -52,7 +52,7 @@ class CyberPayment if (Cookie::has(session_name())) { $returnurl .= "?".SID; } - $req = $globals->xdb->query("SELECT IF(nom_usage!='', nom_usage, nom) AS nom FROM auth_user_md5 WHERE user_id = {?}",Session::get('uid')); + $req = XDB::query("SELECT IF(nom_usage!='', nom_usage, nom) AS nom FROM auth_user_md5 WHERE user_id = {?}",Session::get('uid')); $name = $req->fetchOneCell(); // on constuit la reference de la transaction diff --git a/include/money/paypal.inc.php b/include/money/paypal.inc.php index d3e2ddf..b4cdc95 100644 --- a/include/money/paypal.inc.php +++ b/include/money/paypal.inc.php @@ -52,7 +52,7 @@ class PayPal global $globals; $this->urlform = 'https://'.$globals->money->paypal_site.'/cgi-bin/webscr'; - $req = $globals->xdb->query("SELECT IF(nom_usage!='', nom_usage, nom) AS nom FROM auth_user_md5 WHERE user_id = {?}",Session::get('uid')); + $req = XDB::query("SELECT IF(nom_usage!='', nom_usage, nom) AS nom FROM auth_user_md5 WHERE user_id = {?}",Session::get('uid')); $name = $req->fetchOneCell(); $roboturl = str_replace("https://","http://",$globals->baseurl) @@ -73,7 +73,7 @@ class PayPal 'last_name' => $name, 'email' => Session::get('bestalias').'@polytechnique.org'); - $res = $globals->xdb->query( + $res = XDB::query( "SELECT a.adr1 AS address1, a.adr2 AS address2, a.city, a.postcode AS zip, a.country, IF(t.tel, t.tel, q.profile_mobile) AS night_phone_b diff --git a/include/money/trezo.inc.php b/include/money/trezo.inc.php index 6f9b72a..9bede9c 100644 --- a/include/money/trezo.inc.php +++ b/include/money/trezo.inc.php @@ -54,9 +54,9 @@ function solde_until($date='') global $globals; $sql = "SELECT SUM(credit)-SUM(debit) FROM money_trezo"; if (empty($date)) { - $res = $globals->xdb->query($sql); + $res = XDB::query($sql); } else { - $res = $globals->xdb->query($sql." WHERE date <= {?}", $date); + $res = XDB::query($sql." WHERE date <= {?}", $date); } return $res->fetchOneCell(); } diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 9fb1ec4..56092a9 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -54,12 +54,12 @@ class NewsLetter if (isset($id)) { if ($id == 'last') { - $res = $globals->xdb->query("SELECT MAX(id) FROM newsletter WHERE bits!='new'"); + $res = XDB::query("SELECT MAX(id) FROM newsletter WHERE bits!='new'"); $id = $res->fetchOneCell(); } - $res = $globals->xdb->query("SELECT * FROM newsletter WHERE id={?}", $id); + $res = XDB::query("SELECT * FROM newsletter WHERE id={?}", $id); } else { - $res = $globals->xdb->query("SELECT * FROM newsletter WHERE bits='new'"); + $res = XDB::query("SELECT * FROM newsletter WHERE bits='new'"); } $nl = $res->fetchOneAssoc(); @@ -68,12 +68,12 @@ class NewsLetter $this->_title = $nl['titre']; $this->_head = $nl['head']; - $res = $globals->xdb->iterRow("SELECT cid,titre FROM newsletter_cat ORDER BY pos"); + $res = XDB::iterRow("SELECT cid,titre FROM newsletter_cat ORDER BY pos"); while (list($cid, $title) = $res->next()) { $this->_cats[$cid] = $title; } - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT a.title,a.body,a.append,a.aid,a.cid,a.pos FROM newsletter_art AS a INNER JOIN newsletter AS n USING(id) @@ -91,7 +91,7 @@ class NewsLetter function setSent() { global $globals; - $globals->xdb->execute("UPDATE newsletter SET bits='sent' WHERE id={?}", $this->_id); + XDB::execute("UPDATE newsletter SET bits='sent' WHERE id={?}", $this->_id); } // }}} @@ -100,7 +100,7 @@ class NewsLetter function save() { global $globals; - $globals->xdb->execute('UPDATE newsletter SET date={?},titre={?},head={?} WHERE id={?}', + XDB::execute('UPDATE newsletter SET date={?},titre={?},head={?} WHERE id={?}', $this->_date, $this->_title, $this->_head, $this->_id); } @@ -136,13 +136,13 @@ class NewsLetter { global $globals; if ($a->_aid>=0) { - $globals->xdb->execute('REPLACE INTO newsletter_art (id,aid,cid,pos,title,body,append) + XDB::execute('REPLACE INTO newsletter_art (id,aid,cid,pos,title,body,append) VALUES ({?},{?},{?},{?},{?},{?},{?})', $this->_id, $a->_aid, $a->_cid, $a->_pos, $a->_title, $a->_body, $a->_append); $this->_arts['a'.$a->_aid] = $a; } else { - $globals->xdb->execute( + XDB::execute( 'INSERT INTO newsletter_art SELECT {?},MAX(aid)+1,{?},'.($a->_pos ? intval($a->_pos) : 'MAX(pos)+1').',{?},{?},{?} FROM newsletter_art AS a @@ -158,7 +158,7 @@ class NewsLetter function delArticle($aid) { global $globals; - $globals->xdb->execute('DELETE FROM newsletter_art WHERE id={?} AND aid={?}', $this->_id, $aid); + XDB::execute('DELETE FROM newsletter_art WHERE id={?} AND aid={?}', $this->_id, $aid); foreach ($this->_arts as $key=>$art) { unset($this->_arts[$key]["a$aid"]); } @@ -441,41 +441,41 @@ class NLArticle function insert_new_nl() { global $globals; - $globals->xdb->execute("INSERT INTO newsletter SET bits='new',date=NOW(),titre='to be continued'"); + XDB::execute("INSERT INTO newsletter SET bits='new',date=NOW(),titre='to be continued'"); } function get_nl_slist() { global $globals; - $res = $globals->xdb->query("SELECT id,date,titre FROM newsletter ORDER BY date DESC"); + $res = XDB::query("SELECT id,date,titre FROM newsletter ORDER BY date DESC"); return $res->fetchAllAssoc(); } function get_nl_list() { global $globals; - $res = $globals->xdb->query("SELECT id,date,titre FROM newsletter WHERE bits!='new' ORDER BY date DESC"); + $res = XDB::query("SELECT id,date,titre FROM newsletter WHERE bits!='new' ORDER BY date DESC"); return $res->fetchAllAssoc(); } function get_nl_state() { global $globals; - $res = $globals->xdb->query('SELECT 1 FROM newsletter_ins WHERE user_id={?}', Session::getInt('uid')); + $res = XDB::query('SELECT 1 FROM newsletter_ins WHERE user_id={?}', Session::getInt('uid')); return $res->fetchOneCell(); } function unsubscribe_nl() { global $globals; - $globals->xdb->execute('DELETE FROM newsletter_ins WHERE user_id={?}', Session::getInt('uid')); + XDB::execute('DELETE FROM newsletter_ins WHERE user_id={?}', Session::getInt('uid')); } function subscribe_nl($uid=-1) { global $globals; $user = ($uid == -1) ? Session::getInt('uid') : $uid; - $globals->xdb->execute('REPLACE INTO newsletter_ins (user_id,last) + XDB::execute('REPLACE INTO newsletter_ins (user_id,last) VALUES ({?}, 0)', $user); } diff --git a/include/nomusage.inc.php b/include/nomusage.inc.php index 12fb84e..3d81cf7 100644 --- a/include/nomusage.inc.php +++ b/include/nomusage.inc.php @@ -22,16 +22,16 @@ function set_new_usage($uid, $usage, $alias=false) { global $globals; - $globals->xdb->execute("UPDATE auth_user_md5 set nom_usage={?} WHERE user_id={?}",$usage ,$uid); - $globals->xdb->execute("DELETE FROM aliases WHERE FIND_IN_SET('usage',flags) AND id={?}", $uid); + XDB::execute("UPDATE auth_user_md5 set nom_usage={?} WHERE user_id={?}",$usage ,$uid); + XDB::execute("DELETE FROM aliases WHERE FIND_IN_SET('usage',flags) AND id={?}", $uid); if ($alias && $usage) { - $globals->xdb->execute("UPDATE aliases SET flags=flags & 255-1 WHERE id={?}", $uid); - $globals->xdb->execute("INSERT INTO aliases VALUES({?}, 'alias', 'usage,bestalias', {?}, null)", + XDB::execute("UPDATE aliases SET flags=flags & 255-1 WHERE id={?}", $uid); + XDB::execute("INSERT INTO aliases VALUES({?}, 'alias', 'usage,bestalias', {?}, null)", $alias, $uid); } - $r = $globals->xdb->query("SELECT alias FROM aliases WHERE FIND_IN_SET('bestalias', flags) AND id = {?}", $uid); + $r = XDB::query("SELECT alias FROM aliases WHERE FIND_IN_SET('bestalias', flags) AND id = {?}", $uid); if ($r->fetchOneCell() == "") { - $globals->xdb->execute("UPDATE aliases SET flags = 1 | flags WHERE id = {?} LIMIT 1", $uid); + XDB::execute("UPDATE aliases SET flags = 1 | flags WHERE id = {?} LIMIT 1", $uid); } require_once 'user.func.inc.php'; user_reindex($uid); diff --git a/include/notifs.inc.php b/include/notifs.inc.php index 45e8531..fcb8320 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -29,7 +29,7 @@ define('WATCH_BIRTH', 4); function inscription_notifs_base($uid) { global $globals; - $globals->xdb->execute('REPLACE INTO watch_sub (uid,cid) SELECT {?},id FROM watch_cat', $uid); + XDB::execute('REPLACE INTO watch_sub (uid,cid) SELECT {?},id FROM watch_cat', $uid); } // }}} @@ -41,16 +41,16 @@ function register_watch_op($uid, $cid, $date='', $info='') if (empty($date)) { $date = date('Y-m-d'); }; - $globals->xdb->execute('REPLACE INTO watch_ops (uid,cid,known,date,info) VALUES({?},{?},NOW(),{?},{?})', + XDB::execute('REPLACE INTO watch_ops (uid,cid,known,date,info) VALUES({?},{?},NOW(),{?},{?})', $uid, $cid, $date, $info); if($cid == WATCH_FICHE) { - $globals->xdb->execute('UPDATE auth_user_md5 SET DATE=NOW() WHERE user_id={?}', $uid); + XDB::execute('UPDATE auth_user_md5 SET DATE=NOW() WHERE user_id={?}', $uid); } elseif($cid == WATCH_INSCR) { - $globals->xdb->execute('REPLACE INTO contacts (uid,contact) + XDB::execute('REPLACE INTO contacts (uid,contact) SELECT uid,ni_id FROM watch_nonins WHERE ni_id={?}', $uid); - $globals->xdb->execute('DELETE FROM watch_nonins WHERE ni_id={?}', $uid); + XDB::execute('DELETE FROM watch_nonins WHERE ni_id={?}', $uid); } } @@ -126,9 +126,9 @@ function select_notifs($mail, $uid=null, $last=null, $iterator=true) $sql .= _select_notifs_base('watch_nonins', $mail, $where); if ($iterator) { - return $globals->xdb->iterator($sql . ' ORDER BY cid, promo, date DESC, nom', $last, $uid, $last, $uid, $last, $uid); + return XDB::iterator($sql . ' ORDER BY cid, promo, date DESC, nom', $last, $uid, $last, $uid, $last, $uid); } else { - return $globals->xdb->query($sql, $last, $uid, $last, $uid, $last, $uid); + return XDB::query($sql, $last, $uid, $last, $uid, $last, $uid); } } @@ -163,7 +163,7 @@ class AllNotifs { function AllNotifs() { global $globals; - $res = $globals->xdb->iterator("SELECT * FROM watch_cat"); + $res = XDB::iterator("SELECT * FROM watch_cat"); while($tmp = $res->next()) { $this->_cats[$tmp['id']] = $tmp; } @@ -196,7 +196,7 @@ class Notifs { global $globals; $this->_uid = $uid; - $res = $globals->xdb->iterator("SELECT * FROM watch_cat"); + $res = XDB::iterator("SELECT * FROM watch_cat"); while($tmp = $res->next()) { $this->_cats[$tmp['id']] = $tmp; } @@ -210,7 +210,7 @@ class Notifs { } if($up) { - $globals->xdb->execute('UPDATE auth_user_quick SET watch_last=NOW() WHERE user_id={?}', $uid); + XDB::execute('UPDATE auth_user_quick SET watch_last=NOW() WHERE user_id={?}', $uid); } } } @@ -233,12 +233,12 @@ class Watch { $this->_promos = new PromoNotifs($uid); $this->_nonins = new NoninsNotifs($uid); $this->_subs = new WatchSub($uid); - $res = $globals->xdb->query("SELECT FIND_IN_SET('contacts',watch_flags),FIND_IN_SET('mail',watch_flags) + $res = XDB::query("SELECT FIND_IN_SET('contacts',watch_flags),FIND_IN_SET('mail',watch_flags) FROM auth_user_quick WHERE user_id={?}", $uid); list($this->watch_contacts,$this->watch_mail) = $res->fetchOneRow(); - $res = $globals->xdb->iterator("SELECT * FROM watch_cat"); + $res = XDB::iterator("SELECT * FROM watch_cat"); while($tmp = $res->next()) { $this->_cats[$tmp['id']] = $tmp; } @@ -249,7 +249,7 @@ class Watch { $flags = ""; if($this->watch_contacts) $flags = "contacts"; if($this->watch_mail) $flags .= ($flags ? ',' : '')."mail"; - $globals->xdb->execute('UPDATE auth_user_quick SET watch_flags={?} WHERE user_id={?}', $flags, $this->_uid); + XDB::execute('UPDATE auth_user_quick SET watch_flags={?} WHERE user_id={?}', $flags, $this->_uid); } @@ -280,7 +280,7 @@ class WatchSub { function WatchSub($uid) { $this->_uid = $uid; global $globals; - $res = $globals->xdb->iterRow('SELECT cid FROM watch_sub WHERE uid={?}', $uid); + $res = XDB::iterRow('SELECT cid FROM watch_sub WHERE uid={?}', $uid); while(list($c) = $res->next()) { $this->_data[$c] = $c; } @@ -289,9 +289,9 @@ class WatchSub { function update($ind) { global $globals; $this->_data = Array(); - $globals->xdb->execute('DELETE FROM watch_sub WHERE uid={?}', $this->_uid); + XDB::execute('DELETE FROM watch_sub WHERE uid={?}', $this->_uid); foreach(Env::getMixed($ind) as $key=>$val) { - $globals->xdb->query('INSERT INTO watch_sub SELECT {?},id FROM watch_cat WHERE id={?}', $this->_uid, $key); + XDB::query('INSERT INTO watch_sub SELECT {?},id FROM watch_cat WHERE id={?}', $this->_uid, $key); if(mysql_affected_rows()) { $this->_data[$key] = $key; } @@ -309,7 +309,7 @@ class PromoNotifs { function PromoNotifs($uid) { $this->_uid = $uid; global $globals; - $res = $globals->xdb->iterRow('SELECT promo FROM watch_promo WHERE uid={?} ORDER BY promo', $uid); + $res = XDB::iterRow('SELECT promo FROM watch_promo WHERE uid={?} ORDER BY promo', $uid); while (list($p) = $res->next()) { $this->_data[intval($p)] = intval($p); } @@ -318,7 +318,7 @@ class PromoNotifs { function add($p) { global $globals; $promo = intval($p); - $globals->xdb->execute('REPLACE INTO watch_promo (uid,promo) VALUES({?},{?})', $this->_uid, $promo); + XDB::execute('REPLACE INTO watch_promo (uid,promo) VALUES({?},{?})', $this->_uid, $promo); $this->_data[$promo] = $promo; asort($this->_data); } @@ -326,7 +326,7 @@ class PromoNotifs { function del($p) { global $globals; $promo = intval($p); - $globals->xdb->execute('DELETE FROM watch_promo WHERE uid={?} AND promo={?}', $this->_uid, $promo); + XDB::execute('DELETE FROM watch_promo WHERE uid={?} AND promo={?}', $this->_uid, $promo); unset($this->_data[$promo]); } @@ -339,7 +339,7 @@ class PromoNotifs { $values[] = "('{$this->_uid}',$i)"; $this->_data[$i] = $i; } - $globals->xdb->execute('REPLACE INTO watch_promo (uid,promo) VALUES '.join(',',$values)); + XDB::execute('REPLACE INTO watch_promo (uid,promo) VALUES '.join(',',$values)); asort($this->_data); } @@ -352,7 +352,7 @@ class PromoNotifs { $where[] = "promo=$i"; unset($this->_data[$i]); } - $globals->xdb->execute('DELETE FROM watch_promo WHERE uid={?} AND ('.join(' OR ',$where).')', $this->_uid); + XDB::execute('DELETE FROM watch_promo WHERE uid={?} AND ('.join(' OR ',$where).')', $this->_uid); } function toRanges() { @@ -385,7 +385,7 @@ class NoninsNotifs { function NoninsNotifs($uid) { global $globals; $this->_uid = $uid; - $res = $globals->xdb->iterator("SELECT u.prenom,IF(u.nom_usage='',u.nom,u.nom_usage) AS nom, u.promo, u.user_id + $res = XDB::iterator("SELECT u.prenom,IF(u.nom_usage='',u.nom,u.nom_usage) AS nom, u.promo, u.user_id FROM watch_nonins AS w INNER JOIN auth_user_md5 AS u ON (u.user_id = w.ni_id) WHERE w.uid = {?} @@ -398,13 +398,13 @@ class NoninsNotifs { function del($p) { global $globals; unset($this->_data["$p"]); - $globals->xdb->execute('DELETE FROM watch_nonins WHERE uid={?} AND ni_id={?}', $this->_uid, $p); + XDB::execute('DELETE FROM watch_nonins WHERE uid={?} AND ni_id={?}', $this->_uid, $p); } function add($p) { global $globals; - $globals->xdb->execute('INSERT INTO watch_nonins (uid,ni_id) VALUES({?},{?})', $this->_uid, $p); - $res = $globals->xdb->query('SELECT prenom,IF(nom_usage="",nom,nom_usage) AS nom,promo,user_id + XDB::execute('INSERT INTO watch_nonins (uid,ni_id) VALUES({?},{?})', $this->_uid, $p); + $res = XDB::query('SELECT prenom,IF(nom_usage="",nom,nom_usage) AS nom,promo,user_id FROM auth_user_md5 WHERE user_id={?}', $p); $this->_data["$p"] = $res->fetchOneAssoc(); diff --git a/include/platal/database.inc.php b/include/platal/database.inc.php index f8b6f79..2a4c505 100644 --- a/include/platal/database.inc.php +++ b/include/platal/database.inc.php @@ -19,21 +19,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * **************************************************************************/ -// {{{ class XOrgDB - -class XOrgDB +class XDB { - // {{{ constructor - - function XOrgDB() - { - } - - // }}} // {{{ function _prepare function _prepare($args) { - $query = array_map(Array($this, '_db_escape'), $args); + $query = array_map(Array('XDB', '_db_escape'), $args); $query[0] = str_replace('{?}', '%s', str_replace('%', '%%', $args[0])); return call_user_func_array('sprintf', $query); } @@ -43,7 +34,7 @@ class XOrgDB function &query() { - return new XOrgDBResult($this->_prepare(func_get_args())); + return new XOrgDBResult(XDB::_prepare(func_get_args())); } // }}} @@ -51,7 +42,7 @@ class XOrgDB function execute() { global $globals; - return $globals->db->query($this->_prepare(func_get_args())); + return $globals->db->query(XDB::_prepare(func_get_args())); } // }}} @@ -59,7 +50,7 @@ class XOrgDB function &iterator() { - return new XOrgDBIterator($this->_prepare(func_get_args())); + return new XOrgDBIterator(XDB::_prepare(func_get_args())); } // }}} @@ -67,7 +58,7 @@ class XOrgDB function &iterRow() { - return new XOrgDBIterator($this->_prepare(func_get_args()), MYSQL_NUM); + return new XOrgDBIterator(XDB::_prepare(func_get_args()), MYSQL_NUM); } // }}} @@ -110,9 +101,6 @@ class XOrgDB // }}} } -// }}} -// {{{ class XOrgDBResult - class XOrgDBResult { // {{{ properties @@ -241,9 +229,6 @@ class XOrgDBResult // }}} } -// }}} -// {{{ class XOrgDBIterator - class XOrgDBIterator extends XOrgIterator { // {{{ properties @@ -305,7 +290,5 @@ class XOrgDBIterator extends XOrgIterator // }}} } -// }}} - // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: ?> diff --git a/include/profil/assign_deco.inc.php b/include/profil/assign_deco.inc.php index 1d1849c..97b8cae 100644 --- a/include/profil/assign_deco.inc.php +++ b/include/profil/assign_deco.inc.php @@ -20,13 +20,13 @@ ***************************************************************************/ -$res = $globals->xdb->iterator("SELECT * FROM profile_medals_grades ORDER BY mid, pos"); +$res = XDB::iterator("SELECT * FROM profile_medals_grades ORDER BY mid, pos"); $grades = Array(); while ($tmp = $res->next()) { $grades[$tmp['mid']][] = $tmp; } -$res = $globals->xdb->iterator("SELECT * FROM profile_medals ORDER BY type, text"); +$res = XDB::iterator("SELECT * FROM profile_medals ORDER BY type, text"); $mlist = Array(); while ($tmp = $res->next()) { $mlist[$tmp['type']][] = $tmp; diff --git a/include/profil/assign_poly.inc.php b/include/profil/assign_poly.inc.php index 15d2530..ec98308 100644 --- a/include/profil/assign_poly.inc.php +++ b/include/profil/assign_poly.inc.php @@ -21,13 +21,13 @@ $uid = Session::getInt('uid'); -$res = $globals->xdb->query( +$res = XDB::query( "SELECT text,id FROM binets_ins, binets_def WHERE binets_def.id=binets_ins.binet_id AND user_id={?}", $uid); $page->assign('binets', $res->fetchAllAssoc()); -$res = $globals->xdb->query( +$res = XDB::query( "SELECT text,id FROM groupesx_ins, groupesx_def WHERE groupesx_def.id=groupesx_ins.gid AND guid={?}", $uid); diff --git a/include/profil/get_adresses.inc.php b/include/profil/get_adresses.inc.php index df6680c..2593520 100644 --- a/include/profil/get_adresses.inc.php +++ b/include/profil/get_adresses.inc.php @@ -39,8 +39,8 @@ function is_adr_empty($adrid){ function delete_address($adrid, $in_request_array = false){ global $globals; - $globals->xdb->execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}",Session::getInt('uid', -1), $adrid); - $globals->xdb->execute("DELETE FROM tels WHERE uid = {?} AND adrid = {?}",Session::getInt('uid', -1), $adrid); + XDB::execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}",Session::getInt('uid', -1), $adrid); + XDB::execute("DELETE FROM tels WHERE uid = {?} AND adrid = {?}",Session::getInt('uid', -1), $adrid); if($in_request_array == true){ unset($_REQUEST['adrid'][$adrid]); } @@ -61,11 +61,11 @@ for($i = 1; $i <= $nb_adr_max; $i++){ $sql_order = ''; //recuperation des adrid -$res = $globals->xdb->query("SELECT adrid FROM adresses WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut) ".$sql_order, Session::getInt('uid', -1)); +$res = XDB::query("SELECT adrid FROM adresses WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut) ".$sql_order, Session::getInt('uid', -1)); $adrids = $res->fetchColumn(); //recuperation des donnees de la bd -$res = $globals->xdb->iterRow( +$res = XDB::iterRow( "SELECT FIND_IN_SET('res-secondaire', statut), FIND_IN_SET('courrier', statut), FIND_IN_SET('active', statut), FIND_IN_SET('temporaire', statut), @@ -95,7 +95,7 @@ for ($i = 0; $i < $nb_adr; $i++) { $adresses[$adrid]['txt'] = get_address_text($adresses[$adrid]); } -$restels = $globals->xdb->iterator( +$restels = XDB::iterator( "SELECT t.adrid, telid, tel_type, t.tel_pub, t.tel FROM tels AS t INNER JOIN adresses AS a ON(t.uid = a.uid AND t.adrid = a.adrid) diff --git a/include/profil/get_deco.inc.php b/include/profil/get_deco.inc.php index e516a3c..d4542e9 100644 --- a/include/profil/get_deco.inc.php +++ b/include/profil/get_deco.inc.php @@ -21,20 +21,20 @@ if (Env::has('medal_op')) { if (Env::get('medal_op')=='retirer' && Env::getInt('medal_id')) { - $globals->xdb->execute("DELETE FROM profile_medals_sub WHERE uid = {?} AND mid = {?}", Session::getInt('uid', -1), Env::getInt('medal_id', -1)); + XDB::execute("DELETE FROM profile_medals_sub WHERE uid = {?} AND mid = {?}", Session::getInt('uid', -1), Env::getInt('medal_id', -1)); } if (Env::get('medal_op')=='ajouter' && Env::getInt('medal_id')) { - $globals->xdb->execute("INSERT INTO profile_medals_sub (uid,mid) VALUES ({?}, {?})", Session::getInt('uid', -1), Env::getInt('medal_id')); + XDB::execute("INSERT INTO profile_medals_sub (uid,mid) VALUES ({?}, {?})", Session::getInt('uid', -1), Env::getInt('medal_id')); } } if (Post::has('grade')) { foreach (Post::getMixed('grade') as $mid=>$gid) { - $globals->xdb->execute('UPDATE profile_medals_sub SET gid={?} WHERE uid={?} AND mid={?}', $gid, Session::getInt('uid'), $mid); + XDB::execute('UPDATE profile_medals_sub SET gid={?} WHERE uid={?} AND mid={?}', $gid, Session::getInt('uid'), $mid); } } -$res = $globals->xdb->query( +$res = XDB::query( "SELECT m.id, m.text AS medal, m.type, m.img, s.gid FROM profile_medals_sub AS s INNER JOIN profile_medals AS m ON ( s.mid = m.id ) @@ -42,7 +42,7 @@ $res = $globals->xdb->query( $medals = $res->fetchAllAssoc(); -$res = $globals->xdb->query("SELECT profile_medals_pub FROM auth_user_quick WHERE user_id = {?}", Session::getInt('uid', -1)); +$res = XDB::query("SELECT profile_medals_pub FROM auth_user_quick WHERE user_id = {?}", Session::getInt('uid', -1)); $medals_pub = $res->fetchOneCell(); if(Env::has('modifier') || Env::has('suivant')) { diff --git a/include/profil/get_emploi.inc.php b/include/profil/get_emploi.inc.php index 3c4eaa6..00aa739 100644 --- a/include/profil/get_emploi.inc.php +++ b/include/profil/get_emploi.inc.php @@ -23,7 +23,7 @@ require_once('geoloc.inc.php'); require_once('secteur.emploi.inc.php'); require_once('fonction.emploi.inc.php'); -$res = $globals->xdb->iterRow("SELECT entrid, entreprise, secteur, ss_secteur, poste, fonction, +$res = XDB::iterRow("SELECT entrid, entreprise, secteur, ss_secteur, poste, fonction, adr1, adr2, adr3, postcode, city, country, region, tel, fax, mobile, pub, adr_pub, tel_pub, email, email_pub, web FROM entreprises @@ -64,14 +64,14 @@ for($i = $nb_res; $i < 2 ; $i++){ //recuperation des donnees sur les secteurs : -$res = $globals->xdb->iterRow("SELECT id, label FROM emploi_secteur"); +$res = XDB::iterRow("SELECT id, label FROM emploi_secteur"); while(list($tmp_secteur_id, $tmp_secteur_label) = $res->next()){ $secteurs[$tmp_secteur_id] = $tmp_secteur_label; } //recuperation des donnees sur les fonctions : -$res = $globals->xdb->iterRow("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) FROM fonctions_def ORDER BY id"); +$res = XDB::iterRow("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) FROM fonctions_def ORDER BY id"); while(list($tmp_fonction_id, $tmp_fonction_label, $tmp_fonction_titre) = $res->next()){ $fonctions[$tmp_fonction_id] = $tmp_fonction_label; @@ -79,7 +79,7 @@ while(list($tmp_fonction_id, $tmp_fonction_label, $tmp_fonction_titre) = $res->n } //recuperation du CV -$res = $globals->xdb->query("SELECT cv FROM auth_user_md5 WHERE user_id = {?}", Session::getInt('uid', -1)); +$res = XDB::query("SELECT cv FROM auth_user_md5 WHERE user_id = {?}", Session::getInt('uid', -1)); $cv = $res->fetchOneCell(); ?> diff --git a/include/profil/get_general.inc.php b/include/profil/get_general.inc.php index a8702f3..528a05d 100644 --- a/include/profil/get_general.inc.php +++ b/include/profil/get_general.inc.php @@ -30,13 +30,13 @@ $sql = "SELECT u.nom, u.prenom, u.nom_ini, u.prenom_ini, u.promo, u.promo_sorti LEFT JOIN applis_ins AS a2 ON(a2.uid = u.user_id and a2.ordre = 1) WHERE u.user_id = {?}"; -$result = $globals->xdb->query($sql, Session::getInt('uid', -1)); +$result = XDB::query($sql, Session::getInt('uid', -1)); list($nom, $prenom, $nom_ini, $prenom_ini, $promo, $promo_sortie, $nom_usage, $nationalite, $mobile, $mobile_pub, $web, $web_pub, $freetext, $freetext_pub, $nickname, $synchro_ax, $matricule_ax, $appli_id1,$appli_type1, $appli_id2,$appli_type2) = $result->fetchOneRow(); -$result = $globals->xdb->query("SELECT pub FROM photo WHERE uid = {?}", Session::getInt('uid', -1)); +$result = XDB::query("SELECT pub FROM photo WHERE uid = {?}", Session::getInt('uid', -1)); $photo_pub = $result->fetchOneCell(); $nom_anc = $nom; @@ -74,7 +74,7 @@ require_once("xorg.misc.inc.php"); $prenom_anc_comp = replace_accent($prenom_anc); // Y a-t-il une photo en attente de confirmation ? -$sql = $globals->xdb->query("SELECT COUNT(*) FROM requests WHERE type='photo' AND user_id = {?}", Session::getInt('uid', -1)); +$sql = XDB::query("SELECT COUNT(*) FROM requests WHERE type='photo' AND user_id = {?}", Session::getInt('uid', -1)); $nouvellephoto=$sql->fetchOneCell(); // vim:set et sws=4 sw=4 sts=4: diff --git a/include/profil/get_mentor.inc.php b/include/profil/get_mentor.inc.php index c1b7c7d..08333e3 100644 --- a/include/profil/get_mentor.inc.php +++ b/include/profil/get_mentor.inc.php @@ -26,7 +26,7 @@ $max_mentor_pays = 10; $max_mentor_secteurs = 10; //recuperation de l'expertise -$res = $globals->xdb->query("SELECT expertise FROM mentor WHERE uid = {?}", Session::getInt('uid',-1)); +$res = XDB::query("SELECT expertise FROM mentor WHERE uid = {?}", Session::getInt('uid',-1)); $mentor_expertise = $res->fetchOneCell(); $mentor_expertise_bd = $mentor_expertise; @@ -35,12 +35,12 @@ $mentor_expertise_bd = $mentor_expertise; if(Post::get('mentor_pays_op', '') == 'retirer') { if(Post::has('mentor_pays_id')) { $id_supprimee = Post::get('mentor_pays_id', '00'); - $globals->xdb->execute("DELETE FROM mentor_pays WHERE uid = {?} AND pid = {?} LIMIT 1", Session::getInt('uid', -1), $id_supprimee); + XDB::execute("DELETE FROM mentor_pays WHERE uid = {?} AND pid = {?} LIMIT 1", Session::getInt('uid', -1), $id_supprimee); } } //recuperation des pays -$res = $globals->xdb->iterRow("SELECT m.pid, p.pays +$res = XDB::iterRow("SELECT m.pid, p.pays FROM mentor_pays AS m LEFT JOIN geoloc_pays AS p ON(m.pid = p.a2) WHERE m.uid = {?} LIMIT {?}", Session::getInt('uid', -1), $max_mentor_pays); $nb_mentor_pays = $res->total(); @@ -51,7 +51,7 @@ for($i = 1; $i <= $nb_mentor_pays ; $i++) list($mentor_pid[$i], $mentor_pays[$i] if((Post::get('mentor_pays_op', '') == 'ajouter') && ($nb_mentor_pays < $max_mentor_pays)) { if(Post::get('mentor_pays_id', '00') != '00') { $id_ajoutee = Post::get('mentor_pays_id', '00'); - $globals->xdb->execute("INSERT INTO mentor_pays(uid, pid) VALUES({?}, {?})", Session::getInt('uid', -1), $id_ajoutee); + XDB::execute("INSERT INTO mentor_pays(uid, pid) VALUES({?}, {?})", Session::getInt('uid', -1), $id_ajoutee); $nb_mentor_pays++; $mentor_pid[$nb_mentor_pays] = $id_ajoutee; $mentor_pays[$nb_mentor_pays] = Post::get('mentor_pays_name', ''); @@ -64,12 +64,12 @@ if((Post::get('mentor_pays_op', '') == 'ajouter') && ($nb_mentor_pays < $max_men if(Post::get('mentor_secteur_op', '') == 'retirer') { if(Post::has('mentor_secteur_id')) { $id_supprimee = Post::get('mentor_secteur_id', ''); - $globals->xdb->execute("DELETE FROM mentor_secteurs WHERE uid = {?} AND secteur = {?} LIMIT 1", Session::getInt('uid', -1), $id_supprimee); + XDB::execute("DELETE FROM mentor_secteurs WHERE uid = {?} AND secteur = {?} LIMIT 1", Session::getInt('uid', -1), $id_supprimee); } } //recuperation des secteurs -$res = $globals->xdb->iterRow("SELECT m.secteur, s.label, m.ss_secteur, ss.label +$res = XDB::iterRow("SELECT m.secteur, s.label, m.ss_secteur, ss.label FROM mentor_secteurs AS m LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id) LEFT JOIN emploi_ss_secteur AS ss ON(s.id = ss.secteur AND m.ss_secteur = ss.id) @@ -88,7 +88,7 @@ if((Post::get('mentor_secteur_op', '')== 'ajouter') && ($nb_mentor_secteurs < $m $sid_ajoutee = Post::get('mentor_secteur_id', ''); if(Post::has('mentor_ss_secteur_id')) $ssid_ajoutee = Post::get('mentor_ss_secteur_id', ''); - $globals->xdb->execute("INSERT INTO mentor_secteurs (uid, secteur, ss_secteur) + XDB::execute("INSERT INTO mentor_secteurs (uid, secteur, ss_secteur) VALUES({?}, {?}, {?})", Session::getInt('uid', -1), $sid_ajoutee, ($ssid_ajoutee == '')?null:$ssid_ajoutee); $nb_mentor_secteurs++; $mentor_sid[$nb_mentor_secteurs] = $sid_ajoutee; diff --git a/include/profil/get_poly.inc.php b/include/profil/get_poly.inc.php index d58b2cd..d658eaa 100644 --- a/include/profil/get_poly.inc.php +++ b/include/profil/get_poly.inc.php @@ -26,7 +26,7 @@ $sql = "SELECT section". " FROM auth_user_md5 AS u". " WHERE user_id = {?}"; -$result = $globals->xdb->query($sql, Session::getInt('uid', -1)); +$result = XDB::query($sql, Session::getInt('uid', -1)); $section = $result->fetchOneCell(); replace_ifset($section,'section'); @@ -35,22 +35,22 @@ replace_ifset($section,'section'); if (Env::has('binet_op')) { // retrait binet if( (Env::get('binet_op', '')=='retirer')&&(Env::getInt('binet_id', 0) != 0)) { - $globals->xdb->execute("DELETE FROM binets_ins WHERE user_id = {?} AND binet_id = {?}", Session::getInt('uid', -1), Env::getInt('binet_id', -1)); + XDB::execute("DELETE FROM binets_ins WHERE user_id = {?} AND binet_id = {?}", Session::getInt('uid', -1), Env::getInt('binet_id', -1)); } // ajout binet if (Env::get('binet_op')=="ajouter" && (Env::getInt('binet_id', 0) != 0)) { - $globals->xdb->execute("INSERT INTO binets_ins (user_id,binet_id) VALUES({?}, {?})", Session::getInt('uid', -1), Env::getInt('binet_id', -1)); + XDB::execute("INSERT INTO binets_ins (user_id,binet_id) VALUES({?}, {?})", Session::getInt('uid', -1), Env::getInt('binet_id', -1)); } } /************* gestion des groupes X ************/ if (Env::has('groupex_op')) { // retrait groupe X if (Env::get('groupex_op')=="retirer" && (Env::getInt('groupex_id', 0) != 0)) { - $globals->xdb->execute("DELETE FROM groupesx_ins WHERE guid = {?} AND gid = {?}", Session::getInt('uid', -1), Env::getInt('groupex_id', -1)); + XDB::execute("DELETE FROM groupesx_ins WHERE guid = {?} AND gid = {?}", Session::getInt('uid', -1), Env::getInt('groupex_id', -1)); } // ajout groupe X if (Env::get('groupex_op')=="ajouter" && (Env::getInt('groupex_id', 0) != 0)) { - $globals->xdb->execute("INSERT INTO groupesx_ins (guid, gid) VALUES ({?}, {?})", Session::getInt('uid', -1), Env::getInt('groupex_id', -1)); + XDB::execute("INSERT INTO groupesx_ins (guid, gid) VALUES ({?}, {?})", Session::getInt('uid', -1), Env::getInt('groupex_id', -1)); } } diff --git a/include/profil/get_skill.inc.php b/include/profil/get_skill.inc.php index ee19a70..a5381b7 100644 --- a/include/profil/get_skill.inc.php +++ b/include/profil/get_skill.inc.php @@ -22,19 +22,19 @@ if(Env::has('langue_op')){ if(Env::get('langue_op', '')=='retirer'){ - $globals->xdb->execute("DELETE FROM langues_ins WHERE uid = {?} AND lid = {?}", Session::getInt('uid', -1), Env::get('langue_id', '')); + XDB::execute("DELETE FROM langues_ins WHERE uid = {?} AND lid = {?}", Session::getInt('uid', -1), Env::get('langue_id', '')); } elseif(Env::get('langue_op', '') == 'ajouter'){ if(Env::get('langue_id', '') != '') - $globals->xdb->execute("INSERT INTO langues_ins (uid,lid,level) VALUES ({?}, {?}, {?})", Session::getInt('uid', -1), Env::get('langue_id', ''), Env::get('langue_level', '')); + XDB::execute("INSERT INTO langues_ins (uid,lid,level) VALUES ({?}, {?}, {?})", Session::getInt('uid', -1), Env::get('langue_id', ''), Env::get('langue_level', '')); } } if(Env::has('comppros_op')){ if(Env::get('comppros_op', '')=='retirer'){ - $globals->xdb->execute("DELETE FROM competences_ins WHERE uid = {?} AND cid = {?}", Session::getInt('uid', -1), Env::get('comppros_id', '')); + XDB::execute("DELETE FROM competences_ins WHERE uid = {?} AND cid = {?}", Session::getInt('uid', -1), Env::get('comppros_id', '')); } elseif(Env::get('comppros_op', '') == 'ajouter') { if(Env::get('comppros_id', '') != '') - $globals->xdb->execute("INSERT INTO competences_ins (uid,cid,level) VALUES({?}, {?}, {?})", Session::getInt('uid', -1), Env::get('comppros_id', ''), Env::get('comppros_level', '')); + XDB::execute("INSERT INTO competences_ins (uid,cid,level) VALUES({?}, {?}, {?})", Session::getInt('uid', -1), Env::get('comppros_id', ''), Env::get('comppros_level', '')); } } @@ -43,7 +43,7 @@ $nb_lg_max = 10; // nombre maximum autorisé de compétences professionnelles $nb_cpro_max = 20; -$res = $globals->xdb->iterRow("SELECT ld.id, ld.langue_fr, li.level FROM langues_ins AS li, langues_def AS ld " +$res = XDB::iterRow("SELECT ld.id, ld.langue_fr, li.level FROM langues_ins AS li, langues_def AS ld " ."WHERE (li.lid=ld.id AND li.uid= {?}) LIMIT $nb_lg_max", Session::getInt('uid', -1)); $nb_lg = $res->total(); @@ -52,7 +52,7 @@ for ($i = 1; $i <= $nb_lg; $i++) { list($langue_id[$i], $langue_name[$i], $langue_level[$i]) = $res->next(); } -$res = $globals->xdb->iterRow("SELECT cd.id, cd.text_fr, ci.level FROM competences_ins AS ci, competences_def AS cd " +$res = XDB::iterRow("SELECT cd.id, cd.text_fr, ci.level FROM competences_ins AS ci, competences_def AS cd " ."WHERE (ci.cid=cd.id AND ci.uid={?}) LIMIT $nb_cpro_max", Session::getInt('uid', -1)); $nb_cpro = $res->total(); @@ -71,7 +71,7 @@ $langues_levels = Array( 6 => "6" ); -$res = $globals->xdb->iterRow("SELECT id, langue_fr FROM langues_def"); +$res = XDB::iterRow("SELECT id, langue_fr FROM langues_def"); while(list($tmp_lid, $tmp_lg_fr) = $res->next()){ $langues_def[$tmp_lid] = $tmp_lg_fr; @@ -83,7 +83,7 @@ $comppros_levels = Array( 'expert' => 'expert' ); -$res = $globals->xdb->iterRow("SELECT id, text_fr, FIND_IN_SET('titre',flags) FROM competences_def"); +$res = XDB::iterRow("SELECT id, text_fr, FIND_IN_SET('titre',flags) FROM competences_def"); while(list($tmp_id, $tmp_text_fr, $tmp_title) = $res->next()){ $comppros_def[$tmp_id] = $tmp_text_fr; diff --git a/include/profil/update_adresses.inc.php b/include/profil/update_adresses.inc.php index d148ad9..ad1e9d8 100644 --- a/include/profil/update_adresses.inc.php +++ b/include/profil/update_adresses.inc.php @@ -24,7 +24,7 @@ reset($adresses); function insert_new_tel($adrid, $tel) { global $globals; if ($tel['tel'] == "") return; - $globals->xdb->execute( + XDB::execute( "INSERT INTO tels SET tel_type = {?}, tel_pub = {?}, @@ -54,7 +54,7 @@ foreach($adresses as $adrid => $adr){ if ($adr["nouvelle"] == 'ajout') { //nouvelle adresse - $globals->xdb->execute("INSERT INTO adresses SET + XDB::execute("INSERT INTO adresses SET adr1 = {?}, adr2 = {?}, adr3 = {?}, @@ -87,7 +87,7 @@ foreach($adresses as $adrid => $adr){ else{ //c'est une mise à jour - $globals->xdb->execute( + XDB::execute( "UPDATE adresses SET adr1 = {?}, adr2 = {?}, @@ -120,7 +120,7 @@ foreach($adresses as $adrid => $adr){ insert_new_tel($adrid, $tel); else if ($tel['tel'] != "") { - $globals->xdb->execute( + XDB::execute( "UPDATE tels SET tel_type = {?}, tel_pub = {?}, @@ -136,7 +136,7 @@ foreach($adresses as $adrid => $adr){ $adrid, $tel['telid']); } else { - $globals->xdb->execute( + XDB::execute( "DELETE FROM tels WHERE uid = {?} AND adrid = {?} AND diff --git a/include/profil/update_deco.inc.php b/include/profil/update_deco.inc.php index 4437936..8208d5f 100644 --- a/include/profil/update_deco.inc.php +++ b/include/profil/update_deco.inc.php @@ -19,7 +19,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -$globals->xdb->execute("UPDATE auth_user_quick SET profile_medals_pub = {?} WHERE user_id = {?}", $medals_pub, Session::getInt('uid', -1)); +XDB::execute("UPDATE auth_user_quick SET profile_medals_pub = {?} WHERE user_id = {?}", $medals_pub, Session::getInt('uid', -1)); // vim:set et sws=4 sw=4 sts=4: ?> diff --git a/include/profil/update_emploi.inc.php b/include/profil/update_emploi.inc.php index 7971459..3b5120d 100644 --- a/include/profil/update_emploi.inc.php +++ b/include/profil/update_emploi.inc.php @@ -21,7 +21,7 @@ for($i = 0; $i < 2; $i++){ - $globals->xdb->execute("REPLACE INTO entreprises(uid,entrid,entreprise,secteur,ss_secteur,poste,fonction,adr1,adr2,adr3,postcode,city,country,region,tel,fax,mobile,pub, adr_pub, tel_pub, email, email_pub, web) ". + XDB::execute("REPLACE INTO entreprises(uid,entrid,entreprise,secteur,ss_secteur,poste,fonction,adr1,adr2,adr3,postcode,city,country,region,tel,fax,mobile,pub, adr_pub, tel_pub, email, email_pub, web) ". "VALUES ({?}, {?}, {?}, ". "{?},". "{?}". @@ -41,5 +41,5 @@ for($i = 0; $i < 2; $i++){ $pubpro[$i], $adr_pubpro[$i], $tel_pubpro[$i], $emailpro[$i], $email_pubpro[$i], $webpro[$i]); } -$globals->xdb->execute("UPDATE auth_user_md5 set cv= {?} WHERE user_id = {?}", $cv, Session::getInt('uid', -1)); +XDB::execute("UPDATE auth_user_md5 set cv= {?} WHERE user_id = {?}", $cv, Session::getInt('uid', -1)); ?> diff --git a/include/profil/update_general.inc.php b/include/profil/update_general.inc.php index 0b3d818..535b9c6 100644 --- a/include/profil/update_general.inc.php +++ b/include/profil/update_general.inc.php @@ -20,23 +20,23 @@ ***************************************************************************/ if ($appli_id1>0) - $globals->xdb->execute("REPLACE INTO applis_ins SET uid= {?}, aid = {?}, type = {?}, ordre = 0", Session::getInt('uid', -1), $appli_id1, $appli_type1); + XDB::execute("REPLACE INTO applis_ins SET uid= {?}, aid = {?}, type = {?}, ordre = 0", Session::getInt('uid', -1), $appli_id1, $appli_type1); else - $globals->xdb->execute("DELETE FROM applis_ins WHERE uid= {?} AND ordre=0", Session::getInt('uid', -1)); + XDB::execute("DELETE FROM applis_ins WHERE uid= {?} AND ordre=0", Session::getInt('uid', -1)); if ($appli_id2>0) - $globals->xdb->execute("REPLACE INTO applis_ins SET uid= {?}, aid = {?}, type = {?}, ordre = 1", Session::getInt('uid', -1), $appli_id2, $appli_type2); + XDB::execute("REPLACE INTO applis_ins SET uid= {?}, aid = {?}, type = {?}, ordre = 1", Session::getInt('uid', -1), $appli_id2, $appli_type2); else - $globals->xdb->execute("DELETE FROM applis_ins WHERE uid= {?} AND ordre=1", Session::getInt('uid', -1)); + XDB::execute("DELETE FROM applis_ins WHERE uid= {?} AND ordre=1", Session::getInt('uid', -1)); if ($nationalite != $nationalite_anc || $nom != $nom_anc || $prenom != $prenom_anc) { $sql = "UPDATE auth_user_md5 SET nationalite= {?}, nom = {?}, prenom = {?} WHERE user_id= {?}"; - $globals->xdb->execute($sql, $nationalite, $nom, $prenom, Session::getInt('uid', -1)); + XDB::execute($sql, $nationalite, $nom, $prenom, Session::getInt('uid', -1)); } -$globals->xdb->execute( +XDB::execute( "UPDATE auth_user_quick SET profile_nick={?}, profile_mobile={?}, profile_mobile_pub={?}, @@ -55,6 +55,6 @@ if ($nickname != $nickname_anc) { require_once('user.func.inc.php'); user_reindex(Session::getInt('uid', -1)); } -$globals->xdb->execute("UPDATE photo SET pub = {?} WHERE uid = {?}", $photo_pub, Session::getInt('uid', -1)); +XDB::execute("UPDATE photo SET pub = {?} WHERE uid = {?}", $photo_pub, Session::getInt('uid', -1)); // vim:set et sws=4 sts=4 sw=4: ?> diff --git a/include/profil/update_mentor.inc.php b/include/profil/update_mentor.inc.php index 0f70291..4abf46f 100644 --- a/include/profil/update_mentor.inc.php +++ b/include/profil/update_mentor.inc.php @@ -22,7 +22,7 @@ //mise a jour d'expertise si nécessaire if($mentor_expertise != $mentor_expertise_bd) { - $globals->xdb->execute("REPLACE INTO mentor(uid, expertise) VALUES({?}, {?})", Session::getInt('uid', -1), $mentor_expertise); + XDB::execute("REPLACE INTO mentor(uid, expertise) VALUES({?}, {?})", Session::getInt('uid', -1), $mentor_expertise); } diff --git a/include/profil/update_poly.inc.php b/include/profil/update_poly.inc.php index c51ecce..5add42e 100644 --- a/include/profil/update_poly.inc.php +++ b/include/profil/update_poly.inc.php @@ -21,6 +21,6 @@ $sql = "UPDATE auth_user_md5 set section= {?} WHERE user_id= {?}"; -$globals->xdb->execute($sql, $section, Session::getInt('uid', -1)); +XDB::execute($sql, $section, Session::getInt('uid', -1)); ?> diff --git a/include/register.inc.php b/include/register.inc.php index 47cae63..69ccd76 100644 --- a/include/register.inc.php +++ b/include/register.inc.php @@ -84,7 +84,7 @@ function check_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid) $ourmat = sprintf('%04u%04u', 1900+$year, $rang); } - $res = $globals->xdb->query( + $res = XDB::query( 'SELECT user_id, promo, perms IN ("admin","user"), nom, prenom FROM auth_user_md5 WHERE matricule={?} and deces = 0', $ourmat); @@ -107,7 +107,7 @@ function check_old_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid) { global $globals; - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( 'SELECT user_id, nom, prenom, matricule FROM auth_user_md5 WHERE promo={?} AND deces=0 AND perms="pending"', $promo); @@ -119,7 +119,7 @@ function check_old_mat($promo, $mat, $nom, $prenom, &$ourmat, &$ourid) } } - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( 'SELECT user_id, nom, prenom, matricule, alias FROM auth_user_md5 AS u INNER JOIN aliases AS a ON (u.user_id = a.id and FIND_IN_SET("bestalias", a.flags)) @@ -179,13 +179,13 @@ function create_aliases (&$sub) $mailorg2 = $mailorg.sprintf(".%02u", ($promo%100)); $forlife = make_forlife($prenom, $nom, $promo); - $res = $globals->xdb->query('SELECT COUNT(*) FROM aliases WHERE alias={?}', $forlife); + $res = XDB::query('SELECT COUNT(*) FROM aliases WHERE alias={?}', $forlife); if ($res->fetchOneCell() > 0) { return "Tu as un homonyme dans ta promo, il faut traiter ce cas manuellement.
". "envoie un mail à support@polytechnique.org en expliquant ta situation."; } - $res = $globals->xdb->query('SELECT id, type, expire FROM aliases WHERE alias={?}', $mailorg); + $res = XDB::query('SELECT id, type, expire FROM aliases WHERE alias={?}', $mailorg); if ( $res->numRows() ) { @@ -193,10 +193,10 @@ function create_aliases (&$sub) $res->free(); if ( $h_type != 'homonyme' and empty($expire) ) { - $globals->xdb->execute('UPDATE aliases SET expire=ADDDATE(NOW(),INTERVAL 1 MONTH) WHERE alias={?}', $mailorg); - $globals->xdb->execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $h_id); - $globals->xdb->execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $uid); - $res = $globals->xdb->query("SELECT alias FROM aliases WHERE id={?} AND expire IS NULL", $h_id); + XDB::execute('UPDATE aliases SET expire=ADDDATE(NOW(),INTERVAL 1 MONTH) WHERE alias={?}', $mailorg); + XDB::execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $h_id); + XDB::execute('REPLACE INTO homonymes (homonyme_id,user_id) VALUES ({?},{?})', $h_id, $uid); + $res = XDB::query("SELECT alias FROM aliases WHERE id={?} AND expire IS NULL", $h_id); $als = $res->fetchColumn(); require_once('diogenes/diogenes.hermes.inc.php'); @@ -258,9 +258,9 @@ function finish_ins($sub_state) $pass_encrypted = hash_encrypt($pass_clair); $hash = rand_url_id(12); - $globals->xdb->execute('UPDATE auth_user_md5 SET last_known_email={?} WHERE matricule = {?}', $email, $mat); + XDB::execute('UPDATE auth_user_md5 SET last_known_email={?} WHERE matricule = {?}', $email, $mat); - $globals->xdb->execute( + XDB::execute( "REPLACE INTO register_pending (uid, forlife, bestalias, mailorg2, password, email, date, relance, naissance, hash) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, NOW(), 0, {?}, {?})", $uid, $forlife, $bestalias, $mailorg2, $pass_encrypted, $email, $naissance, $hash); diff --git a/include/rss.inc.php b/include/rss.inc.php index 10fb3ed..ba9ae91 100644 --- a/include/rss.inc.php +++ b/include/rss.inc.php @@ -44,7 +44,7 @@ function init_rss($template, $alias, $hash) $page->register_modifier('rss_date', '_rss_encode_date'); $page->default_modifiers = Array('@to_rss'); - $res = $globals->xdb->query( + $res = XDB::query( 'SELECT a.id FROM aliases AS a INNER JOIN auth_user_quick AS q ON ( a.id = q.user_id AND q.core_rss_hash = {?} ) diff --git a/include/secteur.emploi.inc.php b/include/secteur.emploi.inc.php index f6e7eae..41d0f05 100644 --- a/include/secteur.emploi.inc.php +++ b/include/secteur.emploi.inc.php @@ -26,7 +26,7 @@ function select_secteur($secteur){ $secteur = -1; } $html = "\n"; - $res = $globals->xdb->iterRow("SELECT id, label FROM emploi_secteur"); + $res = XDB::iterRow("SELECT id, label FROM emploi_secteur"); while (list($tmp_id, $tmp_label) = $res->next()) { $html .= "\n"; } @@ -37,7 +37,7 @@ function select_ss_secteur($secteur,$ss_secteur){ global $globals; if ($secteur) { $html = "\n"; - $res = $globals->xdb->iterRow("SELECT id, label FROM emploi_ss_secteur WHERE secteur = {?}", $secteur); + $res = XDB::iterRow("SELECT id, label FROM emploi_ss_secteur WHERE secteur = {?}", $secteur); while (list($tmp_id, $tmp_label) = $res->next()){ $html .= "\n"; } diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 980d566..d4edac7 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -33,30 +33,30 @@ function user_clear_all_subs($user_id, $really_del=true) global $globals; $uid = intval($user_id); - $res = $globals->xdb->query("SELECT alias FROM aliases WHERE type='a_vie' AND id={?}", $uid); + $res = XDB::query("SELECT alias FROM aliases WHERE type='a_vie' AND id={?}", $uid); $alias = $res->fetchOneCell(); if ($really_del) { - $globals->xdb->execute("DELETE FROM emails WHERE uid={?}", $uid); - $globals->xdb->execute("DELETE FROM newsletter_ins WHERE user_id={?}", $uid); + XDB::execute("DELETE FROM emails WHERE uid={?}", $uid); + XDB::execute("DELETE FROM newsletter_ins WHERE user_id={?}", $uid); } - $globals->xdb->execute("DELETE FROM virtual_redirect WHERE redirect = {?}", $alias.'@'.$globals->mail->domain); - $globals->xdb->execute("DELETE FROM virtual_redirect WHERE redirect = {?}", $alias.'@'.$globals->mail->domain2); - - $globals->xdb->execute("UPDATE auth_user_md5 SET password='',smtppass='' WHERE user_id={?}", $uid); - $globals->xdb->execute("UPDATE auth_user_quick SET watch_flags='' WHERE user_id={?}", $uid); - - $globals->xdb->execute("DELETE FROM competences_ins WHERE uid={?}", $uid); - $globals->xdb->execute("DELETE FROM entreprises WHERE uid={?}", $uid); - $globals->xdb->execute("DELETE FROM langues_ins WHERE uid={?}", $uid); - $globals->xdb->execute("DELETE FROM mentor_pays WHERE uid={?}", $uid); - $globals->xdb->execute("DELETE FROM mentor_secteur WHERE uid={?}", $uid); - $globals->xdb->execute("DELETE FROM mentor WHERE uid={?}", $uid); - $globals->xdb->execute("DELETE FROM perte_pass WHERE uid={?}", $uid); - $globals->xdb->execute("DELETE FROM requests WHERE user_id={?}", $uid); - $globals->xdb->execute("DELETE FROM user_changes WHERE user_id={?}", $uid); - $globals->xdb->execute("DELETE FROM watch_sub WHERE uid={?}", $uid); + XDB::execute("DELETE FROM virtual_redirect WHERE redirect = {?}", $alias.'@'.$globals->mail->domain); + XDB::execute("DELETE FROM virtual_redirect WHERE redirect = {?}", $alias.'@'.$globals->mail->domain2); + + XDB::execute("UPDATE auth_user_md5 SET password='',smtppass='' WHERE user_id={?}", $uid); + XDB::execute("UPDATE auth_user_quick SET watch_flags='' WHERE user_id={?}", $uid); + + XDB::execute("DELETE FROM competences_ins WHERE uid={?}", $uid); + XDB::execute("DELETE FROM entreprises WHERE uid={?}", $uid); + XDB::execute("DELETE FROM langues_ins WHERE uid={?}", $uid); + XDB::execute("DELETE FROM mentor_pays WHERE uid={?}", $uid); + XDB::execute("DELETE FROM mentor_secteur WHERE uid={?}", $uid); + XDB::execute("DELETE FROM mentor WHERE uid={?}", $uid); + XDB::execute("DELETE FROM perte_pass WHERE uid={?}", $uid); + XDB::execute("DELETE FROM requests WHERE user_id={?}", $uid); + XDB::execute("DELETE FROM user_changes WHERE user_id={?}", $uid); + XDB::execute("DELETE FROM watch_sub WHERE uid={?}", $uid); include_once('lists.inc.php'); if (function_exists(lists_xmlrpc)) { @@ -72,7 +72,7 @@ function get_user_login($data, $get_forlife = false) { global $globals, $page; if (preg_match(',^[0-9]*$,', $data)) { - $res = $globals->xdb->query("SELECT alias FROM aliases WHERE type='a_vie' AND id={?}", $data); + $res = XDB::query("SELECT alias FROM aliases WHERE type='a_vie' AND id={?}", $data); if ($res->numRows()) { return $res->fetchOneCell(); } else { @@ -90,7 +90,7 @@ function get_user_login($data, $get_forlife = false) { list($mbox, $fqdn) = explode('@', $data); if ($fqdn == $globals->mail->domain || $fqdn == $globals->mail->domain2) { - $res = $globals->xdb->query("SELECT a.alias + $res = XDB::query("SELECT a.alias FROM aliases AS a INNER JOIN aliases AS b ON (a.id = b.id AND b.type IN ('alias', 'a_vie') AND b.alias={?}) WHERE a.type = 'a_vie'", $mbox); @@ -103,7 +103,7 @@ function get_user_login($data, $get_forlife = false) { } elseif ($fqdn == $globals->mail->alias_dom || $fqdn == $globals->mail->alias_dom2) { - $res = $globals->xdb->query("SELECT redirect + $res = XDB::query("SELECT redirect FROM virtual_redirect INNER JOIN virtual USING(vid) WHERE alias={?}", $mbox.'@'.$globals->mail->alias_dom); @@ -117,7 +117,7 @@ function get_user_login($data, $get_forlife = false) { } else { - $res = $globals->xdb->query("SELECT alias + $res = XDB::query("SELECT alias FROM aliases AS a INNER JOIN emails AS e ON e.uid=a.id WHERE e.email={?} AND a.type='a_vie'", $data); @@ -178,7 +178,7 @@ function get_user_details_pro($uid, $view = 'private') LEFT JOIN geoloc_region AS gr ON (gr.a2 = e.country and gr.region = e.region) WHERE e.uid = {?} ORDER BY e.entrid"; - $res = $globals->xdb->query($sql, $uid); + $res = XDB::query($sql, $uid); $all_pro = $res->fetchAllAssoc(); foreach ($all_pro as $i => $pro) { if (!has_user_right($pro['pub'], $view)) @@ -255,7 +255,7 @@ function get_user_details_adr($uid, $view = 'private') { LEFT JOIN geoloc_pays AS gp ON (gp.a2=a.country) WHERE uid= {?} AND NOT FIND_IN_SET('pro',a.statut) ORDER BY NOT FIND_IN_SET('active',a.statut), FIND_IN_SET('temporaire',a.statut), FIND_IN_SET('res-secondaire',a.statut)"; - $res = $globals->xdb->query($sql, $uid); + $res = XDB::query($sql, $uid); $all_adr = $res->fetchAllAssoc(); $adrid_index = array(); foreach ($all_adr as $i => $adr) { @@ -270,7 +270,7 @@ function get_user_details_adr($uid, $view = 'private') { INNER JOIN adresses AS a ON (a.uid = t.uid) AND (a.adrid = t.adrid) WHERE t.uid = {?} AND NOT FIND_IN_SET('pro',a.statut) ORDER BY t.adrid, t.tel_type DESC, t.telid"; - $restel = $globals->xdb->iterator($sql, $uid); + $restel = XDB::iterator($sql, $uid); while ($nexttel = $restel->next()) { if (has_user_right($nexttel['tel_pub'], $view)) { $adrid = $nexttel['adrid']; @@ -312,7 +312,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private') LEFT JOIN photo AS p ON (p.uid = u.user_id) LEFT JOIN mentor AS m ON (m.uid = u.user_id) WHERE a.alias = {?}"; - $res = $globals->xdb->query($reqsql, $from_uid, $login); + $res = XDB::query($reqsql, $from_uid, $login); $user = $res->fetchOneAssoc(); $uid = $user['user_id']; // hide orange status, cv, nickname, section @@ -352,11 +352,11 @@ function &get_user_details($login, $from_uid = '', $view = 'private') FROM binets_ins LEFT JOIN binets_def ON binets_ins.binet_id = binets_def.id WHERE user_id = {?}"; - $res = $globals->xdb->query($sql, $uid); + $res = XDB::query($sql, $uid); $user['binets'] = $res->fetchColumn(); $user['binets_join'] = join(', ', $user['binets']); - $res = $globals->xdb->iterRow("SELECT text, url + $res = XDB::iterRow("SELECT text, url FROM groupesx_ins LEFT JOIN groupesx_def ON groupesx_ins.gid = groupesx_def.id WHERE guid = {?}", $uid); @@ -367,7 +367,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private') $user['gpxs_join'] = join(', ', $user['gpxs']); } - $res = $globals->xdb->iterRow("SELECT applis_def.text, applis_def.url, applis_ins.type + $res = XDB::iterRow("SELECT applis_def.text, applis_def.url, applis_ins.type FROM applis_ins INNER JOIN applis_def ON applis_def.id = applis_ins.aid WHERE uid={?} @@ -383,7 +383,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private') $user['applis_join'] = join(', ', $user['applis_fmt']); if (has_user_right($user['medals_pub'], $view)) { - $res = $globals->xdb->iterator("SELECT m.id, m.text AS medal, m.type, m.img, s.gid, g.text AS grade + $res = XDB::iterator("SELECT m.id, m.text AS medal, m.type, m.img, s.gid, g.text AS grade FROM profile_medals_sub AS s INNER JOIN profile_medals AS m ON ( s.mid = m.id ) LEFT JOIN profile_medals_grades AS g ON ( s.mid = g.mid AND s.gid = g.gid ) @@ -400,7 +400,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private') // {{{ function add_user_address() function add_user_address($uid, $adrid, $adr) { global $globals; - $globals->xdb->execute( + XDB::execute( "INSERT INTO adresses (`uid`, `adrid`, `adr1`, `adr2`, `adr3`, `postcode`, `city`, `country`, `datemaj`, `pub`) ( SELECT u.user_id, {?}, {?}, {?}, {?}, {?}, {?}, gp.a2, NOW(), {?} FROM auth_user_md5 AS u @@ -421,7 +421,7 @@ function add_user_address($uid, $adrid, $adr) { function update_user_address($uid, $adrid, $adr) { global $globals; // update address - $globals->xdb->execute( + XDB::execute( "UPDATE adresses AS a LEFT JOIN geoloc_pays AS gp ON (gp.pays = {?}) SET `adr1` = {?}, `adr2` = {?}, `adr3` = {?}, `postcode` = {?}, `city` = {?}, a.`country` = gp.a2, `datemaj` = NOW(), `pub` = {?} @@ -430,7 +430,7 @@ function update_user_address($uid, $adrid, $adr) { $adr['adr1'], $adr['adr2'], $adr['adr3'], $adr['postcode'], $adr['city'], $adr['pub'], $adrid, $uid); if (isset($adr['tels']) && is_array($adr['tels'])) { - $res = $globals->xdb->query("SELECT telid FROM tels WHERE uid = {?} AND adrid = {?} ORDER BY telid", $uid, $adrid); + $res = XDB::query("SELECT telid FROM tels WHERE uid = {?} AND adrid = {?} ORDER BY telid", $uid, $adrid); $telids = $res->fetchColumn(); foreach ($adr['tels'] as $tel) { if (isset($tel['telid']) && isset($tel['remove']) && $tel['remove']) { @@ -449,14 +449,14 @@ function update_user_address($uid, $adrid, $adr) { // {{{ function remove_user_address() function remove_user_address($uid, $adrid) { global $globals; - $globals->xdb->execute("DELETE FROM adresses WHERE adrid = {?} AND uid = {?}", $adrid, $uid); - $globals->xdb->execute("DELETE FROM tels WHERE adrid = {?} AND uid = {?}", $adrid, $uid); + XDB::execute("DELETE FROM adresses WHERE adrid = {?} AND uid = {?}", $adrid, $uid); + XDB::execute("DELETE FROM tels WHERE adrid = {?} AND uid = {?}", $adrid, $uid); } // }}} // {{{ function add_user_tel() function add_user_tel($uid, $adrid, $telid, $tel) { global $globals; - $globals->xdb->execute( + XDB::execute( "INSERT INTO tels SET uid = {?}, adrid = {?}, telid = {?}, tel = {?}, tel_type = {?}, tel_pub = {?}", $uid, $adrid, $telid, $tel['tel'], $tel['tel_type'], $tel['tel_pub']); } @@ -464,7 +464,7 @@ function add_user_tel($uid, $adrid, $telid, $tel) { // {{{ function update_user_tel() function update_user_tel($uid, $adrid, $telid, $tel) { global $globals; - $globals->xdb->execute( + XDB::execute( "UPDATE tels SET tel = {?}, tel_type = {?}, tel_pub = {?} WHERE telid = {?} AND adrid = {?} AND uid = {?}", $tel['tel'], $tel['tel_type'], $tel['tel_pub'], @@ -474,13 +474,13 @@ function update_user_tel($uid, $adrid, $telid, $tel) { // {{{ function remove_user_tel() function remove_user_tel($uid, $adrid, $telid) { global $globals; - $globals->xdb->execute("DELETE FROM tels WHERE telid = {?} AND adrid = {?} AND uid = {?}", $telid, $adrid, $uid); + XDB::execute("DELETE FROM tels WHERE telid = {?} AND adrid = {?} AND uid = {?}", $telid, $adrid, $uid); } // }}} // {{{ function add_user_pro() function add_user_pro($uid, $entrid, $pro) { global $globals; - $globals->xdb->execute( + XDB::execute( "INSERT INTO entreprises (`uid`, `entrid`, `entreprise`, `poste`, `secteur`, `ss_secteur`, `fonction`, `adr1`, `adr2`, `adr3`, `postcode`, `city`, `country`, `region`, `tel`, `fax`, `mobile`, `email`, `web`, `pub`, `adr_pub`, `tel_pub`, `email_pub`) SELECT u.user_id, {?}, {?}, {?}, s.id, ss.id, f.id, @@ -551,19 +551,19 @@ function update_user_pro($uid, $entrid, $pro) { $query = "UPDATE entreprises AS e ".$join." SET ".substr($set,1)." WHERE e.uid = {?} AND e.entrid = {?}"; $args_where = array($uid, $entrid); $args = array_merge(array($query), $args_join, $args_set, $args_where); - $globals->db->query($globals->xdb->_prepare($args)); + $globals->db->query(XDB::_prepare($args)); } // }}} // {{{ function remove_user_pro() function remove_user_pro($uid, $entrid) { global $globals; - $globals->xdb->execute("DELETE FROM entreprises WHERE entrid = {?} AND uid = {?}", $entrid, $uid); + XDB::execute("DELETE FROM entreprises WHERE entrid = {?} AND uid = {?}", $entrid, $uid); } // }}} // {{{ function set_user_details() function set_user_details_addresses($uid, $adrs) { global $globals; - $res = $globals->xdb->query("SELECT adrid FROM adresses WHERE uid = {?} AND adrid >= 1 ORDER BY adrid", $uid); + $res = XDB::query("SELECT adrid FROM adresses WHERE uid = {?} AND adrid >= 1 ORDER BY adrid", $uid); $adrids = $res->fetchColumn(); foreach ($adrs as $adr) { if (isset($adr['adrid']) && isset($adr['remove']) && $adr['remove']) { @@ -586,7 +586,7 @@ function set_user_details_addresses($uid, $adrs) { function set_user_details_pro($uid, $pros) { global $globals; - $res = $globals->xdb->query("SELECT entrid FROM entreprises WHERE uid = {?} ORDER BY entrid", $uid); + $res = XDB::query("SELECT entrid FROM entreprises WHERE uid = {?} ORDER BY entrid", $uid); $entrids = $res->fetchColumn(); foreach ($pros as $pro) { if (isset($pro['entrid']) && isset($pro['remove']) && $pro['remove']) { @@ -606,13 +606,13 @@ function set_user_details_pro($uid, $pros) function set_user_details($uid, $details) { global $globals; if (isset($details['nom_usage'])) { - $globals->xdb->execute("UPDATE auth_user_md5 SET nom_usage = {?} WHERE user_id = {?}", strtoupper($details['nom_usage']), $uid); + XDB::execute("UPDATE auth_user_md5 SET nom_usage = {?} WHERE user_id = {?}", strtoupper($details['nom_usage']), $uid); } if (isset($details['mobile'])) { - $globals->xdb->execute("UPDATE auth_user_quick SET profile_mobile = {?} WHERE user_id = {?}", $details['mobile'], $uid); + XDB::execute("UPDATE auth_user_quick SET profile_mobile = {?} WHERE user_id = {?}", $details['mobile'], $uid); } if (isset($details['nationalite'])) { - $globals->xdb->execute( + XDB::execute( "UPDATE auth_user_md5 AS u INNER JOIN geoloc_pays AS gp SET u.nationalite = gp.a2 @@ -624,18 +624,18 @@ function set_user_details($uid, $details) { if (isset($details['adr_pro']) && is_array($details['adr_pro'])) set_user_details_pro($uid, $details['adr_pro']); if (isset($details['binets']) && is_array($details['binets'])) { - $globals->xdb->execute("DELETE FROM binets_ins WHERE user_id = {?}", $uid); + XDB::execute("DELETE FROM binets_ins WHERE user_id = {?}", $uid); foreach ($details['binets'] as $binet) - $globals->xdb->execute( + XDB::execute( "INSERT INTO binets_ins (`user_id`, `binet_id`) SELECT {?}, id FROM binets_def WHERE text = {?} LIMIT 1", $uid, $binet); } if (isset($details['gpxs']) && is_array($details['gpxs'])) { - $globals->xdb->execute("DELETE FROM groupesx_ins WHERE user_id = {?}", $uid); + XDB::execute("DELETE FROM groupesx_ins WHERE user_id = {?}", $uid); foreach ($details['gpxs'] as $groupex) { if (preg_match('/([^<]+)/', $groupex, $a)) $groupex = $a[1]; - $globals->xdb->execute( + XDB::execute( "INSERT INTO groupesx_ins (`user_id`, `binet_id`) SELECT {?}, id FROM groupesx_def WHERE text = {?} LIMIT 1", $uid, $groupex); @@ -670,8 +670,8 @@ function _user_reindex($uid, $keys, $muls) { function user_reindex($uid) { global $globals; - $globals->xdb->execute("DELETE FROM search_name WHERE uid={?}", $uid); - $res = $globals->xdb->query("SELECT prenom, nom, nom_usage, profile_nick FROM auth_user_md5 INNER JOIN auth_user_quick USING(user_id) WHERE auth_user_md5.user_id = {?}", $uid); + XDB::execute("DELETE FROM search_name WHERE uid={?}", $uid); + $res = XDB::query("SELECT prenom, nom, nom_usage, profile_nick FROM auth_user_md5 INNER JOIN auth_user_quick USING(user_id) WHERE auth_user_md5.user_id = {?}", $uid); _user_reindex($uid, $res->fetchOneRow(), array(1,1,1,0.2)); } diff --git a/include/validations.inc.php b/include/validations.inc.php index 60cceff..45229e7 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -95,7 +95,7 @@ class Validate $this->stamp = date('YmdHis'); $this->unique = $_unique; $this->type = $_type; - $res = $globals->xdb->query( + $res = XDB::query( "SELECT u.prenom, u.nom, u.promo, a.alias, b.alias FROM auth_user_md5 AS u INNER JOIN aliases AS a ON ( u.user_id=a.id AND a.type='a_vie' ) @@ -114,11 +114,11 @@ class Validate { global $globals; if ($this->unique) { - $globals->xdb->execute('DELETE FROM requests WHERE user_id={?} AND type={?}', $this->uid, $this->type); + XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}', $this->uid, $this->type); } $this->stamp = date('YmdHis'); - $globals->xdb->execute('INSERT INTO requests (user_id, type, data, stamp) VALUES ({?}, {?}, {?}, {?})', + XDB::execute('INSERT INTO requests (user_id, type, data, stamp) VALUES ({?}, {?}, {?}, {?})', $this->uid, $this->type, $this, $this->stamp); return true; @@ -130,7 +130,7 @@ class Validate function update () { global $globals; - $globals->xdb->execute('UPDATE requests SET data={?}, stamp=stamp + XDB::execute('UPDATE requests SET data={?}, stamp=stamp WHERE user_id={?} AND type={?} AND stamp={?}', $this, $this->uid, $this->type, $this->stamp); @@ -147,10 +147,10 @@ class Validate { global $globals; if ($this->unique) { - return $globals->xdb->execute('DELETE FROM requests WHERE user_id={?} AND type={?}', + return XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}', $this->uid, $this->type); } else { - return $globals->xdb->execute('DELETE FROM requests WHERE user_id={?} AND type={?} AND stamp={?}', + return XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?} AND stamp={?}', $this->uid, $this->type, $this->stamp); } } @@ -264,9 +264,9 @@ class Validate { global $globals; if ($stamp == -1) { - $res = $globals->xdb->query('SELECT data FROM requests WHERE user_id={?} and type={?}', $uid, $type); + $res = XDB::query('SELECT data FROM requests WHERE user_id={?} and type={?}', $uid, $type); } else { - $res = $globals->xdb->query("SELECT data, stamp FROM requests WHERE user_id={?} AND type={?} and stamp={?}", $uid, $type, $stamp); + $res = XDB::query("SELECT data, stamp FROM requests WHERE user_id={?} AND type={?} and stamp={?}", $uid, $type, $stamp); } if ($result = $res->fetchOneCell()) { $result = unserialize($result); diff --git a/include/validations/aliases.inc.php b/include/validations/aliases.inc.php index 42465b9..9cd0b0b 100644 --- a/include/validations/aliases.inc.php +++ b/include/validations/aliases.inc.php @@ -47,7 +47,7 @@ class AliasReq extends Validate $this->raison = $_raison; $this->public = $_public; - $res = $globals->xdb->query(" + $res = XDB::query(" SELECT v.alias FROM virtual_redirect AS vr INNER JOIN virtual AS v ON (v.vid=vr.vid AND v.alias LIKE '%@{$globals->mail->alias_dom}') @@ -98,15 +98,15 @@ class AliasReq extends Validate { global $globals; - $globals->xdb->execute("UPDATE auth_user_quick SET emails_alias_pub = {?} WHERE user_id = {?}", $this->public, $this->uid); + XDB::execute("UPDATE auth_user_quick SET emails_alias_pub = {?} WHERE user_id = {?}", $this->public, $this->uid); if ($this->old) { - return $globals->xdb->execute('UPDATE virtual SET alias={?} WHERE alias={?}', $this->alias, $this->old); + return XDB::execute('UPDATE virtual SET alias={?} WHERE alias={?}', $this->alias, $this->old); } else { - $globals->xdb->execute('INSERT INTO virtual SET alias={?},type="user"', $this->alias); + XDB::execute('INSERT INTO virtual SET alias={?},type="user"', $this->alias); $vid = mysql_insert_id(); $dom = $globals->mail->shorter_domain(); - return $globals->xdb->query('INSERT INTO virtual_redirect (vid,redirect) VALUES ({?}, {?})', $vid, $this->forlife.'@'.$dom); + return XDB::query('INSERT INTO virtual_redirect (vid,redirect) VALUES ({?}, {?})', $vid, $this->forlife.'@'.$dom); } } diff --git a/include/validations/evts.inc.php b/include/validations/evts.inc.php index 56786e0..9bcba19 100644 --- a/include/validations/evts.inc.php +++ b/include/validations/evts.inc.php @@ -79,7 +79,7 @@ class EvtReq extends Validate function commit() { global $globals; - return $globals->xdb->execute( + return XDB::execute( "INSERT INTO evenements SET user_id = {?}, creation_date=NOW(), titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide')", diff --git a/include/validations/homonymes.inc.php b/include/validations/homonymes.inc.php index 56860bb..66c7be4 100644 --- a/include/validations/homonymes.inc.php +++ b/include/validations/homonymes.inc.php @@ -134,8 +134,8 @@ est ambigu pour des raisons d'homonymie et signalera ton email exact."; switch_bestalias($this->uid, $this->loginbis); if (!$this->warning) { - $globals->xdb->execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $this->loginbis); - $globals->xdb->execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $this->uid, $this->uid); + XDB::execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $this->loginbis); + XDB::execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $this->uid, $this->uid); } return true; diff --git a/include/validations/listes.inc.php b/include/validations/listes.inc.php index c97e7ea..6ffd215 100644 --- a/include/validations/listes.inc.php +++ b/include/validations/listes.inc.php @@ -96,7 +96,7 @@ class ListeReq extends Validate $liste = strtolower($this->liste); if ($ret) { foreach(Array($liste, $liste."-owner", $liste."-admin", $liste."-bounces") as $l) { - $globals->xdb->execute("INSERT INTO aliases (alias,type) VALUES({?}, 'liste')", $l); + XDB::execute("INSERT INTO aliases (alias,type) VALUES({?}, 'liste')", $l); } } return $ret; diff --git a/include/validations/marketing.inc.php b/include/validations/marketing.inc.php index be3292f..0e3faf9 100644 --- a/include/validations/marketing.inc.php +++ b/include/validations/marketing.inc.php @@ -47,7 +47,7 @@ class MarkReq extends Validate $this->m_email = $email; $this->perso = $perso; - $res = $globals->xdb->query('SELECT nom, prenom, promo FROM auth_user_md5 WHERE user_id = {?}', $mark_id); + $res = XDB::query('SELECT nom, prenom, promo FROM auth_user_md5 WHERE user_id = {?}', $mark_id); list ($this->m_nom, $this->m_prenom, $this->m_promo) = $res->fetchOneRow(); } diff --git a/include/validations/nomusage.inc.php b/include/validations/nomusage.inc.php index f9b2e6d..b53d868 100644 --- a/include/validations/nomusage.inc.php +++ b/include/validations/nomusage.inc.php @@ -53,7 +53,7 @@ class UsageReq extends Validate $this->alias = make_username($this->prenom, $this->nom_usage); if (!$this->nom_usage) $this->alias = ""; - $res = $globals->xdb->query(" + $res = XDB::query(" SELECT e.alias, u.nom_usage, a.id FROM auth_user_md5 as u LEFT JOIN aliases as e ON(e.type='alias' AND FIND_IN_SET('usage',e.flags) AND e.id = u.user_id) diff --git a/include/validations/orange.inc.php b/include/validations/orange.inc.php index c379084..2754bb7 100644 --- a/include/validations/orange.inc.php +++ b/include/validations/orange.inc.php @@ -42,7 +42,7 @@ class OrangeReq extends Validate global $globals; $this->Validate($_uid, true, 'orange'); $this->promo_sortie = $_sortie; - $res = $globals->xdb->query("SELECT promo FROM auth_user_md5 WHERE user_id = {?}", $_uid); + $res = XDB::query("SELECT promo FROM auth_user_md5 WHERE user_id = {?}", $_uid); $this->promo = $res->fetchOneCell(); } @@ -89,7 +89,7 @@ class OrangeReq extends Validate { global $globals; - $globals->xdb->execute("UPDATE auth_user_md5 set promo_sortie={?} WHERE user_id={?}",$this->promo_sortie ,$this->uid); + XDB::execute("UPDATE auth_user_md5 set promo_sortie={?} WHERE user_id={?}",$this->promo_sortie ,$this->uid); return true; } diff --git a/include/validations/paiements.inc.php b/include/validations/paiements.inc.php index e0aafca..0a3a9e4 100644 --- a/include/validations/paiements.inc.php +++ b/include/validations/paiements.inc.php @@ -57,11 +57,11 @@ class PayReq extends Validate $this->montant_max = $_montantmax; if ($_asso_id) { - $res = $globals->xdb->query("SELECT nom FROM groupex.asso WHERE id = {?}", $_asso_id); + $res = XDB::query("SELECT nom FROM groupex.asso WHERE id = {?}", $_asso_id); $this->asso = $res->fetchOneCell(); } if ($_asso_id && $_evt) { - $res = $globals->xdb->query("SELECT intitule FROM groupex.evenements WHERE asso_id = {?} AND eid = {?}", $_asso_id, $_evt); + $res = XDB::query("SELECT intitule FROM groupex.evenements WHERE asso_id = {?} AND eid = {?}", $_asso_id, $_evt); $this->evt_intitule = $res->fetchOneCell(); } } @@ -83,7 +83,7 @@ class PayReq extends Validate global $globals; if ($this->evt) { - $globals->xdb->execute('DELETE FROM requests WHERE type={?} AND data LIKE {?}', 'paiements', PayReq::same_event($this->evt, $this->asso_id)); + XDB::execute('DELETE FROM requests WHERE type={?} AND data LIKE {?}', 'paiements', PayReq::same_event($this->evt, $this->asso_id)); } Validate::submit(); } @@ -119,9 +119,9 @@ class PayReq extends Validate function commit() { global $globals; - $res = $globals->xdb->query("SELECT MAX(id) FROM paiement.paiements"); + $res = XDB::query("SELECT MAX(id) FROM paiement.paiements"); $id = $res->fetchOneCell()+1; - $ret = $globals->xdb->execute("INSERT INTO paiement.paiements VALUES + $ret = XDB::execute("INSERT INTO paiement.paiements VALUES ( {?}, {?}, {?}, '', {?}, {?}, {?}, {?}, {?}, {?} ) @@ -130,7 +130,7 @@ class PayReq extends Validate $this->montant, $this->montant_min, $this->montant_max, $this->bestalias."@".$globals->mail->domain, $this->msg_reponse, $this->asso_id); if ($this->asso_id && $this->evt) - $ret = $globals->xdb->execute("UPDATE groupex.evenements SET paiement_id = {?} WHERE asso_id = {?} AND eid = {?}", $id, $this->asso_id, $this->evt); + $ret = XDB::execute("UPDATE groupex.evenements SET paiement_id = {?} WHERE asso_id = {?} AND eid = {?}", $id, $this->asso_id, $this->evt); return $ret; } diff --git a/include/validations/photos.inc.php b/include/validations/photos.inc.php index b1c2375..a1596cc 100644 --- a/include/validations/photos.inc.php +++ b/include/validations/photos.inc.php @@ -142,7 +142,7 @@ class PhotoReq extends Validate { global $globals; - $globals->xdb->execute('REPLACE INTO photo (uid, attachmime, attach, x, y) + XDB::execute('REPLACE INTO photo (uid, attachmime, attach, x, y) VALUES ({?},{?},{?},{?},{?})', $this->uid, $this->mimetype, $this->data, $this->x, $this->y); require_once('notifs.inc.php'); diff --git a/include/webservices/manageurs.server.inc.php b/include/webservices/manageurs.server.inc.php index 11679d5..ee8820b 100644 --- a/include/webservices/manageurs.server.inc.php +++ b/include/webservices/manageurs.server.inc.php @@ -29,7 +29,7 @@ function get_annuaire_infos($method, $params) { //on ne recupere pas les adresses inutilement if(!isset($params[2])){ - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT q.profile_mobile AS cell, a.naissance AS age FROM auth_user_md5 AS a INNER JOIN auth_user_quick AS q USING (user_id) @@ -37,7 +37,7 @@ function get_annuaire_infos($method, $params) { $array = $res->next(); } else{ - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT q.profile_mobile AS cell, a.naissance AS age, adr.adr1, adr.adr2, adr.adr3, adr.postcode, adr.city, adr.country, @@ -83,7 +83,7 @@ function get_annuaire_infos($method, $params) { $adrid_index = array(); foreach ($array['adresse'] as $i => $a) $adrid_index[$a['adrid']] = $i; // on rajoute les numéros de tels - $restel = $globals->xdb->iterator( + $restel = XDB::iterator( "SELECT t.tel, t.tel_type, t.adrid FROM tels AS t INNER JOIN adresses AS a ON (t.adrid = a.adrid AND t.uid = a.uid) @@ -150,7 +150,7 @@ function get_nouveau_infos($method, $params) { if(!isset($params[0]) || ($params[0] != $globals->manageurs->manageurs_pass)){return false;} if( !empty($params[1]) ){ // on verifie qu'on a bien un matricule - $res = $globals->xdb->query( + $res = XDB::query( "SELECT a.nom, a.nom_usage,a.prenom,a.flags='femme' as femme ,a.deces!= 0 as decede ,a.naissance,a.promo,al.alias as mail FROM auth_user_md5 AS a INNER JOIN aliases as al ON a.user_id=al.id diff --git a/include/xnet/globals.inc.php b/include/xnet/globals.inc.php index f57dac0..c4185dd 100644 --- a/include/xnet/globals.inc.php +++ b/include/xnet/globals.inc.php @@ -48,7 +48,6 @@ class XnetGlobals extends PlatalGlobals if ($globals->debug & 1) { $globals->db->trace_on(); } - $globals->xdb =& new XOrgDB; } function asso($key=null) @@ -60,10 +59,10 @@ class XnetGlobals extends PlatalGlobals $gp = substr($gp, 0, strpos($gp, '/')); if ($gp) { - $res = $this->xdb->query('SELECT a.*, d.nom AS domnom - FROM groupex.asso AS a - LEFT JOIN groupex.dom AS d ON d.id = a.dom - WHERE diminutif = {?}', $gp); + $res = XDB::query('SELECT a.*, d.nom AS domnom + FROM groupex.asso AS a + LEFT JOIN groupex.dom AS d ON d.id = a.dom + WHERE diminutif = {?}', $gp); if (!($aid = $res->fetchOneAssoc())) { $aid = array(); } diff --git a/include/xnet/mail.inc.php b/include/xnet/mail.inc.php index 4555f24..5f665e5 100644 --- a/include/xnet/mail.inc.php +++ b/include/xnet/mail.inc.php @@ -30,7 +30,7 @@ function get_all_redirects($membres, $mls, &$client) $tos = array(); if ($membres) { - $res = $globals->xdb->query( + $res = XDB::query( 'SELECT IF(u.nom <> "", u.nom, m.nom) AS nom, IF(u.prenom <> "", u.prenom, m.prenom) AS prenom, IF(m.email <> "", m.email, CONCAT(a.alias, "@polytechnique.org")) as email, @@ -47,7 +47,7 @@ function get_all_redirects($membres, $mls, &$client) foreach ($members as $mem) { list($m, $dom) = explode('@',$mem[1]); if ($dom == $globals->mail->domain || $dom == $globals->mail->domain2) { - $res = $globals->xdb->query('SELECT prenom, nom, FIND_IN_SET("femme", u.flags) AS sexe + $res = XDB::query('SELECT prenom, nom, FIND_IN_SET("femme", u.flags) AS sexe FROM auth_user_md5 AS u INNER JOIN aliases AS a ON u.user_id = a.id WHERE a.alias = {?}', $m); @@ -56,7 +56,7 @@ function get_all_redirects($membres, $mls, &$client) $tos[] = $person; } } else { - $res = $globals->xdb->query('SELECT prenom, nom FROM groupex.membres WHERE email={?}', $mem); + $res = XDB::query('SELECT prenom, nom FROM groupex.membres WHERE email={?}', $mem); if ($person = $res->fetchOneAssoc()) { $person['email'] = $mem[1]; $tos[] = $person; diff --git a/include/xnet/session.inc.php b/include/xnet/session.inc.php index 445fdfe..d26200f 100644 --- a/include/xnet/session.inc.php +++ b/include/xnet/session.inc.php @@ -101,7 +101,7 @@ class XnetSession $page->kill("Erreur d'authentification avec polytechnique.org !"); } - $res = $globals->xdb->query(" + $res = XDB::query(" SELECT u.user_id AS uid, prenom, nom, perms, promo, password, FIND_IN_SET('femme', u.flags) AS femme, a.alias AS forlife, a2.alias AS bestalias, q.core_mail_fmt AS mail_fmt, q.core_rss_hash FROM auth_user_md5 AS u @@ -150,7 +150,7 @@ function may_update() { global $globals; if (!$globals->asso('id')) { return false; } if (has_perms()) { return true; } - $res = $globals->xdb->query( + $res = XDB::query( "SELECT perms FROM groupex.membres WHERE uid={?} AND asso_id={?}", Session::getInt('uid'), $globals->asso('id')); @@ -168,7 +168,7 @@ function is_member() { if (!$is_member) $is_member = array(); if (!isset($is_member[$asso_id])) { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT COUNT(*) FROM groupex.membres WHERE uid={?} AND asso_id={?}", diff --git a/include/xnet/smarty.plugins.inc.php b/include/xnet/smarty.plugins.inc.php index f8331d5..fd14806 100644 --- a/include/xnet/smarty.plugins.inc.php +++ b/include/xnet/smarty.plugins.inc.php @@ -29,7 +29,7 @@ function list_all_my_groups($params) return; } global $globals; - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT a.nom, a.diminutif FROM groupex.asso AS a INNER JOIN groupex.membres AS m ON m.asso_id = a.id diff --git a/include/xorg/globals.inc.php b/include/xorg/globals.inc.php index 085a2d1..8d60895 100644 --- a/include/xorg/globals.inc.php +++ b/include/xorg/globals.inc.php @@ -52,7 +52,6 @@ class XorgGlobals extends PlatalGlobals if ($globals->debug & 1) { $globals->db->trace_on(); } - $globals->xdb =& new XOrgDB; } } diff --git a/include/xorg/session.inc.php b/include/xorg/session.inc.php index f1a05f6..54b6416 100644 --- a/include/xorg/session.inc.php +++ b/include/xorg/session.inc.php @@ -83,7 +83,7 @@ class XorgSession if (Env::get('domain') == "alias") { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT redirect FROM virtual INNER JOIN virtual_redirect USING(vid) @@ -99,7 +99,7 @@ class XorgSession } $field = (!$redirect && preg_match('/^\d*$/', $uname)) ? 'id' : 'alias'; - $res = $globals->xdb->query( + $res = XDB::query( "SELECT u.user_id, u.password FROM auth_user_md5 AS u INNER JOIN aliases AS a ON ( a.id=u.user_id AND type!='homonyme' ) @@ -114,7 +114,7 @@ class XorgSession $new_password = hash_xor(Env::get('xorpass'), $password); $expected_response = hash_encrypt("$uname:$new_password:{$session->challenge}"); if (Env::get('response') == $expected_response) { - $globals->xdb->execute("UPDATE auth_user_md5 SET password = {?} WHERE user_id = {?}", $new_password, $uid); + XDB::execute("UPDATE auth_user_md5 SET password = {?} WHERE user_id = {?}", $new_password, $uid); } } if (Env::get('response') == $expected_response) { @@ -226,7 +226,7 @@ function try_cookie() return -1; } - $res = @$globals->xdb->query( + $res = @XDB::query( "SELECT user_id,password FROM auth_user_md5 WHERE user_id = {?} AND perms IN('admin','user')", Cookie::getInt('ORGuid') ); @@ -256,7 +256,7 @@ function try_cookie() function start_connexion ($uid, $identified) { global $globals; - $res = $globals->xdb->query(" + $res = XDB::query(" SELECT u.user_id AS uid, prenom, nom, perms, promo, matricule, password, FIND_IN_SET('femme', u.flags) AS femme, UNIX_TIMESTAMP(s.start) AS lastlogin, s.host, a.alias AS forlife, a2.alias AS bestalias, q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash @@ -295,7 +295,7 @@ function set_skin() global $globals; if (logged() && $globals->skin->enable) { $uid = Session::getInt('uid'); - $res = $globals->xdb->query("SELECT skin,skin_tpl + $res = XDB::query("SELECT skin,skin_tpl FROM auth_user_quick AS a INNER JOIN skins AS s ON a.skin=s.id WHERE user_id = {?} AND skin_tpl != ''", $uid); diff --git a/modules/auth.php b/modules/auth.php index 8550ae3..da708a5 100644 --- a/modules/auth.php +++ b/modules/auth.php @@ -55,7 +55,7 @@ class AuthModule extends PLModule if (Session::get('chall') && $_GET['PASS'] == md5(Session::get('chall').$cle)) { - $res = $globals->xdb->query("SELECT password FROM auth_user_md5 WHERE user_id=10154"); + $res = XDB::query("SELECT password FROM auth_user_md5 WHERE user_id=10154"); $pass = $res->fetchOneCell(); $client =& lists_xmlrpc(10154, $pass, "x-econfiance.polytechnique.org"); @@ -73,7 +73,7 @@ class AuthModule extends PLModule $where = join(' OR ',$membres); - $all = $globals->xdb->iterRow( + $all = XDB::iterRow( "SELECT u.prenom,u.nom,a.alias FROM auth_user_md5 AS u INNER JOIN aliases AS a ON ( u.user_id = a.id AND a.type!='homonyme' ) @@ -151,7 +151,7 @@ class AuthModule extends PLModule } /* on parcourt les entrees de groupes_auth */ - $res = $globals->xdb->iterRow('select privkey,name,datafields from groupesx_auth'); + $res = XDB::iterRow('select privkey,name,datafields from groupesx_auth'); while (list($privkey,$name,$datafields) = $res->next()) { if (md5($gpex_challenge.$privkey) == $gpex_pass) { diff --git a/modules/auth/auth.inc.php b/modules/auth/auth.inc.php index 64aa66e..2d5aab4 100644 --- a/modules/auth/auth.inc.php +++ b/modules/auth/auth.inc.php @@ -25,7 +25,7 @@ function gpex_make_auth($chlg, $privkey, $datafields) { $fieldarr = explode(",",$datafields); $tohash = "1$chlg$privkey"; - $res = $globals->xdb->query("SELECT matricule, matricule_ax, promo, + $res = XDB::query("SELECT matricule, matricule_ax, promo, promo_sortie, flags, deces, nom, prenom, nationalite, section, naissance @@ -40,7 +40,7 @@ function gpex_make_auth($chlg, $privkey, $datafields) { } else if (isset($personnal_data[$val])) { $tohash .= $personnal_data[$val]; } else if ($val == 'username') { - $res = $globals->xdb->query("SELECT alias FROM aliases + $res = XDB::query("SELECT alias FROM aliases WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", Session::getInt('uid')); $min_username = $res->fetchOneCell(); @@ -56,7 +56,7 @@ function gpex_make_params($chlg, $privkey, $datafields) { global $globals; $params = "&auth=".gpex_make_auth($chlg, $privkey, $datafields); - $res = $globals->xdb->query("SELECT matricule, matricule_ax, promo, + $res = XDB::query("SELECT matricule, matricule_ax, promo, promo_sortie, flags, deces, nom, prenom, nationalite, section, naissance @@ -72,7 +72,7 @@ function gpex_make_params($chlg, $privkey, $datafields) { } else if (isset($personnal_data[$val])) { $params .= "&$val=".$personnal_data[$val]; } else if ($val == 'username') { - $res = $globals->xdb->query("SELECT alias FROM aliases + $res = XDB::query("SELECT alias FROM aliases WHERE id = {?} AND FIND_IN_SET('bestalias', flags)", Session::getInt('uid')); $min_username = $res->fetchOneCell(); diff --git a/modules/banana.php b/modules/banana.php index 3be2ced..aa5ccca 100644 --- a/modules/banana.php +++ b/modules/banana.php @@ -68,7 +68,7 @@ class BananaModule extends PLModule && Post::has('bananadisplay') && Post::has('bananamail') && Post::has('bananaupdate') && Post::get('action')=="OK" )) { - $req = $globals->xdb->query(" + $req = XDB::query(" SELECT nom,mail,sig,if(FIND_IN_SET('threads',flags),'1','0'), IF(FIND_IN_SET('automaj',flags),'1','0') FROM forums.profils @@ -86,7 +86,7 @@ class BananaModule extends PLModule $page->assign('disp', $disp); $page->assign('maj' , $maj); } else { - $globals->xdb->execute( + XDB::execute( 'REPLACE INTO forums.profils (uid,sig,mail,nom,flags) VALUES ({?},{?},{?},{?},{?})', Session::getInt('uid'), Post::get('bananasig'), diff --git a/modules/carnet.php b/modules/carnet.php index 286c0d5..b4e5176 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -118,7 +118,7 @@ class CarnetModule extends PLModule $watch = new Watch(Session::getInt('uid')); - $res = $globals->xdb->query("SELECT promo_sortie + $res = XDB::query("SELECT promo_sortie FROM auth_user_md5 WHERE user_id = {?}", Session::getInt('uid', -1)); @@ -156,7 +156,7 @@ class CarnetModule extends PLModule function _get_list($offset, $limit) { global $globals; $uid = Session::getInt('uid'); - $res = $globals->xdb->query("SELECT COUNT(*) FROM contacts WHERE uid = {?}", $uid); + $res = XDB::query("SELECT COUNT(*) FROM contacts WHERE uid = {?}", $uid); $total = $res->fetchOneCell(); $order = Get::get('order'); @@ -170,7 +170,7 @@ class CarnetModule extends PLModule if (Get::get('inv') == '') $order = str_replace(" DESC,", ",", $order); - $res = $globals->xdb->query(" + $res = XDB::query(" SELECT u.prenom, IF(u.nom_usage='',u.nom,u.nom_usage) AS nom, a.alias AS forlife, u.promo FROM contacts AS c INNER JOIN auth_user_md5 AS u ON (u.user_id = c.contact) @@ -197,14 +197,14 @@ class CarnetModule extends PLModule switch (Env::get('action')) { case 'retirer': if (is_numeric($user)) { - if ($globals->xdb->execute('DELETE FROM contacts + if (XDB::execute('DELETE FROM contacts WHERE uid = {?} AND contact = {?}', $uid, $user)) { $page->trig("Contact retiré !"); } } else { - if ($globals->xdb->execute( + if (XDB::execute( 'DELETE FROM contacts USING contacts AS c INNER JOIN aliases AS a ON (c.contact=a.id and a.type!="homonyme") @@ -218,7 +218,7 @@ class CarnetModule extends PLModule case 'ajouter': require_once('user.func.inc.php'); if (($login = get_user_login($user)) !== false) { - if ($globals->xdb->execute( + if (XDB::execute( 'INSERT INTO contacts (uid, contact) SELECT {?}, id FROM aliases @@ -289,7 +289,7 @@ class CarnetModule extends PLModule WHERE c.uid = $uid ORDER BY ".$order; - $page->assign_by_ref('citer', $globals->xdb->iterator($sql)); + $page->assign_by_ref('citer', XDB::iterator($sql)); } } @@ -313,7 +313,7 @@ class CarnetModule extends PLModule $sql .= ' ORDER BY u.nom, u.prenom, u.promo'; } - $citer = $globals->xdb->iterRow($sql, Session::getInt('uid')); + $citer = XDB::iterRow($sql, Session::getInt('uid')); $pdf = new ContactsPDF(); while (list($alias) = $citer->next()) { @@ -342,7 +342,7 @@ class CarnetModule extends PLModule new_nonhtml_page('carnet/calendar.tpl', AUTH_PUBLIC); if ($alias && $hash) { - $res = $globals->xdb->query( + $res = XDB::query( 'SELECT a.id FROM aliases AS a INNER JOIN auth_user_quick AS q ON ( a.id = q.user_id AND q.core_rss_hash = {?} ) diff --git a/modules/email.php b/modules/email.php index 881b2c0..ddecd56 100644 --- a/modules/email.php +++ b/modules/email.php @@ -45,8 +45,8 @@ class EmailModule extends PLModule if (Post::has('best')) { // bestalias is the first bit : 1 // there will be maximum 8 bits in flags : 255 - $globals->xdb->execute("UPDATE aliases SET flags=flags & (255 - 1) WHERE id={?}", $uid); - $globals->xdb->execute("UPDATE aliases SET flags=flags | 1 WHERE id={?} AND alias={?}", + XDB::execute("UPDATE aliases SET flags=flags & (255 - 1) WHERE id={?}", $uid); + XDB::execute("UPDATE aliases SET flags=flags | 1 WHERE id={?} AND alias={?}", $uid, Post::get('best')); } @@ -57,17 +57,17 @@ class EmailModule extends PLModule FROM aliases WHERE id = {?} AND type!='homonyme' ORDER BY LENGTH(alias)"; - $page->assign('aliases', $globals->xdb->iterator($sql, $uid)); + $page->assign('aliases', XDB::iterator($sql, $uid)); $sql = "SELECT email FROM emails WHERE uid = {?} AND FIND_IN_SET('active', flags)"; - $page->assign('mails', $globals->xdb->iterator($sql, $uid)); + $page->assign('mails', XDB::iterator($sql, $uid)); // on regarde si l'utilisateur a un alias et si oui on l'affiche ! $forlife = Session::get('forlife'); - $res = $globals->xdb->query( + $res = XDB::query( "SELECT alias FROM virtual AS v INNER JOIN virtual_redirect AS vr USING(vid) @@ -93,7 +93,7 @@ class EmailModule extends PLModule if ($action == 'suppr' && $value) { //Suppression d'un alias - $globals->xdb->execute( + XDB::execute( 'DELETE virtual, virtual_redirect FROM virtual INNER JOIN virtual_redirect USING (vid) @@ -102,7 +102,7 @@ class EmailModule extends PLModule } //Récupération des alias éventuellement existants - $res = $globals->xdb->query( + $res = XDB::query( "SELECT alias, emails_alias_pub FROM auth_user_quick, virtual INNER JOIN virtual_redirect USING(vid) @@ -135,7 +135,7 @@ class EmailModule extends PLModule return; } else { //vérifier que l'alias n'est pas déja pris - $res = $globals->xdb->query('SELECT COUNT(*) FROM virtual WHERE alias={?}', + $res = XDB::query('SELECT COUNT(*) FROM virtual WHERE alias={?}', $alias.'@'.$globals->mail->alias_dom); if ($res->fetchOneCell() > 0) { $page->trig("L'alias $alias@{$globals->mail->alias_dom} a déja été attribué. @@ -164,10 +164,10 @@ class EmailModule extends PLModule && ($value == 'public' || $value == 'private')) { if ($value == 'public') { - $globals->xdb->execute("UPDATE auth_user_quick SET emails_alias_pub = 'public' + XDB::execute("UPDATE auth_user_quick SET emails_alias_pub = 'public' WHERE user_id = {?}", Session::getInt('uid')); } else { - $globals->xdb->execute("UPDATE auth_user_quick SET emails_alias_pub = 'private' + XDB::execute("UPDATE auth_user_quick SET emails_alias_pub = 'private' WHERE user_id = {?}", Session::getInt('uid')); } @@ -206,7 +206,7 @@ class EmailModule extends PLModule } } - $res = $globals->xdb->query( + $res = XDB::query( "SELECT alias FROM virtual INNER JOIN virtual_redirect USING(vid) @@ -219,7 +219,7 @@ class EmailModule extends PLModule $page->assign('melix',$melix); } - $res = $globals->xdb->query( + $res = XDB::query( "SELECT alias,expire FROM aliases WHERE id={?} AND (type='a_vie' OR type='alias') @@ -284,7 +284,7 @@ class EmailModule extends PLModule $_REQUEST['bcc'] = Session::get('bestalias').'@'.$globals->mail->domain; } - $res = $globals->xdb->query( + $res = XDB::query( "SELECT u.prenom, u.nom, u.promo, a.alias as forlife FROM auth_user_md5 AS u INNER JOIN contacts AS c ON (u.user_id = c.contact) @@ -305,7 +305,7 @@ class EmailModule extends PLModule if ($warn == 'warn' && $email) { $email = valide_email($email); // vérifications d'usage - $sel = $globals->xdb->query( + $sel = XDB::query( "SELECT e.uid, a.alias FROM emails AS e INNER JOIN auth_user_md5 AS u ON e.uid = u.user_id @@ -354,7 +354,7 @@ L' $page->assign('neuneu', true); } else { $page->assign('email',$email); - $sel = $globals->xdb->query( + $sel = XDB::query( "SELECT e1.uid, e1.panne != 0 AS panne, count(e2.uid) AS nb_mails, u.nom, u.prenom, u.promo FROM emails as e1 @@ -367,7 +367,7 @@ L' if ($x = $sel->fetchOneAssoc()) { // on écrit dans la base que l'adresse est cassée if (!$x['panne']) { - $globals->xdb->execute("UPDATE emails SET panne=NOW() WHERE email = {?}", $email); + XDB::execute("UPDATE emails SET panne=NOW() WHERE email = {?}", $email); } $page->assign_by_ref('x', $x); } diff --git a/modules/events.php b/modules/events.php index 4e0ca1e..98d2592 100644 --- a/modules/events.php +++ b/modules/events.php @@ -39,7 +39,7 @@ class EventsModule extends PLModule $page->changeTpl('login.tpl'); - $res = $globals->xdb->query('SELECT date, naissance FROM auth_user_md5 + $res = XDB::query('SELECT date, naissance FROM auth_user_md5 WHERE user_id={?}', Session::getInt('uid')); list($date, $naissance) = $res->fetchOneRow(); @@ -60,7 +60,7 @@ class EventsModule extends PLModule // incitation à mettre une photo - $res = $globals->xdb->query('SELECT COUNT(*) FROM photo + $res = XDB::query('SELECT COUNT(*) FROM photo WHERE uid={?}', Session::getInt('uid')); $page->assign('photo_incitation', $res->fetchOneCell() == 0); @@ -100,15 +100,15 @@ class EventsModule extends PLModule // cache les evenements lus et raffiche les evenements a relire if (Env::has('lu')){ - $globals->xdb->execute('DELETE FROM evenements_vus AS ev + XDB::execute('DELETE FROM evenements_vus AS ev INNER JOIN evenements AS e ON e.id = ev.evt_id WHERE peremption < NOW)'); - $globals->xdb->execute('REPLACE INTO evenements_vus VALUES({?},{?})', + XDB::execute('REPLACE INTO evenements_vus VALUES({?},{?})', Env::get('lu'), Session::getInt('uid')); } if (Env::has('nonlu')){ - $globals->xdb->execute('DELETE FROM evenements_vus + XDB::execute('DELETE FROM evenements_vus WHERE evt_id = {?} AND user_id = {?}', Env::get('nonlu'), Session::getInt('uid')); } @@ -128,7 +128,7 @@ class EventsModule extends PLModule AND ev.user_id IS NULL ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC, e.peremption"; $page->assign('evenement', - $globals->xdb->iterator($sql, Session::getInt('uid'), + XDB::iterator($sql, Session::getInt('uid'), $promo, $promo) ); @@ -140,7 +140,7 @@ class EventsModule extends PLModule AND (e.promo_max = 0 || e.promo_max >= {?}) ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC, e.peremption"; $page->assign('evenement_summary', - $globals->xdb->iterator($sql, Session::getInt('uid'), + XDB::iterator($sql, Session::getInt('uid'), $promo, $promo) ); } diff --git a/modules/geoloc.php b/modules/geoloc.php index bd9ea59..fdb8289 100644 --- a/modules/geoloc.php +++ b/modules/geoloc.php @@ -54,7 +54,7 @@ class GeolocModule extends PLModule $page->changeTpl('geoloc/index.tpl'); - $res = $globals->xdb->query('SELECT COUNT(DISTINCT uid) + $res = XDB::query('SELECT COUNT(DISTINCT uid) FROM adresses WHERE cityid IS NOT NULL'); $page->assign('localises', $res->fetchOneCell()); @@ -135,7 +135,7 @@ class GeolocModule extends PLModule $where = $fields->get_where_statement(); if ($where) $where = "WHERE ".$where; - $users = $globals->xdb->iterator(" + $users = XDB::iterator(" SELECT u.user_id AS id, u.prenom, u.nom, u.promo FROM adresses AS a INNER JOIN auth_user_md5 AS u ON(u.user_id = a.uid) diff --git a/modules/lists.php b/modules/lists.php index 6435b4d..e393a7f 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -133,7 +133,7 @@ class ListsModule extends PLModule $page->trig('le nom de la liste ne doit contenir que des lettres, chiffres et tirets'); } - $res = $globals->xdb->query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste); + $res = XDB::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste); $n = $res->fetchOneCell(); if ($n) { @@ -210,7 +210,7 @@ class ListsModule extends PLModule $membres = Array(); foreach ($members as $member) { list($m) = explode('@',$member[1]); - $res = $globals->xdb->query("SELECT prenom,if (nom_usage='', nom, nom_usage) AS nom, + $res = XDB::query("SELECT prenom,if (nom_usage='', nom, nom_usage) AS nom, promo, a.alias AS forlife FROM auth_user_md5 AS u INNER JOIN aliases AS a ON u.user_id = a.id @@ -555,7 +555,7 @@ class ListsModule extends PLModule && $this->client->delete_list($liste, Post::getBool('del_archive'))) { foreach (array('', '-owner', '-admin', '-bounces') as $app) { - $globals->xdb->execute("DELETE FROM aliases + XDB::execute("DELETE FROM aliases WHERE type='liste' AND alias='{?}'", $liste.$app); } diff --git a/modules/marketing.php b/modules/marketing.php index 6543e97..d2ede2a 100644 --- a/modules/marketing.php +++ b/modules/marketing.php @@ -45,7 +45,7 @@ class MarketingModule extends PLModule // Quelques statistiques - $res = $globals->xdb->query( + $res = XDB::query( "SELECT COUNT(*) AS vivants, COUNT(NULLIF(perms='admin' OR perms='user', 0)) AS inscrits, 100*COUNT(NULLIF(perms='admin' OR perms='user', 0))/COUNT(*) AS ins_rate, @@ -62,17 +62,17 @@ class MarketingModule extends PLModule $stats = $res->fetchOneAssoc(); $page->assign('stats', $stats); - $res = $globals->xdb->query("SELECT count(*) FROM auth_user_md5 WHERE date_ins > ". + $res = XDB::query("SELECT count(*) FROM auth_user_md5 WHERE date_ins > ". date('Ymd000000', strtotime('1 week ago'))); $page->assign('nbInsSem', $res->fetchOneCell()); - $res = $globals->xdb->query("SELECT count(*) FROM register_pending WHERE hash != 'INSCRIT'"); + $res = XDB::query("SELECT count(*) FROM register_pending WHERE hash != 'INSCRIT'"); $page->assign('nbInsEnCours', $res->fetchOneCell()); - $res = $globals->xdb->query("SELECT count(*) FROM register_marketing"); + $res = XDB::query("SELECT count(*) FROM register_marketing"); $page->assign('nbInsMarket', $res->fetchOneCell()); - $res = $globals->xdb->query("SELECT count(*) FROM register_mstats + $res = XDB::query("SELECT count(*) FROM register_mstats WHERE TO_DAYS(NOW()) - TO_DAYS(success) <= 7"); $page->assign('nbInsMarkOK', $res->fetchOneCell()); } @@ -90,7 +90,7 @@ class MarketingModule extends PLModule $page->assign('path', 'marketing/private/'.$uid); - $res = $globals->xdb->query("SELECT nom, prenom, promo, matricule + $res = XDB::query("SELECT nom, prenom, promo, matricule FROM auth_user_md5 WHERE user_id={?} AND perms='pending'", $uid); @@ -107,7 +107,7 @@ class MarketingModule extends PLModule } if ($action == 'del') { - $globals->xdb->execute('DELETE FROM register_marketing WHERE uid={?} AND email={?}', + XDB::execute('DELETE FROM register_marketing WHERE uid={?} AND email={?}', $uid, $value); } @@ -139,14 +139,14 @@ class MarketingModule extends PLModule } if ($action == 'add' && Post::has('email') && Post::has('type')) { - $globals->xdb->execute( + XDB::execute( "INSERT INTO register_marketing SET uid = {?}, sender = {?}, email = {?}, date = NOW(), type = {?}", $uid, Session::get('uid'), Post::get('email'), Post::get('type')); } - $res = $globals->xdb->iterator( + $res = XDB::iterator( "SELECT r.*, a.alias FROM register_marketing AS r INNER JOIN aliases AS a ON (r.sender=a.id AND a.type = 'a_vie') @@ -154,7 +154,7 @@ class MarketingModule extends PLModule ORDER BY date", $uid); $page->assign('addr', $res); - $res = $globals->xdb->query("SELECT date, relance FROM register_pending + $res = XDB::query("SELECT date, relance FROM register_pending WHERE uid = {?}", $uid); if (list($pending, $relance) = $res->fetchOneCell()) { $page->assign('pending', $pending); @@ -181,7 +181,7 @@ class MarketingModule extends PLModule WHERE u.promo = {?} AND u.deces = 0 AND u.perms='pending' GROUP BY u.user_id ORDER BY nom, prenom"; - $page->assign('nonins', $globals->xdb->iterator($sql, $promo)); + $page->assign('nonins', XDB::iterator($sql, $promo)); } function handler_public(&$page, $uid = null) @@ -194,7 +194,7 @@ class MarketingModule extends PLModule return PL_NOT_FOUND; } - $res = $globals->xdb->query("SELECT nom, prenom, promo FROM auth_user_md5 + $res = XDB::query("SELECT nom, prenom, promo FROM auth_user_md5 WHERE user_id={?} AND perms='pending'", $uid); if (list($nom, $prenom, $promo) = $res->fetchOneRow()) { @@ -206,7 +206,7 @@ class MarketingModule extends PLModule require_once('xorg.misc.inc.php'); $email = trim(Post::get('mail')); - $res = $globals->xdb->query('SELECT COUNT(*) FROM register_marketing + $res = XDB::query('SELECT COUNT(*) FROM register_marketing WHERE uid={?} AND email={?}', $uid, $email); if (!isvalid_email_redirection($email)) { @@ -215,7 +215,7 @@ class MarketingModule extends PLModule $page->assign('already', true); } else { $page->assign('ok', true); - $globals->xdb->execute( + XDB::execute( "INSERT INTO register_marketing (uid,sender,email,date,last,nb,type,hash) VALUES ({?}, {?}, {?}, NOW(), 0, 0, {?}, '')", $uid, Session::getInt('uid'), $email, Post::get('origine')); @@ -241,7 +241,7 @@ class MarketingModule extends PLModule INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie') WHERE u.date_ins > ".date("Ymd000000", strtotime ('1 week ago'))." ORDER BY u.$sort DESC"; - $page->assign('ins', $globals->xdb->iterator($sql)); + $page->assign('ins', XDB::iterator($sql)); } function handler_volontaire(&$page, $promo = null) @@ -250,7 +250,7 @@ class MarketingModule extends PLModule $page->changeTpl('marketing/volontaire.tpl'); - $res = $globals->xdb->query( + $res = XDB::query( "SELECT DISTINCT a.promo FROM register_marketing AS m @@ -266,7 +266,7 @@ class MarketingModule extends PLModule INNER JOIN auth_user_md5 AS a ON a.user_id = m.uid AND a.promo = {?} INNER JOIN aliases AS sa ON (m.sender = sa.id AND sa.type='a_vie') ORDER BY a.nom"; - $page->assign('addr', $globals->xdb->iterator($sql, $promo)); + $page->assign('addr', XDB::iterator($sql, $promo)); } } @@ -279,7 +279,7 @@ class MarketingModule extends PLModule if (Post::has('relancer')) { require_once 'marketing.inc.php'; - $res = $globals->xdb->query("SELECT COUNT(*) FROM auth_user_md5 WHERE deces=0"); + $res = XDB::query("SELECT COUNT(*) FROM auth_user_md5 WHERE deces=0"); $nbdix = $res->fetchOneCell(); $sent = Array(); @@ -296,7 +296,7 @@ class MarketingModule extends PLModule INNER JOIN auth_user_md5 AS u ON r. uid = u.user_id WHERE hash!='INSCRIT' ORDER BY date DESC"; - $page->assign('relance', $globals->xdb->iterator($sql)); + $page->assign('relance', XDB::iterator($sql)); } } diff --git a/modules/payment.php b/modules/payment.php index 8a761b1..dc8791e 100644 --- a/modules/payment.php +++ b/modules/payment.php @@ -111,7 +111,7 @@ class PaymentModule extends PLModule $pay->init($val, $meth); $pay->prepareform($pay); } else { - $res = $globals->xdb->iterator("SELECT timestamp, montant + $res = XDB::iterator("SELECT timestamp, montant FROM paiement.transactions WHERE uid = {?} AND ref = {?} ORDER BY timestamp DESC", @@ -151,7 +151,7 @@ class PaymentModule extends PLModule $montant = "$champ201 $champ202"; /* on extrait les informations sur l'utilisateur */ - $res = $globals->xdb->query(" + $res = XDB::query(" SELECT a.prenom,a.nom,a.promo,l.alias,FIND_IN_SET(a.flags,'femme') FROM auth_user_md5 AS a INNER JOIN aliases AS l ON (a.user_id=l.id AND type!='homonyme') @@ -167,7 +167,7 @@ class PaymentModule extends PLModule } echo ($ref = $matches[1]); - $res = $globals->xdb->query("SELECT mail,text,confirmation + $res = XDB::query("SELECT mail,text,confirmation FROM paiement.paiements WHERE id={?}", $ref); if (!list($conf_mail,$conf_title,$conf_text) = $res->fetchOneRow()) { cb_erreur("référence de commande inconnue"); @@ -175,7 +175,7 @@ class PaymentModule extends PLModule /* on extrait le code de retour */ if ($champ906 != "0000") { - $res = $globals->xdb->query("SELECT rcb.text,c.id,c.text + $res = XDB::query("SELECT rcb.text,c.id,c.text FROM paiement.codeRCB AS rcb LEFT JOIN paiement.codeC AS c ON rcb.codeC=c.id WHERE rcb.id='$champ906'"); @@ -187,7 +187,7 @@ class PaymentModule extends PLModule } /* on fait l'insertion en base de donnees */ - $globals->xdb->execute("INSERT INTO paiement.transactions (id,uid,ref,fullref,montant,cle) + XDB::execute("INSERT INTO paiement.transactions (id,uid,ref,fullref,montant,cle) VALUES ({?},{?},{?},{?},{?},{?})", $champ901, $uid, $ref, $champ200, $montant, $champ905); @@ -256,7 +256,7 @@ class PaymentModule extends PLModule } /* on extrait les informations sur l'utilisateur */ - $res = $globals->xdb->query(" + $res = XDB::query(" SELECT a.prenom,a.nom,a.promo,l.alias,FIND_IN_SET(a.flags,'femme') FROM auth_user_md5 AS a INNER JOIN aliases AS l ON (a.user_id=l.id AND type!='homonyme') @@ -271,14 +271,14 @@ class PaymentModule extends PLModule } $ref = $matches[1]; - $res = $globals->xdb->query("SELECT mail,text,confirmation + $res = XDB::query("SELECT mail,text,confirmation FROM paiement.paiements WHERE id={?}", $ref); if (!list($conf_mail,$conf_title,$conf_text) = $res->fetchOneRow()) { paypal_erreur("référence de commande inconnue"); } /* on fait l'insertion en base de donnees */ - $globals->xdb->execute("INSERT INTO paiement.transactions (id,uid,ref,fullref,montant,cle) + XDB::execute("INSERT INTO paiement.transactions (id,uid,ref,fullref,montant,cle) VALUES ({?},{?},{?},{?},{?},{?})", $no_transaction, $uid, $ref, $fullref, $montant, $clef); diff --git a/modules/platal.php b/modules/platal.php index 9e2f0f2..ce6e34f 100644 --- a/modules/platal.php +++ b/modules/platal.php @@ -92,12 +92,12 @@ class PlatalModule extends PLModule if ($state) { $_SESSION['core_rss_hash'] = rand_url_id(16); - $globals->xdb->execute('UPDATE auth_user_quick + XDB::execute('UPDATE auth_user_quick SET core_rss_hash={?} WHERE user_id={?}', Session::get('core_rss_hash'), Session::getInt('uid')); } else { - $globals->xdb->execute('UPDATE auth_user_quick + XDB::execute('UPDATE auth_user_quick SET core_rss_hash="" WHERE user_id={?}', Session::getInt('uid')); Session::kill('core_rss_hash'); @@ -114,7 +114,7 @@ class PlatalModule extends PLModule if (Env::has('mail_fmt')) { $fmt = Env::get('mail_fmt'); if ($fmt != 'texte') $fmt = 'html'; - $globals->xdb->execute("UPDATE auth_user_quick + XDB::execute("UPDATE auth_user_quick SET core_mail_fmt = '$fmt' WHERE user_id = {?}", Session::getInt('uid')); @@ -141,13 +141,13 @@ class PlatalModule extends PLModule $url = Env::get('url'); if (Env::get('submit') == 'Valider' and Env::has('url')) { - $globals->xdb->execute('UPDATE auth_user_quick + XDB::execute('UPDATE auth_user_quick SET redirecturl = {?} WHERE user_id = {?}', $url, Session::getInt('uid')); $log->log('carva_add', 'http://'.Env::get('url')); $page->trig("Redirection activée vers $url"); } elseif (Env::get('submit') == "Supprimer") { - $globals->xdb->execute("UPDATE auth_user_quick + XDB::execute("UPDATE auth_user_quick SET redirecturl = '' WHERE user_id = {?}", Session::getInt('uid')); @@ -156,7 +156,7 @@ class PlatalModule extends PLModule $page->trig('Redirection supprimée'); } - $res = $globals->xdb->query('SELECT redirecturl + $res = XDB::query('SELECT redirecturl FROM auth_user_quick WHERE user_id = {?}', Session::getInt('uid')); @@ -186,7 +186,7 @@ class PlatalModule extends PLModule $_SESSION['password'] = $password = Post::get('response2'); - $globals->xdb->execute('UPDATE auth_user_md5 + XDB::execute('UPDATE auth_user_md5 SET password={?} WHERE user_id={?}', $password, Session::getInt('uid')); @@ -221,18 +221,18 @@ class PlatalModule extends PLModule if (Env::get('op') == "Valider" && strlen($pass) >= 6 && Env::get('smtppass1') == Env::get('smtppass2')) { - $globals->xdb->execute('UPDATE auth_user_md5 SET smtppass = {?} + XDB::execute('UPDATE auth_user_md5 SET smtppass = {?} WHERE user_id = {?}', $pass, $uid); $page->trig('Mot de passe enregistré'); $log->log("passwd_ssl"); } elseif (Env::get('op') == "Supprimer") { - $globals->xdb->execute('UPDATE auth_user_md5 SET smtppass = "" + XDB::execute('UPDATE auth_user_md5 SET smtppass = "" WHERE user_id = {?}', $uid); $page->trig('Compte SMTP et NNTP supprimé'); $log->log("passwd_del"); } - $res = $globals->xdb->query("SELECT IF(smtppass != '', 'actif', '') + $res = XDB::query("SELECT IF(smtppass != '', 'actif', '') FROM auth_user_md5 WHERE user_id = {?}", $uid); $page->assign('actif', $res->fetchOneCell()); @@ -258,7 +258,7 @@ class PlatalModule extends PLModule // paragraphe rajouté : si la date de naissance dans la base n'existe pas, on l'update // avec celle fournie ici en espérant que c'est la bonne - $res = $globals->xdb->query( + $res = XDB::query( "SELECT user_id, naissance FROM auth_user_md5 AS u INNER JOIN aliases AS a ON (u.user_id=a.id AND type!='homonyme') @@ -269,8 +269,8 @@ class PlatalModule extends PLModule $page->assign('ok', true); $url = rand_url_id(); - $globals->xdb->execute('INSERT INTO perte_pass (certificat,uid,created) VALUES ({?},{?},NOW())', $url, $uid); - $res = $globals->xdb->query('SELECT email FROM emails WHERE uid = {?} AND NOT FIND_IN_SET("filter", flags)', $uid); + XDB::execute('INSERT INTO perte_pass (certificat,uid,created) VALUES ({?},{?},NOW())', $url, $uid); + $res = XDB::query('SELECT email FROM emails WHERE uid = {?} AND NOT FIND_IN_SET("filter", flags)', $uid); $mails = implode(', ', $res->fetchColumn()); require_once "diogenes/diogenes.hermes.inc.php"; @@ -305,10 +305,10 @@ Mail envoy { global $globals; - $globals->xdb->execute('DELETE FROM perte_pass + XDB::execute('DELETE FROM perte_pass WHERE DATE_SUB(NOW(), INTERVAL 380 MINUTE) > created'); - $res = $globals->xdb->query('SELECT uid FROM perte_pass WHERE certificat={?}', $certif); + $res = XDB::query('SELECT uid FROM perte_pass WHERE certificat={?}', $certif); $ligne = $res->fetchOneAssoc(); if (!$ligne) { $page->changeTpl('index.tpl'); @@ -319,10 +319,10 @@ Mail envoy if (Post::has('response2')) { $password = Post::get('response2'); $logger = new DiogenesCoreLogger($uid); - $globals->xdb->query('UPDATE auth_user_md5 SET password={?} + XDB::query('UPDATE auth_user_md5 SET password={?} WHERE user_id={?} AND perms IN("admin","user")', $password, $uid); - $globals->xdb->query('DELETE FROM perte_pass WHERE certificat={?}', $certif); + XDB::query('DELETE FROM perte_pass WHERE certificat={?}', $certif); $logger->log("passwd",""); $page->changeTpl('tmpPWD.success.tpl'); } else { @@ -343,7 +343,7 @@ Mail envoy $page->assign('xorg_title','Polytechnique.org - Skins'); if (Env::has('newskin')) { // formulaire soumis, traitons les données envoyées - $globals->xdb->execute('UPDATE auth_user_quick + XDB::execute('UPDATE auth_user_quick SET skin={?} WHERE user_id={?}', Env::getInt('newskin'), Session::getInt('uid')); @@ -355,7 +355,7 @@ Mail envoy LEFT JOIN auth_user_quick AS a ON s.id=a.skin WHERE skin_tpl != '' AND ext != '' GROUP BY id ORDER BY s.date DESC"; - $page->assign_by_ref('skins', $globals->xdb->iterator($sql)); + $page->assign_by_ref('skins', XDB::iterator($sql)); } function handler_exit(&$page, $level = null) @@ -410,7 +410,7 @@ Mail envoy $uid = init_rss('rss.tpl', $user, $hash); - $rss = $globals->xdb->iterator( + $rss = XDB::iterator( 'SELECT e.id, e.titre, e.texte, e.creation_date FROM auth_user_md5 AS u INNER JOIN evenements AS e ON ( (e.promo_min = 0 || e.promo_min <= u.promo) diff --git a/modules/profile.php b/modules/profile.php index fb92fd9..7c1d733 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -55,14 +55,14 @@ class ProfileModule extends PLModule $where = ( $this->promo > 0 ? "WHERE promo='{$this->promo}'" : "" ); - $res = $globals->xdb->query( + $res = XDB::query( "SELECT COUNT(*) FROM auth_user_md5 AS u RIGHT JOIN photo AS p ON u.user_id=p.uid $where"); $pnb = $res->fetchOneCell(); - $res = $globals->xdb->query( + $res = XDB::query( "SELECT promo, user_id, a.alias AS forlife, IF (nom_usage='', nom, nom_usage) AS nom, prenom FROM photo AS p @@ -82,7 +82,7 @@ class ProfileModule extends PLModule global $globals; - $res = $globals->xdb->query("SELECT id, pub FROM aliases + $res = XDB::query("SELECT id, pub FROM aliases LEFT JOIN photo ON(id = uid) WHERE alias = {?}", $x); list($uid, $photo_pub) = $res->fetchOneRow(); @@ -93,7 +93,7 @@ class ProfileModule extends PLModule Header('Content-type: image/'.$myphoto->mimetype); echo $myphoto->data; } else { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT attachmime, attach FROM photo WHERE uid={?}", $uid); @@ -140,18 +140,18 @@ class ProfileModule extends PLModule $myphoto->clean(); } } elseif (Env::get('suppr')) { - $globals->xdb->execute('DELETE FROM photo WHERE uid = {?}', + XDB::execute('DELETE FROM photo WHERE uid = {?}', Session::getInt('uid')); - $globals->xdb->execute('DELETE FROM requests + XDB::execute('DELETE FROM requests WHERE user_id = {?} AND type="photo"', Session::getInt('uid')); } elseif (Env::get('cancel')) { - $sql = $globals->xdb->query('DELETE FROM requests + $sql = XDB::query('DELETE FROM requests WHERE user_id={?} AND type="photo"', Session::getInt('uid')); } - $sql = $globals->xdb->query('SELECT COUNT(*) FROM requests + $sql = XDB::query('SELECT COUNT(*) FROM requests WHERE user_id={?} AND type="photo"', Session::getInt('uid')); $page->assign('submited', $sql->fetchOneCell()); @@ -175,7 +175,7 @@ class ProfileModule extends PLModule if (logged() && Env::get('view') == 'ax') $view = 'ax'; if (is_numeric($x)) { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT alias FROM aliases AS a INNER JOIN auth_user_md5 AS u ON (a.id=u.user_id AND a.type='a_vie') @@ -224,7 +224,7 @@ class ProfileModule extends PLModule $page->assign_by_ref('x', $user); $page->assign('photo_url', $photo); // alias virtual - $res = $globals->xdb->query( + $res = XDB::query( "SELECT alias FROM virtual INNER JOIN virtual_redirect USING(vid) @@ -253,7 +253,7 @@ class ProfileModule extends PLModule require_once 'synchro_ax.inc.php'; if (Post::has('register_from_ax_question')) { - $globals->xdb->query('UPDATE auth_user_quick + XDB::query('UPDATE auth_user_quick SET profile_from_ax = 1 WHERE user_id = {?}', Session::getInt('uid')); @@ -270,7 +270,7 @@ class ProfileModule extends PLModule // pour tous les tabs, la date de naissance pour verifier // quelle est bien rentree et la date. - $res = $globals->xdb->query( + $res = XDB::query( "SELECT naissance, DATE_FORMAT(date, '%d.%m.%Y') FROM auth_user_md5 WHERE user_id={?}", Session::getInt('uid')); @@ -291,7 +291,7 @@ class ProfileModule extends PLModule $birth = sprintf("%s-%s-%s", substr(Env::get('birth'), 4, 4), substr(Env::get('birth'), 2, 2), substr(Env::get('birth'), 0, 2)); - $globals->xdb->execute("UPDATE auth_user_md5 + XDB::execute("UPDATE auth_user_md5 SET naissance={?} WHERE user_id={?}", $birth, Session::getInt('uid')); @@ -321,7 +321,7 @@ class ProfileModule extends PLModule /* on sauvegarde les changements dans user_changes : * on a juste besoin d'insérer le user_id de la personne dans la table */ - $globals->xdb->execute('REPLACE INTO user_changes SET user_id={?}', + XDB::execute('REPLACE INTO user_changes SET user_id={?}', Session::getInt('uid')); if (!Session::has('suid')) { @@ -361,7 +361,7 @@ class ProfileModule extends PLModule require_once 'validations.inc.php'; require_once 'xorg.misc.inc.php'; - $res = $globals->xdb->query( + $res = XDB::query( "SELECT u.promo, u.promo_sortie FROM auth_user_md5 AS u WHERE user_id={?}", Session::getInt('uid')); @@ -386,7 +386,7 @@ class ProfileModule extends PLModule $page->trig('Tu appartiens déjà à la promotion correspondante à cette année de sortie.'); } elseif ($promo_sortie == $promo + 3) { - $globals->xdb->execute( + XDB::execute( "UPDATE auth_user_md5 set promo_sortie={?} WHERE user_id={?}", $promo_sortie, Session::getInt('uid')); $page->trig('Ton statut "orange" a été supprimé.'); @@ -417,7 +417,7 @@ class ProfileModule extends PLModule $page->changeTpl('fiche_referent.tpl'); $page->assign('simple', true); - $res = $globals->xdb->query( + $res = XDB::query( "SELECT prenom, nom, user_id, promo, cv, a.alias AS bestalias FROM auth_user_md5 AS u INNER JOIN aliases AS a ON (u.user_id=a.id @@ -442,12 +442,12 @@ class ProfileModule extends PLModule ///// recuperations infos referent //expertise - $res = $globals->xdb->query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id); + $res = XDB::query("SELECT expertise FROM mentor WHERE uid = {?}", $user_id); $page->assign('expertise', $res->fetchOneCell()); //secteurs $secteurs = $ss_secteurs = Array(); - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT s.label, ss.label FROM mentor_secteurs AS m LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id) @@ -461,7 +461,7 @@ class ProfileModule extends PLModule $page->assign_by_ref('ss_secteurs', $ss_secteurs); //pays - $res = $globals->xdb->query( + $res = XDB::query( "SELECT gp.pays FROM mentor_pays AS m LEFT JOIN geoloc_pays AS gp ON(m.pid = gp.a2) @@ -490,7 +490,7 @@ class ProfileModule extends PLModule $page->assign('ss_secteur_sel', $ss_secteur_sel); //recuperation des noms de secteurs - $res = $globals->xdb->iterRow("SELECT id, label FROM emploi_secteur"); + $res = XDB::iterRow("SELECT id, label FROM emploi_secteur"); $secteurs[''] = ''; while (list($tmp_id, $tmp_label) = $res->next()) { $secteurs[$tmp_id] = $tmp_label; @@ -500,7 +500,7 @@ class ProfileModule extends PLModule //on recupere les sous-secteurs si necessaire $ss_secteurs[''] = ''; if (!empty($secteur_sel)) { - $res = $globals->xdb->iterRow("SELECT id, label FROM emploi_ss_secteur + $res = XDB::iterRow("SELECT id, label FROM emploi_ss_secteur WHERE secteur = {?}", $secteur_sel); while (list($tmp_id, $tmp_label) = $res->next()) { $ss_secteurs[$tmp_id] = $tmp_label; @@ -509,7 +509,7 @@ class ProfileModule extends PLModule $page->assign_by_ref('ss_secteurs', $ss_secteurs); //recuperation des noms de pays - $res = $globals->xdb->iterRow("SELECT a2, pays FROM geoloc_pays + $res = XDB::iterRow("SELECT a2, pays FROM geoloc_pays WHERE pays <> '' ORDER BY pays"); $pays['00'] = ''; while (list($tmp_id, $tmp_label) = $res->next()) { @@ -518,7 +518,7 @@ class ProfileModule extends PLModule $page->assign_by_ref('pays', $pays); // nb de mentors - $res = $globals->xdb->query("SELECT count(*) FROM mentor"); + $res = XDB::query("SELECT count(*) FROM mentor"); $page->assign('mentors_number', $res->fetchOneCell()); if (!Env::has('Chercher')) { @@ -556,7 +556,7 @@ class ProfileModule extends PLModule WHERE $where GROUP BY uid ORDER BY RAND({?})"; - $res = $globals->xdb->iterator($sql, Session::getInt('uid')); + $res = XDB::iterator($sql, Session::getInt('uid')); if ($res->total() == 0) { $page->assign('recherche_trop_large', true); @@ -594,7 +594,7 @@ class ProfileModule extends PLModule require_once 'validations.inc.php'; require_once 'xorg.misc.inc.php'; - $res = $globals->xdb->query( + $res = XDB::query( "SELECT u.nom, u.nom_usage, u.flags, e.alias FROM auth_user_md5 AS u LEFT JOIN aliases AS e ON(u.user_id = e.id @@ -685,7 +685,7 @@ class ProfileModule extends PLModule $user = get_user_details($login); // alias virtual - $res = $globals->xdb->query( + $res = XDB::query( "SELECT alias FROM virtual INNER JOIN virtual_redirect USING(vid) diff --git a/modules/register.php b/modules/register.php index a8ee89d..b14f2b4 100644 --- a/modules/register.php +++ b/modules/register.php @@ -49,7 +49,7 @@ class RegisterModule extends PLModule } if ($hash) { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT m.uid, u.promo, u.nom, u.prenom, u.matricule FROM register_marketing AS m INNER JOIN auth_user_md5 AS u ON u.user_id = m.uid @@ -62,7 +62,7 @@ class RegisterModule extends PLModule $sub_state['prenom'] = $prenom; $sub_state['ourmat'] = $ourmat; - $globals->xdb->execute( + XDB::execute( "REPLACE INTO register_mstats (uid,sender,success) SELECT m.uid, m.sender, 0 FROM register_marketing AS m @@ -169,7 +169,7 @@ class RegisterModule extends PLModule require_once('user.func.inc.php'); if ($hash) { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT r.uid, r.forlife, r.bestalias, r.mailorg2, r.password, r.email, r.naissance, u.nom, u.prenom, u.promo, u.flags @@ -201,19 +201,19 @@ class RegisterModule extends PLModule /****************** REALLY CREATE ACCOUNT ******************/ /***********************************************************/ - $globals->xdb->execute('UPDATE auth_user_md5 + XDB::execute('UPDATE auth_user_md5 SET password={?}, perms="user", date=NOW(), naissance={?}, date_ins = NOW() WHERE user_id={?}', $password, $naissance, $uid); - $globals->xdb->execute('REPLACE INTO auth_user_quick (user_id) VALUES ({?})', $uid); - $globals->xdb->execute('INSERT INTO aliases (id,alias,type) + XDB::execute('REPLACE INTO auth_user_quick (user_id) VALUES ({?})', $uid); + XDB::execute('INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, "a_vie")', $uid, $forlife); - $globals->xdb->execute('INSERT INTO aliases (id,alias,type,flags) + XDB::execute('INSERT INTO aliases (id,alias,type,flags) VALUES ({?}, {?}, "alias", "bestalias")', $uid, $bestalias); if ($mailorg2) { - $globals->xdb->execute('INSERT INTO aliases (id,alias,type) + XDB::execute('INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, "alias")', $uid, $mailorg2); } @@ -226,7 +226,7 @@ class RegisterModule extends PLModule $logger = new DiogenesCoreLogger($uid); $logger->log('inscription', $email); - $globals->xdb->execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid); + XDB::execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid); $globals->hook->subscribe($forlife, $uid, $promo, $password); @@ -242,7 +242,7 @@ class RegisterModule extends PLModule /***********************************************************/ /************* envoi d'un mail au démarcheur ***************/ /***********************************************************/ - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT DISTINCT sa.alias, IF(s.nom_usage,s.nom_usage,s.nom) AS nom, s.prenom, s.flags AS femme FROM register_marketing AS m @@ -250,7 +250,7 @@ class RegisterModule extends PLModule INNER JOIN aliases AS sa ON ( sa.id = m.sender AND FIND_IN_SET('bestalias', sa.flags) ) WHERE m.uid = {?}", $uid); - $globals->xdb->execute("UPDATE register_mstats SET success=NOW() WHERE uid={?}", $uid); + XDB::execute("UPDATE register_mstats SET success=NOW() WHERE uid={?}", $uid); while (list($salias, $snom, $sprenom, $sfemme) = $res->next()) { require_once('diogenes/diogenes.hermes.inc.php'); @@ -269,7 +269,7 @@ class RegisterModule extends PLModule $mymail->send(); } - $globals->xdb->execute("DELETE FROM register_marketing WHERE uid = {?}", $uid); + XDB::execute("DELETE FROM register_marketing WHERE uid = {?}", $uid); redirect($globals->baseurl.'/register/success'); $page->assign('uid', $uid); @@ -284,7 +284,7 @@ class RegisterModule extends PLModule if (Env::has('response2')) { $_SESSION['password'] = $password = Post::get('response2'); - $globals->xdb->execute('UPDATE auth_user_md5 SET password={?} + XDB::execute('UPDATE auth_user_md5 SET password={?} WHERE user_id={?}', $password, Session::getInt('uid')); diff --git a/modules/search.php b/modules/search.php index aab1117..1fcd390 100644 --- a/modules/search.php +++ b/modules/search.php @@ -63,8 +63,8 @@ class SearchModule extends PLModule 'u.promo DESC, NomSortKey, prenom'))).' LIMIT '.$offset * $globals->search->per_page.',' .$globals->search->per_page; - $list = $globals->xdb->iterator($sql); - $res = $globals->xdb->query("SELECT FOUND_ROWS()"); + $list = XDB::iterator($sql); + $res = XDB::query("SELECT FOUND_ROWS()"); $nb_tot = $res->fetchOneCell(); return array($list, $nb_tot); } @@ -75,21 +75,21 @@ class SearchModule extends PLModule $page->assign('formulaire',1); $page->assign('choix_nats', - $globals->xdb->iterator('SELECT a2 AS id,IF(nat=\'\',pays,nat) AS text + XDB::iterator('SELECT a2 AS id,IF(nat=\'\',pays,nat) AS text FROM geoloc_pays ORDER BY text')); $page->assign('choix_postes', - $globals->xdb->iterator('SELECT id,fonction_fr FROM fonctions_def + XDB::iterator('SELECT id,fonction_fr FROM fonctions_def ORDER BY fonction_fr')); $page->assign('choix_binets', - $globals->xdb->iterator('SELECT id,text FROM binets_def ORDER BY text')); + XDB::iterator('SELECT id,text FROM binets_def ORDER BY text')); $page->assign('choix_groupesx', - $globals->xdb->iterator('SELECT id,text FROM groupesx_def ORDER BY text')); + XDB::iterator('SELECT id,text FROM groupesx_def ORDER BY text')); $page->assign('choix_sections', - $globals->xdb->iterator('SELECT id,text FROM sections ORDER BY text')); + XDB::iterator('SELECT id,text FROM sections ORDER BY text')); $page->assign('choix_schools', - $globals->xdb->iterator('SELECT id,text FROM applis_def ORDER BY text')); + XDB::iterator('SELECT id,text FROM applis_def ORDER BY text')); $page->assign('choix_secteurs', - $globals->xdb->iterator('SELECT id,label FROM emploi_secteur ORDER BY label')); + XDB::iterator('SELECT id,label FROM emploi_secteur ORDER BY label')); if (Env::has('school')) { $sql = 'SELECT type FROM applis_def WHERE id='.Env::getInt('school'); @@ -97,7 +97,7 @@ class SearchModule extends PLModule $sql = 'DESCRIBE applis_def type'; } - $res = $globals->xdb->query($sql); + $res = XDB::query($sql); $row = $res->fetchOneRow(); if (Env::has('school')) { $types = $row[0]; @@ -143,8 +143,8 @@ class SearchModule extends PLModule .implode(',',array_filter(array($fields->get_order_statement(), 'promo DESC, NomSortKey, prenom'))).' LIMIT '.($offset * $limit).','.$limit; - $liste = $globals->xdb->iterator($sql); - $res = $globals->xdb->query("SELECT FOUND_ROWS()"); + $liste = XDB::iterator($sql); + $res = XDB::query("SELECT FOUND_ROWS()"); $nb_tot = $res->fetchOneCell(); return Array($liste, $nb_tot); } diff --git a/modules/stats.php b/modules/stats.php index 1143932..c12eb97 100644 --- a/modules/stats.php +++ b/modules/stats.php @@ -65,7 +65,7 @@ class StatsModule extends PLModule define('DUREEJOUR',24*3600); //recupere le nombre d'inscriptions par jour sur la plage concernée - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT IF( date_ins>DATE_SUB(NOW(),INTERVAL $jours DAY), TO_DAYS(date_ins)-TO_DAYS(NOW()), ".(-($jours+1)).") AS jour, @@ -132,7 +132,7 @@ EOF2; $depart = 1920; //recupere le nombre d'inscriptions par jour sur la plage concernée - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT promo, SUM(perms IN ('admin', 'user')) / COUNT(*) * 100 FROM auth_user_md5 WHERE promo >= $depart AND deces = 0 @@ -179,7 +179,7 @@ EOF2; //nombre de jours sur le graph $jours = 365; define('DUREEJOUR',24*3600); - $res = $globals->xdb->query("SELECT min(TO_DAYS(date_ins)-TO_DAYS(now())) + $res = XDB::query("SELECT min(TO_DAYS(date_ins)-TO_DAYS(now())) FROM auth_user_md5 WHERE promo = {?} AND perms IN ('admin', 'user')", @@ -187,7 +187,7 @@ EOF2; $jours = -$res->fetchOneCell(); //recupere le nombre d'inscriptions par jour sur la plage concernée - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT IF( date_ins>DATE_SUB(NOW(),INTERVAL $jours DAY), TO_DAYS(date_ins)-TO_DAYS(NOW()), ".(-($jours+1)).") AS jour, @@ -252,7 +252,7 @@ EOF2; $page->changeTpl('stats/nb_by_promo.tpl'); - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( "SELECT promo,COUNT(*) FROM auth_user_md5 WHERE promo > 1900 AND perms IN ('admin','user') @@ -281,7 +281,7 @@ EOF2; $page->changeTpl('stats/coupure.tpl'); if (!is_null($cp_id)) { - $res = $globals->xdb->query("SELECT UNIX_TIMESTAMP(debut) AS debut, + $res = XDB::query("SELECT UNIX_TIMESTAMP(debut) AS debut, TIME_FORMAT(duree,'%kh%i') AS duree, resume, description, services FROM coupures @@ -296,7 +296,7 @@ EOF2; $beginning_date = date("Ymd", time() - 3600*24*21) . "000000"; $sql = "SELECT id, UNIX_TIMESTAMP(debut) AS debut, resume, services FROM coupures where debut > '$beginning_date' order by debut desc"; - $page->assign('coupures', $globals->xdb->iterator($sql)); + $page->assign('coupures', XDB::iterator($sql)); } } } diff --git a/modules/trezo.php b/modules/trezo.php index b0fd027..615554d 100644 --- a/modules/trezo.php +++ b/modules/trezo.php @@ -63,7 +63,7 @@ class TrezoModule extends PLModule $page->assign('mon_sel', $mon_sel); $page->assign_by_ref('month_arr', $trim_fr); - $page->assign('ops', $globals->xdb->iterator( + $page->assign('ops', XDB::iterator( "SELECT date, label, credit, debit FROM money_trezo WHERE date >= {?} and date <= {?} order by date", $from_date, $to_date)); @@ -96,7 +96,7 @@ class TrezoModule extends PLModule switch($action) { case "edit": if ($op_id) { - $res = $globals->xdb->query("SELECT date,label,credit,debit FROM money_trezo WHERE id={?}", $op_id); + $res = XDB::query("SELECT date,label,credit,debit FROM money_trezo WHERE id={?}", $op_id); list($op_date,$op_label,$op_credit,$op_debit) = $res->fetchOneRow(); } break; @@ -115,12 +115,12 @@ class TrezoModule extends PLModule if ($op_debit) { $sql .= ',debit='.$op_debit; } if ($op_id) { $sql .= ",id='$op_id'"; } - $globals->xdb->execute($sql); + XDB::execute($sql); break; case "del": if ($op_id) { - $globals->xdb->execute("DELETE FROM money_trezo WHERE id={?}", $op_id); + XDB::execute("DELETE FROM money_trezo WHERE id={?}", $op_id); } break; } @@ -137,7 +137,7 @@ class TrezoModule extends PLModule $page->assign('from_solde', solde_until($from_date)); $page->assign('to_solde', solde_until($to_date)); $page->assign('month_arr', $mois_fr); - $page->assign('ops', $globals->xdb->iterator( + $page->assign('ops', XDB::iterator( "SELECT id, date, label, credit, debit FROM money_trezo WHERE date >= {?} and date <= {?} ORDER BY date", $from_date, $to_date)); diff --git a/modules/xnet.php b/modules/xnet.php index 7b7c0a9..565c7f3 100644 --- a/modules/xnet.php +++ b/modules/xnet.php @@ -97,18 +97,18 @@ class XnetModule extends PLModule $page->useMenu(); if (Get::has('del')) { - $res = $globals->xdb->query('SELECT id, nom, mail_domain + $res = XDB::query('SELECT id, nom, mail_domain FROM groupex.asso WHERE diminutif={?}', Get::get('del')); list($id, $nom, $domain) = $res->fetchOneRow(); $page->assign('nom', $nom); if ($id && Post::has('del')) { - $globals->xdb->query('DELETE FROM groupex.membres WHERE asso_id={?}', $id); + XDB::query('DELETE FROM groupex.membres WHERE asso_id={?}', $id); $page->trig('membres supprimés'); if ($domain) { - $globals->xdb->query('DELETE FROM virtual_domains WHERE domain={?}', $domain); - $globals->xdb->query('DELETE FROM virtual, virtual_redirect + XDB::query('DELETE FROM virtual_domains WHERE domain={?}', $domain); + XDB::query('DELETE FROM virtual, virtual_redirect USING virtual INNER JOIN virtual_redirect USING (vid) WHERE alias LIKE {?}', '%@'.$domain); $page->trig('suppression des alias mails'); @@ -123,7 +123,7 @@ class XnetModule extends PLModule } } - $globals->xdb->query('DELETE FROM groupex.asso WHERE id={?}', $id); + XDB::query('DELETE FROM groupex.asso WHERE id={?}', $id); $page->trig("Groupe $nom supprimé"); Get::kill('del'); } @@ -133,12 +133,12 @@ class XnetModule extends PLModule } if (Post::has('diminutif')) { - $globals->xdb->query('INSERT INTO groupex.asso (id,diminutif) + XDB::query('INSERT INTO groupex.asso (id,diminutif) VALUES(NULL,{?})', Post::get('diminutif')); redirect(Post::get('diminutif').'/edit'); } - $res = $globals->xdb->query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM'); + $res = XDB::query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM'); $page->assign('assos', $res->fetchAllAssoc()); } @@ -150,7 +150,7 @@ class XnetModule extends PLModule $page->setType('plan'); - $res = $globals->xdb->iterator( + $res = XDB::iterator( 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom FROM groupex.dom INNER JOIN groupex.asso ON dom.id = asso.dom @@ -160,7 +160,7 @@ class XnetModule extends PLModule while ($tmp = $res->next()) { $groupesx[$tmp['id']][] = $tmp; } $page->assign('groupesx', $groupesx); - $res = $globals->xdb->iterator( + $res = XDB::iterator( 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom FROM groupex.dom INNER JOIN groupex.asso ON dom.id = asso.dom @@ -170,14 +170,14 @@ class XnetModule extends PLModule while ($tmp = $res->next()) { $binets[$tmp['id']][] = $tmp; } $page->assign('binets', $binets); - $res = $globals->xdb->iterator( + $res = XDB::iterator( 'SELECT asso.diminutif, asso.nom FROM groupex.asso WHERE cat LIKE "%Promotions%" ORDER BY diminutif'); $page->assign('promos', $res); - $res = $globals->xdb->iterator( + $res = XDB::iterator( 'SELECT asso.diminutif, asso.nom FROM groupex.asso WHERE FIND_IN_SET("Institutions", cat) @@ -204,16 +204,16 @@ class XnetModule extends PLModule $page->assign('cat', $cat); $page->assign('dom', $dom); - $res = $globals->xdb->query("SELECT id,nom FROM groupex.dom + $res = XDB::query("SELECT id,nom FROM groupex.dom WHERE FIND_IN_SET({?}, cat) ORDER BY nom", $cat); $doms = $res->fetchAllAssoc(); $page->assign('doms', $doms); if (empty($doms)) { - $res = $globals->xdb->iterator("SELECT diminutif, nom FROM groupex.asso + $res = XDB::iterator("SELECT diminutif, nom FROM groupex.asso WHERE FIND_IN_SET({?}, cat) ORDER BY nom", $cat); } elseif (!is_null($dom)) { - $res = $globals->xdb->iterator("SELECT diminutif, nom FROM groupex.asso + $res = XDB::iterator("SELECT diminutif, nom FROM groupex.asso WHERE FIND_IN_SET({?}, cat) AND dom={?} ORDER BY nom", $cat, $dom); } else { diff --git a/modules/xnetevents.php b/modules/xnetevents.php index 2580e7a..b555285 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -47,7 +47,7 @@ class XnetEventsModule extends PLModule $eid = Post::get('del'); - $res = $globals->xdb->query("SELECT asso_id, short_name FROM groupex.evenements + $res = XDB::query("SELECT asso_id, short_name FROM groupex.evenements WHERE eid = {?} AND asso_id = {?}", $eid, $globals->asso('id')); @@ -58,36 +58,36 @@ class XnetEventsModule extends PLModule // deletes the event mailing aliases if ($tmp[1]) { - $globals->xdb->execute( + XDB::execute( "DELETE FROM virtual WHERE type = 'evt' AND alias LIKE {?}", $tmp[1].'-absents@%'); - $globals->xdb->execute( + XDB::execute( "DELETE FROM virtual WHERE type = 'evt' AND alias LIKE {?}", $tmp[1].'-participants@%'); } // deletes the event items - $globals->xdb->execute("DELETE FROM groupex.evenements_items WHERE eid = {?}", $eid); + XDB::execute("DELETE FROM groupex.evenements_items WHERE eid = {?}", $eid); // deletes the event participants - $globals->xdb->execute("DELETE FROM groupex.evenements_participants + XDB::execute("DELETE FROM groupex.evenements_participants WHERE eid = {?}", $eid); // deletes the event - $globals->xdb->execute("DELETE FROM groupex.evenements + XDB::execute("DELETE FROM groupex.evenements WHERE eid = {?} AND asso_id = {?}", $eid, $globals->asso('id')); // delete the requests for payments require_once 'validations.inc.php'; - $globals->xdb->execute("DELETE FROM requests + XDB::execute("DELETE FROM requests WHERE type = 'paiements' AND data LIKE {?}", PayReq::same_event($eid, $globals->asso('id'))); } $page->assign('admin', may_update()); - $evenements = $globals->xdb->iterator( + $evenements = XDB::iterator( "SELECT e.*, LEFT(10, e.debut) AS debut_day, LEFT(10, e.fin) AS fin_day, IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10), 1) AS inscr_open, e.deadline_inscription, @@ -104,7 +104,7 @@ class XnetEventsModule extends PLModule $evts = array(); while ($e = $evenements->next()) { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT titre, details, montant, ei.item_id, nb FROM groupex.evenements_items AS ei LEFT JOIN groupex.evenements_participants AS ep @@ -118,7 +118,7 @@ class XnetEventsModule extends PLModule $e['topay'] += $m['nb'] * $m['montant']; } - $query = $globals->xdb->query( + $query = XDB::query( "SELECT montant FROM {$globals->money->mpay_tprefix}transactions AS t WHERE ref = {?} AND uid = {?}", $e['paiement_id'], Session::get('uid')); @@ -191,13 +191,13 @@ class XnetEventsModule extends PLModule // update actual inscriptions foreach ($subs as $j => $nb) { if ($nb > 0) { - $globals->xdb->execute( + XDB::execute( "REPLACE INTO groupex.evenements_participants VALUES ({?}, {?}, {?}, {?}, {?})", $eid, Session::getInt('uid'), $j, $nb, $evt['paid']); $page->assign('updated', true); } else { - $globals->xdb->execute( + XDB::execute( "DELETE FROM groupex.evenements_participants WHERE eid = {?} AND uid = {?} AND item_id = {?}", $eid, Session::getInt("uid"), $j); @@ -246,7 +246,7 @@ class XnetEventsModule extends PLModule // check the event is in our group if (!is_null($eid)) { - $res = $globals->xdb->query("SELECT short_name, asso_id + $res = XDB::query("SELECT short_name, asso_id FROM groupex.evenements WHERE eid = {?}", $eid); $infos = $res->fetchOneAssoc(); @@ -294,7 +294,7 @@ class XnetEventsModule extends PLModule } // Store the modifications in the database - $globals->xdb->execute('REPLACE INTO groupex.evenements + XDB::execute('REPLACE INTO groupex.evenements SET eid={?}, asso_id={?}, organisateur_uid={?}, intitule={?}, paiement_id = {?}, descriptif = {?}, debut = {?}, fin = {?}, show_participants = {?}, short_name = {?}, @@ -319,13 +319,13 @@ class XnetEventsModule extends PLModule $montant = strtr(Post::get('montant'.$i), ',', '.'); $money_defaut += (float)$montant; - $globals->xdb->execute(" + XDB::execute(" REPLACE INTO groupex.evenements_items VALUES ({?}, {?}, {?}, {?}, {?})", $eid, $i, Post::get('titre'.$i), Post::get('details'.$i), $montant); } else { - $globals->xdb->execute("DELETE FROM groupex.evenements_items + XDB::execute("DELETE FROM groupex.evenements_items WHERE eid = {?} AND item_id = {?}", $eid, $i); } } @@ -343,7 +343,7 @@ class XnetEventsModule extends PLModule // events with no sub-event: add a sub-event with no name if ($nb_moments == 0) { - $globals->xdb->execute("INSERT INTO groupex.evenements_items + XDB::execute("INSERT INTO groupex.evenements_items VALUES ({?}, {?}, '', '', 0)", $eid, 1); } @@ -354,7 +354,7 @@ class XnetEventsModule extends PLModule } // get a list of all the payment for this asso - $res = $globals->xdb->iterator("SELECT id, text + $res = XDB::iterator("SELECT id, text FROM {$globals->money->mpay_tprefix}paiements WHERE asso_id = {?}", $globals->asso('id')); $paiements = array(); @@ -364,7 +364,7 @@ class XnetEventsModule extends PLModule // when modifying an old event retreive the old datas if ($eid) { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT eid, intitule, descriptif, debut, fin, show_participants, paiement_id, short_name, deadline_inscription, noinvite @@ -373,7 +373,7 @@ class XnetEventsModule extends PLModule $evt = $res->fetchOneAssoc(); // find out if there is already a request for a payment for this event require_once 'validations.inc.php'; - $res = $globals->xdb->query("SELECT stamp FROM requests + $res = XDB::query("SELECT stamp FROM requests WHERE type = 'paiements' AND data LIKE {?}", PayReq::same_event($eid, $globals->asso('id'))); $stamp = $res->fetchOneCell(); @@ -383,7 +383,7 @@ class XnetEventsModule extends PLModule } $page->assign('evt', $evt); // get all the different moments infos - $res = $globals->xdb->iterator( + $res = XDB::iterator( "SELECT item_id, titre, details, montant FROM groupex.evenements_items AS ei INNER JOIN groupex.evenements AS e ON(e.eid = ei.eid) @@ -422,7 +422,7 @@ class XnetEventsModule extends PLModule // change the price paid by a participant if (Env::get('adm') == 'prix' && $member) { - $globals->xdb->execute("UPDATE groupex.evenements_participants + XDB::execute("UPDATE groupex.evenements_participants SET paid = IF(paid + {?} > 0, paid + {?}, 0) WHERE uid = {?} AND eid = {?}", strtr(Env::get('montant'), ',', '.'), @@ -432,7 +432,7 @@ class XnetEventsModule extends PLModule // change the number of personns coming with a participant if (Env::get('adm') == 'nbs' && $member) { - $res = $globals->xdb->query("SELECT paid + $res = XDB::query("SELECT paid FROM groupex.evenements_participants WHERE uid = {?} AND eid = {?}", $member['uid'], $eid); @@ -444,17 +444,17 @@ class XnetEventsModule extends PLModule $nb = max(intval($nb), 0); if ($nb) { - $globals->xdb->execute("REPLACE INTO groupex.evenements_participants + XDB::execute("REPLACE INTO groupex.evenements_participants VALUES ({?}, {?}, {?}, {?}, {?})", $eid, $member['uid'], $id, $nb, $paid); } else { - $globals->xdb->execute("DELETE FROM groupex.evenements_participants + XDB::execute("DELETE FROM groupex.evenements_participants WHERE uid = {?} AND eid = {?} AND item_id = {?}", $member['uid'], $eid, $id); } } - $res = $globals->xdb->query("SELECT uid FROM groupex.evenements_participants + $res = XDB::query("SELECT uid FROM groupex.evenements_participants WHERE uid = {?} AND eid = {?}", $member['uid'], $eid); $u = $res->fetchOneCell(); @@ -474,7 +474,7 @@ class XnetEventsModule extends PLModule $tri = (Env::get('order') == 'alpha' ? 'promo, nom, prenom' : 'nom, prenom, promo'); $whereitemid = is_null($item_id) ? '' : "AND ep.item_id = $item_id"; - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( 'SELECT UPPER(SUBSTRING(IF(u.nom IS NULL, m.nom, IF(u.nom_usage<>"", u.nom_usage, u.nom)), 1, 1)), COUNT(DISTINCT ep.uid) @@ -515,7 +515,7 @@ class XnetEventsModule extends PLModule } if ($evt['paiement_id']) { - $res = $globals->xdb->iterator( + $res = XDB::iterator( "SELECT IF(u.nom_usage<>'', u.nom_usage, u.nom) AS nom, u.prenom, u.promo, a.alias AS email, t.montant FROM {$globals->money->mpay_tprefix}transactions AS t diff --git a/modules/xnetevents/xnetevents.inc.php b/modules/xnetevents/xnetevents.inc.php index 884d7aa..cc19ed7 100644 --- a/modules/xnetevents/xnetevents.inc.php +++ b/modules/xnetevents/xnetevents.inc.php @@ -24,7 +24,7 @@ function get_event_detail($eid, $item_id = false) { global $globals; - $res = $globals->xdb->query( + $res = XDB::query( "SELECT SUM(nb) AS nb_tot, e.*, IF(e.deadline_inscription, e.deadline_inscription >= LEFT(NOW(), 10), 1) AS inscr_open, @@ -54,7 +54,7 @@ function get_event_detail($eid, $item_id = false) // smart calculation of the total number if (!$item_id) { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT MAX(nb) FROM groupex.evenements AS e INNER JOIN groupex.evenements_items AS ei ON (e.eid = ei.eid) @@ -67,7 +67,7 @@ function get_event_detail($eid, $item_id = false) $evt['item_id'] = 0; } - $res = $globals->xdb->query( + $res = XDB::query( "SELECT titre, details, montant, ei.item_id, nb FROM groupex.evenements_items AS ei LEFT JOIN groupex.evenements_participants AS ep @@ -81,7 +81,7 @@ function get_event_detail($eid, $item_id = false) $evt['topay'] += $m['nb'] * $m['montant']; } - $req = $globals->xdb->query( + $req = XDB::query( "SELECT montant FROM {$globals->money->mpay_tprefix}transactions AS t WHERE ref = {?} AND uid = {?}", $evt['paiement_id'], Session::get('uid')); @@ -135,18 +135,18 @@ function get_event_participants($evt, $item_id, $tri, $limit = '') { ORDER BY $tri $limit"; if ($item_id) { - $res = $globals->xdb->query($query, $eid); + $res = XDB::query($query, $eid); return $res->fetchAllAssoc(); } - $res = $globals->xdb->iterator($query, $eid); + $res = XDB::iterator($query, $eid); $tab = array(); $user = 0; while ($u = $res->next()) { $u['montant'] = 0; if ($money && $pay_id) { - $res_ = $globals->xdb->query( + $res_ = XDB::query( "SELECT montant FROM {$globals->money->mpay_tprefix}transactions AS t WHERE ref = {?} AND uid = {?}", @@ -157,7 +157,7 @@ function get_event_participants($evt, $item_id, $tri, $limit = '') { $u['paid'] += trim($p); } } - $res_ = $globals->xdb->iterator( + $res_ = XDB::iterator( "SELECT ep.nb, ep.item_id, ei.montant FROM groupex.evenements_participants AS ep INNER JOIN groupex.evenements_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id) @@ -185,7 +185,7 @@ function subscribe_lists_event($participate, $uid, $evt) { if ($email) { $email .= '@'.$globals->mail->domain; } else { - $res = $globals->xdb->query("SELECT email FROM groupex.membres WHERE uid = {?} AND asso_id = {?}", Session::get('uid'), $globals->asso('id')); + $res = XDB::query("SELECT email FROM groupex.membres WHERE uid = {?} AND asso_id = {?}", Session::get('uid'), $globals->asso('id')); $email = $res->fetchOneCell(); } @@ -193,13 +193,13 @@ function subscribe_lists_event($participate, $uid, $evt) { $unsubscri = $participate ? $absent_list : $participant_list; if ($subscribe) { - $globals->xdb->execute( + XDB::execute( "REPLACE INTO virtual_redirect VALUES({?},{?})", $subscribe, $email); } if ($unsubscri) { - $globals->xdb->execute( + XDB::execute( "DELETE FROM virtual_redirect WHERE vid = {?} AND redirect = {?}", $unsubscri, $email); } @@ -222,7 +222,7 @@ function event_change_shortname(&$page, $old, $new) //vérifier que l'alias n'est pas déja pris if ($new && $old != $new) { - $res = $globals->xdb->query('SELECT COUNT(*) FROM virtual + $res = XDB::query('SELECT COUNT(*) FROM virtual WHERE alias LIKE {?}', $new.'-absents@%'); if ($res->fetchOneCell() > 0) { @@ -239,7 +239,7 @@ function event_change_shortname(&$page, $old, $new) // if had a previous shortname change the old lists foreach (array('-absents@', '-participants@') as $v) { $v .= $globals->xnet->evts_domain; - $globals->xdb->execute("UPDATE virtual SET alias = {?} + XDB::execute("UPDATE virtual SET alias = {?} WHERE type = 'evt' AND alias = {?}", $new.$v, $old.$v); } @@ -250,11 +250,11 @@ function event_change_shortname(&$page, $old, $new) if (!$old && $new) { // if we have a first new short_name create the lists - $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}", + XDB::execute("INSERT INTO virtual SET type = 'evt', alias = {?}", $new.'-participants@'.$globals->xnet->evts_domain); $lastid = mysql_insert_id(); - $globals->xdb->execute( + XDB::execute( "INSERT INTO virtual_redirect ( SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect FROM groupex.evenements_participants AS ep @@ -265,11 +265,11 @@ function event_change_shortname(&$page, $old, $new) GROUP BY ep.uid)", $lastid, '@'.$globals->mail->domain, $eid); - $globals->xdb->execute("INSERT INTO virtual SET type = 'evt', alias = {?}", + XDB::execute("INSERT INTO virtual SET type = 'evt', alias = {?}", $new.'-absents@'.$globals->xnet->evts_domain); $lastid = mysql_insert_id(); - $globals->xdb->execute("INSERT INTO virtual_redirect ( + XDB::execute("INSERT INTO virtual_redirect ( SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect FROM groupex.membres AS m LEFT JOIN groupex.evenements_participants AS ep ON (ep.uid = m.uid) @@ -286,7 +286,7 @@ function event_change_shortname(&$page, $old, $new) // if we delete the old short name, delete the lists foreach (array('-absents@', '-participants@') as $v) { $v .= $globals->xnet->evts_domain; - $globals->xdb->execute("DELETE virtual, virtual_redirect FROM virtual + XDB::execute("DELETE virtual, virtual_redirect FROM virtual LEFT JOIN virtual_redirect USING(vid) WHERE virtual.alias = {?}", $infos['short_name'].$v); diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 94b935e..beeb0b0 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -33,7 +33,7 @@ function get_infos($email) list($mbox,$dom) = explode('@', $email); } - $res = $globals->xdb->query( + $res = XDB::query( "SELECT uid, nom, prenom, email, email AS email2, perms='admin', origine FROM groupex.membres WHERE $field = {?} AND asso_id = {?}", $email, $globals->asso('id')); @@ -41,7 +41,7 @@ function get_infos($email) if ($res->numRows()) { return $res->fetchOneAssoc(); } elseif ($dom == 'polytechnique.org' || $dom == 'm4x.org') { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT user_id AS uid, u.promo, IF(u.nom_usage<>'', u.nom_usage, u.nom) AS nom, u.prenom, b.alias, @@ -107,7 +107,7 @@ class XnetGrpModule extends PLModule { global $globals; - $res = $globals->xdb->query("SELECT logo, logo_mime + $res = XDB::query("SELECT logo, logo_mime FROM groupex.asso WHERE id = {?}", $globals->asso('id')); list($logo, $logo_mime) = $res->fetchOneRow(); @@ -142,7 +142,7 @@ class XnetGrpModule extends PLModule if (Post::get('mail_domain') && (strstr(Post::get('mail_domain'), '.') === false)) { $page->trig_run("le domaine doit être un FQDN (aucune modif effectuée) !!!"); } - $globals->xdb->execute( + XDB::execute( "UPDATE groupex.asso SET nom={?}, diminutif={?}, cat={?}, dom={?}, descr={?}, site={?}, mail={?}, resp={?}, @@ -158,11 +158,11 @@ class XnetGrpModule extends PLModule Post::get('sub_url'), Post::get('inscriptible'), $globals->asso('id')); if (Post::get('mail_domain')) { - $globals->xdb->execute('INSERT INTO virtual_domains (domain) VALUES({?})', + XDB::execute('INSERT INTO virtual_domains (domain) VALUES({?})', Post::get('mail_domain')); } } else { - $globals->xdb->execute( + XDB::execute( "UPDATE groupex.asso SET descr={?}, site={?}, mail={?}, resp={?}, forum={?}, ax={?}, pub= {?}, sub_url={?} @@ -177,7 +177,7 @@ class XnetGrpModule extends PLModule if ($_FILES['logo']['name']) { $logo = file_get_contents($_FILES['logo']['tmp_name']); $mime = $_FILES['logo']['type']; - $globals->xdb->execute('UPDATE groupex.asso + XDB::execute('UPDATE groupex.asso SET logo={?}, logo_mime={?} WHERE id={?}', $logo, $mime, $globals->asso('id')); @@ -187,7 +187,7 @@ class XnetGrpModule extends PLModule } if (has_perms()) { - $dom = $globals->xdb->iterator('SELECT * FROM groupex.dom ORDER BY nom'); + $dom = XDB::iterator('SELECT * FROM groupex.dom ORDER BY nom'); $page->assign('dom', $dom); $page->assign('super', true); } @@ -242,7 +242,7 @@ class XnetGrpModule extends PLModule } if ($group == 'initiale') - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( 'SELECT UPPER(SUBSTRING( IF(m.origine="X", IF(u.nom_usage<>"", u.nom_usage, u.nom),m.nom), 1, 1)) as letter, COUNT(*) @@ -252,7 +252,7 @@ class XnetGrpModule extends PLModule GROUP BY letter ORDER BY letter', $globals->asso('id')); else - $res = $globals->xdb->iterRow( + $res = XDB::iterRow( 'SELECT IF(m.origine="X",u.promo,"extérieur") AS promo, COUNT(*), IF(m.origine="X",u.promo,"") AS promo_o FROM groupex.membres AS m @@ -302,7 +302,7 @@ class XnetGrpModule extends PLModule .addslashes(Env::get('promo')).'"'; } - $ann = $globals->xdb->iterator( + $ann = XDB::iterator( "SELECT IF(m.origine='X',IF(u.nom_usage<>'', u.nom_usage, u.nom) ,m.nom) AS nom, IF(m.origine='X',u.prenom,m.prenom) AS prenom, IF(m.origine='X',u.promo,'extérieur') AS promo, @@ -340,14 +340,14 @@ class XnetGrpModule extends PLModule if (!is_null($u) && may_update()) { $page->assign('u', $u); - $res = $globals->xdb->query("SELECT nom, prenom, promo, user_id + $res = XDB::query("SELECT nom, prenom, promo, user_id FROM auth_user_md5 AS u INNER JOIN aliases AS al ON (al.id = u.user_id AND al.type != 'liste') WHERE al.alias = {?}", $u); if (list($nom, $prenom, $promo, $uid) = $res->fetchOneRow()) { - $res = $globals->xdb->query("SELECT COUNT(*) + $res = XDB::query("SELECT COUNT(*) FROM groupex.membres AS m INNER JOIN aliases AS a ON (m.uid = a.id AND a.type != 'homonyme') @@ -359,7 +359,7 @@ class XnetGrpModule extends PLModule } elseif (Env::has('accept')) { - $globals->xdb->execute("INSERT INTO groupex.membres + XDB::execute("INSERT INTO groupex.membres VALUES ({?}, {?}, 'membre', 'X', NULL, NULL, NULL, NULL)", $globals->asso('id'), $uid); require_once 'diogenes/diogenes.hermes.inc.php'; @@ -408,7 +408,7 @@ class XnetGrpModule extends PLModule } if (Post::has('inscrire')) { - $res = $globals->xdb->query('SELECT IF(m.email IS NULL, + $res = XDB::query('SELECT IF(m.email IS NULL, CONCAT(al.alias,"@polytechnique.org"), m.email) FROM groupex.membres AS m @@ -457,7 +457,7 @@ class XnetGrpModule extends PLModule new_group_page('xnet/groupe/telepaiement.tpl'); - $res = $globals->xdb->query( + $res = XDB::query( "SELECT id, text FROM {$globals->money->mpay_tprefix}paiements WHERE asso_id = {?} AND NOT FIND_IN_SET(flags, 'old') @@ -500,7 +500,7 @@ class XnetGrpModule extends PLModule $trans = array(); foreach($tit as $foo) { $pid = $foo['id']; - $res = $globals->xdb->query( + $res = XDB::query( "SELECT IF(u.nom_usage<>'', u.nom_usage, u.nom) AS nom, u.prenom, u.promo, a.alias, timestamp AS `date`, montant FROM {$globals->money->mpay_tprefix}transactions AS t @@ -546,7 +546,7 @@ class XnetGrpModule extends PLModule $not_in_group_ext = array(); foreach ($subscribers as $mail) { - $res = $globals->xdb->query( + $res = XDB::query( 'SELECT COUNT(*) FROM groupex.membres AS m LEFT JOIN auth_user_md5 AS u ON (m.uid=u.user_id AND m.uid<50000) @@ -586,7 +586,7 @@ class XnetGrpModule extends PLModule if ($x) { require_once 'user.func.inc.php'; if ($forlife = get_user_forlife($email)) { - $globals->xdb->execute( + XDB::execute( 'INSERT INTO groupex.membres (uid,asso_id,origine) SELECT user_id,{?},"X" FROM auth_user_md5 AS u @@ -599,9 +599,9 @@ class XnetGrpModule extends PLModule } } else { if (isvalid_email($email)) { - $res = $globals->xdb->query('SELECT MAX(uid)+1 FROM groupex.membres'); + $res = XDB::query('SELECT MAX(uid)+1 FROM groupex.membres'); $uid = max(intval($res->fetchOneCell()), 50001); - $globals->xdb->execute('INSERT INTO groupex.membres (uid,asso_id,origine,email) + XDB::execute('INSERT INTO groupex.membres (uid,asso_id,origine,email) VALUES({?},{?},"ext",{?})', $uid, $globals->asso('id'), $email); global $platal; @@ -627,7 +627,7 @@ class XnetGrpModule extends PLModule return; } - $globals->xdb->execute( + XDB::execute( "DELETE FROM groupex.membres WHERE uid={?} AND asso_id={?}", $user['uid'], $globals->asso('id')); @@ -652,7 +652,7 @@ class XnetGrpModule extends PLModule } } - $globals->xdb->execute( + XDB::execute( "DELETE FROM virtual_redirect USING virtual_redirect INNER JOIN virtual USING(vid) @@ -683,7 +683,7 @@ class XnetGrpModule extends PLModule if (Post::has('change')) { if ($user['origine'] != 'X') { - $globals->xdb->query('UPDATE groupex.membres + XDB::query('UPDATE groupex.membres SET prenom={?}, nom={?}, email={?} WHERE uid={?} AND asso_id={?}', Post::get('prenom'), Post::get('nom'), @@ -697,7 +697,7 @@ class XnetGrpModule extends PLModule $perms = Post::getInt('is_admin'); if ($user['perms'] != $perms) { - $globals->xdb->query('UPDATE groupex.membres SET perms={?} + XDB::query('UPDATE groupex.membres SET perms={?} WHERE uid={?} AND asso_id={?}', $perms ? 'admin' : 'membre', $user['uid'], $globals->asso('id')); @@ -725,12 +725,12 @@ class XnetGrpModule extends PLModule $ask = !empty($_REQUEST['ml4'][$ml]); if($state == $ask) continue; if($ask) { - $globals->xdb->query("INSERT INTO virtual_redirect (vid,redirect) + XDB::query("INSERT INTO virtual_redirect (vid,redirect) SELECT vid,{?} FROM virtual WHERE alias={?}", $user['email'], $ml); $page->trig("{$user['prenom']} {$user['nom']} a été abonné à $ml"); } else { - $globals->xdb->query("DELETE FROM virtual_redirect + XDB::query("DELETE FROM virtual_redirect USING virtual_redirect INNER JOIN virtual USING(vid) WHERE redirect={?} AND alias={?}", @@ -744,7 +744,7 @@ class XnetGrpModule extends PLModule $listes = $client->get_lists($user['email2']); $page->assign('listes', $listes); - $res = $globals->xdb->query( + $res = XDB::query( 'SELECT alias, redirect IS NOT NULL as sub FROM virtual AS v LEFT JOIN virtual_redirect AS vr ON(v.vid=vr.vid AND redirect={?}) diff --git a/modules/xnetlists.php b/modules/xnetlists.php index b284fc9..513c805 100644 --- a/modules/xnetlists.php +++ b/modules/xnetlists.php @@ -87,7 +87,7 @@ class XnetListsModule extends ListsModule $alias = Post::get('del_alias'); // prevent group admin from erasing aliases from other groups $alias = substr($alias, 0, strpos($alias, '@')).'@'.$globals->asso('mail_domain'); - $globals->xdb->query( + XDB::query( 'DELETE FROM x4dat.virtual_redirect, x4dat.virtual USING x4dat.virtual AS v LEFT JOIN x4dat.virtual_redirect USING(vid) @@ -98,7 +98,7 @@ class XnetListsModule extends ListsModule $listes = $this->client->get_lists(); $page->assign('listes',$listes); - $alias = $globals->xdb->iterator( + $alias = XDB::iterator( 'SELECT alias,type FROM x4dat.virtual WHERE alias @@ -133,7 +133,7 @@ class XnetListsModule extends ListsModule } $new = $liste.'@'.$globals->asso('mail_domain'); - $res = $globals->xdb->query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new); + $res = XDB::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new); $n = $res->fetchOneCell(); if($n) { @@ -158,24 +158,24 @@ class XnetListsModule extends ListsModule ."support@m4x.org"); return; } - $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) + XDB::execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'@'.$dom, 'list'); - $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) + XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+post@listes.polytechnique.org"); - $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) + XDB::execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'-owner@'.$dom, 'list'); - $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) + XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+owner@listes.polytechnique.org"); - $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) + XDB::execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'-admin@'.$dom, 'list'); - $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) + XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+admin@listes.polytechnique.org"); - $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) + XDB::execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'-bounces@'.$dom, 'list'); - $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) + XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+bounces@listes.polytechnique.org"); @@ -202,7 +202,7 @@ class XnetListsModule extends ListsModule $not_in_group_x = array(); $not_in_group_ext = array(); - $ann = $globals->xdb->iterator( + $ann = XDB::iterator( "SELECT IF(m.origine='X',IF(u.nom_usage<>'', u.nom_usage, u.nom) ,m.nom) AS nom, IF(m.origine='X',u.prenom,m.prenom) AS prenom, IF(m.origine='X',u.promo,'extérieur') AS promo, @@ -245,14 +245,14 @@ class XnetListsModule extends ListsModule $dom = 'm4x.org'; } if($dom == 'polytechnique.org' || $dom == 'm4x.org') { - $res = $globals->xdb->query( + $res = XDB::query( "SELECT a.alias, b.alias FROM x4dat.aliases AS a LEFT JOIN x4dat.aliases AS b ON (a.id=b.id AND b.type = 'a_vie') WHERE a.alias={?} AND a.type!='homonyme'", $mbox); if (list($alias, $blias) = $res->fetchOneRow()) { $alias = empty($blias) ? $alias : $blias; - $globals->xdb->query( + XDB::query( "INSERT INTO x4dat.virtual_redirect (vid,redirect) SELECT vid, {?} FROM x4dat.virtual @@ -262,7 +262,7 @@ class XnetListsModule extends ListsModule $page->trig("$mbox@polytechnique.org n'existe pas."); } } else { - $globals->xdb->query( + XDB::query( "INSERT INTO x4dat.virtual_redirect (vid,redirect) SELECT vid,{?} FROM x4dat.virtual @@ -272,7 +272,7 @@ class XnetListsModule extends ListsModule } if (Env::has('del_member')) { - $globals->xdb->query( + XDB::query( "DELETE FROM x4dat.virtual_redirect USING x4dat.virtual_redirect INNER JOIN x4dat.virtual USING(vid) @@ -280,7 +280,7 @@ class XnetListsModule extends ListsModule redirect("?liste=$lfull"); } - $res = $globals->xdb->iterator( + $res = XDB::iterator( "SELECT redirect FROM x4dat.virtual_redirect AS vr INNER JOIN x4dat.virtual AS v USING(vid) @@ -311,14 +311,14 @@ class XnetListsModule extends ListsModule } $new = $liste.'@'.$globals->asso('mail_domain'); - $res = $globals->xdb->query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new); + $res = XDB::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new); $n = $res->fetchOneCell(); if($n) { $page->trig('cet alias est déjà pris'); return; } - $globals->xdb->query('INSERT INTO x4dat.virtual (alias,type) VALUES({?}, "user")', $new); + XDB::query('INSERT INTO x4dat.virtual (alias,type) VALUES({?}, "user")', $new); global $platal; redirect(smarty_function_rel()."/{$platal->ns}alias/admin/$new"); diff --git a/plugins/function.select_db_table.php b/plugins/function.select_db_table.php index 47103f3..4276fa8 100644 --- a/plugins/function.select_db_table.php +++ b/plugins/function.select_db_table.php @@ -23,7 +23,7 @@ function select_options($table,$valeur,$champ="text",$pad=false,$where="") { global $globals; $sql = "SELECT id,$champ FROM $table $where ORDER BY $champ"; - $res = $globals->xdb->iterRow($sql); + $res = XDB::iterRow($sql); $sel = ' selected="selected"'; // on ajoute une entree vide si $pad est vrai diff --git a/plugins/function.select_nat.php b/plugins/function.select_nat.php index 7c1b39e..6afeacb 100644 --- a/plugins/function.select_nat.php +++ b/plugins/function.select_nat.php @@ -23,7 +23,7 @@ function select_nat($valeur,$pad=false) { global $globals; $sql = "SELECT a2 AS id,IF(nat='',pays,nat) AS text FROM geoloc_pays ORDER BY text"; - $res = $globals->xdb->iterRow($sql); + $res = XDB::iterRow($sql); $sel = ' selected="selected"'; // on ajoute une entree vide si $pad est vrai diff --git a/plugins/insert.getName.php b/plugins/insert.getName.php index 4ebbd65..81058cc 100644 --- a/plugins/insert.getName.php +++ b/plugins/insert.getName.php @@ -26,7 +26,7 @@ function smarty_insert_getName() if ($uid < 0) { return ""; } - $res = $globals->xdb->query("SELECT prenom FROM auth_user_md5 WHERE user_id={?}", $uid); + $res = XDB::query("SELECT prenom FROM auth_user_md5 WHERE user_id={?}", $uid); return $res->fetchOneCell(); } diff --git a/plugins/insert.getNbIns.php b/plugins/insert.getNbIns.php index 914f6a0..02eb725 100644 --- a/plugins/insert.getNbIns.php +++ b/plugins/insert.getNbIns.php @@ -31,7 +31,7 @@ function smarty_insert_getNbIns($params, &$smarty) { global $globals; - $res = $globals->xdb->query("SELECT COUNT(*) FROM auth_user_md5 WHERE perms IN ('admin','user') AND deces=0"); + $res = XDB::query("SELECT COUNT(*) FROM auth_user_md5 WHERE perms IN ('admin','user') AND deces=0"); $cnt = $res->fetchOneCell(); return number_format($cnt, 0, ",", "."); } diff --git a/plugins/insert.getUserName.php b/plugins/insert.getUserName.php index 37ab6cd..3b7a55a 100644 --- a/plugins/insert.getUserName.php +++ b/plugins/insert.getUserName.php @@ -31,11 +31,11 @@ function smarty_insert_getUsername() } if (Cookie::get('ORGdomain', 'login') != 'alias') { - $res = $globals->xdb->query("SELECT alias FROM aliases + $res = XDB::query("SELECT alias FROM aliases WHERE id={?} AND (type IN ('a_vie','alias') AND FIND_IN_SET('bestalias', flags))", $id); return $res->fetchOneCell(); } else { - $res = $globals->xdb->query(" + $res = XDB::query(" SELECT v.alias FROM virtual AS v INNER JOIN virtual_redirect USING(vid) diff --git a/plugins/insert.mkStats.php b/plugins/insert.mkStats.php index 28c930f..d83ec67 100644 --- a/plugins/insert.mkStats.php +++ b/plugins/insert.mkStats.php @@ -32,7 +32,7 @@ function smarty_insert_mkStats($params, &$smarty) { global $globals; - $res = $globals->xdb->query('select count(*) from requests'); + $res = XDB::query('select count(*) from requests'); $cnt = $res->fetchOneCell(); return ($cnt ? $cnt : '-'); } diff --git a/scripts/listes_redirect.php b/scripts/listes_redirect.php index 8c3f948..450b451 100644 --- a/scripts/listes_redirect.php +++ b/scripts/listes_redirect.php @@ -10,7 +10,7 @@ if (empty($matches)) { header("Location: https://www.polytechnique.org/lists/$action/$mbox"); } else { require("../include/xorg.inc.php"); - $res = $globals->xdb->query("select diminutif from groupex.asso where mail_domain = {?}", $fqdn); + $res = XDB::query("select diminutif from groupex.asso where mail_domain = {?}", $fqdn); if ($gpx = $res->fetchOneCell()) { header("Location: http://www.polytechnique.net/$gpx/lists/$action/$mbox"); } diff --git a/scripts/webredirect.php b/scripts/webredirect.php index e112476..68322d2 100644 --- a/scripts/webredirect.php +++ b/scripts/webredirect.php @@ -26,7 +26,7 @@ require("../include/xorg.inc.php"); // la config d'apache impose la forme suivante pour REQUEST_URI : // REQUEST_URI = /prenom.nom(/path/fichier.hmtl)? list($username, $path) = preg_split('/\//', $_SERVER["REQUEST_URI"], 2, PREG_SPLIT_NO_EMPTY); -$res = $globals->xdb->query( +$res = XDB::query( "SELECT redirecturl FROM auth_user_quick AS a INNER JOIN aliases AS al ON (al.id = a.user_id AND (al.type='a_vie' OR al.type='alias')) -- 2.1.4