MMS upload script

Started on the old forum in November 2009 · view the original in the archive · old links redirect here

6 replies · 810 views · started 17 years ago · 1 min read

5 participants
davidjmorin Newbie · 4 posts #1

Hey all. This is a basic question i know but how do i do the following? Maybe point me to a tutorial

have email mobile@site.com

have sql 5.0 have php5.0

what i want is to have folder /upload have a script that checks email every 5 min for new images and deletes them once loaded into /upload folder. also have ability to comment and rate.

maybe there is a readymade script sorry to bother. still very new to PHP

metulj Super moderator Principal · 1,726 posts #2

davidjmorin wrote: Hey all. This is a basic question i know but how do i do the following? Maybe point me to a tutorial

have email mobile@site.com

have sql 5.0 have php5.0

what i want is to have folder /upload have a script that checks email every 5 min for new images and deletes them once loaded into /upload folder. also have ability to comment and rate.

maybe there is a readymade script sorry to bother. still very new to PHP

does your server support CRON JOB? but keep in mind... checking every 5 minutes, will piss off server owner...

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

strikingv Developer · 70 posts #3

if no corn job is supported u will have to do it ourself. IE create a php file with the codes n visit it every 5 minutes 😛

Anshul Senior · 296 posts #4

davidjmorin wrote: Hey all. This is a basic question i know but how do i do the following? Maybe point me to a tutorial

have email mobile@site.com

have sql 5.0 have php5.0

what i want is to have folder /upload have a script that checks email every 5 min for new images and deletes them once loaded into /upload folder. also have ability to comment and rate.

maybe there is a readymade script sorry to bother. still very new to PHP

there is script uploaded by gumslone like this or search for kmx forum in it u wil get the upload.php it is wat u want 🙂

subzero Super moderator Fellow · 3,954 posts #5

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

davidjmorin Newbie · 4 posts #6

metulj wrote: does your server support CRON JOB? but keep in mind... checking every 5 minutes, will piss off server owner...

I do have cron available.

what would i need to do this with godaddy?

davidjmorin Newbie · 4 posts #7

i really have no idea how to have a php file check my email and then parse the email for images then post to a webfolder. I have a script that reads a folder with images and then creates the gallery which is working. but the script that checks email is not.

this is my script for checking email. the image folder is like this on my system /html/net/photoblog/images

<?php
$cfg = array();
######## CONFIG #######
$cfg['upload_dir'] = 'images'; //what directory to upload images to 
$cfg['mail_server'] = 'email.secureserver.net'; //email server 
$cfg['mail_port'] = '110'; //email server port
 
/* email server services as described on http://php.net/imap_open */ 
$cfg['mail_services'] = '/pop3';
 
$cfg['mail_username'] = 'mobile@blackberrypinpal.com'; //username for the email address to check 
$cfg['mail_password'] = '**********'; //password for above user $cfg['debug'] = false; //true or false for debugging
 
/* Accepted File Types: if less than four characters, use a dot as the first char. */ 
$cfg['accepted'] = array('.3g2','.png','.jpg','.jpe','jpeg','.gif');
######## END CONFIG #########
 
$pid=2;
 
$type = array('text', 'multipart', 'message', 'application', 'audio', 'image', 'video', 'other'); $encoding = array('7bit', '8bit', 'binary', 'base64', 'quoted-printable', 'other');
 
if(!is_dir($cfg['upload_dir'])) {
  @mkdir($cfg['upload_dir']) or die('Cannot create directory:
'.$cfg['upload_dir'].'! Make sure the parent folder has write permissions'); }
 
// open POP connection
$inbox = @imap_open
('{'.$cfg['mail_server'].':'.$cfg['mail_port'].$cfg['mail_services'].'}',
$cfg['mail_username'], $cfg['mail_password']) or die('Connection to server failed.');
 
// parse message body
function parse($structure) {
global $type;
global $encoding;
 
// create an array to hold message sections $ret = array();
 
// split structure into parts
$parts = $structure->parts;
 
 for($x=0; $x<sizeof($parts); $x++) {
  $ret[$x]['pid'] = ($x+1);
  $that = $parts[$x];
 
// default to text
  if ($that->type == '') {
   $that->type = 0;
  }
  $ret[$x]['type'] = $type[$that->type] . '/' . strtolower($that->subtype);
 
// default to 7bit
  if ($that->encoding == '') {
   $that->encoding = 0;
  }
 
  $ret[$x]['encoding'] = $encoding[$that->encoding];
  $ret[$x]['size'] = strtolower($that->bytes);
  $ret[$x]['disposition'] = strtolower($that->disposition);
 
  if ($that->ifparameters == 1) {
   $params = $that->parameters;
 
   foreach ($params as $p) {
    if($p->attribute == 'NAME') {
     $ret[$x]['name'] = $p->value;
     break;
    }
   }
  }
 }
 return $ret;
}
 
function get_attachments($arr) {
 for($x=0; $x < sizeof($arr); $x++) {
  if($arr[$x]['disposition'] == 'attachment') {
   $ret[] = $arr[$x];
  }
 }
 return $ret;
}
 
$count = @imap_num_msg($inbox) or die('No Messages in mailbox!'); //echo 'count: ' . $count;
 
// get message headers and structure
for ($c = 1; $c <= $count; $c++) {
 $id = $c;
 $headers = imap_header($inbox, $id);
 $structure = imap_fetchstructure($inbox, $id);
 
// if multipart, parse
 if(sizeof($structure->parts) > 1) {
  $sections = parse($structure);
  $attachments = get_attachments($sections);  }
 
if ($cfg['debug']) {
 echo 'Structure of message: ' . $id . '<BR><pre>';  print_r($structure);  echo '</pre><BR>';  echo 'Sections of message: ' . $id . '<BR><pre>';  print_r($sections);  echo '</pre><BR>'; }
 
// look for specified part
 for($x=0; $x<sizeof($sections); $x++) {
  if($sections[$x]['pid'] == $pid) {
    $dtype = $sections[$x]['type'];
    $dencoding = $sections[$x]['encoding'];
    $filename = $sections[$x]['name'];
  }
 }
 
if ($cfg['debug']) {
 echo ' type: ' . $dtype . '<BR>';
 echo 'encoding: ' . $dencoding . '<BR>';  echo 'filename: ' . $filename . '<BR>';  echo ' id: ' . $id . '<BR><BR>'; }
 
$attachment = imap_fetchbody($inbox, $id, $pid);
 
if (!$cfg['debug']) {
 
 //if (in_array(substr($filename, -4), $cfg['accepted'])) {
  if ($dencoding == 'base64') {
  // Decode and save attachment to a file
   list($usec, $sec) = explode(' ', microtime());
   $usec = substr($usec,2,3);
   $name = date('Ymd.His');
   $fp=fopen($cfg['upload_dir'].'/'.$name.'_'.$filename,'w');
   fwrite($fp,imap_base64($attachment));
   fclose($fp);
  }
 //}
}
 
}
 
if (!$cfg['debug']) {
// delete all emails
for ($i = 1; $i <= $count; $i++) {
imap_delete($inbox, $i);
}
imap_expunge($inbox);
}
 
imap_close($inbox);
 
if (!$cfg['debug']) {
header('Location: '.$cfg['upload_dir']); } ?>

Now does my mail server have to be like i have it or like this: webmail.blackberrypinpal.com

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close