Advertisement
Guest User

Untitled

a guest
Apr 8th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. <?php
  2. require_once 'TOOLS/Response.php';
  3. require_once 'const/GlobalParams.php';
  4. require_once 'LoggerManager.php';
  5. class Login extends CI_Controller {
  6.  
  7.     function __construct() {
  8.         parent::__construct();
  9.     }
  10.  
  11.     function index() {
  12.         $this->load->helper('url');
  13.         $this->load->library('session');
  14.         $this->load->model('Users');
  15.         $users = $this->Users->FETCH_ALL(true);
  16.         $data['users'] =$users;
  17.         $this->load->view('login_view',$data);
  18.     }
  19.     function VerifyLogin(){
  20.         $obj =& get_instance();
  21.         $logger = new LoggerManager($obj);
  22.         $jsonObj = json_decode($_POST["json"]);
  23.         $this->load->model('Users');
  24.         $response = new Response();
  25.         $id = $jsonObj->id;
  26.         $password = $jsonObj->password;
  27.         $result = $this->Users->LOGIN($id, $password);//sha1($password));
  28.         if(sizeof ($result)==0)
  29.         {
  30.            $response->Status ="badPassword";
  31.         }
  32.         else
  33.         if ( $newPassword!=null )
  34.         {
  35.             $id_user = $result[0]->id_pracownicy;
  36.             $update = array('password' =>sha1($newPassword));
  37.             $this->Users->UPDATE($id_user,$update);
  38.             $response->Status ="updated";
  39.         }    
  40.         else
  41.         {    
  42.             $this->load->model('Sessiondata');
  43.             $guid =$this->Sessiondata->ADD_NEW_SESSION($result[0]->id_pracownicy,$result[0]->username);
  44.             $response->Status ="loggedIn";
  45.             $response->Guid = $guid;
  46.             $response->Key = $this->generateKey($result[0]->id_pracownicy, $result[0]->username);
  47.             $response->Content =$this->Users->FETCH_ALL_EDITOR();
  48.         }
  49.         $logger->LOG_LOGIN($id,$response->Status);
  50.         echo json_encode($response);
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement