multifarious project a personal email-system team members abdullah alghamdi metaib alenzai mohammed...

28
Multifarious Multifarious Project Project A personal email- A personal email- system system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Upload: beverly-mccoy

Post on 01-Jan-2016

221 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Multifarious ProjectMultifarious ProjectA personal email-system A personal email-system

Team Members

• Abdullah Alghamdi

• Metaib Alenzai

• Mohammed Alshehri

• Hamd Alshamsi

Page 2: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

The Project IdeaThe Project Idea

Email system allows user to login Email system allows user to login securely into a web-based email securely into a web-based email system.system.

Page 3: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

SYSTEM LAYOUTSYSTEM LAYOUTUser logs into the web based email system

Login page displayed to user as part of client side PHP scripts

Authentication and data communication occurs between client and server

Server performs processing and authentication procedures and returns appropriate response

Server side checks for user profiles and details in the database

Page 4: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Programming Languages UsedProgramming Languages Used

PHPPHP HTMLHTML

Page 5: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

PHP and Why?PHP and Why? PHP stands for PHP: Hypertext Preprocessor. PHP stands for PHP: Hypertext Preprocessor. PHP runs on different platforms (Windows, Linux, PHP runs on different platforms (Windows, Linux,

Unix, etc.)Unix, etc.) PHP supports many databases (MySQL, Informix, PHP supports many databases (MySQL, Informix,

Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) etc.)

PHP is an open source software (OSS).PHP is an open source software (OSS). PHP is compatible with almost all servers used today PHP is compatible with almost all servers used today

(Apache, IIS, etc.)(Apache, IIS, etc.) PHP is easy to learn and runs efficiently on the PHP is easy to learn and runs efficiently on the

server side.server side.

Page 6: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

HTMLHTML HTML stands for HTML stands for HHyper yper TText ext MMarkup arkup LLanguage anguage An HTML file is a text file containing small An HTML file is a text file containing small

markup tagsmarkup tags The markup tags tell the Web browser The markup tags tell the Web browser how to how to

displaydisplay the page the page An HTML file must have an An HTML file must have an htmhtm or or htmlhtml file file

extension extension An HTML file can be created using a An HTML file can be created using a simple text simple text

editoreditor

Page 7: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Logon.phpLogon.php This is the main file. It contains the PHP code that This is the main file. It contains the PHP code that

will be executed once a username and password will be executed once a username and password will be entered. It authenticates the username will be entered. It authenticates the username and password that are entered by the user by and password that are entered by the user by communicating with the server.communicating with the server.

The code also sets the cookie for 1800 seconds The code also sets the cookie for 1800 seconds and expires after that, so that the user has to and expires after that, so that the user has to logon again after that time period.logon again after that time period.

The code checks for an invalid usernames and The code checks for an invalid usernames and passwords and prevents that kind of input from passwords and prevents that kind of input from the user.the user.

This file relays all the obtained information to This file relays all the obtained information to INDEX.PHP and communicates with it.INDEX.PHP and communicates with it.

Page 8: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Logon PageLogon Page

Page 9: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Logon PHP CodeLogon PHP Code

if( isset($_POST['user']) && isset($_POST['pass']) ) { $mbox = @imap_open('{mailhost.fit.edu}INBOX', $_POST['user'], $_POST['pass']);

if($mbox) { setcookie("auth",serialize(Array($_POST['user'],$_POST['pass'])),time()+1800,"/",".fit.edu"); } else { setcookie('auth','',-1,"/",".fit.edu"); }

Page 10: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Logon HTML CodeLogon HTML Code<head> <title>Email Login</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

<body> <form method="POST"> <table width="100%" height="100%"><tr><td align="center" valign="center">

<fieldset style="width:300px"> <legend><small>Login to Email</small></legend> <table align=center> <tr> <td align=center width=50%>Username:</td> <td align=center width=50%>Password:</td> </tr>

Page 11: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Auth PHP Auth PHP

AUTH.PHP contains the logic to authorize a user.AUTH.PHP contains the logic to authorize a user. The main function in this PHP code is the Die The main function in this PHP code is the Die

function. If a user enters a wrong function. If a user enters a wrong username/password or blank username/password or blank username/password, this function will prevent the username/password, this function will prevent the user from logging in.user from logging in.

This file communicates this information to This file communicates this information to LOGON.PHP and acts as a bridge between the LOGON.PHP and acts as a bridge between the client and the mail server client and the mail server

Page 12: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Auth Code Auth Code

1- function die_with_honor($s) { die("Error: \"$s\""); }

2- $bad_user = true; require(dirname(__FILE__)."/logon.php");

Page 13: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

IndexIndex INDEX.PHP verifies the authentication requested by INDEX.PHP verifies the authentication requested by

LOGON.PHP by talking to the email-server.LOGON.PHP by talking to the email-server. After verifying login, INDEX.PHP displays 20 email After verifying login, INDEX.PHP displays 20 email

messages per page and also displays the number of pages messages per page and also displays the number of pages that are in the email INBOX. As an example, if the user has that are in the email INBOX. As an example, if the user has 43 email messages in his INBOX, then INDEX.PHP will 43 email messages in his INBOX, then INDEX.PHP will display the first 20 email messages and 3 pages.display the first 20 email messages and 3 pages.

INDEX.PHP communicates with AUTH.PHP file for user INDEX.PHP communicates with AUTH.PHP file for user authentication purposes.authentication purposes.

INDEX.PHP also contains the HTML code to display the INDEX.PHP also contains the HTML code to display the contents of the inbox to the user who logs into the email contents of the inbox to the user who logs into the email system.system.

INDEX.PHP also communicates with COMPOSE.PHP, INDEX.PHP also communicates with COMPOSE.PHP, DELETE.PHP and READ.PHP that perform different email DELETE.PHP and READ.PHP that perform different email functions that are discussed later.functions that are discussed later.

Page 14: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Index PageIndex Page

Page 15: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Index PHP CodeIndex PHP Code1- $startMsg = 1; if(isset($_GET['start'])) $startMsg = $_GET['start'];

$countMsg = 20; if(isset($_GET['count'])) $countMsg = $_GET['count'];

2- $messages = Array(); for($i=$startMsg; $i<$lastMsg; $i++) $messages[imap_uid($conn, $i)] = imap_headerinfo($conn, $i);

imap_close($conn);?>

Page 16: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Index HTML CodeIndex HTML Code

<table width="900" border="0" cellpadding="1" cellspacing="0" style="border: 1px solid black"> <tr bgcolor="blue" style="color: white;"> <td width="20%"><b>From:</b></td> <td width="36%"><b>Subject:</b></td> <td width="18%"><b>Received:</b></td> <td width="11%"><b>Delete:</b></td> <td width="10%"><b>Reply:</b></td> </tr>

<? foreach($messages as $uid => $msg) { $bgcolor = ($msg->Unseen == 'U' || $msg->Recent == 'N' ? 'lightgrey' : 'white'); ?> <tr>

Page 17: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Read Read READ.PHP communicates with the database using SQL READ.PHP communicates with the database using SQL

queries to retrieve data for a particular user.queries to retrieve data for a particular user. It passes in the SQL query using the IMAP protocol to talk to It passes in the SQL query using the IMAP protocol to talk to

the Florida Tech Mail Server. the Florida Tech Mail Server. The use of the IMAP protocol in READ.PHP allows this email The use of the IMAP protocol in READ.PHP allows this email

system to display simple text emails, emails with pictures system to display simple text emails, emails with pictures and even emails with pictures containing text. and even emails with pictures containing text.

The code also formats the contents of an email that will be The code also formats the contents of an email that will be displayed to the user.displayed to the user.

Once the entire procedure of reading an email and Once the entire procedure of reading an email and displaying the email to the user has been completed, it displaying the email to the user has been completed, it closed the IMAP connection that was established to talk to closed the IMAP connection that was established to talk to the Florida Tech mail server.the Florida Tech mail server.

Page 18: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Read PageRead Page

Page 19: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Read PHP CodeRead PHP Code

if (!isset($struct->parts)) {$content = imap_body($conn, $uid, FT_UID); $content = "<pre>$content</pre>";}else {for($i=1; $i<=count($struct->parts); $i++) { $content .= imap_fetchbody($conn, $uid, "$i", FT_UID); }

Page 20: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Read Code HTMLRead Code HTML

<html><head><title><?=$header->Subject?></title></head><body><table width="100%" style="border: 1px solid black"><tr><td align="center">&nbsp;[&nbsp;<a href="index.php?start=<?=$start?>&count=<?=$count?>">Inbox</a>&nbsp;]&nbsp;[&nbsp;<a href="compose.php?reply=<?=$uid?>">Reply</a>&nbsp;]&nbsp;[&nbsp;<a href="delete.php?message=<?=$uid?>&start=<?=$start?>&count=<?=$count?>">Delete</a>&nbsp;]&nbsp;[&nbsp;<a href="logout.php">Logout</a>&nbsp;]</td></tr></table><?=$content?></body></html>

Page 21: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

ComposeCompose

The COMPOSE.PHP file displays the HTML content The COMPOSE.PHP file displays the HTML content required when the user has to compose an email.required when the user has to compose an email.

It also contains the code to reply to an email, to It also contains the code to reply to an email, to delete an email and also to logout of a system.delete an email and also to logout of a system.

When a user hits the reply hyperlink at the top of When a user hits the reply hyperlink at the top of the page, the entire text of the original mail is the page, the entire text of the original mail is displayed in the compose window and then the displayed in the compose window and then the user can proceed to send the reply to the user can proceed to send the reply to the concerned email address.concerned email address.

Page 22: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Compose PageCompose Page

Page 23: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Compose PHP CodeCompose PHP Code1-if(isset($_POST['to'])) { imap_mail($_POST['to'], $_POST['subject'], $_POST['body'], '', '', '', $user.'@fit.edu');header("Location: index.php"); } $to = ''; $subject = ''; $body = '';

2-if( isset($_GET['reply']) ) { $uid = $_GET['reply']; $conn = imap_open ("{mailhost.fit.edu}INBOX", $user, $pass); $header = imap_headerinfo($conn,imap_msgno($conn, $uid)); $struct = imap_fetchstructure($conn, $uid, FT_UID);

Page 24: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Compose HTML CodeCompose HTML Code1-<legend><small>Compose New Mail&nbsp;</small></legend> <table border="0" align="center"> <tr> <td width="9%">To:</td> <td width="91%"> <input type="text" name="to" size="100" value="<?=$to?>">

2-<br>[&nbsp;<a href="index.php">Inbox</a>&nbsp;]&nbsp;[&nbsp;<a href="logout.php">Logout</a>&nbsp;]

Page 25: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Delete Delete

DELETE.PHP allows the user to delete any DELETE.PHP allows the user to delete any message that is selected by the user.message that is selected by the user.

The actual delete function in PHP does not delete The actual delete function in PHP does not delete the message from the inbox.the message from the inbox.

So we use the So we use the expunge()expunge() function to actually function to actually delete the message.delete the message.

Once the deletion is completed, the reordered list Once the deletion is completed, the reordered list of emails is displayed to the user.of emails is displayed to the user.

Page 26: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Delete CodeDelete Code

$conn = imap_open ("{mailhost.fit.edu}INBOX", $user, $pass);

imap_delete($conn, $uid, FT_UID); imap_expunge($conn); imap_close($conn);

Page 27: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

Logout Logout

setcookie('auth',null,-1,"/",".fit.edu");header("Location: index.php");

Page 28: Multifarious Project A personal email-system Team Members Abdullah Alghamdi Metaib Alenzai Mohammed Alshehri Hamd Alshamsi

THE END THE END