<?php use Utils\Database\XDb; //prepare the templates and include all neccessary require_once './lib/common.inc.php'; //Preprocessing if ($error == false) { $cache_id = isset($_REQUEST['cacheid']) ? $_REQUEST['cacheid'] : ''; $target = isset($_REQUEST['target']) ? $_REQUEST['target'] : 'myignores.php'; if ($usr !== false) { //add to caches $rs = XDb::xQuery('SELECT ignorer_count FROM caches WHERE cache_id=\'' . XDb::xEscape($cache_id) . '\''); if ($record = Xdb::xFetchArray($rs)) { XDb::xSql('UPDATE caches SET ignorer_count=\'' . ($record['ignorer_count'] + 1) . '\' WHERE cache_id=\'' . XDb::xEscape($cache_id) . '\''); //add watch XDb::xSql('INSERT INTO `cache_ignore` (`cache_id`, `user_id`) VALUES (\'' . XDb::xEscape($cache_id) . '\', \'' . XDb::xEscape($usr['userid']) . '\')'); //add to user $rs = XDb::xSql('SELECT cache_ignores FROM user WHERE user_id=\'' . XDb::xEscape($usr['userid']) . '\''); $record = XDb::xFetchArray($rs); XDb::xSql('UPDATE user SET cache_ignores=\'' . ($record['cache_ignores'] + 1) . '\' WHERE user_id=\'' . XDb::xEscape($usr['userid']) . '\''); tpl_redirect($target); } } } tpl_BuildTemplate();
if (!($record = Xdb::xFetchArray($rs))) { tpl_set_var("ni_ma_takiego_kesza", tr(ni_ma_takiego_kesza)); tpl_set_var("sekcja_2_start", '<!--'); tpl_set_var("sekcja_2_stop", '-->'); tpl_set_var("sekcja_5_start", ''); tpl_set_var("sekcja_5_stop", ''); $Opensprawdzacz->endzik(); } $cache_id = $record['cache_id']; tpl_set_var("wp_oc", $Opensprawdzacz->cache_wp); tpl_set_var("ikonka_keszyny", '<img src="tpl/stdstyle/images/' . $record['icon_large'] . '" />'); tpl_set_var("cacheid", $record['cache_id']); tpl_set_var("ofner", $record['username']); tpl_set_var("cachename", $record['name']); tpl_set_var("id_uzyszkodnika", $record['user_id']); Xdb::xFreeResults($rs); $wp_rs = XDb::xSql("SELECT `waypoints`.`wp_id`,\n `waypoints`.`type`,\n `waypoints`.`longitude`,\n `waypoints`.`latitude`,\n `waypoints`.`status`,\n `waypoints`.`type`,\n `waypoints`.`opensprawdzacz`\n FROM `waypoints`\n WHERE `cache_id`= ? AND `type` = 3 ", $cache_id); $wp_record = XDb::xFetchArray($wp_rs); if ($wp_record['type'] == 3 && $wp_record['opensprawdzacz'] == 1) { tpl_set_var("sekcja_formularz_opensprawdzacza_start", ''); tpl_set_var("sekcja_formularz_opensprawdzacza_stop", ''); tpl_set_var("okienka", ''); } else { tpl_set_var("okienka", tr('os_nie_ma_w_os')); tpl_set_var("sekcja_formularz_opensprawdzacza_start", '<!--'); tpl_set_var("sekcja_formularz_opensprawdzacza_stop", '-->'); } } XDb::xFreeResults($wp_rs); } // budujemy kod html ktory zostaje wsylany do przegladraki
function handler_duplicated($page, $action = 'list', $email = null) { $page->changeTpl('emails/duplicated.tpl'); $states = array('pending' => 'En attente...', 'safe' => 'Pas d\'inquiétude', 'unsafe' => 'Recherches en cours', 'dangerous' => 'Usurpations par cette adresse'); $page->assign('states', $states); if (Post::has('action')) { S::assert_xsrf_token(); } switch (Post::v('action')) { case 'create': if (trim(Post::v('emailN')) != '') { Xdb::execute('INSERT IGNORE INTO email_watch (email, state, detection, last, uid, description) VALUES ({?}, {?}, CURDATE(), NOW(), {?}, {?})', trim(Post::v('emailN')), Post::v('stateN'), S::i('uid'), Post::v('descriptionN')); } break; case 'edit': Xdb::execute('UPDATE email_watch SET state = {?}, last = NOW(), uid = {?}, description = {?} WHERE email = {?}', Post::v('stateN'), S::i('uid'), Post::v('descriptionN'), Post::v('emailN')); break; default: if ($action == 'delete' && !is_null($email)) { Xdb::execute('DELETE FROM email_watch WHERE email = {?}', $email); } } if ($action != 'create' && $action != 'edit') { $action = 'list'; } $page->assign('action', $action); if ($action == 'list') { $it = XDB::iterRow('SELECT w.email, w.detection, w.state, s.email AS forlife FROM email_watch AS w INNER JOIN email_redirect_account AS r ON (w.email = r.redirect) INNER JOIN email_source_account AS s ON (s.uid = r.uid AND s.type = \'forlife\') ORDER BY w.state, w.email, s.email'); $table = array(); $props = array(); while (list($email, $date, $state, $forlife) = $it->next()) { if (count($props) == 0 || $props['mail'] != $email) { if (count($props) > 0) { $table[] = $props; } $props = array('mail' => $email, 'detection' => $date, 'state' => $state, 'users' => array($forlife)); } else { $props['users'][] = $forlife; } } if (count($props) > 0) { $table[] = $props; } $page->assign('table', $table); } elseif ($action == 'edit') { $it = XDB::iterRow('SELECT w.detection, w.state, w.last, w.description, a.hruid AS edit, s.email AS forlife FROM email_watch AS w INNER JOIN email_redirect_account AS r ON (w.email = r.redirect) INNER JOIN email_source_account AS s ON (s.uid = r.uid AND s.type = \'forlife\') LEFT JOIN accounts AS a ON (w.uid = a.uid) WHERE w.email = {?} ORDER BY s.email', $email); $props = array(); while (list($detection, $state, $last, $description, $edit, $forlife) = $it->next()) { if (count($props) == 0) { $props = array('mail' => $email, 'detection' => $detection, 'state' => $state, 'last' => $last, 'description' => $description, 'edit' => $edit, 'users' => array($forlife)); } else { $props['users'][] = $forlife; } } $page->assign('doublon', $props); } }
function handler_ipwatch($page, $action = 'list', $ip = null) { $page->changeTpl('admin/ipwatcher.tpl'); $states = array('safe' => 'Ne pas surveiller', 'unsafe' => 'Surveiller les inscriptions', 'dangerous' => 'Surveiller tous les accès', 'ban' => 'Bannir cette adresse'); $page->assign('states', $states); switch (Post::v('action')) { case 'create': if (trim(Post::v('ipN')) != '') { S::assert_xsrf_token(); Xdb::execute('INSERT IGNORE INTO ip_watch (ip, mask, state, detection, last, uid, description) VALUES ({?}, {?}, {?}, CURDATE(), NOW(), {?}, {?})', ip_to_uint(trim(Post::v('ipN'))), ip_to_uint(trim(Post::v('maskN'))), Post::v('stateN'), S::i('uid'), Post::v('descriptionN')); } break; case 'edit': S::assert_xsrf_token(); Xdb::execute('UPDATE ip_watch SET state = {?}, last = NOW(), uid = {?}, description = {?}, mask = {?} WHERE ip = {?}', Post::v('stateN'), S::i('uid'), Post::v('descriptionN'), ip_to_uint(Post::v('maskN')), ip_to_uint(Post::v('ipN'))); break; default: if ($action == 'delete' && !is_null($ip)) { S::assert_xsrf_token(); Xdb::execute('DELETE FROM ip_watch WHERE ip = {?}', ip_to_uint($ip)); } } if ($action != 'create' && $action != 'edit') { $action = 'list'; } $page->assign('action', $action); if ($action == 'list') { $sql = "SELECT w.ip, IF(s.ip IS NULL,\n IF(w.ip = s2.ip, s2.host, s2.forward_host),\n IF(w.ip = s.ip, s.host, s.forward_host)),\n w.mask, w.detection, w.state, a.hruid\n FROM ip_watch AS w\n LEFT JOIN log_sessions AS s ON (s.ip = w.ip)\n LEFT JOIN log_sessions AS s2 ON (s2.forward_ip = w.ip)\n LEFT JOIN accounts AS a ON (a.uid = s.uid)\n GROUP BY w.ip, a.hruid\n ORDER BY w.state, w.ip, a.hruid"; $it = Xdb::iterRow($sql); $table = array(); $props = array(); while (list($ip, $host, $mask, $date, $state, $hruid) = $it->next()) { $ip = uint_to_ip($ip); $mask = uint_to_ip($mask); if (count($props) == 0 || $props['ip'] != $ip) { if (count($props) > 0) { $table[] = $props; } $props = array('ip' => $ip, 'mask' => $mask, 'host' => $host, 'detection' => $date, 'state' => $state, 'users' => array($hruid)); } else { $props['users'][] = $hruid; } } if (count($props) > 0) { $table[] = $props; } $page->assign('table', $table); } elseif ($action == 'edit') { $sql = "SELECT w.detection, w.state, w.last, w.description, w.mask,\n a1.hruid AS edit, a2.hruid AS hruid, s.host\n FROM ip_watch AS w\n LEFT JOIN accounts AS a1 ON (a1.uid = w.uid)\n LEFT JOIN log_sessions AS s ON (w.ip = s.ip)\n LEFT JOIN accounts AS a2 ON (a2.uid = s.uid)\n WHERE w.ip = {?}\n GROUP BY a2.hruid\n ORDER BY a2.hruid"; $it = Xdb::iterRow($sql, ip_to_uint($ip)); $props = array(); while (list($detection, $state, $last, $description, $mask, $edit, $hruid, $host) = $it->next()) { if (count($props) == 0) { $props = array('ip' => $ip, 'mask' => uint_to_ip($mask), 'host' => $host, 'detection' => $detection, 'state' => $state, 'last' => $last, 'description' => $description, 'edit' => $edit, 'users' => array($hruid)); } else { $props['users'][] = $hruid; } } $page->assign('ip', $props); } }
} /* * Check dead emails */ if ($panne_level > 0) { $res = XDB::fetchAllAssoc("SELECT r.redirect, a.hruid\n FROM email_redirect_account AS r\n INNER JOIN accounts AS a ON (a.uid = r.uid)\n WHERE r.broken_level = {?} AND r.flags != 'broken'\n ORDER BY a.hruid", $panne_level); if ($res) { echo "Nouvelles adresses en panne detectees :\n"; foreach ($res as $assoc) { echo '* ' . $assoc['redirect'] . ' pour ' . $assoc['hruid'] . "\n"; } echo "\n\n"; Xdb::execute("UPDATE email_redirect_account\n SET flags = 'broken'\n WHERE broken_level = 3"); } Xdb::execute('UPDATE email_redirect_account SET broken_level = {?} WHERE broken_level > {?}', $panne_level, $panne_level); } /* * Retrieve the users with no active redirection, but still one working * inactive redirection. */ if ($opt_verbose) { $res = XDB::fetchAllAssoc("SELECT a.hruid, r2.redirect\n FROM accounts AS a\n LEFT JOIN email_redirect_account AS r1 ON (a.uid = r1.uid AND r1.flags = 'active')\n INNER JOIN email_redirect_account AS r2 ON (a.uid = r2.uid AND r2.flags = 'inactive'\n AND r2.type != 'imap' AND r2.type != 'homonym')\n WHERE r1.uid IS NULL\n GROUP BY a.uid"); if ($res) { echo "Camarades n'ayant plus d'adresses actives, mais ayant une adresse inactive :\n"; foreach ($res as $user) { echo '* ' . $user['redirect'] . ' pour ' . $user['hruid'] . "\n"; } } echo "\n";