Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. <?php
  2.  
  3. //session_start();
  4. include 'dbConnect.php';
  5. function loginaction(){
  6. include 'dbConnect.php';
  7. $time = time();
  8.  
  9.  
  10.  
  11. if(isset($_REQUEST['login'])){
  12. $key = $_GET['telegram_key'];
  13. $json = '{"false":"index.html","a":" admin.php","b":"leader.php","c":"user.php"}';
  14.  
  15.  
  16. $query = $db->prepare("SELECT operators.operator_id, telegramlog.telegram_key FROM telegramlog LEFT JOIN operators ON telegramlog.operator_id = operators.operator_id WHERE telegramlog.telegram_key = ?, key_time = ? ;");
  17. $query->execute(array($key,$time));
  18. $result = $query->fetchAll();
  19.  
  20.  
  21. if(isset($_REQUEST['error'])){
  22. $error= $_REQUEST['error'];
  23. echo errorDefine($num);
  24. }
  25.  
  26.  
  27. statements ($time,$row,$result,$sResult,$db,$query,$squery);
  28.  
  29. }
  30. else if (isset($_REQUEST['loginnorm'])){
  31. $username=$_REQUEST['user'];
  32. $password=$_REQUEST['pass'];
  33. $json = '{"false":"index.html","a":" admin.php","b":"leader.php","c":"user.php"}';
  34.  
  35. if(isset($_REQUEST['error'])){
  36. $error= $_REQUEST['error'];
  37. echo errorDefine($err);
  38. }
  39.  
  40. $squery = $db->prepare("SELECT * FROM operators WHERE email = ? and heslo = ?;");
  41. $sResult = $squery->execute(array($username,$password));
  42.  
  43.  
  44. statements($time,$sResult,$db,$squery,$result);
  45. }
  46.  
  47.  
  48.  
  49. }
  50. function errorDefine($num){
  51. $json = '{"0":"špatné přihlášení","1":"čas vypršel","2":"prázdné pole","3":"asi vše funguje.."}';
  52. $err = json_decode($json, true);
  53. return $err[$num];
  54. }
  55.  
  56.  
  57.  
  58. function statements($time,$sResult,$db,$squery,$result,$json){
  59.  
  60. $redirects = json_decode($json, true);
  61. $result = $result[3];
  62. $sResult = $sResult[3];
  63.  
  64.  
  65. if($time > $row['key_time']){
  66. if($result){
  67. header('location: user.php');
  68. }
  69. }
  70. elseif($sResult){
  71. while($row = $squery ->fetch(PDO::FETCH_ASSOC)){
  72. echo '<script type="text/javascript">alert("You are logged in as user '. $row['users'] . '")</script>';
  73.  
  74. if($row['users']=="a"){
  75. header('location: admin.php');
  76. }
  77. elseif($row['users']=="b"){
  78. header('location: leader.php');
  79. }
  80. elseif($row['users']=="c"){
  81. header('location: user.php');
  82. }
  83. else{
  84. return $redirects[$sResult['users']]."?err=2";
  85. }
  86. }
  87. }
  88. else if ($time < $row['key_time']) {
  89. header("location: function.php?error=1");
  90. }
  91. else if('empty'){
  92. header("location: function.php?error=3");
  93. }
  94. }
  95.  
  96.  
  97. loginaction();
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement