Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.92 KB | None | 0 0
  1. <?php
  2. $headers  = 'MIME-Version: 1.0' . "\r\n";
  3. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  4.  
  5. $servername = "db";
  6. $username = "username";
  7. $password = "password";
  8. $dbname = "dbname";
  9.  
  10. $allowed = array("user1", "user2", "user3","user4");
  11.  
  12. // Create connection
  13. $conn = new mysqli($servername, $username, $password, $dbname);
  14. // Check connection
  15. if ($conn->connect_error) {
  16.    die("Connection failed: " . $conn->connect_error);
  17. }
  18.  
  19. echo "<head><title>PokeNamur ARENES</title></head>";
  20.  
  21. if (in_array($_SERVER['PHP_AUTH_USER'],$allowed) ) {
  22.    echo "<form name='form' method='post' action=''>";
  23.    echo "Nom: <input type='text' name='name' id='name' value='".$_SERVER['PHP_AUTH_USER']."'>&nbsp;";
  24.    echo "<input type='submit' name='Envoyer' value='Envoyer'>";
  25.    echo "</form>";
  26. } else { $_POST[name] = $_SERVER['PHP_AUTH_USER'] ; }
  27.  
  28.  
  29. $count = "SELECT count(*) as total
  30.        FROM gympokemon
  31.        JOIN gymmember ON  gympokemon.pokemon_uid = gymmember.pokemon_uid
  32.        JOIN gym ON  gymmember.gym_id = gym.gym_id
  33.        JOIN gymdetails ON gymdetails.gym_id = gym.gym_id
  34.        WHERE trainer_name = '".$_POST[name]."'" ;
  35.  
  36. $sql = "SELECT pokemon_id, cp, concat(ifnull(description,''),' ',name) AS gym_name, gym_points, latitude, longitude, CONVERT_TZ(gym.last_scanned,'+00:00','+01:00') AS last_scanned, url
  37.        FROM gympokemon
  38.        JOIN gymmember ON  gympokemon.pokemon_uid = gymmember.pokemon_uid
  39.        JOIN gym ON  gymmember.gym_id = gym.gym_id
  40.        JOIN gymdetails ON gymdetails.gym_id = gym.gym_id
  41.        WHERE trainer_name = '".$_POST[name]."'
  42.    ORDER BY cp DESC" ;
  43.  
  44. $result = $conn->query($sql);
  45. $count_result = $conn->query($count);
  46.  
  47. if(!empty($_POST['name'])) {
  48.         echo "<B>".$_POST[name]."</B>";
  49.     while($row = $count_result->fetch_assoc()) {
  50.           echo "<B>&nbsp;DETIENT <font color='red'>".$row["total"]."</font>&nbsp;ARENES</B><BR><BR>";
  51.         }
  52. }
  53. else {
  54.         echo "<B>AUCUN RESULTAT A AFFICHER</B><BR>";
  55.         echo "<B>VEUILLEZ INDIQUER VOTRE NOM DE JOUEUR</B><BR>";
  56. }
  57.  
  58. if ($result->num_rows > 0) {
  59.         echo "<CENTER><TABLE BORDER=1 CELLPADDING='10'>";
  60.         echo "<TR>";
  61.         echo "<TD></TD>";
  62.         echo "<TD><B>NOM ARENE</B></TD>";
  63.         echo "<TD ALIGN='CENTER'><B>POKEMON</B></TD>";
  64.         echo "<TD ALIGN='CENTER'><B>POINTS ARENE</B></TD>";
  65.         echo "<TD ALIGN='CENTER'><B>DATE MAJ</B></TD>";
  66.         echo "</TR>";
  67.         while($row = $result->fetch_assoc()) {
  68.                 echo "<TR>";
  69.                 echo "<TD><A HREF='".$row["url"]."'><IMG SRC='".$row["url"]."'WIDTH=100'</IMG></A></TD>";
  70.                 echo "<TD>".utf8_encode($row["gym_name"])."<BR><BR><a href='http://www.google.com/maps/place/".$row["latitude"].",".$row["longitude"]."'>Instructions GPS</a><BR><BR>".$row["latitude"].",".$row["longitude"]."</TD>";
  71.                 echo "<TD ALIGN='CENTER' WIDTH=100><IMG SRC='./icons/".$row["pokemon_id"].".png' WIDTH=50 </IMG><BR>";
  72.                 echo "".$row["cp"]."&nbsp;CP</TD>";
  73.                 if ($row["gym_points"] > 0) { $lvl = 1;}
  74.                 if ($row["gym_points"] >= 4000) { $lvl = 2;}
  75.                 if ($row["gym_points"] >= 6000) { $lvl = 3;}
  76.                 if ($row["gym_points"] >= 8000) { $lvl = 4;}
  77.                 if ($row["gym_points"] >= 12000) { $lvl = 5;}
  78.                 if ($row["gym_points"] >= 16000) { $lvl = 6;}
  79.                 if ($row["gym_points"] >= 20000) { $lvl = 7;}
  80.                 if ($row["gym_points"] >= 30000) { $lvl = 8;}
  81.                 if ($row["gym_points"] >= 40000) { $lvl = 9;}
  82.                 if ($row["gym_points"] >= 50000) { $lvl = 10;}
  83.                 echo "<TD ALIGN='CENTER'><IMG SRC='./shield/Valor_".$lvl.".png' WIDTH=50 </IMG><BR>".$row["gym_points"]."</TD>";
  84.                 echo "<TD ALIGN='CENTER' WIDTH=100>".$row["last_scanned"]."</TD>";
  85.                 echo "</TR>";
  86.         }
  87.         echo "</TABLE></CENTER>";
  88. } else {
  89. }
  90. $conn->close();
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement