include_once('../priv/bdconnect.php');
include_once('../fonctions.php');
//Langue par defaut
if($l=="") $l="fra";
include_once('../langues/'.$l.'_inc.php');
$connect=mysql_connect($cntHost, $cntUser, $cntPswd) or die ("Mauvaise connection");
if (!empty($_GET)) while(list($name, $value) = each($_GET)) $$name = $value;
$niches="";
//Login par defaut
if($login=="") $login=$login_defaut;
$inc="login=$login&l=$l&mb=$mb";
// nombre de videos
if($mini=="") $mini=0;
// information webmaster
$strSql="SELECT * FROM mb_affilies WHERE id=$mb";
$res = mysql_db_query($cntBd, $strSql) or die ("Requete invalide $strSql !
".mysql_error());
$row=mysql_fetch_assoc($res);
$modele=$row['modele'];
$maxi=$row['maxi'];
$Cid=$row['catid'];
$cfond=$row['cfond'];
$clien=$row['clien'];
$chover=$row['chover'];
$ctitre=$row['ctitre'];
$ctexte=$row['ctexte'];
$cvideo=$row['cvideo'];
$border=$row['border'];
$fontsize=$row['fontsize'];
$cbgtext=$row['cbgtext'];
//lecture du fichier modele
$sourcetpl=tmpl("mb-modele_1_".$l.".html");
// recherche des rubriques à afficher
$catid=explode(",",substr($Cid,1,-1));
$nbN=count($catid);
foreach($catid as $elem)
{
$requet.="V_idcat LIKE '%,$elem,%'";
if($b<($nbN-1)) $requet.=" OR ";
$b++;
}
if($cat!="")
{
$requet="";
if($a>0) $requet.=" OR ";
else $a++;
$requet.="V_idcat LIKE '%,$cat,%'";
}
//affichage des videos
if($requet=="") $requet=1;
$strSql="SELECT count(*) as count FROM videos LEFT JOIN traduction ON V_id=Trad_idfilm WHERE ($requet) AND V_online<='".time()."' AND V_doc=0 ";
$res = mysql_db_query($cntBd, $strSql) or die ("Requete invalide $strSql !
".mysql_error());
$row_nbVideos=mysql_fetch_array($res);
$nbVideos1 = $row_nbVideos['count'];
$strSql="SELECT * FROM videos LEFT JOIN traduction ON V_id=Trad_idfilm WHERE ($requet) AND V_online<='".time()."' AND V_doc=0 ORDER BY V_online DESC LIMIT $mini,$maxi";
$res = mysql_db_query($cntBd, $strSql) or die ("Requete invalide $strSql !
".mysql_error());
$nbVideos=mysql_num_rows($res);
if ($nbVideos>0)
{
while($row = mysql_fetch_array($res))
{
// table videos
$V_id=$row['V_id'];
$catid=explode(",",substr($row["V_idcat"],1,-1));
$V_modele=$row['V_modele'];
$V_age=$row['V_age'];
$V_duree=$row['V_duree'];
$V_ref=$row['V_ref'];
$V_rep=$row['V_rep'];
$V_fichier=$row['V_fichier'];
$V_date=$row['V_date'];
$V_online=$row['V_online'];
$V_poids=$row['V_poids'];
// table traduction
$titre=strtolower($row['Trad_titre']);
$Desc=nl2br($row['Trad_Desc']);
// Nombre de fois où le film a été vu
$strSqlVu="SELECT count(S_idfilm) as count FROM stats_films WHERE S_idfilm='$V_id'";
$resVu = mysql_db_query($cntBd, $strSqlVu) or die ("Requete invalide $strSqlVu !
".mysql_error());
$row_vu = mysql_fetch_array($resVu);
$NbResultVu = $row_vu['count'];
if($NbResultVu=="") $NbResultVu=0;
// remplacement des tags
$source=rmpl("IDVID",$V_id,$sourcetpl);
$source=rmpl("TITRE",ucfirst($titre),$source);
$source=rmpl("DESCRIPTIF",$Desc,$source);
$source=rmpl("POIDS",$V_poids,$source);
$source=rmpl("DUREE",$V_duree,$source);
$source=rmpl("ONLINE",date("d/m/Y",$V_online),$source);
$source=rmpl("CAT",$niches,$source);
$source=rmpl("VU","$NbResultVu",$source);
$source=rmpl("D","$Domaine",$source);
// les vignettes
$img=array();
$ext=array();
if ($handle = @opendir($Path.'/videos/'.$V_rep))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && $file != "Thumbs.db")
{
if(substr($file,-3)=="jpg")
{
$img[]=substr($file,0,-4);
$ext[]=substr($file,-3);
}
}
}
}
sort($img);
preg_match_all("#%%IMG(.*)%%#",$source,$matches);
$tagIMG=$matches[0];
foreach ($tagIMG as $key=>$elem)
{
$source=rmpl(str_replace('%%','',$elem),$Domaine."/videos/".$V_rep."/".$img[$key].'.'.$ext[$key],$source);
}
$strLignes.=$source;
$img=array();
$ext=array();
}
}
// pagination ===================================================================================================================
$Nbpages=ceil($nbVideos1 / $maxi);
$x=30;
$a=$x;
$z=0;
if($p=="") $p=1;
if($cat!="") $q.='&cat='.$cat;
while($z < $Nbpages)
{
/*
if($z<$x)
{
$y=$z+1;
if($p==$y) $Color =" STYLE='color: #FFFFFF; background-color: #8A8A8A; padding-top: 5px; padding-bottom: 5px; font-weight: bold;'";
else $Color="";
$pages.="$y";
if($y < $x && $y<$Nbpages) $pages.=" | ";
}
else
{
if($z==$x) $pages.=" \n