Location: PHPKode > projects > Akasha > akasha/message_view.php
<?

if ($akashaID == $ID) {

	include ("includes/global.inc"); 		// Global Variables
	include ("includes/functions.inc"); 	// Global Functions
	include ("includes/head.inc"); 			// Standard Headers
	include ("stylesheets/homestyle.inc"); 	// Stylesheets

	$mime_encoding = array (0 => "7bit", "7bit" => 0,
                        1 => "8bit", "8bit" => 1,
                        2 => "binary", "binary" => 2,
                        3 => "base64", "base64" => 3,
                        4 => "quoted-printable", "quoted-printable" => 4,
                        5 => "unknown", "unknown" => 5
                       );


  $username =  getUsername($ID);
  $password = getPassword($ID);


    $mbox = imap_open("{".$domain."/pop3:110}INBOX", "$username", "$password");
    $header=imap_header($mbox,$message_id);
    $date=ereg_replace(" ","&nbsp;", date("Y M d - H:i",$header->udate));
    $htmlfrom	=htmlspecialchars(decode_mime_string($header->fromaddress));
    $mysubject	= decode_mime_string($header->subject);
    $mysubject	= htmlspecialchars($mysubject);
    if ($mysubject == "") {
    	$mysubject = "No Subject";
    }
    $htmlto		=htmlspecialchars(decode_mime_string($header->toaddress));
    $htmlreplyto	=htmlspecialchars(decode_mime_string($header->reply_toaddress));
    $htmlcc		=htmlspecialchars(decode_mime_string($header->ccaddress));

  	include ("includes/javascripts.inc"); 			// Javascripts

  echo "</head>\n";
  echo "<body bgcolor='#FFFFFF' text='#000000' link='#3457A9' vlink='#3457A9' alink='#009966'>\n";
  echo "<table width='100%' border='0' cellspacing='0' cellpadding='0' height='200'>\n";
  echo "  <tr>\n";
  echo "    <td valign='top' width='812' align='left'>\n";

  	$mailadress = getUserMailAdress($ID);	
  	$username =  getUsername($ID);
  	$password = getPassword($ID);

 	$postakutusu_adi = "Inbox";
  echo "			<table width='100%' border='0' cellspacing='0' cellpadding='0'>\n";
  echo "        <tr bgcolor='#D1D1D1'>\n";
  echo "          <td><b><font color='#304167'><i>$mysubject</i></font></b></td>\n";

  $mboxstatus=imap_check($mbox);
  $messagecount=$mboxstatus->Nmsgs;
  echo "          <td align='right'><b><font color='#304167'><i>Message No: $message_id / $messagecount</i></font></b></td>\n";
  echo "        </tr>\n";
  echo "			</table>\n";

  echo "      <br>\n";
  echo "      <form method='post' action='message_process.php' name='mesajlar' onSubmit='submitonce(this)'>\n";
  echo "				<input type='hidden' name='ID' value='$ID'>\n";
  echo "				<input type='hidden' name='mbox_id' value='$mbox_id'>\n";
  echo "				<input type='hidden' name='top' value='$top'>\n";
	$chk=array();
  echo "				<input type='hidden' name='chk[0]' value='$message_id'>\n";
  echo "        <table width='100%' border='0' cellspacing='2' cellpadding='0' class='stil9'>\n";
  echo "          <tr align='right'>\n";
  echo "            <td>\n";
  echo "              <table width='100%' border='0' cellspacing='0' cellpadding='0'>\n";
  echo "                <tr>\n";

  $prevmessage = $message_id -1;
  $nextmessage = $message_id + 1;
  if ($message_id == $messagecount) {
  	if ($message_id != 1) {
  		echo "                  <td valign='bottom'><a href='message_view.php?ID=$ID&message_id=$prevmessage&mbox_id=inbox' class='stil8'><img src='images/previous.gif' border='0'>previous message</a></td>\n";
  	}
  } else {
  	if ($message_id == 1) {
  		echo "                  <td valign='bottom'><a href='message_view.php?ID=$ID&message_id=$nextmessage&mbox_id=inbox' class='stil8'>next message<img src='images/next.gif' border='0'></a></td>\n";
  	} else {
  		echo "                  <td valign='bottom'><a href='message_view.php?ID=$ID&message_id=$prevmessage&mbox_id=inbox' class='stil8'><img src='images/previous.gif' border='0'>previous message</a> | <a href='message_view.php?ID=$ID&message_id=$nextmessage&mbox_id=inbox' class='stil8'>next message<img src='images/next.gif' border='0'></td></a>\n";
  	}
  }
  echo "                  <td align='right'>Move this message to \n";
  echo "                    <select name='slcmbox'>\n";
  $user_id = findUserByHash($ID);

  $query = "select mbox_id,mbox_tip,mboxname from tblMailBoxes where user_id = $user_id";
  $result = mysql_db_query("$dbname",$query);
  if($result) {
  	while ($r = mysql_fetch_array($result)) {
   		$mbox_idX = $r["mbox_id"];
   		$mbox_tip = $r["mbox_tip"];
   		$mboxname = $r["mboxname"];

  		if ($mbox_tip != 1) {
    		if ($mbox_tip == 2) {
      	 	echo " 	            <option value='$mbox_idX' selected>$mboxname</option>\n";
     		} else {
        	echo " 	            <option value='$mbox_idX'>$mboxname</option>\n";
     		}
  		}
   	}
  }
  echo "                    </select>\n";
  echo "              		</td><td width='5%' valign='middle'>\n";
  echo "                    <input type='image' src='images/ok.gif' width='25' height='25'align='middle'>\n";
  echo "                  </td>\n";
  echo "                </tr>\n";
  echo "              </table>\n";
  echo "            </td>\n";
  echo "          </tr>\n";
  echo "          \n";
  echo "          <tr>\n";
  echo "            <td width='18%' nowrap bgcolor='#D1D1D1'>\n";
  echo "              <table width='100%' border='0' cellspacing='0' cellpadding='1' bgcolor='#B6B6B6'>\n";
  echo "                <tr>\n";
  echo "                  <td>\n";
  echo "                    <table width='100%' border='0' cellspacing='0' cellpadding='1'>\n";
  echo "                      <tr bgcolor='#DFDFDF'>\n";
  echo "                        <td width='13%' align='left' nowrap><b><font color='#4E4E4E'>Subject</font></b></td>\n";
  echo "                        <td width='1%' align='center' nowrap><b><font color='#4E4E4E'>:</font></b></td>\n";
  echo "                        <td width='86%' nowrap>$mysubject</td>\n";
  echo "                      </tr>\n";
  echo "                      <tr bgcolor='#DFDFDF'>\n";
  echo "                        <td width='13%' align='left' nowrap><b><font color='#4E4E4E'>Date</font></b></td>\n";
  echo "                        <td width='1%' align='center' nowrap><b><font color='#4E4E4E'>:</font></b></td>\n";
  echo "                        <td width='86%' nowrap>$date</td>\n";
  echo "                      </tr>\n";
  echo "                      <tr bgcolor='#DFDFDF'>\n";
  echo "                        <td width='13%' align='left'><b><font color='#4E4E4E'>From</font></b></td>\n";
  echo "                        <td width='1%' align='center'><b><font color='#4E4E4E'>:</font></b></td>\n";
  echo "                        <td width='86%'>$htmlfrom</td>\n";
  echo "                      </tr>\n";
  echo "                      <tr bgcolor='#DFDFDF'>\n";
  echo "                        <td width='13%' align='left'><b><font color='#4E4E4E'>To</font></b></td>\n";
  echo "                        <td width='1%' align='center'><b><font color='#4E4E4E'>:</font></b></td>\n";
  echo "                        <td width='86%'>$htmlto</td>\n";
  echo "                      </tr>\n";
  if (strlen($htmlcc) > 0) {
    echo "                      <tr bgcolor='#DFDFDF'>\n";
    echo "                        <td width='13%' align='left'><b><font color='#4E4E4E'>CC</font></b></td>\n";
    echo "                        <td width='1%' align='center'><b><font color='#4E4E4E'>:</font></b></td>\n";
    echo "                        <td width='86%'>$htmlcc</td>\n";
    echo "                      </tr>\n";
  }

  $structure=imap_fetchstructure($mbox,$message_id);
  $c=count($structure->parts);
  if ($c<=1 ) {
  	$attachyok = 1;
  }

  if ($attachyok == 0) {
    echo "                      <tr bgcolor='#DFDFDF'>\n";
    echo "                        <td width='13%' align='left' valign='top'><b><font color='#4E4E4E'>Attachments</font></b></td>\n";
    echo "                        <td width='1%' align='center' valign='top'><b><font color='#4E4E4E'>:</font></b></td>\n";
    echo "                        <td width='86%'>\n";
  }

  $start=0;

  $structure=imap_fetchstructure($mbox,$message_id);				

  if (eregi("MIXED",$structure->subtype) )  {
  	$body   =imap_fetchbody($mbox,$message_id,1);
  	$fullheader	=imap_fetchheader($mbox,$message_id);
  	if (eregi("Content-Type: text/html",$fullheader) ) {
  		$showhtml=1;
  	} else {
  		$showhtml=0;
  	}
  	$start=1;
  }

  if (eregi("RELATED",$structure->subtype) )  {
  	$body   =imap_fetchbody($mbox,$message_id,1);
  	$showhtml=1;
  	$start=1;
  }

  if ( $start== 0) {
  	$fullheader	=imap_fetchheader($mbox,$message_id);
  	if ( eregi("Content-Type: text/html",$fullheader) ) {
  		$showhtml=1;
  	} else {
  		$showhtml=0;
  	}

  	$body	=imap_fetchbody($mbox,$message_id,1);
  	$start=0;
  }

  $messageencoding = 4;
  $messagepart=$structure->parts[0];
  $messageencoding=$messagepart->encoding;
  if ($messageencoding==3) {
  	$body = imap_base64($body);
  }

  if ($showhtml == 1) {
  	$htmlbody = htmlisle($body);
  } else {
    if ($messageencoding == 4) { 
      $qp = 1;
    } else {
      $qp = 0;	
    }
      $htmlbody=bodyIsle($body);
  }

  	$related = 0;
  	if (eregi("RELATED",$structure->subtype) ) {
  		$related = 1;
  	}
  	if (! eregi("MIXED",$structure->subtype) ) {
  		if ($related != 1) {
  		//	exit;
  		}
  	}

  	if ($attachyok == 0) {	
    	for ($i=$start; $i<$c; $i++) {
    		if ($i != $start){
    			echo "<br>\n";
    		}
    		$part0=$structure->parts[$i];

//     		if ( ! empty($part0->type) ) {
    			$part=$i+1;

    			$parameters=$part0->parameters;
    			$attach_type=$part0->subtype;
    			$mytype=$part0->type;
    			$encoding=$part0->encoding;
    			$text_encoding=$mime_encoding[$encoding];
    			
    			if (empty($text_encoding)) {
    				$text_encoding="unknown";
    			}

    			if (eregi("RFC822",$attach_type)) {
    				$att="RFC822 Message";
    				$val="message.txt";
    			} else {
    				$att=$parameters[0]->attribute;
    				$val=$parameters[0]->value;
    			}
    			
    			$val=eregi_replace(" ","_",$val);
    			$size=sprintf("%0.2f",$part0->bytes / 1024);
   				echo "										<a href='download.php?ID=$ID&message_id=$message_id&part=$part&encoding=$encoding&gercekisim=$val&mbox_id=inbox'>$val ($size K)</a>";					
//    		}
    	}
  	}

  if ($attachyok == 0) {
    echo "												</td>\n";
    echo "                      </tr>\n";
  }


  echo "                    </table>\n";
  echo "                    </td>\n";
  echo "                </tr>\n";
  echo "              </table>\n";
  echo "            </td>\n";
  echo "          </tr>\n";
  echo "          <tr align='right'>\n";

	$replysubject = "Re: $mysubject";
	$replysubject = rawurlencode($replysubject);
	$forwardsubject = "Fwd: $mysubject";
	$forwardsubject = rawurlencode($forwardsubject);
	$htmlto = rawurlencode($htmlto);
	$htmlto = rawurlencode($htmlto);
	$htmlfrom = rawurlencode($htmlfrom);

  echo "            <td nowrap bgcolor='#E3E7E8'><img src='images/reply.gif' width='16' height='17' border='0'> <a href='new_message.php?ID=$ID&to=$htmlfrom&message_id=$message_id&subject=$replysubject&db=2'> Reply to Author</a> | <img src='images/forward.gif' width='21' height='16' border='0'> <a href='new_message.php?ID=$ID&message_id=$message_id&subject=$forwardsubject&db=2'>Forward Message</a></td>\n";
  echo "          </tr>\n";
  echo "          <tr>\n";
  echo "            <td>\n";

  echo "							&nbsp;<br>";

	//$htmlbody = htmlspecialchars(stripslashes($htmlbody));
	$htmlbody = stripslashes($htmlbody);

  echo nl2br($htmlbody);
  echo "							&nbsp;<p>";
  echo "						</td>\n";
  echo "          </tr>\n";
  echo "          <tr align='right'>\n";
   $mysubject = str_replace(' ', '_', $mysubject);
  echo "            <td nowrap bgcolor='#DFDFDF'><img src='images/save.gif'> <a href='download.php?ID=$ID&message_id=$message_id&part=1&encoding=$messageencoding&mbox_id=inbox&gercekisim=$mysubject.txt'>Download Message</a> | <img src='images/print.gif'> <a href='javascript:printit()'>Print Message</a></td>\n";
  echo "          </tr>\n";
  echo "        </table>\n";
  echo "        <div align='right'></div>\n";
  echo "      </form>\n";
  echo "		</td>\n";
  echo "  </tr>\n";
  echo "</table>\n";

  imap_close($mbox);

  echo "</body>\n";
  echo "</html>\n";

} else {
		Header("Location: main.php?error_code=1");
}

?>
Return current item: Akasha