Uma das últimas dele. Ansioso demais pra que ele venha logo ao mundo!
Agora, o bico é da mamãe! kkkkkkkkk
Uma das últimas dele. Ansioso demais pra que ele venha logo ao mundo!
Agora, o bico é da mamãe! kkkkkkkkk
Many people have posted about this before, but exactly because is a basic matter, is good to post my opinion on this subject.
About 4 years ago, I had to create a PHP code to send e-mail, but may lack of know how made me forget to make the mail function to work out. Besides, not everytime you can make such fixes on your server. This lead me to create the mail using sockets and sending commands to the smtp server of my preference.
In that time, hotmail, yahoo and gmail allowed the use of the smtp commands by telnet without worries. They hadn’t implemented at all the security protocols, like ssl or tls. That’s a good thing they had implemented security, of course. But,… and programming? What’s the difference now?
You cant say that the old code will still work out fine. It really can’t! if you try the correct commands on the telnet, all you’ll get is the client disconnection on the 3rd command sent to server. Fortunately, PEAR have a implementation of the SMTP protocol and have everything there to be used.
To install the package on your development machine, just type on the console (as a root if you are on linux)
Then its just to use some code like the one below:
require_once 'Mail.php';
class MyMail{
private $to;
private $from;
private $subject = "Testando envio autenticado pelo Google";
private $body = "Teste efetuado com sucesso!";
private $host = "ssl://smtp.gmail.com";
private $port = 25;
private $username;
private $password;
public function getTo(){
return $this->to;
}
public function setTo($t){
$this->to = $t;
}
public function getFrom(){
return $this->from;
}
public function setFrom($f){
$this->from = $f;
}
public function getSubject(){
return $this->subject;
}
public function setSubject($s){
$this->subject = $s;
}
public function getBody(){
return $this->body;
}
public function setBody($b){
$this->body = $b;
}
public function getHost(){
return $this->host;
}
public function setHost($h){
$this->host = $h;
}
public function getPort(){
return $this->port;
}
public function setPort($p){
$this->port = $p;
}
public function getUsername(){
return $this->username;
}
public function setUsername($un){
$this->username = $un;
}
public function getPassword(){
return $this->password;
}
public function setPassword($p){
$this->password = $p;
}
public function send(){
$headers = array ('From' => $this->getFrom(),
'To' => $this->getTo(),
'Subject' => $this->getSubject());
$smtp = Mail::factory("smtp", array ('host' => $this->getHost(),
'port' => $this->getPort(), // SMTPS(para mais detalhes ver /etc/services
'auth' => true,
'debug' => true, // Debug ligado
'username' => $this->getUsername(),
'password' => $this->getPassword())
);
$rc = $smtp->send($this->;to, $headers, $this->body);
if(PEAR::isError($rc)){
echo("<h1>Error " . $rc->getMessage(). "</h1>");
} else {
echo("Email enviado com sucesso!!");
}
}
}
It’s a preliminary class, so, many enhancements can be made to make the class better, but it just works as expected. Example to use? see below:
if(isset($_POST)){
require_once 'MyMail.class.php';
$ms = new MyMail();
$ms->setFrom('me@gmail.com');
$ms->setTo('noone@gmail.com');
$ms->setHost('smtp.google.com');
$ms->setPort('25');
$ms->setUsername('me@gmail.com');
$ms->setPassword('p@ssw0rd');
$ms->setBody('Test Message using PHP');
$ms->setSubject('Test');
$ms->send();
}
This will produce the following stream to be sent to the server:
DEBUG: Recv: 220 mx.google.com ESMTP 23sm733843qyk.3 DEBUG: Send: EHLO localhost DEBUG: Recv: 250-mx.google.com at your service, [189.70.93.58] DEBUG: Recv: 250-SIZE 35651584 DEBUG: Recv: 250-8BITMIME DEBUG: Recv: 250-STARTTLS DEBUG: Recv: 250-ENHANCEDSTATUSCODES DEBUG: Recv: 250 PIPELINING DEBUG: Send: STARTTLS DEBUG: Recv: 220 2.0.0 Ready to start TLS DEBUG: Send: EHLO localhost DEBUG: Recv: 250-mx.google.com at your service, [189.70.93.58] DEBUG: Recv: 250-SIZE 35651584 DEBUG: Recv: 250-8BITMIME DEBUG: Recv: 250-AUTH LOGIN PLAIN DEBUG: Recv: 250-ENHANCEDSTATUSCODES DEBUG: Recv: 250 PIPELINING DEBUG: Send: AUTH LOGIN DEBUG: Recv: 334 VXNlcm5hbWU6 DEBUG: Send: ZmFiaW8uY2VzYXIubWVkZWlyb3NAZ21haWwuY29t DEBUG: Recv: 334 UGFzc3dvcmQ6 DEBUG: Send: ZG1hdGRtYXQwMQ== DEBUG: Recv: 235 2.7.0 Accepted DEBUG: Send: MAIL FROM:<sender-mail@gmail.com> DEBUG: Recv: 250 2.1.0 OK 23sm733843qyk.3 DEBUG: Send: RCPT TO:<receiver-email@gmail.com> DEBUG: Recv: 250 2.1.5 OK 23sm733843qyk.3 DEBUG: Send: DATA DEBUG: Recv: 354 Go ahead 23sm733843qyk.3 DEBUG: Send: From: sender-email@gmail.com To: receiver-email@gmail.com Subject: Teste de e-mail Teste de E-mail via Sockets . DEBUG: Recv: 250 2.0.0 OK 1256749304 23sm733843qyk.3 DEBUG: Send: QUIT DEBUG: Recv: 221 2.0.0 closing connection 23sm733843qyk.3
Today on twitter, @lauromoura has tweet a report about a Windows 7 failure. See the link:
http://seclists.org/fulldisclosure/2009/Sep/0039.html
Worth to see, what Steve Ballmer said on Vista’s release and the press opinions: here.
Fact: no Windows (and no Operating System) will be totally secure. It’s all just a matter of time.
Well, It’s just one more tip. Microsoft has been releasing some Training Kits for the technologies that are running on market today. I’ve found some of them and the links are below:
Some day I’ll have time to study some of them.
Enjoy!
Today I went to review the SQL Server 2008 enhancements on XML support. To test the queries on AdventureWorks, the first thing I needed to know was: “Where are the XML data columns?”
I don’t actually have the graphic on the database model to search for and wasn’t on the mood to create the database diagram to search visually for the XML columns.
Then, I’ve got the idea of searching on the catalog for that. It should be simple to do (and it was!) but worth the post, as many people may have the need to use the same thing, not only on AdventureWorks, but on large (I mean many tables) databases:
Here is the script:
SELECT t.name, c.name, ty.name
FROM sys.tables t INNER JOIN sys.columns c ON
(t.object_id = c.object_id)
INNER JOIN sys.systypes ty ON
(c.system_type_id = ty.xtype)
WHERE ty.name = ‘xml’
With this script, you can create a procedure that returns the table name and the column name that uses a type that’s passed by a parameter. Or even create a PowerShell function to achieve this. Let’s see the latter:
param([string] $typeName, [string] $server, [string] $database)
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection "server=$server;database=$database;Integrated Security=sspi"
$sqlConnection.Open()
$sqlCommand = $sqlConnection.CreateCommand()
$sqlCommand.CommandText = "SELECT t.name [Table], c.name [Column]
FROM sys.tables t INNER JOIN sys.columns c
ON (t.object_id = c.object_id)
INNER JOIN sys.systypes ty
ON (c.system_type_id = ty.xtype)
WHERE ty.name = ‘$typename ‘"
$sqlReader = $sqlCommand.ExecuteReader()
$dataTable = New-Object System.Data.DataTable
$dataTable.Load($sqlReader);
$sqlConnection.Close()
Write-Output $dataTable
Interesting, huh?
Bem, um pouquinho tarde, mas enfim, passei nesse sábado na prova 70-431: Microsoft SQL Server 2005 – Implementation and Maintenance, inaugurando a minha intenção de me especializar em banco de dados.
A prova é composta de duas partes, uma com 35 questões objetivas, e outra com 12 questões de simulação. A parte objetiva é bem tradicional, e pelo menos as questões que foram selecionadas na minha prova foram bem distribuídas nos assuntos. Houveram questões de XML, de desenvolvimento com CLR, backup/restore, … acho que só não caiu de Service Broker. Na parte prática, tive sorte e das 12 questões, 4 foram sobre backup/restore (para configurar um backup de acordo com algumas características pedidas).
Agora é estudar pra atualizar pra MCTS: SQL Server 2008!
Yeah testers, the new Windows has just been released for testing. It’s avaliable here.
Microsoft recommends that you don’t upgrade from beta to RC, but reinstall from scratch.
Enjoy it! Test it!
Este vai ser um post sobre um tema introdutório para administradores de banco de dados. Uma tarefa comum que deve ser realizada de tempos em tempos e pela sua importância, é importante que ocorra com frequência, para que se tenha segurança com relação a algum desastre que possa acontecer… ninguém sabe quando um erro pode ocorrer, ou quando os dados podem ficar corrompidos, por esse ou aquele motivo.
Dentro do SQL Server 2008, os backups podem ser feitos de algumas formas:
Apesar de usarmos as extensões bak e trn, não há obrigatoriedade dessas extensões, sendo somente uma boa prática as que foram usadas nos exemplos.
No SQL Server 2008 foi introduzida uma novidade que é a compressão de backup. Por default este é um recurso que está desativado. Para poder usar como um recurso padrão para todos os backups, primeiro é preciso reconfigurar a base de dados, com:
sp_configure ‘backup compression default’, 1;
go
reconfigure;
Com isso, habilitamos no servidor a compressão de backup por default, o que significa que todo banco de dados terá backups comprimidos. Foi então adicionada a query de backup a opção do with COMPRESSION ou NO_COMPRESSION, para que se possa escolher na query se se deseja um backup comprimido ou não.
Além destas formas, também é possível usar a simples estratégia de Attach/Detach que é extremamente conveniente, quando se pode deixar o banco off-line por algum tempo.
[1] White Paper sobre compressão de backup no SQL Server 2008
[2] Backing Up and Restoring How-to Topics
[3] Copy-Only Backups
[4] Full Database Backups
[5] Differential Database Backups
There are two easy ways to do this. The SQL Server, have two procedures, sp_who and sp_who2 that solves this problem. Syntax:
sp_who 'loginname'
The sp_who procedure shows information about the actual users, sessions and process in a instance of SQL Server. Can be executed without parameters, and returns info about all users and sessions and processes.
The sp_who2 procedure show the same information that sp_who shows (and works the same way too), but adds the cpu time and disk io consumption on the result.
Another way is use the query below, you can retrieve the same information (in less detail) from the sysprocesses system view.
SELECT DB_NAME(dbid) as [database]
[login_time],
[open_tran],
[nt_username]
[hostname],
[program_name]
FROM master..sysProcesses
With the launch of Windows Vista SP1 giving some significant fixes on performance issues on the operating system, Microsoft tries to take off the slow adjective from the mouth of users who tried Windows Vista.
Personally, SP1 really had improved performance, but much more can be done to take it better.
Below is a round table with Microsoft specialists, that’s very interesting to understand what can be done to take the performance of day-to-day operations better.
Springboard Series Virtual Roundtable: Windows Vista Performance