PDA

View Full Version : Well, yeah it's me.


lulzury
07-30-2008, 04:32 AM
Hi, well some of you may know me.
I registered here to maybe get some help from Zok and others on my PHP.

Anyways, what happened to that cellphone script your wrote Zok?
I wanted to take a look at it. I want to write a script that will explode certain strings from an email and post them in my website.

btw, getting the hang of PHP.

Zok
07-30-2008, 11:07 PM
#!/usr/bin/env perl -w

use Mail::POP3Client;
use IO::Socket::SSL;
use Email::MIME::Attachment::Stripper;
use DBI;
use strict;

# GMAIL INFO:
my $username = 'you@gmail.com'; # edit this
my $password = 'your_pass'; # edit this

my $mailhost = 'pop.gmail.com';
my $port = '995';
my $time = time();

my $pop = new Mail::POP3Client( USER => $username,
PASSWORD => $password,
HOST => $mailhost,
PORT => $port,
USESSL => 'true',
DEBUG => 0,
);
if (($pop->Count()) < 1) {
print "No mail at $time\n";
exit;
}

# SQL INFO:
my $database = "database_name";
$port = "3306"; # overwrite
$password = "database_password"; # overwrite
$username = "database_username"; # overwrite
my $dsn = "DBI:mysql:database=$database;host=localhost;port=$ port";
my $dbh = DBI->connect($dsn,$username,$password);
for(my $i = 1; $i <= $pop->Count(); $i++) {
my $message = $pop->HeadAndBody($i);

my $stripper = Email::MIME::Attachment::Stripper->new($message);

my $msg = $stripper->message;
my @attachments = $stripper->attachments;
my $filename = $attachments[0]{ 'filename' };
if(!$filename =~ /jpg/) { exit; }
my $out = "/path_to_photos/pics/" . $filename;
open OUT, ">$out" or die "cannot open the file yo: $!";
print OUT $attachments[0]{ 'payload' };
close OUT;
system("convert /path_to_photos/pics/$filename -resize 640x480 /path_to_photos/pics/thumb_$filename");
my $q = "INSERT INTO `otg` (`date`,`filename`) VALUES ('$time','$filename')";
my $sth = $dbh->prepare($q);
$sth->execute();
}
$pop->Close();
exit;

lulzury
07-31-2008, 02:48 AM
#!/usr/bin/env perl -w

use Mail::POP3Client;
use IO::Socket::SSL;
use Email::MIME::Attachment::Stripper;
use DBI;
use strict;

SHORTENED

Thank you man! I'll see what I can do.