Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Gente se puderem me ajudar
quero criar uma miniatura e usala depois, pq a imagem toda fika feia
segue o arkivo do album.php e depois do upload.php [ o upload de imagens do album eh feito no próprio album.php o upload serve pro perfil mais naum estou conseguindo utilizar o sistema do perfil [ upload.php ] no album pois no perfil pego a imagem por ID da sessão e no album pego por uniqueid, se puderem me ajudar agradeçeria ]
Album.php
>
<? // all the basic stuff
require("../include/pre.php"); // all the basic stuff
//require("localSettings.php");
require("../include/connect.php");
function delete_file($name)
{
if (file_exists($name))
unlink($name);
}
if ($_GET['op'] == '3') { delete_file($imagem); header('Location:album.php?id='. $_GET['id'] .'&refresh='. uniqid("")); $del = mysql_query("DELETE FROM `fotos` WHERE `Id`=" . $_GET['idf'] . "");}
if ($_GET['send']=='1')
{
//session_start();
$filename = "../upload2/" . uniqid("").".jpg";
$ext = strrchr($HTTP_POST_FILES["file"]["name"], '.');
move_uploaded_file($HTTP_POST_FILES["file"]["tmp_name"], $filename);
$rs= mysql_query("INSERT INTO fotos(`user`, `imagem`, `comentario`) values('" . $_GET['id'] ."','$filename','" . $_POST['comentario'] . "')",$db);
header('Location:album.php?id='. $_GET['id'] .'&refresh='. uniqid(""));
if($ext=='.jpg' && filesize($filename)<2300832)
$img = @imagecreatefromjpeg($filename);
else
{
delete_file($filename);
header('Location: album.php?id='. $_GET['id'] .'&error=Só extensão .jpg com menos de 300kb&refresh='. uniqid(""));
die();
}
if (strlen($_GET['cm'])>0)
{
delete_file('c_'. uniqid("").'.jpg');
delete_file('c_'. uniqid("").'_m.jpg');
}
else
{
delete_file(uniqid("").'.jpg');
delete_file(uniqid("").'_m.jpg');
}
$size = getimagesize($filename);
$width= $size[0];
$height= $size[1];
if ($width>128)
{
$percentage = 128 / $width;
$width *= $percentage;
$height *= $percentage;
$img_r = imagecreatetruecolor ($width, $height);
imagecopyresampled($img_r, $img, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
}
else
{
$img_r = $img;
}
if ($width>64)
{
$percentage = 64 / $width;
$width *= $percentage;
$height *= $percentage;
}
$img_sm = imagecreatetruecolor($width, $height);
imagecopyresampled($img_sm, $img, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
if (strlen($_GET['cm'])>0)
{
ImageJpeg($img_r, "../upload2/" . uniqid("").".jpg", 100);
ImageJpeg($img_sm, "../upload2/" . uniqid("")."_m.jpg", 100);
}
else
{
ImageJpeg($img_r, "../upload2/" . uniqid("").".jpg", 100);
ImageJpeg($img_sm, "../upload2/" . uniqid("")."_m.jpg", 100);
}
die();
}
draw_top($topic_message); //starts drawing the page
?>
<style>
<!--
/*Post-it note script- by javascriptkit.com
Visit JavaScript Kit (http://javascriptkit.com) for script
Credit must stay intact for use*/
#postit{
position:absolute;
width:465px;
padding:5px;
border:0px solid black;
visibility:hidden;
z-index:100;
cursor:hand;
height: 139px;
}
.unnamed1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
}
.style4 {
font-size: 16px;
font-weight: bold;
color: #CCCCCC;
}
.style6 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #999999; }
.style8 {color: #999999}
.style9 {color: #000000}
-->
</style>
<style type="text/css">
<!--
.style10 {color: #000033}
.style9 {color: #000000}
-->
</style>
<table width=100% cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top" width="100%">
<table width="100%">
<form method="post" action="album.php?send=1<? if (strlen($_GET['id'])>0) echo ('&id='. $_GET['id']) ?>" enctype="multipart/form-data">
<tr>
<td valign="top"> <?
draw_user_sidebar();
?></td>
<td width="100%" valign="top">
<script language="JavaScript1.2">
//drag drop function for ie4+ and NS6////
/////////////////////////////////
function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx
crossobj.style.top=tempy+e.clientY-offsety
return false
}
}
function initializedrag(e){
if (ie4&&event.srcElement.id=="postit"||ns6&&e.target.id=="postit"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY
tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)
dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
</script>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<th scope="col"><span class="style9"><img src="../img/tema/etop.jpg" width="14" height="26"></span></th>
<td background="../img/tema/mtop.jpg" scope="col"><div align="center"><span class="style9"><strong>Album de Fotos </strong></span></div></td>
<th scope="col"><span class="style9"><img src="../img/tema/dtop.jpg" width="14" height="26"></span></th>
</tr>
<tr>
<td background="../img/tema/eesc.jpg" scope="col"> </td>
<td width="100%" align="center" scope="col"><table width="75%" border="0">
<tr>
<? $quant =0; $rsfoto = mysql_query("SELECT * FROM fotos WHERE user=" . $_GET['id'] . " order by id");
$cont = 0;
while($row = mysql_fetch_array($rsfoto)) {
$quant=$quant+1;
$fotob = $row['imagem'];
if ($_SESSION['id'] == $_GET['id']) {
echo "<td>";
echo "<center>";
echo "<table><tr><td height='26' background='../img/tema/mtop.jpg' scope='col'><div align='center'><strong>";
echo "<a href='album.php?op=3&img=".$arquivo.$row['imagem']."&id=" . $_GET['id'] ."&idf=" . $row['Id'] ."'>" ."Excluir Imagem"."</a></strong></div></td></tr>";
} else {
echo "<td>";
echo "<center>";
echo "<table><tr><td height='26' scope='col'>";
}
echo "<tr><td width='100%' scope='col'><div align='center'><a href='verfoto.php?img=" . $row['imagem'] . "&id=" . $_GET['id'] ."'><img src='" . $row['imagem'] ."' width='128' height='128'></a>"; echo "<br>"; echo "<br>".$row['comentario']; echo "<br>"; echo"</div></td></tr></table></center>";echo "</td>"; $cont=$cont+1; if ($cont==6) { echo "</tr>"; $cont==0;} if ($cont == 9) { echo "<tr>";}
if ($cont == 3) { echo "<tr>";}
if ($cont == 9) { echo "<tr>";}
if ($cont == 12) { echo "<tr>";}
if ($cont == 15) { echo "<tr>";}
if ($cont == 18) { echo "<tr>";}
if ($cont == 21) { echo "<tr>";}
if ($cont == 24) { echo "<tr>";}
if ($cont == 27) { echo "<tr>";}
if ($cont == 30) { echo "<tr>";}
if ($cont == 33) { echo "<tr>";}
if ($cont == 36) { echo "<tr>";}
if ($cont == 39) { echo "<tr>";}
if ($cont == 42) { echo "<tr>";}
if ($cont == 45) { echo "<tr>";}
if ($cont == 48) { echo "<tr>";}
if ($cont == 51) { echo "<tr>";}
if ($cont == 54) { echo "<tr>";}
if ($cont == 57) { echo "<tr>";}
if ($cont == 60) { echo "<tr>";}
if ($cont == 63) { echo "<tr>";}
if ($cont == 66) { echo "<tr>";}
if ($cont == 69) { echo "<tr>";}
if ($cont == 72) { echo "<tr>";}
if ($cont == 75) { echo "<tr>";}
if ($cont == 78) { echo "<tr>";}
if ($cont == 81) { echo "<tr>";}
if ($cont == 84) { echo "<tr>";}
if ($cont == 87) { echo "<tr>";}
if ($cont == 90) { echo "<tr>";}
if ($cont == 93) { echo "<tr>";}
if ($cont == 96) { echo "<tr>";}
if ($cont == 99) { echo "<tr>";}
if ($cont == 102) { echo "<tr>";}
}?>
</tr>
</table>
<p>
<? if ($_SESSION['id'] == $_GET['id']) { ?>
</p>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<th scope="col"><span class="style9"><img src="../img/tema/etop.jpg" width="14" height="26"></span></th>
<td background="../img/tema/mtop.jpg" scope="col"><div align="center"><span class="style9"><strong><? print((strlen($_GET['cm'])>0 ? "Album de Foto" :"Foto do Usuário")); ?></strong></span></div></td>
<th scope="col"><span class="style9"><img src="../img/tema/dtop.jpg" width="14" height="26"></span></th>
</tr>
<tr>
<td background="../img/tema/eesc.jpg" scope="col"> </td>
<td width="100%" align="center" scope="col"><?
echo "<p>";echo"</p>";
echo "<table width='100%'>"
."<tr>"
."<td width='10%' valign='top' align='right'> <b>Arquivo:</b><br>"
."</td>"
."<td width='90%'> <input type='file' name='file' size=30> </td>"
."</tr>"
."<tr>"
."<td valign='top'><strong>Comentário:</strong></td>"
."<td align='left'><textarea name='comentario' cols='50' rows='10'></textarea></td>"
."</tr>"
."<tr>"
."<td></td>"
."<td align='left'> <input type='submit' value='Enviar Figura'>"
."</td>"
."</tr>"
."</table>"
."<br>"
."<table width='80%' align='center' bgcolor='#FFFFCC' style='border: 1px solid #bbbbbb'>"
."<tr>"
."<td align='center'><strong>Importante</strong>: Somente arquivos
.jpg menores que 300kb serão permitidos. Caso apresente
erro no upload tente usar <strong>CTRL + F5</strong> </td>"
."</tr>"
."</table>"; ?></td>
<td background="../img/tema/ddir.jpg" scope="col"> </td>
</tr>
<tr>
<th background="../img/el.jpg" scope="col"><span class="style9"><img src="../img/tema/ebut.jpg" width="14" height="15"></span></th>
<td height="15" background="../img/tema/mbut.jpg" scope="col"> </td>
<th scope="col"><span class="style9"><img src="../img/tema/dbut.jpg" width="14" height="15"></span></th>
</tr>
</table>
</td><? } ?>
<td background="../img/tema/ddir.jpg" scope="col"> </td>
</tr>
<tr>
<th background="../img/el.jpg" scope="col"><span class="style9"><img src="../img/tema/ebut.jpg" width="14" height="15"></span></th>
<td height="15" background="../img/tema/mbut.jpg" scope="col"> </td>
<th scope="col"><span class="style9"><img src="../img/tema/dbut.jpg" width="14" height="15"></span></th>
</tr>
</table> </td>
</tr>
</form>
</table> </td>
</tr>
</table>
<div id="postit" style="left:288px;top:155px" >
<div align="left">
<!--INSERT YOUR CONTENT HERE-->
<table width="100%" height="126" cellpadding="0" cellspacing="0">
<tr>
<td height="26" scope="col"><span class="style11"><img src="../img/tema/etop.jpg" width="14" height="26"></span></td>
<td height="26" background="../img/tema/mtop.jpg" scope="col"><div align="center"><span class="style11"><strong>ZoomIBF<a href="java script:closeit()"> [X]</a></strong></span></div></td>
<td height="26" scope="col"><span class="style11"><img src="../img/tema/dtop.jpg" width="14" height="26"></span></td>
<td rowspan="3" scope="col"> </td>
</tr>
<tr>
<td background="../img/tema/eesc.jpg" scope="col"> </td>
<td width="100%" bgcolor="#FFFFFF" scope="col"><img src='<? print $fotob; ?>'></a></td>
<td background="../img/tema/ddir.jpg" scope="col"> </td>
</tr>
<tr>
<td background="../img/el.jpg" scope="col"><span class="style11"><img src="../img/tema/ebut.jpg" width="14" height="15"></span></td>
<td height="15" background="../img/tema/mbut.jpg" scope="col"> </td>
<td scope="col"><span class="style11"><img src="../img/tema/dbut.jpg" width="14" height="15"></span></td>
</tr>
</table>
</div>
</div>
<script>
//Post-it only once per browser session? (0=no, 1=yes)
//Specifying 0 will cause postit to display every time page is loaded
var once_per_browser=1
///No need to edit beyond here///
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all
if (ns4)
crossobj=document.layers.postit
else if (ie4||ns6)
crossobj=ns6? document.getElementById("postit") : document.all.postit
function closeit(){
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
crossobj.visibility="hide"
}
function get_cookie4(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie4.length > 0) {
offset = document.cookie4.indexOf(search)
if (offset != -1) { // if cookie4 exists
offset += search.length
// set index of beginning of value
end = document.cookie4.indexOf(";", offset);
// set index of end of cookie4 value
if (end == -1)
end = document.cookie4.length;
returnvalue=unescape(document.cookie4.substring(offset, end))
}
}
return returnvalue;
}
function showornot(){
if (get_cookie4('postdisplay')==''){
showit()
document.cookie4="postdisplay=yes"
}
}
function showit(){
if (ie4||ns6)
crossobj.style.visibility="visible"
else if (ns4)
crossobj.visibility="show"
}
if (once_per_browser)
showornot()
else
showit()
</script>
<?
draw_bottom();
?>
upload.php
>
<?
function delete_file($name)
{
if (file_exists($name))
unlink($name);
}
if ($_GET['send']=='1')
{
session_start();
$filename = "../upload/" . uniqid("").tmp;
$ext = strrchr($HTTP_POST_FILES["file"]["name"], '.');
move_uploaded_file($HTTP_POST_FILES["file"]["tmp_name"], $filename);
/*if ($ext=='.gif')
{
passthru("gif2png -O -d ../upload/". $filename);
$filename = $filename . ".png";
$img = @imagecreatefrompng($filename);
}
else*/ if($ext=='.jpg'|'.png' && filesize($filename)<300832)
$img = @imagecreatefromjpeg($filename);
else
{
delete_file($filename);
header('Location: upload.php?cm='. $_GET['cm'] .'&error=Só extensão .jpg com menos de 300kb&refresh='. uniqid(""));
die();
}
if (strlen($_GET['cm'])>0)
{
delete_file('c_'. $_GET['cm'].'.jpg');
delete_file('c_'. $_GET['cm'].'_m.jpg');
}
else
{
delete_file($_SESSION['id'].'.jpg');
delete_file($_SESSION['id'].'_m.jpg');
}
$size = getimagesize($filename);
$width= $size[0];
$height= $size[1];
if ($width>128)
{
$percentage = 128 / $width;
$width *= $percentage;
$height *= $percentage;
$img_r = imagecreatetruecolor ($width, $height);
imagecopyresampled($img_r, $img, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
}
else
{
$img_r = $img;
}
if ($width>64)
{
$percentage = 64 / $width;
$width *= $percentage;
$height *= $percentage;
}
$img_sm = imagecreatetruecolor($width, $height);
imagecopyresampled($img_sm, $img, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
if (strlen($_GET['cm'])>0)
{
ImageJpeg($img_r, "../upload/c_". $_GET['cm'] . ".jpg", 100);
ImageJpeg($img_sm, "../upload/c_". $_GET['cm'] . "_m.jpg", 100);
}
else
{
ImageJpeg($img_r, "../upload/". $_SESSION['id'] . ".jpg", 100);
ImageJpeg($img_sm, "../upload/". $_SESSION['id'] . "_m.jpg", 100);
}
delete_file($filename);
header('Location: upload.php?cm='. $_GET['cm'] .'&refresh='. uniqid(""));
die();
}
require("../include/pre.php"); // all the basic stuff
require("../include/stringtools.php");
draw_top($topic_message); //starts drawing the page
?>
<table width=100% cellpadding="0" cellspacing="0">
<tr>
<td width="100%" align="center" valign="top" bgcolor="#FFFFFF">
<?
draw_frame_top("Foto Upload");
?>
<table width="100%">
<form method="post" action="upload.php?send=1<? if (strlen($_GET['cm'])>0) echo ('&cm='. $_GET['cm']) ?>" enctype="multipart/form-data">
<tr>
<td width="15%" align="center" valign="top"> <?
show_system_messages();
if (strlen($_GET['cm'])>0)
draw_community_picture($_GET['cm']);
else
draw_user_picture($_SESSION['id']);
echo "<br><br>";
if (strlen($_GET['cm'])>0)
draw_community_small_picture($_GET['cm']);
else
draw_user_small_picture($_SESSION['id']);
?>
</td>
<td width="85%" valign="top">
<?
draw_small_frame_top((strlen($_GET['cm'])>0 ? " Foto da Comunidade" :"Foto do usuário"), "mini_smile");
?>
<?
if(strlen($_GET['cm'])>0) {
$c_verifica = mysql_query("SELECT * FROM communities WHERE owner=". $_SESSION['id'] ."", $db)
or bug("Database error, please try again");
if(mysql_num_rows($c_verifica)<=0) { echo"<font size=2><b>Você não pode alterar a imagem da comunidade!</b></font><br>"; }
else { ?>
<table width="100%">
<tr>
<td width="10%" valign="top" align="right">
<b>Arquivo:</b><br>
</td>
<td width="90%">
<input type="file" name="file" size=30>
</td>
</tr>
<tr>
<td></td>
<td align="left">
<input type="submit" value="Mudar Foto">
</td>
</tr>
</table>
<? } } else { ?><br>
<table width="100%">
<tr>
<td width="10%" valign="top" align="right">
<b>Arquivo:</b><br>
</td>
<td width="90%">
<input type="file" name="file" size=30>
</td>
</tr>
<tr>
<td></td>
<td align="left">
<input type="submit" value="Mudar Foto">
</td>
</tr>
</table><? } ?><br>
<table width="80%" align="center" bgcolor="#FFFFCC" style="border: 1px solid #bbbbbb">
<tr>
<td align="center"><b>Importante:</b> Só extensão .jpg arquivos menores que 300kb.<br>
Se der erro duranto o upload, pressione <b>CTRL+F5</b>x
</td>
</tr>
</table>
<?
draw_small_frame_bottom();
?>
</td>
</tr>
</form>
</table>
<?
draw_frame_bottom();
?> </td>
</tr>
</table>
<?
draw_bottom();
?>
se conseguirem e puderem resolver eu agradeçeriaum abraço a todos.
Carregando comentários...