Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User {
- private $user_id;
- private $username;
- private $password;
- private $authentication;
- private $token;
- // costruttore
- public function __construct($idu=NULL, $usr=NULL, $psw=NULL, $aut=NULL ) {
- if ( $idu ) $this->user_id = $idu;
- if ( $usr ) $this->username = $usr;
- if ( $psw ) $this->password = md5($psw);
- if ( $aut ) $this->authentication = $aut;
- if ( $this->password != NULL)
- $this->token = substr($this->password,0,5);
- else {
- srand(mktime());
- $this->token = substr(md5(rand()),0,5);
- }
- }
- function setUsr( $usr ) {
- $this->username = $usr;
- }
- function setPsw( $psw ) {
- $this->password = md5($psw);
- }
- function setAut( $aut ) {
- $this->authentication = $aut;
- }
- function getUsr() {
- return $this->username;
- }
- function getPsw() {
- return $this->password;
- }
- function getAut() {
- return $this->authentication;
- }
- public function getTok() {
- return $this->token;
- }
- function getIdu() {
- return $this->user_id;
- }
- }
- /**/
- $db = new DBO();
- $db->connetti("kbsalso");
- $query = "SELECT * FROM user WHERE user_account = '".trim($_POST['usr'])."' LIMIT 1";
- $res = $db->estrai($db->query($query));
- if ( $res["user_password"] == md5(trim($_POST['psw'])) ) {
- $user = new User($res["user_id"],$res["user_account"],$res["user_password"],$res["user_permission"] );
- $data['code'] = 0;
- session_start();
- $data["pagelink"] = "index.php?page=main&token=".$user->getTok;
- } else $data['code'] = 2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement