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

if ($akashaID == $ID) {

	include ("includes/global.inc"); 	// Global Variables
	include ("includes/functions.inc"); // Global Functions
	$user_id = findUserByHash($ID);

	$query = "select user_id from tblMessages where message_id=$message_id";
	$result = mysql_db_query("$dbname",$query);
  	if($result) {
		while ($r = mysql_fetch_array($result)) {
			$auth_user = $r["user_id"];
		}
	}

	if ($auth_user != $user_id) {
		Header("Location: main.php?error_code=1");		
	}

	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
                       );


	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);	

  	$query = "select count(*) from tblMessages where mbox_id = $mbox_id and user_id = $user_id";
  	$result = mysql_db_query("$dbname",$query);
  	if($result) {
		while ($r = mysql_fetch_array($result)) {
			$messagecount = $r["count(*)"];
		}
	}

  	$query = "select min(message_id) from tblMessages where mbox_id = $mbox_id and user_id = $user_id";
  	$result = mysql_db_query("$dbname",$query);
  	if($result) {
		while ($r = mysql_fetch_array($result)) {
			$minmessage = $r["min(message_id)"];
		}
	}

	$query = "select * from tblMessages where message_id=$message_id";
	$result = mysql_db_query("$dbname",$query);
	if($result) {
			while ($r = mysql_fetch_array($result)) {
				$htmlfrom = $r["header_from"];
				$htmlto = $r["header_to"];
				$htmlcc = $r["header_cc"];
				$htmlbcc = $r["header_bcc"];
				$htmlbody = $r["msg_body"];
				$mailbox_id = $r["mbox_id"];

				$mysubject = $r["header_subject"];
	  			if ( strlen($mysubject) <= 0 ) {
  					$mysubject="No Subject";
  				}
				$date = $r["header_date"];
			}
	}

  	echo "			<table width='100%' border='0' cellspacing='0' cellpadding='0'>\n";
  	echo "        <tr bgcolor='#2B3D61'>\n";
  	echo "          <td><b><font color='#DCD7CB'><i>$mysubject</i></font></b></td>\n";
  	echo "          <td align='right'><b><font color='#DCD7CB'><i>&nbsp;</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";

  	$query = "select min(message_id) from tblMessages where message_id > $message_id and user_id = $user_id and mbox_id = $mbox_id";
  	$result = mysql_db_query("$dbname",$query);
  	if($result) {
		while ($r = mysql_fetch_array($result)) {
			$nextmessage = $r["min(message_id)"];
		}
	}

  	$query = "select max(message_id) from tblMessages where message_id < $message_id and user_id = $user_id and mbox_id = $mbox_id";
  	$result = mysql_db_query("$dbname",$query);
  	if($result) {
		while ($r = mysql_fetch_array($result)) {
			$prevmessage = $r["max(message_id)"];
		}
	}

  	if ($nextmessage ==0) {
  		if ($prevmessage != 0) {
  			echo "                  <td valign='bottom'><a href='message_viewDB.php?ID=$ID&message_id=$prevmessage&mbox_id=$mbox_id' class='stil8'><img src='images/previous.gif' border='0'>previous message</a></td>\n";
  		}
  	} else {
  		if ($prevmessage == 0) {
  			echo "                  <td valign='bottom'><a href='message_viewDB.php?ID=$ID&message_id=$nextmessage&mbox_id=$mbox_id' class='stil8'>next message<img src='images/next.gif' border='0'></a></td>\n";
  		} else {
  			echo "                  <td valign='bottom'><a href='message_viewDB.php?ID=$ID&message_id=$prevmessage&mbox_id=$mbox_id' class='stil8'><img src='images/previous.gif' border='0'>previous message</a> | <a href='message_viewDB.php?ID=$ID&message_id=$nextmessage&mbox_id=$mbox_id' 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_idX != $mailbox_id) {
	  			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'>\n";
  	echo "                  </td>\n";
  	echo "                </tr>\n";
  	echo "              </table>\n";
  	echo "            </td>\n";
  	echo "          </tr>\n";
  	echo "          <tr>\n";
  	echo "            <td width='18%' nowrap>\n";
  	echo "              <table width='100%' border='1' cellspacing='0' cellpadding='1' bgcolor='#DCD7CB'>\n";
  	echo "                <tr>\n";
  	echo "                  <td>\n";
  	echo "                    <table width='100%' border='0' cellspacing='0' cellpadding='1'>\n";
  	echo "                      <tr bgcolor='#DCD7CB'>\n";
  	echo "                        <td width='13%' align='left' nowrap><b><font color='#2B3D61'>Subject</font></b></td>\n";
  	echo "                        <td width='1%' align='center' nowrap><b><font color='#2B3D61'>:</font></b></td>\n";
  	echo "                        <td width='86%' nowrap>$mysubject</td>\n";
  	echo "                      </tr>\n";
  	echo "                      <tr bgcolor='#DCD7CB'>\n";
  	echo "                        <td width='13%' align='left' nowrap><b><font color='#2B3D61'>Date</font></b></td>\n";
  	echo "                        <td width='1%' align='center' nowrap><b><font color='#2B3D61'>:</font></b></td>\n";
  	echo "                        <td width='86%' nowrap>$date</td>\n";
  	echo "                      </tr>\n";
  	echo "                      <tr bgcolor='#DCD7CB'>\n";
  	echo "                        <td width='13%' align='left'><b><font color='#2B3D61'>From</font></b></td>\n";
  	echo "                        <td width='1%' align='center'><b><font color='#2B3D61'>:</font></b></td>\n";
  	echo "                        <td width='86%'>$htmlfrom</td>\n";
  	echo "                      </tr>\n";
  	echo "                      <tr bgcolor='#DCD7CB'>\n";
  	echo "                        <td width='13%' align='left'><b><font color='#2B3D61'>To</font></b></td>\n";
  	echo "                        <td width='1%' align='center'><b><font color='#2B3D61'>:</font></b></td>\n";
  	echo "                        <td width='86%'>$htmlto</td>\n";
  	echo "                      </tr>\n";
  	if (strlen($htmlcc) > 0) {
		echo "                      <tr bgcolor='#DCD7CB'>\n";
    	echo "                        <td width='13%' align='left'><b><font color='#2B3D61'>CC</font></b></td>\n";
    	echo "                        <td width='1%' align='center'><b><font color='#2B3D61'>:</font></b></td>\n";
    	echo "                        <td width='86%'>$htmlcc</td>\n";
    	echo "                      </tr>\n";
  	}

  	$query = "select count(attach_id) from tblAttachments where message_id=$message_id";
  	$result = mysql_db_query("$dbname",$query);
  	if($result) {
		while ($r = mysql_fetch_array($result)) {
			$c = $r["count(attach_id)"];
		}
	}

  	if ($c<=0 ) {
  		$attachyok = 1;
  	}

  	if ($attachyok == 0) {
    	echo "                      <tr bgcolor='#DCD7CB'>\n";
    	echo "                        <td width='13%' align='left' valign='top'><b><font color='#2B3D61'>Attachments</font></b></td>\n";
    	echo "                        <td width='1%' align='center' valign='top'><b><font color='#2B3D61'>:</font></b></td>\n";
    	echo "                        <td width='86%'>\n";
  		$query = "select * from tblAttachments where message_id=$message_id";
  		$result = mysql_db_query("$dbname",$query);
  		if($result) {
			while ($r = mysql_fetch_array($result)) {
				$attach_id = $r["attach_id"];
				$dosya_adi = $r["dosya_adi"];

	    		echo "<a href='download.php?ID=$ID&attach_id=$attach_id&gercekisim=$dosya_adi&message_id=$message_id'>$dosya_adi </a><br>";
			}
		}
    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);
	$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=1'> 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=1'>Forward Message</a></td>\n";
  	echo "          </tr>\n";
  	echo "          <tr>\n";
  	echo "            <td>\n";
  	echo "							&nbsp;<br>";
	$htmlbody = stripslashes($htmlbody);
  	echo nl2br($htmlbody);
  	echo "							&nbsp;<p>";
  	echo "						</td>\n";
  	echo "          </tr>\n";
  	echo "          <tr align='right'>\n";
  	echo "            <td nowrap bgcolor='#DFDFDF'><img src='images/save.gif'> <a href='download.php?ID=$ID&message_id=$message_id&gercekisim=$mysubject.txt&message=1'>Download Message</a> | <img src='images/print.gif'> <a href='javascript:printit()'>Print Message</a></td>\n";
  	echo "          </tr>\n";
  	echo "        </table>\n";
  	echo "      </form>\n";
  	echo "		</td>\n";
  	echo "  </tr>\n";
  	echo "</table>\n";
  	echo "</body>\n";
  	echo "</html>\n";

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

?>
Return current item: Akasha