peterpan12345 Posted April 24, 2008 Share Posted April 24, 2008 <? function onpost($content){ $content = preg_replace( "`(http)+(s)?:(//)((\w|\.|\-|_)+)(/)?(\S+)?`i", "<a href=\"#\" onclick=\"window.open('http://\\0','','')\" onmouseover=\"window.status='\\0';return true\" onmouseout=\"window.status='';return true\">\\0</a>", $content); return $content; } ?> <? // http://www.phphulp.nl/php/scripts/2/237/ //show all errors, Very usefull while scripting. It shows al errors and warnings error_reporting(E_ALL); //include config.php for settings //If you doen't want to use it. please leave it blank. $mail_user_id = '[email protected]';//used for the script not your private mail or your ptivate mail will be inserted! //email password 'password'; $mail_password = '123456'; //database host $host = 'localhost';//often localhost //database name $database_name = 'db'; //database username $database_username = 'user'; //database password $database_password = 'pass'; //dateformat in database follow iso standaard $iso = 'Y-m-d H:i:s';//php 5 replace it for 'c' or keep it $filelocation = "/var/www/vhosts/globestar.nl/httpdocs/upload/"; mysql_select_db($databse_name,mysql_connect($host,$databse_username,$database_password)); //conect to mailserver //dit nog even aanpassen. Het werkt alleen als de mailserver op local host staat :/ en dat is niet iedeaal. if($mbox = imap_open("{localhost:143}INBOX",$mail_user_id,$mail_password)) { //check mail $mtnum = imap_num_msg($mbox); if($mtnum > 0){ //get trough all messages with a for loop. for($mnum = 1;$mnum <= $mtnum; $mnum++){ //fetch content due there is a change that this page has a multi header. (as text and image) imap_body($mbox,$mnum); doesn't work. $mcontent = imap_fetchbody($mbox,$mnum,1); //fetch headers $mheader = imap_headerinfo($mbox,$mnum); //replace the emil in header info //ereg ("/<(.*?)\>/si", $mheader->fromaddress, $regs); // match afzender emailadres binnen de <> en stop in $mheader->fromaddress preg_match("/<(.*?)\>/si", $mheader->fromaddress,$matches_q); if($matches_q[1] == ""){ $mheader->fromaddress = preg_replace("/<(.*?)\>/si", "", $mheader->fromaddress); } else { $mheader->fromaddress = $matches_q[1]; } //recive the structure of the email $mstructure = imap_fetchstructure($mbox,$mnum); //check this email has a mixed subtype. if($mstructure->subtype == 'MIXED') { //loop trough all parts of the email for($mpart = 1;!empty($mstructure->parts[$mpart]->dparameters[0]->value);$mpart++){ //revice any data from the attacment $mdata = imap_fetchbody($mbox,$mnum,$mpart + 1); //decode the 64 coded string to a string who could understood by PHP for creating the image form a string $mdecode = base64_decode($mdata); //create image from string. // string to file here // als een bestand is een image // $mimage = imagecreatefromstring($mdecode); $mfilename = $mstructure->parts[$mpart]->dparameters[0]->value; $mfilename = 'EEEMMMDDD.TXT'; // $output="hungry but too lazy to cook."; // $newfile="newfile.txt"; // file_put_contents($filelocation.$mfilename, $mdecode) ; //recive the size of the image. //getimagesize($mimage); doesn't work. $mwidth = imagesx($mimage); $mheigth = imagesy($mimage); //check max size; //resize the image. if($photow < $mwidth){ $mprop = $photow / $mwidth; $mnewwidth = $photow; $mnewheight = $mheigth * $mprop; $mnewheight = round($mnewheight); $mnewimage = imagecreatetruecolor($mnewwidth, $mnewheight); imagecopyresampled($mnewimage, $mimage, 0, 0, 0, 0, $mnewwidth, $mnewheight, $mwidth, $mheigth); //check if the image name allready exist if true delete the older one if(file_exists($filelocation.$mfilename)){ unlink($filelocation.$mfilename); } //only gif, jpg,jpeg and png are suported corectly. if(($mstructure->parts[$mpart]->subtype == 'jpg') or ($mstructure->parts[$mpart]->subtype == 'jpeg')){ //create a jpeg file. imagejpeg($mnewimage,$filelocation.$mfilename); }else{ //create a png/gif file. In GD 1.6 or higer imagegif isn't supproted imagepng($mnewimage,$filelocation.$mfilename); } }else{ if(file_exists($filelocation.$mfilename)){ unlink($filelocation.$mfilename); } //only gif, jpg,jpeg and png are suported if(($mstructure->parts[$mpart]->subtype == 'jpg') or ($mstructure->parts[$mpart]->subtype == 'jpeg')){ imagejpeg($mimage,$filelocation.$mfilename); }else{ imagepng($mimage,$filelocation.$mfilename); } } //ubbcode: Replace * for a [ (Ubb phrasesr suxs here ^^) $mcontent.='[img=http://'.$domain.$filelocation.$mfilename.']\n'; imagedestroy($mimage); } } //insert in database //make your own database query //echo date($iso, strtotime($mheader->date))."DATE<BR>"; //echo $mheader->subject."Subject<BR>"; //echo onpost($mcontent)."Content<BR>"; //echo $mheader->fromaddress."From<BR>"; //echo $mheader->emailaddres."Email<BR>"; $sql = "INSERT INTO `".$database_name."` (`subject`,`date`,`content`,`author`) VALUES ('".$mheader->subject."','".date($iso, strtotime($mheader->date))."','".mysql_real_escape_string($mcontent)."','".$mheader->fromaddress."')"; echo $sql."<br>"; mysql_query($sql); ?> (edited by kenrbnsn to add tags) Link to comment https://forums.phpfreaks.com/topic/102705-please-help-me-with-this-php-code-my-programming-is-not-that-good-to-solve-it/ Share on other sites More sharing options...
trq Posted April 24, 2008 Share Posted April 24, 2008 Do you have an actual question? Link to comment https://forums.phpfreaks.com/topic/102705-please-help-me-with-this-php-code-my-programming-is-not-that-good-to-solve-it/#findComment-525937 Share on other sites More sharing options...
PFMaBiSmAd Posted April 24, 2008 Share Posted April 24, 2008 What ever the question is, he posted it 4 times. Link to comment https://forums.phpfreaks.com/topic/102705-please-help-me-with-this-php-code-my-programming-is-not-that-good-to-solve-it/#findComment-525940 Share on other sites More sharing options...
trq Posted April 24, 2008 Share Posted April 24, 2008 What ever the question is, he posted it 4 times. I know, I removed three of them. Link to comment https://forums.phpfreaks.com/topic/102705-please-help-me-with-this-php-code-my-programming-is-not-that-good-to-solve-it/#findComment-525944 Share on other sites More sharing options...
bilis_money Posted April 24, 2008 Share Posted April 24, 2008 cuz his first timer. you need patience guys... Link to comment https://forums.phpfreaks.com/topic/102705-please-help-me-with-this-php-code-my-programming-is-not-that-good-to-solve-it/#findComment-525965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.