Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. PHP error

    Dear my editor used is vi de linux
  3. Yesterday
  4. PHP error

    Gotcha on that open { BTW, I've seen editors that have a hot key that auto formats pasted code. is that what you used? if so, which editor do you use? if not, returning manually formatted code is above and beyond. either way, great work. let me know about your editor. thx again dsonesuk
  5. PHP error

    <?php $now = time(); // current time $mailbox = '{your-mailserver-here/imap/novalidate-cert}INBOX'; // see http://www.php.net/manual/en/function.imap-open.php $mbox = imap_open($mailbox, 'email-address-here', 'password-here'); // log in to mail server if (!$mbox) echo ('Failed opening mailbox<br>' . print_r(imap_errors(), true)); // remove the print_r for production use else { $box = imap_check($mbox); // get the inbox for ($imap_idx = 1; $imap_idx <= $box->Nmsgs; $imap_idx++) { // loop through the messages $headers = imap_headerinfo($mbox, $imap_idx); // http://www.php.net/manual/en/function.imap-headerinfo.php $raw_headers = imap_fetchheader($mbox, $imap_idx); // http://www.php.net/manual/en/function.imap-fetchheader.php $selected_headers = ''; $text_part = ''; $html_part = ''; $original_message = imap_body($mbox, $imap_idx); // save the copy of the entire thing, attachments and all // build selected headers string for ($ii = 0; $ii < count($headers->from); $ii++) $selected_headers .= 'From: ' . $headers->from[$ii]->mailbox . '@' . $headers->from[$ii]->host . "\n"; for ($ii = 0; $ii < count($headers->to); $ii++) $selected_headers .= 'To: ' . $headers->to[$ii]->mailbox . '@' . $headers->to[$ii]->host . "\n"; for ($ii = 0; $ii < count($headers->cc); $ii++) $selected_headers .= 'Cc: ' . $headers->cc[$ii]->mailbox . '@' . $headers->cc[$ii]->host . "\n"; for ($ii = 0; $ii < count($headers->bcc); $ii++) $selected_headers .= 'Bcc: ' . $headers->bcc[$ii]->mailbox . '@' . $headers->bcc[$ii]->host . "\n"; if (!empty($headers->date)) $selected_headers .= 'Date: ' . $headers->date . "\n"; if (!empty($headers->subject)) $selected_headers .= 'Subject: ' . $headers->subject . "\n"; // see below; getMsg uses global variables getMsg($mbox, $imap_idx); $text_part = $plainmsg; // text portion of the email $html_part = $htmlmsg; // html portion of the email // check for text portion first $msg_text = trim(strip_tags($plainmsg, '<a>')); if ($msg_text == '') { // text portion is empty, check html portion $msg_text = trim($htmlmsg); if ($msg_text == '') { // no text or html portion auto-detected, check manually $msg_text = imap_body($mbox, $imap_idx); // get the entire raw message // check for quoted-printable encoding with possible boundary markers and headers at the top $chunks = explode("\n", trim($msg_text)); if (count($chunks) > 1) { // if there are multiple lines $quoted_printable = false; if (strpos($chunks[0], '--') === 0) { // if the first line is a boundary marker (starts with '--') array_shift($chunks); // remove the first line if (strpos($chunks[count($chunks) - 1], '--') === 0) { // check the last line array_pop($chunks); // remove that too } } if (strpos(strtolower($chunks[0]), 'content-type') === 0) array_shift($chunks); // remove the first line if it's a content-type header if (strpos(strtolower($chunks[0]), 'content-transfer-encoding') === 0) { if (strpos(strtolower($chunks[0]), 'quoted-printable')) $quoted_printable = true; // this email was sent using quoted-printable encoding array_shift($chunks); // remove the content-transfer-encoding header } $msg_text = implode("\n", $chunks); // put the remaining lines back together if ($quoted_printable) $msg_text = quoted_printable_decode($msg_text); $msg_text = utf8_decode($msg_text); } } } $from = trim($headers->from[0]->mailbox . '@' . $headers->from[0]->host); $msgId = isset($headers->message_id) ? trim($headers->message_id) : ''; $time = strtotime($headers->date); if ($time == 0) $time = $now; /* * **************************************************** At this point: $headers: the object returned from imap_headerinfo $selected_headers: text of some headers to display to a user checking mail (subject, from, etc) $text_part: the text portion, if found $html_part: the html portion, if found $msg_text: either the text part, html part, or manually-decoded part (this is the variable to use as email body) $original_message: the entire unprocessed email body, includingall parts and any attachments $from: From address $msgId: message ID from the headers $time: email delivery time, as a Unix timestamp $attachments: array of attachments (see below) ***************************************************** */ // process attachments foreach ($attachments as $filename => $data) { // e.g. file_put_contents('attachments/' . $filename, $data); } // flag the email for deletion imap_delete($mbox, $imap_idx); } // delete emails and close the mailbox imap_expunge($mbox); imap_close($mbox); } function getMsg($mbox, $mid) { // input $mbox = IMAP stream, $mid = message id // output all the following: global $htmlmsg, $plainmsg, $charset, $attachments; // the message may in $htmlmsg, $plainmsg, or both $htmlmsg = $plainmsg = $charset = ''; $attachments = array(); // HEADER $h = imap_header($mbox, $mid); // add code here to get date, from, to, cc, subject... // BODY $s = imap_fetchstructure($mbox, $mid); if (empty($s->parts)) // not multipart getMsgPart($mbox, $mid, $s, 0); // no part-number, so pass 0 else { // multipart: iterate through each part foreach ($s->parts as $partno0 => $p) getMsgPart($mbox, $mid, $p, $partno0 + 1); } } function getMsgPart($mbox, $mid, $p, $partno) { // $partno = '1', '2', '2.1', '2.1.3', etc if multipart, 0 if not multipart global $htmlmsg, $plainmsg, $charset, $attachments; // DECODE DATA $data = ($partno) ? imap_fetchbody($mbox, $mid, $partno) : // multipart imap_body($mbox, $mid); // not multipart // Any part may be encoded, even plain text messages, so check everything. if ($p->encoding == 4) $data = quoted_printable_decode($data); elseif ($p->encoding == 3) $data = base64_decode($data); // no need to decode 7-bit, 8-bit, or binary // PARAMETERS // get all parameters, like charset, filenames of attachments, etc. $params = array(); if ($p->ifparameters) foreach ($p->parameters as $x) $params[strtolower($x->attribute)] = $x->value; if ($p->ifdparameters) foreach ($p->dparameters as $x) $params[strtolower($x->attribute)] = $x->value; // ATTACHMENT // Any part with a filename is an attachment, // so an attached text file (type 0) is not mistaken as the message. if (!empty($params['filename']) || !empty($params['name'])) { // filename may be given as 'Filename' or 'Name' or both $filename = (!empty($params['filename'])) ? $params['filename'] : $params['name']; // filename may be encoded, so see imap_mime_header_decode() $attachments[$filename] = $data; // this is a problem if two files have same name } // TEXT elseif ($p->type == 0 && $data) { // Messages may be split in different parts because of inline attachments, // so append parts together with blank row. if ($p->ifsubtype && strtolower($p->subtype) == 'plain') $plainmsg .= trim($data) . "\n\n"; else $htmlmsg .= $data . "<br><br>"; $charset = $params['charset']; // assume all parts are same charset } // EMBEDDED MESSAGE // Many bounce notifications embed the original message as type 2, // but AOL uses type 1 (multipart), which is not handled here. // There are no PHP functions to parse embedded messages, // so this just appends the raw source to the main message. elseif ($p->type == 2 && $data) { $plainmsg .= trim($data) . "\n\n"; } // SUBPART RECURSION if (!empty($p->parts)) { foreach ($p->parts as $partno0 => $p2) getMsgPart($mbox, $mid, $p2, $partno . '.' . ($partno0 + 1)); // 1.2, 1.2.1, etc. } } ?>
  6. PHP error

  7. PHP error

    No! it highlights error caused by missing '{' saying unexpected elseif, and suggest possible syntax error with preceding error '{'. which turns out to be correct, so working way down I found '}' embedded in comment.
  8. PHP error

    wouldn't have got that. thx dsonesuk EDIT Does your text editor have a function to test for an open curly bracket?
  9. PHP error

    its a comment should have // at beginning; This // assume all parts are same charset } // EMBEDDED MESSAGE the curly bracket at end is part of elseif condition should be // assume all parts are same charset } // EMBEDDED MESSAGE
  10. PHP error

    looks like you need a ; at the end of this line: $mbox = IMAP stream, $mid = message id
  11. PHP error

  12. PHP error

    <?php $now = time(); // current time $mailbox = '{your-mailserver-here/imap/novalidate-cert}INBOX'; // see http://www.php.net/manual/en/function.imap-open.php $mbox = imap_open($mailbox, 'email-address-here', 'password-here'); // log in to mail server if (!$mbox) echo ('Failed opening mailbox<br>' . print_r(imap_errors(), true)); // remove the print_r for production use else{ $box = imap_check($mbox); // get the inbox for ($imap_idx = 1; $imap_idx <= $box->Nmsgs; $imap_idx++) // loop through the messages { $headers = imap_headerinfo($mbox, $imap_idx); // http://www.php.net/manual/en/function.imap-headerinfo.php $raw_headers = imap_fetchheader($mbox, $imap_idx); // http://www.php.net/manual/en/function.imap-fetchheader.php $selected_headers = ''; $text_part = ''; $html_part = ''; $original_message = imap_body($mbox, $imap_idx); // save the copy of the entire thing, attachments and all // build selected headers string for ($ii = 0; $ii < count($headers->from); $ii++) $selected_headers .= 'From: ' . $headers->from[$ii]->mailbox . '@' . $headers->from[$ii]->host . "\n"; for ($ii = 0; $ii < count($headers->to); $ii++) $selected_headers .= 'To: ' . $headers->to[$ii]->mailbox . '@' . $headers->to[$ii]->host . "\n"; for ($ii = 0; $ii < count($headers->cc); $ii++) $selected_headers .= 'Cc: ' . $headers->cc[$ii]->mailbox . '@' . $headers->cc[$ii]->host . "\n"; for ($ii = 0; $ii < count($headers->bcc); $ii++) $selected_headers .= 'Bcc: ' . $headers->bcc[$ii]->mailbox . '@' . $headers->bcc[$ii]->host . "\n"; if (!empty($headers->date)) $selected_headers .= 'Date: ' . $headers->date . "\n"; if (!empty($headers->subject)) $selected_headers .= 'Subject: ' . $headers->subject . "\n"; // see below; getMsg uses global variables getMsg($mbox, $imap_idx); $text_part = $plainmsg; // text portion of the email $html_part = $htmlmsg; // html portion of the email // check for text portion first $msg_text = trim(strip_tags($plainmsg, '<a>')); if ($msg_text == '') { // text portion is empty, check html portion $msg_text = trim($htmlmsg); if ($msg_text == '') { // no text or html portion auto-detected, check manually $msg_text = imap_body($mbox, $imap_idx); // get the entire raw message // check for quoted-printable encoding with possible boundary markers and headers at the top $chunks = explode("\n", trim($msg_text)); if (count($chunks) > 1) // if there are multiple lines { $quoted_printable = false; if (strpos($chunks[0], '--') === 0) // if the first line is a boundary marker (starts with '--') { array_shift($chunks); // remove the first line if (strpos($chunks[count($chunks) - 1], '--') === 0) // check the last line { array_pop($chunks); // remove that too } } if (strpos(strtolower($chunks[0]), 'content-type') === 0) array_shift($chunks); // remove the first line if it's a content-type header if (strpos(strtolower($chunks[0]), 'content-transfer-encoding') === 0) { if (strpos(strtolower($chunks[0]), 'quoted-printable')) $quoted_printable = true; // this email was sent using quoted-printable encoding array_shift($chunks); // remove the content-transfer-encoding header } $msg_text = implode("\n", $chunks); // put the remaining lines back together if ($quoted_printable) $msg_text = quoted_printable_decode($msg_text); $msg_text = utf8_decode($msg_text); } } } $from = trim($headers->from[0]->mailbox . '@' . $headers->from[0]->host); $msgId = isset($headers->message_id) ? trim($headers->message_id) : ''; $time = strtotime($headers->date); if ($time == 0) $time = $now; /****************************************************** At this point: $headers: the object returned from imap_headerinfo $selected_headers: text of some headers to display to a user checking mail (subject, from, etc) $text_part: the text portion, if found $html_part: the html portion, if found $msg_text: either the text part, html part, or manually-decoded part (this is the variable to use as email body) $original_message: the entire unprocessed email body, includingall parts and any attachments $from: From address $msgId: message ID from the headers $time: email delivery time, as a Unix timestamp $attachments: array of attachments (see below) ******************************************************/ // process attachments foreach ($attachments as $filename => $data) { // e.g. file_put_contents('attachments/' . $filename, $data); } // flag the email for deletion imap_delete($mbox, $imap_idx); } // delete emails and close the mailbox imap_expunge($mbox); imap_close($mbox);}function getMsg($mbox,$mid) { // input $mbox = IMAP stream, $mid = message id // output all the following: global $htmlmsg,$plainmsg,$charset,$attachments; // the message may in $htmlmsg, $plainmsg, or both $htmlmsg = $plainmsg = $charset = ''; $attachments = array(); // HEADER $h = imap_header($mbox,$mid); // add code here to get date, from, to, cc, subject... // BODY $s = imap_fetchstructure($mbox,$mid); if (empty($s->parts)) // not multipart getMsgPart($mbox,$mid,$s,0); // no part-number, so pass 0 else { // multipart: iterate through each part foreach ($s->parts as $partno0=>$p) getMsgPart($mbox,$mid,$p,$partno0+1); }}function getMsgPart($mbox,$mid,$p,$partno) { // $partno = '1', '2', '2.1', '2.1.3', etc if multipart, 0 if not multipart global $htmlmsg,$plainmsg,$charset,$attachments; // DECODE DATA $data = ($partno)? imap_fetchbody($mbox,$mid,$partno): // multipart imap_body($mbox,$mid); // not multipart // Any part may be encoded, even plain text messages, so check everything. if ($p->encoding==4) $data = quoted_printable_decode($data); elseif ($p->encoding==3) $data = base64_decode($data); // no need to decode 7-bit, 8-bit, or binary // PARAMETERS // get all parameters, like charset, filenames of attachments, etc. $params = array(); if ($p->ifparameters) foreach ($p->parameters as $x) $params[ strtolower( $x->attribute ) ] = $x->value; if ($p->ifdparameters) foreach ($p->dparameters as $x) $params[ strtolower( $x->attribute ) ] = $x->value; // ATTACHMENT // Any part with a filename is an attachment, // so an attached text file (type 0) is not mistaken as the message. if (!empty($params['filename']) || !empty($params['name'])) { // filename may be given as 'Filename' or 'Name' or both $filename = (!empty($params['filename']))? $params['filename'] : $params['name']; // filename may be encoded, so see imap_mime_header_decode() $attachments[$filename] = $data; // this is a problem if two files have same name } // TEXT elseif ($p->type==0 && $data) { // Messages may be split in different parts because of inline attachments, // so append parts together with blank row. if ($p->ifsubtype && strtolower($p->subtype)=='plain') $plainmsg .= trim($data) ."\n\n"; else $htmlmsg .= $data ."<br><br>"; $charset = $params['charset']; // assume all parts are same charset } // EMBEDDED MESSAGE // Many bounce notifications embed the original message as type 2, // but AOL uses type 1 (multipart), which is not handled here. // There are no PHP functions to parse embedded messages, // so this just appends the raw source to the main message. elseif ($p->type==2 && $data) { $plainmsg .= trim($data) ."\n\n"; } // SUBPART RECURSION if (!empty($p->parts)) { foreach ($p->parts as $partno0=>$p2) getMsgPart($mbox,$mid,$p2,$partno.'.'.($partno0+1)); // 1.2, 1.2.1, etc. }} ?>
  13. PHP error

    pls post with the code tags <>
  14. PHP error

    email2mysql.php
  15. PHP error

    ok email2mysql.php
  16. PHP error

    might as well post your code so we can see what's actually on line 73
  17. PHP error

    Dear because when executing email2mysql.php file taken from URL http://w3schools.invisionzone.com/topic/41225-get-contents-from-e-mail-and-write-it-to-mysql-table appears Parse error: syntax error, unexpected 'stream' (T_STRING) in email2mysql.php on line 73 thank you very much for your help
  18. How to add Search function to this?

    nobody can help?
  19. getting max value in php

    great! i got the point and this solved my problem. thank you.
  20. I have resized an image to fit inside a canvas without any problems. However, now I need to resize a canvas without resizing the image that it contains. How do I do this? Thank You
  21. How site's admin manage their site ?

    Hey there thanks for the response.If u don't mind can u please show some real site's (i mean not example) CMS design/UI looks
  22. Last week
  23. How to get an iframe with no borders ?

    Thanks , got rid of '}' & width "" : Width is working fine now . How come this page can use html { height: 100%; https://www.w3schools.com/cssref/tryit.asp?filename=trycss_dim_height_percent Also , on same page they are showing Resize values . Theoretically , could I likewise calculate a Resize value , then plug this absolute value into "td height: value" ? ? Also , I am using css .thumb:hover, .thumb:hover span { . It works fine when not using <iframe . But when I use <iframe , instead the hover object and <img show up side by side . Is there a way to get hover working ? Thanks
  24. Ingolme:  I have a posting on the css area.  Would you take a look at for me.

    Thanks in advance

    ohsnyder

  25. How site's admin manage their site ?

    Everybody uses a CMS. The only difference is whether the CMS is created by a third party (like Wordpress) or is custom built by the same team that owns the website.
  26. getting max value in php

    $highmark is a string. Do not implode $highmarks.
  27. w3.css form to the php action page

    Try using value ="some data" instead of placeholder. value =" ' . <?php $var ?> . ' " or value =" ' . <?php $var['columnName'] ?> . ' " depending on situation if I'm understanding your question
  28. w3.css form to the php action page

    I am trying to use the example contact form in the w3-ccs examples. The submit form processes but there is no data sent with the form. Can some one set me on the right path on how to get the data into php processing page? php process code: <?php $EmailFrom = "email@greengardensdesign.com"; $EmailTo = "email@greengardensdesign.com"; $Subject = "Possible New Job"; $Name = Trim(stripslashes($_POST['Name'])); $Address = Trim(stripslashes($_POST['Address'])); $City = Trim(stripslashes($_POST['City'])); $Email = Trim(stripslashes($_POST['Email'])); $Phone = Trim(stripslashes($_POST['Phone'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Address: "; $Body .= $Address; $Body .= "\n"; $Body .= "City: "; $Body .= $City; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Phone: "; $Body .= $Phone; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> input form code: <form action="/contactengine.php" method="post" class="w3-container w3-card-4 w3-light-grey w3-text-blue w3-margin"> <h2 class="w3-center">Contact Us</h2> <div class="w3-row w3-section"> <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-user"></i></div> <div class="w3-rest"> <input class="w3-input w3-border" name="Name" type="text" placeholder="Full Name"> </div> </div> <div class="w3-row w3-section"> <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-car"></i></div> <div class="w3-rest"> <input class="w3-input w3-border" name="Address" type="text" placeholder="Street Address"> </div> </div> <div class="w3-row w3-section"> <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-car"></i></div> <div class="w3-rest"> <input class="w3-input w3-border" name="City" type="text" placeholder="City and State"> </div> </div> <div class="w3-row w3-section"> <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-envelope-o"></i></div> <div class="w3-rest"> <input class="w3-input w3-border" name="Email" type="text" placeholder="Email"> </div> </div> <div class="w3-row w3-section"> <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-phone"></i></div> <div class="w3-rest"> <input class="w3-input w3-border" name="Phone" type="text" placeholder="Phone"> </div> </div> <div class="w3-row w3-section"> <div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-pencil"></i></div> <div class="w3-rest"> <input class="w3-input w3-border" name="Message" type="text" placeholder="Message"> </div> </div> <button class="w3-button w3-block w3-section w3-blue w3-ripple w3-padding">Send</button> </form>
  1. Load more activity
×