Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once("init.php");
- $ld = mysql_query("SELECT max(idm) as idm FROM email limit 1");
- $lid = mysql_fetch_object($ld);
- $last_id = (int)$lid->idm;
- $mailbox = '***';
- $username = '***';
- $password = '***';
- $encryption = 'ssl'; // or ssl or ''
- // open connection
- $imap = new Imap($mailbox, $username, $password, $encryption);
- // stop on error
- if($imap->isConnected()==false) die($imap->getError());
- $imap->selectFolder('INBOX');
- $emails = $imap->getMessages();
- //new dbug($emails);
- foreach ($emails as $key => $x) {
- $mid = (int)$x["uid"]-1;
- //if ($mid>$last_id)
- if (1==1)
- {
- $titulek = $x["subject"];
- $cdatum = $x["date"];
- $rd = explode(",", $cdatum);
- $rdx = $rd[1];
- $date = date_create($rdx);
- $datum = date_format($date, 'd.m.Y');
- $text = $x["body"];
- echo $dec = mb_detect_encoding($text);
- //echo iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $text);
- echo iconv('cp1250', "UTF-8//IGNORE", $text);
- $text = str_replace("'", "", $text);
- $text = strip_tags($text, '<br><a><b><i><u>');
- //$text = mysql_real_escape_string($text);
- $autor = $x["from"];
- if (isset($x["attachments"]))
- {
- $count_att = count($x["attachments"]);
- if ($count_att>0)
- {
- include_once("news_att.php");
- for ($i=0;$i<$count_att;$i++)
- {
- $name = $x["attachments"][$i]["name"];
- $size = $x["attachments"][$i]["size"];
- mysql_query("INSERT INTO email_files (idm,nazev,velikost) VALUES($mid,'$name','$size')");
- }
- }
- unset($x["attachments"]);
- }
- //use encoding;
- //use encoding.php
- // $utf8_string = Encoding::toUTF8($text);
- echo $text;
- $save = "INSERT INTO email (idm,autor,predmet,text) VALUES($mid,'$autor','$titulek','$text')";
- //$save = mysql_query("INSERT INTO email (idm,autor,predmet,text) VALUES($mid,'$autor','$titulek','$text')");
- /*
- $result = mysql_query($save);
- if (!$result) {
- die('Invalid query: ' . mysql_error());
- }
- */
- }
- echo "<hr>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement