/**
 * Created by PhpStorm.
 * User: csibi
 * Date: 2015.02.18.
 * Time: 14:55
 */
function logincrypt($email, $pwd, &$error = false)
{
    $isOk = false;
    $unique_salt = \runner::config("pwd_salt");
    $unique_logarithm = \runner::config("pwd_logarithm");
    $unique_method = \runner::config("pwd_method");
    $input = $email . ";" . $pwd;
    //var_dump(\Routerunner\Crypt::crypter($input, null, null, 0, $unique_salt, $unique_logarithm, $unique_method));
    $SQL = "SELECT pwd, confirm_date FROM member WHERE email = :email";
    if ($result = \Routerunner\Db::query($SQL, array(":email" => $email))) {
        $result = $result[0];
        if (is_null($result["confirm_date"])) {
            $error = "User has not been confirmed!";
        }
        $isOk = \Routerunner\Crypt::checker($input, $result["pwd"], $unique_salt, $unique_logarithm, $unique_method);
        if (!$isOk) {
            $error = "Incorrect password!";
        }
    } else {
        $error = "User is not exists!";
    }
    return $isOk;
}
Exemplo n.º 2
0
 public static function submit($forms, &$errors = array(), &$return_SQL = false, &$return_params = false, &$values = array())
 {
     if (!is_array($forms)) {
         $forms = array($forms);
     }
     foreach ($forms as $frm_name => $form) {
         $flashed = \Routerunner\Routerunner::$slim->flash($form->path . DIRECTORY_SEPARATOR . $form->formname);
         $params = \Routerunner\Bootstrap::$params;
         $halt = false;
         if (isset($flashed, $flashed['fields'])) {
             // check form fields
             $fields = $flashed['fields'];
             $form_fields = array_keys($form->fields);
             if (($_routerunner_form_id_index = array_search($form->id_field, $form_fields)) && ($_routerunner_form_nonce_index = array_search('_routerunner_form_nonce', $form_fields))) {
                 unset($form_fields[$_routerunner_form_id_index], $form_fields[$_routerunner_form_nonce_index]);
             }
             if (\Routerunner\Common::arrDiff($fields, $form_fields)) {
                 // exception
                 $halt = true;
             }
             unset($flashed['fields']);
             // check form params
             /*
             if (\Routerunner\Common::arrDiff($flashed, $form->params)) {
             	// exception
             	$halt = true;
             }
             */
             $form->params = $flashed;
         } else {
             $errors[] = 'Form not exists or the page has been refreshed!';
         }
         $fid = false;
         if (!empty($form->fields[$form->id_field]['value'])) {
             $fid = $form->fields[$form->id_field]['value'];
         }
         if ($fid && !empty($form->fields['_routerunner_form_nonce']['value'])) {
             if (!isset($_SESSION['nonce-' . $fid]) || !\Routerunner\Crypt::checker($form->fields['_routerunner_form_nonce']['value'], $_SESSION['nonce-' . $fid])) {
                 $errors[] = 'Error in form submit or data has been sent already!';
                 $halt = true;
             }
         }
         if (!$halt) {
             unset($form->fields[$form->id_field]);
             unset($form->fields['_routerunner_form_nonce']);
             unset($_SESSION['nonce-' . $fid]);
         }
         $succeed = false;
         if (!$halt) {
             $error_row = isset($form->params['error_format']) ? $form->params['error_format'] : '<p class="err">%s</p>' . PHP_EOL;
             $succeed = true;
             $submit_params = array();
             if (isset($form->unset) && is_array($form->unset)) {
                 foreach ($form->unset as $field) {
                     if (isset($form->fields[$field], $form->fields[$field]["value"])) {
                         $values[$field] = $form->fields[$field]["value"];
                     } elseif (isset($form->fields[$field])) {
                         $values[$field] = $form->fields[$field]["value"];
                     }
                     unset($form->fields[$field]);
                 }
             }
             if (isset($form->set) && is_array($form->set)) {
                 foreach ($form->set as $field => $value) {
                     $values[$field] = $value;
                     $form->fields[$field] = array("field" => $field, "value" => $value);
                 }
             }
             foreach ($form->fields as $field => $field_param) {
                 $field_succeed = true;
                 $values[$field] = null;
                 if (!isset($params[$field]) && isset($field_param['value'])) {
                     $params[$field] = $field_param['value'];
                 }
                 $regexps = isset($field_param['regexp']) ? $field_param['regexp'] : false;
                 if ($regexps && !is_array($regexps)) {
                     $regexps = array($regexps);
                 } elseif (!$regexps) {
                     $regexps = array();
                 }
                 if (!isset($params[$field]) || !$params[$field]) {
                     if (isset($field_param['default_on_fail'], $field_param['default']) && $field_param['default_on_fail']) {
                         $params[$field] = $field_param['default'];
                     } elseif (isset($field_param['errormsg'])) {
                         $errors[$field] = sprintf($error_row, $field_param['errormsg']);
                         if (isset($field_param['mandatory']) && $field_param['mandatory']["value"] === true) {
                             if (isset($field_param['mandatory']['msg']) && !isset($errors[$field])) {
                                 $errors[$field] = sprintf($error_row, $field_param['mandatory']['msg']);
                             }
                             $field_succeed = false;
                             $regexps = array();
                         }
                     } elseif (isset($field_param['mandatory']) && $field_param['mandatory']["value"] === true) {
                         if (isset($field_param['mandatory']['msg']) && !isset($errors[$field])) {
                             $errors[$field] = sprintf($error_row, $field_param['mandatory']['msg']);
                         }
                         $field_succeed = false;
                         $regexps = array();
                     }
                 }
                 foreach ($regexps as $regexp) {
                     $isOk = false;
                     if (is_array($regexp["value"])) {
                         foreach ($regexp["value"] as $regexp_key => $regexp_value) {
                             $pattern = "~" . trim($regexp_value, "/~ ") . "~";
                             if (isset($regexp['options'])) {
                                 $pattern .= is_array($regexp["options"]) && isset($regexp["options"][$regexp_key]) ? $regexp["options"][$regexp_key] : $regexp["options"];
                             }
                             if (preg_match($pattern, $params[$field])) {
                                 $isOk = true;
                             }
                         }
                     } else {
                         $pattern = "~" . trim($regexp["value"], "~/ ") . "~";
                         if (isset($regexp['options'])) {
                             $pattern .= $regexp['options'];
                         }
                         $isOk = preg_match($pattern, $params[$field]);
                     }
                     if (isset($params[$field]) && !$isOk) {
                         if (isset($regexp['msg']) && !isset($errors[$field])) {
                             $errors[$field] = sprintf($error_row, $regexp['msg']);
                         }
                         $field_succeed = false;
                     }
                 }
                 if ($field_succeed) {
                     if (isset($params[$field]) && isset($field_param["field"])) {
                         if (isset($field_param['function']) && function_exists($field_param['function'])) {
                             $fn = $field_param['function'];
                             $submit_params[$field] = $fn($params[$field]);
                         } else {
                             $submit_params[$field] = $params[$field];
                         }
                         $values[$field] = $submit_params[$field];
                     }
                 } else {
                     $succeed = false;
                 }
             }
         }
         if ($succeed) {
             $method = isset($form->params['xmethod']) ? $form->params['xmethod'] : $form->params['method'];
             if (isset($form->params[$method . '_sql'])) {
                 $sql = $form->params[$method . '_sql'];
                 if (preg_match('/\\:[a-z0-9]+/im', $sql)) {
                     // named parameters
                     array_walk($sql_params, function ($value, &$key) {
                         if (substr($key, 0, 1) != ':') {
                             $key = ':' . $key;
                         }
                     });
                 }
             } else {
                 $from = isset($form->params['from']) ? $form->params['from'] : $form->class;
                 $from = \Routerunner\Common::dbField($from);
                 $sql_params = array();
                 if ($method === 'post') {
                     $sql = 'INSERT INTO ' . $from . ' (';
                     $fields = array();
                     foreach ($submit_params as $field => $submit_value) {
                         $field_param = $form->fields[$field];
                         if (isset($params[$field]) && (!isset($field_param['fixed']) || $field_param['fixed'] !== true) && (!isset($field_param['field']) || $field_param['field'] !== false)) {
                             $_field = isset($field_param['field']) ? $field_param['field'] : $field;
                             $fields[] = \Routerunner\Common::dbField($_field);
                             $param_key = \Routerunner\Common::dbField($_field, ':', '', '.', '` .', '.');
                             $sql_params[$param_key] = $submit_value;
                             /*
                             if (isset($submit_params[$field])) {
                             	$sql_params[$param_key] = $submit_params[$field];
                             } else {
                             	$sql_params[$param_key] = $params[$field];
                             }
                             */
                         }
                     }
                     $sql .= implode(', ', $fields) . ') VALUES (' . implode(', ', array_keys($sql_params)) . ')';
                 } elseif ($method == 'put') {
                     $sql = 'UPDATE ' . $from . ' SET ';
                     $fields = array();
                     foreach ($submit_params as $field => $submit_value) {
                         $field_param = $form->fields[$field];
                         if (isset($params[$field]) && (!isset($field_param['fixed']) || $field_param['fixed'] !== true) && (!isset($field_param['field']) || $field_param['field'] !== false)) {
                             $_field = isset($field_param['field']) ? $field_param['field'] : $field;
                             $row = \Routerunner\Common::dbField($_field) . ' = ';
                             $param_key = \Routerunner\Common::dbField($_field, ':', '', '.', '` .', '.');
                             $row .= $param_key;
                             $sql_params[$param_key] = $submit_value;
                             /*
                             if (isset($submit_params[$field])) {
                             	$sql_params[$param_key] = $submit_params[$field];
                             } else {
                             	$sql_params[$param_key] = $params[$field];
                             }
                             */
                             $fields[] = $row;
                         }
                     }
                     $sql .= implode(', ', $fields) . ' WHERE ';
                     if (isset($form->params['condition'])) {
                         $conditions = $form->params['condition'];
                         while ($condition = array_shift($conditions)) {
                             if (!is_array($condition)) {
                                 $condition = array($condition);
                             }
                             $add_condition = true;
                             if (isset($condition[1]) && is_array($condition[1])) {
                                 foreach ($condition[1] as $condition_field => $condition_value) {
                                     if (isset($form->fields[$condition_value]['value'])) {
                                         $sql_params[$condition_field] = $form->fields[$condition_value]['value'];
                                     } else {
                                         $add_condition = false;
                                     }
                                 }
                             } elseif (isset($condition[1])) {
                                 $sql_params[] = $condition[1];
                             } else {
                                 $add_condition = false;
                             }
                             if ($add_condition) {
                                 $sql .= $condition[0];
                                 if (count($conditions) && isset($condition[2])) {
                                     $sql .= ' ' . $condition[2] . ' ';
                                 }
                             }
                         }
                     } else {
                         // exception
                     }
                 } elseif ($method == 'delete') {
                     $sql = 'DELETE FROM ' . $from . ' WHERE ';
                     if (isset($form->params['condition'])) {
                         $conditions = $form->params['condition'];
                         while ($condition = array_shift($conditions)) {
                             if (!is_array($condition)) {
                                 $condition = array($condition);
                             }
                             $add_condition = true;
                             if (isset($condition[1]) && is_array($condition[1])) {
                                 foreach ($condition[1] as $condition_field => $condition_value) {
                                     if (isset($form->fields[$condition_value]['value'])) {
                                         $sql_params[$condition_field] = $form->fields[$condition_value]['value'];
                                     } else {
                                         $add_condition = false;
                                     }
                                 }
                             } elseif (isset($condition[1])) {
                                 $sql_params[] = $condition[1];
                             } else {
                                 $add_condition = false;
                             }
                             if ($add_condition) {
                                 $sql .= $condition[0];
                                 if (count($conditions) && isset($condition[2])) {
                                     $sql .= ' ' . $condition[2] . ' ';
                                 }
                             }
                         }
                     } elseif (isset($submit_params) && $submit_params) {
                         $fields = array();
                         foreach ($submit_params as $field => $submit_value) {
                             $field_param = $form->fields[$field];
                             if (isset($params[$field]) && (!isset($field_param['fixed']) || $field_param['fixed'] !== true) && (!isset($field_param['field']) || $field_param['field'] !== false)) {
                                 $_field = isset($field_param['field']) ? $field_param['field'] : $field;
                                 $row = \Routerunner\Common::dbField($_field) . ' = ';
                                 $param_key = \Routerunner\Common::dbField($_field, ':', '', '.', '` .', '.');
                                 $row .= $param_key;
                                 $sql_params[$param_key] = $submit_value;
                                 /*
                                 if (isset($submit_params[$field])) {
                                 	$sql_params[$param_key] = $submit_params[$field];
                                 } else {
                                 	$sql_params[$param_key] = $params[$field];
                                 }
                                 */
                                 $fields[] = $row;
                             }
                         }
                         $sql .= implode(' AND ', $fields);
                     } else {
                         // exception
                     }
                 }
             }
             if ($return_SQL || $return_params) {
                 $return_SQL = $sql;
                 $return_params = $sql_params;
             } else {
                 \Routerunner\Db::begin_transaction();
                 if ($method === 'post') {
                     $succeed = \Routerunner\Db::insert($sql, $sql_params);
                 } else {
                     \Routerunner\Db::query($sql, $sql_params);
                 }
                 \Routerunner\Db::commit();
             }
         }
     }
     return $succeed;
 }
<?php

/**
 * Created by PhpStorm.
 * User: csibi
 * Date: 2015.02.18.
 * Time: 14:55
 */
$post = $_POST;
$msg = "";
$SQL = "SELECT id, email, confirm_date, licence FROM member WHERE email = :email";
if ($result = \Routerunner\Db::query($SQL, array(":email" => $post["email"]))) {
    $user = $result[0];
    if (is_null($user["confirm_date"])) {
        $msg = "User has not been confirmed!";
    }
    if (!$msg) {
        // confirm generálás
        $secret = uniqid(md5(uniqid('', true)));
        $confirm = 'forgotten/' . implode('/', $user) . '/' . $secret;
        $expire = time() + 2 * 24 * 60 * 60;
        $confirm_hash = \Routerunner\Crypt::crypter($confirm, $expire, $user['id'], 0, $secret);
        $path = runner::config("BASE") . 'admin/forgotten/?' . $user['id'] . '/' . $secret . '/' . $confirm_hash;
        $user["confirm_code"] = $path;
        if ($result = \mail::mailer("/mail/forgotten", $user, null)) {
            $debug = 1;
        } else {
            $msg = "E-mail cannot be sent!";
        }
    }
} else {
 public static function load($context, $model, &$pager = array())
 {
     $from = isset($context["from"]) ? $context["from"] : $model->class;
     $select = array();
     $predefined = array('route', 'class', 'reference', 'table_from', 'table_id', 'permission', 'permissions', 'rewrite', 'url', 'override', 'states', 'owner', 'group', 'other', 'parent', 'prev');
     foreach (array_keys(get_object_vars($model)) as $var) {
         if (!in_array($var, $predefined)) {
             $select[$var] = '`' . $var . '`';
         }
     }
     if (isset($context["select"]) && is_array($context["select"])) {
         foreach ($context["select"] as $var => $field) {
             if (isset($select[$var])) {
                 $select[$var] = $field;
             }
         }
     }
     $leftJoin = isset($context["leftJoin"]) ? $context["leftJoin"] : false;
     $where = isset($context["where"]) ? $context["where"] : false;
     $session = false;
     $change_id = false;
     if (isset($where["session"])) {
         $session = $where["session"];
         unset($where["session"]);
     }
     if (isset($where["change_id"])) {
         $change_id = $where["change_id"];
         unset($where["change_id"]);
     }
     if (isset($where["silent"])) {
         unset($where["silent"]);
     }
     $orderBy = isset($context["orderBy"]) ? $context["orderBy"] : current($select);
     $groupBy = isset($context["groupBy"]) ? $context["groupBy"] : false;
     $limit = isset($context["limit"]) ? $context["limit"] : false;
     $offset = isset($context["offset"]) ? $context["offset"] : false;
     $random = isset($context["random"]) ? $context["random"] : false;
     $pk = isset($context["primary_key"]) ? $context["primary_key"] : false;
     $params = array();
     if (\runner::stack("model_create") && isset($model->route, \runner::stack("model_create")["route"]) && $model->route == \runner::stack("model_create")["route"]) {
         $load = array();
     } else {
         if (isset($where['sections'])) {
             unset($where['sections']);
         }
         if (isset($context["SQL"], $context["SQLhash"]) && \Routerunner\Crypt::checker($context["SQL"], $context["SQLhash"], "SQLchecked")) {
             $SQL = $context["SQL"];
             $params = $where;
         } else {
             $SQL = self::SQL_creator($select, $from, $pk, $leftJoin, $where, $params, $orderBy, $groupBy, $limit, $offset);
         }
         if (\runner::now("debug::model->load") === true) {
             \runner::now("debug::model->load", false);
             echo "debug::model->load" . PHP_EOL . $SQL . PHP_EOL . print_r($params, true);
         }
         $load = \Routerunner\Db::query($SQL, $params);
     }
     if ((!is_array($load) || !count($load)) && (isset($context['blank']) && $context['blank'] === true)) {
         foreach ($select as $field => &$value) {
             $value = '';
         }
         $load = array($select);
     }
     if (isset($model->override) && is_array($model->override) && count($model->override)) {
         if ($load && isset($load[0])) {
             $load[0] = array_merge($load[0], $model->override);
         } elseif ($load) {
             $load = array_merge($load, $model->override);
         } else {
             $load = array($model->override);
         }
     }
     if (is_array($load) && count($load) > 0) {
         $models = self::set_models($load, $model, $pk, $from, $random, $session);
         $model = $models;
         if (isset($context["force_list"]) && $context["force_list"] === true && !is_array($model)) {
             $model = array($model);
         } elseif (isset($context["force_view"]) && $context["force_view"] === true && is_array($model)) {
             $model = array_shift($model);
         }
         if (isset($context['pager']) && is_array($context['pager'])) {
             foreach ($context['pager'] as $pager_section => $pager_params) {
                 if (is_array($pager_params)) {
                     $pager_SQL_params = array();
                     //$pager_params['select'] = (isset($pager_params['select'])) ? $pager_params['select'] : array('c' => 'COUNT(*)');
                     $pager_params['primary_key'] = isset($pager_params['primary_key']) ? $pager_params['primary_key'] : $pk;
                     $pager_params['select'] = isset($pager_params['select']) ? $pager_params['select'] : array($pager_params['primary_key'] => 'id');
                     $pager_params['from'] = isset($pager_params['from']) ? $pager_params['from'] : $from;
                     $pager_params['leftJoin'] = isset($pager_params['leftJoin']) ? $pager_params['leftJoin'] : $leftJoin;
                     $pager_params['where'] = isset($pager_params['where']) ? $pager_params['where'] : $where;
                     $pager_params['orderBy'] = isset($pager_params['orderBy']) ? $pager_params['orderBy'] : $orderBy;
                     $pager_params['groupBy'] = isset($pager_params['groupBy']) ? $pager_params['groupBy'] : $groupBy;
                     $pager_params['limit'] = isset($pager_params['limit']) ? $pager_params['limit'] : false;
                     $pager_params['offset'] = isset($pager_params['offset']) ? $pager_params['offset'] : $offset;
                     $pager_SQL = self::SQL_creator($pager_params['select'], $pager_params['from'], $pager_params['primary_key'], $pager_params['leftJoin'], $pager_params['where'], $pager_SQL_params, $pager_params['orderBy'], $pager_params['groupBy'], $pager_params['limit'], $pager_params['offset']);
                     if ($result = \Routerunner\Db::query($pager_SQL, $pager_SQL_params)) {
                         $pager[$pager_section] = count($result);
                     } else {
                         $pager[$pager_section] = 0;
                     }
                 } else {
                     $pager[$pager_section] = $pager_params;
                 }
             }
         }
         if (\runner::now("debug::model->return") === true) {
             \runner::now("debug::model->return", false);
             var_dump("debug::model->return", $model);
         }
         return $model;
     } elseif (\runner::config('mode') == 'backend' && ($model_create = \runner::stack("model_create")) && $model && isset($model_create["class"]) && substr(get_class($model), strrpos(get_class($model), "\\") + 1) == $model_create["class"]) {
         $return = true;
         if (is_array($model_create)) {
             $created_model = $model;
             if (is_array($model)) {
                 $created_model = $model[0];
             }
             foreach ($model_create as $var_name => $var_value) {
                 if (!isset($created_model->{$var_name}) || $created_model->{$var_name} != $var_value) {
                     $return = false;
                 }
             }
         }
         if (!$return) {
             $model = null;
         }
         return $model;
     } else {
         if (\runner::now("debug::model->return") === true) {
             \runner::now("debug::model->return", false);
             var_dump("debug::model->return", null);
         }
         return null;
     }
 }
<?php

/**
 * Created by PhpStorm.
 * User: csibi
 * Date: 2015.02.18.
 * Time: 14:55
 */
$post = $_POST;
$msg = "";
if (!logincrypt($post["email"], $post["password"], $msg)) {
    echo '<div class="alert alert-danger">' . $msg . '</div>';
} else {
    echo '<div class="alert alert-success">Logged in successfully!</div>';
    $SQL = "SELECT id, email, last_login, last_ip, licence FROM member WHERE email = :email";
    if ($result = \Routerunner\Db::query($SQL, array(":email" => $post["email"]))) {
        $user = $result[0];
        if (isset($post["rememberme"]) && $post["rememberme"]) {
            $user["rememberme"] = true;
        }
        \runner::flash('member', $user);
        $SQL = "UPDATE member SET last_login = :last_login, last_ip = :last_ip WHERE email = :email";
        $params = array(":last_login" => time(), ":last_ip" => $_SERVER["REMOTE_ADDR"], ":email" => $post["email"]);
        \Routerunner\Db::query($SQL, $params);
        \runner::redirect($_SERVER["HTTP_REFERER"]);
    }
}
 public static function siblings($reference, $lang = false, &$find = null)
 {
     $SQL = 'CALL `{PREFIX}tree_siblings`(:reference, :lang, NULL, NULL, :session)';
     $session_id = \runner::stack('session_id');
     if (empty($session_id)) {
         $session_id = 0;
     }
     if ($siblings = \Routerunner\Db::query($SQL, array(':reference' => $reference, ':lang' => $lang ? $lang : NULL, ':session' => $session_id))) {
         if (!is_null($find)) {
             $found = null;
             foreach ($siblings as $index => $sibling) {
                 if ($sibling['reference'] == $find) {
                     $found = $index;
                     break;
                 }
             }
             $find = $found;
         }
         return $siblings;
     }
     return array();
 }
Exemplo n.º 7
0
 public static function escape($str)
 {
     return \Routerunner\Db::escape($str);
 }
<?php

/**
 * Created by PhpStorm.
 * User: csibi
 * Date: 2014.10.23.
 * Time: 16:23
 */
if (\bootstrap::get("url") == "forgotten") {
    $isOk = false;
    $bootstrap = \bootstrap::get();
    if (isset($bootstrap->params) && is_array($bootstrap->params) && count($bootstrap->params) === 1) {
        $params = explode("/", array_shift(array_keys($bootstrap->params)));
        $SQL = "SELECT id, email, confirm_date, licence FROM member WHERE id = :id";
        if ($result = \Routerunner\Db::query($SQL, array(":id" => $params[0]))) {
            $user = $result[0];
            $secret = $params[1];
            $hash = $params[2];
            $SQL_Crypt = 'SELECT hash FROM {PREFIX}crypt WHERE secret = :secret AND keep > UNIX_TIMESTAMP()';
            $params_Crypt = array(':secret' => $hash);
            if ($result_Crypt = \db::query($SQL_Crypt, $params_Crypt)) {
                $crypt_hash = $result_Crypt[0]['hash'];
                $confirm = 'forgotten/' . implode('/', $user) . '/' . $secret;
                if (\Routerunner\Crypt::checker($confirm, $crypt_hash, $secret)) {
                    //\Routerunner\Crypt::delete_crypt($crypt_hash, $confirm);
                    $alphabet = "abcdefghijklmnpqrstuwxyzABCDEFGHIJKLMNPQRSTUWXYZ123456789";
                    $pwd = "";
                    for ($i = 0; $i < 8; $i++) {
                        $n = rand(0, strlen($alphabet) - 1);
                        $pwd .= substr($alphabet, $n, 1);
                    }
 /**
  * Constructor
  * @param  array $arguments Associative array of application settings
  */
 public function __construct($arguments = null, $function = null)
 {
     if (ini_get('xdebug.max_nesting_level')) {
         ini_set('xdebug.max_nesting_level', 200);
     }
     if (!isset($_SESSION["runner"]) && is_array($arguments)) {
         Routerunner::setRunnerParams($arguments);
     }
     if (!self::$loaded) {
         require 'BaseClasses' . DIRECTORY_SEPARATOR . 'BaseRunner.php';
         require 'BaseClasses' . DIRECTORY_SEPARATOR . 'BaseModel.php';
         require 'BaseClasses' . DIRECTORY_SEPARATOR . 'BaseBootstrap.php';
         require 'Tunnel.php';
         require 'Slim' . DIRECTORY_SEPARATOR . 'Slim.php';
         require 'Slim' . DIRECTORY_SEPARATOR . 'RunnerSlim.php';
         \Slim\RunnerSlim::registerAutoloader();
         require 'SlimView.php';
         require_once 'phpquery' . DIRECTORY_SEPARATOR . 'phpQuery.php';
     }
     self::$loaded = true;
     if (isset($arguments) && is_array($arguments)) {
         $this->container['settings'] = array_merge(static::getDefaultSettings(), $arguments);
     } else {
         $this->container['settings'] = static::getDefaultSettings();
     }
     if (isset($_SESSION["routerunner-config"])) {
         $this->container['settings'] = array_merge($_SESSION["routerunner-config"], $this->container['settings']);
     }
     if (isset($this->settings['DOCUMENT_ROOT'])) {
         $site_root = $this->settings['DOCUMENT_ROOT'];
         if (substr($site_root, -1) !== DIRECTORY_SEPARATOR) {
             $site_root .= DIRECTORY_SEPARATOR;
         }
     } else {
         $site_root = rtrim(isset($_SERVER["DOCUMENT_ROOT"]) ? $_SERVER["DOCUMENT_ROOT"] : $this->settings['DOCUMENT_ROOT'], '/\\') . DIRECTORY_SEPARATOR . $this->settings['SITEROOT'];
         if (substr($site_root, -1) !== DIRECTORY_SEPARATOR) {
             $site_root .= DIRECTORY_SEPARATOR;
         }
     }
     $this->container['settings']['SITEROOT'] = $site_root;
     if (!function_exists("backend_mode")) {
         require $site_root . 'runner-config.php';
     }
     Routerunner::$static = $this;
     \Routerunner\Db::initialize($this->settings);
     new \Routerunner\Helper($this);
     \Routerunner\Routerunner::$slim = new \Slim\RunnerSlim(array('view' => new \Routerunner\CustomView(), 'templates.path' => \Routerunner\Helper::$scaffold_class));
     \Routerunner\Routerunner::$slim->notFound(function () {
         return false;
     });
     $method = "get";
     $resource = "/";
     if (!isset($arguments["bootstrap"]) || $arguments["bootstrap"] !== false) {
         \Routerunner\Bootstrap::initialize($this->settings, false);
         $method = \Routerunner\Bootstrap::getMethod();
         $resource = \Routerunner\Bootstrap::getResource();
     }
     if (isset($arguments["method"])) {
         $method = $arguments["method"];
     }
     if (isset($arguments["resource"])) {
         $resource = $arguments["resource"];
     }
     if ($method == "head") {
         $method = "get";
     }
     $routerunner_object = $this;
     \Routerunner\Config::custom_config($this->container['settings']);
     \runner::config("notFound", false);
     if (\Routerunner\Bootstrap::$component) {
         return false;
         exit;
     }
     if (isset($arguments) && isset($function) && !is_string($function) && is_callable($function) && \Routerunner\Routerunner::$slim->now('redirect_url')) {
         $arguments["skip_redirect"] = true;
         $arguments["skip_route"] = true;
         \Routerunner\Routerunner::$slim->{$method}($resource, function () use($routerunner_object, $arguments) {
             $this->middleware($routerunner_object, $arguments);
         }, $function, function () {
             if (\Routerunner\Routerunner::$slim->now('redirect_url')) {
                 \Routerunner\Routerunner::$slim->redirect(\Routerunner\Routerunner::$slim->now('redirect_url'));
             }
         });
         \Routerunner\Routerunner::$slim->run();
     } elseif (isset($arguments) && isset($function) && !is_string($function) && is_callable($function)) {
         $arguments["skip_redirect"] = true;
         $arguments["skip_route"] = true;
         \Routerunner\Routerunner::$slim->{$method}($resource, function () use($routerunner_object, $arguments) {
             $this->middleware($routerunner_object, $arguments);
         }, $function);
         \Routerunner\Routerunner::$slim->notFound(function () use($routerunner_object, $arguments) {
             \runner::config("notFound", true);
             $this->middleware($routerunner_object, $arguments);
         });
         \Routerunner\Routerunner::$slim->run();
     } elseif (isset($arguments) && is_array($arguments) && isset($arguments['root'])) {
         \Routerunner\Routerunner::$slim->{$method}($resource, function () use($routerunner_object, $arguments) {
             $this->middleware($routerunner_object, $arguments);
         });
         \Routerunner\Routerunner::$slim->notFound(function () use($routerunner_object, $arguments) {
             \runner::config("notFound", true);
             $this->middleware($routerunner_object, $arguments);
         });
         \Routerunner\Routerunner::$slim->run();
     } elseif (!is_string($arguments) && is_callable($arguments)) {
         $function = $arguments;
         $arguments = array("skip_redirect" => true, "skip_route" => true);
         \Routerunner\Routerunner::$slim->{$method}($resource, function () use($routerunner_object, $arguments) {
             $this->middleware($routerunner_object, $arguments);
         }, $function, function () {
             if (\Routerunner\Routerunner::$slim->now('redirect_url')) {
                 $this->redirect(\Routerunner\Routerunner::$slim->now('redirect_url'));
             }
         });
         \Routerunner\Routerunner::$slim->notFound(function () use($routerunner_object, $arguments) {
             \runner::config("notFound", true);
             $this->middleware($routerunner_object, $arguments);
         });
         \Routerunner\Routerunner::$slim->run();
     } else {
         $arguments = array("skip_redirect" => true, "skip_route" => true);
         \Routerunner\Routerunner::$slim->{$method}($resource, function () use($routerunner_object, $arguments) {
             $this->middleware($routerunner_object, $arguments);
         });
         \Routerunner\Routerunner::$slim->notFound(function () use($routerunner_object, $arguments) {
             \runner::config("notFound", true);
             $this->middleware($routerunner_object, $arguments);
         });
     }
 }