Hallo!
Ich habe mir etwas in PHP geschriebe mit einer Klasse, die es schon gab, aber leider holt der vom body immer nur die erste zeile - aber wieso?
der code:
was könnte es sein?
Ich habe mir etwas in PHP geschriebe mit einer Klasse, die es schon gab, aber leider holt der vom body immer nur die erste zeile - aber wieso?
der code:
PHP-Code:
<?php
session_start();
// !!!!
$mails = array(); // unveraendert lassen!
// !!!
if ($_REQUEST['emplog']) $_SESSION['emplog'] = $_REQUEST['emplog'].'@********';
if (!$_SESSION['emplog']) die ('Keinen User gewählt!'); else echo $_SESSION['emplog'];
$mysql['host'] = 'localhost';
$mysql['user'] = 'root';
$mysql['pass'] = '********';
$mysql['db'] = '********';
mysql_connect ($mysql['host'], $mysql['user'], $mysql['pass']);
mysql_select_db ($mysql['db']);
$server = '********';
$port = '110';
$uname = '********';
$passwd = '********';
function pop_login () {
global $pop3, $auth, $error_msg, $count;
global $server, $port, $uname, $passwd;
# connect to the pop server
if ( ! $pop3->connect($server, $port) ) {
$error_msg .= sprintf("Failed to connect to POP server %s on port %s.<br><small>%s</small>", $auth->auth["server"], $auth->auth["port"], $pop3->ERROR);
}
# login to the POP server
$count = $pop3->apop($uname, $passwd);
if ( $count < 0 ) {
$error_msg .= "Failed to login to POP server<br><small>$pop3->ERROR</small>";
}
}
include(dirname(__FILE__)."/lib/poprepend.inc");
pop_login();
if ($_GET['del']) {
if ( $pop3->delete($_GET['del']) ) {
echo "gelöscht!";
$pop3->quit();
pop_login();
} else {
echo "<br>Failed to delete message number $id. <br><small>$pop3->ERROR</small>";
}
}
echo $error_msg;
for ( $i = 1; $i <= $count; $i++ ){
# get the size of this message
$size = $pop3->pop_list($i);
# get the headers and zero lines of body
$body_lines = 0;
// $header_array = $pop3->top($i, $body_lines);
$header_array = $pop3->get($i);
$show_msg = TRUE;
# reset header variables
$from = $subject = $date = " ";
# loop through the headers and look for the stuff
# we are interested in...
$in_body = 'false';
while ( list ($linenbr, $line) = each ($header_array) ) {
$body = '';
if ( eregi ("^From:(.*)", $line, $match) ) {
$from = trim ( $match[1] );
} elseif ( eregi ("^To:(.*)", $line, $match) ) {
$to = trim ( $match[1] );
} elseif ( (!$cc) and (eregi ("^cc:(.*)", $line, $match)) ) {
$cc = htmlentities(trim ( $match[1] ));
} elseif ( eregi ("^Subject:(.*)", $line, $match) ) {
$subject = trim ( $match[1] );
# skip pine generated internal messages
if ( ereg ("DON\'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA", $subject) ) {
$show_msg = FALSE;
}
} elseif ( eregi ("^Date:(.*)", $line, $match) ) {
$date = trim ( $match[1] );
//
// und hier die nächsten 2 elseif stimmt irgendwas nicht...
//
} elseif ( eregi ("^\r", $line) ) {
$in_body = true;
} elseif ( $in_body ) {
$body .= "<br>" . htmlentities($line);
}
} # for each line in the message header
if ( $show_msg && $to == $_SESSION['emplog']) {
$sql = "INSERT INTO `mails` (`from`,`to`,`subject`,`content`,`date`) VALUES ('".$from."','".$to."','".$subject."','".$body."','".$date."');";
if (mysql_query ($sql)) { /* $pop3->delete($i); */ echo '<b>Gepseichert:/b> '.$sql.'<br /><br />'; }
/*
$mails[] = array(FROM => $from,
TO => $to,
SUBJECT => $subject,
DATE => $date,
MSGNBR => $i,
MSGURL => 'msg.php3?id='.$i);
*/
}
} # for each message
$pop3->quit();
die();
?>
<table width="900" cellspacing=1 cellpadding=1 style="border-collapse: collapse;" bordercolor="#000000">
<tr bgcolor="#c0c0c0">
<td width="150">Absender</td>
<td width="150">Empfaenger</td>
<td width="150">Datum</td>
<td width="250">Betreff</td>
<td>Lesen</td>
<td>del</td>
</tr>
<?php
if (count($mails) > 0) {
for ($i=0;$i<count($mails);$i++) {
if ( eregi ("^(.*)<(.*)>", $mails[$i][FROM], $match) ) {
if ($match[1])
{
$mails[$i][FROM] = trim($match[2]);
}
}
echo '<tr>
<td>'.htmlspecialchars(str_replace(array("<", ">"), "", $mails[$i][FROM])).'</td>
<td>'.htmlspecialchars(str_replace(array("<", ">"), "", $mails[$i][TO])).'</td>
<td>'.substr($mails[$i][DATE], 0, 22).'</td>
<td>'.$mails[$i][SUBJECT].'</td>
<td>'.$mails[$i][MSGURL].'</td>
<td><a href="?del='.$mails[$i][MSGNBR].'">'.$mails[$i][MSGNBR].'</a></td>
</tr>';
}
} else echo '<tr><td colspan="4">Keine Nachrichten vorhanden!</td></tr>';
?>
</table>
Kommentar