Advertisement
Guest User

Untitled

a guest
Jun 8th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.62 KB | None | 0 0
  1. <?php
  2. function GetId($account) {
  3.   include('configs/conf.php');
  4.   $stmt = $conn->prepare("SELECT id FROM account WHERE username = ?");
  5.   $stmt->bind_param("s", $account);
  6.   $stmt->execute();
  7.   $stmt->bind_result($id);
  8.   $stmt->store_result();
  9.   $stmt->fetch();
  10.   if ($stmt->num_rows > 0) {
  11.     return $id;
  12.   }
  13. }
  14.  
  15. function getavatar($account) {
  16.   include('configs/conf.php');
  17.   mysqli_select_db($conn, $webdbname);
  18.   $stmt = $conn->prepare("SELECT avatarpic FROM accounts WHERE username = ?");
  19.   $stmt->bind_param("s", $account);
  20.   $stmt->execute();
  21.   $stmt->bind_result($avatar);
  22.   $stmt->store_result();
  23.   if($stmt->num_rows > 0) {
  24.     while($stmt->fetch()) {
  25.       if(file_exists('images/avatars/'.$avatar)){
  26.         return $avatar;
  27.       } else {
  28.         $update_avatar = $conn->prepare("UPDATE accounts SET avatarpic = 'unknown.png' WHERE username = ?");
  29.         $update_avatar->bind_param("s", $_SESSION['username']);
  30.         $update_avatar->execute();
  31.         return 'unknown.png';
  32.       }
  33.     }
  34.   }
  35. }
  36.  
  37. function getgmlevel($id, $type) {
  38.   include("configs/conf.php");
  39.   $stmt = $conn->prepare("SELECT gmlevel FROM account_access WHERE id = ?");
  40.   $stmt->bind_param("i", $id);
  41.   $stmt->execute();
  42.   $stmt->bind_result($gmLevel);
  43.   $stmt->fetch();
  44.   #$result = $stmt->get_result();1
  45.  if($type == 0) {
  46.     return $gmLevel;
  47.   }elseif($type == 1) {
  48.     switch($gmLevel) {
  49.       case "None":
  50.       return "Player";
  51.       break;
  52.  
  53.       case"1":
  54.       return "GM";
  55.       break;
  56.  
  57.       case"2":
  58.       return "Moderator";
  59.       break;
  60.  
  61.       case"3";
  62.       return "Admin";
  63.       break;
  64.  
  65.       case"4":
  66.       return "Console";
  67.       break;
  68.  
  69.       case $gmLevel>4:
  70.         return "&#9940; Unk &#9940;";
  71.         break;
  72.  
  73.       default:
  74.         return "Player";
  75.         break;
  76.     }
  77.   } else {
  78.     return "unknown type?";
  79.   }
  80. }
  81.  
  82.   function getcoins($id, $cointype) {
  83.       include("configs/conf.php");
  84.       mysqli_select_db($conn, $webdbname);
  85.       $stmt = $conn->prepare("SELECT vp, dp FROM accounts WHERE id = ?");
  86.       $stmt->bind_param("i", $id);
  87.       $stmt->execute();
  88.       $stmt->bind_result($vp, $dp);
  89.         $stmt->store_result();
  90.         $stmt->fetch();
  91.       if($stmt->num_rows() == 0) {
  92.         $insert_acc = $conn->prepare("INSERT INTO accounts(id, username, avatarpic) VALUES (?, ?, 'unknown.png')");
  93.         $insert_acc->bind_param("is", $id, $_SESSION['username']);
  94.         $insert_acc->execute();
  95.         return 0;
  96.       } else {
  97.         if ($cointype == 0) {
  98.           return $vp;
  99.         } elseif($cointype == 1) {
  100.           return $dp;
  101.         } else {
  102.           return "unknown";
  103.         }
  104.       }
  105.  
  106.   }
  107.  
  108.   function loadSession($accDetails_text, $login_text, $first_text, $second_text, $thrid_text, $fourth_text) {
  109.     include("configs/conf.php");
  110.  
  111.     // Checks if form has been submitted
  112.     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  113.         function post_captcha($user_response) {
  114.             $fields_string = '';
  115.             $fields = array(
  116.                 'secret' => $secretkey,
  117.                 'response' => $user_response
  118.             );
  119.             foreach($fields as $key=>$value)
  120.             $fields_string .= $key . '=' . $value . '&';
  121.             $fields_string = rtrim($fields_string, '&');
  122.  
  123.             $ch = curl_init();
  124.             curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/recaptcha/api/siteverify');
  125.             curl_setopt($ch, CURLOPT_POST, count($fields));
  126.             curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  127.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
  128.  
  129.             $result = curl_exec($ch);
  130.             curl_close($ch);
  131.  
  132.             return json_decode($result, true);
  133.         }
  134.  
  135.         // Call the function post_captcha
  136.         $res = post_captcha($_POST['g-recaptcha-response']);
  137.  
  138.         if (!$res['success']) {
  139.             // What happens when the CAPTCHA wasn't checked
  140.             echo '<p>Please go back and make sure you check the security CAPTCHA box.</p><br>';
  141.         } else {
  142.             // If CAPTCHA is successfully completed...
  143.  
  144.             // Paste mail function or whatever else you want to happen here!
  145.             echo '<br><p>CAPTCHA was completed successfully!</p><br>';
  146.         }
  147.     } else {
  148.  
  149.     if(!isset($_SESSION['username'])) {
  150.       echo "<div class='card-header'>$login_text</div>";
  151.       echo "<div class='card-body'>";
  152.       echo "<div class='output'></div>";
  153.       echo "<form action='../functions/login.php' method='POST' class='myForm' autocomplete='on'>";
  154.       echo "<div class='form-group'>";
  155.       echo "<label for='loginuser'>User:</label>";
  156.       echo "<input type='text' class='form-control' id='loginuser' name='user'>";
  157.       echo "</div>";
  158.       echo "<div class='form-group'>";
  159.       echo "<label for='loginpass'>Password:</label>";
  160.       echo "<input type='password' class='form-control' id='loginpass' name='pass' autocomplete='new-password'>";
  161.       echo "</div>";
  162.       echo '<div class="g-recaptcha" data-sitekey="'.$sitekey.'"></div>';
  163.       echo "<input type='submit' value='Login' class='btn btn-primary'>";
  164.       echo "</form>";
  165.       echo "</div>";
  166.     }else{
  167.         include('configs/conf.php');
  168.         mysqli_select_db($conn, $dbname);
  169.         $stmt = $conn->prepare("SELECT id, email, locked FROM account WHERE username = ?");
  170.         $stmt->bind_param("s", $_SESSION['username']);
  171.         $stmt->execute();
  172.         $stmt->bind_result($id, $email, $locked);
  173.         $stmt->store_result();
  174.         $stmt->fetch();
  175.         if($locked == 0) {
  176.           $locked = "Active";
  177.         }elseif ($locked == 1) {
  178.           $locked = "Locked";
  179.         }
  180.         echo "<div class='card-header'>$accDetails_text</div>";
  181.         echo "<div class='card-body'>";
  182.         echo "<table class='table left-panel-table'>";
  183.         echo "<tr>";
  184.         echo "<td>$first_text</td>";
  185.         echo "<td>$second_text</td>";
  186.         echo "</tr>";
  187.         echo "<tr>";
  188.         echo "<td><strong>".$_SESSION['username']."</strong></td>";
  189.         echo "<td><strong>".getgmlevel($id, 1)."</strong></td>";
  190.       #  echo "<td>".$locked."</td>";
  191.        echo "</tr>";
  192.         echo "<tr>";
  193.         echo "<td>$thrid_text</td>";
  194.         echo "<td>$fourth_text</td>";
  195.         echo "</tr>";
  196.         echo "<tr>";
  197.         echo "<td><strong>".getcoins($id, 0)."</strong></td>";
  198.         echo "<td><strong>".getcoins($id, 1)."</strong></td>";
  199.         echo "</tr>";
  200.         echo "</table>";
  201.         echo "<a href='../functions/logout.php'>Logout</a>";
  202.         echo "<div style='float: right;'><a href='/ucp'>User Panel</a></div>";
  203.         echo "</div>";
  204.     }
  205.     return;
  206.   }
  207. }
  208. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement