Jump to content


  • Content count

  • Joined

  • Last visited

  • Days Won


Everything posted by dsonesuk

  1. 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. } } ?>
  2. 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.
  3. 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
  4. W3 Cards Responsive Center Align

    I had a hard job loading on desktop, god knows what it will be like for smaller devices. All these cards use float left, they won't centre while float: left; is used.
  5. How to get an iframe with no borders ?

    Get rid misplaced '}', double quote after width. Height with percentage value unit won't work, it has to be unit of 'px' or 'vh'.
  6. meaning of *{

  7. meaning of *{

    Universal selector for all element whatever they are.
  8. margin-right in my body

    First off, don't use container class on body, without it it will be 100% width, by default, also don't use deprecated center tags. If you want a element to be full width use container-fluid class, these container classes have padding either side of 15px, with a .row class within them, which has a -15px margin either side it will make this .row container same width as .container class, but! content will not go beyond padding. IF you don't use .container classes without this padding and you use row class, because it does not have the same padding width to counteract -15px margin, these margin will extend beyond the 100% container width, larger than the browser width, so scrollbars will appear. So like I mentioned before, use bootstrap as intended container classes outside, .row classes inside, OR create custommized .gutterless class (not part of bootstrap) .gutterless, .gutterless > .row { margin: 0; padding: 0; } element texto-h2, and div elements without any class or container class with direct child elements using .row are the problem.
  9. margin-right in my body

    If you use width: 100% on block elements with margin or padding, the total width will be 100% of parent element available width + margin and padding of this element. Without access to this site, there's not much more we can suggest.
  10. How to position elements correctly

    ??????????? 1) row1 one column 2) row2 three columns 3) row3 two columns Using margins, float or display: block/inline-block
  11. margin-right in my body

    Its a 15px padding and margin gutter, on each side, if you do not follow the way bootstrap uses these correctly spaces will appear because -15px margins make container wider than intended. The other option is to produce a '.gutterless' class specifically for removing these when required.
  12. STRANGE !!! update table td select !!!!

    For innerhtml to work it requires the element to have opening and closing tags <div>...</div>, most inputs don't have that, ALL inputs should use .value anyway.
  13. Either one will work, its used to insert a text element to help vetically align the popup content box as it need something to align to, this also uses display: inline-block so it acts as text would with text-align and vertical-align, you can change to top/bottom whatever.
  14. https://www.w3schools.com/code/tryit.asp?filename=FNKT1I1OB9M4
  15. Multiply File Upload

    Because its not an image, its an array of images, you need to setup a foreach loop to get each image file foreach ($_FILES["fileToUpload"]["name"] as $index => $imageFile) { $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"][$index]); ... } Every $_FILES["fileToUpload"]["?????"] within foreach loop has to end with [$index] as shown above, this tell it what image in the array is being processed.
  16. Breaking a line of text in the middle

    If you use <br> to set breaks and use media queries to change to display: none or initial depending on device width
  17. The trouble is, these simple email options are open to abuse from hackers and spam bots, if you think that won't be a problem you'd be wrong! you WILL receive 100s of spam emails. Without proper validation and sterilization, with addition of some sort of reCAPTCHA forcing user to identify that they are human, by selecting a image or type specific text before submitting takes place.
  18. You require a server that uses a server language script (PHP, ASP.net) to process and send the email. For PHP its a short display of minimum required https://www.w3schools.com/php/func_mail_mail.asp OR if you wish to use default email program from users device https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_mail
  19. Put id reference value in quotes, as it is now its treating liste as undefined variable.
  20. Showing one div element on hover of another?

    You can't do that! As Cascading in Cascading Style Sheet (css) means it cascades down from parent to children or sibling to below sibling elements. it never goes up. Only with JS can that be done; The space between ':hover .text' means the element with class 'text' must be within element div with class 'buttonbottom' to cascade down to .buttonbottom:hover .text{display: none;} You can place these above .text element, adding padding-bottom:, and position: relative; to bottom of box class element to allow space for these elements, then add position: absolute; and bottom: property to these bottom buttons. this will position them to where they are now, even though they are above .test class element. Then use .buttonbottom:hover ~ .text{display: none;}
  21. The php session code should be at very top before ANY html including the doctype and there must be no spaces empty newlines above it <?php ob_start(); session_start(); ?> <!DOCTYPE html>
  22. How to format text in a Textarea?

    The OP doesn't mean font size, colour etc, he mean a LIST individual lines, that is copied to clipboard and when pasted to email remains as list of individual line, and not a big block of text.
  23. strange html decoding?

    This usually happens when the page or content produced is not UTF-8 encoded, have you set the charset? https://www.w3schools.com/tags/att_meta_charset.asp All these documents should be saved and produced using UTF-8 encoding, most web based editor do this automatically, notepad need to be specifically saved and mac text editor setting need changing to be used as html editor as UTF-8 encoded. If database driven, it should be set to use UTF-8 encoding by database and tables.
  24. Then you are looking to use cssText where you can use what you original posted cnv1.style.cssText = "z-index:2; position:relative;" cnv2.style.cssText = "z-index:1; position:relative;" OR cnv1.setAttribute("style", "z-index: 2; position:relative;"); cnv2.setAttribute("style", "z-index: 1; position:relative;"); using .style on it own as you originally had it adjust single properties one at a time, and these must be camelCase
  25. Links inside :after CSS

    To have the content: property work as a link it has to be placed within anchor link, most :hover :after should be transferred to this anchor element from li element see https://codepen.io/anon/pen/RxyPJE