Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.73 KB | None | 0 0
  1. <?php
  2.  
  3. require "scripts/connect.php";
  4.  
  5. if(HTTPS){
  6. echo " <script>
  7. if (window.location.protocol != 'https:')
  8. window.location.href = 'https:' + window.location.href.substring(window.location.protocol.length);
  9. </script> ";
  10. }
  11.  
  12. if (NOINDEX) {
  13. $meta = "noindex, ";
  14. } else {
  15. $meta = "index, ";
  16. }
  17. if (NOFOLLOW) {
  18. $meta .= "nofollow";
  19. } else {
  20. $meta .= "follow";
  21. }
  22.  
  23. if(!isset($_GET['page'])) $_GET['page'] = '';
  24. if($_GET['page'] == 'logout'){
  25. $link->query("DELETE FROM `auth_keys` WHERE `key` = '".$_COOKIE['auth_key']."'");
  26. setcookie("usr", "", time() - 3600);
  27. setcookie("auth_key", "", time() - 3600);
  28. }
  29.  
  30. function generateRandomString($length = 10) {
  31. $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  32. $charactersLength = strlen($characters);
  33. $randomString = '';
  34. for ($i = 0; $i < $length; $i++) {
  35. $randomString .= $characters[rand(0, $charactersLength - 1)];
  36. }
  37. return $randomString;
  38. }
  39.  
  40. if(isset($_POST['login']) AND $_POST['login'] == 1){
  41. if($_POST['usr'] == '' OR $_POST['pw'] == ''){
  42. $error = '<div class="al_alert">Please enter username and password</div>';
  43. }else{
  44. $result = $link->query("SELECT * FROM `users` WHERE `username` = '".$link->real_escape_string($_POST['usr'])."' AND `password` = '".$link->real_escape_string($_POST['pw'])."'");
  45.  
  46. if($result->num_rows > 0){
  47. setcookie('usr', md5($_POST['usr']), time() + 14400, "/");
  48. setcookie('auth_key', $cookie_value = generateRandomString(), time() + 14400, "/");
  49. $key = $cookie_value;
  50. $usr = md5($_POST['usr']);
  51. $link->query("DELETE FROM `auth_keys` WHERE `user` = '".$_POST['usr']."'");
  52. $link->query("INSERT INTO `auth_keys` (`user`,`key`) VALUES ('".$_POST['usr']."','".$cookie_value."')");
  53. }else{
  54. $error = '<div class="al_alert">Username or password are incorrect</div>';
  55. }
  56. }
  57. }
  58.  
  59. function getButton($name, $url){
  60. echo "<a href='?page=$url'> <div style='cursor: pointer;' class='al_btn'>
  61. <div class='anim_btn'>
  62. $name
  63. </div>
  64. $name
  65. </div> </a>";
  66. }
  67.  
  68. $loggedIn = 0;
  69. if(!isset($usr) AND isset($_COOKIE['usr'])) $usr = $_COOKIE['usr'];
  70. if(!isset($key) AND isset($_COOKIE['auth_key'])) $key = $_COOKIE['auth_key'];
  71. if(!isset($key)) $key = '';
  72. if(!isset($usr)) $usr = '';
  73. $res = $link->query("SELECT * FROM `auth_keys` WHERE `key`='".$key."'");
  74. if($res->num_rows > 0) if(md5(mysqli_result($res, 0, 'user')) == $usr) $loggedIn = 1;
  75.  
  76. $page = $_GET["page"];
  77. if($page == '' OR $page == 'logout') $page = "dashboard";
  78. if($loggedIn == 0) $page = "login";
  79. ?>
  80.  
  81.  
  82. <!DOCTYPE html>
  83. <html ng-app="License">
  84. <head>
  85. <meta charset="utf-8">
  86. <title>AdvancedLicense-System</title>
  87.  
  88. <meta name="robots" content="<?php echo $meta; ?>">
  89.  
  90. <script src='https://code.jquery.com/jquery-latest.min.js' type='text/javascript'></script>
  91. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
  92. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
  93. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
  94.  
  95. <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"> </script>
  96.  
  97. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
  98. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
  99. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular-animate.js"></script>
  100. <link href='https://fonts.googleapis.com/css?family=Quicksand' rel='stylesheet' type='text/css'>
  101. <script type="text/javascript" src="scripts/Angular.JS"></script>
  102. <link rel='stylesheet' href='css/master.css' type='text/css' charset='utf-8'>
  103. </head>
  104. <body>
  105. <div class="al_nav">
  106. <div class="title">
  107. {vakaris}
  108. <i>Plugin Licenses</i>
  109. </div>
  110.  
  111. <?php getButton(" Dashboard","dashboard"); ?>
  112. <?php getButton(" Manage  license","manage"); ?>
  113. <?php getButton(" Add license","add"); ?>
  114. <?php getButton(" Logout","logout"); ?>
  115. </div>
  116.  
  117. <div class="content"> <?php require "content/$page.php"; ?> </div>
  118. </body>
  119. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement