settings = get_option( 'adfoxly_settings' );
$this->setStatus( $this->settings[ 'statistics-status' ] );
$this->model = new StatisticsModel();
}
public function setStatus( $status ) {
$this->status = $status;
}
public function insertTables() {
$this->model->insertTables();
}
public function checkFingerPrint( $bannerId ) {
// $statistics = new Statistics();
// global $wpdb;
// $table = $statistics->dbViewsStatistics();
// $fingerprint = $this->setFingerPrint();
//
// $result = $wpdb->get_row( "SELECT COUNT(fingerprint) as fingerprint FROM $table WHERE `banner_id` = '$bannerId' AND `fingerprint` != '' AND `fingerprint` = '$fingerprint'", OBJECT );
// if ( $result && $result->fingerprint > 0 ) {
// return 1;
// } else {
// return 0;
// }
}
public function getFingerPrint() {
$ip = Adfoxly::ip();
$browser = $_SERVER[ 'HTTP_USER_AGENT' ];
$language = $_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ];
$fingerprint = "$ip + $browser + $language";
return md5( $fingerprint );
}
public function saveView( $id ) {
$this->model->saveView( $id, $this->getFingerPrint() );
}
public function saveClick( $id ) {
// $this->model->saveView( $id, $this->getFingerPrint() );
}
public function render( $id = null ) {
if ( $this->status === 'enabled' ) {
if ( $this->settings[ 'statistics-type' ] === 'google-analytics' ) {
if ( ! empty( $this->settings ) ) {
if ( ! empty( $this->settings[ 'statistics-gaid-select' ] ) ) {
$gaid = $this->settings[ 'statistics-gaid-select' ];
} else if ( ! empty( $this->settings[ 'adfoxly-statistics-custom-gaid' ] ) ) {
$gaid = $this->settings[ 'adfoxly-statistics-custom-gaid' ];
}
}
if ( isset( $gaid ) && ! empty( $gaid ) ) {
add_action( 'wp_footer', function() use( $id, $gaid )
{
$render = '';
echo $render;
} );
}
} else if ( $this->settings[ 'statistics-type' ] === 'piwik' ) {
add_action( 'wp_footer', function() use( $id )
{
$render = '';
return $render;
} );
} else {
add_action( 'wp_footer', function() use( $id )
{
$render = '';
echo $render;
} );
}
if ( ! empty( $render ) ) {
return $render;
}
}
}
}