Advertisement
GWibisono

check.php

Jan 24th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.01 KB | None | 0 0
  1. <?php
  2. ob_start();
  3.     echo myUri(2);
  4.  
  5.     print_r($_POST);//username, password, type
  6.     $select="<option>Pilih Tipe</option>";
  7.    
  8.     foreach($_POST as $nm=>$val)$$nm=$val;
  9.     $sql="select * from `".prefix()."users` where username='$username'";
  10.    
  11.     $userData= queryFetch($sql);
  12.    
  13.     if($userData['password'])
  14.     {
  15. //PROSES CHECK APAKAH PASSWORD BENAR.. proses ini milik joomla
  16.         $ar=explode(":",$userData['password']);
  17.         $pass=md5($password.$ar[1]).":$ar[1]";
  18.         $sql="select count(password) c from `".prefix()."users`
  19.         where username='$username' and password='$pass'";
  20.         echo $sql;
  21.         $row=queryFetch($sql);
  22.         $loginOK=$row['c']==1?TRUE:FALSE;
  23. //password salah
  24.         if(!$loginOK)
  25.             $alert="Periksa kembali User dan Password Anda";
  26.     }else{
  27.         $loginOK=FALSE;
  28.         $alert="Periksa kembali User Anda";
  29.     }
  30.    
  31.     if(intval($type)==0&&$loginOK==TRUE)
  32.     {
  33.     //==============LIST YANG BISA DI AMBIL
  34.         $sql="select role_id id, role_name name
  35.         from `".prefix()."hrd_role` role, `".prefix()."hrd_userrole` userrole
  36.         where role.role_id=urole_role
  37.         and urole_user=$userData[id]";
  38.         $q=query($sql);
  39.         $select="";
  40.         while($row=fetch($q))
  41.         {
  42.             $select.="<option value='{$row['id']}'>{$row['name']}</option>";
  43.         }
  44.        
  45.     }elseif($loginOK==TRUE){
  46.         $sql="select count(role_name) c
  47.         from `".prefix()."hrd_role` role, `".prefix()."hrd_userrole` userrole
  48.         where role.role_id=urole_role
  49.         and urole_user=$userData[id]
  50.         and urole_role=$type";
  51.         $row=queryFetch($sql);
  52.         $loginOK=$row['c']==1?TRUE:FALSE;
  53.         $loginOK=="TRUE"?$url=my_url()."usercp":$url=NULL;
  54. //===bila tipe yang dipilih tidak sesuai tidak akan di proses
  55.         if(!$loginOK){
  56.             $alert="Periksa kembali Role Anda";
  57.         }else{
  58.             $alert="Selamat Datang ".$userData['name'];
  59.         }
  60.     }
  61.    
  62.     $post=ob_get_contents();
  63.     ob_end_clean();    
  64.     $a=array(
  65.         'post'=>$post
  66.     );
  67.    
  68.     if(isset($select))
  69.     {
  70.         $a['type']=$select;
  71.     }
  72.    
  73.     if(isset($url))
  74.     {
  75.         $a['url']=$url;
  76.     }
  77.    
  78.     if(isset($alert))
  79.     {
  80.         $a['alert']=$alert;
  81.     }
  82.    
  83.     $json= json_encode($a);
  84. die($json);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement