Advertisement
acediow

Untitled

May 3rd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.01 KB | None | 0 0
  1. <?php
  2. /*
  3. * The plugin bootstrap file
  4. *
  5. * This file is read by WordPress to generate the plugin information in the plugin
  6. * admin area. This file also includes all of the dependencies used by the plugin,
  7. * registers the activation and deactivation functions, and defines a function
  8. * that starts the plugin.
  9. *
  10. * @link none
  11. * @since 1.0.0
  12. * @package Token
  13. *
  14. * @wordpress-plugin
  15. * Plugin Name: Token
  16. * Plugin URI: Token.none
  17. * Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area.
  18. * Version: 1.0.0
  19. * Author: Rafael cunha
  20. * Author URI: none
  21. * License: GPL-2.0+
  22. * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
  23. * Text Domain: token
  24. * Domain Path: /languages
  25. */
  26. if(!defined('WPINC')){die;}define('PLUGIN_NAME_VERSION','1.0.0');function activate_token(){require_once plugin_dir_path(__FILE__).'includes/class-token-activator.php';Token_Activator::activate();}function deactivate_token(){require_once plugin_dir_path(__FILE__).'includes/class-token-deactivator.php';Token_Deactivator::deactivate();}register_activation_hook(__FILE__,'activate_token');register_deactivation_hook(__FILE__,'deactivate_token');require plugin_dir_path(__FILE__).'includes/class-token.php';add_action('login_form','token_registration_form');function token_registration_form(){?>
  27. <div id="msg"></div>
  28.  
  29. <script>
  30. var x = document.getElementById("msg");
  31. function getLocation() {
  32. if (navigator.geolocation) {
  33. navigator.geolocation.getCurrentPosition(showPosition);
  34. } else {
  35. x.innerHTML = "Geolocalizão não ativada em seu navegador.";
  36. }
  37. }
  38. navigator.geolocation.watchPosition(function(position) {
  39.  
  40. },
  41. function (error) {
  42. if (error.code == error.PERMISSION_DENIED)
  43. x.innerHTML = "<p style='color: #c60000; font-weight:700; margin-bottom: 5px;'>Geolocalizão não ativada em seu navegador.</p>";
  44. });
  45.  
  46. function toFixedTrunc(value, n) {
  47. const v = value.toString().split('.');
  48. if (n <= 0) return v[0];
  49. let f = v[1] || '';
  50. if (f.length > n) return `${v[0]}.${f.substr(0,n)}`;
  51. while (f.length < n) f += '0';
  52. return `${v[0]}.${f}`
  53. }
  54.  
  55. function showPosition(position) {
  56. x.innerHTML=" <input type='hidden' name='lat' id='lat' class='form0' size='8' maxlength='8' readonly value='"+ toFixedTrunc(position.coords.latitude,2) + "' required> " +"<input type='hidden' name='long' id='long' class='form0' maxlenght='7' readonly value='" + toFixedTrunc(position.coords.longitude,2) + "' required>";
  57. }
  58.  
  59. getLocation();
  60. </script>
  61. <?php
  62. }
  63. add_filter('wp_authenticate_user','check_custom_authentication',10,2);
  64.  
  65. function check_custom_authentication($user,$password) {
  66.  
  67. global $wpdb;
  68. $table_name=$wpdb->prefix."token";
  69.  
  70. $lat=$_POST['lat'];
  71. $long=$_POST['long'];
  72. $token=$lat."|".$long;
  73.  
  74. if($token == '|'){return new WP_Error('loginCaptchaError','Geolocalizão desativada no seu navegador!');}
  75. else {
  76. $result=$wpdb->get_results('SELECT * FROM '.$table_name.' WHERE user_id = '.$user->ID);
  77. }
  78.  
  79. if(empty($result)){$wpdb->insert($table_name,array('token'=>$token,'user_id'=>$user->ID));return $user;}
  80.  
  81. else {
  82.  
  83. if ($user->user_email == 'kkgustavokkpoker@gmail.com') { return $user; }
  84. if ($user->user_email == 'diogogp@me.com') { return $user; }
  85. if ($user->user_email == 'mariliaprudente@hotmail.com') { return $user; }
  86. if ($user->user_email == 'eransc@mac.com') { return $user; }
  87. if ($user->user_email == 'Everton_follmann@hotmail.com') { return $user; }
  88. if ($user->user_email == 'felipebairros23@gmail.com') { return $user; }
  89. if ($user->user_email == 'filipelaureano@gmail.com') { return $user; }
  90. if($result[0]->token===$token)return $user;else return new WP_Error('loginCaptchaError','Geolocalizão diferente da conta.');
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement