<?
function in_multi_array($needle, $haystack)
{
$in_multi_array = false;
if(in_array($needle, $haystack))
{
$in_multi_array = true;
}
else
{
for($i = 0; $i < sizeof($haystack); $i++)
{
if(is_array($haystack[$i]))
{
if(in_multi_array($needle, $haystack[$i]))
{
$in_multi_array = $i;
break;
}
}
}
}
return $in_multi_array;
}
if (!isset($supporto)){
$supporti=array();
$testo="select distinct(supporto),count(*) from movie group by supporto order by supporto";
$res=mysql_query($testo,$db);
$num=mysql_num_rows($res);
$totale=0;
OpenTable("Elenco Supporti Film");
$num2=0;
for($i=0;$i<$num;$i++){
$supporto=mysql_result($res,$i,0);
$numero=mysql_result($res,$i,1);
$totale=$totale+$numero;
$tmp=explode(",",$supporto);
$ln=sizeof($tmp);
for($ii=0;$ii<$ln;$ii++){
$str=$tmp[$ii];
//echo "<p>$str";
$pos=in_multi_array($str,$supporti);
if ($pos>0){
$supporti[$pos][0]=$tmp[$ii];
if (!isset($supporti[$pos][1]))
$supporti[$pos][1]=0;
$supporti[$pos][1]=$supporti[$pos][1]+$numero;
}else{
$supporti[$num2][0]=$tmp[$ii];
if (!isset($supporti[$num2][1]))
$supporti[$num2][1]=0;
$supporti[$num2][1]=$supporti[$num2][1]+$numero;
$num2=$num2+1;
}
}
if ($supporto==""){
$supporto_="non assegnato";
}else{
}
}
//$supporti=array_multisort($supporti,'SORT_STRING');
$num=sizeof($supporti);
echo "<tr>";
echo "<td width='100'> </td>";
echo "<td bgcolor=$bgcolor6><b>Supporto</b></td>";
echo "<td bgcolor=$bgcolor6><b>Film Presenti</b></td>";
echo "<td width='100'> </td>";
echo "</tr>";
for($i=0;$i<$num;$i++){
$supporto_=$supporti[$i][0];
$numero=$supporti[$i][1];
if ($supporto_=="")
$supporto_="N/A";
if ($i % 2==0)
$sfondo=$bgcolor2;
else
$sfondo=$bgcolor3;
echo "<tr>";
echo "<td width='100'> </td>";
echo "<td bgcolor=$sfondo><a href='$PHP_SELF?page=$page&supporto=$supporto_&tipo=movie'>$supporto_</a></td>";
echo "<td bgcolor=$sfondo align='right'>$numero</td>";
echo "<td width='100'> </td>";
echo "</tr>";
}
echo "<tr>";
echo "<td width='100'> </td>";
echo "<td> </td><td bgcolor=$bgcolor6><b>totale film: $totale</b></td>";
echo "<td width='100'> </td>";
echo "</tr>";
closetable();
$testo="select distinct(supporto),count(*) from programmi group by supporto order by supporto";
$res=mysql_query($testo,$db);
$num=mysql_num_rows($res);
$totale=0;
OpenTable("Elenco Supporti Programmi");
for($i=0;$i<$num;$i++){
$supporto=mysql_result($res,$i,0);
$numero=mysql_result($res,$i,1);
$totale=$totale+$numero;
if ($supporto=="")
$supporto_="non assegnato";
else
$supporto_=$supporto;
echo "<tr><td><a href='$PHP_SELF?page=$page&supporto=$supporto&tipo=prog'>$supporto_</a></td><td>Programmi presenti: $numero</td></tr>";
}
echo "<tr><td> </td><td>totale Programmi: $totale</td></tr>";
closetable();
}else{
switch ($tipo){
case 'movie':
$testo="select * ";
$testo.="from movie ";
$testo.="where supporto like '%$supporto%' ";
$testo.="order by id";
//echo "<p>$testo";
$res=mysql_query($testo,$db);
$num=mysql_num_rows($res);
//Preparazione Immagine
$im= imagecreatetruecolor ( 1138, 800 );
$background = imagecolorallocate($im, 240, 240, 255);
$text_color = imagecolorallocate($im, 0, 0, 0);
$text_color2= imagecolorallocate($im, 80, 80, 255);
$bianco= imagecolorallocate($im, 255, 255, 255);
$nero= imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle ( $im, 2, 2, 1136,798, $background);
imagefilledrectangle ( $im, 610, 0, 860,800, $nero);
$font = imageloadfont("font\almosnow.gdf");
$font2=imageloadfont("font\dreamofme.gdf");
imagestring($im,$font,10,10,"$supporto",$text_color2);
imagestringup($im,$font,545,780,"$supporto",$text_color2);
$style = array($nero, $nero, $nero, $nero, $nero, $bianco, $bianco, $bianco, $bianco, $bianco);
imagesetstyle($im, $style);
imageline($im, 539, 0, 539, 800, IMG_COLOR_STYLED);
imageline($im, 599, 0, 599, 800, IMG_COLOR_STYLED);
$im2=imagecreatefromjpeg("grafica\\divx_lrg_bl_jpg.jpg");
$width=imagesx($im2);
$height=imagesy($im2);
$tmp=$width/$height;
imagecopyresampled ($im, $im2, 870, 10+155, 0, 0, 200*$tmp, 200, $width, $height);
imagedestroy($im2);
//Tabella con scheda
OpenTable("Elenco Film Supporto $supporto");
echo "<tr><td><a href='$PHP_SELF?page=$page'>Torna a elenco</a></td></tr>";
echo "<tr><td> </td></tr>";
for($i=0;$i<$num;$i++){
$id_film=mysql_result($res,$i,'id');
$nome_film=mysql_result($res,$i,'titolo');
$durata=mysql_result($res,$i,'durata');
$attori=mysql_result($res,$i,'attori');
if ($i % 2==0)
$sfondo=$bgcolor2;
else
$sfondo=$bgcolor3;
echo "<tr>";
echo "<td bgcolor=$sfondo><a href='$PHP_SELF?page=elenchi\scheda.php&id_film=$id_film'>$nome_film</a></td>";
echo "<td bgcolor=$sfondo>$durata</td>";
echo "</tr>";
$testo="select * from movie_img where id_film=$id_film";
$res2=mysql_query($testo,$db);
$num2=mysql_num_rows($res2);
if ($num2>0){
$nome_file=mysql_result($res2,0,'nome_file');
//define("FISICAL_PATH","c:\\siti\\movie\\images");
$im2=imagecreatefromjpeg(FISICAL_PATH."\\$id_film\\$nome_file");
}else{
$im2=imagecreatefromjpeg("grafica\\bianco.jpg");
}
$width=imagesx($im2);
$height=imagesy($im2);
$tmp=$width/$height;
//echo "<p>$tmp";
//imagecopymerge ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h, int pct )
//imagecopyresampled ( resource dst_image, resource src_image, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h )
imagecopyresampled ($im, $im2, 620, 10+155*$i, 0, 0, 150*$tmp, 150, $width, $height);
imagedestroy($im2);
$attori=str_replace(chr(13).chr(10),' ', $attori);
$attori=substr($attori,0,75);
imagestring($im, 2, 10, 80+($i*60), "- $nome_film", $text_color);
imagestring($im, 2, 10, 95+($i*60), " Durata: $durata", $text_color);
imagestring($im, 2, 10, 110+($i*60), " Attori: $attori", $text_color);
//imagestringup($im, 2, 870+($i*25), 790, "- $nome_film", $text_color);
}
//imagefilledrectangle ( $im, 2, 2, 1136,798, $colore );
imagejpeg($im,"copertine\\$supporto.jpg");
imagedestroy($im);
echo "<tr><td colspan='2'> </td></tr>";
echo "<tr>";
echo "<td colspan='2'>";
echo "<img width='600' src=\"copertine\\$supporto.jpg\">";
echo "</td>";
echo "</tr>";
closetable();
break;
case 'prog':
$testo="select * from programmi where supporto='$supporto'";
$res=mysql_query($testo,$db);
$num=mysql_num_rows($res);
OpenTable("Elenco programmi Supporto $supporto");
echo "<tr><td><a href='$PHP_SELF?page=$page'>Torna a elenco</a></td></tr>";
echo "<tr><td> </td></tr>";
for($i=0;$i<$num;$i++){
$id=mysql_result($res,$i,'id');
$nome_prog=mysql_result($res,$i,'nome');
echo "<tr><td bgcolor=$bgcolor2><a href='$PHP_SELF?page=elenchi\scheda_prog.php&id_prog=$id'>$nome_prog</a></td></tr>";
}
closetable();
break;
}
}
?>