<?php
function video_category() {
global  $htmlorphp,$folder,$LANGAUGE,$video_catsloop;

if($video_catsloop=="1"){$width = "100%";}
elseif($video_catsloop=="2"){$width = "50%";}
elseif($video_catsloop=="3"){$width = "33%";}
elseif($video_catsloop=="4"){$width = "25%";}
elseif($video_catsloop=="5"){$width = "20%";}
elseif($video_catsloop=="6"){$width = "16%";}
else{$width = "";}

$sql = @mysql_query("SELECT * FROM videocategory where active='1' order by order_cat");
$xx = mysql_num_rows($sql);
if($xx == 0){
$prints = $LANGAUGE[277];
}else{
$prints = "<table border='0' width='100%' id='t1'>
<tr>";
$tr = 0;
$ii = 0;
while ($Row = @mysql_fetch_array($sql))
{
$Row['name'] = text(3,$Row['name']);
$Row['image'] = text(3,$Row['image']);

if ($htmlorphp=="1"){
$links = "video-cats-".$Row['id'].".html";
}else{
$links = "video.php?x=category&id=".$Row['id']."";
}

//if (file_exists($Row['image'])){
if($Row['image'] == ""){
$i = "<a href='$links'><img width='100' height='100' src='$folder/icons/nopic.jpg' alt='".$Row['name']."' border='0' /><br />".$Row['name']."</a>";
}else{
$i = "<a href='$links'><img width='100' height='100' src='".$Row['image']."' alt='".$Row['name']."' border='0' /><br />".$Row['name']."</a>";
}
//}else{
//$i = "<a href='$links'><img width='100' height='100' src='$folder/icons/nopic.jpg' alt='".$Row['name']."' border='0' /><br />".$Row['name']."</a>";
//}

++$ii;
++$tr;
if($tr==$video_catsloop){
$trx = "</tr><tr>";
$tr = 0;
}else{
$trx = "";
}

$prints .= "<td width='$width' class='category' align='center'><div>".$i."</div></td>";

if($ii==$xx){
$trr = str_replace("<tr>","",$trx); ;
}else{
$trr = $trx;
}
$prints .= "$trr";
}

$prints .= "</table>";
}
return $prints;
}


function video_content($catid) {
global  $htmlorphp,$folder,$limit_video,$LANGAUGE;

$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = $limit_video;
$startpoint = ($page * $perpage) - $perpage;

$sqlx = @mysql_query("SELECT * FROM videocontent where active='1' AND cat='".$catid."' order by id desc LIMIT $startpoint,$perpage");
$xxx = mysql_num_rows($sqlx);
if($xxx == 0){
$prints = $LANGAUGE[277];
}else{
$prints .= "<table class='xtable' width='100%' id='t2' >
    <tr>
      <td width='70%' class='xtr' align='center'>".$LANGAUGE[279]."</td>
      <td width='20%' class='xtr' align='center'>".$LANGAUGE[280]."</td>
      <td width='10%' class='xtr' align='center'>".$LANGAUGE[281]."</td>
</tr>";
while ($Rows = @mysql_fetch_array($sqlx))
{
$Rows['name'] = text(3,$Rows['name']);
$Rows['url'] = text(3,$Rows['url']);
$Rows['textcode'] = text(3,$Rows['textcode']);

$d = date("j/n/Y",$Rows['date']);

if($Rows['selectcode']==1){
$des = "<br />".$Rows['textcode']."";
}else{
$des = "";
}

if ($htmlorphp=="1"){
$lx = "video-show-".$Rows['id'].".html";
}else{
$lx = "video.php?x=show&id=".$Rows['id']."";
}

$prints .= "<tr>
<td width='70%' class='xtd'><a href='$lx'>".$Rows['name']."</a></td>
<td width='20%' class='xtd' align='center'>".$d."</td>
<td width='10%' class='xtd' align='center'>".$Rows['visitor']."</td>
</tr>";
}
$prints .= "</table>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("SELECT * FROM videocontent where active='1' AND cat='".$catid."'")) / $perpage);
if($pagesnum > 1){
$prints .= "<div class='multipage'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {
if ($htmlorphp=="1"){
$z = "<span><a href='v".$catid.",".$i.".html'>$i</a></span>";
}else{
$z = "<span><a href='video.php?x=category&id=".$catid."&page=".$i."'>$i</a></span>";
}

} else {
$z = "<span class='act'>$i</span>";
}
$prints .= "$z";
}
$prints .= "</div>";
}
}
return $prints;
}
?>