| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 3.1.13 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <info@fireplugins.com> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace FireBox\Core\Tables; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) |
| 15 |
{ |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
use FPFramework\Includes\DB; |
| 20 |
|
| 21 |
class Boxlog extends DB |
| 22 |
{ |
| 23 |
/** |
| 24 |
* The column list below covers this table in full, so inserts can safely be |
| 25 |
* restricted to it. |
| 26 |
* |
| 27 |
* @var bool |
| 28 |
*/ |
| 29 |
protected $enforce_insert_columns = true; |
| 30 |
|
| 31 |
public function __construct() |
| 32 |
{ |
| 33 |
$this->table_name = 'firebox_logs'; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Returns whether the given impression log belongs to the given campaign. |
| 38 |
* |
| 39 |
* Conversion events are logged against a log_id supplied by the client, so without |
| 40 |
* this any visitor could attribute conversions to impressions that never happened or |
| 41 |
* that belong to another campaign. |
| 42 |
* |
| 43 |
* @param int $log_id |
| 44 |
* @param int $box_id |
| 45 |
* |
| 46 |
* @return bool |
| 47 |
*/ |
| 48 |
public function belongsToCampaign($log_id, $box_id) |
| 49 |
{ |
| 50 |
$log_id = (int) $log_id; |
| 51 |
$box_id = (int) $box_id; |
| 52 |
|
| 53 |
if ($log_id <= 0 || $box_id <= 0) |
| 54 |
{ |
| 55 |
return false; |
| 56 |
} |
| 57 |
|
| 58 |
global $wpdb; |
| 59 |
|
| 60 |
return (bool) $wpdb->get_var($wpdb->prepare( |
| 61 |
"SELECT 1 FROM `{$this->getFullTableName()}` WHERE id = %d AND box = %d LIMIT 1",// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
| 62 |
$log_id, |
| 63 |
$box_id |
| 64 |
)); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Get columns and formats |
| 69 |
* |
| 70 |
* @return array |
| 71 |
*/ |
| 72 |
public function get_columns() |
| 73 |
{ |
| 74 |
return [ |
| 75 |
'id' => '%d', |
| 76 |
'sessionid' => '%s', |
| 77 |
'visitorid' => '%s', |
| 78 |
'user' => '%d', |
| 79 |
'box' => '%d', |
| 80 |
'page' => '%s', |
| 81 |
'country' => '%s', |
| 82 |
'device' => '%s', |
| 83 |
'referrer' => '%s', |
| 84 |
'date' => '%s', |
| 85 |
]; |
| 86 |
} |
| 87 |
} |