function __autoload($class) { if (file_exists(LIB . $class . EXT)) { require LIB . $class . EXT; } else { $dir = dir(LIB); while (false !== ($entry = $dir->read())) { if ($entry != "." && $entry != ".." && $entry != "igrape" && $entry == $class) { if (file_exists(LIB . $class . DS . $class . EXT)) { require LIB . $class . DS . $class . EXT; } else { iGrape::invalidModel(); exit; } } } $dir->close(); } }
function iGrape($cmd) { global $conf; $args = explode('/', $cmd); if (empty($args[0])) { if (!defined('INDEX')) { define('INDEX', $conf['index_page']); } $args = explode('/', INDEX); //}elseif($args[0] == LOGOUT_TRIGGER) } elseif ($args[0] == LOGOUT_TRIGGER) { unset($this); session_destroy(); reload('/'); } // Instantiate the model $_model = iGrape::loadModel($args[0]); $_model->model = empty($args[1]) ? 'index' : $args[1]; if ($_model->model[0] == "_" || is_callable(array('Model', $_model->model))) { iGrape::invalidModel(); } //$_model->$testtttt; // Instantiate the controller $_controller = iGrape::loadController($args[0]); $_controller->action = empty($args[1]) ? 'index' : $args[1]; // set up the parameters for ($i = 2; $i < count($args); $i++) { $_controller->argv[] = $args[$i]; } // check if data was submitted, populate the $data field if (isset($_POST)) { $_controller->form = $_POST; unset($_POST); } // Security-paranoia if ($_controller->action[0] == "_" || is_callable(array('Controller', $_controller->action))) { iGrape::invalidAction(); } if (is_callable(array(&$_controller, $_controller->action))) { call_user_func_array(array(&$_controller, $_controller->action), $_controller->argv); } else { $_controller->missing(); } $_controller->render(); }