Location: PHPKode > projects > Akasha > new_message.php
<?

if ($akashaID == $ID) {

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

?>

  <script language="JavaScript">
  <!--
  function submitonce(theform){
  	if (document.all||document.getElementById){
  		for (i=0;i<theform.length;i++){
  			var tempobj=theform.elements[i]
  			if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
  				tempobj.disabled=true
  		}
  	}
  }
  //-->
  </script>
  <script language="JavaScript">
  <!--
  function formURL(){
		if (formURL.arguments[0] == 1) 
			document.myForm.action="attachments.php?ID="+formURL.arguments[1];
		if (formURL.arguments[0] == 2)
			document.myForm.action="postmail.php?ID="+formURL.arguments[1];
	}
  //-->
  </script>
<?

  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'>\n";
  echo "		  <div align='center'>&nbsp;<br>\n";
  echo "      <form name='myForm' method='post' action='postmail.php?ID=$ID' onSubmit='submitonce(this)'>\n";
  echo "        <table width='550' border='0' cellspacing='0' cellpadding='0' bgcolor='#FFFFFF'>\n";
  echo "          <tr>\n";
  echo "            <td>\n";
  echo "              <table width='550' border='0' cellspacing='0' cellpadding='0'>\n";
  echo "                <tr bgcolor='#DCD7CB'>\n";
  echo "                  <td width='20' align='left' nowrap>&nbsp;</td>\n";
  echo "                  <td width='100' align='left' nowrap><b><font color='#2B3D61'>To</font></b></td>\n";
  echo "                  <td width='430'>\n";
	$to = rawurldecode($to);
  echo "                    <input type='text' name='to' class='stiltextfield' size='30' value='$to'>\n";
  echo "                  </td>\n";
  echo "                </tr>\n";
  echo "                <tr bgcolor='#DCD7CB'>\n";
  echo "                  <td width='20' align='left' nowrap>&nbsp;</td>\n";
  echo "                  <td width='100' align='left' nowrap><b><font color='#2B3D61'>CC</font></b></td>\n";
  echo "                  <td width='430'>\n";
	$cc = rawurldecode($cc);
  echo "                    <input type='text' name='cc' class='stiltextfield' size='30' value='$cc'>\n";
  echo "                  </td>\n";
  echo "                </tr>\n";
  echo "                <tr bgcolor='#DCD7CB'>\n";
  echo "                  <td width='20' align='left' valign='top' nowrap>&nbsp;</td>\n";
  echo "                  <td width='100' align='left' nowrap><b><font color='#2B3D61'>BCC</font></b></td>\n";
  echo "                  <td width='430'>\n";
	$bcc = rawurldecode($bcc);
  echo "                    <input type='text' name='bcc' class='stiltextfield' size='30' value='$bcc'>\n";
  echo "                  </td>\n";
  echo "                </tr>\n";
  echo "                <tr bgcolor='#DCD7CB'>\n";
  echo "                  <td width='20' align='left' nowrap>&nbsp;</td>\n";
  echo "                  <td width='100' align='left' nowrap><b><font color='#2B3D61'>Subject</font></b></td>\n";
  echo "                  <td width='430' nowrap>\n";
	$subject = rawurldecode($subject);
  echo "                    <input type='text' name='subject' class='stiltextfield' size='30' value='$subject'>\n";
  echo "                  </td>\n";
  echo "                </tr>\n";
  echo "                <tr bgcolor='#DCD7CB'>\n";
  echo "                  <td width='20' align='left' valign='top' nowrap>&nbsp;</td>\n";
  echo "													<td width='100' align='left' valign='top' nowrap><b><input type='submit' name='submitX' value='Attachments' class='stilbutton'"; ?> onClick="formURL('1','<? echo $ID ?>')" <? echo "></font></b></td>\n";
  echo "                  <td width='430' nowrap>\n";

  $handle=opendir($attach_dir);
  while ($file = readdir($handle)) {
		$attach_id = substr($file,1,46);

			$idvar = strstr($file,$ID);
			if ($idvar) {
				$attachedfile = strstr($file,"######");
				$attach_name = substr($attachedfile,6);
				$size = filesize("$attach_dir$file");
				$size = ceil($size / 1024);
			  echo "	<font color='#2B3D61'>$attach_name ($size K)</font><br>\n";
			}
  }
  closedir($handle); 
  echo "                  &nbsp;</td>\n";
  echo "                </tr>\n";
  echo "              </table>\n";
  echo "						<tr><td bgcolor='#FFFFFF'>\n";

  	$msgbody = htmlspecialchars(rawurldecode($msgbody));
	$msgbody=stripslashes($msgbody);

	if ($db == 1) {
  	$user_id = findUserByHash($ID);
  	$query = "select * from tblMessages where message_id=$message_id and user_id=$user_id";
  	$result = mysql_db_query("$dbname",$query);
  	if($result) {
 			while ($r = mysql_fetch_array($result)) {
 				$msgbody = $r["msg_body"];
				$msgbody = ereg_replace("\n","\n>",$msgbody);
				$ek = "\n\n\n-------Folder Name-------\n>";
				$msgbody = "$ek$msgbody";
				$msgbody = stripslashes($msgbody);
  		}
	 	}
	}
	if ($db == 2) {


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

  	$mbox = imap_open("{".$domain."/pop3:110}INBOX", "$username", "$password");

    $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) {
    	$msgbody = htmlisle($body);
    } else {
    	$msgbody=bodyIsle($body);
    }

		$msgbody = ereg_replace("\n","\n>",$msgbody);
		$ek = "\n\n\n-------Original Message-------\n>";
		$msgbody = "$ek$msgbody";
		$msgbody = stripslashes($msgbody);
  	imap_close($mbox);
	}

  echo "        <textarea name='msgbody' cols='60' rows='20' wrap='PHYSICAL' class='stilmsgbody'>$msgbody</textarea>\n";
  echo "        <br>\n";
	echo "				</td></tr>\n";
	echo "				<tr><td bgcolor='#FFFFFF' align='right'>\n";
	echo "              <input type='reset' name='reset' value='Reset'>\n";
	echo "													<input type='submit' name='submitX' value='Send'"; ?> onClick="formURL('2','<? echo $ID ?>')" <? echo ">\n";
	
	echo "				</td></tr>\n";
	echo "              </td>\n";
	echo "          </tr>\n";
	echo "        </table>\n";
  echo "      </form>\n";
  echo "      <br>\n";
  echo "      </td></div>\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