Ross Hulford wrote: > Her is the code (not mine) what I am trying to so is cut out all the > header > info that is included in the message as shown here > http://supercool-74.com/sms/liveticker.php Granted, it's 5 hours later, but I'm not seeing anything much at that URL... > The message is supposed to be terminated by the "xx" string which is > defined > in config.php but it just continues and prints all the header info too. I'm confused by your placement of header info and rest of message... Since the headers come FIRST, I don't quite understand why you are having problems with it printing headers info *after* the content... So I'll comment on the parts of code that I *do* understand, and maybe push you in the right direction for something anyway. ------------------------------------------------------------------------------------- > <?php > > include ("config.php"); > > $mbox = imap_open ("{".$pop3_server."/pop3:110}INBOX",$mailbox,$password); You are usually better off using IMAP instead of POP when possible. > $headers = imap_headers ($mbox); > $max = count($headers); > > include ("head.php"); > > echo "<table border=\"0\" cellspacing=\"30\" cellpadding=\"0\">\n"; > > for ($i = $max; $i > 0; $i--) > > { > > $header = imap_header ($mbox,$i); > $from = $header->from; > $email = $from[0]->mailbox."@".$from[0]->host; Hmmm. I'm assuming this is correct, that $header->from is an array? And that's already all torn apart into ->mailbox and ->host elements? Seems to me you might be able to get this more clearly somehow from the $header structure, but maybe that's just the way it is.... > $date = $header->date; > $date = split(" ",$date); Might as well use http://php.net/explode if you're not going to use the power of RegEx. > $structure = imap_fetchstructure ($mbox,$i); > $encoding = $structure->encoding; > > if ($endword) > { > $end = strpos(imap_body ($mbox,$i),$endword); > } > > if ($startword) > { > $beginning = ereg($startword,imap_body ($mbox,$i)); > $start = strpos(imap_body ($mbox,$i),$startword); > if ($end) Here's your FIRST big problem that is probably actually related to what you are asking about. $end could *easily* have been 0 (the integer) if $endword appeared at the very *beginning* of the imap_body($mbox, $i) expression. Now maybe that "never" happens in the real world with your data, but it's really better to use if ($end !== FALSE) here to make sure you don't get in the Bad Habit of confusing 0 and FALSE results from strpos(). > { > $body = substr(imap_body > ($mbox,$i),$start+strlen($startword),$end-$start-strlen($endword)); > } > else > { > $body = substr(imap_body ($mbox,$i),$start+strlen($startword)); > } > } You are calling image_body($mbox, $i) several times in here. It would probably be better to do $body = imap_body($mbox, $i) early on, and then just use $body. It may be more natural, if $end === FALSE, to set $end to strlen($body) at that point, and then just have one call to substr() to get the portion of the $body you want. > else > { > $beginning = true; > > if ($end) > { > $body = substr(imap_body ($mbox,$i),0,$end); > } > else > { > $body = imap_body ($mbox,$i); > } > } So now I'm very confused about your beginning, end, start, body, and substr() calls, because I have NO IDEA what you are doing at this point... A cleaner structure, IMHO would be: $body = imap_body($mbox, $i); //Find the end of the section we want: $endpos = strlen($body); //Whole thing, by default if (strlen($endword)){ $endpos = strpos($body, $endword); if ($endpos === FALSE) $endpos = strlen($body); } //Find the beginning of the section we want: $startpos = 0; //Whole thing, by default: if (strlen($startword)){ $startpos = strpos($body, $startword); if ($startpos === FALSE) $startpos = 0; else{ $startpos += strlen($startword); //Don't include $startword in result } } //Now get the section defined by $startpos, $endpos: $body = substr($body, $startpos, $endpos); If you are *still* not getting what you think you should, use: echo "<HR><PRE>Original: '", imap_body($mbox, $i), "'\nStart: '$startword' $startpos\nEnd: '$endword' $endpos\nBody: '$body'</PRE><HR>\n"; here to figure out why. Pay close attention to what's inside the ''s in that output, such as newlines and spaces, which are the usual things to trip you up in this kind of work. > if (in_array ($email,$allowed_senders) && $beginning) > { > if ($date[1] == "1"){$date[1]="01";} > elseif ($date[1] == "2"){$date[1]="02";} > elseif ($date[1] == "3"){$date[1]="03";} > elseif ($date[1] == "4"){$date[1]="04";} > elseif ($date[1] == "5"){$date[1]="05";} > elseif ($date[1] == "6"){$date[1]="06";} > elseif ($date[1] == "7"){$date[1]="07";} > elseif ($date[1] == "8"){$date[1]="08";} > elseif ($date[1] == "9"){$date[1]="09";} Is is just silly. Use something like: $date_1 = sprintf('%02s', $date[1]); > if ($date[2] == "Jan"){$date[2]="01";} > elseif ($date[2] == "Feb"){$date[2]="02";} > elseif ($date[2] == "Mar"){$date[2]="03";} > elseif ($date[2] == "Apr"){$date[2]="04";} > elseif ($date[2] == "May"){$date[2]="05";} > elseif ($date[2] == "Jun"){$date[2]="06";} > elseif ($date[2] == "Jul"){$date[2]="07";} > elseif ($date[2] == "Aug"){$date[2]="08";} > elseif ($date[2] == "Sep"){$date[2]="09";} > elseif ($date[2] == "Oct"){$date[2]="10";} > elseif ($date[2] == "Nov"){$date[2]="11";} > elseif ($date[2] == "Dec"){$date[2]="12";} Try this: $monthnames = array(1=>'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); $months = arrayflip($monthnames); $date_2 = sprintf('%02s', $date[2]); > // Decode quoted printable and base64 encoding and coding HTML special > charakters > > if ($encoding == 4) > { > $body = htmlentities(quoted_printable_decode($body), ENT_QUOTES); > } > elseif ($encoding == 3) > { > $body = htmlentities(base64_decode($body), ENT_QUOTES); > } > else > { > $body = htmlentities($body, ENT_QUOTES); > } > > // Line breaks > > $body = eregi_replace("\*br","\n<br>",$body); Whoa! abracadbra just turned into a bunch of line breaks. So did Brazil. And any other word with 'br' in it. Plus, "\*br" is not really kosher PHP string, is it? You should have "\\*br" > echo "<tr>\n"; > echo "<td nowrap valign=\"top\"><b>".$date[0]." > ".$date[1].".".$date[2].".".$date[3]."<br>\n".$date[4]."</b></td>\n"; > echo "<td valign=\"top\">+++ ".$body." +++</td>\n</tr>\n"; Why did you do all that work for the '01' instead of $date[1] if you're not going to use it? > $beginning = false; So you switch $beginning back and forth from true to false... Why? Are you using it somewhere I'm not seeing? > } > } > > echo "</table>\n"; > > > > // Copyright reference must not be removed: > > ?> > > <table border="0" cellspacing="0" cellpadding="0"> > <tr> > <td width="50"> </td> > <td> </td> > </tr> > </table> > > <?php > > imap_close ($mbox); > > // Link to admin page > > echo "<p> </p>"; > echo "<p><a href=\"admin.php\">=> Admin</a></p>"; > > include ("foot.htm"); -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php