Profile_Page.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * User profile page file.
  4. *
  5. * Provides a class with all the properties and methods to display the page.
  6. *
  7. * @category Page
  8. */
  9. /**
  10. * Require dependent files if not present.
  11. */
  12. require_once(PATH::PAGE . "Page.php");
  13. /**
  14. * User profile page model.
  15. *
  16. * @category Page
  17. */
  18. class Profile_Page extends Page{
  19. /**
  20. * @var string Player name.
  21. */
  22. public $name;
  23. /**
  24. * @var string Player email.
  25. */
  26. public $mail;
  27. /**
  28. * @var string Player API key.
  29. */
  30. public $api_key;
  31. /**
  32. * Constructor.
  33. *
  34. * Retrieves the data and initializes the variables.
  35. *
  36. * @global int Player ID.
  37. * @global resource Database connection.
  38. */
  39. public function __construct(){
  40. global $UID;
  41. global $db;
  42. $this->view = PATH::VIEW . "profile.php";
  43. $s = "
  44. SELECT
  45. name,
  46. mail,
  47. api_key
  48. FROM player
  49. WHERE uid = '$UID';
  50. ";
  51. $q = $db->query($s);
  52. if ($r = $q->fetchArray(SQLITE3_ASSOC)){
  53. $this->name = $r["name"];
  54. $this->mail = $r["mail"];
  55. $this->api_key = $r["api_key"];
  56. }
  57. $this->title = $this->name ." - SWDB";
  58. $this->description = $this->name . " user profile";
  59. $this->canonical = URL::BASE . "profile/";
  60. }
  61. }
  62. ?>