Gestion plus propre du htdocs/.htaccess
[platal.git] / include / xorg.misc.inc.php
index e6bf429..37525b8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
+ *  Copyright (C) 2003-2007 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -110,4 +110,32 @@ function make_forlife($prenom,$nom,$promo) {
     $forlife = str_replace("'","",$forlife);
     return $forlife;
 }
+
+function check_ip($level)
+{   
+    $test = array();
+    switch ($level) {
+      case 'unsafe': $test[] = "state = 'unsafe'";
+      case 'dangerous': $test[] = "state = 'dangerous'";
+      case 'ban': $test[] = "state = 'ban'"; break;
+      default: return false;
+    }
+    $res = XDB::query("SELECT  state
+                         FROM  ip_watch
+                        WHERE  ip = {?} AND (" . implode(' OR ', $test) . ')',
+                      $_SERVER['REMOTE_ADDR']);
+    return $res->numRows();
+}
+
+function send_warning_mail($title)
+{
+    $mailer = new PlMailer();
+    $mailer->setFrom("webmaster@polytechnique.org");
+    $mailer->addTo("hotliners@staff.polytechnique.org");
+    $mailer->setSubject($title);
+    $mailer->setTxtBody("Identifiants de session :\n" . var_export($_SESSION, true) . "\n\n"
+                       ."Identifiants de connexion :\n" . var_export($_SERVER, true));
+    $mailer->send(); 
+}
+
 ?>