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

if ($akashaID == $ID) {

	include ("includes/global.inc"); 						// Global Variables
	include ("includes/functions.inc"); 				// Global Functions

	if ($mbox_id == 'inbox') {
  	$tersname = strrev($gercekisim);
  	$dosya_isim = stristr($tersname,".");
  	$lenisim = strlen($dosya_isim);
  	$extension=trim(strtolower(substr($gercekisim,$lenisim)));
  	
  	$dosyatipi="application/octet-stream";
  	$mime=fopen("mime.types","r");
  	while ( !feof($mime) ) {
  		$mytype=fgets($mime,1000);
  		$mimeparts=explode("	",$mytype);	
  		$mimeuzanti = trim(strtolower($mimeparts[1]));
  		
  		if ($mimeuzanti == $extension) {
  			$dosyatipi=$mimeparts[0];
  		}	
  	}
  	fclose($mime);


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

  	$body=imap_fetchbody($mbox,$message_id,$part);


  	if ($encoding==3){
  		$body   =imap_base64($body);
  	}

  	if ($encoding==4){
  		$body   =imap_qprint($body);
  	}

  	Header("Content-type: $dosyatipi; name=$gercekisim");
  	Header("Content-Disposition: attachment; filename=$gercekisim");

  	echo $body;

  	imap_close($mbox);
	} else {
   	$user_id = findUserByHash($ID);

		if ($message==1) {
    	$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)) {
   				$veri = $r["msg_body"];
					$gercekisim = $r["header_subject"];
					$dosyatipi = "text/plain";
    		}
  	 	}

    	Header("Content-type: $dosyatipi; name=$gercekisim");
    	Header("Content-Disposition: attachment; filename=$gercekisim");
  		echo $veri;

		} else {
      $query = "select * from tblAttachments where message_id=$message_id and user_id=$user_id and attach_id=$attach_id";
      $result = mysql_db_query("$dbname",$query);
      if($result) {
    		while ($r = mysql_fetch_array($result)) {
    			$veri = $r["veri"];
    			$dosyatipi = $r["dosya_tipi"];
    		}
    	}

	if ($gercekisim != "iso-8859-9") {
	if ($gercekisim != "iso-8859-1") {
   		$veri =imap_base64($veri);
	}
	}

    	Header("Content-type: $dosyatipi; name=$gercekisim");
    	Header("Content-Disposition: attachment; filename=$gercekisim");
  		echo $veri;
		}
	}
} else {
		Header("Location: main.php?error_code=1");
}

?>
Return current item: Akasha