Jump to content


waterboy

Member Since 21/03/2011
Offline Last Active Private
-----

Topics I've Started

Php Image Uploader

04/06/2011, 21:36

Antes de fazer esse teste... vejam o video no link Video do Tutorial
upload-imagem.php
<?php
// Conexão com o banco de dados
$conn = @mysql_connect("localhost", "root", "p@ssw0rd") or die ("Problemas na conexão.");
$db = @mysql_select_db("thiago_cardoso", $conn) or die ("Problemas na conexão");

// Se o usuário clicou no botão cadastrar efetua as ações
if ($_POST['cadastrar']) {
	
	// Recupera os dados dos campos
	$nome = $_POST['nome'];
	$email = $_POST['email'];
	$foto = $_FILES["foto"];
	
	// Se a foto estiver sido selecionada
	

	
	if (!empty($foto["name"])) {
		
		// Largura máxima em pixels
		$largura = 900;
		// Altura máxima em pixels
		$altura = 900;
		// Tamanho máximo do arquivo em bytes
		$tamanho = 1000;

    	// Verifica se o arquivo é uma imagem
    	if(!eregi("^image\/(pjpeg|jpeg|png|gif|bmp)$", $foto["type"])){
     	   $error[1] = "Isso não é uma imagem.";
   	 	} 
	
		// Pega as dimensões da imagem
		$dimensoes = getimagesize($foto["tmp_name"]);
			
	
		// Verifica se a largura da imagem é maior que a largura permitida
		       if($dimensoes[0] > $largura) {
			       $error[2] = "A largura da imagem não deve ultrapassar ".$largura." pixels";
		       }

		// Verifica se a altura da imagem é maior que a altura permitida
		if($dimensoes[1] > $altura) {
			$error[3] = "Altura da imagem não deve ultrapassar ".$altura." pixels";
		}
		
		// Verifica se o tamanho da imagem é maior que o tamanho permitido
		if($arquivo["size"] > $tamanho) {
   		 	$error[4] = "A imagem deve ter no máximo ".$tamanho." bytes";
		}

		// Se não houver nenhum erro
		if (count($error) == 0) {
		
			// Pega extensão da imagem
			preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $foto["name"], $ext);

        	// Gera um nome único para a imagem
        	$nome_imagem = md5(uniqid(time())) . "." . $ext[1];

        	// Caminho de onde ficará a imagem
        	$caminho_imagem = "fotos/" . $nome_imagem;

			// Faz o upload da imagem para seu respectivo caminho
			move_uploaded_file($foto["tmp_name"], $caminho_imagem);
		
			// Insere os dados no banco
			$sql = mysql_query("INSERT INTO usuarios VALUES ('NULL', '".$nome."', '".$email."', '".$nome_imagem."')");
		
			// Se os dados forem inseridos com sucesso
			if ($sql){
				echo "Você foi cadastrado com sucesso.";
			}
		}
	
		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
			}
		}
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cadastro de usuário</title>
<link href="as-cores.css" rel="stylesheet" type="text/css" />
</head>

<body>
<fieldset>
<legend>Novo Usuário</legend>

<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" name="cadastro" >
Nome:<br />
<input type="text" name="nome" /><br /><br />
Email:<br />
<input type="text" name="email" /><br /><br />
Foto de exibição:<br />
<input type="file" name="foto" /><br /><br />
<input type="submit" name="cadastrar" value="Cadastrar" />
</form>
</fieldset>
<br><br><br>


<fieldset>
<legend> Usuários Cadastrados </legend>
<?php
// Seleciona todos os usuários
$sql = mysql_query("SELECT * FROM usuarios ORDER BY nome");

// Exibe as informações de cada usuário
while ($usuario = mysql_fetch_object($sql)) {
	// Exibimos a foto
	echo "<BR><BR>";
	echo "<table border='2'>";
	echo "<tr><td><img src='fotos/".$usuario->foto."' alt='Foto de exibição' height='300' wight='100'></td></tr></table>";
	// Exibimos o nome e email
	echo "<table border='2'>";
	echo "<tr><td><b>Nome:</b> </td><td>" . $usuario->nome . "</td>";
	echo "<tr><td><b>Email:</b> </td><td>" . $usuario->email . "</td>";
	echo "</tr></table>";
}


?>

</fieldset>

</body>
</html>

Servidor De Webmail. Como Configurar

23/05/2011, 12:19

Ola Pessoal tudo blz?

Eu acabei de instalar o Squirrelmail, que um dos melhores Servidores de Webmail do Mundo.
Mas eu estou com Duvidas sobre ele. se alguem ja usou ou ja COnfigurou o bichinho..... tem como me dar uma ajuda?

Tipo minha Duvida nesse Arquivo aqui...

config.php, que se localiza no /etc/lampp/htdocs/squirrelamail/config/config.php <- assim no meu server
<?php

/**
* SquirrelMail Configuration File
* Created using the configure script, conf.pl
*/

global $version;
$config_version = '1.4.0';
$config_use_color = 2;

$org_name      = "Nome_da_empresa";
$org_logo      = SM_PATH . 'images/sm_logo.png';
$org_logo_width  = '308';
$org_logo_height = '111';
$org_title     = "Nome_da_empresa";
$signout_page  = '';
$frame_top     = '_top';

$provider_uri     = 'http://endereco_do_seu_site/';

$provider_name     = 'Nome_da_empresa';

$motd = "";

$squirrelmail_default_language = 'pt_BR';

$domain                 = 'seu_dominio.com.br';
$imapServerAddress      = 'localhost';
$imapPort               = 143;
$useSendmail            = false;
$smtpServerAddress      = 'mail.dominio.com.br'; /*Pode ser colocado o IP do seu servidor de email*/
$smtpPort               = 25;
$sendmail_path          = '/usr/sbin/sendmail';
$pop_before_smtp        = false;
$imap_server_type       = 'courier';
$invert_time            = false;
$optional_delimiter     = 'detect';

$default_folder_prefix          = '';
$trash_folder                   = 'INBOX.Trash';
$sent_folder                    = 'INBOX.Sent';
$draft_folder                   = 'INBOX.Drafts';
$default_move_to_trash          = true;
$default_move_to_sent           = true;
$default_save_as_draft          = true;
$show_prefix_option             = true;
$list_special_folders_first     = true;
$use_special_folder_color       = true;
$auto_expunge                   = true;
$default_sub_of_inbox           = true;
$show_contain_subfolders_option = true;
$default_unseen_notify          = 2;
$default_unseen_type            = 1;
$auto_create_special            = true;
$delete_folder                  = true;
$noselect_fix_enable            = true;

$default_charset          = 'iso-8859-1';
$data_dir                 = SM_PATH . 'data/';
$attachment_dir           = $data_dir;
$dir_hash_level           = 0;
$default_left_size        = '150';
$force_username_lowercase = true;
$default_use_priority     = true;
$hide_sm_attributions     = false;
$default_use_mdn          = true;
$edit_identity            = true;
$edit_name                = true;
$allow_thread_sort        = false;
$allow_server_sort        = false;
$allow_charset_search     = true;
$uid_support              = true;


$theme_css = '';
$theme_default = 0;
$theme[0]['PATH'] = SM_PATH . 'themes/default_theme.php';
$theme[0]['NAME'] = 'Default';
$theme[1]['PATH'] = SM_PATH . 'themes/plain_blue_theme.php';
$theme[1]['NAME'] = 'Plain Blue';
$theme[2]['PATH'] = SM_PATH . 'themes/sandstorm_theme.php';
$theme[2]['NAME'] = 'Sand Storm';
$theme[3]['PATH'] = SM_PATH . 'themes/deepocean_theme.php';
$theme[3]['NAME'] = 'Deep Ocean';
$theme[4]['PATH'] = SM_PATH . 'themes/slashdot_theme.php';
$theme[4]['NAME'] = 'Slashdot';
$theme[5]['PATH'] = SM_PATH . 'themes/purple_theme.php';
$theme[5]['NAME'] = 'Purple';
$theme[6]['PATH'] = SM_PATH . 'themes/forest_theme.php';
$theme[6]['NAME'] = 'Forest';
$theme[7]['PATH'] = SM_PATH . 'themes/ice_theme.php';
$theme[7]['NAME'] = 'Ice';
$theme[8]['PATH'] = SM_PATH . 'themes/seaspray_theme.php';
$theme[8]['NAME'] = 'Sea Spray';
$theme[9]['PATH'] = SM_PATH . 'themes/bluesteel_theme.php';
$theme[9]['NAME'] = 'Blue Steel';
$theme[10]['PATH'] = SM_PATH . 'themes/dark_grey_theme.php';
$theme[10]['NAME'] = 'Dark Grey';
$theme[11]['PATH'] = SM_PATH . 'themes/high_contrast_theme.php';
$theme[11]['NAME'] = 'High Contrast';
$theme[12]['PATH'] = SM_PATH . 'themes/black_bean_burrito_theme.php';
$theme[12]['NAME'] = 'Black Bean Burrito';
$theme[13]['PATH'] = SM_PATH . 'themes/servery_theme.php';
$theme[13]['NAME'] = 'Servery';
$theme[14]['PATH'] = SM_PATH . 'themes/maize_theme.php';
$theme[14]['NAME'] = 'Maize';
$theme[15]['PATH'] = SM_PATH . 'themes/bluesnews_theme.php';
$theme[15]['NAME'] = 'BluesNews';
$theme[16]['PATH'] = SM_PATH . 'themes/deepocean2_theme.php';
$theme[16]['NAME'] = 'Deep Ocean 2';
$theme[17]['PATH'] = SM_PATH . 'themes/blue_grey_theme.php';
$theme[17]['NAME'] = 'Blue Grey';
$theme[18]['PATH'] = SM_PATH . 'themes/dompie_theme.php';
$theme[18]['NAME'] = 'Dompie';
$theme[19]['PATH'] = SM_PATH . 'themes/methodical_theme.php';
$theme[19]['NAME'] = 'Methodical';
$theme[20]['PATH'] = SM_PATH . 'themes/greenhouse_effect.php';
$theme[20]['NAME'] = 'Greenhouse Effect (Changes)';
$theme[21]['PATH'] = SM_PATH . 'themes/in_the_pink.php';
$theme[21]['NAME'] = 'In The Pink (Changes)';
$theme[22]['PATH'] = SM_PATH . 'themes/kind_of_blue.php';
$theme[22]['NAME'] = 'Kind of Blue (Changes)';
$theme[23]['PATH'] = SM_PATH . 'themes/monostochastic.php';
$theme[23]['NAME'] = 'Monostochastic (Changes)';
$theme[24]['PATH'] = SM_PATH . 'themes/shades_of_grey.php';
$theme[24]['NAME'] = 'Shades of Grey (Changes)';
$theme[25]['PATH'] = SM_PATH . 'themes/spice_of_life.php';
$theme[25]['NAME'] = 'Spice of Life (Changes)';
$theme[26]['PATH'] = SM_PATH . 'themes/spice_of_life_lite.php';
$theme[26]['NAME'] = 'Spice of Life - Lite (Changes)';
$theme[27]['PATH'] = SM_PATH . 'themes/spice_of_life_dark.php';
$theme[27]['NAME'] = 'Spice of Life - Dark (Changes)';
$theme[28]['PATH'] = SM_PATH . 'themes/christmas.php';
$theme[28]['NAME'] = 'Holiday - Christmas';
$theme[29]['PATH'] = SM_PATH . 'themes/darkness.php';
$theme[29]['NAME'] = 'Darkness (Changes)';
$theme[30]['PATH'] = SM_PATH . 'themes/random.php';
$theme[30]['NAME'] = 'Random (Changes every login)';
$theme[31]['PATH'] = SM_PATH . 'themes/midnight.php';
$theme[31]['NAME'] = 'Midnight';
$theme[32]['PATH'] = SM_PATH . 'themes/alien_glow.php';
$theme[32]['NAME'] = 'Alien Glow';
$theme[33]['PATH'] = SM_PATH . 'themes/dark_green.php';
$theme[33]['NAME'] = 'Dark Green';
$theme[34]['PATH'] = SM_PATH . 'themes/penguin.php';
$theme[34]['NAME'] = 'Penguin';
$theme[35]['PATH'] = SM_PATH . 'themes/minimal_bw.php';
$theme[35]['NAME'] = 'Minimal BW';
$theme[36]['PATH'] = SM_PATH . 'themes/redmond.php';
$theme[36]['NAME'] = 'Redmond';

$default_use_javascript_addr_book = false;
$addrbook_dsn = '';
$addrbook_table = 'address';

$prefs_dsn = '';
$prefs_table = 'userprefs';
$prefs_user_field = 'user';
$prefs_key_field = 'prefkey';
$prefs_val_field = 'prefval';
$no_list_for_subscribe = false;
$smtp_auth_mech = 'none';
$imap_auth_mech = 'login';
$use_imap_tls = false;
$use_smtp_tls = false;
$session_name = 'SQMSESSID';

@include SM_PATH . 'config/config_local.php';

/**
* Make sure there are no characters after the PHP closing
* tag below (including newline characters and whitespace).
* Otherwise, that character will cause the headers to be
* sent and regular output to begin, which will majorly screw
* things up when we try to send more headers later.
*/
?> 


Snmp Em Php Ou Algo Do Genero

20/05/2011, 09:33

Ola Turminha Tudo beleza?

Alguem pode me dar uma Ajudinha???
Estou programando um Sistema em PHP que exibe informações sobre Portas,
Arquivos Listados no HD, a porta do Servidor.... mas precisa rodar no Windows.

Por que, ja achei códigos em PHP sobre isso, só que para linux.

Abraços

Gerenciador De Notas. Super Basico

21/03/2011, 12:25

Olá Galera?

Vamos ver nosso Primeiro Programa em C / C++

Código: GerenciadorNotas1.C
    /* Biblioteca de comandos usados na Lingagem C/C++ */
#include <stdio.h>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    /* Armazenador de Variaveis tipo: Float */
    float nota1, nota2, nota3, nota4, media;
    printf("Exiba a Nota 1: ");
    scanf("%f",&nota1);
    printf("Exiba a Nota 2: ");
    scanf("%f",&nota2);
    printf("Exiba a Nota 3: ");
    scanf("%f",&nota3);
    printf("Exiba a Nota 4: ");
    scanf("%f",&nota4);
    
    /* Calculando.... as Notas Digitadas */
    media=(nota1+nota2+nota3+nota4)/4;
    /* Notas Digitadas Sendo Exibidas */
    printf("Notas 1: %f \n",nota1);
    printf("Notas 2: %f \n",nota2);
    printf("Notas 3: %f \n",nota3);
    printf("Notas 4: %f \n",nota4);

    /* Exibindo a Media final após o Calculo da Media */
    printf("Sua Media Final e: %f \n",media);
    
    system("PAUSE");
    return EXIT_SUCCESS;
}


Boa Sorte!!

Abraços Waterboy

Primeira Aplicação Java.

21/03/2011, 12:16

Ola Galera!!

Código: JavaApplication.java
import javax.swing.JFrame;

public class JavaApplication extends JFrame {

  public Main()
  {
    super ("Minha JavaApplication 1.0");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(270,200);
    this.setVisible(true);
  }

  public static void main(String args[]) {

     new Main();
  }


}


Boa sorte a todos!!

abraços Waterboy

IPB Skin By Virteq