Файл: adultscript-2.0.3-pro/files/misc/nuevo/related.php
Строк: 77
<?php
//***********************************************
//* NuevoLab FLASH PLAYER ver. 8.0 *
//* *
//* http://www.nuevolab.com *
//* email: support@nuevolab.com *
//* *
//***********************************************
define('_VALID', true);
require '../../libraries/bootstrap.php';
define ('PLAYER_URL', BASE_URL.'/misc/nuevo');
$video_id = (isset($_GET['id'])) ? (int) $_GET['id'] : 0;
if ($video_id === 0) {
die('Invalid video id!');
}
if(!isset($_GET['title'])) {
die('Invalid video title');
} else {
$title = trim($_GET['title']);
}
$related=array();
$cache = VF::factory('cache');
$db = VF::factory('database');
$cache_id = 'player_related_'.$video_id;
$sql = "SELECT *,MATCH title AGAINST ('".$db->escape($title)."') AS relevance FROM #__video WHERE status = '1' ORDER BY relevance DESC LIMIT 16";
if (!$related = $cache->get($cache_id, 86400)) {
$related = $db->get_rows($sql);
$cache->store($cache_id, $related, 86400);
}
ob_start();
?>
<related>
<?php
foreach($related as $rel) {
$title=trunc($rel['title'],50);
$title=str_replace("/","",$title);
$desc=trunc($rel['description'],150);
$desc=str_replace("/","",$desc);
$link=BASE_URL."/".$rel['video_id']."/".$rel['slug'];
$duration = date("i:s",$rel['duration']);
$thumb = MEDIA_URL."/videos/tmb/".path($rel['video_id'])."/".$rel['thumb'].".jpg";
print "<item>n";
print "<title><![CDATA[".$title."]]></title>n";
print "<description><![CDATA[".$desc."]]></description>n";
print "<link><![CDATA[".$link."]]></link>n";
print "<thumb><![CDATA[".$thumb."]]></thumb>n";
print "<runtime>".$duration."</runtime>n";
print "</item>n";
}
?>
</related>
<?php
$config = ob_get_contents();
ob_end_clean();
VResponse::add_header('Content-Type', 'text/xml');
VResponse::add_header('Pragma', 'no-cache');
VResponse::add_header('Cache-Control', 'no-cache, must-revalidate');
VResponse::add_header('Last-Modified', gmdate('D, d M Y H:i:s').' GMT');
VResponse::add_header('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT');
VResponse::send_headers();
echo $config;
VF::close();
function trunc($string, $length = 80, $etc = '...',$break_words = false)
{
if ($length == 0)
return '';
if (strlen($string) > $length) {
$length -= strlen($etc);
if (!$break_words)
$string = preg_replace('/s+?(S+)?$/', '', substr($string, 0, $length+1));
return substr($string, 0, $length).$etc;
} else
return $string;
}
?>