Exemplo n.º 1
0
 public function login($username, $password)
 {
     $admin_user = new Admin_user();
     if ($admin_user->login($username, $password)) {
         $userdata = array('user_id' => $admin_user->id, 'logged_in' => TRUE);
         $this->CI->session->set_userdata($userdata);
         $this->update_login_status();
         return TRUE;
     }
     return FALSE;
 }
 public static function getAdmin($username)
 {
     $db = Connection::getInstance();
     $mysqli = $db->getConnection();
     $query = "select * from admin_user where username='{$username}'";
     $result = $mysqli->query($query);
     $user = new Admin_user();
     if ($result->num_rows > 0) {
         if ($row = $result->fetch_assoc()) {
             $user->setUsername($row["username"]);
             $user->setPassword($row["password"]);
         }
     }
     return $user;
 }
Exemplo n.º 3
0
 /**
  * Handles the login of an admin user.
  *
  * @param string $user
  * @param string $pass
  * @return boolean
  */
 public function login($user, $pass)
 {
     require_once APPLICATION_PATH . MODEL_DIR . '/Admin_user.php';
     $admin_user = new Admin_user();
     $logged_in_user = $admin_user->getUser($user, $pass);
     if (!empty($logged_in_user)) {
         CakeSession::write('admin', true);
         CakeSession::write('auth', true);
         CakeSession::write('admin_user', $logged_in_user);
         return TRUE;
     } else {
         $this->status = FALSE;
         return FALSE;
     }
 }
Exemplo n.º 4
0
}
/**
 * change user password
 */
if (isset($_POST['form']) && $_POST['form'] == "change_password") {
    $user = $_POST['data'];
    require_once APPLICATION_PATH . MODEL_DIR . '/Admin_user.php';
    $admin_users = new Admin_user();
    @($user = $admin_users->changePassword($user));
    if ($user) {
        $result = TRUE;
    } else {
        $result = FALSE;
    }
}
/**
 * change user password
 */
if (isset($_POST['form']) && $_POST['form'] == "delete_user") {
    $user = $_POST['data'];
    require_once APPLICATION_PATH . MODEL_DIR . '/Admin_user.php';
    $admin_users = new Admin_user();
    @($user = $admin_users->deleteUser($user));
    if ($user) {
        $result = TRUE;
    } else {
        $result = FALSE;
    }
}
header('Content-Type: application/json');
echo json_encode(array("result" => $result));
Exemplo n.º 5
0
        return $menu;
    }
    // modified in version 1.97
    function activation_switch($formelement = "activation")
    {
        $radio_group = "<label for=\"" . $formelement . "\">Active?</label>\n";
        $labels = array("y" => "yes", "n" => "no", "b" => "blocked");
        foreach ($labels as $key => $val) {
            $radio_group .= " <input name=\"" . $formelement . "\" type=\"radio\" value=\"" . $key . "\" ";
            $radio_group .= $this->activation == $key ? "checked=\"checked\" />\n" : "/>\n";
            $radio_group .= $val;
        }
        return $radio_group;
    }
}
$admin_update = new Admin_user();
$admin_update->access_page($_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'], DEFAULT_ADMIN_LEVEL);
// check the level inside the config file
if (isset($_POST['Submit'])) {
    if ($_POST['Submit'] == "Update") {
        $conf_str = isset($_POST['send_confirmation']) ? $_POST['send_confirmation'] : "";
        // the checkbox value to send a confirmation mail
        $admin_update->update_user_by_admin($_POST['level'], $_POST['user_id'], $_POST['password'], $_POST['email'], $_POST['activation'], $conf_str);
        $admin_update->get_userdata($_POST['login_name']);
        // this is needed to get the modified data after update
    } elseif ($_POST['Submit'] == "Search") {
        $admin_update->get_userdata($_POST['login_name']);
    }
} elseif (isset($_GET['login_id']) && intval($_GET['login_id']) > 0) {
    $admin_update->get_userdata($_GET['login_id'], "is_id");
}