{
return array(
'phpinfo' => $this->make_hook('phpinfo', AUTH_MDP, 'admin'),
+ 'get_rights' => $this->make_hook('get_rights', AUTH_MDP, 'admin'),
'admin' => $this->make_hook('default', AUTH_MDP, 'admin'),
'admin/ax-xorg' => $this->make_hook('ax_xorg', AUTH_MDP, 'admin'),
'admin/dead-but-active' => $this->make_hook('dead_but_active', AUTH_MDP, 'admin'),
'admin/wiki' => $this->make_hook('wiki', AUTH_MDP, 'admin'),
'admin/ipwatch' => $this->make_hook('ipwatch', AUTH_MDP, 'admin'),
'admin/icons' => $this->make_hook('icons', AUTH_MDP, 'admin'),
+ 'admin/accounts' => $this->make_hook('accounts', AUTH_MDP, 'admin'),
);
}
exit;
}
+ function handler_get_rights(&$page, $level)
+ {
+ if (S::suid()) {
+ $page->kill('Déjà en SUID');
+ }
+ $user =& S::user();
+ Platal::session()->startSUID($user, $level);
+
+ pl_redirect('/');
+ }
+
function handler_default(&$page)
{
$page->changeTpl('admin/index.tpl');
$page->setTitle('Administration - Edit/Su/Log');
require_once("emails.inc.php");
- if (S::has('suid')) {
+ if (S::suid()) {
$page->kill("Déjà en SUID !!!");
}
}
if(Env::has('suid_button') && $registered) {
- S::logger()->log("suid_start", "login on " . $user->login());
- if (!Platal::session()->startSUID($user->id())) {
+ if (!Platal::session()->startSUID($user)) {
$page->trigError('Impossible d\'effectuer un SUID sur ' . $user->id());
} else {
pl_redirect("");
// Profile edition.
case "u_edit":
// Loads new values from environment.
- require_once('secure_hash.inc.php');
- $pass_encrypted = Env::v('newpass_clair') != "********" ? hash_encrypt(Env::v('newpass_clair')) : Env::v('passw');
+ $pass_encrypted = Env::v('newpass_clair') != "********" ? sha1(Env::v('newpass_clair')) : Env::v('passw');
$naiss = Env::v('naissanceN');
$deces = Env::v('decesN');
$perms = Env::v('permsN');
// Forum ban update.
case "b_edit":
- XDB::execute("DELETE FROM forums.innd WHERE uid = {?}", $user->id());
+ XDB::execute("DELETE FROM forum_innd WHERE uid = {?}", $user->id());
if (Env::v('write_perm') != "" || Env::v('read_perm') != "" || Env::v('commentaire') != "" ) {
- XDB::execute("INSERT INTO forums.innd
+ XDB::execute("INSERT INTO forum_innd
SET ipmin = '0', ipmax = '4294967295',
write_perm = {?}, read_perm = {?},
comment = {?}, priority = '200', uid = {?}",
"SELECT alias
FROM virtual
INNER JOIN virtual_redirect USING (vid)
- WHERE type = 'user' AND redirect LIKE CONCAT({?}, '@%')", $user->id()));
+ WHERE type = 'user' AND (redirect = {?} OR redirect = {?})",
+ $user->forlifeEmail(),
+ // TODO: remove this über-ugly hack. The issue is that you need
+ // to remove all @m4x.org addresses in virtual_redirect first.
+ $user->login() . '@' . $globals->mail->domain2));
$page->assign('aliases', XDB::iterator(
"SELECT alias, type='a_vie' AS for_life,FIND_IN_SET('bestalias',flags) AS best,expire
// Displays forum bans.
$res = XDB::query("SELECT write_perm, read_perm, comment
- FROM forums.innd
+ FROM forum_innd
WHERE uid = {?}", $user->id());
$bans = $res->fetchOneAssoc();
$page->assign('bans', $bans);
$action = Env::v('valid_promo') == 'Ajouter des membres' ? 'add' : 'ax';
pl_redirect('admin/promo/' . $action . '/' . Env::i('promo'));
} else {
- $page->trigError('Promo non valide');
+ $page->trigError('Promotion non valide.');
}
}
{
$page->changeTpl('admin/homonymes.tpl');
$page->setTitle('Administration - Homonymes');
- require_once("homonymes.inc.php");
+ $this->load("homonyms.inc.php");
if ($target) {
- if (! list($prenom,$nom,$forlife,$loginbis) = select_if_homonyme($target)) {
- $target=0;
+ $user = User::getSilent($target);
+ if (!$user || !($loginbis = select_if_homonyme($user))) {
+ $target = 0;
} else {
- $page->assign('nom',$nom);
- $page->assign('prenom',$prenom);
- $page->assign('forlife',$forlife);
+ $page->assign('user', $user);
$page->assign('loginbis',$loginbis);
}
}
case 'mail':
S::assert_xsrf_token();
- send_warning_homonyme($prenom, $nom, $forlife, $loginbis);
- switch_bestalias($target, $loginbis);
+ send_warning_homonyme($user, $loginbis);
+ switch_bestalias($user, $loginbis);
$op = 'list';
- $page->trigSuccess('Email envoyé à ' . $forlife . '.');
+ $page->trigSuccess('Email envoyé à ' . $user->forlifeEmail() . '.');
break;
case 'correct':
S::assert_xsrf_token();
- 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);
+ switch_bestalias($user, $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($user, $loginbis);
$op = 'list';
- $page->trigSuccess('Email envoyé à ' . $forlife . ', alias supprimé.');
+ $page->trigSuccess('Email envoyé à ' . $user->forlifeEmail() . ', alias supprimé.');
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
+ "SELECT a.alias AS homonyme, s.alias AS forlife,
+ IF(h.homonyme_id = s.id, a.expire, NULL) AS expire,
+ IF(h.homonyme_id = s.id, a.type, NULL) AS type,
+ ac.uid AS user_id
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");
+ INNER JOIN accounts AS ac ON (ac.uid = a.id)
+ WHERE a.type = 'homonyme' OR a.expire != ''
+ ORDER BY a.alias, forlife");
$hnymes = Array();
while ($tab = $res->next()) {
$hnymes[$tab['homonyme']][] = $tab;
}
}
- function handler_ax_xorg(&$page) {
+ function handler_ax_xorg(&$page)
+ {
$page->changeTpl('admin/ax-xorg.tpl');
$page->setTitle('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
+ '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)
$page->assign('plus', $res->fetchAllAssoc());
}
- function handler_deaths(&$page, $promo = 0, $validate = false) {
+ function handler_deaths(&$page, $promo = 0, $validate = false)
+ {
$page->changeTpl('admin/deces_promo.tpl');
$page->setTitle('Administration - Deces');
$page->assign('decedes', $res);
}
- function handler_dead_but_active(&$page) {
+ function handler_dead_but_active(&$page)
+ {
$page->changeTpl('admin/dead_but_active.tpl');
$page->setTitle('Administration - Décédés');
$page->assign('dead', $res);
}
- function handler_synchro_ax(&$page, $login = null, $action = null) {
+ function handler_synchro_ax(&$page, $login = null, $action = null)
+ {
$page->changeTpl('admin/synchro_ax.tpl');
$page->setTitle('Administration - Synchro AX');
} else if (Env::has('user')) {
$user = User::get(Env::v('user'));
} else if (Env::has('mat')) {
- $res = XDB::query("SELECT user_id FROM auth_user_md5 WHERE matricule = {?}", Env::i('mat'));
+ $res = XDB::query("SELECT user_id
+ FROM auth_user_md5
+ WHERE matricule = {?}",
+ Env::i('mat'));
$user = User::get($res->fetchOneCell());
} else {
return;
$page->assign('vit', new ValidateIterator());
}
- function handler_validate_answers(&$page, $action = 'list', $id = null) {
+ function handler_validate_answers(&$page, $action = 'list', $id = null)
+ {
$page->setTitle('Administration - Réponses automatiques de validation');
$page->assign('title', 'Gestion des réponses automatiques');
$table_editor = new PLTableEditor('admin/validate/answers','requests_answers','id');
$table_editor->describe('answer','texte',false);
$table_editor->apply($page, $action, $id);
}
- function handler_skins(&$page, $action = 'list', $id = null) {
+
+ function handler_skins(&$page, $action = 'list', $id = null)
+ {
$page->setTitle('Administration - Skins');
$page->assign('title', 'Gestion des skins');
$table_editor = new PLTableEditor('admin/skins','skins','id');
$table_editor->apply($page, $action, $id);
}
- function handler_postfix_blacklist(&$page, $action = 'list', $id = null) {
+ function handler_postfix_blacklist(&$page, $action = 'list', $id = null)
+ {
$page->setTitle('Administration - Postfix : Blacklist');
$page->assign('title', 'Blacklist de postfix');
$table_editor = new PLTableEditor('admin/postfix/blacklist','postfix_blacklist','email', true);
$table_editor->describe('email','email',true);
$table_editor->apply($page, $action, $id);
}
- function handler_postfix_whitelist(&$page, $action = 'list', $id = null) {
+
+ function handler_postfix_whitelist(&$page, $action = 'list', $id = null)
+ {
$page->setTitle('Administration - Postfix : Whitelist');
$page->assign('title', 'Whitelist de postfix');
$table_editor = new PLTableEditor('admin/postfix/whitelist','postfix_whitelist','email', true);
$table_editor->describe('email','email',true);
$table_editor->apply($page, $action, $id);
}
- function handler_mx_broken(&$page, $action = 'list', $id = null) {
+
+ function handler_mx_broken(&$page, $action = 'list', $id = null)
+ {
$page->setTitle('Administration - MX Défaillants');
$page->assign('title', 'MX Défaillant');
$table_editor = new PLTableEditor('admin/mx/broken', 'mx_watch', 'host', true);
$table_editor->describe('text', 'Description du problème', false);
$table_editor->apply($page, $action, $id);
}
- function handler_logger_actions(&$page, $action = 'list', $id = null) {
+
+ function handler_logger_actions(&$page, $action = 'list', $id = null)
+ {
$page->setTitle('Administration - Actions');
$page->assign('title', 'Gestion des actions de logger');
$table_editor = new PLTableEditor('admin/logger/actions','logger.actions','id');
$table_editor->describe('description','description',true);
$table_editor->apply($page, $action, $id);
}
+
function handler_downtime(&$page, $action = 'list', $id = null) {
$page->setTitle('Administration - Coupures');
$page->assign('title', 'Gestion des coupures');
function handler_wiki(&$page, $action = 'list', $wikipage = null, $wikipage2 = null)
{
- if (S::v('core_rss_hash')) {
+ if (S::hasAuthToken()) {
$page->setRssLink('Changement Récents',
- '/Site/AllRecentChanges?action=rss&user=' . S::v('hruid') . '&hash=' . S::v('core_rss_hash'));
+ '/Site/AllRecentChanges?action=rss&user=' . S::v('hruid') . '&hash=' . S::v('token'));
}
// update wiki perms
$sql = "SELECT w.ip, IF(s.ip IS NULL,
IF(w.ip = s2.ip, s2.host, s2.forward_host),
IF(w.ip = s.ip, s.host, s.forward_host)),
- w.mask, w.detection, w.state, u.hruid
+ w.mask, w.detection, w.state, a.hruid
FROM ip_watch AS w
LEFT JOIN logger.sessions AS s ON (s.ip = w.ip)
LEFT JOIN logger.sessions AS s2 ON (s2.forward_ip = w.ip)
- LEFT JOIN auth_user_md5 AS u ON (u.user_id = s.uid)
- GROUP BY w.ip, u.hruid
- ORDER BY w.state, w.ip, u.hruid";
+ LEFT JOIN accounts AS a ON (a.uid = s.uid)
+ GROUP BY w.ip, a.hruid
+ ORDER BY w.state, w.ip, a.hruid";
$it = Xdb::iterRow($sql);
$table = array();
$page->assign('table', $table);
} elseif ($action == 'edit') {
$sql = "SELECT w.detection, w.state, w.last, w.description, w.mask,
- u1.hruid AS edit, u2.hruid AS hruid, s.host
+ a1.hruid AS edit, a2.hruid AS hruid, s.host
FROM ip_watch AS w
- LEFT JOIN auth_user_md5 AS u1 ON (u1.user_id = w.uid)
+ LEFT JOIN accounts AS a1 ON (a1.uid = w.uid)
LEFT JOIN logger.sessions AS s ON (w.ip = s.ip)
- LEFT JOIN auth_user_md5 AS u2 ON (u2.user_id = s.uid)
+ LEFT JOIN accounts AS a2 ON (a2.uid = s.uid)
WHERE w.ip = {?}
- GROUP BY u2.hruid
- ORDER BY u2.hruid";
+ GROUP BY a2.hruid
+ ORDER BY a2.hruid";
$it = Xdb::iterRow($sql, ip_to_uint($ip));
$props = array();
sort($icons);
$page->assign('icons', $icons);
}
+
+ function handler_accounts(&$page)
+ {
+ $page->changeTpl('admin/accounts.tpl');
+ $page->assign('disabled', XDB::iterator('SELECT a.hruid, FIND_IN_SET(\'watch\', a.flags) AS watch,
+ a.state = \'disabled\' AS disabled, a.comment
+ FROM accounts AS a
+ WHERE a.state = \'disabled\' OR FIND_IN_SET(\'watch\', a.flags)
+ ORDER BY a.hruid'));
+ $page->assign('admins', XDB::iterator('SELECT a.hruid
+ FROM accounts AS a
+ WHERE a.is_admin
+ ORDER BY a.hruid'));
+ }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: