A foreign email address has to be valid to be added to a ML.
[platal.git] / include / platal.inc.php
index 8402229..cffcb58 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2009 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -21,6 +21,9 @@
 
 $TIME_BEGIN = microtime(true);
 
+require_once dirname(__FILE__) . '/version.inc.php';
+require_once dirname(__FILE__) . '/misc.inc.php';
+
 define('PERMS_EXT',   'ext');
 define('PERMS_USER',  'user');
 define('PERMS_ADMIN', 'admin');
@@ -33,24 +36,26 @@ define('NO_AUTH', 0);
 define('DO_AUTH', 1);
 define('NO_HTTPS', 2);
 
-function pl_autoload($cls)
+function pl_autoload($cls, array $pathes = array())
 {
     $cls  = strtolower($cls);
-    $path = dirname(dirname(__FILE__));
-    if (!@include "$path/classes/$cls.php") {
-        if (substr($cls, -3, 3) == 'req') {
-            @include 'validations.inc.php';
-            return;
-        } else if (substr($cls, 0, 6) == 'banana') {
-            require_once 'banana/banana.inc.php';
-            Banana::load(substr($cls, 6));
-            return;
+    $basepath = dirname(dirname(dirname(__FILE__)));
+
+    array_unshift($pathes, 'core/classes', 'classes');
+    foreach ($pathes as $path) {
+        if (@include_once "$basepath/$path/$cls.php") {
+            return true;
         }
-        @include "$cls.inc.php";
     }
+    return false;
 }
 pl_autoload('Env');
 
+function pl_core_include($file)
+{
+    return dirname(__FILE__) . '/' . $file;
+}
+
 function pl_error_handler($errno, $errstr, $errfile, $errline)
 {
     static $errortype;