public function __construct() { $this->allow_redirect = true; $this->view = Das_View::getInstance($this->getDefaultFile()); $app_web_path = 'http://' . $_SERVER['SERVER_NAME'] . '' . $_SERVER['SCRIPT_NAME']; $app_web_path = strtolower($app_web_path); $app_web_path = str_replace("index.php", "", $app_web_path); $this->app_web_path = $app_web_path; $this->view->RES_PATH = $app_web_path; $dv = new Das_ViewUtil(); $this->view->dv = $dv; $login = new Das_Login(); $this->view->login = $login->getUserInfo(); $act = $this->getAction(); if (!isset($act) && $act == null) { $act = "index"; } $act = strtolower($act); $method = $act . "Action"; if (method_exists($this, $method)) { $this->{$method}(); } else { $this->indexAction(); } }
public function indexAction() { if ($this->isPost()) { $username = $_POST['username']; $password = $_POST['password']; $login = new Das_Login(); $login->login($username, $password); if ($login->checkLogin()) { //loginSuccess $info = $login->getUserInfo(); //echo "<pre>"; //var_dump($info); //die; $this->redirect("index"); } else { $this->view->isError = true; $this->view->error = "登录不成功"; } } $this->view->render("login.html"); }
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/lib'), get_include_path()))); require_once 'Zend/Loader/Autoloader.php'; $loader = Zend_Loader_Autoloader::getInstance(); $loader->registerNamespace('Zend'); $loader->registerNamespace('Das'); $loader->registerNamespace('Model'); $loader->registerNamespace('Doctrine'); $loader->registerNamespace('DBModel'); require_once 'Twig/Autoloader.php'; Twig_Autoloader::register(); //loading doctrine $loader->pushAutoloader(array('Doctrine', 'autoload')); spl_autoload_register(array('Doctrine', 'modelsAutoload')); $manager = Doctrine_Manager::getInstance(); $manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true); $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, true); $model_path = APPLICATION_PATH . "/lib/DBModel"; Doctrine_Core::loadModels($model_path); $config = new Zend_Config_Ini(APPLICATION_PATH . "/config.ini", "doctrine"); $dsn = $config->dsn; $conn = Doctrine_Manager::connection($dsn, 'doctrine'); $conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true); Doctrine_Manager::getInstance()->getCurrentConnection()->setCharset('utf8'); $login = new Das_Login(); if (!$login->checkLogin()) { $l = new Model_Login(); echo ":."; } else { $cmd = Das_Command::getInstance(); } //check login...