From: x2001corpet Date: Tue, 25 Jul 2006 18:58:59 +0000 (+0000) Subject: migration d'admin X-Git-Tag: xorg/0.9.11~262 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=86f0a6af68bfec7f19d65b86f549689a2b33a53f;p=platal.git migration d'admin git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@649 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/ChangeLog b/ChangeLog index 91e4128..cb39e59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ VERSION 0.9.11 ?? ???? 2006 New: + * Admin: + - Switch to the new URI scheme. -Car + * Auth: - Switch to the new URI scheme. -MC @@ -23,7 +26,7 @@ New: - Switch to the new URI scheme. -MC * Geoloc: - - Switch to the new URI scheme. -MC + - Switch to the new URI scheme. -MC/Car * Lists: - Switch to the new URI scheme. -MC diff --git a/htdocs/admin/admin_trombino.php b/htdocs/admin/admin_trombino.php deleted file mode 100644 index 0974548..0000000 --- a/htdocs/admin/admin_trombino.php +++ /dev/null @@ -1,59 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Trombino'); - -$uid = Env::i('uid'); -$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' ) - WHERE user_id = {?}", $uid); -list($forlife, $promo) = $q->fetchOneRow(); - -switch (Env::v('action')) { - - case "ecole": - header("Content-type: image/jpeg"); - readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg"); - exit; - break; - - case "valider": - $data = file_get_contents($_FILES['userfile']['tmp_name']); - list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']); - $mimetype = substr($_FILES['userfile']['type'], 6); - unlink($_FILES['userfile']['tmp_name']); - XDB::execute( - "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}", - $uid, $mimetype, $data, $x, $y); - break; - - case "supprimer": - XDB::execute('DELETE FROM photo WHERE uid = {?}', $uid); - break; -} - -$page->assign('forlife', $forlife); -$page->run(); -?> diff --git a/htdocs/admin/ax-xorg.php b/htdocs/admin/ax-xorg.php deleted file mode 100644 index d6218f6..0000000 --- a/htdocs/admin/ax-xorg.php +++ /dev/null @@ -1,51 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - AX/X.org'); - -// liste des différences -$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 - WHERE (SOUNDEX(u.nom) != SOUNDEX(ia.nom) AND SOUNDEX(CONCAT(ia.particule,u.nom)) != SOUNDEX(ia.nom) - AND SOUNDEX(u.nom) != SOUNDEX(ia.nom_patro) AND SOUNDEX(CONCAT(ia.particule,u.nom)) != SOUNDEX(ia.nom_patro)) - OR u.prenom != ia.prenom OR (u.promo != ia.promo AND u.promo != ia.promo+1 AND u.promo != ia.promo-1) - ORDER BY u.promo,u.nom,u.prenom'); -$page->assign('diffs', $res->fetchAllAssoc()); - -// gens à l'ax mais pas chez nous -$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 - WHERE u.nom IS NULL'); -$page->assign('mank', $res->fetchAllAssoc()); - -// gens chez nous et pas à l'ax -$res = XDB::query('SELECT promo,nom,prenom FROM auth_user_md5 WHERE matricule_ax IS NULL'); -$page->assign('plus', $res->fetchAllAssoc()); - - -$page->run(); -?> diff --git a/htdocs/admin/deces_promo.php b/htdocs/admin/deces_promo.php deleted file mode 100644 index 1a0a098..0000000 --- a/htdocs/admin/deces_promo.php +++ /dev/null @@ -1,56 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Deces'); - -$promo = Env::i('promo'); -if (Env::has('sub10')) $promo -= 10; -if (Env::has('sub01')) $promo -= 1; -if (Env::has('add01')) $promo += 1; -if (Env::has('add10')) $promo += 10; - -$page->assign('promo',$promo); - -if (Env::v('valider') == "Valider") { - $new_deces = array(); - $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::v($mat); - if($val == $deces || empty($val)) continue; - 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'); - register_watch_op($uid, WATCH_DEATH, $val); - require_once('user.func.inc.php'); - user_clear_all_subs($uid, false); // by default, dead ppl do not loose their email - } - } - $page->assign('new_deces',$new_deces); -} - -$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 deleted file mode 100644 index fbddca7..0000000 --- a/htdocs/admin/emails_bounces_re.php +++ /dev/null @@ -1,38 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Postfix : Regexps Bounces'); - -if (Post::has('submit')) { - foreach (Env::v('lvl') as $id=>$val) { - 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', XDB::iterator("SELECT * FROM emails_bounces_re ORDER BY pos")); - -$page->run(); -?> diff --git a/htdocs/admin/evenements.php b/htdocs/admin/evenements.php deleted file mode 100644 index 17791ef..0000000 --- a/htdocs/admin/evenements.php +++ /dev/null @@ -1,98 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Evenements'); - -$arch = Env::v('arch', 0); -$evid = Post::i('evt_id'); -$page->assign('arch', $arch); - -switch(Post::v('action')) { - case "Proposer": - XDB::execute('UPDATE evenements SET titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?} WHERE id = {?}', - Post::v('titre'), Post::v('texte'), Post::v('peremption'), Post::v('promo_min'), Post::v('promo_max'), $evid); - break; - - case "Valider": - XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",valide") WHERE id = {?}', $evid); - break; - - case "Invalider": - XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"valide", "") WHERE id = {?}', $evid); - break; - - case "Supprimer": - XDB::execute('DELETE from evenements WHERE id = {?}', $evid); - break; - - case "Archiver": - XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",archive") WHERE id = {?}', $evid); - break; - - case "Desarchiver": - XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"archive","") WHERE id = {?}', $evid); - break; - - case "Editer": - $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); - $page->assign('texte',$texte); - $page->assign('promo_min',$promo_min); - $page->assign('promo_max',$promo_max); - $page->assign('peremption',$peremption); - - $select = ""; - for ($i = 1 ; $i < 30 ; $i++) { - $p_stamp=date("Ymd",time()+3600*24*$i); - $year=substr($p_stamp,0,4); - $month=substr($p_stamp,4,2); - $day=substr($p_stamp,6,2); - - $select .= "\n"; - } - $page->assign('select',$select); - - break; -} - -if ($action != "Editer") { - - $sql = "SELECT e.id, e.titre, e.texte, - DATE_FORMAT(e.creation_date,'%d/%m/%Y %T') AS creation_date, - DATE_FORMAT(e.peremption,'%d/%m/%Y') AS peremption, - e.promo_min, e.promo_max, - FIND_IN_SET('valide', e.flags) AS fvalide, - FIND_IN_SET('archive', e.flags) AS farch, - u.promo, u.nom, u.prenom, a.alias AS forlife - FROM evenements AS e - INNER JOIN auth_user_md5 AS u ON(e.user_id = u.user_id) - 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', XDB::iterator($sql)); -} - -$page->run(); -?> diff --git a/htdocs/admin/geoloc.php b/htdocs/admin/geoloc.php deleted file mode 100644 index dc92555..0000000 --- a/htdocs/admin/geoloc.php +++ /dev/null @@ -1,47 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Geolocalisation'); - -$nb_synchro = 0; - -if (Env::has('id') && is_numeric(Env::v('id'))) { - if (synchro_city(Env::v('id'))) $nb_synchro ++; -} - -if (Env::has('missinglat')) { - $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 = XDB::query("SELECT COUNT(*) FROM geoloc_city WHERE lat = 0 AND lon = 0"); -$page->assign("nb_missinglat", $res->fetchOneCell()); - -$page->run(); - -// vim:set et sws=4 sts=4 sw=4: -?> diff --git a/htdocs/admin/geoloc_dynamap.php b/htdocs/admin/geoloc_dynamap.php deleted file mode 100644 index e95eab0..0000000 --- a/htdocs/admin/geoloc_dynamap.php +++ /dev/null @@ -1,68 +0,0 @@ -trig("Impossible d'accéder au webservice"); - else - $refresh = true; -} - -if (Env::v('fix') == 'smallest_maps') { - require_once('geoloc.inc.php'); - set_smallest_levels(); -} - -if (Env::v('fix') == 'precise_coordinates') { - 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')) { - require_once('geoloc.inc.php'); - if (!get_new_maps(Env::v('url'))) - $page->trig("Impossible d'accéder aux nouvelles cartes"); -} - -$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 = 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 = XDB::query("SELECT COUNT(*) FROM adresses WHERE cityid IS NOT NULL AND glat = 0 AND glng = 0"); -$noCoordinates = $countNoCoordinates->fetchOneCell(); - -if (isset($refresh) && $missing) { - $page->assign("xorg_extra_header", ""); -} -$page->assign("nb_cities_not_on_map", $missing); -$page->assign("no_smallest", $noSmallest); -$page->assign("no_coordinates", $noCoordinates); - -$page->run(); - -// vim:set et sws=4 sts=4 sw=4: -?> - diff --git a/htdocs/admin/homonymes.php b/htdocs/admin/homonymes.php deleted file mode 100644 index 5871b6d..0000000 --- a/htdocs/admin/homonymes.php +++ /dev/null @@ -1,84 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Homonymes'); -require_once("homonymes.inc.php"); - -$op = Env::v('op', 'list'); -$target = Env::i('target'); - -if ($target) { - if (! list($prenom,$nom,$forlife,$loginbis) = select_if_homonyme($target)) { - $target=0; - } else { - $page->assign('nom',$nom); - $page->assign('prenom',$prenom); - $page->assign('forlife',$forlife); - $page->assign('loginbis',$loginbis); - } -} - -$page->assign('op',$op); -$page->assign('target',$target); - -// on a un $target valide, on prepare les mails -if ($target) { - - // on examine l'op a effectuer - switch ($op) { - case 'mail': - send_warning_homonyme($prenom, $nom, $forlife, $loginbis); - switch_bestalias($target, $loginbis); - $op = 'list'; - break; - case 'correct': - switch_bestalias($target, $loginbis); - 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; - } -} - -if ($op == 'list') { - $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, - IF(h.homonyme_id=s.id, a.type, NULL) AS type - FROM aliases AS a - LEFT JOIN homonymes AS h ON (h.homonyme_id = a.id) - INNER JOIN aliases AS s ON (s.id = h.user_id AND s.type='a_vie') - INNER JOIN auth_user_md5 AS u ON (s.id=u.user_id) - WHERE a.type='homonyme' OR a.expire!='' - ORDER BY a.alias,promo"); - $hnymes = Array(); - while ($tab = $res->next()) { - $hnymes[$tab['homonyme']][] = $tab; - } - $page->assign_by_ref('hnymes',$hnymes); -} - -$page->run(); -?> diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php deleted file mode 100644 index 0b50e49..0000000 --- a/htdocs/admin/index.php +++ /dev/null @@ -1,39 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration'); - -$res = XDB::iterRow(" - SELECT h1, h2, texte, url - FROM admin_a AS a - INNER JOIN admin_h2 AS h2 USING(h2id) - INNER JOIN admin_h1 AS h1 USING(h1id) - ORDER BY h1.prio, h2.prio, a.prio"); -$index = Array(); -while(list($h1,$h2,$txt,$url) = $res->next()) { - $index[$h1][$h2][] = Array('txt' => $txt, 'url'=>$url); -} -$page->assign_by_ref('index', $index); - -$page->run(); -?> diff --git a/htdocs/admin/lists.php b/htdocs/admin/lists.php deleted file mode 100644 index 07d84fc..0000000 --- a/htdocs/admin/lists.php +++ /dev/null @@ -1,31 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Mailing lists'); -require_once 'lists.inc.php'; - -$client =& lists_xmlrpc(S::v('uid'), S::v('password')); -$listes = $client->get_all_lists(); -$page->assign_by_ref('listes',$listes); -$page->run(); -?> diff --git a/htdocs/admin/logger.php b/htdocs/admin/logger.php deleted file mode 100644 index 1d61209..0000000 --- a/htdocs/admin/logger.php +++ /dev/null @@ -1,36 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Logs des sessions'); -require_once('diogenes/diogenes.logger-view.inc.php'); - -if (!Env::has('logauth')) { - $_REQUEST['logauth'] = 'native'; -} - -$logview = new DiogenesLoggerView; -$logview->run($page); - -$page->fakeDiogenes(); -$page->run(); -?> diff --git a/htdocs/admin/newsletter.php b/htdocs/admin/newsletter.php deleted file mode 100644 index a72e1d7..0000000 --- a/htdocs/admin/newsletter.php +++ /dev/null @@ -1,34 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Newsletter : liste'); -require_once("newsletter.inc.php"); - -if(Get::has('new')) { - insert_new_nl(); - http_redirect("newsletter.php"); -} - -$page->assign_by_ref('nl_list', get_nl_slist()); -$page->run(); -?> diff --git a/htdocs/admin/newsletter_edit.php b/htdocs/admin/newsletter_edit.php deleted file mode 100644 index c7dd3ac..0000000 --- a/htdocs/admin/newsletter_edit.php +++ /dev/null @@ -1,63 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Newsletter : Edition'); -require_once("newsletter.inc.php"); - -$nid = Get::v('nid', 'last'); -$nl = new NewsLetter($nid); - -if(Get::has('del_aid')) { - $nl->delArticle(Get::v('del_aid')); - http_redirect("{$_SERVER['PHP_SELF']}?nid=$nid"); -} - -if(Post::v('update')) { - $nl->_title = Post::v('title'); - $nl->_date = Post::v('date'); - $nl->_head = Post::v('head'); - $nl->save(); -} - -if(Post::v('save')) { - $art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'), - Get::v('edit_aid'), Post::v('cid'), Post::v('pos')); - $nl->saveArticle($art); - http_redirect("{$_SERVER['PHP_SELF']}?nid=$nid"); -} - -if(Get::has('edit_aid')) { - $eaid = Get::v('edit_aid'); - if(Post::has('aid')) { - $art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'), - $eaid, Post::v('cid'), Post::v('pos')); - } else { - $art = $eaid<0 ? new NLArticle() : $nl->getArt($eaid); - } - $page->assign('art', $art); -} - -$page->assign_by_ref('nl',$nl); - -$page->run(); -?> diff --git a/htdocs/admin/postfix_delayed.php b/htdocs/admin/postfix_delayed.php deleted file mode 100644 index 82160dc..0000000 --- a/htdocs/admin/postfix_delayed.php +++ /dev/null @@ -1,47 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés'); - - -if (Env::has('del')) { - $crc = Env::v('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::v('crc'); - XDB::execute("UPDATE postfix_mailseen SET release = 'ok' WHERE crc = {?}", $crc); - $page->trig($crc." a le droit de passer !"); -} - -$sql = XDB::iterator( - "SELECT crc, nb, update_time, create_time, - FIND_IN_SET('del', release) AS del, - FIND_IN_SET('ok', release) AS ok - FROM postfix_mailseen - WHERE nb >= 30 - ORDER BY release != ''"); - -$page->assign_by_ref('mails', $sql); -$page->run(); -?> diff --git a/htdocs/admin/synchro_ax.php b/htdocs/admin/synchro_ax.php deleted file mode 100644 index 559fc04..0000000 --- a/htdocs/admin/synchro_ax.php +++ /dev/null @@ -1,68 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Synchro AX'); - -require_once('synchro_ax.inc.php'); - -if (is_ax_key_missing()) { - $page->assign('no_private_key', true); - $page->run(); -} - -require_once('user.func.inc.php'); - -if (Env::has('user')) { - $login = get_user_forlife(Env::v('user')); - if ($login === false) { - exit; - } -} - -if (Env::has('mat')) { - $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') - WHERE matricule={?}", Env::i('mat')); - $login = $res->fetchOneCell(); -} - -if ($login) { - if (Env::has('importe')) { - ax_synchronize($login, S::v('uid')); - } - // get details from user, but looking only info that can be seen by ax - $user = get_user_details($login, S::v('uid'), 'ax'); - $userax= get_user_ax($user['matricule_ax']); - require_once 'profil.func.inc.php'; - $diff = diff_user_details($userax, $user, 'ax'); - - $page->assign('x', $user); - $page->assign('diff', $diff); -} -$page->run(); - -// vim:set et sts=4 sws=4 sw=4: -?> diff --git a/htdocs/admin/utilisateurs.php b/htdocs/admin/utilisateurs.php deleted file mode 100644 index 03b81d5..0000000 --- a/htdocs/admin/utilisateurs.php +++ /dev/null @@ -1,203 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Edit/Su/Log'); -require_once("emails.inc.php"); -require_once("user.func.inc.php"); - -if (S::has('suid')) { - $page->kill("déjà en SUID !!!"); -} - -if (Env::has('user_id')) { - $login = get_user_login(Env::i('user_id')); -} elseif (Env::has('login')) { - $login = get_user_login(Env::v('login')); -} else { - $login = false; -} - -if(Env::has('logs_button') && $login) { - http_redirect("logger.php?loguser=$login&year=".date('Y')."&month=".date('m')); -} - -if (Env::has('ax_button') && $login) { - http_redirect("synchro_ax.php?user=$login"); -} - -if(Env::has('suid_button') && $login) { - $_SESSION['log']->log("suid_start", "login by ".S::v('forlife')); - $_SESSION['suid'] = $_SESSION; - $r = XDB::query("SELECT id FROM aliases WHERE alias={?}", $login); - if($uid = $r->fetchOneCell()) { - start_connexion($uid,true); - http_redirect("../"); - } -} - -if ($login) { - $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(); - - $redirect = new Redirect($mr['user_id']); - - // Check if there was a submission - foreach($_POST as $key => $val) { - switch ($key) { - case "add_fwd": - $email = trim(Env::v('email')); - if (!isvalid_email_redirection($email)) { - $page->trig("invalid email $email"); - } else { - $redirect->add_email($email); - $page->trig("Ajout de $email effectué"); - } - break; - - case "del_fwd": - if (!empty($val)) { - $redirect->delete_email($val); - } - break; - - case "del_alias": - if (!empty($val)) { - 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é"); - } - break; - case "activate_fwd": - if (!empty($val)) { - $redirect->modify_one_email($val, true); - } - break; - case "deactivate_fwd": - if (!empty($val)) { - $redirect->modify_one_email($val, false); - } - break; - case "add_alias": - XDB::execute("INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, 'alias')", - $mr['user_id'], Env::v('email')); - break; - - case "best": - // 'bestalias' is the first bit of the set : 1 - // 255 is the max for flags (8 sets max) - 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; - - - // Editer un profil - case "u_edit": - require_once('secure_hash.inc.php'); - $pass_encrypted = Env::v('newpass_clair') != "********" ? hash_encrypt(Env::v('newpass_clair')) : Env::v('passw'); - $naiss = Env::v('naissanceN'); - $perms = Env::v('permsN'); - $prenm = Env::v('prenomN'); - $nom = Env::v('nomN'); - $promo = Env::i('promoN'); - $sexe = Env::v('sexeN'); - $comm = Env::v('commentN'); - - $query = "UPDATE auth_user_md5 SET - naissance = '$naiss', - password = '$pass_encrypted', - perms = '$perms', - prenom = '".addslashes($prenm)."', - nom = '".addslashes($nom)."', - flags = '$sexe', - promo = $promo, - comment = '".addslashes($comm)."' - WHERE user_id = '{$mr['user_id']}'"; - if (XDB::execute($query)) { - user_reindex($mr['user_id']); - - require_once("diogenes/diogenes.hermes.inc.php"); - $mailer = new HermesMailer(); - $mailer->setFrom("webmaster@polytechnique.org"); - $mailer->addTo("web@polytechnique.org"); - $mailer->setSubject("INTERVENTION de ".S::v('forlife')); - $mailer->setTxtBody(preg_replace("/[ \t]+/", ' ', $query)); - $mailer->send(); - - $page->trig("updaté correctement."); - } - if (Env::v('nomusageN') != $mr['nom_usage']) { - require_once('nomusage.inc.php'); - set_new_usage($mr['user_id'], Env::v('nomusageN'), make_username(Env::v('prenomN'), Env::v('nomusageN'))); - } - $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']); - $mr = $r->fetchOneAssoc(); - break; - - // DELETE FROM auth_user_md5 - case "u_kill": - user_clear_all_subs($mr['user_id']); - $page->trig("'{$mr['user_id']}' a été désinscrit !"); - require_once("diogenes/diogenes.hermes.inc.php"); - $mailer = new HermesMailer(); - $mailer->setFrom("webmaster@polytechnique.org"); - $mailer->addTo("web@polytechnique.org"); - $mailer->setSubject("INTERVENTION de ".S::v('forlife')); - $mailer->setTxtBody("\nUtilisateur $login effacé"); - $mailer->send(); - break; - } - } - - $res = XDB::query("SELECT UNIX_TIMESTAMP(start), host - FROM logger.sessions - WHERE uid={?} AND suid=0 - ORDER BY start DESC - LIMIT 1", $mr['user_id']); - list($lastlogin,$host) = $res->fetchOneRow(); - $page->assign('lastlogin', $lastlogin); - $page->assign('host', $host); - - $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' - ORDER BY type!= 'a_vie'", $mr["user_id"])); - $page->assign('xorgmails', $xorgmails); - $page->assign('email_panne', $email_panne); - $page->assign('emails',$redirect->emails); - - $page->assign('mr',$mr); -} - -$page->run(); - -// vim:set et sws=4 sts=4 sw=4: -?> diff --git a/htdocs/admin/valider.php b/htdocs/admin/valider.php deleted file mode 100644 index 162a7fa..0000000 --- a/htdocs/admin/valider.php +++ /dev/null @@ -1,34 +0,0 @@ -assign('xorg_title','Polytechnique.org - Administration - Valider une demande'); -require_once("validations.inc.php"); - -if(Env::has('uid') && Env::has('type') && Env::has('stamp')) { - $req = Validate::get_request(Env::v('uid'), Env::v('type'), Env::v('stamp')); - if($req) { $req->handle_formu(); } -} - -$page->assign('vit', new ValidateIterator()); -$page->run(); -?> diff --git a/htdocs/admin/gerer_applis.php b/htdocs/admin_old/gerer_applis.php similarity index 100% rename from htdocs/admin/gerer_applis.php rename to htdocs/admin_old/gerer_applis.php diff --git a/htdocs/admin/gerer_auth-groupex.php b/htdocs/admin_old/gerer_auth-groupex.php similarity index 100% rename from htdocs/admin/gerer_auth-groupex.php rename to htdocs/admin_old/gerer_auth-groupex.php diff --git a/htdocs/admin/gerer_binets.php b/htdocs/admin_old/gerer_binets.php similarity index 100% rename from htdocs/admin/gerer_binets.php rename to htdocs/admin_old/gerer_binets.php diff --git a/htdocs/admin/gerer_coupure.php b/htdocs/admin_old/gerer_coupure.php similarity index 100% rename from htdocs/admin/gerer_coupure.php rename to htdocs/admin_old/gerer_coupure.php diff --git a/htdocs/admin/gerer_decos.php b/htdocs/admin_old/gerer_decos.php similarity index 100% rename from htdocs/admin/gerer_decos.php rename to htdocs/admin_old/gerer_decos.php diff --git a/htdocs/admin/gerer_groupesx.php b/htdocs/admin_old/gerer_groupesx.php similarity index 100% rename from htdocs/admin/gerer_groupesx.php rename to htdocs/admin_old/gerer_groupesx.php diff --git a/htdocs/admin/gerer_paiement.php b/htdocs/admin_old/gerer_paiement.php similarity index 100% rename from htdocs/admin/gerer_paiement.php rename to htdocs/admin_old/gerer_paiement.php diff --git a/htdocs/admin/gerer_skins.php b/htdocs/admin_old/gerer_skins.php similarity index 100% rename from htdocs/admin/gerer_skins.php rename to htdocs/admin_old/gerer_skins.php diff --git a/htdocs/admin/logger_actions.php b/htdocs/admin_old/logger_actions.php similarity index 100% rename from htdocs/admin/logger_actions.php rename to htdocs/admin_old/logger_actions.php diff --git a/htdocs/admin/newsletter_cats.php b/htdocs/admin_old/newsletter_cats.php similarity index 100% rename from htdocs/admin/newsletter_cats.php rename to htdocs/admin_old/newsletter_cats.php diff --git a/htdocs/admin/postfix_blacklist.php b/htdocs/admin_old/postfix_blacklist.php similarity index 100% rename from htdocs/admin/postfix_blacklist.php rename to htdocs/admin_old/postfix_blacklist.php diff --git a/htdocs/admin/postfix_whitelist.php b/htdocs/admin_old/postfix_whitelist.php similarity index 100% rename from htdocs/admin/postfix_whitelist.php rename to htdocs/admin_old/postfix_whitelist.php diff --git a/htdocs/index.php b/htdocs/index.php index 427dd76..881a223 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -26,7 +26,7 @@ require_once dirname(__FILE__).'/../classes/PLModule.php'; $platal = new Platal('auth', 'banana', 'carnet', 'email', 'events', 'geoloc', 'lists', 'marketing', 'payment', 'platal', 'profile', - 'register', 'search', 'stats', 'trezo'); + 'register', 'search', 'stats', 'trezo', 'admin'); $platal->run(); ?> diff --git a/modules/admin.php b/modules/admin.php new file mode 100644 index 0000000..f403992 --- /dev/null +++ b/modules/admin.php @@ -0,0 +1,716 @@ + $this->make_hook('default', AUTH_MDP, 'admin'), + 'admin/postfix/delayed' => $this->make_hook('postfix_delayed', AUTH_MDP, 'admin'), + 'admin/postfix/regexp_bounces' => $this->make_hook('postfix_regexpsbounces', AUTH_MDP, 'admin'), + 'admin/logger' => $this->make_hook('logger', AUTH_MDP, 'admin'), + 'admin/logger/actions' => $this->make_hook('logger_action', AUTH_MDP, 'admin'), + 'admin/users' => $this->make_hook('user', AUTH_MDP, 'admin'), + 'admin/homonyms' => $this->make_hook('homonyms', AUTH_MDP, 'admin'), + 'admin/ax-xorg' => $this->make_hook('ax_xorg', AUTH_MDP, 'admin'), + 'admin/deaths' => $this->make_hook('deaths', AUTH_MDP, 'admin'), + 'admin/synchro_ax' => $this->make_hook('synchro_ax', AUTH_MDP, 'admin'), + 'admin/events' => $this->make_hook('events', AUTH_MDP, 'admin'), + 'admin/formations' => $this->make_hook('formations', AUTH_MDP, 'admin'), + 'admin/newsletter' => $this->make_hook('newsletter', AUTH_MDP, 'admin'), + 'admin/newsletter/edit' => $this->make_hook('newsletter_edit', AUTH_MDP, 'admin'), + 'admin/lists' => $this->make_hook('lists', AUTH_MDP, 'admin'), + 'admin/validate' => $this->make_hook('validate', AUTH_MDP, 'admin'), + 'admin/geoloc' => $this->make_hook('geoloc', AUTH_MDP, 'admin'), + 'admin/geoloc/dynamap' => $this->make_hook('geoloc_dynamap', AUTH_MDP, 'admin'), + 'admin/trombino' => $this->make_hook('trombino', AUTH_MDP, 'admin'), + ); + } + + function handler_default(&$page) + { + $page->changeTpl('admin/index.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration'); + } + + function handler_postfix_delayed(&$page) + { + $page->changeTpl('admin/postfix_delayed.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés'); + + if (Env::has('del')) { + $crc = Env::v('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::v('crc'); + XDB::execute("UPDATE postfix_mailseen SET release = 'ok' WHERE crc = {?}", $crc); + $page->trig($crc." a le droit de passer !"); + } + + $sql = XDB::iterator( + "SELECT crc, nb, update_time, create_time, + FIND_IN_SET('del', release) AS del, + FIND_IN_SET('ok', release) AS ok + FROM postfix_mailseen + WHERE nb >= 30 + ORDER BY release != ''"); + + $page->assign_by_ref('mails', $sql); + } + + function handler_postfix_regexpsbounces(&$page, $new = null) { + $page->changeTpl('admin/emails_bounces_re.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Regexps Bounces'); + $page->assign('new', $new); + + if (Post::has('submit')) { + foreach (Env::v('lvl') as $id=>$val) { + 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', XDB::iterator("SELECT * FROM emails_bounces_re ORDER BY pos")); + } + + function handler_logger(&$page) { + $page->changeTpl('logger-view.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Logs des sessions'); + require_once('diogenes/diogenes.logger-view.inc.php'); + + if (!Env::has('logauth')) { + $_REQUEST['logauth'] = 'native'; + } + + $logview = new DiogenesLoggerView; + $logview->run($page); + + $page->fakeDiogenes(); + } + + function handler_user(&$page, $login = false) { + $page->changeTpl('admin/utilisateurs.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Edit/Su/Log'); + require_once("emails.inc.php"); + require_once("user.func.inc.php"); + + if (S::has('suid')) { + $page->kill("déjà en SUID !!!"); + } + + if (Env::has('user_id')) { + $login = get_user_login(Env::i('user_id')); + } elseif (Env::has('login')) { + $login = get_user_login(Env::v('login')); + } + + if(Env::has('logs_button') && $login) { + pl_redirect("admin/logger?login=$login&year=".date('Y')."&month=".date('m')); + } + + if (Env::has('ax_button') && $login) { + pl_redirect("admin/synchro_ax/$login"); + } + + if(Env::has('suid_button') && $login) { + $_SESSION['log']->log("suid_start", "login by ".S::v('forlife')); + $_SESSION['suid'] = $_SESSION; + $r = XDB::query("SELECT id FROM aliases WHERE alias={?}", $login); + if($uid = $r->fetchOneCell()) { + start_connexion($uid,true); + pl_redirect(""); + } + } + + if ($login) { + $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(); + + $redirect = new Redirect($mr['user_id']); + + // Check if there was a submission + foreach($_POST as $key => $val) { + switch ($key) { + case "add_fwd": + $email = trim(Env::v('email')); + if (!isvalid_email_redirection($email)) { + $page->trig("invalid email $email"); + } else { + $redirect->add_email($email); + $page->trig("Ajout de $email effectué"); + } + break; + + case "del_fwd": + if (!empty($val)) { + $redirect->delete_email($val); + } + break; + + case "del_alias": + if (!empty($val)) { + 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é"); + } + break; + case "activate_fwd": + if (!empty($val)) { + $redirect->modify_one_email($val, true); + } + break; + case "deactivate_fwd": + if (!empty($val)) { + $redirect->modify_one_email($val, false); + } + break; + case "add_alias": + XDB::execute("INSERT INTO aliases (id,alias,type) VALUES ({?}, {?}, 'alias')", + $mr['user_id'], Env::v('email')); + break; + + case "best": + // 'bestalias' is the first bit of the set : 1 + // 255 is the max for flags (8 sets max) + 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; + + + // Editer un profil + case "u_edit": + require_once('secure_hash.inc.php'); + $pass_encrypted = Env::v('newpass_clair') != "********" ? hash_encrypt(Env::v('newpass_clair')) : Env::v('passw'); + $naiss = Env::v('naissanceN'); + $perms = Env::v('permsN'); + $prenm = Env::v('prenomN'); + $nom = Env::v('nomN'); + $promo = Env::i('promoN'); + $sexe = Env::v('sexeN'); + $comm = Env::v('commentN'); + + $query = "UPDATE auth_user_md5 SET + naissance = '$naiss', + password = '$pass_encrypted', + perms = '$perms', + prenom = '".addslashes($prenm)."', + nom = '".addslashes($nom)."', + flags = '$sexe', + promo = $promo, + comment = '".addslashes($comm)."' + WHERE user_id = '{$mr['user_id']}'"; + if (XDB::execute($query)) { + user_reindex($mr['user_id']); + + require_once("diogenes/diogenes.hermes.inc.php"); + $mailer = new HermesMailer(); + $mailer->setFrom("webmaster@polytechnique.org"); + $mailer->addTo("web@polytechnique.org"); + $mailer->setSubject("INTERVENTION de ".S::v('forlife')); + $mailer->setTxtBody(preg_replace("/[ \t]+/", ' ', $query)); + $mailer->send(); + + $page->trig("updaté correctement."); + } + if (Env::v('nomusageN') != $mr['nom_usage']) { + require_once('nomusage.inc.php'); + set_new_usage($mr['user_id'], Env::v('nomusageN'), make_username(Env::v('prenomN'), Env::v('nomusageN'))); + } + $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']); + $mr = $r->fetchOneAssoc(); + break; + + // DELETE FROM auth_user_md5 + case "u_kill": + user_clear_all_subs($mr['user_id']); + $page->trig("'{$mr['user_id']}' a été désinscrit !"); + require_once("diogenes/diogenes.hermes.inc.php"); + $mailer = new HermesMailer(); + $mailer->setFrom("webmaster@polytechnique.org"); + $mailer->addTo("web@polytechnique.org"); + $mailer->setSubject("INTERVENTION de ".S::v('forlife')); + $mailer->setTxtBody("\nUtilisateur $login effacé"); + $mailer->send(); + break; + } + } + + $res = XDB::query("SELECT UNIX_TIMESTAMP(start), host + FROM logger.sessions + WHERE uid={?} AND suid=0 + ORDER BY start DESC + LIMIT 1", $mr['user_id']); + list($lastlogin,$host) = $res->fetchOneRow(); + $page->assign('lastlogin', $lastlogin); + $page->assign('host', $host); + + $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' + ORDER BY type!= 'a_vie'", $mr["user_id"])); + $page->assign('xorgmails', $xorgmails); + $page->assign('email_panne', $email_panne); + $page->assign('emails',$redirect->emails); + + $page->assign('mr',$mr); + } + } + function handler_homonyms(&$page, $op = 'list', $target = null) { + $page->changeTpl('admin/homonymes.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Homonymes'); + require_once("homonymes.inc.php"); + + if ($target) { + if (! list($prenom,$nom,$forlife,$loginbis) = select_if_homonyme($target)) { + $target=0; + } else { + $page->assign('nom',$nom); + $page->assign('prenom',$prenom); + $page->assign('forlife',$forlife); + $page->assign('loginbis',$loginbis); + } + } + + $page->assign('op',$op); + $page->assign('target',$target); + + // on a un $target valide, on prepare les mails + if ($target) { + + // on examine l'op a effectuer + switch ($op) { + case 'mail': + send_warning_homonyme($prenom, $nom, $forlife, $loginbis); + switch_bestalias($target, $loginbis); + $op = 'list'; + break; + case 'correct': + switch_bestalias($target, $loginbis); + 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; + } + } + + if ($op == 'list') { + $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, + IF(h.homonyme_id=s.id, a.type, NULL) AS type + FROM aliases AS a + LEFT JOIN homonymes AS h ON (h.homonyme_id = a.id) + INNER JOIN aliases AS s ON (s.id = h.user_id AND s.type='a_vie') + INNER JOIN auth_user_md5 AS u ON (s.id=u.user_id) + WHERE a.type='homonyme' OR a.expire!='' + ORDER BY a.alias,promo"); + $hnymes = Array(); + while ($tab = $res->next()) { + $hnymes[$tab['homonyme']][] = $tab; + } + $page->assign_by_ref('hnymes',$hnymes); + } + } + + function handler_ax_xorg(&$page) { + $page->changeTpl('admin/ax-xorg.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - AX/X.org'); + + // liste des différences + $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 + WHERE (SOUNDEX(u.nom) != SOUNDEX(ia.nom) AND SOUNDEX(CONCAT(ia.particule,u.nom)) != SOUNDEX(ia.nom) + AND SOUNDEX(u.nom) != SOUNDEX(ia.nom_patro) AND SOUNDEX(CONCAT(ia.particule,u.nom)) != SOUNDEX(ia.nom_patro)) + OR u.prenom != ia.prenom OR (u.promo != ia.promo AND u.promo != ia.promo+1 AND u.promo != ia.promo-1) + ORDER BY u.promo,u.nom,u.prenom'); + $page->assign('diffs', $res->fetchAllAssoc()); + + // gens à l'ax mais pas chez nous + $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 + WHERE u.nom IS NULL'); + $page->assign('mank', $res->fetchAllAssoc()); + + // gens chez nous et pas à l'ax + $res = XDB::query('SELECT promo,nom,prenom FROM auth_user_md5 WHERE matricule_ax IS NULL'); + $page->assign('plus', $res->fetchAllAssoc()); + } + + function handler_deaths(&$page, $promo = 0, $validate = false) { + $page->changeTpl('admin/deces_promo.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Deces'); + + if (!$promo) + $promo = Env::i('promo'); + if (Env::has('sub10')) $promo -= 10; + if (Env::has('sub01')) $promo -= 1; + if (Env::has('add01')) $promo += 1; + if (Env::has('add10')) $promo += 10; + + $page->assign('promo',$promo); + + if ($validate) { + $new_deces = array(); + $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::v($mat); + if($val == $deces || empty($val)) continue; + 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'); + register_watch_op($uid, WATCH_DEATH, $val); + require_once('user.func.inc.php'); + user_clear_all_subs($uid, false); // by default, dead ppl do not loose their email + } + } + $page->assign('new_deces',$new_deces); + } + + $res = XDB::iterator('SELECT matricule, nom, prenom, deces FROM auth_user_md5 WHERE promo = {?} ORDER BY nom,prenom', $promo); + $page->assign('decedes', $res); + } + + function handler_synchro_ax(&$page, $user = null, $action = null) { + $page->changeTpl('admin/synchro_ax.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Synchro AX'); + + require_once('synchro_ax.inc.php'); + + if (is_ax_key_missing()) { + $page->assign('no_private_key', true); + $page->run(); + } + + require_once('user.func.inc.php'); + + if ($user) + $login = get_user_forlife($user); + + if (Env::has('user')) { + $login = get_user_forlife(Env::v('user')); + if ($login === false) { + return; + } + } + + if (Env::has('mat')) { + $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') + WHERE matricule={?}", Env::i('mat')); + $login = $res->fetchOneCell(); + } + + if ($login) { + if ($action == 'import') { + ax_synchronize($login, S::v('uid')); + } + // get details from user, but looking only info that can be seen by ax + $user = get_user_details($login, S::v('uid'), 'ax'); + $userax= get_user_ax($user['matricule_ax']); + require_once 'profil.func.inc.php'; + $diff = diff_user_details($userax, $user, 'ax'); + + $page->assign('x', $user); + $page->assign('diff', $diff); + } + } + + function handler_events(&$page, $arch) { + $page->changeTpl('admin/evenements.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Evenements'); + + $arch = $arch == 'archives'; + $evid = Post::i('evt_id'); + $page->assign('arch', $arch); + + switch(Post::v('action')) { + case "Proposer": + XDB::execute('UPDATE evenements SET titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?} WHERE id = {?}', + Post::v('titre'), Post::v('texte'), Post::v('peremption'), Post::v('promo_min'), Post::v('promo_max'), $evid); + break; + + case "Valider": + XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",valide") WHERE id = {?}', $evid); + break; + + case "Invalider": + XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"valide", "") WHERE id = {?}', $evid); + break; + + case "Supprimer": + XDB::execute('DELETE from evenements WHERE id = {?}', $evid); + break; + + case "Archiver": + XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",archive") WHERE id = {?}', $evid); + break; + + case "Desarchiver": + XDB::execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"archive","") WHERE id = {?}', $evid); + break; + + case "Editer": + $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); + $page->assign('texte',$texte); + $page->assign('promo_min',$promo_min); + $page->assign('promo_max',$promo_max); + $page->assign('peremption',$peremption); + + $select = ""; + for ($i = 1 ; $i < 30 ; $i++) { + $p_stamp=date("Ymd",time()+3600*24*$i); + $year=substr($p_stamp,0,4); + $month=substr($p_stamp,4,2); + $day=substr($p_stamp,6,2); + + $select .= "\n"; + } + $page->assign('select',$select); + + break; + } + + if ($action != "Editer") { + + $sql = "SELECT e.id, e.titre, e.texte, + DATE_FORMAT(e.creation_date,'%d/%m/%Y %T') AS creation_date, + DATE_FORMAT(e.peremption,'%d/%m/%Y') AS peremption, + e.promo_min, e.promo_max, + FIND_IN_SET('valide', e.flags) AS fvalide, + FIND_IN_SET('archive', e.flags) AS farch, + u.promo, u.nom, u.prenom, a.alias AS forlife + FROM evenements AS e + INNER JOIN auth_user_md5 AS u ON(e.user_id = u.user_id) + 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', XDB::iterator($sql)); + } + } + + function handler_newsletter(&$page, $new = false) { + $page->changeTpl('admin/newsletter.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : liste'); + require_once("newsletter.inc.php"); + + if($new) { + insert_new_nl(); + pl_redirect("admin/newsletter"); + } + + $page->assign_by_ref('nl_list', get_nl_slist()); + } + + function handler_newsletter_edit(&$page, $nid = 'last', $aid = null, $action = 'edit') { + $page->changeTpl('admin/newsletter_edit.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Edition'); + require_once("newsletter.inc.php"); + + $nl = new NewsLetter($nid); + + if($action == 'delete') { + $nl->delArticle($aid); + pl_redirect("admin/newsletter/edit/$nid"); + } + + if($aid == 'update') { + $nl->_title = Post::v('title'); + $nl->_date = Post::v('date'); + $nl->_head = Post::v('head'); + $nl->save(); + } + + if(Post::v('save')) { + $art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'), + $aid, Post::v('cid'), Post::v('pos')); + $nl->saveArticle($art); + pl_redirect("admin/newsletter/edit/$nid"); + } + + if($action == 'edit') { + $eaid = $aid; + if(Post::has('title')) { + $art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'), + $eaid, Post::v('cid'), Post::v('pos')); + } else { + $art = ($eaid == 'new') ? new NLArticle() : $nl->getArt($eaid); + } + $page->assign('art', $art); + } + + $page->assign_by_ref('nl',$nl); + } + + function handler_lists(&$page) { + $page->changeTpl('admin/lists.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists'); + require_once 'lists.inc.php'; + + $client =& lists_xmlrpc(S::v('uid'), S::v('password')); + $listes = $client->get_all_lists(); + $page->assign_by_ref('listes',$listes); + } + + function handler_validate(&$page) { + $page->changeTpl('admin/valider.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Valider une demande'); + require_once("validations.inc.php"); + + if(Env::has('uid') && Env::has('type') && Env::has('stamp')) { + $req = Validate::get_request(Env::v('uid'), Env::v('type'), Env::v('stamp')); + if($req) { $req->handle_formu(); } + } + + $page->assign('vit', new ValidateIterator()); + } + + function handler_geoloc(&$page, $action = false) { + $page->changeTpl('admin/geoloc.tpl'); + require_once("geoloc.inc.php"); + $page->assign('xorg_title','Polytechnique.org - Administration - Geolocalisation'); + + $nb_synchro = 0; + + if (Env::has('id') && is_numeric(Env::v('id'))) { + if (synchro_city(Env::v('id'))) $nb_synchro ++; + } + + if ($action == 'missinglat') { + $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 = XDB::query("SELECT COUNT(*) FROM geoloc_city WHERE lat = 0 AND lon = 0"); + $page->assign("nb_missinglat", $res->fetchOneCell()); + } + + function handler_geoloc_dynamap(&$page, $action = false) { + $page->changeTpl('admin/geoloc_dynamap.tpl'); + + if ($action == 'cities_not_on_map') { + require_once('geoloc.inc.php'); + if (!fix_cities_not_on_map(20)) + $page->trig("Impossible d'accéder au webservice"); + else + $refresh = true; + } + + if ($action == 'smallest_maps') { + require_once('geoloc.inc.php'); + set_smallest_levels(); + } + + if ($action == 'precise_coordinates') { + 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 ($action == 'newmaps') { + require_once('geoloc.inc.php'); + if (!get_new_maps(Env::v('url'))) + $page->trig("Impossible d'accéder aux nouvelles cartes"); + } + + $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 = 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 = XDB::query("SELECT COUNT(*) FROM adresses WHERE cityid IS NOT NULL AND glat = 0 AND glng = 0"); + $noCoordinates = $countNoCoordinates->fetchOneCell(); + + if (isset($refresh) && $missing) { + $page->assign("xorg_extra_header", ""); + } + $page->assign("nb_cities_not_on_map", $missing); + $page->assign("no_smallest", $noSmallest); + $page->assign("no_coordinates", $noCoordinates); + } + + function handler_trombino(&$page, $uid = null, $action = null) { + $page->changeTpl('admin/admin_trombino.tpl'); + $page->assign('xorg_title','Polytechnique.org - Administration - Trombino'); + $page->assign('uid', $uid); + + $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' ) + WHERE user_id = {?}", $uid); + list($forlife, $promo) = $q->fetchOneRow(); + + switch ($action) { + + case "original": + header("Content-type: image/jpeg"); + readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg"); + exit; + break; + + case "new": + $data = file_get_contents($_FILES['userfile']['tmp_name']); + list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']); + $mimetype = substr($_FILES['userfile']['type'], 6); + unlink($_FILES['userfile']['tmp_name']); + XDB::execute( + "REPLACE INTO photo SET uid={?}, attachmime = {?}, attach={?}, x={?}, y={?}", + $uid, $mimetype, $data, $x, $y); + break; + + case "delete": + XDB::execute('DELETE FROM photo WHERE uid = {?}', $uid); + break; + } + + $page->assign('forlife', $forlife); + } + +} + +?> diff --git a/templates/admin/admin_trombino.tpl b/templates/admin/admin_trombino.tpl index 41c1c70..a8bb15b 100644 --- a/templates/admin/admin_trombino.tpl +++ b/templates/admin/admin_trombino.tpl @@ -33,17 +33,15 @@ Photo actuelle de {$forlife}

-Supprimer cette photo +Supprimer cette photo

-Voir sa photo de trombi récupérée à l'école (si disponible) +Voir sa photo de trombi récupérée à l'école (si disponible)

-
+
- -
diff --git a/templates/admin/deces_promo.tpl b/templates/admin/deces_promo.tpl index 980c687..f34996f 100644 --- a/templates/admin/deces_promo.tpl +++ b/templates/admin/deces_promo.tpl @@ -26,7 +26,7 @@

Ajout du décès de {$i.name} le {$i.date}.

{/foreach} - +
@@ -48,7 +48,7 @@
-
+ @@ -64,8 +64,7 @@ {/iterate}
Nom
- - +
diff --git a/templates/admin/emails_bounces_re.tpl b/templates/admin/emails_bounces_re.tpl index 666552d..0711277 100644 --- a/templates/admin/emails_bounces_re.tpl +++ b/templates/admin/emails_bounces_re.tpl @@ -33,13 +33,13 @@ Rappel sur les niveaux : - + - {if $smarty.get.new} + {if $new} {/if} diff --git a/templates/admin/evenements.tpl b/templates/admin/evenements.tpl index c5771fc..ed9f8f5 100644 --- a/templates/admin/evenements.tpl +++ b/templates/admin/evenements.tpl @@ -24,10 +24,10 @@

Gestion des événements : - {if $arch} - [ Actualités | Archives ] + {if $arch eq 'archives'} + [ Actualités | Archives ] {else} - [ Actualités | Archives ] + [ Actualités | Archives ] {/if}

@@ -63,10 +63,9 @@ @@ -72,7 +72,7 @@ {elseif $op eq 'mail-conf'} - +
Position/Niveau Regexp/Raison
@@ -61,7 +61,7 @@ Rappel sur les niveaux : {else}
- nouveau + nouveau
- +
- {if $ev.farch} {else} diff --git a/templates/admin/geoloc.tpl b/templates/admin/geoloc.tpl index e303841..898101e 100644 --- a/templates/admin/geoloc.tpl +++ b/templates/admin/geoloc.tpl @@ -25,10 +25,10 @@

Synchroniser des villes avec geoloc.org

{if $nb_missinglat} -

[toutes les villes sans coordonnées ({$nb_missinglat})]

+

[toutes les villes sans coordonnées ({$nb_missinglat})]

{/if} - +

La ville dont l'id est :

diff --git a/templates/admin/geoloc_dynamap.tpl b/templates/admin/geoloc_dynamap.tpl index 03e97d1..e3944ac 100644 --- a/templates/admin/geoloc_dynamap.tpl +++ b/templates/admin/geoloc_dynamap.tpl @@ -27,11 +27,11 @@

Utiliser de nouvelles cartes

- +


- +

@@ -41,14 +41,14 @@ {if $nb_cities_not_on_map}

Il y a {$nb_cities_not_on_map} villes qui ne sont pas placées dans les cartes. - [Réparer] + [Réparer]

{else}

Toutes les villes de la base sont placées dans des cartes.

{/if} {if $no_smallest}

- Il faut définir la plus petite carte + Il faut définir la plus petite carte pour chaque ville (à ne faire qu'une fois quand on a placé toutes les villes).

{/if} @@ -58,7 +58,7 @@

{$no_coordinates} adresses n'ont pas été bien reconnues précisément. - [Mettre les coordonnées du centre de la ville] + [Mettre les coordonnées du centre de la ville]

{/if} {* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/admin/homonymes.tpl b/templates/admin/homonymes.tpl index ab4dbb6..19100db 100644 --- a/templates/admin/homonymes.tpl +++ b/templates/admin/homonymes.tpl @@ -59,10 +59,10 @@
{$user.expire|date_format} fiche - edit + edit {if $user.type eq 'alias'} - mailer - corriger + mailer + corriger {/if}
@@ -99,8 +99,6 @@ L' @@ -109,7 +107,7 @@ L' {elseif $op eq 'correct-conf'} - +
Envoyer un mail pour prévenir l'utilisateur
- -
@@ -136,8 +134,6 @@ L' diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index ee1d024..6512257 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -1,46 +1,129 @@ {**************************************************************************} -{* *} -{* Copyright (C) 2003-2006 Polytechnique.org *} -{* http://opensource.polytechnique.org/ *} -{* *} +{* *} +{* Copyright (C) 2003-2006 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} {* This program is free software; you can redistribute it and/or modify *} {* it under the terms of the GNU General Public License as published by *} -{* the Free Software Foundation; either version 2 of the License, or *} -{* (at your option) any later version. *} -{* *} -{* This program is distributed in the hope that it will be useful, *} -{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} -{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} -{* GNU General Public License for more details. *} -{* *} -{* You should have received a copy of the GNU General Public License *} -{* along with this program; if not, write to the Free Software *} -{* Foundation, Inc., *} -{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} -{* *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} {**************************************************************************} -

Administration Polytechnique.org

-{foreach from=$index key=h1 item=index2}
Mettre en place le robot {$loginbis}@polytechnique.org
- -
- - {foreach from=$index2 key=h2 item=index3} - + + + + + - {/foreach}
{$h1}
Système
+ Postfix :   + Blacklist +   |   + Whitelist +   |   + Retardés +   |   + Regexps Bounces +
- {$h2} :   - {foreach from=$index3 item=ln name=ln} - {$ln.txt} - {if !$smarty.foreach.ln.last} + Sécurité :   + Logs des sessions   |   - {/if} - {/foreach} + Actions
+
-{/foreach} + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Contenu du site
+ Utilisateurs :   + Edit/Su/Logs +   |   + Homonymes +   |   + AX/X.org +   |   + Décès +   |   + Synchro AX +
+ Infos dynamiques :   + Coupures +
+ Champs profil :   + Formations +   |   + Binets +   |   + Groupes X +   |   + Skins +   |   + Décorations +
+ Newsletter :   + Liste +   |   + Catégories +
+ Administrer :   + Auth Groupes X +   |   + Listes +
+ Valider demandes :   + Valider +   |   + Événements +
+ Trésorerie :   + Comptes +   |   + Paiements +
+ Géoloc :   + Synchro +   |   + Dynamap +
{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/admin/newsletter.tpl b/templates/admin/newsletter.tpl index b483b34..ec3edbc 100644 --- a/templates/admin/newsletter.tpl +++ b/templates/admin/newsletter.tpl @@ -31,13 +31,13 @@ titre - Créer une nouvelle lettre + Créer une nouvelle lettre {foreach item=nl from=$nl_list} {$nl.date|date_format} - {$nl.titre|default:"[no title]"} + {$nl.titre|default:"[no title]"} {/foreach} diff --git a/templates/admin/newsletter_edit.tpl b/templates/admin/newsletter_edit.tpl index f18fd85..b19bfa3 100644 --- a/templates/admin/newsletter_edit.tpl +++ b/templates/admin/newsletter_edit.tpl @@ -27,11 +27,11 @@ {if !$art}

-[liste] +[liste] [visualiser]

- +
@@ -72,7 +72,7 @@
- +
@@ -86,7 +86,7 @@ Créer un nouvel article ... - [créer] + [créer] {foreach from=$nl->_arts item=arts key=cat} @@ -103,8 +103,8 @@ Pos: {$art->_pos}
- [edit]
- [delete] + [edit]
+ [delete] {/foreach} @@ -114,7 +114,7 @@ {else}

-[retour] +[retour]

{if !$art->check()}

article trop long !

{/if} @@ -135,12 +135,11 @@
- + diff --git a/templates/admin/postfix_delayed.tpl b/templates/admin/postfix_delayed.tpl index 04de022..8ae554b 100644 --- a/templates/admin/postfix_delayed.tpl +++ b/templates/admin/postfix_delayed.tpl @@ -39,7 +39,7 @@
Editer un article -
{$m.create_time|date_format} {if $m.del}Poubelle{elseif $m.ok}Autorisé{else}En attente{/if} - +
diff --git a/templates/admin/synchro_ax.tpl b/templates/admin/synchro_ax.tpl index be3c2a1..a429f86 100644 --- a/templates/admin/synchro_ax.tpl +++ b/templates/admin/synchro_ax.tpl @@ -29,7 +29,7 @@ Impossible d'utiliser ce service, il manque la clef privée AX dans la configuration de plat/al.

{else} - + @@ -43,9 +43,8 @@
Synchroniser un utilisateur
{/if} - -{if $x and !no_private_key} -
+{if $x} + {if $x.profile_from_ax}
Cet utilisateur a accepeté la synchronisation @@ -135,8 +134,7 @@ Emplois {/if}
- - +
{else}
diff --git a/templates/admin/utilisateurs.tpl b/templates/admin/utilisateurs.tpl index a96ba6c..40063a2 100644 --- a/templates/admin/utilisateurs.tpl +++ b/templates/admin/utilisateurs.tpl @@ -33,7 +33,7 @@ Attention, d {if $smarty.post.u_kill_conf} - +
Confirmer la suppression de {$smarty.request.user_id}   @@ -42,7 +42,7 @@ Attention, d {else} -
+
@@ -109,7 +109,7 @@ function act_fwd(fwd, activate) { {/literal} - +
@@ -210,7 +210,7 @@ function act_fwd(fwd, activate) {
- [Trombino] + [Trombino] @@ -222,7 +222,7 @@ function act_fwd(fwd, activate) { Ne pas utiliser [Désinscrire] si le but est d'exclure la personne. Pour ceci changer ses permissions en 'disabled'.

- +
@@ -262,7 +262,7 @@ Pour ceci changer ses permissions en 'disabled'. * à ne modifier qu'avec l'accord express de l'utilisateur !!!

- +
diff --git a/templates/admin/valider.tpl b/templates/admin/valider.tpl index 92cbe95..66d6445 100644 --- a/templates/admin/valider.tpl +++ b/templates/admin/valider.tpl @@ -51,7 +51,7 @@ {/foreach}
- +
@@ -66,7 +66,7 @@
Réponse
rules}> - +
Ajouté dans l'email :

diff --git a/templates/skin/common.menu.tpl b/templates/skin/common.menu.tpl index 6fcc6c8..073c6a0 100644 --- a/templates/skin/common.menu.tpl +++ b/templates/skin/common.menu.tpl @@ -85,7 +85,7 @@ - +
Valid
{insert name="mkStats"}{insert name="mkStats"}
{/if} diff --git a/upgrade/0.9.11/04_admin.sql b/upgrade/0.9.11/04_admin.sql new file mode 100644 index 0000000..18e1360 --- /dev/null +++ b/upgrade/0.9.11/04_admin.sql @@ -0,0 +1 @@ +DROP TABLE admin_a, admin_h1, admin_h2; \ No newline at end of file