Jump to content
Fórum Script Brasil
  • 0

Sistema De Fotos


Beraldo
 Share

Question

Script postado por: dmetallica

Sistema de Fotos

Galera criei um sistema de fotos...

Com :

»upload

»visualização 1

»visualização 2

aqui vai os fontes...

SQL... Base de dados

#
#banco: fotos
#

DROP TABLE IF EXISTS tabela_foto;
CREATE TABLE tabela_foto (
  file varchar(100) default '0',
  comentario varchar(250) default '0',
  titulo varchar(50) default '0'
) TYPE=MyISAM;


upload.php
/*************************************************
*  Nome: Diego Pacheco                                                     
*  Nick_Name:Dmetallica                                                    
*  Idade: 19                                                                      
*  Programo: VB,PHP,DELPHI,SQL,ACCESS,JS,PASCAL         
*  ICQ: 122464657
*  MSN: [email protected]
*  Uma_frase:"Morro de pé mas não vivo de juelhos"           
*  » TE AMO BRUNA  (Minha namorada!) «                         
*                                                                                     
*************************************************/

<style>
A{
  text-decoration: none
  size: 4;
  color:blue;
 }

A:hover
{
font-weight: bold;
font-size: 18;
text-decoration: Underline;
color:red;
}
</style>

<script language='javascript'>

function valida()
  {
    if (document.form1.titulo.value=="")
      {
       window.alert("Preencha o campo Titulo!");
       document.form1.titulo.focus();
      }

     if (document.form1.comentario.value=="")
      {
       window.alert("Preencha o campo Comentario!");
       document.form1.comentario.focus();
      }

     if (document.form1.file.value=="")
      {
       window.alert("Escolha uma foto no seu PC!");
       document.form1.file.focus();
      }


  }

</script>

<?php


//-----------------------------------------------
$conexao=mysql_connect("localhost","root",""); //
mysql_select_db("fotos",$conexao);             //
//-----------------------------------------------

echo "<center> <b><font color='orange' size='7'>Sistema de Fotos </font> </b>";

if ($enviar!="")
 {
   copy($file,"C:\Arquivos de programas\EasyPHP\www\Meus Php\SistemaFotos\/".$file_name);//$diretorio  é o nome da pasta onde os arquivos vão ficar apos o upload!
   unlink($file);
   $msg="<center><font face=verdana, Helvetica, sans-serif size=4><font color=blue><b>Seus Arquivos Foram Enviados Corretamente!";

   $sql="insert into tabela_foto (file,comentario,titulo) values('$file_name','$comentario','$titulo')";
   $query=mysql_query($sql,$conexao) or die("Erro ao Gravar dados!");

 }

echo "<form name='form1' action='upload.php' method='post' ENCTYPE='multipart/form-data'>";

echo "<table border='1' bgcolor='wheat' bgcolor='wheat' style='FILTER: alpha(opacity=70);'>";
     echo "<tr>";
          echo "<td>";
               echo "Foto :";
          echo "</td>";
          echo "<td>";
               echo "<input type='file' size='20' name='file'>";
          echo "</td>";
     echo "</tr>";
     echo "<tr>";
          echo "<td>";
               echo "Titulo :";
          echo "</td>";
          echo "<td>";
               echo "<input type='text' size='20' name='titulo' value='$titulo'>";
          echo "</td>";
     echo "</tr>";
     echo "<tr>";
          echo "<td>";
               echo "Comentario :";
          echo "</td>";
          echo "<td>";
               echo "<input type='text' size='20' name='comentario' value='$comentario'>";
          echo "</td>";
     echo "</tr>";
     echo "<tr>";
          echo "<td colspan='2' align='center'>";
               echo "<input type='hidden' name='MAX_FILE_SIZE' value='100000'>";
               echo "<input type='submit' name='enviar' value='Fazer Upload Agora!' onMouseup='valida();'>";
          echo "</td>";
     echo "</tr>";
echo "</table>";

echo "</form>";

echo "<br>";

echo $msg;

echo "<br>";

if ($enviar!="")
 {
    echo "</font><font color='orange'> Arquivo Enviado: ";
    echo "</font><font color='bronze'>".$file_name;
 }

echo "<br>";
echo "<br>";
echo "<a href='visualiza.php?pagina=1'>Visualizar Fotos!</a>";

?>  

ver_perto.php
/*************************************************
*  Nome: Diego Pacheco                                                     
*  Nick_Name:Dmetallica                                                    
*  Idade: 19                                                                      
*  Programo: VB,PHP,DELPHI,SQL,ACCESS,JS,PASCAL         
*  ICQ: 122464657
*  MSN: [email protected]
*  Uma_frase:"Morro de pé mas não vivo de juelhos"           
*  » TE AMO BRUNA  (Minha namorada!) «                         
*                                                                                     
*************************************************/

<style>
A{
  text-decoration: none
  size: 4;
  color:blue;
 }

A:hover
{
font-weight: bold;
font-size: 18;
text-decoration: Underline;
color:red;
}
</style>

<?

echo "<body alink='blue' vlink='blue'>";

echo "<center> <b><font color='orange' size='7'>Sistema de Fotos </font> </b>";

echo "<form action='ver_perto.php' method='post' ENCTYPE='multipart/form-data'>";

$host = "localhost";
$user = "root";
$pass = "";
$db_nome = "fotos";
$link = mysql_connect ($host, $user, $pass); 
$query = "SELECT * from tabela_foto where file='$file'";
$result = mysql_db_query ($db_nome, $query, $link) or die ("Conexão falhou!");
$num = mysql_num_rows($result);
while ($array_result = mysql_fetch_array($result))
  {
    $A=$array_result["file"];
    $B=$array_result["titulo"];
    $C=$array_result["comentario"];
  }

mysql_close($link); 

echo "<b>Titulo da Imagem: </b> <font color='green'>".$B."</font>";
echo "<br>";
echo "<br>";

echo "<table border='3' bordercolor='burlywood' bgcolor='wheat' width='15%'>";
  echo "<tr>";
   echo "<td>";
     echo "<a href='$A'><img src='$A' alt='$B' border='1' width='300' heigth='300'></a>";
   echo "</td>";
  echo "</tr>";
echo "</table>";

echo "<br>";
echo "<b>Comentario da Imagem: </b> <font size='3' color='gray'>".$C."</font>";

echo "<br>";
echo "<br>";
echo "<a href='visualiza.php?pagina=1'>Visualização de Fotos!</a>";

echo "</form>";
echo "</body>";
echo "</html>";


visualiza.php
/*************************************************
*  Nome: Diego Pacheco                                                     
*  Nick_Name:Dmetallica                                                    
*  Idade: 19                                                                      
*  Programo: VB,PHP,DELPHI,SQL,ACCESS,JS,PASCAL         
*  ICQ: 122464657
*  MSN: [email protected]
*  Uma_frase:"Morro de pé mas não vivo de juelhos"           
*  » TE AMO BRUNA  (Minha namorada!) «                         
*                                                                                     
*************************************************/

<style>
A{
  text-decoration: none
  size: 4;
  color:blue;
 }

A:hover
{
font-weight: bold;
font-size: 18;
text-decoration: Underline;
color:red;
}

img {A:hover, A:active {color: #00cc00 }} 
A:hover img, A:active img {FILTER: "Gray";border:0px; border-thickness: 0px; border-color: #ffcc00; border-style: solid}
.style {font-family: "Courier New", Courier, mono}

</style>

<?

echo "<body alink='blue' vlink='blue'>";

echo "<center> <b><font color='orange' size='7'>Sistema de Fotos </font> </b>";

echo "<form action='visualiza.php' method='post' ENCTYPE='multipart/form-data'>";

$host = "localhost";
$user = "root";
$pass = "";
$db_nome = "fotos";
$link = mysql_connect ($host, $user, $pass); 
$query = "SELECT * from tabela_foto";
$result = mysql_db_query ($db_nome, $query, $link) or die ("Conexão falhou!"); 

$num = mysql_num_rows($result);
$total_reg = 9; //total de fotos por pagina.

mysql_close($link); 

if ($num <= $total_reg) { 
    $total_paginas = 1; 
} 

if ($num%$total_reg == 0) { 
    $total_paginas = $num / $total_reg; 
} 
else {
    $total_paginas = ($num/$total_reg) - (($num%$total_reg)/$total_reg) + 1;
} 

$linha_inicial = ($pagina - 1) * $total_reg; 
$linha_final = $linha_inicial + $total_reg - 1; 

//----------------- DADOS DAS PAGINAS ------------------------------------------
echo "<center> Arquivo tem <b><font color='green'>".$num."</font></b> Fotos <br>";
echo "Página <b><font color='orange'>".$pagina."</b></font> de <b><font color='orange'>".$total_paginas."</b></font></center><br>";
//------------------------------------------------------------------------------

$marcador = 0; 

echo "<table border='3' bordercolor='burlywood' bgcolor='wheat' width='15%'>";

while ($array_result = mysql_fetch_array($result)) { 

    if ($marcador >= $linha_inicial and $marcador <= $linha_final) { 
        //aqui você personaliza sua saída...            

    $A=$array_result["file"];
    $B=$array_result["titulo"];

     if (($cont==3) OR ($cont==6) OR ($cont==9) OR ($cont==12) )
       {
         echo "<tr>";
         echo "<td align='center'>";
         echo "<a href='ver_perto.php?file=$A'><img src='$A' alt='$B' border='1' width='100' heigth='100'></a>";
         echo "</td>";
       }
     else
      {
        echo "<td align='center'>";
        echo "<a href='ver_perto.php?file=$A'><img src='$A'  alt='$B' border='1' width='100' heigth='100'></a>";
        echo "</td>";
      }

     $cont=$cont+1;

     if (($cont==3) OR ($cont==6) OR ($cont==9) OR ($cont==12) )
      {
        echo "</tr>";
      }

}

//------------------------------------------------------------------------------

$marcador = $marcador + 1;

}



echo "</table>";
echo "<BR>";

if ($pagina == 1) {
    echo "<font color=\"#999999\"><< anterior</font> |"; 
} 

else { 
    echo "<< <a href=\"visualiza.php?pagina=".($pagina - 1)."\" targe=\"_self\">anterior</a> |";
} 

$i = 1; 
while ($i <= $total_paginas) { 

    if ($i == $pagina) { 
        echo " <font size='4'><b><u>$i</u></b></font> ";
    } 

    else { 
        echo " <a href=\"visualiza.php?pagina=".$i."\" target=\"_self\">".$i."</a> ";
    } 
    $i = $i + 1; 
} 


if ($pagina == $total_paginas) { 
    echo "| <font color=\"#999999\">próxima >></font>\n"; 
} 

else { 
    echo "| <a href=\"visualiza.php?pagina=".($pagina + 1)."\" targe=\"_self\">próxima</a> >>\n";
}

echo "</from>";

echo "<br>";
echo "<br>";
echo "<a href='upload.php'>Upload de Fotos!</a>";

?>  

OBS: em upload.php

copy($file,"C:\Arquivos de programas\EasyPHP\www\Meus Php\SistemaFotos\/".$file_name);

mude odiretorio ondi vão as fotos!

é isso ai fallou... :)

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
Guest Visitante

tambem to precisando com upload via http... alguém ajuda ai nesse codigo??

e mais uma duvida.. o nome do banco q eu crio se chama ''fotos'' ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      151k
    • Total Posts
      649.1k
×
×
  • Create New...