Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * The plugin bootstrap file
- *
- * This file is read by WordPress to generate the plugin information in the plugin
- * admin area. This file also includes all of the dependencies used by the plugin,
- * registers the activation and deactivation functions, and defines a function
- * that starts the plugin.
- *
- * @link none
- * @since 1.0.0
- * @package Token
- *
- * @wordpress-plugin
- * Plugin Name: Token
- * Plugin URI: Token.none
- * Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area.
- * Version: 1.0.0
- * Author: Rafael cunha
- * Author URI: none
- * License: GPL-2.0+
- * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
- * Text Domain: token
- * Domain Path: /languages
- */
- 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(){?>
- <div id="msg"></div>
- <script>
- var x = document.getElementById("msg");
- function getLocation() {
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(showPosition);
- } else {
- x.innerHTML = "Geolocalizão não ativada em seu navegador.";
- }
- }
- navigator.geolocation.watchPosition(function(position) {
- },
- function (error) {
- if (error.code == error.PERMISSION_DENIED)
- x.innerHTML = "<p style='color: #c60000; font-weight:700; margin-bottom: 5px;'>Geolocalizão não ativada em seu navegador.</p>";
- });
- function toFixedTrunc(value, n) {
- const v = value.toString().split('.');
- if (n <= 0) return v[0];
- let f = v[1] || '';
- if (f.length > n) return `${v[0]}.${f.substr(0,n)}`;
- while (f.length < n) f += '0';
- return `${v[0]}.${f}`
- }
- function showPosition(position) {
- 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>";
- }
- getLocation();
- </script>
- <?php
- }
- add_filter('wp_authenticate_user','check_custom_authentication',10,2);
- function check_custom_authentication($user,$password) {
- global $wpdb;
- $table_name=$wpdb->prefix."token";
- $lat=$_POST['lat'];
- $long=$_POST['long'];
- $token=$lat."|".$long;
- if($token == '|'){return new WP_Error('loginCaptchaError','Geolocalizão desativada no seu navegador!');}
- else {
- $result=$wpdb->get_results('SELECT * FROM '.$table_name.' WHERE user_id = '.$user->ID);
- }
- if(empty($result)){$wpdb->insert($table_name,array('token'=>$token,'user_id'=>$user->ID));return $user;}
- else {
- if ($user->user_email == 'kkgustavokkpoker@gmail.com') { return $user; }
- if ($user->user_email == 'diogogp@me.com') { return $user; }
- if ($user->user_email == 'mariliaprudente@hotmail.com') { return $user; }
- if ($user->user_email == 'eransc@mac.com') { return $user; }
- if ($user->user_email == 'Everton_follmann@hotmail.com') { return $user; }
- if ($user->user_email == 'felipebairros23@gmail.com') { return $user; }
- if ($user->user_email == 'filipelaureano@gmail.com') { return $user; }
- if($result[0]->token===$token)return $user;else return new WP_Error('loginCaptchaError','Geolocalizão diferente da conta.');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement