Ir para conteúdo
Fórum Script Brasil

Oblongs

Membros
  • Total de itens

    14
  • Registro em

  • Última visita

Tudo que Oblongs postou

  1. Da pra resolver com PHP e Javascript... Me contacta pelo e-mail / jdstarweb@gmail.com ou contato@jdwebmaker.com.br
  2. Criei um mini projeto para ficar melhor o entendimento. Obrigado! package mover; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFileChooser; public class MoverArquivo extends javax.swing.JFrame { public MoverArquivo() { initComponents(); } //Metodo que será responsável por enviar o arquivo public void enviarArquivo(File arquivo){ try { //Recebendo o arquivo de entrada FileInputStream entrada = new FileInputStream(arquivo); //Preparando arquivo de saida FileOutputStream saida = new FileOutputStream("teste.zip"); //Variavel para passar os Bytes e montar o arquivo em novo diretorio int b = 0; //Loop responsável pelo envio Byte a Byte while((b = entrada.read()) != -1){ saida.write(b); } //Não esqueça de fechar o envio assim que terminar saida.close(); } catch (FileNotFoundException ex) { Logger.getLogger(MoverArquivo.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MoverArquivo.class.getName()).log(Level.SEVERE, null, ex); } } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jbAbrir = new javax.swing.JButton(); jlUrl = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jbAbrir.setText("Abrir"); jbAbrir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbAbrirActionPerformed(evt); } }); jlUrl.setText("URL"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addComponent(jbAbrir) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jlUrl) .addContainerGap(296, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(45, 45, 45) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jbAbrir) .addComponent(jlUrl)) .addContainerGap(48, Short.MAX_VALUE)) ); pack(); }// </editor-fold> //Acao do botao para abrir o aquivo private void jbAbrirActionPerformed(java.awt.event.ActionEvent evt) { //Criando um objeto do tipo JFileChooser JFileChooser janelaArquivo = new JFileChooser(); //Deixando a janela visivel janelaArquivo.showOpenDialog(this); //Passando para o método criado acima por parametro, já que ele precisa de um arquivo enviarArquivo(janelaArquivo.getSelectedFile()); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MoverArquivo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MoverArquivo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MoverArquivo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MoverArquivo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MoverArquivo().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jbAbrir; private javax.swing.JLabel jlUrl; // End of variables declaration }
  3. Oblongs

    kkkkkkk

    kkkkkkkkkkkkk
  4. É só colocar o nome da coluna que você quer ao invés da chave estrangeira. exemplo! chamado.setFk_cliente(rs.getString("nome_cliente)); chamado.setFk_modulo(rs.getString("nome_do_modulo")); chamado.setFk_setor(rs.getString("nome_setor));
  5. Dá uma olhadinha neste código e tente entender. Fiz com imagem, mas acredito que dê para fazer com arquivo Lembrando que você pode usar o JFileChooser para pegar o caminho //Metodo para fazer upload de image public void uploadImage(File src,String nomeImg) throws FileNotFoundException{ FileInputStream entrada = new FileInputStream(src); FileOutputStream saida = new FileOutputStream("img_patrimonio/"+nomeImg); int buffer; try { while((buffer = entrada.read()) != -1){ saida.write(buffer); } } catch (IOException ex) { JOptionPane.showConfirmDialog(null,"Erro de buffer!\n"+ex,"Alerta!",JOptionPane.ERROR_MESSAGE); } try { entrada.close(); } catch (IOException ex){ JOptionPane.showConfirmDialog(null,"Erro de entrada!\n"+ex,"Alerta!",JOptionPane.ERROR_MESSAGE); } try { saida.close(); } catch (IOException ex) { JOptionPane.showConfirmDialog(null,"Erro de saída!\n"+ex,"Alerta!",JOptionPane.ERROR_MESSAGE); } }Pegando o caminho public void actionPerformed(ActionEvent e) { JFileChooser teste = new JFileChooser(); FileNameExtensionFilter f = new FileNameExtensionFilter("*jpg","jpg"); teste.setFileFilter(f); teste.showOpenDialog(jpForm); try{ jlbUrlImg.setText(teste.getSelectedFile().toString()); }catch(Exception ex){ System.out.println("Nenhum arquivo selecionado!"); } }Criei um objeto chamado teste e um chamado "f". Teste é o JFileChooser, e "F" é o tipo de arquivo que será lido. teste.getSelectedFile().toString()pega o caminho do arquivo selecionado.
  6. popularTabela(DefaultTableModel modelo, String valorPesquisa, int i); Coloca esse método dentro do método que você está chamando ao salvar Exemplo; public void salvarDados(){ popularTabela(DefaultTableModel modelo, String valorPesquisa, int i); } assim quando você salvar ele irá atualizar sua tabela. Isso é só uma questão de lógica.
  7. Faz uma condição para isso. if(numero de usuário == 5){ Não deixa mais incluir no banco de dados. }else{ Ainda está permitido. } Para isso você terá que contar quantos registro está no seu banco de dados.
  8. Oblongs

    Gravar arquivo texto

    De uma olhadinha neste código que criei para a empresa que trabalho. Ele funciona perfeitamente <?php if(isset($_GET['mac'])){ if($_GET['mac'] != ''){ $mac = $_GET['mac']; date_default_timezone_set('AMERICA/SAO_PAULO'); $lote = date("dmy"); $mac2 = (substr($mac,-12,6).dechex(hexdec(substr($mac,6)) + 1)); $mac3 = wordwrap($mac2,2,":",true); $fp = fopen('fibra.csv','a'); $fw = fwrite($fp,strtoupper($mac3).";"."FIBRA;".$lote.";".strtoupper($mac3)."\r\n"); header('location: sxt.php'); } } $ler = fopen("fibra.csv","r"); $num = count($dados); echo "<table border='1'>"; while($dados = fgetcsv($ler,1000,";")){ echo "<tr>"; echo "<td>".$dados[0]."</td>"; echo "<td>".$dados[1]."</td>"; echo "<td>".$dados[2]."</td>"; echo "<td>".$dados[3]."</td>"; echo "</tr>"; } echo "</table>"; ?>
  9. Talvez eu possa te ajudar.. Me contacta pelo email: contato@jdwebmaker.com.br ou jdstarweb@gmail.com
  10. Abfra seu php.ini dê CTRL + F e procure "output_buffering" em "Default Value" coloque On.
  11. Fiz algumas alterações, pois existiam alguns códigos que já não usa mais no php. Testei e funcionou 100%. Caso não esteja visualizando o e-mail, procure na lixeira ou Spam. _____________________________________________________________________________________ Arquivo 1 / Formulario form.php _____________________________________________________________________________________ <?php $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); $ip = gethostbyname($_SERVER['REMOTE_ADDR']); ?> <html> <head> <script language="javascript"> function checa_formulario(email){ if (email.nome.value == ""){ alert("Por Favor não deixe o seu nome em branco!!!"); email.nome.focus(); return (false); } if (email.email_from.value == ""){ alert("Por Favor não deixe o seu email em branco!!!"); email.email_from.focus(); return (false); } if (email.email.value == ""){ alert("não deixe o email destinatario em branco!!!"); email.email.focus(); return (false); } if (email.assunto.value == ""){ alert("não deixe o assunto em branco!!!"); email.assunto.focus(); return (false); } } </script> <title>Formulário</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .email { text-transform: lowercase; } .texto { color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; text-decoration: none; } .style1 { color: #666666; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 18px; text-decoration: none; } table { font-family: Verdana, Geneva, sans-serif; } table { font-size: 12px; } table { color: #000; } --> </style> </head> <body onLoad="document.email.nome.focus();"> <form onSubmit="return checa_formulario(this)" action="envia.php" method="post" enctype="multipart/form-data" name="email"> <input NAME="hostname" TYPE="HIDDEN" ID="hostname" VALUE="<?php print $hostname; ?>"> <input NAME="ip" TYPE="HIDDEN" ID="ip" VALUE="<?php print $ip; ?>"> <table width="502" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" background="imagens/fale_conosco.gif" bgcolor="#ffffff"> <tr> <td> <br> <br> <table width="400" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#ffffff"> <tr> <td> <table width="55%" border="0" align="center"> <tr> <td><div align="right"><span class="texto">Nome:</span></div></td> <td><input name="nome" type="text" id="nome" size="50" class="texto"></td> </tr> <tr> <td width="19%"><div align="right" class="texto">Email:</div></td> <td width="81%"><input name="email_from" type="text" class="texto"></td> </tr> <tr> <td width="19%"><div align="right" class="texto">Para:</div></td> <td width="81%"> <select name="destinatario" class="texto"> <option selected="selected" class="texto">Selecione um Setor</option> <option class="texto" value="contato@descontopravoce.com.br">Atendimento</option> <option class="texto" value="mkt@descontopravoce.com.br">Marketing</option> <option class="texto" value="rh@descontopravoce.com.br">RH</option> <option class="texto" value="contato@descontopravoce.com.br">Logistica</option> <option class="texto" value="wagner@descontopravoce.com.br">Diretoria</option> </select> </td> </tr> <tr> <td><div align="right" class="texto">Assunto:</div></td> <td><input name="assunto" type="text" id="assunto" class="texto"></td> </tr> <tr> <td><div align="center" class="texto">Mensagem</div></td> <td><textarea name="mensagem" cols="50" rows="3" id="mensagem" class="texto"></textarea></td> </tr> <tr> <td><div align="center" class="texto">Anexo do Email</div></td> <td><input name="arquivo" type="file" size="40" class="texto"></td> </tr> <tr> <td>&nbsp;</td> <td><input type="submit" name="Submit" value="Enviar" class="texto"></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </form> <tr> <td VALIGN="TOP"><div ALIGN="CENTER"><font SIZE="1" FACE="Arial, Helvetica, sans-serif"> <?php print "Endereço IP do Host de origem: " . $ip; ?> </font></div></td> </tr> </body> </html> _________________________________________________________________________________ Arquivo 2 / Responsável por enviar o e-mail envia.php _________________________________________________________________________________ <?php $mensagem = ""; $ip = ""; //pego os dados enviados pelo formulario $nome = $_POST["nome"]; $email = $_POST["destinatario"]; $assunto = $_POST["assunto"]; $email_from = $_POST["email_from"]; $mensagem_final = "Enviado por: $_POST[nome] \n\n\n\n<br><br><br>"; $mensagem_final .= "Mensagem: $mensagem \n\n\n<br><br> __________________________________________________________________________________________________ <br> Endereço de IP do remetente da mensagem : $ip"; //formato o campo da mensagem $mensagem = wordwrap( $mensagem_final, 50, "<br>", 1); //anexando um arquivo ou não $arquivo = isset($_FILES["arquivo"]) ? $_FILES["arquivo"] : FALSE; if(file_exists($arquivo["tmp_name"]) and !empty($arquivo)){ $fp = fopen($_FILES["arquivo"]["tmp_name"],"rb"); $anexo = fread($fp,filesize($_FILES["arquivo"]["tmp_name"])); $anexo = base64_encode($anexo); fclose($fp); $anexo = chunk_split($anexo); $boundary = "XYZ-" . date("dmYis") . "-ZYX"; $mens = "--$boundary\n"; $mens .= "Content-Transfer-Encoding: 8bits\n"; $mens .= "Content-Type: text/html; charset=\"ISO-8859-1\"\n\n"; //plain $mens .= "$mensagem_final\n"; $mens .= "--$boundary\n"; $mens .= "Content-Type: ".$arquivo["type"]."\n"; $mens .= "Content-Disposition: attachment; filename=\"".$arquivo["name"]."\"\n"; $mens .= "Content-Transfer-Encoding: base64\n\n"; $mens .= "$anexo\n"; $mens .= "--$boundary--\r\n"; $headers = "MIME-Version: 1.0\n"; $headers .= "From: \"$nome\" <$email_from>\r\n"; $headers .= "Content-type: multipart/mixed; boundary=\"$boundary\"\r\n"; $headers .= "$boundary\n"; mail($email,$assunto,$mens,$headers); echo "<br><br><br><br><br>"; echo "<center> <table> <tr bgcolor=\"#B9DCFF\"> <td width=\"500\"> <div align=center><font size=3 face=arial><b><br>Email com anexo enviado com sucesso<br><br> Aguarde nosso contato<br><br> Obrigado!</font> <div align=center><font color= #FFFFFF size=2 face=arial><b><br></font> <center> <font color=#FF9900> <b>__________________________________________________________</b> </font> </center> </td> </tr> </table> </center>"; } else{ $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"$nome\" <$email_from>\r\n"; mail($email,$assunto,$mensagem_final, $headers); echo "<br><br><br><br><br>"; echo "<center> <table> <tr bgcolor=\"#B9DCFF\"> <td width=\"500\"> <div align=center><font size=3 face=arial><b><br>Email enviado com sucesso<br><br> Aguarde nosso contato<br><br> Obrigado!</font> <div align=center><font color= #FFFFFF size=2 face=arial><b><br></font> <center> <font color=#FF9900> <b>__________________________________________________________</b> </font> </center> </td> </tr> </table> </center>"; } ?>
  12. <html> <head> <title>Sistema de Criptografar</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="estilo.css"> </head> <body> <center> <form action="" method="POST" > <h1>Sistema de Criptografia</h1><br/> <label>Digite a Chave: </label><br/> <input type="text" class='texto' name="chave" value="" /><br/><br/> <label>Digite o texto:</label><br/> <textarea name="texto" rows="0" cols="0"></textarea><br/><br/> <input type="submit" value="Criptografar" name="enviar" class="submit" /> <input type="submit" value="Descriptografar" name="enviar" class="submit" /> </form> </center> <?php if(isset($_POST["enviar"])){ $texto=$_POST['texto']; $chave=$_POST['chave']; $seg=123; $criptoalterar = array ("a","b","c","d","e","f","g","h","i","j","l","m","n","o","p","q","r","s","t","u","v","x","z"); $criptoalterado = array ("U","N","R","O","P","T","6","Y","K","W","Q","9","5","V","6","C","0","X","H","3","B","7","F"); if ($chave== "") { echo '<center class="format">Campo chave é obrigatório</center>'; exit(); } if ($chave!=$seg){ echo 'Chave Incorreta Verifique e tente novamente!'; exit(); } switch ($_POST['enviar']){ case 'Criptografar': $alterar = str_replace($criptoalterar, $criptoalterado, $texto); echo $alterar; break; case 'Descriptografar': $voltar = str_replace($criptoalterado, $criptoalterar, $texto); echo $voltar; break; default: } } ?> </body> </html> Olá, tente desta forma! Funcionou perfeitamente, porém mudei de minuscula para maiúscula. : ]
  13. Oblongs

    php + banco de dados (mysql)

    Está esquecendo as Aspas $sql = "SELECT * FROM alguma coisa";
  14. Oblongs

    ERRO COM CONEXÃO MYSQL

    Não esqueceu de colocar as aspas " código sql ";? : ]
×
×
  • Criar Novo...