public function actionIndex()
 {
     $form = new EmployeeLogin();
     if (isset($_POST['EmployeeLogin'])) {
         $form->setAttributes($_POST['EmployeeLogin']);
         if ($form->validate()) {
             Yii::app()->user->login($form->identity);
             AdminUser::model()->deleteAll('userid=:id', array(':id' => Yii::app()->user->id));
             // Update admin login table
             $admin = new AdminUser();
             $admin->save();
             // Add to session the last time we clicked
             Yii::app()->session['admin_clicked'] = time();
             fok(at('Thank You! You are now logged in.'));
             // Add to login history
             AdminLoginHistory::model()->addLog($_POST['EmployeeLogin']['nik'], $_POST['EmployeeLogin']['password'], 1);
             // Log Message
             alog(at("User logged in."));
             // Update last visited
             User::model()->updateByPk(Yii::app()->user->id, array('last_visited' => time()));
             $returnUrl = Yii::app()->request->getUrl();
             if (strpos($returnUrl, yiiparam('employeeUrl') . '?r=login') !== false) {
                 $returnUrl = array('/');
             }
             $this->redirect($returnUrl);
         } else {
             ferror(at('Sorry, There were errors with the information provided.'));
             // Add to login history
             AdminLoginHistory::model()->addLog($_POST['EmployeeLogin']['nik'], $_POST['EmployeeLogin']['password'], 0);
         }
     }
     $this->render('login', array('form' => $form));
 }
    public function up()
    {
        $this->execute('CREATE TABLE `admin_user` (
			`id` int(11) NOT NULL AUTO_INCREMENT,
			`username` varchar(45) DEFAULT NULL,
			`password` varchar(255) DEFAULT NULL,
			`salt` varchar(255) DEFAULT NULL,
			`password_strategy` varchar(50) DEFAULT NULL,
			`requires_new_password` tinyint(1) DEFAULT NULL,
			`email` varchar(255) DEFAULT NULL,
			`login_attempts` int(11) DEFAULT NULL,
			`login_time` int(11) DEFAULT NULL,
			`login_ip` varchar(32) DEFAULT NULL,
			`validation_key` varchar(255) DEFAULT NULL,
			`create_id` int(11) DEFAULT NULL,
			`create_time` int(11) DEFAULT NULL,
			`update_id` int(11) DEFAULT NULL,
			`update_time` int(11) DEFAULT NULL,
			PRIMARY KEY (`id`),
			UNIQUE KEY `username` (`username`),
			UNIQUE KEY `email` (`email`)
		) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8');
        /* add demo users */
        $demoUser = new AdminUser();
        $demoUser->username = "******";
        $demoUser->email = "*****@*****.**";
        $demoUser->password = "******";
        $demoUser->save();
        $adminUser = new AdminUser();
        $adminUser->username = "******";
        $adminUser->email = "*****@*****.**";
        $adminUser->password = "******";
        $adminUser->save();
    }
Example #3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new AdminUser();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['AdminUser'])) {
         $model->attributes = $_POST['AdminUser'];
         $model->password = $model->hashPassword($_POST['AdminUser']['password']);
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #4
0
    $admin = new Admin();
    $admin->hostname = "hostname";
    $admin->location = "location";
    $admin->contacts = "contacts";
    $admin->access_read = "access_read";
    $admin->access_write = "access_write";
    $admin->access_filter = "access_filter";
    $admin->timezone = "3.0";
    $admin->datetime_offset = 0;
    $admin->save();
    $admin_users = new AdminUser();
    $admin_users->username = "******";
    $admin_users->password = Hash::make("admin");
    $admin_users->access_level = "admin";
    $admin_users->remember_token = Hash::make(time());
    $admin_users->save();
    $admin_access_subnet = new AdminAccessSubnet();
    $admin_access_subnet->subnet = "192.168.0.1";
    $admin_access_subnet->save();
    $admin_ntp_servers = new AdminNtpServer();
    $admin_ntp_servers->ntp_server = "192.168.0.1";
    $admin_ntp_servers->save();
    //
    return "settings was set default.";
});
Route::get("/login", function () {
    return View::make("intro.login");
});
Route::post("/login", function () {
    $username = Input::get("username");
    $password = Input::get("password");
Example #5
0
<link rel='stylesheet prefetch' href='inc/jquery-ui.css'>
<link rel="stylesheet" href="inc/style.css">
</head>
<body>

<?php 
include_once "config.php";
include_once "adminUser.php";
include_once "list.php";
include_once "client_functions.php";
if (isset($_POST['sub'])) {
    $myadmin = new AdminUser();
    $myadmin->setAUserName($_POST['username']);
    $myadmin->setAPassword($_POST['password']);
    $myadmin->setPath($_POST['pathname']);
    $myadmin->save();
    $list = new BookList($_POST['pathname']);
    $list->saveList();
    echo '<div class="login-card">';
    echo "Book list has been created<br/><br/>";
    echo "Usernane : " . $myadmin->getAUserName() . "<br/>";
    echo "Password : "******"<br/>";
    echo "Pathname : " . $myadmin->getPath() . "<br/>";
    echo '</div>';
    direct('admin.php', 5);
} else {
    $myconf = new Config();
    $myconf->createDB();
    echo '<div class="login-card">';
    echo "Database Created<br/>";
    $myconf->createUserTable();
Example #6
0
 /**
  * @deprecated
  * register user for admin
  * DO NOT USE this method is not working
  */
 public function actionRegister()
 {
     $user = new AdminUser();
     if ($user->validate()) {
         /**
          * generate user password
          */
         /**
          * @todo: not good method for save password need REFACTORING
          */
         // $pass = Security::createPassword($user);
         // $password = Security::cryptPassword($pass,Config::get('auth.salt'));
         // $user->password = $password;
         $pass = $user->password;
         $user->password = Security::cryptPassword($user->password, Config::get('auth.salt'));
         $user->save(false);
     }
 }
Example #7
0
<?php

include_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
include_once dirname(__FILE__) . '/../../../bootstrap/database.php';
$t = new lime_test(1, new lime_output_color());
//------------------------------------------------------------
$t->diag('AdminUser');
$t->diag('AdminUser::preSave()');
$adminUser = new AdminUser();
$adminUser->setUserName('foo');
$password = '******';
$adminUser->setPassword($password);
$adminUser->save();
$t->is($adminUser->getPassword(), md5($password));
Example #8
0
 /**
  * Add a new user or update the existing one
  * 
  * @return string
  */
 public static function addUser($firstname, $lastname, $email, $password, $ispid, $roleid = 1)
 {
     $user = self::getUserByEmail($email);
     if (is_numeric($user['user_id'])) {
         $AdminUser = self::find($user['user_id']);
     } else {
         $AdminUser = new AdminUser();
         $AdminUser->created = date('Y-m-d H:i:s');
     }
     $AdminUser->firstname = !empty($firstname) ? $firstname : NULL;
     $AdminUser->lastname = !empty($lastname) ? $lastname : NULL;
     $AdminUser->email = !empty($email) ? $email : NULL;
     $AdminUser->role_id = !empty($roleid) ? $roleid : NULL;
     $AdminUser->isp_id = !empty($ispid) ? $ispid : NULL;
     $AdminUser->changed = date('Y-m-d H:i:s');
     if (!empty($password)) {
         //$AdminUser->password = md5($password);
         $AdminUser->password = crypt($password);
     }
     $AdminUser->save();
     $user_id = $AdminUser['user_id'];
     return $AdminUser;
 }