Ir para conteúdo
Fórum Script Brasil

Wdroid

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre Wdroid

Wdroid's Achievements

0

Reputação

  1. Olá amigos. Sou novo aqui no forum. Estou com o seguinte problema: tenho um codigo php onde consigo fazer o upload de uma imagem jpeg paras as pastas e consigo salvar o nome do arquivo no banco de dados. O que eu preciso é que o codigo faça o upload de 4 imagens e salvar o nome no banco de dados. Este codigo abaixo, funciona apenas para uma imagem. segue abaixo o codigo: form_xing.php &lt;script language="javascript" src="scripts.js"></script> <br /> <br /> <? $erro = array(); $foi = false; $foi_post = false; if (strlen($_POST["form_email"])==0) $erro[] = "form_email"; if (strlen($_POST["form_nome"])==0) $erro[] = "form_nome"; if (strlen($_POST["form_cidade"])==0) $erro[] = "form_cidade"; if (strlen($_POST["form_estado"])==0) $erro[] = "form_estado"; if ( (strpos($_POST["form_email"],"@")<1) || (strpos($_POST["form_email"],".")<1) ) $erro[] = "form_email"; if (strlen($_POST["form_categoria"])==0) $erro[] = "form_categoria"; if (strlen($_POST["form_subcategoria"])==0) $erro[] = "form_subcategoria"; if (strlen($_POST["form_produto"])==0) $erro[] = "form_produto"; if (strlen($_POST["form_valor"])==0) $erro[] = "form_valor"; if (strlen($_POST["form_expira"])==0) $erro[] = "form_expira"; if (strlen($_POST["form_quantidade"])==0) $erro[] = "form_quantidade"; if (strlen($_POST["form_conservacao"])==0) $erro[] = "form_conservacao"; if (( $_FILES["imagem_produto"]["tmp_name"] != "" ) && (!sizeof($erro))) { if(!eregi("^image\/(pjpeg|jpeg|jpg)$", $_FILES["imagem_produto"]["type"])) { echo '&lt;script language="javascript">alert("Arquivo em formato inválido! Apenas arquivos jpg...");window.back();</script>'; $erro[] = "imagem_produto"; } else { $grande_arq = fazerupload( $_FILES["imagem_produto"], // Arquivo q foi upload "", // Nome do arquivo final "anuncios/img/1/", // Destino "'Grande'", // Apelido 600000, // Tamanho maximo em bytes true,0,0); // Imagem if ($grande_arq == false) { $erro[] = "imagem_produto"; $errou = true; $img = ""; } else { redimensionar("anuncios/img/1/".$grande_arq,"anuncios/img/2/".$grande_arq,30,30 ); redimensionar("anuncios/img/1/".$grande_arq,"anuncios/img/3/".$grande_arq,80,80 ); redimensionar("anuncios/img/1/".$grande_arq,"anuncios/img/4/".$grande_arq,300,400 ); $img = $grande_arq; } } } if(!sizeof($erro)) { $foi = true; $email = $_POST["form_email"]; $nome = $_POST["form_nome"]; $cidade = $_POST["form_cidade"]; $estado = $_POST["form_estado"]; $telefone = $_POST["form_telefone"]; $celular = $_POST["form_celular"]; $MSN = $_POST["form_msn"]; $skype = $_POST["form_skype"]; $categoria = $_POST["form_categoria"]; $subcategoria = $_POST["form_subcategoria"]; $produto = $_POST["form_produto"]; $modelo = $_POST["form_modelo"]; $marca = $_POST["form_marca"]; $ano = $_POST["form_ano"]; $garantia = $_POST["form_garantia"]; $cor = $_POST["form_cor"]; $novo = $_POST["form_conservacao"]; $descricao = $_POST["form_descricao"]; $valor = $_POST["form_valor"]; $quantidade = $_POST["form_quantidade"]; $expira = $_POST["form_expira"]; $aceita_news = $_POST["form_news"]; $tipo = $_POST["form_tipo"]; $expirara = strftime("%Y%m%d", strtotime("+".$expira." days")); if ( (strpos($email,"@")>1) && (strpos($email,".")>1) && ($aceita_news == 1) ) mysql_query("INSERT INTO `newsletter` ( `email` ) VALUES ('".$email."');"); $SQL = "INSERT INTO `vender` ( `id` , `email` , `nome` , `cidade` , `estado` , `telefone` , `celular` , `MSN` , `skype` , `subcategoria` , `categoria` , `produto`, `modelo`, `marca`, `ano`, `garantia`, `cor`, `novo`, `descricao`, `valor`, `quantidade`, `img`, `img2`, `img3`, `img4`, `bloqueado`, `aguardandopgto`, `data`, `termino`, `tipo`) VALUES ('', '".$email."', '".$nome."', '".$cidade."' , '".$estado."', '".$telefone."' , '".$celular."' , '".$MSN."' , '".$skype."' , '".$subcategoria."', '".$categoria."', '".$produto."' , '".$modelo."' , '".$marca."' , '".$ano."' , '".$garantia."' , '".$cor."', '".$novo."', '".$descricao."', '".$valor."', '".$quantidade."', '".$img."', '".$img2."', '".$img3."', '".$img4."', '1', '1', '".date("YmdHis")."', '".$expirara."', '".$tipo."');"; $result_id = mysql_query($SQL) or die(mysql_error()); echo '<center><div style="width:350px;"><b></b><br><BR>Obrigado.</div></center>'; } else if (isset($_POST["form_expira"])) { $foi_post = true; ?> <center> <div align="center" style="background-color: #C2D7E9; width:250px; padding:10px;border: #6BB1E4 1px solid"><font face=arial size="2"> Os campos com " * " são obrigatórios! </font></div> </center><br /><br /> <? } if (!($foi)) { ?> <font size="4"> Teste Titulo</font><br /> <br /> <style> input,textarea,select {font-family:Verdana;font-size:10px; border:1px solid #C2D7E9} </style> <form name="form1" method="post" action="" enctype="multipart/form-data" > <table width="400" border="0" align="center" cellpadding="3" cellspacing="0"> <tr> <td colspan="2" style="border-bottom:1px solid #FF6600;"><strong>Dados Pessoais</strong></td> </tr> <tr> <td colspan="2" height="5"></td> </tr> <tr> <td width="100"> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_email")) ) echo "<font color=red><b>"; ?> Email: * <? if (($foi_post==true) && (ExisteNoArray($erro,"form_email")) ) echo "</b></font>"; ?> </td> <td><input name="form_email" type="text" size="35" maxlength="100" style="width:280px" value="<?=$_POST["form_email"];?>"></td> </tr> <tr> <td width="90"> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_nome")) ) echo "<font color=red><b>"; ?> Nome: * <? if (($foi_post==true) && (ExisteNoArray($erro,"form_nome")) ) echo "</b></font>"; ?> </td> <td><input name="form_nome" type="text" size="35" maxlength="150" style="width:280px" value="<?=$_POST["form_nome"];?>"></td> </tr> <tr> <td> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_cidade")) ) echo "<font color=red><b>"; ?> Cidade: * <? if (($foi_post==true) && (ExisteNoArray($erro,"form_cidade")) ) echo "</b></font>"; ?> </td> <td><input name="form_cidade" type="text" id="form_cidade" style="width:200px" value="<?=$_POST["form_cidade"];?>"></td> </tr> <tr> <td>Estado:</td> <td><select name="form_estado" style="width:206px;"> <option value="Acre" <? if ($_POST["form_estado"]=="Acre") echo 'selected="selected"';?>>Acre</option> <option value="Alagoas" <? if ($_POST["form_estado"]=="Alagoas") echo 'selected="selected"';?>>Alagoas</option> <option value="Amapá" <? if ($_POST["form_estado"]=="Amapá") echo 'selected="selected"';?>>Amapá</option> <option value="Amazonas" <? if ($_POST["form_estado"]=="Amazonas") echo 'selected="selected"';?>>Amazonas</option> <option value="Bahia" <? if ($_POST["form_estado"]=="Bahia") echo 'selected="selected"';?>>Bahia</option> <option value="Ceará" <? if ($_POST["form_estado"]=="Ceará") echo 'selected="selected"';?>>Ceará</option> <option value="Distrito Federal" <? if ($_POST["form_estado"]=="Distrito Federal") echo 'selected="selected"';?>>Distrito Federal</option> <option value="Espírito Santo" <? if ($_POST["form_estado"]=="Espírito Santo") echo 'selected="selected"';?>>Espírito Santo</option> <option value="Goiás" <? if ($_POST["form_estado"]=="Goiás") echo 'selected="selected"';?>>Goiás</option> <option value="Maranhão" <? if ($_POST["form_estado"]=="Maranhão") echo 'selected="selected"';?>>Maranhão</option> <option value="Mato Grosso" <? if ($_POST["form_estado"]=="Mato Grosso") echo 'selected="selected"';?>>Mato Grosso</option> <option value="Mato Grosso do Sul" <? if ($_POST["form_estado"]=="Mato Grosso do Sul") echo 'selected="selected"';?>>Mato Grosso do Sul</option> <option value="Minas Gerais"<? if ($_POST["form_estado"]=="Minas Gerais") echo 'selected="selected"'; if (!isset($_POST["form_estado"])) echo 'selected="selected"'; ?>> Minas Gerais</option> <option value="Pará" <? if ($_POST["form_estado"]=="Pará") echo 'selected="selected"';?>>Pará</option> <option value="Paraíba" <? if ($_POST["form_estado"]=="Paraíba") echo 'selected="selected"';?>>Paraíba</option> <option value="Paraná" <? if ($_POST["form_estado"]=="Paraná") echo 'selected="selected"';?>>Paraná</option> <option value="Pernambuco" <? if ($_POST["form_estado"]=="Pernambuco") echo 'selected="selected"';?>>Pernambuco</option> <option value="Piauí" <? if ($_POST["form_estado"]=="Piauí") echo 'selected="selected"';?>>Piauí</option> <option value="Rio de Janeiro" <? if ($_POST["form_estado"]=="Rio de Janeiro") echo 'selected="selected"';?>>Rio de Janeiro</option> <option value="Rio Grande do Norte" <? if ($_POST["form_estado"]=="Rio Grande do Norte") echo 'selected="selected"';?>>Rio Grande do Norte</option> <option value="Rio Grande do Sul" <? if ($_POST["form_estado"]=="Rio Grande do Sul") echo 'selected="selected"';?>>Rio Grande do Sul</option> <option value="Rondônia" <? if ($_POST["form_estado"]=="Rondônia") echo 'selected="selected"';?>>Rondônia</option> <option value="Rorâima" <? if ($_POST["form_estado"]=="Rorâima") echo 'selected="selected"';?>>Rorâima</option> <option value="Santa Catarina" <? if ($_POST["form_estado"]=="Santa Catarina") echo 'selected="selected"';?>>Santa Catarina</option> <option value="São Paulo" <? if ($_POST["form_estado"]=="São Paulo") echo 'selected="selected"';?>>São Paulo</option> <option value="Sergipe" <? if ($_POST["form_estado"]=="Sergipe") echo 'selected="selected"';?>>Sergipe</option> <option value="Tocantins" <? if ($_POST["form_estado"]=="Tocantins") echo 'selected="selected"';?>>Tocantins</option> </select> </td> </tr> <tr> <td>Telefone:</td> <td><input name="form_telefone" type="text" id="form_telefone" style="width:100px" value="<?=$_POST["form_telefone"];?>" onkeypress="return txtBoxFormat(document.Form1, form_telefone, '(99) 9999-9999', event);" maxlength="14"> <font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif">somente nº e com DDD</font></td> </tr> <tr> <td>Celular:</td> <td><input name="form_celular" type="text" id="form_celular" style="width:100px" value="<?=$_POST["form_celular"];?>" onkeypress="return txtBoxFormat(document.Form1, form_celular, '(99) 9999-9999', event);" maxlength="14"> <font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif">somente nº e com DDD</font></td> </tr> <tr> <td>MSN:</td> <td><input name="form_msn" type="text" id="form_msn" size="35" style="width:280px" value="<?=$_POST["form_msn"];?>"></td> </tr> <tr> <td>Skype:</td> <td><input name="form_skype" type="text" id="form_skype" size="35" style="width:280px" value="<?=$_POST["form_skype"];?>"></td> </tr> <tr> <td>Tipo:</td> <td><input name="form_tipo" type="text" id="form_tipo" size="35" style="width:280px" value="pg"></td> </tr> <tr> <td colspan="2" height="25"></td> </tr> <tr> <td colspan="2" style="border-bottom:1px solid #FF6600;"><strong>Dados do Produto</strong></td> </tr> <tr> <td colspan="2" height="5"></td> </tr> <tr> <td> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_categoria")) ) echo "<font color=red><b>"; ?> Categoria: * <? if (($foi_post==true) && (ExisteNoArray($erro,"form_categoria")) ) echo "</b></font>"; ?> </td> <td> <select name="form_categoria" id="elemento1" style="width:206px;" onchange="zera_subcat('elemento2');movimento(this.options[this.selectedIndex].value);"> <option value="" <? if (empty($_POST["form_categoria"])) echo 'selected="selected"';?>></option> <? $SQL = "SELECT id,nome FROM `categorias` ORDER BY nome ASC"; $result_id = mysql_query($SQL) or die(mysql_error()); $i = 0; while ($linha = mysql_fetch_array($result_id)) { $id = $linha["id"]; $nome = $linha["nome"]; ?> <option value="<?=$id;?>" <? if ($_POST["form_categoria"]==$id) echo 'selected="selected"';?>> <?=$nome;?> </option> <? } ?> </select> </td> </tr> <tr> <td> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_subcategoria")) ) echo "<font color=red><b>"; ?> Subcategoria: * <? if (($foi_post==true) && (ExisteNoArray($erro,"form_subcategoria")) ) echo "</b></font>"; ?> </td> <td> <select name="form_subcategoria" id="elemento2" style="width:206px;"> <option value="" <? if (empty($_POST["form_subcategoria"])) echo 'selected="selected"';?>>-</option> <? if (!empty($_POST["form_categoria"])) { $SQL = "SELECT * FROM `subcategorias` WHERE id_categoria=".$_POST["form_categoria"]." ORDER BY subcategoria ASC"; $result_id = mysql_query($SQL) or die(mysql_error()); $i = 0; while ($linha = mysql_fetch_array($result_id)) { $id = $linha["id_subcategoria"]; $nome = $linha["subcategoria"]; ?> <option value="<?=$id;?>" <? if ($_POST["form_subcategoria"]==$id) echo 'selected="selected"';?>><?=$nome;?></option> <? } } ?> </select> </td> </tr> <tr> <td> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_produto")) ) echo "<font color=red><b>"; ?> Produto: * <? if (($foi_post==true) && (ExisteNoArray($erro,"form_produto")) ) echo "</b></font>"; ?> </td> <td><input name="form_produto" type="text" id="form_produto" style="width:280px" value="<?=$_POST["form_produto"];?>" maxlength="25"></td> </tr> <tr> <td> </td> <td><font color="#999999" size="1" face="Verdana, Arial, Helvetica, sans-serif">ex: "Celular Motorola V3"</font></td> </tr> <tr> <td>Modelo:</td> <td><input name="form_modelo" type="text" id="form_modelo" style="width:280px" value="<?=$_POST["form_modelo"];?>"></td> </tr> <tr> <td>Marca:</td> <td><input name="form_marca" type="text" id="form_marca" style="width:280px" value="<?=$_POST["form_marca"];?>"></td> </tr> <tr> <td>Cor:</td> <td><input name="form_cor" type="text" style="width:200px" maxlength="50" value="<?=$_POST["form_cor"];?>"></td> </tr> <tr> <td>Ano Fabricação:</td> <td><input name="form_ano" type="text" id="form_ano" style="width:35px" maxlength="4" value="<? if (strlen($_POST["form_ano"])==0) echo date("Y"); else echo $_POST["form_ano"];?>"></td> </tr> <tr> <td>Garantia (meses):</td> <td><input name="form_garantia" type="text" style="width:30px" maxlength="4" value="<? if (strlen($_POST["form_garantia"])==0) echo "0"; else echo $_POST["form_garantia"];?>"></td> </tr> <tr> <td> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_conservacao")) ) echo "<font color=red><b>"; ?> Conservação: * <? if (($foi_post==true) && (ExisteNoArray($erro,"form_conservacao")) ) echo "</b></font>"; ?> </td> <td><input type="radio" name="form_conservacao" value="0" style="border:0px;" <? if ($_POST["form_conservacao"]=="0") echo 'checked="checked"';?>> Novo <input type="radio" name="form_conservacao" value="1" style="border:0px;" <? if ($_POST["form_conservacao"]=="1") echo 'checked="checked"';?>> Seminovo <input type="radio" name="form_conservacao" value="2" style="border:0px;" <? if ($_POST["form_conservacao"]=="2") echo 'checked="checked"';?>> Usado </td> </tr> <tr> <td>Descrição:</td> <td><textarea name="form_descricao" id="form_descricao" style="width:280px; height:120px;"><?=$_POST["form_descricao"];?></textarea></td> </tr> <tr> <td> </td> <td><font color="#999999" size="1" face="Verdana, Arial, Helvetica, sans-serif">ex: "colocar descrição e especificação do produto, se existe defeitos e outras observações"</font></td> </tr> <tr> <td> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_valor")) ) echo "<b>"; ?> <font color=red>Valor (R$): *</font> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_valor")) ) echo "</b>"; ?> </td> <td><input name="form_valor" type="text" id="form_valor" style="width:80px" maxlength="20" value="<?=$_POST["form_valor"];?>"> <font color="#aaaaaa" size="1" face="Verdana, Arial, Helvetica, sans-serif">ex: 100,00</font></td> </tr> <tr> <td> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_quantidade")) ) echo "<font color=red><b>"; ?> Quantidade: * <? if (($foi_post==true) && (ExisteNoArray($erro,"form_quantidade")) ) echo "</b></font>"; ?> </td> <td><input name="form_quantidade" type="text" id="form_quantidade" style="width:35px" maxlength="4" value="<?=$_POST["form_quantidade"];?>"></td> </tr> <tr> <td>Imagem:</td> <td><p> <input type="file" name="imagem_produto" style="width: 280px; height:20px"> </p> <p></p> <p> </p></td> </tr> <tr> <td height="10"> </td> </tr> <tr> <td> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_expira")) ) echo "<b>"; ?> <font color=red>Prazo: * </font> <? if (($foi_post==true) && (ExisteNoArray($erro,"form_expira")) ) echo "</b>"; ?> </td> <td><select name="form_expira" style="width:80px;"> <option value="7">7 dias</option> <option value="15">15 dias</option> <option value="30">30 dias</option> <option value="60" selected>60 dias</option> <option value="90">90 dias </option> <option value="120">120 dias</option> <option value="150">150 dias</option> </select> <font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif"> (prazo para o anuncio)</font></td> </tr> <tr> <td colspan="2" style="padding-top:20px;"><input type="checkbox" value="1" name="form_news" checked="checked" /> Desejo receber as novidades do site via e-mail. </td> </tr> <tr> <td colspan="2" height="35"></td> </tr> <tr align="right"> <td colspan="2" align="center"><input name="acao" type="hidden" id="acao" value="enviar"> <input type="submit" name="Submit" value="Enviar" style="background:#dddddd; border:1px solid #bbbbbb; height:20px"></td> </tr> </table> </form> <? $SQL = "SELECT * FROM `categorias` ORDER BY nome ASC"; $result_id = mysql_query($SQL) or die(mysql_error()); while ($linha = mysql_fetch_array($result_id)) { $id_cat = $linha["id"]; $nome_cat = $linha["nome"]; ?> <select name="form_categoria" id="fontesubcat_<?=$id_cat;?>" style="visibility:hidden;"> <option value="" ></option> <? $SQL2 = "SELECT * FROM `subcategorias` WHERE id_categoria=$id_cat ORDER BY subcategoria ASC"; $result_id2 = mysql_query($SQL2) or die(mysql_error()); while ($linha2 = mysql_fetch_array($result_id2)) { $id_sub = $linha2["id_subcategoria"]; $nome_sub = $linha2["subcategoria"]; ?> <option value="<?=$id_sub;?>"><?=$nome_sub;?></option> <? } ?> </select> <? } ?> &lt;script> movimento(document.getElementById('elemento1').options[document.getElementById('elemento1').selectedIndex].value); </script> <? } ?> [/codebox] Aqui vai as funçoes do codigo acima: func.php [codebox] <? // CLASSE DE FORMATAÇÃO DE VALOR INTEIRO PARA MONETÁRIO function ConverteTimestamp($date) { // YYYYMMDD para DDMMYYYY $data = substr($date, 8, 2) .'/' . substr($date, 5, 2) . '/'. substr($date, 0, 4) .' às '. substr($date, 11, 2) .':'. substr($date, 14, 2) . ':'. substr($date, 17, 2); return $data; } function ConverteTimestampDMA($date) { // YYYYMMDD para DDMMYYYY $data = substr($date, 6, 2) .'.' . substr($date, 4, 2) . '.'. substr($date, 0, 4); return $data; } function ConverteTimestampDMA_AMD($date) { // YYYYMMDD para DDMMYYYY $data = substr($date, 6, 4) .'.' . substr($date, 3, 2) . '.'. substr($date, 0, 2); return $data; } function ConverteDataYMD($date) { // YYYYMMDD para DDMMYYYY $data = substr($date, 8, 2) .'/' . substr($date, 5, 2) . '/'. substr($date, 0, 4); return $data; } function formata($valor) { $valor = trim(strrev($valor)); $preço = ""; for ($i=0;$i<strlen($valor);$i++) { if ($i==2) { $preço = $preço.","; } if (($i<>2)AND(($i+1)%3==0)) { $preço = $preço."."; } $preço = $preço.substr($valor,$i,1); } unset($i,$valor); $preço = strrev($preço); return $preço; } function TiraTags($onde) { if (strpos($onde,"<") > 0) $onde = str_replace("<","<",$detalhes); if (strpos($onde,">") > 0) $onde = str_replace(">",">",$detalhes); return $onde; } function TagsHtml($corpo) { $corpo = str_replace("<",'<',$corpo); $corpo = str_replace(">",'>',$corpo); $corpo = str_replace(chr(13).chr(10),"<br>",$corpo); $corpo = str_replace("","<b>",$corpo); $corpo = str_replace("","</b>",$corpo); $corpo = str_replace("","<em>",$corpo); $corpo = str_replace("","</em>",$corpo); $corpo = str_replace("[img]",'<img src="',$corpo); $corpo = str_replace("[/img]",'" border="0">',$corpo); $corpo = str_replace("[link]",'<a href="',$corpo); $corpo = str_replace("[/link]",'" target="_blank">',$corpo); $corpo = str_replace("[tamanho1]",'<font size=1>',$corpo); $corpo = str_replace("[/tamanho1]",'</font>',$corpo); $corpo = str_replace("[tamanho2]",'<font size=2>',$corpo); $corpo = str_replace("[/tamanho2]",'</font>',$corpo); $corpo = str_replace("[tamanho3]",'<font size=3>',$corpo); $corpo = str_replace("[/tamanho3]",'</font>',$corpo); $corpo = str_replace("[tamanho4]",'<font size=4>',$corpo); $corpo = str_replace("[/tamanho4]",'</font>',$corpo); $corpo = str_replace("[tamanho5]",'<font size=5>',$corpo); $corpo = str_replace("[/tamanho5]",'</font>',$corpo); $corpo = str_replace("[tamanho6]",'<font size=6>',$corpo); $corpo = str_replace("[/tamanho6]",'</font>',$corpo); return $corpo; } function TagsHtml_Inv($corpo) { $corpo = str_replace("<br>","\n",$corpo); $corpo = str_replace("<b>","",$corpo); $corpo = str_replace("</b>","",$corpo); $corpo = str_replace("<em>","",$corpo); $corpo = str_replace("</em>","",$corpo); $corpo = str_replace('<img src="',"[img]",$corpo); $corpo = str_replace('" border="0">',"[/img]",$corpo); $corpo = str_replace('<a href="',"[link]",$corpo); $corpo = str_replace('" target="_blank">',"[/link]",$corpo); $corpo = str_replace('<font size=1>',"[tamanho1]",$corpo); $corpo = str_replace('</font>',"[/tamanho1]",$corpo); $corpo = str_replace('<font size=2>',"[tamanho2]",$corpo); $corpo = str_replace('</font>',"[/tamanho2]",$corpo); $corpo = str_replace('<font size=3>',"[tamanho3]",$corpo); $corpo = str_replace('</font>',"[/tamanho3]",$corpo); $corpo = str_replace('<font size=4>',"[tamanho4]",$corpo); $corpo = str_replace('</font>',"[/tamanho4]",$corpo); $corpo = str_replace('<font size=5>',"[tamanho5]",$corpo); $corpo = str_replace('</font>',"[/tamanho5]",$corpo); $corpo = str_replace('<font size=6>',"[tamanho6]",$corpo); $corpo = str_replace('</font>',"[/tamanho6]",$corpo); return $corpo; } function ExisteNoArray($onde,$oque) { if (in_array($oque, $onde)) return true; else return false; } //esta function aqui faz o upload function fazerupload($arquivo,$nome_arquivo,$destino,$apelido,$tamanhomax,$imagem,$larguramax,$alturamax) { $gerro = $gconfig = array(); $gconfig["tamanho"] = $tamanhomax; $gconfig["largura"] = $larguramax; $gconfig["altura"] = $alturamax; // Se for imagem if ($imagem) { if(!eregi("^image\/(pjpeg|jpeg|png|gif|bmp)$", $arquivo["type"]) ) { $gerro[] = "Arquivo em formato inválido! A imagem deve ser jpg, jpeg, bmp, gif ou png. Envie outro arquivo"; } else { $tamanhos = getimagesize($arquivo["tmp_name"]); if ( ($tamanhos[0] > $gconfig["largura"]) && ($larguramax != 0 ) ) { $gerro[] = "Largura de ".$apelido." deve ser no máximo " . $gconfig["largura"] . " pixels. Tamanho atual: ".$tamanhos[0]; } if ( ($tamanhos[1] > $gconfig["altura"]) && ( $alturamax != 0 ) ) { $gerro[] = "Altura da imagem deve ser no máximo" . $gconfig["altura"] . " pixels. Tamanho atual: ".$tamanhos[1]; } } } // Tamanho do arquivo em bytes if ( ($arquivo["size"] > $gconfig["tamanho"]) && ($tamanhomax != 0 ) ) { $gerro[] = "O arquivo deve ser de no máximo " . $gconfig["tamanho"] . " bytes. Envie outro arquivo. Atual: ".$arquivo["size"]." bytes"; } // Extensao do arquivo $i = 1; $extensao = ""; if (strpos($arquivo["name"],'.')!=0) { while ($extensao == "") { $ponto = substr($arquivo["name"],strlen($arquivo["name"])-$i,1); if ($ponto == ".") $extensao = substr($arquivo["name"],strlen($arquivo["name"])-($i-1),strlen($arquivo["name"])); $i++; if ($i > 255) die("Houve um erro desconhecido! Abortado. Confira o nome do arquivo enviado"); } } else { $gerro[] = "O arquivo enviado deve ter uma extensão. *.*"; } // Se houver erro if(sizeof($gerro)) { foreach($gerro as $err) { echo " - " . $err . "<BR>"; } return false; } // Verificação de dados OK, nenhum erro ocorrido, executa então o upload... else { if ($nome_arquivo == "") { $nome_arquivo = date("Ymd").time(); $nome_arquivo = $nome_arquivo . "." . $extensao; } move_uploaded_file($arquivo["tmp_name"], $destino.$nome_arquivo); return $nome_arquivo; } } // fim da function // REDIMENSIONANDO A IMAGEM //function redimensionar($imagem,$destino,$twidth) { function redimensionar($imagem,$destino,$xmax,$ymax) { $name = ""; if(file_exists($imagem)) { $pic = @imagecreatefromjpeg($imagem) or die ("Falhou"); if ($pic) { $width = imagesx($pic); $height = imagesy($pic); if (($width < $xmax)&&($height < $ymax)) { $theight = $height; $twidth = $width; } else { $theight = $xmax * $height / $width; $twidth = $xmax; if ($theight > $ymax) { $theight = $ymax; $twidth = $ymax * $width / $height; } } $thumb = @imagecreatetruecolor ($twidth, $theight) or die ("Não foi possível criar a imagem!"); imagecopyresized($thumb, $pic, 0, 0, 0, 0, $twidth, $theight, $width, $height); ImageJPEG($thumb,$destino,80); } } return true; } function PesquisaTiraCarac($aonde) { $campo = " 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "; $i = 0; $texto = $aonde; while ($i < strlen($texto)) { $pedaco = substr($texto,$i,1); if ((strpos($campo,$pedaco)==0)&&($pedaco!=" ")) $texto = str_replace($pedaco,"",$texto); else $i++; } $texto = str_replace(" "," ",$texto); return $texto; } function TituloPagInicial($qual) { while ( (strlen($qual)>15)&&( (strpos($qual," ")>15)||(strpos($qual," ")==0) ) ) { $resultado = $resultado.substr($qual,0,15)." "; $qual = substr($qual,15,strlen($qual)); } if (strlen($resultado)==0) return $qual; else return $resultado.$qual; } function NaoDeforma($qual,$max) { if ($max > 0) { while ( (strlen($qual)>$max)&&( (strpos($qual," ")>$max)||(strpos($qual," ")==0) ) ) { $resultado = $resultado.substr($qual,0,$max)." "; $qual = substr($qual,$max,strlen($qual)); } if (strlen($resultado)==0) return $qual; else return $resultado.$qual; } else return $qual; } function emailCliente_Envia($para, $nome, $assunto, $corpo) { $headers = "Content-type: text/html; charset=iso-8859-1\r\n"; $headers.= ""; $corpo = str_replace("{nome}",$nome,$corpo); if (@mail($para,$assunto,$corpo,$headers)) return true; else return false; } function emailCliente($para, $nome, $tipo) { if ($tipo == 1) { // Email $arquivo = "../home/emails/cadastro-prod.html"; $fp = fopen($arquivo,"r"); $corpo_email = fread($fp, filesize($arquivo)); fclose($fp); if ( emailCliente_Envia($para,$nome,"Enviado", $corpo_email) ) return true; else return false; } if ($tipo == 3) { // Email $arquivo = "../home/emails/cadastro-prod-pt.html"; $fp = fopen($arquivo,"r"); $corpo_email = fread($fp, filesize($arquivo)); fclose($fp); if ( emailCliente_Envia($para,$nome,"Obrigado", $corpo_email) ) return true; else return false; } } ?>
×
×
  • Criar Novo...