PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.14
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
firebox / Inc / Framework / Inc / Base / Ajax / FPGeoIP.php

FPGeoIP.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 2.1.14, at Inc/Framework/Inc/Base/Ajax/FPGeoIP.php

99 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FirePlugins Framework
4 * @version 1.1.102
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2024 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FPFramework\Base\Ajax;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class FPGeoIP
20 {
21 /**
22 * GeoIP Class
23 *
24 * @var object
25 */
26 private $geoIP;
27
28 public function __construct()
29 {
30 // Geo IP AJAX
31 add_action('wp_ajax_fpf_on_geoip_ajax', [$this, 'fpf_on_geoip_ajax']);
32 add_action('wp_ajax_nopriv_fpf_on_geoip_ajax', [$this, 'fpf_on_geoip_ajax']);
33 }
34
35 /**
36 * Geo IP Ajax
37 *
38 * @return void
39 */
40 public function fpf_on_geoip_ajax()
41 {
42 if (!current_user_can('manage_options'))
43 {
44 return;
45 }
46
47 $nonce = isset($_POST['nonce']) ? sanitize_text_field($_POST['nonce']) : '';
48
49 // verify nonce
50 if (!$verify = wp_verify_nonce($nonce, 'fpf-geo-lookup-nonce'))
51 {
52 return false;
53 }
54
55 $this->loadGeoIP();
56
57 $task = isset($_POST['task']) ? sanitize_text_field($_POST['task']) : '';
58 $license_key = isset($_POST['license_key']) ? sanitize_text_field($_POST['license_key']) : '';
59
60 $this->geoIP->setKey($license_key);
61
62 switch ($task)
63 {
64 // Update database and redirect
65 case 'update-red':
66 $result = $this->geoIP->updateDatabase();
67
68 if ($result === true)
69 {
70 echo wp_json_encode('refresh');
71 }
72 else
73 {
74 echo wp_json_encode($result);
75 }
76 break;
77 // Update database
78 case 'update':
79 echo wp_json_encode($this->geoIP->updateDatabase());
80 break;
81 // IP Lookup
82 case 'get':
83 $ip = isset($_POST['ip']) ? sanitize_text_field($_POST['ip']) : '';
84 echo wp_json_encode($this->geoIP->setIP($ip)->getRecord());
85 break;
86 }
87 wp_die();
88 }
89
90 /**
91 * Load GeoIP Classes
92 *
93 * @return void
94 */
95 private function loadGeoIP()
96 {
97 $this->geoIP = new \FPFramework\Libs\Vendors\GeoIP\GeoIP();
98 }
99 }