Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

NetBoy16

[Resolvido] Problema com upload de fotos

Recommended Posts

Eu to tendo um problema com um sistema de uploads de fotos que é usado aqui na empresa onde trabalho, sempre usei nos paineis dos sites que fiz e sempre deu certo, mas dessa vez fiz o mesmo processo de sempre e nao dá dando certo, eu tenho suspeitas que é porque esse servidor tem como novidade ser a nova ver sao 5.3, sendo que os anteriores foram tudo 5.2, fiquei sabendo que no 5.3 varias funcoes ficaram "deprecated", mas vou explicar:

 

O cliente acessa o painel administrativo, cria uma categoria, dai dentro daquela categoeia ele pode inserir fotos, entao ele zipa as fotos e faz upload do arquivo zip, além do upload do zip, as fotos normais vao pra pasta fotos e tb é gerado thumbnail de cada foto que é colocado dentro da pasta thumbs que fica dentro de fotos, oque acontece agora é que cadastra as fotos mas quando vou visualizar é como se a foto nao existisse(sabe aquele quadradinho vazio com um icone no meio), e eu to puto com isso pq sempre deu certo e agora dá dando pau.

 

 

Bom, sem mais delongas vou pro codigo:

 

categorias.php

 

<?php

require 'logar.php';

require 'conn.php';

?>
<!DOCTYPE html>
<html>
   <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <title>Painel de Controle 2012</title>
       <link href="css/estilo.css" rel="stylesheet" type="text/css"/>
   <script language="JavaScript" src="js/jquery-1.2.1.min.js" type="text/javascript"></script>
<script language="JavaScript" src="js/menu-collapsed.js" type="text/javascript"></script>
   </head>
   <body onload="horizontal();">
       <div id="container">
          <?php require ("modulos/topo.php");?>
	    <?php require ("modulos/menulateral.php");?>

           <div id="conteudo">
<?php

$id_categoria = $_GET['id_categoria'];

if($_GET['acao']=='del'){

$sql= "delete from produtos where categoria=".$id_categoria;
$result = mysql_query($sql, $connection) or die (mysql_error());

$sql= "delete from categorias where id_categoria=".$id_categoria;
$result = mysql_query($sql, $connection) or die (mysql_error());


} elseif($_GET['acao']=='up'){


$d=mysql_query("SELECT ordem FROM categorias WHERE id_categoria = $id_categoria");
list($ordem)=mysql_fetch_row($d);

$d=mysql_query("SELECT ordem,id_categoria FROM categorias WHERE ordem < $ordem ORDER BY ordem DESC LIMIT 1");
list($ordem_menor,$id_categoria_menor)=mysql_fetch_row($d);

if ($ordem_menor){
$sql= "update categorias set ordem=$ordem_menor where id_categoria=".$id_categoria;
$result = mysql_query($sql, $connection) or die (mysql_error());


$sql= "update categorias set ordem=$ordem where id_categoria=".$id_categoria_menor;
$result = mysql_query($sql, $connection) or die (mysql_error());
}


} elseif($_GET['acao']=='down'){


$d=mysql_query("SELECT ordem FROM categorias WHERE id_categoria = $id_categoria");
list($ordem)=mysql_fetch_row($d);


$d=mysql_query("SELECT ordem,id_categoria FROM categorias WHERE ordem > $ordem ORDER BY ordem ASC LIMIT 1");
list($ordem_maior,$id_categoria_maior)=mysql_fetch_row($d);


if ($ordem_maior){
$sql= "update categorias set ordem=$ordem_maior where id_categoria=".$id_categoria;
$result = mysql_query($sql, $connection) or die (mysql_error());


$sql= "update categorias set ordem=$ordem where id_categoria=".$id_categoria_maior;
$result = mysql_query($sql, $connection) or die (mysql_error());
}


} elseif ($_GET['acao']=='ativa'){


$sql= "update categorias set tipo='1' where id_categoria=".$id_categoria;
$result = mysql_query($sql, $connection) or die (mysql_error());

} elseif($_GET['acao']=='desaativa'){


$sql= "update categorias set tipo='0' where id_categoria=".$id_categoria;
$result = mysql_query($sql, $connection) or die (mysql_error());

}



?>

<script language="javascript">
 function confirmaExclusao(aURL) {
   if(confirm('Você tem certeza que deseja excluir essa Categoria? Todas as fotos cadastradas para ela também serão excluídas.')) {
     location.href = aURL;
   }
 }
</script>
               <table width="80%" border="0" align="center" cellpadding="3" cellspacing="0">
                 <tr align="center"> 
                   <td colspan="2" class=titulo>CATEGORIAS DE FOTOS</td>
                 </tr>
			  <tr align="center"> 
                   <td colspan="2" class=titulo></td>
                 </tr>
			  <?php
if ($_GET['add']){
?>
			  <tr align="center"> 
                   <td colspan="2" class=sucesso>Nova Categoria Adicionada com Sucesso!</td>
                 </tr>
<?php
}
?>
<?php
if ($_GET['edit']){
?>
			  <tr align="center"> 
                   <td colspan="2" class=sucesso>Categoria Editada com Sucesso!</td>
                 </tr>
<?php
}
?>



               </table>
 <P>
			    <table width="590" border="0" align=center cellpadding="2" cellspacing="1">
				 <tr align="right"> 
                   <td colspan="7" class=titulo><form action=admcat.php><input type=hidden name=action value=new><input type=submit value="Nova Categoria"></form></td>
                 </tr>
                         <tr height="35" bgcolor="f2f2f2">
					  <td  width="100" class=titulo>Data</td>
					  <td  width="380" class=titulo>Categoria</td>
					  <td  width="20" class=titulo></td>
					  <td width="20" height="30" align="center"> </td>
							<td width="20" height="30" align="center"> </td>
						</tr>

                           <?php

$busca = "select id_categoria,categoria,tipo,date_format(data,'%d/%m/%Y') as data from categorias categoria order by  ordem desc";



// total de registros a serem exibidos por página:
$total_reg = "15";
$pagina=$_GET['pagina'];
//se a página não for especificada pagina é igual a 1
if(!$pagina) {
$pc = "1";
} else {
$pc = $pagina;
}

//valor inicial das buscas limitadas.
$inicio = $pc-1;
$inicio = $inicio*$total_reg;

//selecionar os dados
$limite = mysql_query("$busca LIMIT $inicio,$total_reg");
$todos = mysql_query("$busca");

$tr = mysql_num_rows($todos); // verifica o número total de registros
$tp = $tr / $total_reg; // verifica o número total de páginas


/////////////////////////////PAGINAÇÃO

//"Anterior e próximo"
$anterior = $pc -1;
$proximo = $pc +1;

$proximo2 = $proximo - 1;
//visualização



    while ($row=mysql_fetch_array($limite)) {
     $i++;

 $r = $i % 2;
if ($r) {
$cor = "#ffffff";
} else {
$cor = "#f2f2f2";
}

  $id_categoria = $row["id_categoria"];
      $categoria_nome = stripslashes($row["categoria"]);
    $data = $row["data"];
	$tipo = $row["tipo"];


$categoria_nome = ucfirst($categoria_nome);






?>
                          <tr bgcolor="<?=$cor?>"> 
					     <td height="30" width="140" align="left" class=texto><?=$data?> </td>
                             <td height="30" width="340" align="left" class=texto><?=$categoria_nome?> </td>

							<td width="20" height="30" align="center"><a class=links href="edit_cat.php?id_categoria=<?=$id_categoria?>"><IMG SRC="images/edit.gif" WIDTH="16" HEIGHT="16" BORDER="0" ALT=""></a></td>
							<td width="20" height="30" align="center"><a href="javascript:confirmaExclusao('categorias.php?acao=del&pagina=<?=$pagina?>&id_categoria=<?=$id_categoria?>')"><IMG SRC="images/delete.gif" WIDTH="16" HEIGHT="16" BORDER="0" ALT=""></a></td>

<td width="20" align=center> <?php		
							if ($tipo=='1'){

echo "<a href='categorias.php?acao=desaativa&pagina=$pagina&id_categoria=$id_categoria'><IMG SRC='images/destaque.gif' WIDTH='16' HEIGHT='16' BORDER='0' ALT='Destaque'></a>";

} else {

echo "<a href='categorias.php?acao=ativa&pagina=$pagina&id_categoria=$id_categoria'><IMG SRC='images/destaque2.gif' WIDTH='16' HEIGHT='16' BORDER='0' ALT='Destaque'></a>";

}
?>
</td>

                           </tr>

						  <?php
  }
			  ?>
						 </table>


						 <table width="400" border="0" align=center cellpadding="2" cellspacing="1">



			  <?php

echo "<tr height=20><td></td></tr><tr><td colspan=2 class=texto>";

if($pc>1) {
echo "<a href='?pagina=$anterior&order=".$order."' class=links2><IMG SRC=images/voltar.gif BORDER=0 align=absmiddle> Anterior</a></td>";
}
echo "";
if($pc<$tp) {
echo "</td><td colspan=2 align=right class=texto><a href='?pagina=$proximo&order=".$order."' class=links2>Próxima <IMG SRC=images/proxima.gif BORDER=0 align=absmiddle></a></td></tr>";
}


?>



					     <tr align="center"> 
                   <td colspan="2" class=titulo> <BR></td>
                 </tr>

					  </table>


 </div>
       </div>
   </body>
</html>

 

 

admcat.php

 

<?php

require 'logar.php';
require 'header.php';

require 'conn.php';

$sql = "select * from categorias order by categoria";
$sql_result = mysql_query($sql, $connection) or die ("Não foi possível selecionar as categorias");

switch($_GET['action'])
{
case 'new':


?>
<script language="javascript">  

function somente_valor(campo){  
var digits="0123456789/"  
var campo_temp   
    for (var i=0;i<campo.value.length;i++){  
        campo_temp=campo.value.substring(i,i+1)   
        if (digits.indexOf(campo_temp)==-1){  
            campo.value = campo.value.substring(0,i);  
        }  
    }  
}  

</script>
<form name="form1" method="post" action="add_cat.php">
               <table width="450" border="0" align="center" cellpadding="3" cellspacing="0">
                 <tr align="center"> 
                   <td colspan="2" class=titulo>CADASTRAR NOVAS CATEGORIAS</td>
                 </tr>
                 <tr> 
                   <td width="20%"> </td>
                   <td width="80%"> </td>
                 </tr>
			    <tr> 
                   <td class=texto>Data:</td>
                   <td class=pequeno><input type=text name=data size=12 maxlength=10 onKeyUp="javascript:somente_valor(this);"> dd/mm/aaaa <A HREF="#"
  onClick="cal.select(document.forms['form1'].data,'anchor1','dd/MM/yyyy'); return false;"
  NAME="anchor1" ID="anchor1"><img src=images/calendar.gif border=0></a></td>
                 </tr>
                 <tr> 
                   <td class=texto>Categoria:</td>
                   <td><input name="categoria" type="text" size="50" maxlength=30 ></td>
                 </tr>				

               <tr> 
                   <td> </td>
                   <td> </td>
                 </tr>
                 <tr align="center"> 
                   <td colspan="2"> 
                     <input type="submit" value="Cadastrar">
                   </td>
                 </tr>
               </table>
             </form>


<?php
break;
case 'edit':

?>
<form name="form1" method="post" action="edit_cat2.php">
               <table width="50%" border="0" align="center" cellpadding="3" cellspacing="0">
                 <tr align="center"> 
                   <td colspan="2" class=titulo>EDITAR CATEGORIAS EXISTENTES</td>
                 </tr>
                 <tr> 
                   <td width="37%"> </td>
                   <td width="63%"> </td>
                 </tr>
                 <tr align="center"> 
                   <td colspan="2" class=pequeno>selecione a categoria que deseja alterar</td>
                 </tr>
                 <tr align="center"> 

                   <td class=texto colspan=2>Categorias: <select name="id_categoria">
                       <option value="0">selecione aqui</option>

<?php
  while ($row=mysql_fetch_array($sql_result)) {
      $id_categoria = $row["id_categoria"];
      $categoria = $row["categoria"];

   $categoria = ucfirst($categoria);

      echo "<option value =\"$id_categoria\">$categoria</option>";
                                }
           ?>

                     </select></td>
                 </tr>
                 <tr align="center"> 
                   <td colspan="2"> </td>
                 </tr>
                 <tr align="center"> 
                   <td colspan="2"><input type="submit" value="Selecionar"></td>
                 </tr>
               </table>
             </form>

<?php
break;
case 'del':

?>
<form name="form1" method="post" action="del_cat.php">
               <table width="60%" border="0" align="center" cellpadding="3" cellspacing="0">
                 <tr align="center"> 
                   <td colspan="2" class=titulo>EXCLUIR CATEGORIAS EXISTENTES</td>
                 </tr>
                 <tr> 
                   <td colspan=2> </td>
                 </tr>
			  <tr> 
                   <td colspan=2><font color=red><b>Atenção!!!</b></font> Ao excluir uma categoria, todos os produtos pertencentes a ela também serão excluídos.</td>
                </tr>
			   <tr> 
                   <td colspan=2> </td>
                 </tr>
                 <tr align="center"> 
                   <td colspan="2" class=pequeno>selecione a categoria que deseja excluir</td>
                 </tr>
			  <tr> 
                   <td colspan=2> </td>
                 </tr>
                 <tr align="center"> 

                   <td class=texto colspan=2>Categoria: <select name="id_categoria">
                       <option value="0">selecione aqui</option>

<?php
  while ($row=mysql_fetch_array($sql_result)) {
 $id_categoria = $row["id_categoria"];
      $categoria = $row["categoria"];

   $categoria = ucfirst($categoria);

      echo "<option value =\"$id_categoria\">$categoria</option>";
                                }
           ?>

                     </select></td>
                 </tr>
                 <tr align="center"> 
                   <td colspan="2"> </td>
                 </tr>
                 <tr align="center"> 
                   <td colspan="2"><input type="submit" value="Selecionar"></td>
                 </tr>
               </table>
             </form>


<?php
}

?>
<?php
require 'bottom.php';
?>

 

 

add_fotos.php

 

<?php
if ($_POST['categoria']=='0'){

header("location: admfotos.php");
exit();
}

require 'logar.php';
require 'conn.php';
require 'hft_image.php';
require_once 'functions.php';

$categoria = mysql_real_escape_string($_POST['categoria']);

function cropImagem($nw, $nh, $source, $stype, $dest) {

   $size = getimagesize($source);
   $w = $size[0];
   $h = $size[1];

   switch($stype) {
       case 'gif':
       $simg = imagecreatefromgif($source);
       break;
       case 'jpg':
       $simg = imagecreatefromjpeg($source);
       break;
       case 'png':
       $simg = imagecreatefrompng($source);
       break;
   }

   $dimg = imagecreatetruecolor($nw, $nh);

   $wm = $w/$nw;
   $hm = $h/$nh;

   $h_height = $nh/2;
   $w_height = $nw/2;

   if($w> $h) {

       $adjusted_width = $w / $hm;
       $half_width = $adjusted_width / 2;
       $int_width = $half_width - $w_height;

       imagecopyresampled($dimg,$simg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h);

   } elseif(($w <$h) || ($w == $h)) {

       $adjusted_height = $h / $wm;
       $half_height = $adjusted_height / 2;
       $int_height = $half_height - $h_height;

       imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$adjusted_height,$w,$h);

   } else {
       imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h);
   }

   imagejpeg($dimg,$dest,100);
}




////////////////////////////////////////////////////////////////// UPLOAD DO ZIP ///////////////////////

if ($_FILES['arquivo']['size']!=0){//foto1 está vazia?

if (($_FILES['arquivo']['type']!='application/x-zip-compressed')&&($_FILES['arquivo']['type']!='application/octet-stream')&&($_FILES['arquivo']['type']!='application/zip'))  {
$erro = "<center>O arquivo enviado não é válido!<p><a href=javascript:history.go(-1); class=links>voltar</a></center>";
echo "Mimetype: ".$_FILES['arquivo']['type'];
echo $erro;
exit();
}

if  ($_FILES['arquivo']['size'] > 20000000) {

$erro = "<center>O tamanho do arquivo excedeu 20Mb</center>";
echo $erro;
exit();
}

//copia a imagem
$chave = rand(0,9999999);
$foto_name =  ".zip";

  $uploaddir = "../fotos/zip/"; // diretorio onde vai ficar a foto
  $uploadfrom = $_FILES["arquivo"]["tmp_name"];
  $uploaddir .= $chave.$foto_name;  

 move_uploaded_file($uploadfrom, $uploaddir);

  $arquivo = $uploaddir;
}

//////////////////////// UPLOAD DO ZIP ////////////////////////////////////////////////////////////////////////////////////


function unzip($zip,$categoria,$connection)
{
//pegando o caminho completo do arquivo zip
$caminho = dirname($zip);

//abrindo o arquivo zip
$zip = zip_open($zip);
//lendo todo o conteudo do arquivo zip
while(($elemento = zip_read($zip)) != false)
{
	//pegando o nome do arquivo/diretorio em questao
	$nome = zip_entry_name($elemento);
	//descartando os diretorios "." e ".."
	if($nome != '.' && $nome != '..')
	{
		//verificando o tamanho total do elemento
		if(zip_entry_filesize($elemento))
		{
			//se possui tamanho, entao nao eh uma pasta, logo, devemos
			//criar um arquivo com o mesmo nome
			$arquivo = fopen("../fotos/zip/".$nome, 'wb');
			//escrevendo todo o conteudo do elemento para o arquivo que
			//acabamos de criar
			fwrite($arquivo, zip_entry_read($elemento, zip_entry_filesize($elemento)));



////////////// TRATA AS FOTOS DO ZIP
$folder = "../fotos/";
$original_image    =    "../fotos/zip/".$nome; 


$chave = rand(0,9999);
$foto_name =  $last_id.".jpg";
$imagem1 = $chave.$foto_name;


$imagem_orig = ImageCreateFromJPEG($original_image);

$largura = ImagesX($imagem_orig);
$altura = ImagesY($imagem_orig);

if (($largura>640)or($altura>480)){


if ($largura > $altura){
   $destination_width    =    640; 
   $destination_height    =   450; 
} else {
$destination_width    =    400; 
   $destination_height    =   580; 
}


} else {

   $destination_width    =    $largura; 
   $destination_height    =   $altura; 

}


   $image    =    new hft_image($original_image);
   $image->resize($destination_width, $destination_height, '-'); 
   $new_file1 = $folder.$imagem1; 
   $image->output_resized($new_file1, "JPEG"); 



if ($largura > $altura){

//GERAR THUMBNAIL
$image2    =    new hft_image($original_image);
$image2->resize("100", "74", '0'); 
   $new_file2 = $folder."/thumbs/t".$imagem1; 
   $image2->output_resized($new_file2, "JPEG"); 

} else {

//cropImage(135, 101, $folder.$imagem1, 'jpg',$folder."/thumbs/t".$imagem1);





cropImagem(100, 74, $folder.$imagem1, 'jpg', $folder."/thumbs/t".$imagem1);





}


//////////////////////////////////////////// MARCA DAGUA ////////////////////////////////////////
$arquivo1 = $new_file1;

$watermark = imagecreatefrompng('marca_dagua.png');  
imageAlphaBlending($watermark, false);
   imageSaveAlpha($watermark, true);
$watermark_width = imagesx($watermark);  
$watermark_height = imagesy($watermark);  
$image = imagecreatetruecolor($watermark_width, $watermark_height);  
$image = imagecreatefromjpeg($arquivo1);  
$size = getimagesize($arquivo1);  
$dest_x = $size[0] - $watermark_width - 10;  
$dest_y = $size[1] - $watermark_height - 10;  
imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);  
imagejpeg($image,$new_file1,100);  
imagedestroy($image);  
imagedestroy($watermark);

//////////////////////////////////////// FIM DE MARCA DAGUA/////////////////////////////////////


$sql= "insert into produtos (foto, categoria) values ('$imagem1', $categoria)";

mysql_query($sql, $connection) or die (mysql_error());


////////////// FIM DO TRATAMENTO DAS FOTOS DO ZIP /////////////////////////////////////////////////////////////////////////////


			//fechando o arquivo que criamos
			fclose($arquivo);
			//voltando para o while

unlink("../fotos/zip/".$nome);

			continue;
		}
		//se a pasta nao existir, cria
		if(!file_exists($caminho . '/' . $nome))
		{
			mkdir($caminho . '/' . $nome);
		}
	}
}
return 0;
}

unzip($arquivo,$categoria,$connection);

unlink($arquivo);



echo "<script language='javaScript'>window.location.href='fotos_mostra.php?add=1&id_categoria=$categoria'</script>";

?>

 <table width="80%" border="0" align="center" cellpadding="3" cellspacing="0">
                 <tr align="center"> 
                   <td colspan="2" class=titulo>FOTOS CADASTRADAS</td>
                 </tr>
                 <tr> 
                   <td width="25%"> </td>
                   <td width="75%"> </td>
                 </tr>


			     <tr> 
                   <td> </td>
                   <td> </td>
                 </tr>
                 </table>


<?php

require 'bottom.php';
?>

 

fotos_mostra.php

 

<?php
require 'logar.php';

require 'conn.php';

?>
<!DOCTYPE html>
<html>
   <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <title>Painel de Controle 2012</title>
       <link href="css/estilo.css" rel="stylesheet" type="text/css"/>
   <script language="JavaScript" src="js/jquery-1.2.1.min.js" type="text/javascript"></script>
<script language="JavaScript" src="js/menu-collapsed.js" type="text/javascript"></script>
   </head>
   <body onload="horizontal();">
       <div id="container">
          <?php require ("modulos/topo.php");?>
	    <?php require ("modulos/menulateral.php");?>

           <div id="conteudo">
		<?php

$categoria = $_REQUEST['id_categoria'];

if ($categoria==''){

$sql = "select id_categoria from categorias where id_categoria > 1 order by id_categoria desc limit 1";
$sql_result = mysql_query($sql, $connection) or die ("Não foi possível selecionar as categorias");


  while ($row=mysql_fetch_array($sql_result)) {

      $categoria = $row["id_categoria"];

  }

} 

$id_produto=$_GET['id_produto'];

if ($_GET['acao']=='del'){



$sql= "delete from produtos where id_produto =".$id_produto;
$result = mysql_query($sql, $connection);

}  elseif ($_GET['acao']=='ativa'){


$sql= "update produtos set tipo='1' where id_produto=".$id_produto;
$result = mysql_query($sql, $connection) or die (mysql_error());

} elseif($_GET['acao']=='desaativa'){


$sql= "update produtos set tipo='0' where id_produto=".$id_produto;
$result = mysql_query($sql, $connection) or die (mysql_error());

}  elseif ($_GET['acao']=='ativa2'){


$sql= "update produtos set tipo2='1' where id_produto=".$id_produto;
$result = mysql_query($sql, $connection) or die (mysql_error());

$sql= "update produtos set tipo2='0' where categoria=$categoria and id_produto!=".$id_produto;
$result = mysql_query($sql, $connection) or die (mysql_error());


} elseif($_GET['acao']=='desaativa2'){


$sql= "update produtos set tipo2='0' where id_produto=".$id_produto;
$result = mysql_query($sql, $connection) or die (mysql_error());

}

?>
<script language="javascript">
 function confirmaExclusao(aURL) {
   if(confirm('Você tem certeza que deseja excluir essa Foto?')) {
     location.href = aURL;
   }
 }
</script>
               <table width="80%" border="0" align="center" cellpadding="3" cellspacing="0">
                 <tr align="center"> 
                   <td colspan="2" class=titulo>FOTOS</td>
                 </tr>

			  <tr align="center"> 
                   <td colspan="2" class=titulo></td>
                 </tr>
<?php
if ($_GET['add']){
?>
			  <tr align="center"> 
                   <td colspan="2" class=sucesso>Foto Cadastrada com Sucesso!</td>
                 </tr>
<?php
}
?>
			  <tr align="center"> 
                   <td colspan="2" class=titulo></td>
                 </tr>


               </table>
 <P>
			    <table width="85%" border="0" align=center cellpadding="2" cellspacing="1">
                           <tr align="center"> 
                   <td colspan="2" class=texto></td>
                 </tr>
			  <tr align="left"> 
                   <td class=titulo>


			<form method="get" action="<?php echo $id; ?>">
Categorias:  <select name="id_categoria" style="width:250px">
<?php

 $sql = "select id_categoria,categoria from categorias categoria order by id_categoria desc limit 12";
$sql_result = mysql_query($sql, $connection) or die ("Não foi possível selecionar as categorias");


  while ($row=mysql_fetch_array($sql_result)) {
      $id = $row["id_categoria"];
      $categoria_nome = $row["categoria"];

$categoria_nome = ucfirst($categoria_nome);


if ($id==$categoria){

echo "<option value =\"$id\" selected>$categoria_nome</option>";

} else {

echo "<option value =\"$id\">$categoria_nome</option>";

}


  }
			  ?>



					   </select>

 <input type="submit" value="Ver" >
</form>
		</td><td align=right><form action=admfotos.php><input type=hidden name=action value=new><input type=hidden name='id_categoria' value='<?=$categoria?>'><input type=submit value="Novas Fotos"></form>		

				</td>
                 </tr>
					     <tr align="center"> 
                   <td colspan="2" class=titulo> <BR></td>
                 </tr>

					  </table>




					  <?php

require 'hft_image.php';

//ini_set(safe_mode,Off);

$pagina = $_GET['pagina'];
$busca = "select * from produtos where categoria = $categoria order by id_produto desc";

// total de registros a serem exibidos por página:
$total_reg = "24";

//se a página não for especificada pagina é igual a 1
if(!$pagina) {
$pc = "1";
} else {
$pc = $pagina;
}

//valor inicial das buscas limitadas.
$inicio = $pc-1;
$inicio = $inicio*$total_reg;



//selecionar os dados
$limite = mysql_query("$busca LIMIT $inicio,$total_reg");
$todos = mysql_query("$busca");

$tr = mysql_num_rows($todos); // verifica o número total de registros
$tp = $tr / $total_reg; // verifica o número total de páginas



//"Anterior e próximo"
$anterior = $pc -1;
$proximo = $pc +1;

$proximo2 = $proximo - 1;
//visualização



echo "<table width=85% border=0 align=center>";
?>


			    <tr align="left"> 
                   <td colspan="2" class=detalhe><i>Encontradas <?=$tr?> fotos para esta categoria</i></td>
                 </tr>
				<tr align="left"> 
                   <td colspan="2" class=titulo> <BR></td>
                 </tr>
<?
$folder="../fotos/";
$total = mysql_num_rows($limite);

$colunas = "4";

if ($total>0) {
   for ($i = 0; $i < $total; $i++) {
       if (($i%$colunas)==0) {

       echo "<tr align=center>";
   }
$dados = mysql_fetch_array($limite);
   $titulo = $dados["nome"];
$foto = $dados["foto"];
$id_produto = $dados["id_produto"];
$tipo = $dados["tipo"];
$tipo2 = $dados["tipo2"];


$new_file = $folder."thumbs/t".$foto; 

   echo "<td width='205' height='140' valign=center class=style2>

<table width='100%' border='0' cellpadding='0' cellspacing='0'>

                         <tr>
                           <td align=center height='93'>   <a href='../fotos/$foto' rel='lightbox' title='$titulo'><img src='$new_file' class=borda></a></td>
                         </tr>

						    <tr> 
                           <td  align='center' valign='middle' class=style3>";

							if ($tipo=='1'){

echo "<a href='fotos_mostra.php?acao=desaativa&pagina=$pagina&id_produto=$id_produto&id_categoria=$categoria'> <IMG SRC='images/destaque.gif' WIDTH='16' HEIGHT='16' BORDER='0' ALT='Destaque'></a>     ";

} else {

echo "<a href='fotos_mostra.php?acao=ativa&pagina=$pagina&id_produto=$id_produto&id_categoria=$categoria'> <IMG SRC='images/destaque2.gif' WIDTH='16' HEIGHT='16' BORDER='0' ALT='Destaque'></a>     ";

}


if ($tipo2=='1'){

echo "<a href='fotos_mostra.php?acao=desaativa2&pagina=$pagina&id_produto=$id_produto&id_categoria=$categoria'> <IMG SRC='images/star.gif' WIDTH='16' HEIGHT='16' BORDER='0' ALT='Destaque'></a>     ";

} else {

echo "<a href='fotos_mostra.php?acao=ativa2&pagina=$pagina&id_produto=$id_produto&id_categoria=$categoria'> <IMG SRC='images/star2.gif' WIDTH='16' HEIGHT='16' BORDER='0' ALT='Destaque'></a>     ";

}
							echo "<a class=links href='edit_produtos.php?id_produto=$id_produto'><IMG SRC='images/edit.gif' WIDTH='16' HEIGHT='16' BORDER='0'></a>     <a href=\"javascript:confirmaExclusao('fotos_mostra.php?acao=del&pagina=$pagina&id_produto=$id_produto&id_categoria=$categoria')\"><IMG SRC='images/delete.gif' WIDTH='16' HEIGHT='16' BORDER='0'></a></td>
                         </tr>
                       </table>


</td>";
}

} 
echo "</tr>";
echo "</table>";
?>

		 	<table width="93%" border="0" align="center" cellpadding="2" cellspacing="1">

				<?php



echo "<tr><td colspan=5 class=style2>";

if($pc>1) {
echo "<a href='?pagina=$anterior&id_categoria=".$categoria."' class=links3><IMG SRC=images/voltar.gif BORDER=0 align=absmiddle> Anterior</a></td>";
}
echo "";
if($pc<$tp) {
echo "</td><td colspan=2 align=right class=style2><a href='?pagina=$proximo&id_categoria=".$categoria."' class=links3>Próxima <IMG SRC=images/proxima.gif BORDER=0 align=absmiddle></a></td></tr>";
}




?>




           </table> 

           </div>
       </div>
   </body>
</html>

 

 

 

Mas entao, eu acredito que seja por causa de ser o novo php 5.3, tavez alguma funcao desse codigo esteja deprecated ou tenha mudado, sei lá, tb sei que o codigo é enooorme, mas preciso muito de ajuda e se alguem puder me ajudar eu dou 1 milhao...kkkkk, zueira :P , mas se alguem puder me ajudar eu ficarei muito grato, muito mesmo.

 

 

Obrigado desde já.

Compartilhar este post


Link para o post
Compartilhar em outros sites

você leu todo o topic? pq eu expliquei laaaá no começo :)

Compartilhar este post


Link para o post
Compartilhar em outros sites

ler eu li, por isso eu disse pra postar o q de fato o q esta acontecendo, o q você realmente nao fez, a unica coisa q você informou foi q nao esta aprecendo a foto quando ela deveria ser mostrada, isto acontece pq você deve estar puxando a imagem de um lugar e upando ela pra outro...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ja foi resolvido, vlw mesmo assim :thumbsup:

 

Se a moderacao quiser marcar como resolvido pode proseguir ^_^

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.