File: /home/vspt/public_html/vinamar.vsptdigital.cl/wp-content/plugins/winwheel4wp/lib/ace_engine.php
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
class winwheel4wp_ace_engine {
private $db_run_log_table;
public function __construct( $config ) {
$this->db_run_log_table = $config;
}
public function count_spins( $args ) {
global $wpdb;
return $wpdb->get_row($wpdb->prepare('SELECT COUNT(*) as count FROM '.$this->db_run_log_table.' WHERE wheel_id = %s AND '.$args['column'].' = %s AND timestamp > %s AND skip_counting = 0',
$args['wheel_hash'],
$args['form_data'],
time() - ($args['max_age'])))->count;
}
public function last_timestamp( $args ) {
global $wpdb;
return $wpdb->get_row($wpdb->prepare('SELECT timestamp FROM '.$this->db_run_log_table.' WHERE wheel_id = %s AND '.$args['column'].' = %s AND skip_counting = 0 ORDER BY timestamp DESC',
$args['wheel_hash'],
$args['form_data']))->timestamp;
}
public function remaining_minutes( $args ) {
return ceil((($args['max_age']) - (time() - $this->last_timestamp( $args ) ))/60);
}
}