public function login() { TemplateEngine::appendPath(__DIR__ . '/../../../../views/auth'); if (Input::exists(Input::POST, $this->usersFields['username']) && Input::exists(Input::POST, $this->usersFields['password'])) { return $this->authLocalPassword(Input::post($this->usersFields['username']), Input::post($this->usersFields['password'])); } else { return false; } }
public function rest($path) { View::setLayout('plain'); View::setTemplate('api'); $model = $this->getModel($path); $model->limit(Input::get('limit')); $model->offset((Input::get('page') - 1) * Input::get('limit')); header("X-Item-Count: " . $model->count()); View::set('response', $model->fetch()->toArray()); }
private function getLink($index) { if ($this->parameters['query'] == '') { $link = $this->parameters['base_url'] . $index; } else { $link = $this->parameters['base_url'] . '?'; $get = Input::get(); foreach ($get as $key => $value) { if ($key == $this->parameters['query']) { continue; } $link .= "{$key}=" . urlencode($value) . '&'; } $link .= "{$this->parameters['query']}={$index}"; } return $link; }
public function bind(Controller $controller, $type, $name) { $this->bound = false; $object = \ntentan\panie\InjectionContainer::resolve($type); if (is_a($object, '\\ntentan\\Model')) { $fields = $this->getModelFields($object); } else { $fields = $this->getClassFields($object); } $requestData = Input::post() + Input::get(); foreach ($fields as $field) { if (isset($requestData[$field])) { $object->{$field} = $requestData[$field] == '' ? null : $requestData[$field]; $this->bound = true; } } return $object; }
private function loadResource($parameters, $routeName) { if ($routeName == null) { return false; } foreach ($this->routes[$routeName]['parameters']['default'] as $parameter => $value) { // Only set the controller on default route, if no route is presented to the router. if ($routeName == 'default' && $this->route != '' && $parameter == 'controller') { continue; } if (!isset($parameters[$parameter])) { $parameters[$parameter] = $value; } else { if ($parameters[$parameter] === '') { $parameters[$parameter] = $value; } } } $parameters += Input::get() + Input::post(); if (isset($parameters['controller'])) { return $this->loadController($parameters); } return false; }
public function __construct() { parent::__construct(); $this->action = Input::server("REQUEST_URI"); }
public function login() { $this->authMethodInstance = $this->getAuthMethod(); $this->authMethodInstance->setPasswordCryptFunction($this->parameters->get('password_crypt', function ($password, $storedPassword) { return md5($password) == $storedPassword; })); $this->authMethodInstance->setUsersModel($this->parameters->get('users_model')); $userModelFields = $this->parameters->get('users_model_fields'); $this->authMethodInstance->setUsersModelFields($userModelFields); View::set('login_data', [$userModelFields['username'] => Input::post($userModelFields['username']), $userModelFields['password'] => Input::post($userModelFields['password'])]); if ($this->loggedIn()) { $this->performSuccessOperation(); } else { if ($this->authMethodInstance->login()) { Session::set('logged_in', true); $this->performSuccessOperation(); } else { $this->performFailureOperation(); } } }
public static function run() { Session::start(); honam\TemplateEngine::prependPath('views/shared'); honam\TemplateEngine::prependPath('views/layouts'); honam\AssetsLoader::setSiteUrl(Url::path('public')); honam\AssetsLoader::appendSourceDir('assets'); honam\AssetsLoader::setDestinationDir('public'); honam\Helper::setBaseUrl(Url::path('')); self::getRouter()->execute(substr(utils\Input::server('REQUEST_URI'), 1)); }
private function getMethod($path) { $methods = kaikai\Cache::read("controller.{$this->getClassName()}.methods", function () { $class = new ReflectionClass($this); $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC); $results = []; foreach ($methods as $method) { $methodName = $method->getName(); if (substr($methodName, 0, 2) == '__') { continue; } if (array_search($methodName, ['addComponent', 'executeControllerAction', 'setComponentResolverParameters'])) { continue; } $docComments = $this->parseDocComment($method->getDocComment()); $keyName = isset($docComments['action']) ? $docComments['action'] . $docComments['method'] : $methodName; $results[$keyName] = ['name' => $method->getName(), 'binder' => isset($docComments['binder']) ? $docComments['binder'] : controllers\ModelBinderRegister::getDefaultBinderClass()]; } return $results; }); if (isset($methods[$path . utils\Input::server('REQUEST_METHOD')])) { return $methods[$path . utils\Input::server('REQUEST_METHOD')]; } else { if (isset($methods[$path])) { return $methods[$path]; } } return false; }
public function __construct() { \ntentan\honam\TemplateEngine::appendPath(__DIR__ . "/../../templates/menu"); $this->setCurrentUrl(Input::server('REQUEST_URI')); }