X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fxorg.misc.inc.php;h=b025e7a465e3ddaee6d5f2f3994bfad8ccd01af7;hb=61e0e8619a9e391d9536d1af3c8cd441491bbc99;hp=5c72a2a4cac99edbc99dbff66455440465389d39;hpb=dd9bac8f7903e9924525ad8db3e38650ff5ad1b6;p=platal.git diff --git a/include/xorg.misc.inc.php b/include/xorg.misc.inc.php index 5c72a2a..b025e7a 100644 --- a/include/xorg.misc.inc.php +++ b/include/xorg.misc.inc.php @@ -155,12 +155,14 @@ function soundex_fr($sIn) static $convVIn, $convVOut, $convGuIn, $convGuOut, $accents; if (!isset($convGuIn)) { global $uc_convert, $lc_convert; - $convGuIn = array( 'GUI', 'GUE', 'GA', 'GO', 'GU', 'SC', 'CA', 'CO', 'CU', 'QU', 'Q', 'CC', 'CK', 'G', 'ST', 'PH'); - $convGuOut = array( 'KI', 'KE', 'KA', 'KO', 'KU', 'SK', 'KA', 'KO', 'KU', 'K', 'K', 'K', 'K', 'J', 'T', 'F'); + $convGuIn = array( 'GUI', 'GUE', 'GA', 'GO', 'GU', 'SCI', 'SCE', 'SC', 'CA', 'CO', + 'CU', 'QU', 'Q', 'CC', 'CK', 'G', 'ST', 'PH'); + $convGuOut = array( 'KI', 'KE', 'KA', 'KO', 'K', 'SI', 'SE', 'SK', 'KA', 'KO', + 'KU', 'K', 'K', 'K', 'K', 'J', 'T', 'F'); $convVIn = array( '/E?(AU)/', '/([EA])?[UI]([NM])([^EAIOUY]|$)/', '/[AE]O?[NM]([^AEIOUY]|$)/', '/[EA][IY]([NM]?[^NM]|$)/', '/(^|[^OEUIA])(OEU|OE|EU)([^OEUIA]|$)/', '/OI/', '/(ILLE?|I)/', '/O(U|W)/', '/O[NM]($|[^EAOUIY])/', '/(SC|S|C)H/', - '/([^AEIOUY1])[^AEIOUYLKTP]([UAO])([^AEIOUY])/', '/([^AEIOUY]|^)([AUO])[^AEIOUYLKTP]([^AEIOUY1])/', '/^KN/', + '/([^AEIOUY1])[^AEIOUYLKTPNR]([UAO])([^AEIOUY])/', '/([^AEIOUY]|^)([AUO])[^AEIOUYLKTP]([^AEIOUY1])/', '/^KN/', '/^PF/', '/C([^AEIOUY]|$)/', '/C/', '/Z$/', '/(?>= 8; + } + return $v; +} + +/** Convert uint to ip (to build a human understandable ip) + */ +function uint_to_ip($uint) +{ + return long2ip($uint); +} + + +/****************************************************************************** + * Security functions + *****************************************************************************/ + function check_ip($level) { if (empty($_SERVER['REMOTE_ADDR'])) { @@ -240,14 +268,16 @@ function check_ip($level) } $ips[] = $_SERVER['REMOTE_ADDR']; foreach ($ips as &$ip) { - $ip = "ip LIKE " . XDB::escape($ip); + $ip = '(ip & mask) = (' . ip_to_uint($ip) . '& mask)'; } - $res = XDB::query('SELECT state + $res = XDB::query('SELECT state, description FROM ip_watch WHERE ' . implode(' OR ', $ips) . ' ORDER BY state DESC'); if ($res->numRows()) { - $_SESSION['check_ip'] = $res->fetchOneCell(); + $state = $res->fetchOneAssoc(); + $_SESSION['check_ip'] = $state['state']; + $_SESSION['check_ip_desc'] = $state['description']; } else { $_SESSION['check_ip'] = 'safe'; } @@ -285,8 +315,10 @@ function check_redirect($red = null) if (is_null($red)) { $red = new Redirect(S::v('uid')); } - $_SESSION['no_redirect'] = !$red->other_active(''); - $_SESSION['mx_failures'] = $red->get_broken_mx(); + if ($red->get_uid() == S::v('uid')) { + $_SESSION['no_redirect'] = !$red->other_active(''); + $_SESSION['mx_failures'] = $red->get_broken_mx(); + } } function send_warning_mail($title) @@ -301,6 +333,17 @@ function send_warning_mail($title) $mailer->send(); } +function kill_sessions() +{ + assert(S::has_perms()); + shell_exec('sudo -u root ' . dirname(dirname(__FILE__)) . '/bin/kill_sessions.sh'); +} + + +/****************************************************************************** + * Dynamic configuration update/edition stuff + *****************************************************************************/ + function update_NbIns() { global $globals;