403Webshell
Server IP : 208.122.213.31  /  Your IP : 216.73.216.45
Web Server : Apache
System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64
User : WHMCS_MIA_382 ( 1001)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/httpd/html/www.superporner.com/porn/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/httpd/html/www.superporner.com/porn/admin/functions.templating.php
<?

//get difference between two dates
function datediff($interval, $datefrom, $dateto, $using_timestamps = false) {
	if (!$using_timestamps) {
	$datefrom = strtotime($datefrom, 0);
	$dateto = strtotime($dateto, 0);
	}
	$difference = $dateto - $datefrom; // Difference in seconds
	
	if($difference < 86400 && $difference >= 3600) {
		$datediff = floor($difference / 3600);
		if($datediff > 1) {
			$datediff = $datediff." hrs";			
		} else {
			$datediff = $datediff." hr";	
		}
	}
	elseif($difference < 3600) {
		$datediff = floor($difference / 60);
		if($datediff > 1) {
			$datediff = $datediff." mins";			
		} else {
			$datediff = $datediff." min";	
		}
	}
	else {
		$datediff = floor($difference / 86400);
		if($datediff > 1) {
			$datediff = $datediff." days";			
		} else {
			$datediff = $datediff." day";	
		}
		
	}
	return $datediff;
}


function showRandom($template, $amount, $cacheName = 'random',$type = 0,$slider = false,$slider_per_page = 8, $userid = false) {
	global $basehttp;
	global $basepath;
	global $gallery_url;
    global $template_path;
	global $thumb_url;
	global $thumbwidth;
	global $thumbheight; 
	global $bad;
	global $good;
	global $cache_path;
	global $overall_cache_time;
	global $results_per_row;
        global $template_url;
	if(is_numeric($userid)) { 
		$filterAnd = "AND content.submitter = '$userid'";
	}	
    $cacheName = "custom".$cacheName.'-'.$userid;
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) as views FROM content WHERE enabled = 1 AND photos = '$type' $filterAnd ORDER BY RAND() LIMIT 0,$amount");
		
        while($row = mysql_fetch_assoc($result)) {		
            if($row['photos'] == 1) {
				$getPhoto = mysql_query("SELECT filename FROM images WHERE record_num = '$row[thumbnail]'");
			    $grow = mysql_fetch_array($getPhoto); 
				$row[thumbfile] = $grow[filename];
            }
               $farray[] = $row;
        }
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
    if(is_array($farray)) {
		$i=0;$j=0;$maxRes = count($farray);
		foreach($farray as $row) {
			if($results_per_row > 0){				
				$i++;
				$rest = $i % $results_per_row;						
				if($rest == 0){
					$class=' last';
				} else {
					$class='';
				}	
			}			
		
			if($slider){
                if($j%$slider_per_page == 0){
                    echo '<div class="window">';
                }
            }
			if($row['photos'] == 1) {
				include($template_path.'/template.content_item_photo.php'); 
			} else {
				include($template_path.'/'.$template);
			}
            if($slider){
                if(($j+1)%$slider_per_page == 0 || $j == ($maxRes - 1)){
                    echo '</div>';
                }
            }
            ++$j;
		}
	} 
}

//generate lighttpd hash
function getMediaLink($filename) {
  global $modsec_secret; // example: s3cr3tk3y (from your lighttpd config)
  global $modsec_url; // example: http://media.asfd.com/dl/ with trailing slash
  $filename = rawurldecode($filename);
  $f = "/".$filename;
  $t = time();
  $t_hex = sprintf("%08x", $t);
  $m = md5($modsec_secret.$f.$t_hex);
  $link = $modsec_url.$m.'/'.$t_hex.$f;
  return $link;
}


//display video player
function displayPlayer($rrow, $width = 590, $height = 475, $skipAutoPlay = false) { 
	global $template_url;
	global $basepath;
	global $basehttp;
	global $flowplayerKey; 
	global $video_url;
	global $player_streamer;
	global $encodeTrailer;
	global $player_rtmp;
	global $player_autoplay;
	global $player_show_watermark;
	global $player_watermark_padding_top;
	global $player_watermark_padding_right;
	global $player_watermark_url;
	global $player_watermark_display_time;
	global $player_watermark_opacity;	
	global $player_watermark_redirect;
	global $modsec_enabled; 
	global $softDelete;
	global $adultCentroPassword;

	if($player_streamer == 'rtmp') { 
		unset($video_url); 
	} 
	if(strpos($width,'%') === false) { 
		$width = $width.'px';
	}
	if(strpos($height,'%') === false) { 
		$height = $height.'px';
	}	
	if(detectMobile()) {
		$bad = array('?','!',' ','&','*','$','#','@');
		$good = array('','','-','','','','','');
		$dirname = str_replace('.flv','',$rrow['orig_filename']);
		$subdir = $rrow['filename'][0].'/'.$rrow['filename'][1].'/'.$rrow['filename'][2].'/'.$rrow['filename'][3].'/'.$rrow['filename'][4].'/';
		$dirname = $subdir.$dirname;
		if(stripos($rrow['hotlinked'],'adultcentro') !== false) {
			$mobileFile = $basehttp.'/index.php'.('?controller=adultCentroGetLink&id='.str_replace('adultcentro','',$rrow['hotlinked'])).'&hash='.md5($adultCentroPassword.str_replace('adultcentro','',$rrow['hotlinked']).$_SERVER['REMOTE_ADDR']);
		}
		else {
			if($rrow[mobile]) { 
				$mobileFile = $video_url.'/'.$subdir.$rrow['mobile'];
			} else { 
				$mobileFile = $video_url.'/'.$subdir.$rrow['filename'];
			}
		}
	?>
		<video id="videoPlayer" src="<? echo $mobileFile; ?>" autobuffer style="width: <? echo $width; ?>; height: <? echo $height; ?>;" controls="controls" onClick="this.play();" poster="<? echo getThumbUrl($rrow['orig_filename'],$rrow['filename'],$rrow['main_thumb'],true); ?>">
    	</video>
	<?
	} else { 
		if($rrow['embed']){ 
			echo resizeEmbedded($rrow['embed'],$width,$height);
		}
		else { 
			if($rrow['hotlinked']) { 			
				if(stripos($rrow['hotlinked'],'adultcentro') !== false) { 
					$defaultFile = $basehttp.'/index.php'.urlencode('?controller=adultCentroGetLink&id='.str_replace('adultcentro','',$rrow['hotlinked']).'&hash='.md5($adultCentroPassword.str_replace('adultcentro','',$rrow['hotlinked']).$_SERVER['REMOTE_ADDR']));
				} else { 
					$defaultFile = $rrow['hotlinked']; 
				}
			} else { 
				$video_file = $rrow['filename'];
				$row[filename] = $video_file; 
				$subdir = $rrow[filename][0].'/'.$rrow[filename][1].'/'.$rrow[filename][2].'/'.$rrow[filename][3].'/'.$rrow[filename][4].'/'; 
				if($encodeTrailer && $rrow['trailer_filename'] && !$_SESSION['userid']) { 
					$rrow['filename'] = $rrow['trailer_filename']; 
				}
				if($modsec_enabled) { 
					$defaultFile = getMediaLink($subdir.$rrow['filename']);
				} else { 
					$defaultFile = $video_url.'/'.$subdir.$rrow['filename'];	
				}
			 }
			
		?>
		<script src="<? echo $basehttp; ?>/includes/player/flowplayer-3.2.11.min.js"></script>
		<a id="thisPlayer" style='display: block; width: <? echo $width; ?>; height: <? echo $height; ?>;'></a>
		<script type='text/javascript'>
		flowplayer("thisPlayer", {
			src: "<? echo $basehttp; ?>/includes/player/flowplayer-3.2.16.swf",
			wmode: "opaque"
		},  {
			key: "<? echo $flowplayerKey; ?>",
			clip: {
				url: '<? echo $defaultFile; ?>',
				<? if($skipAutoPlay){ ?>
				autoPlay: false,
				<? } else { ?>
				autoPlay: <? echo (string)$player_autoplay; ?>,
				<? } ?>
				autoBuffering: true,			
				provider: '<? echo $player_streamer; ?>'
			},
			<? if($player_show_watermark){ ?>
			logo: {
				<? if($player_watermark_redirect){ ?>
				linkUrl: '<? echo $player_watermark_redirect; ?>',
				linkWindow: '_blank',
				<? } ?>
				url: '<? echo $player_watermark_url; ?>',
				opacity: '<? echo $player_watermark_opacity; ?>',
				fullscreenOnly: false,
				top: <? echo $player_watermark_padding_top; ?>,
				right: <? echo $player_watermark_padding_right; ?>,
				displayTime: <? echo $player_watermark_display_time; ?>				
			},
			<? } ?>		
			 plugins: {
				<? if($player_streamer == 'rtmp'){ ?>
				rtmp: {
					url: "<? echo $basehttp; ?>/includes/player/flowplayer.rtmp-3.2.12.swf",
					netConnectionUrl: "<? echo $player_rtmp; ?>",
					durationFunc: 'getStreamLength'	
				}			
				<? } else { ?>
				lighttpd: {
					url: "<? echo $basehttp; ?>/includes/player/flowplayer.pseudostreaming-byterange-3.2.11.swf"
				}
				<? } ?>			
			}
		});
		</script>
		<? 
		}
	}
}


function buildTags($var, $split = ',') {
	global $basehttp;
    $var = str_replace(', ',',',$var);
	$tags = explode(',',$var);
    foreach($tags as $i) {
    	$i2 = str_replace(' ','-',$i);
        $string .= "<a href=\"$basehttp/search/$i2/page1.html\">$i</a>$split ";
    }
    return substr($string,0,-2);
} 

//shows related videos
function showRelated($related, $template, $exclude, $amount) {
	global $cache_path;
	global $overall_cache_time;
	global $thumb_url; 
	global $basehttp;
	global $thumbwidth;
	global $results_per_row; 
	global $thumbheight; 
	global $gallery_url;
	global $template_path;
        global $template_url;
	global $bad;
	global $good;
	
	if($_SESSION[filterContent]) { 
		if($_SESSION[filterContent] == 'photosOnly') { 
			$filterAnd = "AND photos = 1"; 
		}
		if($_SESSION[filterContent] == 'videosOnly') { 
			$filterAnd = "AND photos = 0"; 
		}
	}


	$string = mysql_real_escape_string($string);
	global $basepath;
	$cacheName = "related".$_SERVER[REQUEST_URI];
	$cacheResult = getCache($cacheName);
	if($cacheResult) {
	        $farray = $cacheResult;
	}
	else { 
		if($related) { 
			$result = mysql_query("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) as views FROM content WHERE enabled = 1 $filterAnd AND record_num != '$exclude' AND record_num IN ($related) ORDER BY FIELD(record_num,$related) LIMIT 0,$amount") or die(mysql_error());	        
		} else { 
			$result = mysql_query("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) as views FROM content WHERE enabled = 1 $filterAnd AND record_num != '$exclude' ORDER BY RAND() LIMIT 0,$amount");	        
		}
		while($row = mysql_fetch_assoc($result)) {
			$farray[] = $row;
		}
        setCache($cacheName,$farray,$overall_cache_time);
		
    }
	if(is_array($farray)) {
		$i = 0; 
		foreach($farray as $row) {
			 if($results_per_row > 0){    
			 	$i++;
			 	$rest = $i % $results_per_row;      
			   	if($rest == 0){
					$class=' last';
			    } else {
					$class='';
			    } 
			}
			if($row[photos] == 1) {
				include($template_path.'/template.content_item_photo.php'); 
			} else {
				include($template_path.'/'.$template);
			}
		}
	} 
}

//builds list of channels for specific videos
function buildChannels($id,$mode = 'channels') {
	  global $basehttp;
	  $cresult = mysql_query("SELECT niches.name, niches.record_num FROM niches, content_niches WHERE content_niches.content = '$id' AND content_niches.niche = niches.record_num AND niches.enabled = 1 GROUP BY niches.record_num ORDER BY name ASC");
	  while($crow = mysql_fetch_array($cresult)) {
	  	$categoriesIn .= $crow[record_num].',';
		if($mode == 'channels') {
		  	$catstring .= "<a href='$basehttp/channels/".$crow[record_num]."/".str_replace(' ','-',strtolower($crow[name]))."/page1.html' class='link12' >$crow[name]</a>, ";
		} else {
			$catstring .= "<a href='$basehttp/search/".$crow[record_num]."/".str_replace(' ','-',strtolower($crow[name]))."/page1.html' class='link12' >$crow[name]</a>, ";
		}
	  }
	  return substr($catstring,0,-2); 
}

//resizes embedded video html code to a specified width and height
function resizeEmbedded($subject,$width,$height) {
	 if(eregi('&lt;',$subject)) { $subject = html_entity_decode($subject); }
	 $subject = str_replace("'",'"',$subject);
	 $pattern = "/height=\"[0-9]*\"/";
	$subject = preg_replace($pattern, "height='".$height."'", $subject);
	$pattern = "/width=\"[0-9]*\"/";
	$subject = preg_replace($pattern, "width='".$width."'", $subject);
	return $subject;
	
}



//shows a list of channels, for instance: showChannels('<li>','</li>'); 
function showChannels($pre,$post) {
	global $cache_path;
	global $overall_cache_time;
	global $basehttp;
	global $basepath;
        global $template_url;
	$cached_rfile = $cache_path.'/channelList';
	if(file_exists($cached_rfile) && time() - $overall_cache_time < filemtime($cached_rfile)) {
		$vstring = file_get_contents($cached_rfile);
		$farray = unserialize($vstring);
	}
	else {
		$dresult = mysql_query("SELECT * FROM niches ORDER BY name ASC");
		while($drow = mysql_fetch_array($dresult)) {
			$farray[] = $drow;
		}
		$vstring = serialize($farray);
		file_put_contents($cached_rfile, $vstring);
	}
	if(is_array($farray)) {
		foreach($farray as $row) {
			$link = generateUrl('channel',$row['name'],$row['record_num']);
			echo $pre."<a href='$link'>$row[name]</a>".$post; 
		}
	} 
}





//truncates a string to a certain length - example: "truncate($string,50)" would return the first 50 characters and then "..."
function truncate($tekst,$ile) {
	$znaki = strlen($tekst);
    if ($znaki>=$ile) {
    	$tnij = substr($tekst,0,$ile);
        $skrocone = $tnij."...";
    }
    else {
    	$skrocone = $tekst;
    }
  	return $skrocone;
}

//prints a tag cloud
function printTagCloud($tags) {
         arsort($tags);
        $max_size = 18; // max font size in pixels
        $min_size = 10; // min font size in pixels
        $max_qty = max(array_values($tags));
        $min_qty = min(array_values($tags));
        $spread = $max_qty - $min_qty;
        if ($spread == 0) { 
                $spread = 1;
        }
        $step = ($max_size - $min_size) / ($spread);
        foreach ($tags as $key => $value) {
                $size = round($min_size + (($value - $min_qty) * $step));
       			if($size == 18) {
					$color = 'color: #ff1c04;'; 
				}
				else {
					unset($color);
				}
                echo '<a href="/search/'.$key.'/" style="'.$color.' font-size: ' . $size . 'px" >' . $key . '</a> ';
        }
}

//related to above printTagCloud function
function tagCloud() {
	$result = mysql_query("SELECT * FROM keywords ORDER BY amount DESC LIMIT 0,50");
	while($row = mysql_fetch_array($result)) {
		$tags[$row[word]] = $row[amount]; 
	}
	printTagCloud($tags);
}

//gets the url to a thumbnail (or large thumbnail)
function getThumbUrl($orig_filename,$filename,$number,$big = false) {
	global $thumb_url;
    $dirname = str_replace('.flv','',$orig_filename);
	$subdir = $filename[0].'/'.$filename[1].'/'.$filename[2].'/'.$filename[3].'/'.$filename[4].'/'; 
	$dirname = $subdir.rawurlencode($dirname); 
	if($big) {
		$overlay = $thumb_url.'/'.$dirname.'/'.rawurlencode($orig_filename).'-'.$number.'b.jpg';
	}
	else {
		$overlay = $thumb_url.'/'.$dirname.'/'.rawurlencode($orig_filename).'-'.$number.'.jpg';
	}
	return $overlay;
}

//builds the subsorting links used to sort searches by newest/mostviewed/etc, most viewed by last day, week, month and so forth.
function buildSubSortLinks($mode) {
	global $basehttp; 
	global $q;
	global $catname;
	$catname = strtolower($catname);
	if($_GET[dateRange] == 'day') {
        if($mode == 'select'){
            $day = 'selected="selected"';
        }else{
            $day = "class='subSortBold'";
        }
	} elseif($_GET[dateRange] == 'week') { 
        if($mode == 'select'){
            $week = 'selected="selected"';
        }else{
            $week = "class='subSortBold'";
        }
	} elseif($_GET[dateRange] == 'month') {
        if($mode == 'select'){
            $month = 'selected="selected"';
        }else{
            $month = "class='subSortBold'";
        }
	} else {
        if($mode == 'select'){
            $alltime = 'selected="selected"';
        }else{
            $alltime = "class='subSortBold'";
        }
	}
	
	if($_GET[sortby] == 'views') {
		$orderBy = 'views DESC';
        if($mode == 'select'){
            $views = 'selected="selected"';
        }else{
            $views = "class='subSortBold'";
        }
	} elseif($_GET[sortby] == 'rating') {
		$orderBy = 'rating DESC';
        if($mode == 'select'){
            $rating = 'selected="selected"';
        }else{
            $rating = "class='subSortBold'";
        }
	} elseif($_GET[sortby] == 'longest') {
		$orderBy = 'length DESC';
        if($mode == 'select'){
            $length = 'selected="selected"';
        }else{
            $length = "class='subSortBold'";
        }
	} elseif($_GET[sortby] == 'relevancy') {
		$orderBy = 'score DESC';
        if($mode == 'select'){
            $score = 'selected="selected"';
        }else{
            $score = "class='subSortBold'";
        }
	} elseif($_GET[sortby] == 'newest') {
		$orderBy = 'date_published DESC';
        if($mode == 'select'){
            $newest = 'selected="selected"';
        }else{
            $newest = "class='subSortBold'";
        }
	} else {
		if($_GET[mode] == 'search') {
			$orderBy = 'score DESC';
            if($mode == 'select'){
                
            }else{
                $score = "class='subSortBold'";
            }
		} else {
			$orderBy = 'date_published DESC';
            if($mode == 'select'){
                $newest = 'selected="selected"';
            }else{
                $newest = "class='subSortBold'";
            }
		}
	}
    
	if($_GET[mode] == 'most-viewed') {
        if($mode == 'default'){
            echo "<a $day href='$basehttp/most-viewed/day/'>Last 24 hours</a> <a $week href='$basehttp/most-viewed/week/'>Last Week</a> <a $month href='$basehttp/most-viewed/month/'>Last Month</a> <a $alltime href='$basehttp/most-viewed/'>All Time</a>";	
        } else {
            echo '<select name="sortby" id="mainSortBy">';
            echo "<option $day value='$basehttp/most-viewed/day/'>Last 24 hours</option> <option $week value='$basehttp/most-viewed/week/'>Last Week</option> <option $month value='$basehttp/most-viewed/month/'>Last Month</option> <option $alltime value='$basehttp/most-viewed/'>All Time</option>";	
            echo '</select>';
        }
	}
	if($_GET[mode] == 'top-rated') {
        if($mode == 'default'){
            echo "<a $day href='$basehttp/top-rated/day/'>Last 24 hours</a> <a $week href='$basehttp/top-rated/week/'>Last Week</a> <a $month href='$basehttp/top-rated/month/'>Last Month</a> <a $alltime href='$basehttp/top-rated/'>All Time</a>";	
        } else {
            echo '<select name="sortby" id="mainSortBy">';
            echo "<option $day value='$basehttp/top-rated/day/'>Last 24 hours</option> <option $week value='$basehttp/top-rated/week/'>Last Week</option> <option $month value='$basehttp/top-rated/month/'>Last Month</option> <option $alltime value='$basehttp/top-rated/'>All Time</option>";	
            echo '</select>';
        }
	}
	if($_GET[mode] == 'longest') {
        if($mode == 'default'){
            echo "<a $day href='$basehttp/longest/day/'>Last 24 hours</a> <a $week href='$basehttp/longest/week/'>Last Week</a> <a $month href='$basehttp/longest/month/'>Last Month</a> <a $alltime href='$basehttp/longest/'>All Time</a>";
        } else {
            echo '<select name="sortby" id="mainSortBy">';
            echo "<option $day value='$basehttp/longest/day/'>Last 24 hours</option> <option $week value='$basehttp/longest/week/'>Last Week</option> <option $month value='$basehttp/longest/month/'>Last Month</option> <option $alltime value='$basehttp/longest/'>All Time</option>";
            echo '</select>';
        }
	}
	if($_GET[mode] == 'search' && ($_GET[type] == 'videos' || !$_GET[type])) {
        if($mode == 'default'){
            echo "<a $score href='$basehttp/search/videos/$q/'>Relevancy</a> <a $newest href='$basehttp/search/videos/$q/newest/'>Most Recent</a> <a $rating href='$basehttp/search/videos/$q/rating/'>Top Rated</a> <a $views href='$basehttp/search/videos/$q/views/'>Most Viewed</a> <a $length href='$basehttp/search/videos/$q/longest/'>Longest</a>";
        } else {
            echo '<select name="sortby" id="mainSortBy">';
            echo "<option $score value='$basehttp/search/videos/$q/'>Relevancy</option> <option $newest value='$basehttp/search/videos/$q/newest/'>Most Recent</option> <option $rating value='$basehttp/search/videos/$q/rating/'>Top Rated</option> <option $views value='$basehttp/search/videos/$q/views/'>Most Viewed</option> <option $length value='$basehttp/search/videos/$q/longest/'>Longest</option>";
            echo '</select>';
        }
	}
	if($_GET[mode] == 'channel') {
        if($mode == 'default'){
            echo "<a $newest href='$basehttp/channels/$_GET[channel]/$catname/newest/'>Most Recent</a> <a $rating href='$basehttp/channels/$_GET[channel]/$catname/rating/'>Top Rated</a> <a $views href='$basehttp/channels/$_GET[channel]/$catname/views/'>Most Viewed</a> <a $length href='$basehttp/channels/$_GET[channel]/$catname/longest/'>Longest</a>";
        } else {
            echo '<select name="sortby" id="mainSortBy">';
            echo "<option $newest value='$basehttp/channels/$_GET[channel]/$catname/newest/'>Most Recent</option> <option $rating value='$basehttp/channels/$_GET[channel]/$catname/rating/'>Top Rated</option> <option $views value='$basehttp/channels/$_GET[channel]/$catname/views/'>Most Viewed</option> <option $length value='$basehttp/channels/$_GET[channel]/$catname/longest/'>Longest</option>";
            echo '</select>';
        }
	}
}



if(!function_exists('buildPornstars')) { 
	function buildPornstars($id) {
		global $basehttp;
		$cresult = mysql_query("SELECT pornstars.name, pornstars.record_num FROM pornstars, content_pornstars WHERE content_pornstars.content = '$id' AND content_pornstars.pornstar = pornstars.record_num GROUP BY pornstars.record_num ORDER BY name ASC");
		$bad = array('?','!',' ','&','*','$','#','@');
		$good = array('','','-','','','','','');
		while($crow = mysql_fetch_array($cresult)) {
			$link = "$basehttp/pornstars/".strtolower(str_replace($bad,$good,$crow[name]))."-".$crow[record_num].".html";
		
			$catstring .= "<a href='$link' style='text-decoration:none;'><strong>$crow[name]</strong></a>, ";
		}
		return substr($catstring,0,-2);
	}
}


//show random videos
function showBeingWatched($template, $amount, $cacheName = 'random',$type = 0,$slider = false,$slider_per_page = 8) {
	global $basehttp;
	global $basepath;
	global $gallery_url;
    global $template_path;
	global $thumb_url;
	global $thumbwidth;
	global $thumbheight; 
	global $picthumbwidth;
	global $picthumbheight; 
	global $bad;
	global $good;
	global $cache_path;
	global $overall_cache_time;
	global $results_per_row;
        global $template_url;
    $cacheName = "custom".$cacheName;
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) as views FROM content RIGHT JOIN watch_log ON content.record_num = watch_log.content WHERE content.enabled = 1 $filterAnd AND content.photos = '$type' ORDER BY `time` DESC LIMIT 0,$amount");
		
        while($row = mysql_fetch_assoc($result)) {		
            if($row['photos'] == 1) {
				$getPhoto = mysql_query("SELECT filename FROM images WHERE record_num = '$row[thumbnail]'");
			    $grow = mysql_fetch_array($getPhoto); 
				$row[thumbfile] = $grow[filename];
            }
               $farray[] = $row;
        }
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
    if(is_array($farray)) {
		$i=0;$j=0;$maxRes = count($farray);
		foreach($farray as $row) {
			if($results_per_row > 0){				
				$i++;
				$rest = $i % $results_per_row;						
				if($rest == 0){
					$class=' last';
				} else {
					$class='';
				}	
			}			
		
			if($slider){
                if($j%$slider_per_page == 0){
                    echo '<div class="window">';
                }
            }
			if($row['type'] == 1) {
				include($template_path.'/template.content_item_photo.php'); 
			} else {
				include($template_path.'/'.$template);
			}
            if($slider){
                if(($j+1)%$slider_per_page == 0 || $j == ($maxRes - 1)){
                    echo '</div>';
                }
            }
            ++$j;
		}
	} 
}


function userRecentUploads($userid,$limit,$mode = 'video'){
    global $template_path;
    global $results_per_row;
	global $thumb_url;
	global $thumbwidth;
	global $thumbheight; 
	global $picthumbwidth;
	global $picthumbheight; 
	global $gallery_url; 
        global $template_url;
	
	if($mode == 'video'){
		$andPhotos = 'AND photos = 0';
	} else {
		$andPhotos = 'AND photos = 1';
	}	

    $result = dbQuery("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) AS views,  (SELECT images.filename FROM images WHERE images.record_num = content.thumbnail) AS thumbfile FROM content WHERE enabled = 1 AND content.submitter = '$userid' $andPhotos ORDER BY content.encoded_date DESC LIMIT 0,$limit",true);
    if(count($result) == 0) {
        echo "<p>User has not uploaded anything!</p>";
    }else{
        $i = 0;
        foreach($result as $row) {
            if($results_per_row > 0){
                $i++;
                $rest = $i % $results_per_row;
                if($rest == 0){
                    $class=' last';
                } else {
                    $class='';
                }
            }
            if($row['photos'] == 1) {
                include($template_path.'/template.content_item_photo.php');
            }
            else {                
				include($template_path.'/template.content_item.php');
				
            }
        }
    }
}

function getUsersFriends($userid,$limit){
    global $template_path;
    global $results_per_row;
	global $thumb_url;
	global $thumbwidth;
	global $thumbheight; 
	global $picthumbwidth;
	global $picthumbheight; 
	global $gallery_url; 
        global $template_url;
	

    $result = dbQuery("SELECT   users.record_num, users.username, users.avatar FROM friends, users WHERE  friends.friend = '$userid' AND users.record_num =  friends.user AND approved = 1 ORDER BY username ASC LIMIT 0,$limit",false);
    if(count($result) < 1) {
        echo "<p>You do not have any friends added!</p>";
    } else {
        $i = 0;
        foreach($result as $row) {
            if($results_per_row > 0){
                $i++;
                $rest = $i % $results_per_row;
                if($rest == 0){
                    $class=' last';
                } else {
                    $class='';
                }
            }

            include($template_path.'/template.member_item.php');
        }
    }
}

function getModelsContent($modelid,$type = 0){
    global $template_path;
    global $results_per_row;
	global $thumb_url;
	global $thumbwidth;
	global $thumbheight; 
	global $picthumbwidth;
	global $picthumbheight; 
	global $gallery_url; 
        global $template_url;
	
    $result = dbQuery("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) AS views, (SELECT images.filename FROM images WHERE images.record_num = content.thumbnail) AS thumbfile  FROM content WHERE enabled = 1 AND photos = '$type' AND record_num IN (SELECT content FROM content_pornstars WHERE pornstar = '$modelid')",false);
    if(count($result) < 1) {
        echo "<div class='notification alert'><p>There is no content for this model yet</p></div>";
    } else {
        $i = 0;
        foreach($result as $row) {
            if($results_per_row > 0){
                $i++;
                $rest = $i % $results_per_row;
                if($rest == 0){
                    $class=' last';
                } else {
                    $class='';
                }
            }
            
            if($row['photos'] == 1){
                include($template_path.'/template.content_item_photo.php');
            } else {
                include($template_path.'/template.content_item.php');
            }
        }
    }
}


function checkNav($item) {
	global $thisController;
	global $_GET;

	switch ($item) {
		case 'index':
			return ($thisController == 'index' && !$_GET['mode'] && !$_GET['page']) ? true : false;
		break;
		case 'most-recent':
			return ($thisController =='index' && $_GET['mode']=='most-recent') ? true : false;
		break;
		case 'top-rated':
			return ($thisController =='index' && $_GET['mode']=='top-rated') ? true : false;
		break;
		case 'most-viewed':
			return ($thisController =='index' && $_GET['mode']=='most-viewed') ? true : false;
		break;
		case 'longest':
			return ($thisController =='index' && $_GET['mode']=='longest') ? true : false;
		break;
		case 'most-discussed':
			return ($thisController =='index' && $_GET['mode']=='most-discussed') ? true : false;
		break;
		case 'random':
			return ($thisController =='index' && $_GET['mode']=='random') ? true : false;
		break;
		case 'channels':
			return ($thisController =='channels') ? true : false;
		break;
		case 'photos':
			return ($_GET['mode'] == 'photos') ? true : false;
		break;
		case 'pornstars':
			return ($thisController == 'pornstars') ? true : false;
		break;
		case 'members':
			return ($thisController == 'members') ? true : false;
		break;
		default:
      		return false;
	}
}
	



function _showNewest($template, $amount, $cacheName = 'showNewest',$type = 0,$slider = false,$slider_per_page = 8, $userid = false) {
	global $basehttp;
	global $basepath;
	global $gallery_url;
    global $template_path;
	global $thumb_url;
	global $thumbwidth;
	global $thumbheight; 
	global $bad;
	global $good;
	global $cache_path;
	global $overall_cache_time;
	global $results_per_row;
        global $template_url;
	
	if(is_numeric($userid)) { 
		$filterAnd = "AND content.submitter = '$userid'";
	}	
    $cacheName = "custom".$cacheName.'-'.$userid;
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) as views FROM content WHERE enabled = 1 AND photos = '$type' $filterAnd ORDER BY encoded_date DESC LIMIT 0,$amount");
		
        while($row = mysql_fetch_assoc($result)) {		
            if($row['photos'] == 1) {
				$getPhoto = mysql_query("SELECT filename FROM images WHERE record_num = '$row[thumbnail]'");
			    $grow = mysql_fetch_array($getPhoto); 
				$row[thumbfile] = $grow[filename];
            }
               $farray[] = $row;
        }
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
    if(is_array($farray)) {
		$i=0;$j=0;$maxRes = count($farray);
		foreach($farray as $row) {
			if($results_per_row > 0){				
				$i++;
				$rest = $i % $results_per_row;						
				if($rest == 0){
					$class=' last';
				} else {
					$class='';
				}	
			}			
		
			if($slider){
                if($j%$slider_per_page == 0){
                    echo '<div class="window">';
                }
            }
			if($row['photos'] == 1) {
				include($template_path.'/template.content_item_photo.php'); 
			} else {
				include($template_path.'/'.$template);
			}
            if($slider){
                if(($j+1)%$slider_per_page == 0 || $j == ($maxRes - 1)){
                    echo '</div>';
                }
            }
            ++$j;
		}
	} 
}


function _showMostViewed($template, $amount, $cacheName = 'showMostViewed',$type = 0,$slider = false,$slider_per_page = 8, $userid = false) {
	global $basehttp;
	global $basepath;
	global $gallery_url;
    global $template_path;
	global $thumb_url;
	global $thumbwidth;
	global $thumbheight; 
	global $bad;
	global $good;
	global $cache_path;
	global $overall_cache_time;
	global $results_per_row;
        global $template_url;
        
	if(is_numeric($userid)) { 
		$filterAnd = "AND content.submitter = '$userid'";
	}	
    $cacheName = "custom".$cacheName.'-'.$userid;
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) as views FROM content WHERE enabled = 1 AND photos = '$type' $filterAnd ORDER BY views DESC LIMIT 0,$amount");
		
        while($row = mysql_fetch_assoc($result)) {		
            if($row['photos'] == 1) {
				$getPhoto = mysql_query("SELECT filename FROM images WHERE record_num = '$row[thumbnail]'");
			    $grow = mysql_fetch_array($getPhoto); 
				$row[thumbfile] = $grow[filename];
            }
               $farray[] = $row;
        }
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
    if(is_array($farray)) {
		$i=0;$j=0;$maxRes = count($farray);
		foreach($farray as $row) {
			if($results_per_row > 0){				
				$i++;
				$rest = $i % $results_per_row;						
				if($rest == 0){
					$class=' last';
				} else {
					$class='';
				}	
			}			
		
			if($slider){
                if($j%$slider_per_page == 0){
                    echo '<div class="window">';
                }
            }
			if($row['photos'] == 1) {
				include($template_path.'/template.content_item_photo.php'); 
			} else {
				include($template_path.'/'.$template);
			}
            if($slider){
                if(($j+1)%$slider_per_page == 0 || $j == ($maxRes - 1)){
                    echo '</div>';
                }
            }
            ++$j;
		}
	} 
}

function _showLongest($template, $amount, $cacheName = 'showLongest',$type = 0,$slider = false,$slider_per_page = 8, $userid = false) {
	global $basehttp;
	global $basepath;
	global $gallery_url;
    global $template_path;
	global $thumb_url;
	global $thumbwidth;
	global $thumbheight; 
	global $bad;
	global $good;
	global $cache_path;
	global $overall_cache_time;
	global $results_per_row;
        global $template_url;
	
    if(is_numeric($userid)) { 
		$filterAnd = "AND content.submitter = '$userid'";
	}	
    $cacheName = "custom".$cacheName.'-'.$userid;
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) as views FROM content WHERE enabled = 1 AND photos = '$type' $filterAnd ORDER BY length DESC LIMIT 0,$amount");
		
        while($row = mysql_fetch_assoc($result)) {		
            if($row['photos'] == 1) {
				$getPhoto = mysql_query("SELECT filename FROM images WHERE record_num = '$row[thumbnail]'");
			    $grow = mysql_fetch_array($getPhoto); 
				$row[thumbfile] = $grow[filename];
            }
               $farray[] = $row;
        }
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
    if(is_array($farray)) {
		$i=0;$j=0;$maxRes = count($farray);
		foreach($farray as $row) {
			if($results_per_row > 0){				
				$i++;
				$rest = $i % $results_per_row;						
				if($rest == 0){
					$class=' last';
				} else {
					$class='';
				}	
			}			
		
			if($slider){
                if($j%$slider_per_page == 0){
                    echo '<div class="window">';
                }
            }
			if($row['photos'] == 1) {
				include($template_path.'/template.content_item_photo.php'); 
			} else {
				include($template_path.'/'.$template);
			}
            if($slider){
                if(($j+1)%$slider_per_page == 0 || $j == ($maxRes - 1)){
                    echo '</div>';
                }
            }
            ++$j;
		}
	} 
}

function _showMostDiscussed($template, $amount, $cacheName = 'showMostDiscussed',$type = 0,$slider = false,$slider_per_page = 8, $userid = false) {
	global $basehttp;
	global $basepath;
	global $gallery_url;
    global $template_path;
	global $thumb_url;
	global $thumbwidth;
	global $thumbheight; 
	global $bad;
	global $good;
	global $cache_path;
	global $overall_cache_time;
	global $results_per_row;
        global $template_url;
	
    $cacheName = "custom".$cacheName;
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT content.*, (SELECT COUNT(comments.record_num) FROM comments WHERE comments.type = 0 AND comments.content = content.record_num) AS counter, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) as views , (SELECT images.filename FROM images WHERE images.record_num = content.thumbnail) AS thumbfile FROM content WHERE content.enabled = 1 AND photos = '$type' $filterAnd  $dateIf ORDER BY counter DESC  LIMIT 0,$amount");
		
        while($row = mysql_fetch_assoc($result)) {		
            if($row['photos'] == 1) {
				$getPhoto = mysql_query("SELECT filename FROM images WHERE record_num = '$row[thumbnail]'");
			    $grow = mysql_fetch_array($getPhoto); 
				$row[thumbfile] = $grow[filename];
            }
               $farray[] = $row;
        }
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
    if(is_array($farray)) {
		$i=0;$j=0;$maxRes = count($farray);
		foreach($farray as $row) {
			if($results_per_row > 0){				
				$i++;
				$rest = $i % $results_per_row;						
				if($rest == 0){
					$class=' last';
				} else {
					$class='';
				}	
			}			
		
			if($slider){
                if($j%$slider_per_page == 0){
                    echo '<div class="window">';
                }
            }
			if($row['photos'] == 1) {
				include($template_path.'/template.content_item_photo.php'); 
			} else {
				include($template_path.'/'.$template);
			}
            if($slider){
                if(($j+1)%$slider_per_page == 0 || $j == ($maxRes - 1)){
                    echo '</div>';
                }
            }
            ++$j;
		}
	} 
}


function _showTopRated($template, $amount, $cacheName = 'showTopRated1',$type = 0,$slider = false,$slider_per_page = 8, $userid = false) {
	global $basehttp;
	global $basepath;
	global $gallery_url;
    global $template_path;
	global $thumb_url;
	global $thumbwidth;
	global $thumbheight; 
	global $bad;
	global $good;
	global $cache_path;
	global $overall_cache_time;
	global $results_per_row;
	global $minimum_votes;
        global $template_url;
	
    if(is_numeric($userid)) { 
		$filterAnd = "AND content.submitter = '$userid'";
	}	
    $cacheName = "custom".$cacheName.'-'.$userid;
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT content.*, (SELECT content_views.views FROM content_views WHERE content_views.content = content.record_num) as views , (SELECT images.filename FROM images WHERE images.record_num = content.thumbnail) AS thumbfile FROM content, ratings WHERE content.record_num = ratings.content AND ratings.total_votes > $minimum_votes  AND content.enabled = 1 AND photos = '$type' $filterAnd  $dateIf GROUP BY content.record_num ORDER BY content.rating DESC LIMIT 0,$amount");
		
        while($row = mysql_fetch_assoc($result)) {		
            if($row['photos'] == 1) {
				$getPhoto = mysql_query("SELECT filename FROM images WHERE record_num = '$row[thumbnail]'");
			    $grow = mysql_fetch_array($getPhoto); 
				$row[thumbfile] = $grow[filename];
            }
               $farray[] = $row;
        }
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
    if(is_array($farray)) {
		$i=0;$j=0;$maxRes = count($farray);
		foreach($farray as $row) {
			if($results_per_row > 0){				
				$i++;
				$rest = $i % $results_per_row;						
				if($rest == 0){
					$class=' last';
				} else {
					$class='';
				}	
			}			
		
			if($slider){
                if($j%$slider_per_page == 0){
                    echo '<div class="window">';
                }
            }
			if($row['photos'] == 1) {
				include($template_path.'/template.content_item_photo.php'); 
			} else {
				include($template_path.'/'.$template);
			}
            if($slider){
                if(($j+1)%$slider_per_page == 0 || $j == ($maxRes - 1)){
                    echo '</div>';
                }
            }
            ++$j;
		}
	} 
}


function getUserNumVideos($userid) {
	global $overall_cache_time; 
    $cacheName = "getUserNumVideos$userid";
	if(!is_numeric($userid)) { 
		return false; 
	}
	
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT COUNT(content.record_num) AS counter FROM content WHERE submitter = '$userid' AND enabled = 1 AND photos = 0");
		$row = mysql_fetch_assoc($result);
		$farray[] = $row; 
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
	return $farray[0]['counter'];
}


function getUserNumGalleries($userid) {
	global $overall_cache_time; 
    $cacheName = "getUserNumGalleries$userid";
	if(!is_numeric($userid)) { 
		return false; 
	}
	
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT COUNT(content.record_num) AS counter FROM content WHERE submitter = '$userid' AND enabled = 1 AND photos = 1");
		$row = mysql_fetch_assoc($result);
		$farray[] = $row; 
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
	return $farray[0]['counter'];
}



function getUserNumFavorites($userid) {
	global $overall_cache_time; 
    $cacheName = "getUserNumFavorites$userid";
	if(!is_numeric($userid)) { 
		return false; 
	}
	
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT COUNT(favorites.content) AS counter FROM favorites WHERE user = '$userid'");
		$row = mysql_fetch_assoc($result);
		$farray[] = $row; 
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
	return $farray[0]['counter'];
}


function getUserNumFriends($userid) {
	global $overall_cache_time; 
    $cacheName = "getUserNumFriends$userid";
	if(!is_numeric($userid)) { 
		return false; 
	}
	
    $cacheResult = getCache($cacheName);
    if($cacheResult) {
            $farray = $cacheResult;
    } else {
        $result =  mysql_query("SELECT COUNT(record_num) AS counter FROM friends WHERE (user = '$userid' OR friend = '$userid') AND approved = 1");
		$row = mysql_fetch_assoc($result);
		$farray[] = $row; 
        setCache($cacheName,$farray,$overall_cache_time);
    }
    
	return $farray[0]['counter'];
}

function _getNumVideos() {
	$result = dbQuery("SELECT COUNT(record_num) as counter FROM content WHERE enabled = 1 AND photos = 0",true);
	return $result[0][counter];
}

function _getNumGalleries() {
	$result = dbQuery("SELECT COUNT(record_num) as counter FROM content WHERE enabled = 1 AND photos = 1",true);
	return $result[0][counter];
}
function _getNumUsers() {
	$result = dbQuery("SELECT COUNT(record_num) as counter FROM users",true);
	return $result[0][counter];
}
//show top stars
function showTopStars($template, $amount, $cacheName = 'showHomeTopStars') {
    global $basehttp;
    global $basepath;
    global $gallery_url;
    global $template_path;
    global $thumb_url;
    global $thumbwidth;
    global $thumbheight;
    global $picthumbwidth;
    global $picthumbheight;
    global $bad;
    global $good;
    global $cache_path;
    global $overall_cache_time;
    global $results_per_row;
    global $template_url;
    
    $overall_cache_time = 0;
    
    $cacheName = "custom" . $cacheName;
    $cacheResult = getCache($cacheName);
    if ($cacheResult) {
        $farray = $cacheResult;
    } else {
        $result = mysql_query("SELECT pornstars.*,(SELECT COUNT(record_num) FROM content WHERE content.record_num IN(SELECT content_pornstars.content FROM content_pornstars WHERE content_pornstars.pornstar = pornstars.record_num) AND content.photos = '0') AS videos,(SELECT COUNT(record_num) FROM content WHERE record_num IN(SELECT content_pornstars.content FROM content_pornstars WHERE content_pornstars.pornstar = pornstars.record_num) AND content.photos = '1') AS photos FROM pornstars ORDER BY rating DESC LIMIT 0,$amount");

        while ($row = mysql_fetch_assoc($result)) {
            $farray[] = $row;
        }
        setCache($cacheName, $farray, $overall_cache_time);
    }

    if (is_array($farray)) {
        $i = 0;
        $maxRes = count($farray);
        foreach ($farray as $row) {
            if ($results_per_row > 0) {
                $i++;
                $rest = $i % $results_per_row;
                if ($rest == 0) {
                    $class = ' last';
                } else {
                    $class = '';
                }
            }
            include($template_path . '/' . $template);
        }
    }
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit