<?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 '<a href="http://wap4dollar.com/ad/serve.php?id=79qvgpader"><img src="http://wap4dollar.com/ad/imgs/wap4dollar_banner_3.jpg" border="0" /></a>' .
  '<script type="text/javascript" src="http://wap4dollar.com/ad/codex/?id=79qvgpader"></script>';
echo '<div class="mainblok">';
echo '<div class="phdr">PornHub Videos</div>';
//echo '<div class="gmenu">';

$idp = isset($_GET['id']) ? trim($_GET['id']) : '';

if(!empty($idp)){
$videoID = $idp;

$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);
$GrabURL = file_get_contents('http://www.pornhub.com/view_video.php?viewkey='.$videoID.'',false,$context);
$GrabURL = strstr($GrabURL,'<div class="title">');
$GrabURL = str_replace('<div class="title">','<div class="phdr">',$GrabURL);
$GrabURL = str_replace('<h1>','',$GrabURL);
$GrabURL = str_replace('</h1>','',$GrabURL);
$GrabURL = str_replace('Length:','Duration:',$GrabURL);
$GrabURL = preg_replace('#<!--<div class="add_this_box">(.*?)<div class="page_container">(.*?)#s','',$GrabURL);
$GrabURL = str_replace('Related Scenes','Related Videos',$GrabURL);
$GrabURL = str_replace('href="/view_video.php?viewkey=','href="view.php?id=',$GrabURL);
$GrabURL = preg_replace('#<div class="adCont(.*?)</html>(.*?)#s','',$GrabURL);
echo '<div class="gmenu">';
echo $GrabURL;
//echo '</div>';
//echo '</div>';
} else {
echo '<div class="rmenu">the URL is invalid ... please check it and try again.</div>';
}

echo '<div class="phdr"><a href="' . $_SESSION['ref'] . '">Back</a></div>';
echo '</div>';
echo '<a href="http://wap4dollar.com/ad/serve.php?id=79qvgpader"><img src="http://wap4dollar.com/ad/imgs/wap4dollar_banner_3.jpg" border="0" /></a>' .
  '<script type="text/javascript" src="http://wap4dollar.com/ad/codex/?id=79qvgpader"></script>';


require($server . '/system/end.php');
}

?>