<?php
define('_IN_JOHNCMS', 1);
$server = $_SERVER['DOCUMENT_ROOT'];
require($server . '/system/bootstrap.php');
/** @var Psr\Container\ContainerInterface $container */
$container = App::getContainer();

/** @var PDO $db */
$db = $container->get(PDO::class);

/** @var Johncms\Api\UserInterface $systemUser */
$systemUser = $container->get(Johncms\Api\UserInterface::class);

/** @var Johncms\Api\ToolsInterface $tools */
$tools = $container->get(Johncms\Api\ToolsInterface::class);

/** @var Johncms\Api\EnvironmentInterface $env */
$env = $container->get(Johncms\Api\EnvironmentInterface::class);

/** @var Johncms\Api\BbcodeInterface $bbcode */
$bbcode = $container->get(Johncms\Api\BbcodeInterface::class);

/** @var Johncms\Api\ConfigInterface $config */
$config = $container->get(Johncms\Api\ConfigInterface::class);



$headmod = 'pornhub';
require($server . '/system/head.php');
if ($systemUser->premium !== '1') {

echo '<div class="mainblok">';
echo '<div class="phdr">PornHub Videos</div>';
echo '<div class="rmenu">Please upgrade your account to premium bellow. to show this content</div>';
echo '</div>';
require($server . '/system/end.php');
 
} else {
 
// Обрабатываем ссылку для возврата
if (empty($_SESSION['ref'])) {
    $_SESSION['ref'] = isset($_SERVER['HTTP_REFERER']) ? htmlspecialchars($_SERVER['HTTP_REFERER']) : $home;
}

echo '<div class="mainblok">';
echo '<div class="phdr">PornHub Videos  |  <b>Category</b></div>';
$Pag = isset($_GET['pag']) ? trim($_GET['pag']) : '';
if(!empty($Pag)){
$vpage = $Pag;
} else {
$vpage = "1";
}

$AddHeaders = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"User-Agent: Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (J2ME/23.377; U; en) Presto/2.5.25 Version/10.54"
  )
);

$context = stream_context_create($AddHeaders);

if(!empty($_GET['name'])){
$catName = $_GET['name'];

$GrabURL = file_get_contents('http://www.pornhub.com/categories/'.$catName.'?page='.$vpage.'',false,$context);
$GrabURL = strstr($GrabURL,'<div class="thumb">');
$GrabURL = str_replace('href="/view_video.php?viewkey=','href="view.php?id=',$GrabURL);
$GrabURL = str_replace('Length:','Duration:',$GrabURL);
$GrabURL = preg_replace('#<div class="premiumAd(.*?)</div>(.*?)#s','',$GrabURL);
$GrabURL = preg_replace('#<div class="adCont(.*?)</html>(.*?)#s','',$GrabURL);



echo $GrabURL;

echo '<div class="phdr">'; 

if($vpage > 1){
$navpage1 = $vpage-1;
$navpage2 = $vpage+1;
echo '<a href="categories.php?name='.$catName.'&amp;pag='.$navpage1.'" title="prev">&laquo; Previous</a> | <a href="categories.php?name='.$catName.'&amp;pag='.$navpage2.'" title="Next">Next &raquo;</a>';
}
else{
$navpage = $vpage+1;
echo '<span style="color: silver;">&laquo; Previous</span> | <a href="categories.php?name='.$catName.'&amp;pag='.$navpage.'" title="Next">Next &raquo;</a>';
}

echo '</div>';
}
else{
echo '<div class="phdr">All Categories</div>';

echo '<div class="menu"> <a href="index.php?cat=3">Amateur</a></div>';

echo '<div class="menu"> <a href="index.php?cat=35">Anal</a></div>';

echo '<div class="menu"> <a href="index.php?cat=1">Asian</a></div>';

echo '<div class="menu"> <a href="categories.php?name=babe">Babe</a></div>';

echo '<div class="menu"> <a href="index.php?cat=6">BBW</a></div>';

echo '<div class="menu"> <a href="index.php?cat=4">Big Ass</a></div>';

echo '<div class="menu"> <a href="index.php?cat=7">Big Dick</a></div>';

echo '<div class="menu"> <a href="index.php?cat=8">Big Tits</a></div>';

echo '<div class="menu"> <a href="index.php?cat=76">Bisexual</a></div>';

echo '<div class="menu"> <a href="index.php?cat=9">Blonde</a></div>';

echo '<div class="menu"> <a href="index.php?cat=13">Blowjob</a></div>';

echo '<div class="menu"> <a href="index.php?cat=10">Bondage</a></div>';
 
echo '<div class="menu"> <a href="index.php?cat=11">Brunette</a></div>';

echo '<div class="menu"> <a href="index.php?cat=14">Bukkake</a></div>';

echo '<div class="menu"> <a href="index.php?cat=74">Camel Toe</a></div>';

echo '<div class="menu"> <a href="index.php?cat=12">Celebrity</a></div>';
 
echo '<div class="menu"> <a href="categories.php?name=college">College</a></div>';

echo '<div class="menu"><a href="http://wap4dollar.com/ad/serve.php?id=79qvgpader">Indonesian</a></div>';

echo '<div class="menu"> <a href="index.php?cat=57">Compilation</a></div>';

echo '<div class="menu"> <a href="index.php?cat=15">Creampie</a></div>';
echo '<div class="menu"><a href="http://wap4dollar.com/ad/serve.php?id=79qvgpader">Artist</a></div>'; 
echo '<div class="menu"> <a href="index.php?cat=16">Cumshots</a></div>';

echo '<div class="menu"> <a href="index.php?cat=72">Double Penetration</a></div>';
 
echo '<div class="menu"> <a href="index.php?cat=17">Ebony</a></div>';

echo '<div class="menu"> <a href="index.php?cat=55">Euro</a></div>';

echo '<div class="menu"> <a href="http://morbd24.Com">Exclusive</a></div>';

echo '<div class="menu"> <a href="index.php?cat=18">Fetish</a></div>';
echo '<div class="menu"><a href="http://wap4dollar.com/ad/serve.php?id=79qvgpader">Arbic Sex</a></div>'; 
echo '<div class="menu"> <a href="index.php?cat=19">Fisting</a></div>';

echo '<div class="menu"> <a href="index.php?cat=73">For Women</a></div>';
 
echo '<div class="menu"> <a href="index.php?cat=32">Funny</a></div>';
 
echo '<div class="menu"> <a href="index.php?cat=80">Gangbang</a></div>';
 
echo '<div class="menu"> <a href="index.php?cat=20">Handjob</a></div>';

echo '<div class="menu"> <a href="index.php?cat=21">Hardcore</a></div>';

echo '<div class="menu"> <a href="categories.php?name=hentai">Hentai</a></div>';

echo '<div class="menu"> <a href="index.php?cat=101">Indian</a></div>';

echo '<div class="menu"> <a href="index.php?cat=25">Interracial</a></div>';

echo '<div class="menu"> <a href="index.php?cat=111">Japanese</a></div>';
 
echo '<div class="menu"> <a href="index.php?cat=26">Latina</a></div>';

echo '<div class="menu"> <a href="index.php?cat=27">Lesbian</a></div>';

echo '<div class="menu"> <a href="index.php?cat=78">Massage</a></div>';

echo '<div class="menu"> <a href="index.php?cat=22">Masturbation</a></div>';

echo '<div class="menu"> <a href="index.php?cat=28">Mature</a></div>';
 
echo '<div class="menu"> <a href="index.php?cat=29">MILF</a></div>';

echo '<div class="menu"> <a href="index.php?cat=2">Orgy</a></div>';

echo '<div class="menu"> <a href="index.php?cat=24">Outdoor</a></div>';

echo '<div class="menu"> <a href="index.php?cat=53">Party</a></div>';

echo '<div class="menu"> <a href="categories.php?name=pornstar">Pornstar</a></div>';

echo '<div class="menu"> <a href="index.php?cat=41">POV</a></div>';

echo '<div class="menu"> <a href="index.php?cat=31">Reality</a></div>';

echo '<div class="menu"> <a href="index.php?cat=42">Red Head</a></div>';

echo '<div class="menu"> <a href="index.php?cat=67">Rough Sex</a></div>';

echo '<div class="menu"> <a href="index.php?cat=59">Small Tits</a></div>';
 
echo '<div class="menu"> <a href="index.php?cat=92">Solo Male</a></div>';

echo '<div class="menu"> <a href="index.php?cat=69">Squirt</a></div>';

echo '<div class="menu"> <a href="index.php?cat=33">Striptease</a></div>';
 
echo '<div class="menu"> <a href="categories.php?name=teen">Teen</a></div>';

echo '<div class="menu"> <a href="index.php?cat=65">Threesome</a></div>';

echo '<div class="menu"> <a href="index.php?cat=23">Toys</a></div>';
 
echo '<div class="menu"> <a href="index.php?cat=81">Uniforms</a></div>';

echo '<div class="menu"> <a href="index.php?cat=43">Vintage</a></div>';
echo '<div class="menu"> <a href="index.php?cat=61">Webcam</a></div>';

echo '<div class="phdr"><a href="' . $_SESSION['ref'] . '">Back</a></div>';
}
echo '</div>';
require($server . '/system/end.php');
}
?>