Adult Script Pro Community Forums

The forum is here for legacy reasons. No new posts will be created. User registration is disabled! If you have any questions, please email us or check https://www.adultscriptpro.com for more details!

You are not logged in.

#1 2013-10-29 05:36:07

xpornclub
Member
From: California
Registered: 2012-01-01
Posts: 445
Website

How to make video default rating 2.5 stars?

i would like to know how we can set the default rating to 2.5 stars, so when a video has not been rated it looks like it has 2.5 stars?

Offline

#2 2013-10-29 07:12:23

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: How to make video default rating 2.5 stars?

Edit modules/video/components/view.php and add:

$video['rating'] = 2.5;
$video['rated_by'] = 1;

right before:

$template               = ($video['status'] == '8') ? 'video_view_deleted' : 'video_view';

Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds

Offline

#3 2013-10-29 08:06:39

xpornclub
Member
From: California
Registered: 2012-01-01
Posts: 445
Website

Re: How to make video default rating 2.5 stars?

Im not seeing anything even close to that in the file view.php   Nothing even close to that. $template               = ($video['status'] == '8') ? 'video_view_deleted' : 'video_view';

I looked over the file like 50 times.   

<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_video_view extends VModule_video
{
	private $tpl;
	private $video_id;
	public function __construct()
	{
		parent::__construct();
		$this->tpl		= VF::factory('template');
		$this->video_id = (int) VUri::request(0);
	}
	
	public function render()
	{
		if ($this->vcfg['view_access'] != 'all' && !VBrowser::get('is_robot')) {
			VAuth::check($this->vcfg['view_access'], NULL, 'Please login as a '.$this->vcfg['view_access'].' to watch videos');
		}
		
		$cache_id 	= 'video_'.$this->video_id;
		if (!$video = $this->cache->get($cache_id, 7200)) {
			$this->db->query("SELECT v.video_id, v.user_id, v.title, v.slug, v.description, v.total_views, v.total_comments, v.premium,
			                         v.allow_rating, v.allow_comment, v.allow_embed, v.rating, v.rated_by, v.embed_code, v.allow_download,
			                         v.duration, v.add_time, v.thumb, v.ext, v.type, v.adv, v.sponsor, v.size, vm.meta_title,
			                         vm.meta_desc, vm.meta_keys, u.username,
			                         GROUP_CONCAT(DISTINCT c.cat_id) AS categories,
			                         GROUP_CONCAT(DISTINCT c.slug) AS slugs,
			                         GROUP_CONCAT(DISTINCT c.name) AS name,
                                	 GROUP_CONCAT(DISTINCT t.name) AS tags
                          	  FROM #__video AS v
                          	  LEFT JOIN #__video_category AS vc ON (vc.video_id = v.video_id)
                          	  LEFT JOIN #__video_categories AS c ON (vc.cat_id = c.cat_id)
                          	  LEFT JOIN #__video_tags AS t ON (t.video_id = v.video_id)
                          	  LEFT JOIN #__video_meta AS vm ON (vm.video_id = v.video_id)
                          	  LEFT JOIN #__user AS u ON (u.user_id = v.user_id)
                          	  WHERE v.video_id = ".$this->video_id."
                        	  GROUP BY v.video_id
                        	  LIMIT 1");
			if ($this->db->affected_rows()) {
				$video	= $this->db->fetch_assoc();
				$this->cache->store($cache_id, $video, 7200);
			} else {
				VModule::load('404', TRUE);
			}
		}
		
		// we redirect her if anything is not set correctly
		if (!VUri::match($this->video_id.'/'.$video['slug'].'/')) {
			VF::redirect(BASE_URL.'/'.$this->video_id.'/'.$video['slug'].'/', '301');
		}
		
		if ($video['premium'] == '1' && VModule::enabled('premium')) {
			VF::redirect(BASE_URL.'/premium/'.$this->video_id.'/'.$video['slug'].'/');
		}
		
		VLanguage::load('frontend.video');
		
		$ip			= VServer::ip(TRUE);
		$user_id	= (VAuth::loggedin()) ? (int) $_SESSION['user_id'] : 0;
		$owner_id	= (int) $video['user_id'];
		$friends	= TRUE;
		if ($user_id) {
			if ($video['type'] == 'private' &&
			    $user_id !== (int) $owner_id) {
			    $this->db->query("SELECT user_id
			                      FROM #__user_friends
			                      WHERE user_id = ".$owner_id."
			                      AND friend_id = ".$user_id."
			                      AND status = 'approved'
			                      LIMIT 1");
				if (!$this->db->affected_rows()) {
					$friends = FALSE;
				}
			}
		} else {
			if ($video['type'] == 'private') {
				$friends = FALSE;
			}
		}
		
		$date 	= date('Y-m-d h:i:s');
		$time	= time();
		if (!VBrowser::get('is_robot') && $friends === TRUE) {
			// view_date removed from the update...still in database
			$this->db->query("UPDATE #__video
			                  SET total_views = total_views+1,
			                      view_time = ".time()."
			                  WHERE video_id = ".$this->video_id." LIMIT 1");
			                  
			$this->db->query("UPDATE #__user_activity SET total_video_views = total_video_views+1 WHERE user_id = ".$owner_id." LIMIT 1");
			
			if ($this->vcfg['track_views'] != '0') {
				$this->db->query("INSERT INTO #__video_history
			                	  SET video_id = ".$this->video_id.",
			                    	  user_id = ".$user_id.",
			                    	  ip = ".$ip.",
			                    	  view_time = '".$time."'");
			}
			
			if ($user_id) {
				$this->db->query("UPDATE #__user_activity SET total_viewed_videos = total_viewed_videos+1 WHERE user_id = ".$user_id." LIMIT 1");
				
				if ($_SESSION['group_id'] == VAuth::get_group_id('Registered')) {
					if ($video['embed_code'] == '' && VModule::enabled('premium')) {
						$registered_method	= VF::cfg_item('module.user.registered_method');
						if ($registered_method != '0') {
							VHelper::load('module.user.limit');
							VHelper_user_limit::update($user_id, $registered_method);
						}
					}
				}
			} else {
				if ($video['embed_code'] == '' && VF::cfg_item('module.user.guest_limit') && !VBrowser::get('is_robot')) {
				    VHelper::load('module.user.guest');
				    VHelper_user_guest::update($ip, $video['size']);
				}
			}
		}
		
		if ($this->vcfg['view_related']) {
            $this->get_related_videos(
          		$video['video_id'],
          		$video['title'],
          		$video['tags'],
          		$video['categories']
          	);
        }
		
		require 'nuevo.php';

		if ($this->vcfg['view_comments']) {
			$this->get_comments();
		}
		
		if (VModule::enabled('pornstar')) {
			$this->get_pornstars();
		}
		
		$this->tpl->meta_title	= ($video['meta_title'] != '') ? $video['meta_title'] : $video['title'].' - '.$this->tpl->cfg['site_name'];
		$this->tpl->meta_desc	= ($video['meta_desc'] != '') ? $video['meta_desc'] : __('watch').' '.$video['title'].'. '.$this->tpl->cfg['meta_desc'];
		$this->tpl->meta_keys	= ($video['meta_keys'] != '') ? $video['meta_keys'] : $video['tags'];
		
		$this->tpl->menu		= 'video';
		
		$media_url				= (defined('CDN_THUMB_URL')) ? CDN_THUMB_URL : MEDIA_URL.'/videos/tmb';
		$this->tpl->metas		= array(
			'og:title' 	=> $video['title'],
			'og:type'  	=> 'movie',
			'og:url'	=> CURRENT_URL,
			// need to handle CDN here in the future			
			'og:image'	=> $media_url.'/'.path($video['video_id']).'/'.$video['thumb'].'.jpg'
		);
		$this->tpl->canonical	= BASE_URL.'/'.$video['video_id'].'/'.$video['slug'].'/';
		$this->tpl->vcfg		= $this->vcfg;
		$this->tpl->user_id		= $user_id;
		$this->tpl->video		= $video;
		$this->tpl->categories	= $this->get_video_categories();
		$this->tpl->download	= $this->get_download_perms($user_id);
		$this->tpl->user_id		= $user_id;
		$this->tpl->friends		= $friends;
		$this->tpl->load(array('header', 'video_view', 'footer'));
		$this->tpl->display();
	}
	
	private function get_download_perms($user_id)
	{
		$download	= ($this->vcfg['download'] == '1') ? TRUE : FALSE;
		if ($download) {
			if ($this->vcfg['download_perms'] == 'all') {
				$downoad	= TRUE;
			} elseif ($this->vcfg['download_perms'] == 'registered' && !$user_id) {
				$download	= FALSE;
			} elseif ($this->vcfg['download_perms'] == 'premium') {
				if (!VAuth::group('Premium')) {
					$download = FALSE;
				}
			}
		}
		
		return $download;
	}
	
    private function get_related_videos($video_id, $title, $tags, $categories)
    {
  		$cache_id	= 'video_related_'.$video_id;
  		if (!$related = $this->cache->get($cache_id, 3600) OR
  		    !$related_total = $this->cache->get($cache_id.'_total', 3600)) {
  		    if ($this->vcfg['related_category']) {
  		  		$query 	= ($this->vcfg['related_method'] == 'simple')
  		  			? $this->get_related_category_simple($video_id, $title, $categories)
  		  			: $this->get_related_category_complex($video_id, $tags, $categories);
  		    } else {
  		  		$query	= ($this->vcfg['related_method'] == 'simple')
  		  			? $this->get_related_simple($video_id, $title)
  		  			: $this->get_related_complex($video_id, $tags);
  		    }
  		    
            $related_total	= $query['total'];
            if ($query['sql'] !== FALSE) {
          		$related 	= $this->db->get_rows($query['sql']);
          		if ($this->db->affected_rows()) {
          			$this->cache->store($cache_id, $related, 3600);
          			$this->cache->store($cache_id.'_total', $related_total, 3600);
          		}
          	} else {
          		$related	= array();
          	}	
		}
        
        $this->tpl->related 		= $related;
        $this->tpl->related_total	= $related_total;
    }

    private function get_comments()
    {
		$sql_count		= "SELECT COUNT(comment_id) AS total_comments
		                   FROM #__video_comments 
						   WHERE video_id = ".$this->video_id."
						   AND status = '1'";
        $total_comments = $this->db->get_field($sql_count, 'total_comments');
        $pagination     = VPagination::get(1, $total_comments, $this->vcfg['comments_per_page']);
        $sql			= "SELECT c.comment_id, c.parent_id, c.user_id,
                                  c.comment, c.add_date, c.nickname,
                                  u.username, u.gender, u.avatar
                           FROM #__video_comments AS c
                           LEFT JOIN #__user AS u ON (u.user_id = c.user_id)
                           WHERE c.video_id = ".$this->video_id."
                           AND c.status = '1'
                           ORDER BY c.comment_id DESC
                           LIMIT ".$pagination['limit'];
		$cache_id		= $sql.$total_comments;
		if (!$comments = $this->cache->get($cache_id, 3600)) {
			$comments = $this->db->get_rows($sql);
            if ($this->db->affected_rows()) {
                $this->cache->store($cache_id, $comments, (3600));
            }
        }

        $this->tpl->comments        = $comments;
        $this->tpl->total_comments  = $total_comments;
        $this->tpl->pagination      = $pagination;
    }
    
    private function get_pornstars()
    {
  		$sql 		= "SELECT m.slug, m.name
  		      	       FROM #__model_videos AS mv
  		               LEFT JOIN #__model AS m ON (mv.model_id = m.model_id)
  		               WHERE mv.video_id = ".$this->video_id;
  		$cache_id	= 'video-pornstars-'.$this->video_id;
  		if (!$pornstars = $this->cache->get($cache_id, 3600)) {
  			$pornstars = $this->db->get_rows($sql);
  			if ($this->db->affected_rows()) {
  				$this->cache->store($cache_id, $pornstars, 3600);
  			}
  		}
  		
  		$this->tpl->pornstars	= $pornstars;
    }
    
    private function get_related_category_simple($video_id, $title, $categories)
    {
  		$title		= $this->db->escape($title);
  		$sql_count	= "SELECT COUNT(*) AS total_related
  		               FROM #__video AS v
  		               INNER JOIN #__video_category AS c ON (c.video_id = v.video_id AND c.cat_id IN (".$categories."))
  		               WHERE MATCH (v.title) AGAINST ('".$title."')
  		               AND v.status = 1";
        return array(
      		'total'	=> $this->db->get_field($sql_count, 'total_related'),
      		'sql'	=> "SELECT v.video_id, v.title, v.slug, v.rating, v.rated_by, v.duration, v.thumb,
                               v.thumbs, v.total_views, v.add_time, v.premium, v.ext, u.username,
                               MATCH (v.title) AGAINST ('".$title."') AS relevance
                        FROM #__video AS v
                        INNER JOIN #__video_category AS c ON (c.video_id = v.video_id AND c.cat_id IN (".$categories."))
                        LEFT JOIN #__user AS u ON (u.user_id = v.user_id)
                        WHERE MATCH (v.title) AGAINST ('".$title."')
                        AND v.status = 1
                        AND v.video_id != ".$video_id."
                        ORDER BY relevance DESC LIMIT ".$this->vcfg['related_per_page']
    	);
    }
    
    private function get_related_category_complex($video_id, $tags, $categories)
    {
  		$host	= VF::cfg_item('sphinx_host');
  		$port	= VF::cfg_item('sphinx_port');
  		if (empty($host) OR empty($port)) {
  			throw new VException('Please set your sphinx search engine host and port!');
  		}
    
		VF::load('sphinxapi.sphinxapi');
        $sphinx     = new SphinxClient();
        $sphinx->SetServer($host, $port);
        $sphinx->SetConnectTimeout(1);
        $sphinx->SetFieldWeights(array('tags' => 100, 'title' => 70, 'description' => 30));
        $sphinx->SetFilter('categories', array_values(explode(',', $categories)));
        $sphinx->SetFilter('video', array($video_id), true);
        $sphinx->SetMatchMode(SPH_MATCH_ANY);
        $sphinx->SetLimits(0, $this->vcfg['related_per_page'], 1000);
        
        $tags		= str_replace(',', ' ', VText::truncate_words($tags, 40, ''));
        $results	= $sphinx->Query($tags, 'videos');
		
		if (isset($results['total']) && isset($results['matches'])) {
			$ids	= implode(',', array_keys($results['matches']));
			return array(
				'total'	=> $results['total'],
				'sql'	=> 'SELECT v.video_id, v.title, v.slug, v.rating, v.rated_by, v.duration, v.thumb,
				                   v.thumbs, v.total_views, v.add_time, v.ext, v.premium, u.username
				            FROM #__video AS v
				            LEFT JOIN #__user AS u on (u.user_id = v.user_id)
				            WHERE v.video_id IN ('.$ids.')
				            ORDER BY FIELD (v.video_id, '.$ids.')'
			);
		}
		
		return array('total' => 0, 'sql' => FALSE);
    }
    
    private function get_related_simple($video_id, $title)
    {
  		$title		= $this->db->escape($title);
  		$sql_count	= "SELECT COUNT(*) AS total_related
  		               FROM #__video AS v
  		               WHERE MATCH (v.title) AGAINST ('".$title."')
  		               AND v.status = 1";
        return array(
      		'total'	=> $this->db->get_field($sql_count, 'total_related'),
      		'sql'	=> "SELECT v.video_id, v.title, v.slug, v.rating, v.rated_by, v.duration, v.thumb,
                               v.thumbs, v.total_views, v.add_time, v.ext, v.premium, u.username,
                               MATCH (v.title) AGAINST ('".$title."') AS relevance
                        FROM #__video AS v
                        LEFT JOIN #__user AS u ON (u.user_id = v.user_id)
                        WHERE MATCH (v.title) AGAINST ('".$title."')
                        AND v.status = 1
                        AND v.video_id != ".$video_id."
                        ORDER BY relevance DESC LIMIT ".$this->vcfg['related_per_page']
    	);
    }
    
    private function get_related_complex($video_id, $tags)
    {
  		$host	= VF::cfg_item('sphinx_host');
  		$port	= VF::cfg_item('sphinx_port');
  		if (empty($host) OR empty($port)) {
  			throw new VException('Please set your sphinx search engine host and port!');
  		}

		VF::load('sphinxapi.sphinxapi');
        $sphinx     = new SphinxClient();
        $sphinx->SetServer('localhost', 3312);
        $sphinx->SetConnectTimeout(1);
        $sphinx->SetFieldWeights(array('tags' => 100, 'title' => 70, 'description' => 30));
        $sphinx->SetFilter('video', array($video_id), true);
        $sphinx->SetMatchMode(SPH_MATCH_ANY);
        $sphinx->SetLimits(0, $this->vcfg['related_per_page'], 1000);

        $tags		= str_replace(',', ' ', VText::truncate_words($tags, 40, ''));
        $results	= $sphinx->Query($tags, 'videos');
		
		if (isset($results['total']) && isset($results['matches'])) {
			$ids	= implode(',', array_keys($results['matches']));
			return array(
				'total'	=> $results['total'],
				'sql'	=> 'SELECT v.video_id, v.title, v.slug, v.rating, v.rated_by, v.duration, v.thumb,
				                   v.thumbs, v.total_views, v.add_time, v.ext, v.premium, u.username
				            FROM #__video AS v
				            LEFT JOIN #__user AS u on (u.user_id = v.user_id)
				            WHERE v.video_id IN ('.$ids.')
				            ORDER BY FIELD (v.video_id, '.$ids.')'
			);
		}
		
		return array('total' => 0, 'sql' => FALSE);
    }
}

Offline

#4 2013-10-29 15:40:30

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: How to make video default rating 2.5 stars?

Add before this:

$this->tpl->menu		= 'video';

Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds

Offline

#5 2013-10-29 16:51:51

xpornclub
Member
From: California
Registered: 2012-01-01
Posts: 445
Website

Re: How to make video default rating 2.5 stars?

It kinda works, but the problem is that if it has already been rated it still only shows 2.5 stars.   It should only show 2.5 if no ratings.  If rated show current rating.

Offline

#6 2013-10-29 18:24:54

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: How to make video default rating 2.5 stars?

Hah....good point :-) Add this then:

if ($video['rating'] == '0') && $video['rated_by'] == '0') {
$video['rating'] = 2.5;
$video['rated_by'] = 1;
}

Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds

Offline

#7 2013-10-30 02:11:41

xpornclub
Member
From: California
Registered: 2012-01-01
Posts: 445
Website

Re: How to make video default rating 2.5 stars?

Yeah that worked perfect. What file do I edit to make it look the same for the front page and the video browse pages?

Offline

#8 2013-10-30 08:10:16

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: How to make video default rating 2.5 stars?

It doesnt work in the same way for the frontpage/video browse pages, but you can edit templates/your-template/frontpage.tpl.php and templates/your-template/video_browse.tpl.php and add:

<?php if ($video['rating'] == '0'): $video['rating'] = 2.5; endif; ?>

before:

<div class="rating_bar"><div style="width:<?php echo round($video['rating']*20); ?>%"></div></div>

Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds

Offline

#9 2013-10-30 16:58:31

xpornclub
Member
From: California
Registered: 2012-01-01
Posts: 445
Website

Re: How to make video default rating 2.5 stars?

Perfect   Thanks.   So happy now!

Offline

Board footer

Powered by FluxBB