Guest User

Untitled

a guest
Oct 19th, 2017
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. <!-- Begin campaign loading -->
  2. <?php
  3. //Database Information
  4. $hostname="";
  5. $username="";
  6. $password="";
  7. $dbname="";
  8.  
  9. //Begin user session
  10. session_start();
  11.  
  12. //Connect to Database
  13. mysql_connect("$hostname","$username", "$password") or die ("<html><script language='JavaScript'>alert('Unable to connect to database! Please email contact@wulf.design'),history.go(-1)</script></html>");
  14. mysql_select_db("$dbname");
  15.  
  16. //Perform SQL command
  17. $strSQL = "SELECT * FROM games";
  18. $rs = mysql_query($strSQL);
  19.  
  20. while($row = mysql_fetch_array($rs))
  21. { //While there are rows in the array
  22. $print = false; //Print defaults to FALSE
  23.  
  24. if ($_SESSION['USERNAME'] == $row['userName'])
  25. {//Check to see if the user owns any campaigns
  26. $print = true; //If so, print = TRUE
  27. }
  28.  
  29. //Now check to see if the user is a member of any campaigns
  30. $strSQL3 = "SELECT * FROM gamePlayers WHERE '".$row['gameNumber']."' = j_gameNumber";
  31. $rs3 = mysql_query($strSQL3);
  32.  
  33. while($check2 = mysql_fetch_array($rs3))
  34. {//Check to see if they are a member of any campaign
  35. if($_SESSION['USERNAME'] == $check2['j_userName'])
  36. {//If they are, set print to TRUE
  37. $print = true;
  38. }
  39. }
  40. //If either test above is TRUE, we can begin the printing process
  41. if ($print == true)
  42. { //Print the row of information of the campaign they own or are a part of
  43. echo " <a href = '" . $row['gameName'] . ".php'> <div class='form_Area'>
  44. <p class='gameTitle'>" . $row['gameName'] . "</p>
  45. <p class='gameID'> GameID: " . $row['gameNumber'] . "</p>
  46. <p class='gameUsers'>" . $row['userName'] . " as " . $row['userType'] . " (Owner)</p>";
  47. //Now print all of the people that are a part of the campaign
  48. $strSQL2 = "SELECT * FROM gamePlayers WHERE '".$row['gameNumber']."' = j_gameNumber";
  49. $rs2 = mysql_query($strSQL2);
  50. $i = 0; //i is used to make sure the list of names printed isn't too long
  51. //Now cycle through all of the campaign rows for members
  52. while($row2 = mysql_fetch_array($rs2) )
  53. {
  54. //Print the name of the player
  55. echo "<p class='gameUsers'>-" . $row2['j_userName'] . " as " . $row2['j_userType'] . "</p>";
  56. $i++; //Add one to the "number of names" counter
  57. if ($i > 6)
  58. { //Once enough names for the space is printed, stop printing names
  59. echo "<p class='gameUsers'>+Plus More Users </p>";
  60. break; //and exit out of this print loop
  61. }
  62. }
  63.  
  64. //Close off all the HTML tags
  65. echo " </div> </a>
  66. ";
  67. //Using the name of the game, create a php page for that game
  68. $doc = fopen($row['gameName'] . ".php", "x+");
  69.  
  70. //If fopen is TRUE (meaning it does not already exist)
  71. if ($doc)
  72. {
  73. //Load up the template page that will be cloned
  74. $doc1 = fopen("template.php", "r");
  75. //Write the contents to the new file
  76. while(!feof($doc1))
  77. {
  78. fwrite($doc, fgets($doc1));
  79. }
  80. //And then close the template document
  81. fclose($doc1);
  82. }
  83. //And close the new file, as well
  84. fclose($doc);
  85. }
  86. }
  87. //Once all of this is done, close the connection to the database
  88. mysql_close();
  89. ?>
Add Comment
Please, Sign In to add comment