JuniorOsho
(usa Debian)
Enviado em 11/05/2007 - 22:02h
<?
//matriz, resolvo tudo aqui de ajax...
include("conexao.php");
include("biblioteca.php");
$JSON = new json();
if($_GET["pasta"]){
$evento = "galerias/".$_GET["pasta"]."/";
$dirr = opendir("../".$evento);
$fotos = array();
while($a = readdir($dirr)) {
$b = explode(".", $a);
if($b[1] == "jpg" || $b[1] == "jpge" || $b[1] == "JPG" || $b[1] == "JPGE"){
array_push($fotos, $a);
}
}
$total = count($fotos);
$qtd = 15;
$pagin = $_GET["pg"]*$qtd;
if(($para = $qtd+$pagin) > $total) $para = $total;
$ant = $_GET["pg"]-1;
$prox = $_GET["pg"]+1;
$paginas = $prox*$qtd;
echo '<div id="thumbs">';
$a = 0;
for($i=$pagin;$i<$para;$i++){
echo '';
echo '<a href="#" title="ABRIR A FOTO"><img id="'.$a.'" src="include/mini.php?img=../'.$evento.''.$fotos[$i].'&width=60&height=45" border="0" title="'.$evento.''.$fotos[$i].'" onclick="ajax.exibe(\''.$evento."".$fotos[$i].'\', this);" /></a>';
echo '';
echo ' ';
if(($a%3) == 2) echo '<br />';
$a++;
}
$paginacao = $total/$qtd;
echo '</div><div id="navnum"><ul>';
$a = 1;
for($i=0;$i<$paginacao;$i++) {
echo '<li>
<a href="javascript:void(0);" onclick="ajax.album(\''.$_GET["pasta"].'\', \''.$i.'\')">';
if(strlen($a)==1) {
echo "0".$a;
}else{
echo $a;
}
echo '</a></li>';
if($a == 10 || $a == 20 || $a == 30 || $a == 40 || $a == 50 || $a == 60 || $a == 70) echo '<ul>';
$a++;
}
echo '</ul></div><input type="hidden" id="TotalDeFotos" value="'.$total.'" />';
}
if($_GET["cadastro"] == 1) {
if($_POST["id"] == "") {
$sql = mysql_query("INSERT INTO evento VALUES (NULL, '".$_POST['data']."',
'".$_POST['evento']."', '".$_POST['dir']."', '".$_POST['foto']."',
'".$_POST['fotografo']."');");
if(mysql_insert_id() > 0) echo 'GRAVADA COM SUCESSO! '; else echo 'ERRO, TENTE NOVAMENTE';
}else{
$sql = mysql_query("UPDATE evento SET data = '".$_POST["data"]."',
evento = '".$_POST["evento"]."', pasta = '".$_POST["dir"]."',
foto = '".$_POST['foto']."',
fotografo = '".$_POST['fotografo']."' WHERE idevento = ".$_POST["id"]."");
if($sql) echo 'ALTERADO COM SUCESSO!'; else echo 'ERRO, TENTE NOVAMENTE';
}
}
if($_GET["lista"] == 1) {
$sql = mysql_query("SELECT * FROM evento ORDER BY ".$_GET['campo']." ".$_GET['tipo']."");
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" id="tabelaLista">
<tr>
<th width="5%">Editar</th>
<th width="5%">Excluir</th>
<th width="5%">Data</th>
<th width="1%"><a href="javascript:void(0);" onclick="ajax.listaGaleria(\'data\', \'ASC\')"><img src="../img/setaup.gif" title="ORDENAR ASCENDENTE" border="0" /></a></th>
<th width="1%"><a href="javascript:void(0);" onclick="ajax.listaGaleria(\'data\', \'DESC\')"><img src="../img/setadown.gif" title="ORDENAR DESCENDENTE" border="0" /></a></th>
<th width="20%">Evento</th>
<th width="1%"><a href="javascript:void(0);" onclick="ajax.listaGaleria(\'evento\', \'ASC\')"><img src="../img/setaup.gif" title="ORDENAR ASCENDENTE" border="0" /></a></td>
<th width="1%"><a href="javascript:void(0);" onclick="ajax.listaGaleria(\'evento\', \'DESC\')"><img src="../img/setadown.gif" title="ORDENAR DESCENDENTE" border="0" /></a></th>
<th width="20%">Pasta</th>
<th width="1%"><a href="javascript:void(0);" onclick="ajax.listaGaleria(\'pasta\', \'ASC\')"><img src="../img/setaup.gif" title="ORDENAR ASCENDENTE" border="0" /></a></th>
<th width="1%"><a href="javascript:void(0);" onclick="ajax.listaGaleria(\'pasta\', \'DESC\')"><img src="../img/setadown.gif" title="ORDENAR DESCENDENTE" border="0" /></a></th>
<th width="37%" class="center">Foto Principal </th>
<th width="1%"><a href="javascript:void(0);" title="Aumentar a foto"><img src="../img/mais.gif" border="0" onclick="anime.zoomFoto(\'+\')" /></a></th>
<th width="1%"><a href="javascript:void(0);" title="Diminuir a foto"><img src="../img/menos.gif" border="0" onclick="anime.zoomFoto(\'-\')" /></a></th>
</tr>';
while($s = mysql_fetch_array($sql)){
echo '<tr>
<td class="center"><a href="javascript:void(0);" title="EDITAR" onclick="ajax.editaGaleria(\''.$s[0].'\')"><img src="../img/editar.gif" border="0" /></a></td>
<td class="center"><a href="javascript:void(0);" title="EXCLUIR" onclick="ajax.deletaGaleria(\''.$s[0].'\')"><img src="../img/excluir.gif" border="0" /></a></td>
<td colspan="3">'.strtoupper($s[1]).'</td>
<td colspan="3">'.strtoupper($s[2]).'</td>
<td colspan="3">'.strtoupper($s[3]).'</td>
<td colspan="3" class="center" id="miniaturas"><img src="../include/mini.php?img=../galerias/'.$s[3]."/".$s[4].'&width=180&height=135" width="60" height="45" /></td>
</tr>';
}
echo '</table>';
}
if($_GET["deleta"] == 1) {
$sql = mysql_query("DELETE FROM evento WHERE idevento = '".$_GET["id"]."'");
if($sql) echo 'DELETADO COM SUCESSO!'; else echo 'ERRO, TENTE NOVAMENTE';
}
if($_GET["edita"] == 1) {
$sql = mysql_query("SELECT * FROM evento WHERE idevento = '".$_GET["id"]."'");
$result = mysql_fetch_array($sql);
echo $JSON->encode($result);
}
?>