peterpan12345 Posted April 28, 2008 Share Posted April 28, 2008 Hello administrator, Sorry about the late reply that time. Thanks for asking and helping. For the code.. I have problems saving it to the directory i want. How to make this code save to the directory i want. Do help me, thanks. <? 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 = 'user@globestar.nl';//used for the script not your private mail or your ptivate mail will be inserted! //email password 'password'; $mail_password = '12345'; //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='.$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); Quote Link to comment Share on other sites More sharing options...
Steven8294 Posted April 28, 2008 Share Posted April 28, 2008 Well to save a file to a directory you want, its nothing to do with the code. Quote Link to comment Share on other sites More sharing options...
peterpan12345 Posted April 28, 2008 Author Share Posted April 28, 2008 a friend ask me to help him with the code. i am not good in php... is he trying to make fun of me with the code? what does this code do? please advise... thanks.. n does this code have errors? sorry. Quote Link to comment Share on other sites More sharing options...
Steven8294 Posted April 28, 2008 Share Posted April 28, 2008 Add me at steven8294@hotmail.co.uk Quote Link to comment Share on other sites More sharing options...
peterpan12345 Posted April 28, 2008 Author Share Posted April 28, 2008 hello administrator. is it possible to help me remove the company name from the code itself? thanks. i am not able to edit the post itself. sorry. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.