include ("forixinc.php");
include ("ng_util.php");
include ("gp_util.php");
include ("nc_util.php");
include ("pi_util.php");
include ("pa_util.php");
include ("co_util.php");
include ("mo_util.php");
include ("util.php");
function pri_filter ($tit, $oper, $cla)
{
if ($oper > 0) {
echo("[$tit");
switch ($oper) {
case 1:
echo("=$cla]");
break;
case 2:
echo("<$cla]");
break;
case 3:
echo(">$cla]");
break;
case 4:
echo("=0]");
break;
}
}
}
$gal=intval(get_arg("g"));
if ($gal==1)
$dgal="art";
else if ($gal==2)
$dgal="mod";
else
$dgal="img";
$tip=intval(get_arg("x"));
$ref=intval(get_arg("r"));
$ini=intval(get_arg("i")/9)*9;
if ($ini < 0) $ini = 0;
$fotografo=str_replace(" ","+",get_arg("f"));
$sig=get_arg("s");
$rcp = intval(get_arg("rcp"));
$rng = intval(get_arg("rng"));
$rnc = intval(get_arg("rnc"));
$rpi = intval(get_arg("rpi"));
$rco = intval(get_arg("rco"));
$rma = intval(get_arg("rma"));
$ocla = intval(get_arg("oc"));
$ccla = intval(get_arg("cc"));
$ogre = intval(get_arg("og"));
$cgre = intval(get_arg("cg"));
$ovmr = intval(get_arg("ov"));
$cvmr = intval(get_arg("cv"));
if ($tip==0 and ($fotografo > "" or $sig > ""))
$tip = 99;
if ($tip==0 || $tip==99 || $tip==1001 || $tip==1002)
$ref=1;
if (post_arg("form") == 1) {
if ($tip == 0) {
if (($rcp = intval(post_arg("ano"))) > 0) {
if ($rcp < 50)
$rcp += 2000;
if ($rcp < 1950)
$rcp += 1900;
}
$rng = post_arg("rng");
$rnc = post_arg("rnc");
$rpi = PIref(post_arg("pi"));
$rco = COref(post_arg("ma"));
$rma = MOref(post_arg("mo"));
$ocla = intval(post_arg("ocla"));
$ccla = intval(post_arg("ccla"));
if ($ccla <= 0) $ccla = 1;
$ogre = intval(post_arg("ogre"));
$cgre = intval(post_arg("cgre"));
if ($cgre <= 0) $cgre = 1;
$ovmr = intval(post_arg("ovmr"));
$cvmr = intval(post_arg("cvmr"));
if ($cvmr <= 0) $cvmr = 1;
} else
if ($tip == REF_CP) {
if (($anon = intval(post_arg("ano"))) > 0) {
if ($anon < 50)
$anon += 2000;
if ($anon < 1950)
$anon += 1900;
$ref = $anon;
}
} else
if ($tip == REF_NG)
$ref = intval(post_arg("rng"));
else
if ($tip == REF_GP) {
$ano=intval($ref/100)+1900;
if (($anon = intval(post_arg("ano"))) > 0) {
if ($anon < 50)
$anon += 2000;
if ($anon < 1950)
$anon += 1900;
$ano = $anon;
}
if (($rng = post_arg("rng")) == 0)
$ref = GP_ref_rgp ($ano, $ref);
else
$ref = GP_ref_rng ($ano, $rng);
if ($ref<=0 or intval(substr($ref,strlen($ref)-(2)))>80) {
header("Location: cp.asp?$args&r=$ano&c=$cmdCPgpr");
exit();
}
} else
if ($tip == REF_PA) {
$ano=intval($ref/100000)+1900;
$rgp=intval($ref/1000);
if (($anon = post_arg("ano")) > 0) {
if ($anon < 50)
$anon += 2000;
if ($anon < 1950)
$anon += 1900;
$ano = $anon;
}
if (($rng = post_arg("rng")) == 0)
$rgp = GP_ref_rgp ($ano, $rgp);
else
$rgp = GP_ref_rng ($ano, $rng);
if ($rgp<=0 or intval(substr($rgp,strlen($rgp)-(2)))>80) {
header("Location: cp.asp?$args&r=$ano&c=$cmdCPgpr");
exit();
}
if (post_arg("pi")!="")
$ref = Rpa_npi($rgp,post_arg("pi"));
else {
if (post_arg("num")!="")
$num = intval(post_arg("num"));
else
$num = -1;
if ($num >= 0)
$ref = PArefn ($rgp, $num);
else
$ref = PAref($rgp, PArpi($ref));
}
if ($ref <= 0) {
header("Location: gp.asp?$args&r=$rgp&c=$cmdGPpar");
exit();
}
} else
if ($tip == REF_PI or $tip == REF_PI*10) {
if (($npi = trim(post_arg("pi")))!="")
$ref = PIref(str_replace("'","''",$npi));
}
}
// Photos per page and per row
$ntot = 9;
$ncol = 3;
log_page($REF_FOTO,$ref,$tip);
// Uma foto
if ($tip==101) {
fxhead("Forix: ".$titulo[$N_PGAL]);
$fich=str_replace("'","''",str_replace(" ","+",get_arg("f")));
$SQLQuery="SELECT fotos.*, contactos.copynote FROM fotos inner join contactos on fotos.sig=contactos.sig WHERE fotos.foto='".$fich."'";
if (($result2 = mysql_query($SQLQuery)) and ($RSFoto= mysql_fetch_array($result2))) {
$ref = $RSFoto["ref"];
$cref = $RSFoto["cref"];
tab_ini();
tab_bar(2);
echo("
");
if ($RSFoto["sig"]=="tposter") {
?>
}
echo(" ");
if ($cref==$REF_PI || $cref==$REF_PIA) {
link_ref($cref,$ref,$lin);
if (intval($RSFoto["ano"])>0)
echo(", ".$RSFoto["ano"]." ");
} else
link_ref($cref,$ref,$lin);
echo(" |
");
tab_bar(4);
tab_bor();
$dgal=$RSFoto["gal"];
if (!isset($dgal))
$dgal="img";
echo(" ");
if ($RSFoto["copynote"]!="") {
echo("".$RSFoto["copynote"]." |
");
tab_bar1(2);
} else
echo("");
}
} else {
if ($ref>0) {
$nfoto = 0;
if ($tip == 0) {
fxhead("Forix: ".$titulo[$N_PGAL]);
if ($rcp > 0 or $rng > 0 or $rnc > 0 or $rpi > 0 or $rco > 0 or $rma > 0) {
$sqlx = " from fotos, papi, contactos where fotos.sig=contactos.sig and fotos.dat<=".$hiso." and fotos.camp=1 and (fotos.gal='img' or fotos.gal is NULL) and fotos.cref=".$REF_PA." and fotos.ref=papi.rpa";
if ($rcp > 0)
$sqlx .= " and papi.rpa>".(($rcp-1900)*100000)." and papi.rpa<".(($rcp-1899)*100000);
if ($rng > 0)
$sqlx .= " and papi.rng=$rng";
if ($rnc > 0)
$sqlx .= " and papi.rnc=$rnc";
if ($rpi > 0)
$sqlx .= " and papi.rpi=$rpi";
if ($rco > 0)
$sqlx .= " and papi.rco=$rco";
if ($rma > 0)
$sqlx .= " and papi.rma=$rma";
switch ($ocla) {
case 1:
$sqlx .= " and papi.cla=$ccla";
break;
case 2:
$sqlx .= " and papi.cla<$ccla";
break;
case 3:
$sqlx .= " and papi.cla>$ccla";
break;
case 4:
$sqlx .= " and papi.cla=0";
break;
}
switch ($ogre) {
case 1:
$sqlx .= " and papi.gre=$cgre";
break;
case 2:
$sqlx .= " and papi.gre<$cgre";
break;
case 3:
$sqlx .= " and papi.gre>$cgre";
break;
case 4:
$sqlx .= " and papi.gre=0";
break;
}
switch ($ovmr) {
case 1:
$sqlx .= " and papi.vmr=$cvmr";
break;
case 2:
$sqlx .= " and papi.vmr<$cvmr";
break;
case 3:
$sqlx .= " and papi.vmr>$cvmr";
break;
case 4:
$sqlx .= " and papi.vmr=0";
break;
}
$sql = "Select fotos.*, contactos.copynote" . $sqlx . " order by fotos.ref, fotos.foto limit $ini, $ntot";
} else
$sql = "";
} else
if ($tip==99) {
fxhead("Forix: ".$titulo[$N_PGAL]);
$sqlx=" from fotos, contactos where fotos.sig=contactos.sig";
if (strlen($fotografo)>0)
$sqlx .= " and contactos.copynote like '%".str_replace("+"," ",$fotografo)."%'";
else if (strlen($sig)>0)
$sqlx .= " and contactos.sig like '".$sig."'";
else
$sqlx .= " and contactos.copynote like 'jplc'";
$sqlx .= " and fotos.dat<=".$hiso." and fotos.camp=1 and (fotos.cref<".$REF_CA." or fotos.cref>".$REF_MO.")";
$sql = "Select fotos.*, contactos.copynote" . $sqlx . " order by fotos.cref, fotos.ref, fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_CP) {
fxhead("Forix: ".$ref.", ".$titulo[$N_PGAL]);
$sqlx = " from fotos, contactos where fotos.sig=contactos.sig and fotos.dat<=".$hiso." and fotos.camp=1 and (fotos.gal='img' or fotos.gal is NULL) and ((fotos.ref>".(($ref-1900)*100)." and fotos.ref<".(($ref-1899)*100)." and fotos.cref=".$REF_GP.") or (fotos.ref>".(($ref-1900)*100000)." and fotos.ref<".(($ref-1899)*100000)." and fotos.cref=".$REF_PA."))";
$sql = "Select fotos.*, contactos.copynote" . $sqlx . " order by fotos.ref, fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_NG) {
$ng_nome=NGnome($ref);
fxhead("Forix: ".$ng_nome.", ".$titulo[$N_PGAL]);
$sqlx = " from fotos, contactos, papi where fotos.sig=contactos.sig and papi.rpa=fotos.ref and fotos.dat<=".$hiso." and fotos.camp=1 and (fotos.gal='img' or fotos.gal is NULL) and papi.rng=$ref and (fotos.cref=".$REF_PA." or fotos.cref=".$REF_GP.")";
$sql = "Select fotos.*, contactos.copynote" . $sqlx . " order by fotos.ref, fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_GP) {
$gp_nome=GPnome($ref);
fxhead("Forix: ".(1900+intval($ref/100)).", ".$gp_nome.", ".$titulo[$N_PGAL]);
$sqlx = " from fotos, contactos where fotos.sig=contactos.sig and fotos.dat<=".$hiso." and fotos.camp=1 and (fotos.gal='img' or fotos.gal is NULL) and ((fotos.ref=".$ref." or (fotos.ref>=".($ref*1000)." and fotos.ref<".($ref*1000+1000).")) and (fotos.cref=".$REF_PA." or fotos.cref=".$REF_GP."))";
$sql = "Select fotos.*, contactos.copynote" . $sqlx . " order by fotos.ref, fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_GPP || $tip==$REF_GPD) {
$gp_nome=GPnome($ref);
fxhead("Forix: ".(1900+intval($ref/100)).", ".$gp_nome.", ".$titulo[$N_GALL]);
$sqlx = " from fotos, contactos where fotos.sig=contactos.sig and fotos.dat<=".$hiso." and fotos.camp=1 and fotos.ref=".$ref." and fotos.cref=".$tip;
$sql = "Select fotos.*, contactos.copynote" . $sqlx . " order by fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_PA) {
fxhead("Forix: ".$titulo[$N_PGAL]);
$sqlx = " from fotos, contactos, papi, ngn, pin where fotos.sig=contactos.sig and papi.rpa=fotos.ref and papi.rng=ngn.rng and papi.rpi=pin.rpi and fotos.dat<=$hiso and fotos.camp=1 and fotos.cref=".$REF_PA." and fotos.ref=$ref and ngn.lin=$lin";
$sql = "Select papi.rpi, papi.rng, papi.num, fotos.*, contactos.copynote, ngn.nome as nome_ng, pin.nabr as nome_pi" . $sqlx . " order by fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_PI) {
$pi_nome=PInome($ref);
fxhead("Forix: ".$pi_nome.", ".$titulo[$N_PGAL]);
$sqlx = " from fotos, contactos, papi, ngn where fotos.sig=contactos.sig and papi.rpa=fotos.ref and papi.rng=ngn.rng and fotos.dat<=".$hiso." and fotos.camp=1 and (fotos.gal='img' or fotos.gal is NULL) and fotos.cref=".$REF_PA." and papi.rpi=$ref and ngn.lin=$lin";
$sql = "Select papi.rpa, fotos.*, contactos.copynote, ngn.nome as nome_ng" . $sqlx . " order by fotos.ref, fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_PI*10) {
$pi_nome=PInome($ref);
fxhead("Forix: ".$pi_nome.", ".$titulo[$N_PGAL]);
$sqlx = " from fotos, contactos where fotos.sig=contactos.sig and fotos.dat<=".$hiso." and fotos.camp=1 and fotos.cref=".$REF_PI." and fotos.ref=".$ref;
$sql = "Select fotos.*, contactos.copynote" . $sqlx . " order by fotos.ano, fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_CO) {
$co_nome=COnome($ref);
fxhead("Forix: ".$co_nome.", ".$titulo[$N_PGAL]);
$sqlx = " from fotos, contactos, papi, ngn where fotos.sig=contactos.sig and papi.rpa=fotos.ref and papi.rng=ngn.rng and fotos.dat<=".$hiso." and fotos.camp=1 and (fotos.gal='img' or fotos.gal is NULL) and fotos.cref=".$REF_PA." and papi.rco=$ref and ngn.lin=$lin";
$sql= "Select papi.rpa, fotos.*, contactos.copynote, ngn.nome as nome_ng" . $sqlx . " order by fotos.ref, fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_CA) {
$ca_nome=CAnome($ref);
fxhead("Forix: ".$ca_nome.", ".$titulo[$N_PGAL]);
$sqlx = " from fotos, contactos, papi, ngn where fotos.sig=contactos.sig and papi.rpa=fotos.ref and papi.rng=ngn.rng and fotos.dat<=".$hiso." and fotos.camp=1 and (fotos.gal='img' or fotos.gal is NULL) and fotos.cref=".$REF_PA." and papi.rca=$ref and ngn.lin=$lin";
$sql = "Select papi.rpa, fotos.*, contactos.copynote, ngn.nome as nome_ng" . $sqlx . " order by fotos.ref, fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_CA*10) {
$ncol=1;
$ca_nome=CAnome($ref);
fxhead("Forix: ".$ca_nome.", ".$titulo[$N_PGAL]);
$sqlx = " from fotos, contactos where fotos.sig=contactos.sig and fotos.dat<=".$hiso." and fotos.camp=1 and fotos.cref=".$REF_CA." and fotos.ref=$ref";
$sql = "Select fotos.*, contactos.copynote" . $sqlx . " order by fotos.dat, fotos.foto limit $ini, $ntot";
} else
if ($tip==$REF_MO*10) {
$ncol=1;
$mo_nome=MotNome($ref);
fxhead("Forix: ".$mo_nome.", ".$titulo[$N_PGAL]);
$sqlx = " from fotos, contactos where fotos.sig=contactos.sig and fotos.dat<=".$hiso." and fotos.camp=1 and fotos.cref=".$REF_MO." and fotos.ref=$ref";
$sql = "Select fotos.*, contactos.copynote" . $sqlx . " order by fotos.dat, fotos.foto limit $ini, $ntot";
} else
// Ultimas 45 fotos - PA e GP
if ($tip==1001) {
fxhead("Forix: ".$titulo[$N_PGAL]);
$nfoto = 45;
if ($ini > 36) $ini = 36;
$sql="Select fotos.*, contactos.copynote from fotos, contactos where fotos.sig=contactos.sig and fotos.dat<=".$hiso." and fotos.camp=1 and (fotos.gal='img' or fotos.gal is NULL) and (fotos.cref=".$REF_PA." or fotos.cref=".$REF_GP." or fotos.cref=".$REF_PIA.") and fotos.dat>0 order by fotos.dat desc, fotos.ref, fotos.foto limit $ini, 9";
} else
// Ultimas 27 fotos - PI
if ($tip==1002) {
fxhead("Forix: ".$titulo[$N_PGAL]);
$nfoto = 27;
if ($ini > 18) $ini = 18;
$sql="Select fotos.*, contactos.copynote from fotos, contactos where fotos.sig=contactos.sig and fotos.dat<=".$hiso." and fotos.camp=1 and fotos.cref=".$REF_PI." and fotos.dat>0 order by fotos.dat desc, fotos.ref, fotos.foto limit $ini, 9";
}
// Number of photos
if ($sql > "") {
if ($nfoto == 0 and ($result = mysql_query("Select count(*)".$sqlx)) and ($rs = mysql_fetch_array($result)))
$nfoto = $rs[0];
if (($result = mysql_query($sql)) and mysql_num_rows($result) > 0)
$RSList= mysql_fetch_array($result);
else
$RSList = false;
tab_ini();
tab_bar(2);
echo("");
if ($tip == 0) {
if ($rcp > 0)
echo("[$rcp]");
if ($rng > 0)
echo("[".NG_name($rng)."]");
if ($rnc > 0)
echo("[".NCnome($rng)."]");
if ($rpi > 0)
echo("[".PInome($rpi)."]");
if ($rco > 0)
echo("[".COnome($rco)."]");
if ($rma > 0)
echo("[".MOnome($rma)."]");
if ($ogre > 0 or $ocla > 0 or $ovmr > 0) {
echo(" |
---|
");
pri_filter ($titulo[$N_GRID], $ogre, $cgre);
pri_filter ($titulo[$N_RACE], $ocla, $ccla);
pri_filter ($titulo[$N_FLA], $ovmr, $cvmr);
}
} else
if ($tip==99) {
if ($RSList) {
if ($RSList["sig"]=="tposter") {
?>
}
echo $RSList["copynote"];
} else
echo str_replace("+"," ",$fotografo);
} else
if ($tip==1001 || $tip==1002)
echo $titulo[$N_NEW];
else {
if ($tip==$REF_GPP || $tip==$REF_GPD)
$cref = $REF_GP;
else if ($tip==$REF_PI*10)
$cref = $REF_PI;
else if ($tip==$REF_CA*10)
$cref = $REF_CA;
else if ($tip==$REF_MO*10)
$cref = $REF_MO;
else
$cref = $tip;
link_ref($cref,$ref,$lin);
}
echo(" |
---|
");
if ($ini>0) {
$inia=$ini-9;
if ($inia<0)
$inia=0;
echo("0)
echo("&f=$fotografo");
if (strlen($sig)>0)
echo("&s=$sig");
echo("&i=$inia\"> ");
}
if ($tip==$REF_GPP || $tip==$REF_GPD)
echo $titulo[$N_GALL];
else
echo $titulo[$N_PGAL];
if ($ini<$nfoto-9) {
$inip=$ini+9;
echo(" 0)
echo("&f=$fotografo");
if (strlen($sig)>0)
echo("&s=$sig");
echo("&i=$inip\">");
}
echo(" |
");
tab_bar(4);
tab_bor();
if ($RSList) {
echo(" |
");
// Menu
if ($nfoto>9) {
tab_bor();
echo(" |
");
}
} else
echo("$titulo[$N_NONE] |
");
} else {
tab_ini();
tab_bar(2);
echo("$titulo[$N_PGAL] |
");
tab_bar(2);
}
// Other selections
if ($tip == 0 or $tip == REF_CP or $tip == REF_NG or $tip == REF_GP or $tip == REF_PA or $tip == REF_PI or $tip == REF_PI*10) {
tab_bor();
tab_bar(4);
echo("