-define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/');
-
-require (JIRAFEAU_ROOT . 'lib/config.original.php');
-require (JIRAFEAU_ROOT . 'lib/settings.php');
-require (JIRAFEAU_ROOT . 'lib/functions.php');
-require (JIRAFEAU_ROOT . 'lib/lang.php');
-require (JIRAFEAU_ROOT . 'lib/template/header.php');
-
-check_errors ();
-if (has_error ())
-{
- show_errors ();
- require (JIRAFEAU_ROOT . 'lib/template/footer.php');
+define('JIRAFEAU_ROOT', dirname(__FILE__) . '/');
+
+require(JIRAFEAU_ROOT . 'lib/settings.php');
+require(JIRAFEAU_ROOT . 'lib/functions.php');
+require(JIRAFEAU_ROOT . 'lib/lang.php');
+
+check_errors($cfg);
+if (has_error()) {
+ show_errors();
+ require(JIRAFEAU_ROOT . 'lib/template/footer.php');
+ exit;
+}
+
+require(JIRAFEAU_ROOT . 'lib/template/header.php');
+
+/* Check if user is allowed to upload. */
+if (!jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) {
+ echo '<div class="error"><p>' . t('Access denied') . '</p></div>';
+ require(JIRAFEAU_ROOT.'lib/template/footer.php');