Advertisement
Guest User

Untitled

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