Location: PHPKode > projects > Myphpim > MyPhPim-01.05/popup.php3
<?php

//****************************************************************************************
//                Copyright (C) 2000 Koen de Boeve
//
//        This program is free software; you can redistribute it and/or
//        modify it under the terms of the GNU General Public License
//        as published by the Free Software Foundation; either version 2
//        of the License, or (at your option) any later version.
//
//        This program is distributed in the hope that it will be useful,
//        but WITHOUT ANY WARRANTY; without even the implied warranty of
//        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//        GNU General Public License for more details.
//
//        You should have received a copy of the GNU General Public License
//        along with this program; if not, write to the Free Software
//        Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
//        Version : MyPhPim-01.05
//        Author : Koen de Boeve
//        Contact: hide@address.com
//**************************************************************************************** 

session_start();

include "conf/config.inc";
include "includes/html_cl.inc";
include "includes/mysql_cl.inc";
include "includes/imap_cl.inc";
include "includes/mcrypt_cl.inc";

if ( $type == "email" ) {
	echo "<html><head><title>Add To Addressbook Or Compose New Message</title>\n";
	echo "</head>\n";
	echo "<body bgcolor=white link=blue alink=blue vlink=blue>\n";
	echo "<center><h3>What To Do With $mailaddress ?</h3>\n";
	echo "<font size=-1><a href=main.php3?menu=compose&to=$mailaddress target=bodyframe>| Compose New Mail With This Email Address |</a>\n";
	echo "<p><font size=-1><a href=addresses.php3?menu=create&email=$mailaddress target=bodyframe>| Add To Addressbook |</a>\n";
	echo "<p><form><input type=button value=OK onClick=window.close()></form>\n";
	echo "</center></body></html>\n";
} else if ( $type == "mailsource" ) {
	$imap = new ImapCl;
	$db = new DB;
	$userdata = $db->Fetch_login ( $user, $choosehost );
	$login = $userdata[0];
	$pass = $userdata[1];
	$proto = $userdata[2];
	$host = $userdata[3];
	$port = $userdata[4];
	$query = "SELECT user_id FROM users WHERE user='$user'";
	$result = $db->query ( $query );
	$user_id = $db->result ( $result, 0, "user_id" );
	$mbox = $imap->InitFolder ( $host, $port, $proto, $login, $pass, $folder);
	$text = $imap->FetchSource ( $mbox, $msgno );
	$text = nl2br ( $text );
	echo "<html><head></head><body bgcolor=white><font size=-1>$text</font></body></html>";
	
} else if ( $type == "address" ) {
	$db = new DB;
	$form = new FormCl;
	$query = "SELECT user_id FROM users WHERE user='$user'";
	$result = $db->query ( $query );
	$user_id = $db->result ( $result, 0, "user_id" );
	$query = "SELECT name, firstname, email FROM addresses WHERE email LIKE \"%@%\" AND owner=$user_id ORDER BY name, firstname, email";
	$result = $db->query ( $query );
	$numrows = $db->numrows ( $result );
	if ( $mailto ) {
		$mailto = str_replace (":", ",", $mailto );
	}
	if ( $mailcc ) {
		$mailcc = str_replace (":", ",", $mailcc );
	}
	if ( $mailbcc ) {
		$mailbcc = str_replace (":", ",", $mailbcc );
	}
	echo "<html><head><title>Add Addresses To Message</title>\n";
	echo "</head>\n";
	echo "<body bgcolor=white link=blue alink=blue vlink=blue>\n";
	echo "<center><font size=+1><b>Add Address To \"$field\" Field</b></font><p><table border=0>\n";
	$count = 1;
	for ( $i = 0; $i < $numrows; $i++ ) {
		$name = $db->result ( $result, $i, "name" );
		$firstname = $db->result ( $result, $i, "firstname" );
		$email = $db->result ( $result, $i, "email" );
		switch ( $field ) {
			case "to" : 
				if ( $mailto ) {
					$addressto = $mailto . "," . $email;
				} else {
					$addressto = $mailto . $email;
				}
				$addressto = str_replace ( " ", "%20", $addressto );
				$addresscc = $mailcc;
				$addresscc = str_replace ( " ", "%20", $addresscc );
				$addressbcc = $mailbcc;
				$addressbcc = str_replace ( " ", "%20", $addressbcc );
				break;;
			case "cc" :
				if ( $mailcc ) {
					$addresscc = $mailcc . "," .$email;
				} else {
					$addresscc = $mailcc . $email;
				}	
				$addresscc = str_replace ( " ", "%20", $addresscc );
				$addressto = $mailto;
				$addressto = str_replace ( " ", "%20", $addressto );
				$addressbcc = $mailbcc;
				$addressbcc = str_replace ( " ", "%20", $addressbcc );
				break;;
			case "bcc" :
				if ( $mailbcc ) {
					$addressbcc = $mailbcc . "," . $email;
				} else {
					$addressbcc = $mailbcc . $email;
				}
				$addressbcc = str_replace ( " ", "%20", $addressbcc );
				$addressto = $mailto;
				$addressto = str_replace ( " ", "%20", $addressto );
				$addresscc = $mailcc;
				$addresscc = str_replace ( " ", "%20", $addresscc );
				break;;
		}
		$tmp = $count/2;
		$round = round ( $tmp );
		if ( $tmp == $round ) {
			$color = "lightgrey";
		} else {
			$color = "darkseagreen";
		}
		echo "<tr bgcolor=$color><td><font size=-1>$name $firstname</font></td><td><font size=-1><a href=main.php3?menu=compose&act=$act&folder=$folder&msgno=$msgno&to=$addressto&cc=$addresscc&bcc=$addressbcc onClick=\"window.self.location='popup.php3?type=address&act=$act&folder=$folder&msgno=$msgno&mailto=$addressto&mailcc=$addresscc&mailbcc=$addressbcc&field=$field'\" target=bodyframe>$email</a></font></td></tr>\n";
		//echo "<tr><td><font size=-1>$firstname $name</font></td><td><font size=-1><a href='javascript: window.opener.document.composeform.$field.value=$address' >$email</a></font></td></tr>\n";
		$count++;
	}
	echo "<tr><form><td colspan=2 align=center><input type=button value=OK onClick=window.close()></td></form></tr>\n";
	echo "</table></center>\n";
	echo "</body></html>\n";
} else if ( $type == "error" ) {
	echo "<html><head><title></title>\n";
	echo "</head>\n";
	echo "<body bgcolor=white link=blue alink=blue vlink=blue>\n";
	echo "<h2>$msg</h2>";
	echo "<center><form><input type=button value='OK' onClick=window.close()></form></center>|";
	echo "</body></html>";
} else if ( $type == "mr" ) {
	switch ( $action ) {
		case "new" :
        			$db = new DB;
        			$user_id = $db->UserId ( $user );
        			$vars = $db->SearchPendingRecords ( $user_id , $mrid);
				echo "<html><head><title></title>\n";
				echo "</head>\n";
				echo "<body bgcolor=white link=blue alink=blue vlink=blue>\n";
				$data = $vars[0];
				$byusername = $db->username( $data->byuser );
				echo "<center>Hello $user, user $byusername added an $data->type for you, here are the details:</center>";
				echo "<br><br>";
				$db->ShowThisRecord ( $data );	
				echo "<br><br><center><form action=main.php3 method=POST>";
				echo "Comments: <textarea name=comments rows=5 cols=60>$data->comment</textarea><br>";
				echo "<input type=hidden name=mr value=A>";
				echo "<input type=hidden name=user_id value=$user_id>";
				echo "<input type=hidden name=eventtype value=$data->type>";
				echo "<input type=hidden name=eventid value=$data->record>";
				echo "<input type=hidden name=mr_id value=$mrid>";
				echo "<input type=submit name=mract value=ACCEPT>\n";
				echo "<input type=submit name=mract value=REJECT></form></center>\n";
				echo "</center></body></html>\n";
				break;;
		case "added" :
        			$db = new DB;
        			$user_id = $db->UserId ( $user );
        			$vars = $db->SearchAddedRecords ( $mrid );
				echo "<html><head><title></title>\n";
				echo "</head>\n";
				echo "<body bgcolor=white link=blue alink=blue vlink=blue>\n";
				$data = $vars[0];
				$forusername = $db->username( $data->foruser );
				echo "<center>Hello $user, user $forusername accepted following $data->type from you</center>";
				echo "<br><br>";
				$db->ShowThisRecord ( $data );	
				echo "<br><br><center><form action=main.php3 method=POST>";
				echo "Comments: <textarea name=comments rows=5 cols=60>$data->comment</textarea><br>";
				echo "<input type=hidden name=mr value=C>";
				echo "<input type=hidden name=user_id value=$user_id>";
				echo "<input type=hidden name=eventtype value=$data->type>";
				echo "<input type=hidden name=eventid value=$data->record>";
				echo "<input type=hidden name=mr_id value=$mrid>";
				echo "<input type=submit value=OK></form>\n";
				echo "</center></body></html>\n";
				break;;
		case "rejected" :
        			$db = new DB;
        			$user_id = $db->UserId ( $user );
        			$vars = $db->SearchRejectedRecords ( $mrid );
				echo "<html><head><title></title>\n";
				echo "</head>\n";
				echo "<body bgcolor=white link=blue alink=blue vlink=blue>\n";
				$data = $vars[0];
				$forusername = $db->username( $data->foruser );
				echo "<center>Hello $user, user $forusername Rejected following $data->type from you</center>";
				echo "<br><br>";
				$db->ShowThisRecord ( $data );	
				echo "<br><br><center><form action=main.php3 method=POST>";
				echo "Comments: <textarea name=comments rows=5 cols=60>$data->comment</textarea><br>";
				echo "<input type=hidden name=mr value=A>";
				echo "<input type=hidden name=user_id value=$user_id>";
				echo "<input type=hidden name=eventtype value=$data->type>";
				echo "<input type=hidden name=eventid value=$data->record>";
				echo "<input type=hidden name=mr_id value=$mrid>";
				echo "<input type=submit name=mract value=RESEND>\n";
				echo "<input type=submit name=mract value=CLOSE></form>\n";
				echo "</center></body></html>\n";
				break;;
		}
				
}
	 

?>
Return current item: Myphpim