Advertisement
Guest User

Untitled

a guest
Nov 13th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. function signup(){
  2. global $request;
  3. $request->enable_super_globals();
  4. if (isset($_POST["submit"])) {
  5.  
  6. $username = $_POST["username"];
  7. $password = $_POST["password"];
  8. $email = $_POST["email"];
  9.  
  10. $ip = $request->variable('REMOTE_ADDR', ''); // means we get user's IP address
  11.  
  12. /*
  13. in case you want to get the real timezone the php way
  14.  
  15. $json = file_get_contents( 'http://smart-ip.net/geoip-json/' . $ip); // this one service we gonna use to obtain timezone by IP
  16. // maybe it's good to add some checks (if/else you've got an answer and if json could be decoded, etc.)
  17. $ipData = json_decode( $json, true);
  18.  
  19. if ($ipData['timezone']) {
  20. $tz = new DateTimeZone( $ipData['timezone']);
  21. $now = new DateTime( 'now', $tz); // DateTime object corellated to user's timezone
  22. } else {
  23. // we can't determine a timezone - do something else...
  24.  
  25. */
  26.  
  27. $user_row = array(
  28. 'username' => $username,
  29. 'user_password' => phpbb_hash($password),
  30. 'user_email' => $email,
  31. 'group_id' => 2, // by default, the REGISTERED user group is id 2
  32. 'user_timezone' => (float) "UTC", // no idea if this works
  33. 'user_lang' => "eng",
  34. 'user_type' => USER_NORMAL, // why no "" ???
  35. 'user_ip' => $ip,
  36. 'user_regdate' => time(),
  37. );
  38. // Register user...
  39. $user_id = user_add($user_row);
  40.  
  41. echo "<h1>Registered you now can log in</h1>";
  42.  
  43. }
  44. else
  45. echo "Failed";
  46. $request->disable_super_globals();
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement