Exemplo n.º 1
0
Arquivo: home.php Projeto: pam81/pack
 public function index()
 {
     if ($user = Current_User::user()) {
         redirect("inicio");
     }
     $data["content"] = "home";
     $this->load->view("index", $data);
 }
Exemplo n.º 2
0
 public function index()
 {
     if (Current_User::user()) {
         if (!empty($_GET['logoff'])) {
             $this->logout();
             header("location:login.html");
         } else {
             include 'admin_registration.view.php';
             // @ session already active
             //		    $arr = array('status' => true, 'message' => $ACL_LANG['SESSION_ACTIVE'], 'url' => SUCCESS_URL);
             //        $json_arr = json_encode($arr);
             //        echo $json_arr;
         }
     } else {
         // load data to the view if there are some data needed
         //include('login.view.php');
         //@ session not active
         if ($_SERVER['REQUEST_METHOD'] == 'GET') {
             //@ first load
             $arr = array('status' => false, 'message' => $acl->form());
             $json_arr = json_encode($arr);
             echo $json_arr;
         } else {
             //@ form submission
             $u = !empty($_POST['u']) ? trim($_POST['u']) : false;
             // retrive user var
             $p = !empty($_POST['p']) ? trim($_POST['p']) : false;
             // retrive password var
             // @ try to signin
             $is_auth = Current_User::authenticate($u, $p);
             if ($is_auth) {
                 //@ success
                 $arr = array('status' => true, 'message' => $ACL_LANG['LOGIN_SUCCESS'], 'url' => SUCCESS_URL);
                 $json_arr = json_encode($arr);
                 echo $json_arr;
             } else {
                 //@ failed
                 $arr = array('status' => false, 'message' => $ACL_LANG['LOGIN_FAILED']);
                 $json_arr = json_encode($arr);
                 echo $json_arr;
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Authenticate and validate the user.
  * @param $username
  * @param $password
  * @return unknown_type
  */
 public static function authenticate($username, $password)
 {
     global $db_config;
     $result = FALSE;
     $db = NULL;
     if ($username && $password) {
         $db = @mysql_connect($db_config['server'], $db_config['user'], $db_config['pass']);
         if (!$db) {
             return FALSE;
         }
         $opendb = @mysql_select_db($db_config['name'], $db);
         if (!$opendb) {
             return FALSE;
         }
         $sql = "SELECT * FROM " . $db_config['users'] . " WHERE ";
         switch (LOGIN_METHOD) {
             case 'both':
                 $sql .= "(username='******' OR useremail='" . mysql_real_escape_string($username) . "')";
                 break;
             case 'email':
                 $sql .= "useremail='" . mysql_real_escape_string($username) . "'";
                 break;
             default:
                 $sql .= "username='******'";
                 break;
         }
         $sql .= " AND userpassword = '******'";
         $rs = @mysql_query($sql, $db);
         if (!$rs) {
             return FALSE;
         }
         if (mysql_num_rows($rs)) {
             $u = new stdClass();
             //$u->user_id
             self::$user = $u;
             self::setSession(array_merge(mysql_fetch_assoc($rs), array('expires' => time() + 45 * 60)));
             $result = TRUE;
         }
         mysql_free_result($rs);
         mysql_close($db);
         unset($rs, $sql);
     }
     return $result;
 }
Exemplo n.º 4
0
 public static function login($username, $password)
 {
     $CI =& get_instance();
     $sql = "select * from admusers where active=1 and username='******'";
     $query = $CI->db->query($sql);
     $u = $query->result();
     if (isset($u[0])) {
         $CI->load->model("user_model");
         // password match (comparing encrypted passwords)
         if ($u[0]->password == $CI->user_model->transform_password($password)) {
             //$CI =& get_instance();
             $CI->load->library('session');
             $CI->session->set_userdata('user_id', $u[0]->id);
             self::$user = $u[0];
             return TRUE;
         }
     }
     // login failed
     return FALSE;
 }
Exemplo n.º 5
0
 public static function login($username, $password)
 {
     // get User object by username
     if ($u = Doctrine::getTable('User')->findOneByUsername($username)) {
         // this mutates (encrypts) the input password
         $u_input = new User();
         $u_input->password = $password;
         // password match (comparing encrypted passwords)
         if ($u->password == $u_input->password) {
             unset($u_input);
             $CI =& get_instance();
             $CI->session->set_userdata('user_id', $u->id);
             self::$user = $u;
             return TRUE;
         }
         unset($u_input);
     }
     // login failed
     return FALSE;
 }
Exemplo n.º 6
0
 public static function login($username, $password)
 {
     // get User object by username
     if ($u = Doctrine::getTable('User')->findOneByUsername($username)) {
         // to ge the mutated version of the input password
         $u_input = new User();
         $u_input->password = $password;
         // password match
         if ($u->password == $u_input->password && $u->status == 1) {
             unset($u_input);
             $CI =& get_instance();
             $CI->load->library('session');
             $CI->session->set_userdata('user_id', $u->id);
             self::$user = $u;
             return TRUE;
         }
         unset($u_input);
     }
     // login failed
     return FALSE;
 }
Exemplo n.º 7
0
	<title>Home</title>
	<link rel="stylesheet" href="<?php 
echo base_url();
?>
css/style.css"
		type="text/css" media="all">
</head>
<body>

<div>

	<?php 
if (Current_User::user()) {
    ?>
		<h1>Hello <em><?php 
    echo Current_User::user()->username;
    ?>
</em>.</h1>
		<h3><?php 
    echo anchor('logout', 'Logout');
    ?>
</h3>		
	<?php 
} else {
    ?>
		<h2>New Users: <?php 
    echo anchor('signup', 'Create an Account');
    ?>
.</h2>
		<h2>Members: <?php 
    echo anchor('login', 'Login');
Exemplo n.º 8
0
?>
/js/behaviour.js"></script>
</head>
<body>
	<!--[if !IE]>start wrapper<![endif]-->
	<div id="wrapper">
		<!--[if !IE]>start head<![endif]-->
		<div id="head">
			<div class="inner">
				<h1 id="logo"><a href="#">Voltxion</a></h1>
				<!--[if !IE]>start user details<![endif]-->
                                <br />
                                        <ul id="user_details_menu">
                                            
                                            <?php 
if ($user = Current_User::user()) {
    ?>
                                            <li class="first">Welcome <strong><?php 
    echo $user->username;
    ?>
</strong></li>
                                            <li><a href="#">My Account</a></li>
                                            <li class="last"><?php 
    echo anchor('logout', 'Logout');
    ?>
</li>
					<?php 
} else {
    ?>
                                            <li><?php 
    echo anchor('login', 'Login');
Exemplo n.º 9
0
 public static function verified_login()
 {
     if (!($user = Current_User::user())) {
         redirect('home');
     }
 }
Exemplo n.º 10
0
 public function addnew()
 {
     if ($this->_submit_validateUsuario() === FALSE) {
         $this->add();
         return;
     } else {
         $usuario = Current_User::user();
         $record = array('name' => $this->input->post("name"), 'lastname' => $this->input->post("lastname"), 'username' => $this->input->post("username"), 'password' => User_model::transform_password($this->input->post("password")), 'date_created' => date("Ymd"), 'created_by' => $usuario->username);
         $this->db->insert("admusers", $record);
         $this->addpermisos($this->db->insert_id());
         redirect("usuario/addSuccess");
     }
     redirect("usuario");
 }