public function testCallRunFromGet()
 {
     DBMaker::create('ptest1');
     Database::clearDB();
     $db = Database::getDB($dbName = 'ptest1', $configPath = "C:" . DIRECTORY_SEPARATOR . "xampp" . DIRECTORY_SEPARATOR . "myConfig.ini");
     $_SERVER["REQUEST_METHOD"] = "GET";
     ob_start();
     LoginController::run();
     $output = ob_get_clean();
     $this->assertFalse(empty($output), "It should show something from a GET");
 }
 /**
  * @runInSeparateProcess
  */
 public function testCallRunFromGet()
 {
     ob_start();
     DBMaker::create('botspacetest');
     Database::clearDB();
     $db = Database::getDB($dbName = 'botspacetest', $configPath = 'C:\\xampp\\myConfig.ini');
     $_SERVER['REQUEST_METHOD'] = "GET";
     $_SERVER['HTTP_HOST'] = "localhost";
     $_SESSION = array("base" => "ha_lab3");
     LoginController::run();
     $output = ob_get_clean();
     $this->assertFalse(empty($output), "It should show something from a GET");
 }
                $form_errors["password"] = "******";
            }
            if (empty($form_errors["username"])) {
                $userDAO = UserDAO::getInstance();
                $user = $userDAO->loadByUsername($form_values["username"]);
                if ($user && $user->getStatus() == User::STATUS_OK) {
                    if (strcmp($user->getPasshash(), $password) != 0) {
                        $form_errors["username"] = "******";
                    }
                } else {
                    if ($user && $user->getStatus() == User::STATUS_NEEDADMIN) {
                        $form_errors["username"] = "******";
                    } else {
                        $form_errors["username"] = "******";
                    }
                }
            }
            if (empty($form_errors)) {
                $session->setUser($user);
                $session->setMessage("Welcome, {$user->getUsername()}");
                header("Location: " . BASE_URL);
                return;
            }
        }
        $user = $session->getUser();
        $this->template->render(array("main_page" => "login_tpl.php", "title" => "Login", "user" => $user, "form_values" => $form_values, "form_errors" => $form_errors));
    }
}
$controller = new LoginController();
$controller->run();
session_start();
$url = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
list($fill, $base, $control, $action, $arguments) = explode('/', $url, 5) + array("", "", "", "", null);
$_SESSION['base'] = $base;
$_SESSION['control'] = $control;
$_SESSION['action'] = $action;
$_SESSION['arguments'] = $arguments;
if (!isset($_SESSION['authenticated'])) {
    $_SESSION['authenticated'] = false;
}
switch ($control) {
    case "dataset":
        DatasetController::run();
        break;
    case "login":
        LoginController::run();
        break;
    case "logout":
        LogoutController::run();
        break;
    case "measurement":
        MeasurementController::run();
        break;
    case "profile":
        ProfileController::run();
        break;
    case "sensor":
        SensorController::run();
        break;
    case "signup":
        SignupController::run();
Beispiel #5
0
 /** @return Am_Auth_User provides fluent interface */
 function requireLogin($redirectUrl = null)
 {
     if (!$this->getUserId()) {
         $front = Zend_Controller_Front::getInstance();
         if (!$front->getRequest()) {
             $front->setRequest(new Am_Request());
         } else {
             $front->setRequest(clone $front->getRequest());
         }
         $front->getRequest()->setActionName('index');
         if (!$front->getResponse()) {
             $front->setResponse(new Zend_Controller_Response_Http());
         }
         require_once APPLICATION_PATH . '/default/controllers/LoginController.php';
         $c = new LoginController($front->getRequest(), $front->getResponse(), array('di' => Am_Di::getInstance()));
         if ($redirectUrl) {
             $c->setRedirectUrl($redirectUrl);
         }
         $c->run();
         Zend_Controller_Front::getInstance()->getResponse()->sendResponse();
         exit;
     }
 }
Beispiel #6
0
<?php

/**
 * Авторизация, точка входа.
 */
define('IS_USER_ACTION', 1);
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stdf.php';
require_once ABS_PATH . '/classes/yii/tinyyii.php';
require_once __DIR__ . '/controllers/LoginController.php';
$module = new CModule('login');
$module->setBasePath(dirname(__FILE__));
$controller = new LoginController('login', $module);
$controller->init();
// инициализация контролера
$controller->run('index');
// запуск обработчика
//@todo: Отключает лишнюю обертку в template3
$stretch_page = true;
$registration_page = $registration_folder = true;
$footer_registration = true;
$hide_banner_top = true;
$content = 'tpl.index.php';
include ABS_PATH . '/template3.php';
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     // if user is logged in and went here, something is definitely wrong
     if ($this->getDi()->auth->getUserId()) {
         $this->needRefresh($this->getDi()->auth->getUser());
         if (parse_url($request->getParam('url'), PHP_URL_SCHEME)) {
             $url = $request->getParam('url');
         } else {
             $url = sprintf('%s://%s%s', $request->isSecure() ? 'https' : 'http', $request->getHttpHost(), $request->getParam('url'));
         }
         Am_Controller::redirectLocation($url);
         return;
     }
     //
     require_once APPLICATION_PATH . '/default/controllers/LoginController.php';
     $c = new LoginController($request, $response, $invokeArgs);
     $c->setRedirectUrl($request->getEscaped('url'));
     $c->run();
 }
Beispiel #8
0
 public function directAction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
 {
     if ($url = $request->get('url')) {
         $url = urldecode($url);
     }
     if ($request->get('host') && $request->get('ssl')) {
         $url = (!strcasecmp($request->get('ssl'), 'on') ? 'https://' : 'http://') . $request->get('host') . $url;
         $request->set('url', $url);
     }
     // if user is logged in and went here, something is definitely wrong
     if ($this->getDi()->auth->getUserId()) {
         $this->needRefresh($this->getDi()->auth->getUser());
         if (!parse_url($url, PHP_URL_SCHEME)) {
             $url = sprintf('%s://%s%s', $request->isSecure() ? 'https' : 'http', $request->getHttpHost(), $url);
         }
         Am_Controller::redirectLocation($url);
         return;
     }
     //
     require_once APPLICATION_PATH . '/default/controllers/LoginController.php';
     $c = new LoginController($request, $response, $invokeArgs);
     $c->setRedirectUrl(Am_Controller::escape($url));
     $c->run();
 }
Beispiel #9
0
    $arguments = array_slice($urlPieces, 1);
}
// run the requested controller
switch ($control) {
    //     case 'account' : SignupController::run(array_slice($arguments, 1)); break;
    case 'account':
        SignupController::run($arguments);
        break;
    case 'bank':
        BankController::run($arguments);
        break;
    case 'login':
        LoginController::run(array_merge(array($control), $arguments));
        break;
    case 'logout':
        LoginController::run(array_merge(array($control), $arguments));
        break;
    case 'gps':
        GPSController::run($arguments);
        break;
    case 'view':
        ViewController::run($arguments);
        break;
    default:
        View::run();
        break;
}
function sendMessage($status, $message)
{
    $replyMsg = new ReplyMessage();
    $replyMsg->status = $status;