| Current Path : /var/www/components/com_yendifvideoshare/models/ |
| Current File : /var/www/components/com_yendifvideoshare/models/ads.php |
<?php
/**
* @version 1.2.9
* @package Com_YendifVideoShare
* @author PluginsWare Interactive Pvt. Ltd <admin@yendifplayer.com>
* @copyright Copyright (c) 2012 - 2021 PluginsWare Interactive Pvt. Ltd. All Rights Reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Prevent direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
class YendifVideoShareModelAds extends YendifVideoShareModel {
public function getItem() {
$db = JFactory::getDbo();
$query = 'SELECT * FROM #__yendifvideoshare_adverts WHERE published=1 AND id=' . JFactory::getApplication()->input->getInt( 'id' );
$db->setQuery( $query );
$item = $db->loadObject();
return $item;
}
public function getPrerollId() {
$db = JFactory::getDbo();
$query = sprintf(
'SELECT id FROM #__yendifvideoshare_adverts WHERE published=1 AND (type=%s OR type=%s)',
$db->quote( 'preroll' ),
$db->quote( 'both' )
);
$video = $this->getVideo();
if ( $video->preroll == -1 ) {
$query .= ' ORDER BY RAND() LIMIT 1';
} else {
$query .= ' AND id=' . $video->preroll;
}
$db->setQuery( $query );
$id = $db->loadResult();
return $id;
}
public function getPostrollId() {
$db = JFactory::getDbo();
$query = sprintf(
'SELECT id FROM #__yendifvideoshare_adverts WHERE published=1 AND (type=%s OR type=%s)',
$db->quote( 'postroll' ),
$db->quote( 'both' )
);
$video = $this->getVideo();
if ( $video->postroll == -1 ) {
$query .= ' ORDER BY RAND() LIMIT 1';
} else {
$query .= ' AND id=' . $video->postroll;
}
$db->setQuery( $query );
$id = $db->loadResult();
return $id;
}
public function getVideo() {
$db = JFactory::getDbo();
$query = 'SELECT * FROM #__yendifvideoshare_videos WHERE published=1 AND id=' . JFactory::getApplication()->input->getInt( 'id' );
$db->setQuery( $query );
$item = $db->loadObject();
return $item;
}
public function impression() {
$db = JFactory::getDbo();
$query = 'UPDATE #__yendifvideoshare_adverts SET impressions=impressions+1 WHERE id=' . JFactory::getApplication()->input->getInt( 'id' );
$db->setQuery( $query );
$db->execute();
}
public function click() {
$db = JFactory::getDbo();
$query = 'UPDATE #__yendifvideoshare_adverts SET clicks=clicks+1 WHERE id=' . JFactory::getApplication()->input->getInt( 'id' );
$db->setQuery( $query );
$db->execute();
}
}