Inheritance: extends CI_Controller
 public function indexAction()
 {
     $lang = $this->_request->getParam('lang');
     $langNamespace = new Zend_Session_Namespace('Lang');
     $langNamespace->lang = $lang;
     //		Zend_Debug::dump($_SERVER["HTTP_REFERER"]);
     if (isset($this->_currentUser->id)) {
         $consumerModel = new Consumer();
         $consumer = $consumerModel->fetchRow('id = ' . $this->_currentUser->id);
         if ($consumer != null) {
             $consumer->language_pref = $lang;
             $consumer->save();
         } else {
             $adminModel = new Admin();
             $admin = $adminModel->fetchRow('id = ' . $this->_currentUser->id);
             if ($admin != null) {
                 $admin->language_pref = $lang;
                 $admin->save();
             }
         }
     }
     $messageArray = $this->_flashMessenger->getMessages();
     if ($messageArray != null) {
         foreach ($messageArray as $message) {
             $this->_flashMessenger->addMessage($message);
         }
     }
     $this->_helper->redirector->gotoUrl($_SERVER["HTTP_REFERER"]);
 }
Beispiel #2
0
function adminLogin()
{
    $reservename = getvar('username', 'post');
    $pass = getvar('pass', 'post');
    if (strlen($reservename) >= 5 && strlen($pass) > 5) {
        $admin = new Admin();
        $row = $admin->findOne($reservename, md5($pass));
        if ($row) {
            setvar('admin', $row['username']);
            //session
            if (getvar('rememberme', 'post')) {
                setcookie('username', $reservename, time() + 3600 * 24 * 7);
            }
            //账号默认保存七天
            setHint('欢迎管理员');
            redirect('usershow');
        } else {
            setHint('账号或密码有误');
            redirect('login');
        }
    } else {
        setHint('账号或密码不符合要求');
        redirect('login');
    }
}
 public function testEndreUgyldigKunde()
 {
     //Arrange
     $admin = new Admin(new adminDBStubSqlite());
     $kunde = new kunde();
     $kunde->personnummer = "11122233312";
     $kunde->fornavn = "Ugyldig";
     $kunde->etternavn = "Person";
     $kunde->adresse = "Luftslåttveien 22";
     $kunde->postnr = "1387";
     $kunde->poststed = "Asker";
     $kunde->telefonnr = "22224444";
     $kunde->passord = "11122233312";
     //Act
     $OK = $admin->hentKundeInfo($kunde->personnummer);
     $this->assertEquals("Feil", $OK);
     $oppdatertKunde = clone $kunde;
     $oppdatertKunde->fornavn = "Lina";
     $oppdatertKunde->etternavn = "Jonvik";
     $oppdatertKunde->adresse = "Slaskebakken 22";
     $OK = $admin->endreKundeInfo($oppdatertKunde);
     $this->assertEquals("OK", $OK);
     $OK = $admin->hentKundeInfo($kunde->personnummer);
     $this->assertEquals("Feil", $OK);
 }
Beispiel #4
0
 public function indexAction()
 {
     $fc = FrontController::getInstance();
     $admin = new Admin();
     $output = $admin->render(ADMIN_TEMPLATE, ADMIN_LOGIN);
     $fc->setBody($output);
 }
 function AdminEkle(Admin $admin)
 {
     try {
         $sorgu = "insert into admin (username, ad, soyad, email, tel, dogumTarihi) values(?,?,?,?,?,?)";
         $admindeger = array($admin->getUsername(), $admin->getAd(), $admin->getSoyad(), $admin->getEmail(), $admin->getTel(), $admin->getDogumTarihi());
         $baglanti = new VeriTabaniBaglanti();
         $conn = $baglanti->pdo_baglanti();
         $ekle = $conn->prepare($sorgu);
         $sonuc = $ekle->execute($admindeger);
         if ($sonuc) {
             $kul = new KullaniciGiris();
             $kuldao = new KullaniciGirisDAO();
             $sifre = $admin->getAd() . $admin->getSoyad();
             $yeniSifre = $kuldao->sifreleme($sifre);
             $kul->setEmail($admin->getEmail());
             $kul->setSifre($yeniSifre);
             $kul->setYetkiId(1);
             echo '<p style="color: green;">Veriler Eklendi</p>';
             echo $kuldao->KullaniciEkle($kul);
         } else {
             echo '<p style="color: red;">Hata Oluştu</p>';
         }
     } catch (PDOException $exc) {
         echo $exc->getTraceAsString();
     }
 }
Beispiel #6
0
 public function getSessionInfo()
 {
     $email = $this->getSession("email");
     $admin = new Admin();
     $datainfo = $admin->getUserByEmail($email);
     return $datainfo;
 }
 /**
  * Render the basic drug set admin page.
  */
 public function actionDrugSets()
 {
     $admin = new Admin(DrugSet::model(), $this);
     $admin->setListFields(array('id', 'name', 'subspecialty.name', 'active'));
     $admin->searchAll();
     $admin->getSearch()->setItemsPerPage($this->itemsPerPage);
     $admin->listModel();
 }
Beispiel #8
0
 function delete()
 {
     $this->is_loggedin();
     global $runtime;
     $to_trash = new Admin($runtime['ident']);
     $to_trash->delete();
     redirect('admin/all');
 }
Beispiel #9
0
 function test_slettKonto_FEIL()
 {
     $adminLogikk = new Admin(new AdminDBStub());
     $konto = new konto();
     $konto->kontonummer = 123;
     $OK = $adminLogikk->slettKonto($konto->kontonummer);
     $this->assertEquals("OK", $OK);
 }
Beispiel #10
0
 public function testIsAdmin()
 {
     $admin = new Admin();
     $admin->add_admin('toto');
     $admins = $admin->get_admins();
     $this->assertTrue($admin->is_admin('toto'));
     $admin->remove_admin('toto');
 }
Beispiel #11
0
 public function valid(Admin $admin)
 {
     $sql = 'INSERT INTO `' . $this->table . '` (`id`, `first_name`, `last_name`, `email`, `login`, `password`, `heurisko`, `language`)
               VALUES (:id, :first_name, :last_name, :email, :login, :password, :heurisko, :language)
             ON DUPLICATE KEY UPDATE
                 first_name=:first_name, last_name=:last_name, email=:email, login=:login, password=:password, heurisko=:heurisko, language=:language';
     return $this->execute($sql, null, array(array(':id', $admin->id, PDO::PARAM_INT), array(':first_name', $admin->first_name, PDO::PARAM_STR), array(':last_name', $admin->last_name, PDO::PARAM_STR), array(':email', $admin->email, PDO::PARAM_STR), array(':login', $admin->login, PDO::PARAM_STR), array(':password', $admin->password, PDO::PARAM_STR), array(':heurisko', $admin->isHeurisko(), PDO::PARAM_BOOL), array(':language', $admin->getLanguageId(), PDO::PARAM_INT)));
 }
 function loadModule()
 {
     $module = $this->httpRequest->getModule();
     $GLOBALS['Plugin'] = null;
     if (strpos($module, 'AdminPanel') === 0) {
         $pluginFolderName = strtolower(substr($module, 10));
         # Be carful, here parameters are moved
         $module = $this->httpRequest->getAction();
         if ($module == null) {
             throw new Exception(__('No module'));
         }
         $moduleFilePath = DIR_PLUGINS . $pluginFolderName . '/actions/' . $module . '.class.php';
         # Include admin module
         if (file_exists($moduleFilePath)) {
             require_once $moduleFilePath;
             $moduleController = new $module();
         } else {
             throw new Exception(__('No file found'));
         }
         # Get the action (Prob: HttpRequest->parseUrl() don't parse the second string following '/' )
         ereg($this->httpRequest->getModule() . '/' . $module . '/([^\\?$]+)', $_SERVER['REQUEST_URI'], $res);
         if (isset($res[1])) {
             $action = $res[1];
         } else {
             throw new Exception(__('No action'));
         }
         # if method exist call it
         if (method_exists($moduleController, $action)) {
             # search parameters method
             $reflect = new ReflectionMethod($module, $action);
             $parameters = $reflect->getParameters();
             $tabParam = array();
             foreach ($parameters as $param) {
                 $tabParam[$param->getName()] = $this->httpRequest->getArgument($param->getName());
             }
             try {
                 $pluginsInfoList = Plugin::getManifest($pluginFolderName);
                 $name = $pluginsInfoList['name'];
                 define('PLUGIN_ITSELF_URL_BASE', BASE_PORTAL_URI . 'index.php/' . $this->httpRequest->getModule() . '/');
                 ob_start();
                 //echo Plugin::getHeader($name);
                 # Call action of the plugin
                 call_user_func_array(array(new $module(), $action), $tabParam);
                 $GLOBALS['Plugin']['pluginViewContent'] = ob_get_clean();
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
         } else {
             throw new Exception(__("No action"));
         }
         $GLOBALS['Plugin']['comingFromPlugin'] = true;
         $adminController = new Admin();
         $adminController->index();
     } else {
         parent::loadModule();
     }
 }
 /**
  * @expectedException PDOException
  * @expectedExceptionCode 23000
  * @expectedExceptionMessage Integrity constraint violation: 19 NOT NULL constraint failed: Konto.Kontonummer
  *
  */
 public function testRegistrereUgyldigKontoPåGyldigKunde()
 {
     //Arrange
     $admin = new Admin(new adminDBStubSqlite());
     $konto = new konto();
     $konto->personnummer = "09048433711";
     //Act
     $OK = $admin->registrerKonto($konto);
 }
 public function checkAdminPermissions(Admin $admin)
 {
     foreach (array(Am_Auth_Admin::PERM_LOGS, Am_Auth_Admin::PERM_LOGS_ACCESS, Am_Auth_Admin::PERM_LOGS_INVOICE, Am_Auth_Admin::PERM_LOGS_MAIL, Am_Auth_Admin::PERM_LOGS_ADMIN) as $perm) {
         if ($admin->hasPermission($perm)) {
             return true;
         }
     }
     return false;
 }
Beispiel #15
0
 public function login()
 {
     $this->modelo('AdminDAO');
     $admin = new Admin();
     $admin->setEmail($_REQUEST['email']);
     $admin->setSenha($_REQUEST['senha']);
     $objAdmin = $this->AdminDAO->login($admin);
     $this->visao->render('admin/painel');
 }
Beispiel #16
0
 public function saveUser(Admin $user)
 {
     $userData = $user->getArrayData();
     if ($this->getUser($user->uid) == NULL) {
         // SI NO EXISTE EL USUARIO
         $this->tableGateway->insert($userData);
     } else {
         $this->tableGateway->update($userData, array('UID' => $user->uid));
     }
 }
 /**
  * Edits or adds a Procedure.
  *
  * @param bool|int $id
  *
  * @throws CHttpException
  */
 public function actionEdit($id = false)
 {
     $admin = new Admin(UniqueCodes::model(), $this);
     if ($id) {
         $admin->setModelId($id);
     }
     $admin->setModelDisplayName('Unique Codes');
     $admin->setEditFields(array('code' => 'label', 'active' => 'checkbox'));
     $admin->editModel();
 }
Beispiel #18
0
 public function testSlettUgyldigKunde()
 {
     //Arrange
     $admin = new Admin(new adminDBStubSqlite());
     $personnummer = "987654321";
     //Act
     $OK = $admin->slettKunde($personnummer);
     //Assert
     $this->assertEquals("Feil", $OK);
 }
 /**
  * @expectedException PDOException
  * @expectedExceptionCode 23000
  * @expectedExceptionMessage Integrity constraint violation: 19 NOT NULL constraint failed: Poststed.Postnr
  *
  */
 public function testRegistrereTomKunde()
 {
     //Arrange
     $admin = new Admin(new adminDBStubSqlite());
     $kunde = new kunde();
     //Act (Assert is in comments above)
     //Act
     $OK = $admin->registrerKunde($kunde);
     //@codeCoverageIgnoreStart
 }
Beispiel #20
0
 function authenticate()
 {
     $admin = new Admin();
     $user = $admin->findUser($this->username);
     if ($user && $user->password == $this->password) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #21
0
 public static function instance()
 {
     static $instance = null;
     if ($instance === null) {
         $instance = new Admin();
         $instance->includes();
         $instance->setup_actions();
     }
     return $instance;
 }
 /**
  * @author Øyvind Ahlstrøm
  * @version 1.0, 2016.01.26
  * 
  * Denne testen sjekker om dersom et personnummer har et duplikat.
  * @assert string "Duplikat"
  */
 function testSlettKunde_duplikater()
 {
     // Arrange
     $admin = new Admin(new DBStubAdmin());
     $personnummer = "00000000001";
     // Act
     $resultat = $admin->slettKunde($personnummer);
     // Asssert
     $this->assertEquals("Duplikat", $resultat);
 }
 public function add(Admin $adm)
 {
     if ($adm->getAddable()) {
         $q = $this->_db->prepare("INSERT INTO admin SET mdpAdm=:mdp");
         $q->execute(array(":mdp" => $adm->getMdpAdm()));
         echo "add";
     } else {
         echo "conditions non validées. voir trigger_error";
     }
 }
 public function admin_login(Admin $admin)
 {
     session_regenerate_id();
     if ($admin) {
         $this->admin_id = $_SESSION['admin_id'] = $admin->id;
         $_SESSION['admin_logged_in'] = true;
         $this->admin_logged_in = true;
         $admin->update_last_login();
     }
 }
Beispiel #25
0
 public function testSlettUgyldigKonto()
 {
     //Arrange
     $admin = new Admin(new adminDBStubSqlite());
     $kontonummer = "6666666";
     //Act
     $OK = $admin->slettKonto($kontonummer);
     //Assert
     $this->assertEquals("Feil", $OK);
 }
Beispiel #26
0
 /**
  * @expectedException Exception
  * @expectedExceptionMessage Authorization error.
  * @expectedExceptionCode 401
  */
 public function testUnauthorizedCantUninstall()
 {
     $adminSettingsMockup = $this->adminSettingsMockup;
     $adminDAO = new AdminDAOMockup();
     $adminDAO->settingsMockup = $adminSettingsMockup;
     $adminDAO->readAdminSettings();
     $adminDAO->userIdMockup = "regularUserIdMockup";
     $admin = new Admin($adminDAO);
     $authResponse = $adminDAO->authenticate(null, null, '{"access_token":"mockupRegularUserToken","token_type":"Bearer","expires_in":3600,"id_token":"mockupRegularUserIdToken","created":"1403218562"}');
     $this->assertEquals(false, isset($authResponse['authUrl']));
     $admin->uninstall();
 }
 public function run()
 {
     DB::table('admins')->truncate();
     $admin = new Admin();
     $admin->username = "admin_1";
     $admin->password = "123456";
     $admin->save();
     $admin = new Admin();
     $admin->username = "admin_2";
     $admin->password = "123456";
     $admin->save();
 }
Beispiel #28
0
 function test_registrerKontoFeil()
 {
     $admin = new Admin(new AdminDBStub());
     $konto = new konto();
     $konto->personnummer = "11111111111";
     $konto->kontonummer = null;
     $konto->saldo = 30000;
     $konto->type = "BSU";
     $konto->valuta = "NOK";
     $konto->transaksjoner[0] = "Uttak";
     $resultat = $admin->registrerKonto($konto);
     $this->assertEquals("Feil", $resultat);
 }
Beispiel #29
0
 /**
  * The login page handler.
  * 
  * @access public
  * @return string The HTML code.
  */
 public function login()
 {
     $this->getView()->set('Error', null);
     if (Request::get('login') && Request::get('password')) {
         $Admin = new Admin();
         if ($Admin->login(Request::get('login'), Request::get('password')) !== false) {
             $this->halt();
         } else {
             $this->getView()->set('Error', 'Wrong password');
         }
     }
     return $this->getView()->render();
 }
Beispiel #30
0
function logincheck()
{
    $username = $_POST['username'];
    $password = $_POST['password'];
    $admin = new Admin();
    $one_admin = $admin->findByUsername($username);
    if (count($one_admin) > 0 && $one_admin['password'] == $password) {
        $_SESSION['admin'] = $one_admin;
        echo "success";
    } else {
        echo "failed";
    }
}