Advertisement
Guest User

Untitled

a guest
Apr 1st, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * This will be the class for all user interaction with the website like
  5. * login, register, user profiles, and so forth, there will be other classes
  6. * for other things like groups, regions, money, land, and soon the market one.
  7. *
  8. * in here there will be the following classes to be used.
  9. * register
  10. * profileshow
  11. * profileupdate
  12. * signin
  13. *
  14. */
  15.  
  16. class user{
  17. protected $db;
  18. public function __construct($db) {
  19. $this->db = $db;
  20. }
  21.  
  22. public function login($firstname,$lastname,$password)
  23. {
  24. $r = '';
  25. try
  26. {
  27. $sqluser = "SELECT * FROM `UserAccounts` WHERE `FirstName` = '$firstname' AND `LastName` = '$lastname'";
  28. $name = $this->db->query($sqluser);
  29. foreach($name as $row1)
  30. {
  31. $useruuid = $row1['PrincipalID'];
  32. $r = true;
  33. }
  34. } catch (vNoRowsException $e) {
  35. $r = false;
  36. }
  37. if($r == true)
  38. {
  39. $sqlauth = "SELECT * FROM `auth` WHERE `UUID` = '$useruuid'";
  40. $auth = $this->db->query($sqlauth);
  41. foreach($auth as $row2)
  42. {
  43. $dbpassword = $row2['passwordHash'];
  44. $dbsalt = $row2['passwordSalt'];
  45. }
  46. $password = md5(md5($password).":".$dbsalt); ;
  47. if($password == $dbpassword)
  48. {
  49. $success == true;
  50. }
  51. elseif($password != $dbpassword)
  52. {
  53. $succsess = false;
  54. }
  55.  
  56. $status = "Success";
  57. }elseif($r == false);
  58. {
  59. $status = 'Failed';
  60. }
  61. $message = "this is bad";
  62. $array = array($status,$message,$useruuid,$password,$dbpassword,$dbsalt,$r);
  63. return $array;
  64. // check the db for user account.
  65. // check the password for the account.
  66. // check user account for being active and such
  67. // if all ok get details and send to login
  68. // if failed then send why
  69.  
  70. }
  71.  
  72. public function register($firstName,$lastName,$email,$password,$avatar)
  73. {
  74. $this->db->query('BEGIN');
  75. /*
  76. * This is the uuid's for the system clothes items and such
  77. */
  78. // may just do a while $i < n) .....
  79. $uuid1 = uuid::generate();
  80.  
  81. /*
  82. * This is the standard info that will be put in generally user accounts
  83. */
  84. $serviceURLs = 'HomeURI=http%3a%2f%2flogin.openvirtuallife.com%3a8002%2f InventoryServerURI=http%3a%2f%2flogin.openvirtuallife.com%3a8002%2f AssetServerURI=http%3a%2f%2flogin.openvirtuallife.com%3a8002%2f ProfileServerURI=http%3a%2f%2flogin.openvirtuallife.com%3a8002%2f FriendsServerURI=http%3a%2f%2flogin.openvirtuallife.com%3a8002%2f IMServerURI=http%3a%2f%2flogin.openvirtuallife.com%3a8002%2f GroupsServerURI=http%3a%2f%2flogin.openvirtuallife.com%3a8002%2f GatekeeperURI=http%3a%2f%2flogin.openvirtuallife.com%3a8002';
  85. $scopeID = uuid::zero();
  86. $active = 0;
  87. $userFlags = "-1";
  88. $userLevel = 0;
  89. $created = time(); // unix time stamp
  90. $avatarFirstName = $firstName;
  91. $avatarLastName= $lastName;
  92. $avatarEmail = $email;
  93. $avatarUUID = $uuid1;
  94. // do here the db insertt file.
  95. $uasql = "INSERT INTO `UserAccounts` (`PrincipalID`, `ScopeID`, `FirstName`,"
  96. . " `LastName`, `Email`, `ServiceURLs`, `Created`, `UserLevel`, `UserFlags`, `UserTitle`, `active`) VALUES "
  97. . "('$avatarUUID','$scopeID','$avatarFirstName','$avatarLastName','$avatarEmail','$serviceURLs'"
  98. . ",'$created','$userLevel','$userFlags','','$active')";
  99. $this->db->execute($uasql);
  100. /*
  101. * auth details
  102. */
  103. $passwordSalt = md5(uuid::generate());
  104. $avatarPassword = md5(md5($password).';'.$passwordSalt); // need to do the config for thee password changing.
  105. $avatarID = $avatarUUID;
  106. // do the $db inserts now
  107. $authsql = "";
  108. $this->db-execute($authsql);
  109. /*
  110. * this is the inventory folders
  111. */
  112.  
  113.  
  114. // do the $db instert.
  115. /*
  116. * $avatar will be done later this will be a picked system for male/female and different types
  117. */
  118. $avatar = $avatar;
  119.  
  120.  
  121. $this->db->query('COMMIT');
  122. return true;
  123. }
  124.  
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement