public function Fire() { if ($this->input->do == 'fire') { $user = new User(); $user->set_condition('email = :email'); $user->email = $this->input->email; try { $user = $user->Fetch(); } catch (phalanx\data\ModelException $e) { EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('LOGIN_FAILED'))); return; } if ($user->password != md5(sha1($this->input->password) . $user->salt)) { EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('LOGIN_FAILED'))); return; } // We need to set _COOKIE values so that if the last_event requires // authentication, we can return the correct state. $expires = time() + 60 * 60 * 5; $this->_SetCookie('bugdar_user', $user->user_id, $expires); $this->_SetCookie('bugdar_pass', $user->authkey, $expires); $last_event = NULL; if ($this->input->last_event) { $last_event = unserialize(base64_decode($this->input->last_event)); $class = $last_event[0]; $input = $last_event[1]; if (!class_exists($class)) { $path = phalanx\base\CamelCaseToUnderscore($class); $path = preg_replace('/_event$/', '', $path); require_once BUGDAR_ROOT . "/events/{$path}.php"; } $last_event = new $class($input); } $this->successful = TRUE; EventPump::Pump()->PostEvent($last_event ?: new StandardSuccessEvent('home', l10n::S('LOGIN_SUCCESSFUL'))); return; } // Find the first non-UserLoginEvent that was processed. If the event // hasn't been finished, then this event preempted it and we should // store its data so that the user can return to what she was doing. $events = EventPump::Pump()->GetAllEvents(); foreach ($events as $event) { if (!$event instanceof $this && $event->state() != EventPump::EVENT_FINISHED) { $this->last_event = base64_encode(serialize(array(get_class($event), $event->input))); break; } } }
require_once $path; return phalanx\base\UnderscoreToCamelCase($name) . 'Event'; }); // Register bypass rules. $dispatcher->AddBypassRule('', 'home'); $dispatcher->AddBypassRule('list', 'list_bug'); $dispatcher->AddBypassRule('new', 'new_bug'); $dispatcher->AddBypassRule('view', 'view_bug'); $dispatcher->AddBypassRule('login', 'login_user'); $dispatcher->AddBypassRule('logout', 'logout_user'); // Transform the event name into a template name. phalanx\views\View::set_template_path(dirname(__FILE__) . '/templates/%s.tpl'); phalanx\views\View::set_cache_path(dirname(__FILE__) . '/cache'); $view_handler->set_template_loader(function ($event_class) { $name = preg_replace('/Event$/', '', $event_class); return phalanx\base\CamelCaseToUnderscore($name); }); // Read the configuration file. $config_path = BUGDAR_ROOT . '/includes/config.php'; if (!file_exists($config_path) || !is_readable($config_path)) { throw new CoreException('Could not read configuration file'); } $config = new phalanx\base\KeyDescender(require $config_path); // Setup common functionality. Bugdar::BootstrapDatabase($config); Bugdar::BootstrapAuthentication($config); Bugdar::LoadSettings(); // Finally, begin processing events. $dispatcher->Start(); try { $pump->StopPump();