| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 1.0.6 Free | |
| 4 | + * @version 3.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2021 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FireBox\Core\Tables; |
| @@ -19,14 +19,52 @@ | ||
| 19 | 19 | use FPFramework\Includes\DB; |
| 20 | 20 | |
| 21 | 21 | class Boxlog extends DB |
| 22 | 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 | + | |
| 23 | 31 | public function __construct() |
| 24 | 32 | { |
| 25 | 33 | $this->table_name = 'firebox_logs'; |
| 26 | - $this->primary_key = 'id'; | |
| 27 | 34 | } |
| 28 | - | |
| 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 | + | |
| 29 | 67 | /** |
| 30 | 68 | * Get columns and formats |
| 31 | 69 | * |
| 32 | 70 | * @return array |