101
Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested by: Dr. Eric Breimer Associate Professor Siena College Department of Computer Science Prepared by: Digital Evolutions Janelle Rizzo Alan DiStasio Chris Badalucco Dan Quickenton Erik Mulvaney Mike Stellato April 26, 2010

Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Acceptance Test

Appendix D: Source Code

and

PhpDocumentor

SaintBook

Requested by:

Dr. Eric Breimer

Associate Professor

Siena College

Department of Computer Science

Prepared by:

Digital Evolutions

Janelle Rizzo

Alan DiStasio

Chris Badalucco

Dan Quickenton

Erik Mulvaney

Mike Stellato

April 26, 2010

Page 2: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 2 | P a g e

SaintBook

Acceptance Test

Appendix D: Source Code and PhpDocumentor

Table of Contents

1 Source Code ......................................................................................................................................... 4

1.1. Browse.php ................................................................................................................................... 4

1.2. Change_password.php .................................................................................................................. 6

1.3. Forgot_password.php ................................................................................................................... 9

1.4. Friends_tab.php .......................................................................................................................... 11

1.5. Group.php ................................................................................................................................... 13

1.6. Group_Tab.php ........................................................................................................................... 15

1.7. Home_tab.php ............................................................................................................................ 18

1.8. Join.php ....................................................................................................................................... 25

1.9. Label_tab.php ............................................................................................................................. 29

1.10. Login.php ................................................................................................................................. 31

1.11. Logout.php .............................................................................................................................. 32

1.12. Members_tab.php .................................................................................................................. 34

1.13. Message_center_tab.php ....................................................................................................... 35

1.14. Page.php ................................................................................................................................. 38

1.15. Privacy.php .............................................................................................................................. 40

1.16. Profile.php ............................................................................................................................... 41

1.17. Profile_tab.php ....................................................................................................................... 42

1.18. Register.php ............................................................................................................................ 51

1.19. Super_admin.php .................................................................................................................... 53

1.20. Updateorder.php .................................................................................................................... 56

1.21. User.php .................................................................................................................................. 59

1.22. Utilities.php ............................................................................................................................. 60

1.23. Verify.php ................................................................................................................................ 72

1.24. Wall.php .................................................................................................................................. 75

1.25. Arrange.js ................................................................................................................................ 80

1.26. Check_delete.js ....................................................................................................................... 83

1.27. Countchecks.js ........................................................................................................................ 83

Page 3: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 3 | P a g e

1.28. Locationchange.js.................................................................................................................... 83

1.29. Popup.js ................................................................................................................................... 84

1.30. Authenticated.css .................................................................................................................... 85

1.31. Unauthenticated.css ............................................................................................................... 93

2 PhpDocumentor ................................................................................................................................. 96

Page 4: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 4 | P a g e

1 Source Code

Below is the source code for the SaintBook project. Each section is broken up by the file in

which the source code is from.

1.1. Browse.php <?php

/**

* Functions to handle the browse functionality, which includes

* browsing through users and groups, with a list all and a

* browse alphabetical option also.

*

* @author Alan Dispassion

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package browse

*/

/**

* Creates the browse content depending on if user or group

* is selected as well as alphabetically listing or simply

* listing all.

*

*/

function make_browse_content()

{

if($_GET['type'] != "group"){

$select = $_GET['select'];

if ($select == "group"){

$group_check="checked";

$user_check="";

}

else{

$group_check="";

$user_check="checked";

}

}

echo '

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<center>

';

if($_GET['type'] != "group"){

echo'

<a href="index.php?loc=browse&select='.$select.'">View All</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=A">A</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=B">B</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=C">C</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=D">D</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=E">E</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=F">F</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=G">G</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=H">H</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=I">I</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=J">J</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=K">K</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=L">L</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=M">M</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=N">N</a> ',"|",'

Page 5: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 5 | P a g e

<a href="index.php?loc=browse&select='.$select.'&letter=O">O</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=P">P</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=Q">Q</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=R">R</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=S">S</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=T">T</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=U">U</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=V">V</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=W">W</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=X">X</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=Y">Y</a> ',"|",'

<a href="index.php?loc=browse&select='.$select.'&letter=Z">Z</a>';

}

else{

echo'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'">View All</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=A">A</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=B">B</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=C">C</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=D">D</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=E">E</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=F">F</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=G">G</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=H">H</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=I">I</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=J">J</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=K">K</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=L">L</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=M">M</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=N">N</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=O">O</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=P">P</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=Q">Q</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=R">R</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=S">S</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=T">T</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=U">U</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=V">V</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=W">W</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=X">X</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=Y">Y</a> ',"|",'

<a href="index.php?loc=browse&type=group&id='.$_GET['id'].'&select='.$select.'&letter=Z">Z</a>';

}

$letter_test = $_GET['letter'];

echo '<br /><br />';

if($_GET['type'] != "group"){

echo'

<form>

Users <input type="radio" onClick = "location.href=\'index.php?loc=browse&select=user\'"

name="select" value="Users" '.$user_check.'> | &nbsp;

Groups <input type="radio" onClick = "location.href=\'index.php?loc=browse&select=group\'"

name="select" value="Groups" '.$group_check.'>

</form><br/><br/>';

}

echo'</center>';

if($_GET['type'] != "group"){

if ($select == "group"){

$results = run_query("SELECT * FROM `group` ORDER BY groupname ASC");

echo '

<table cellpadding="5">';

while ($row = mysql_fetch_array($results)){

$name = $row['groupname'];

$name[0] = strtoupper($name[0]);

if (($name[0] == $letter_test) || ($letter_test == "")){

echo'<tr>

<td><a href= "index.php?loc=Home&type=group&id='.$row['ID'].'">';

echo $row['groupname'];

echo'

</td>

</tr>';

}

Page 6: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 6 | P a g e

}

echo'</table>';

}

else{

$results = run_query("SELECT ID, username, firstname, lastname FROM user ORDER BY firstname

ASC");

echo '

<table>';

while ($row = mysql_fetch_array($results)){

$name = $row['firstname'];

$name[0] = strtoupper($name[0]);

if (($name[0] == $letter_test) || ($letter_test == "")){

echo'<tr><td><a href= "index.php?loc=Home&type=user&id='.$row['ID'].'">'.$row['firstname'].'

'.$row['lastname'].'</a></td></tr>';

}

}

echo '</table>';

}

}

else{

$results = run_query("SELECT ID, groupname FROM `group` ORDER BY groupname ASC");

echo '

<table>';

while ($row = mysql_fetch_array($results)){

$name = $row['groupname'];

$name[0] = strtoupper($name[0]);

if (($name[0] == $letter_test) || ($letter_test == "")){

if($_GET['id'] != $row['ID']){

$results2 = run_query("SELECT RID, AID FROM group_friend WHERE ((RID = ".$row['ID']." AND

AID = ".$_GET['id'].") OR (AID = ".$row['ID']." AND RID = ".$_GET['id']."))");

$row2 = mysql_fetch_array($results2);

if(($row2['RID'] == $row['ID']) || ($row2['AID'] == $row['ID'])){

}

else{

echo'<tr><td><a href=

"index.php?loc=Home&type=group&id='.$row['ID'].'">'.$row['groupname'].'</a></td><td><a

href="index.php?loc=request&action=groupfriend&id='.$_GET['id'].'&group_id='.$row['ID'].'">R

equest Friendship</a></td></tr>';

}

}

}

}

echo '</table>';

}

echo'

</div>

</div>

</div>

</div>

';}?>

1.2. Change_password.php

<?php

/**

* Script to handle the change password function,

* A change password link will be sent to that email, then from

* that link they will be forwarded back to SaintBook to create a

* new password

*

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package change_password

*/

require_once("utilities.php");

session_start();

Page 7: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 7 | P a g e

/**

* Session id from user clicking on link in email

*/

$sid = $_GET['PHPSESSID'];

/**

* Email submitted through from by current user

*/

$given_email = $_GET['email'];

/**

* ???

*/

$given_code = $_GET['code'];

/**

* Post of the submit value by the submit button

*/

$submitted = $_POST['submit'];

/**

* User's actual email

*/

$actual_email = $_SESSION['fp_email'];

/**

* User's actual username

*/

$actual_username = $_SESSION['fp_username'];

/**

* ???

*/

$actual_code = $_SESSION['fp_code'];

/**

* First submitted password

*/

$password = $_POST['pwd'];

/**

* Re-typed submitted password

*/

$password2 = $_POST['pwd2'];

if ( $given_email == $actual_email &&

$given_code == $actual_code &&

$given_code != "" &&

$given_email != "" &&

$password != "" &&

$password2 != "" &&

$password == $password2 &&

$submitted == "Submit") {

/**

* Encrypts password

*/

$password = md5(trim($password));

/**

* Parses email to split where '@' symbol is

*/

$a = explode("@", $actual_email);

$ext = $a[1];

/**

* Updates password, depending on guest or normal user

*/

if($ext != "siena.edu"){

Page 8: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 8 | P a g e

// run_query("UPDATE guest SET password = '$password' WHERE username = '$actual_email'");

$params = array();

$params[0] = 'ss';

$params[1] = $password;

$params[2] = $actual_email;

run_baller_query("UPDATE guest SET password = ? WHERE username = ?", $params);

}

else{

// run_query("UPDATE user SET password = '$password' WHERE username = '$actual_email'");

$params = array();

$params[0] = 'ss';

$params[1] = $password;

$params[2] = $actual_email;

run_baller_query("UPDATE user SET password = ? WHERE username = ?", $params);

}

session_destroy();

/**

* Passes in the forgot password - continued into the make

* header function to be displayed

*/

make_header("Forgot Password - Continued");

echo'

<div id="container">

<div id = "header">

<h1>Welcome!</h1>

</div>

<div id = "content">

<h2>Change Password Complete</h2>

<b>Congratulations! You have successfully changed your password. You may now log in using

your new password. </b><br />

<div class = "links">

<a href="login.php">Log In</a>

</div>

</div>

';

make_footer_unauth();

}

/**

* If a field isn't filled out or the passwords don't match

* error message pops up

*/

else {

make_header("Forgot Password - Continued");

if ($submitted == "Submit") {

if($password != $password2){

$error = "The passwords do not match. Please try again.";

}

else if($password == ""){

$error = "Please enter a value in the first password field.";

}

else{

$error = "Please enter a value in the second password field.";

}

error_message("Error",$error);

}

/**

* For to enter a new password and then re-type password

*/

echo '

<div id="container">

<div id = "header">

<h1>Welcome!</h1>

</div>

Page 9: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 9 | P a g e

<div id = "content">

<h2>Email Verified</h2>

<table>

<form method="post"

action="change_password.php?PHPSESSID='.$sid.'&email='.$given_email.'&code='.$given_code.'">

<tr>

<td>Password:</td><td><input type="password" name="pwd" /></td><td>

</tr>

<tr>

<td>Re-enter Password:</td><td><input type="password" name="pwd2" /></td><td>

</tr>

<tr>

<td><input type="submit" name = "submit" value="Submit" /></td>

</tr>

</form>

</table>

<div class = "links">

<a href="login.php">Log In</a>

</div>

</div>';

make_footer_unauth();

}

?>

1.3. Forgot_password.php <?php

/**

* Script to handle the forgot password function, User clicks

* he forgot password button, enters their email and then

* the email with the link to change their password is

* emailed to them

*

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package forgot_password

*/

require_once("utilities.php");

/**

* Post variable for submitted email

* @var string

*/

$email = $_POST['email'];

/**

* Post variable of the submit button value

* @var string

*/

$submit = $_POST['submit'];

/**

* Splits submitted email the the '@' sign

*/

$a = explode("@", $email);

$username = $a[0];

$ext = $a[1];

/**

* If submit button is clicked

*/

Page 10: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 10 | P a g e

if (($submit == "Change Password") && ($email != "") && (filter_var($email,

FILTER_VALIDATE_EMAIL))) {

/**

* Sets the cookie to expire in 24 hours = 1440 minutes = 8640 seconds

*/

session_set_cookie_params(86400);

/**

* Starts a session on the server, creates SID, and transmits SID cookie to client

*/

session_start();

/**

* Replaces special characters with html friendly characters

*/

$id = htmlspecialchars(session_id());

/**

* Stores the user's email on the server (in a session variable)

* @var string

*/

$_SESSION['fp_email'] = $email;

/**

* Stores the user's username on the server (in a session variable)

* @var string

*/

$_SESSION['fp_username'] = $username;

$code = rand();

/**

* Stores the user's random code on the server (in a session variable)

* @var int

*/

$_SESSION['fp_code'] = $code;

/**

* Sends an email with a link to the verify script,

* the link includes the SID, email, and random code

*/

mail($_POST['email'], "SaintBook - Forgot Password","

SaintBook - Change Password

You are receiving this email because your have requested to change your password

Click on the following link to change your password:

http://sb.sienacs.com/source_files/php_files/change_password.php?PHPSESSID{$id}&email={$e

mail}&code={$code}

If you cannot click the link, open the URL above by copying it to the address bar of your

web browser.");

/**

* Lets the user know an email was sent

*/

make_header("Forgot Password - Email");

echo'

<div id="container">

<div id = "header">

<h1>Welcome!</h1>

</div>

<div id = "content">

<h2>Registration - Email</h2>

<center><b>Check your email (',$email,') and click the link verify your

email and change your password.<br />

Page 11: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 11 | P a g e

It may take a few minutes for the email to be sent. To complete the

change password process, your browser must allow cookies, i.e., cookies must be

enabled.</b><br /></center>

<div class = "links">

<a href="login.php">Log In</a>

</div>

</div>

';

make_footer_unauth();

}

else {

make_header("Forgot Password");

if($submit == "Change Password"){

error_message("Error","Please enter a valid email.");

}

echo'

<div id="container">

<div id = "header">

<h1>Welcome!</h1>

</div>

<div id = "content">

<h2>Forgotten Password</h2>

<table>

<form action="forgot_password.php" method="post">

<tr>

<td>Email:</td><td><input type="text" name="email" value = "'.$_POST['email'].'"/></td>

</tr>

<tr>

<td><input type="submit" name = "submit" value="Change Password" /></td>

</tr>

</form>

</table>

<div class = "links">

<a href="login.php">Log In</a>

</div>

</div>';

make_footer_unauth();

}

?>

1.4. Friends_tab.php <?php

/**

* Friend Tab class to handle the friends tab functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Friends Tab

*/

class Friend_Tab

{

/**

* User's username

* @var string

*/

var $uname;

/**

Page 12: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 12 | P a g e

* User's first name

* @var string

*/

var $fname;

/**

* User's last name

* @var string

*/

var $lname;

/**

* User or Group

* @var string

*/

var $type;

/**

* Function to get these users info

*

* @param string

* @param string

* @param string

* @param string

*/

function __construct($username, $firstname, $lastname, $type){

$this->uname = $username;

$this->fname = $firstname;

$this->lname = $lastname;

$this->type = $type;

}

/**

* Function to display friends tab's main content

*/

public function create_main_content()

{

if($this->type == "group"){

$results = run_query("SELECT RID, AID FROM group_friend WHERE (RID = ".$this->uname." OR AID

= ".$this->uname.") AND pending IS NULL");

}

else{

$results = run_query("SELECT RID, AID FROM user_friend WHERE (RID = ".$this->uname." OR AID

= ".$this->uname.") AND pending IS NULL");

}

?>

<script type="text/javascript" src="source_files/javascript/check_delete.js">

</script>

<?php

echo '

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<h3>Friends</h3>

<table cellpadding="5">';

while($row = mysql_fetch_array($results)){

if($this->type == "group"){

if($row['RID'] == $this->uname){

// $results2 = run_query("SELECT groupname FROM `group` WHERE ID = ".$row['AID']."");

$params = array();

$params[0] = 'i';

$params[1] = $row['AID'];

$row2 = run_baller_query("SELECT groupname FROM `group` WHERE ID = ?", $params);

// $row2 = mysql_fetch_array($results2);

echo '<tr><td><a

href="index.php?loc=Home&type=group&id='.$row['AID'].'">'.$row2['groupname'].'</a></td></tr>

';

}

Page 13: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 13 | P a g e

else{

// $results2 = run_query("SELECT groupname FROM `group` WHERE ID = ".$row['RID']."");

$params = array();

$params[0] = 'i';

$params[1] = $row['RID'];

$row2 = run_baller_query("SELECT groupname FROM `group` WHERE ID = ?", $params);

// $row2 = mysql_fetch_array($results2);

echo '<tr><td><a

href="index.php?loc=Home&type=group&id='.$row['RID'].'">'.$row2['groupname'].'</a></td></tr>

';

}

}

else{

if($row['RID'] == $this->uname){

// $results2 = run_query("SELECT firstname, lastname FROM user WHERE ID = ".$row['AID']."");

$params = array();

$params[0] = 'i';

$params[1] = $row['AID'];

$row2 = run_baller_query("SELECT firstname, lastname FROM user WHERE ID = ?", $params);

// $row2 = mysql_fetch_array($results2);

echo '<tr><td><a

href="index.php?loc=Home&type=user&id='.$row['AID'].'">'.$row2['firstname'].'

'.$row2['lastname'].'</a></td>';

if($this->uname == $_SESSION['userid']){

echo '<td><a href="index.php?loc=request&type=user&id='.$this-

>uname.'&action=remove&user_id='.$row['AID'].'" onclick="return deletechecked();">Remove

Friend</a></td>';

}

echo'</tr>';

}

else{

// $results2 = run_query("SELECT firstname, lastname FROM user WHERE ID = ".$row['RID']."");

$params = array();

$params[0] = 'i';

$params[1] = $row['RID'];

$row2 = run_baller_query("SELECT firstname, lastname FROM user WHERE ID = ?", $params);

// $row2 = mysql_fetch_array($results2);

echo '<tr><td><a

href="index.php?loc=Home&type=user&id='.$row['RID'].'">'.$row2['firstname'].'

'.$row2['lastname'].'</a></td>';

if($this->uname == $_SESSION['userid']){

echo '<td><a href="index.php?loc=request&type=user&id='.$this-

>uname.'&action=remove&user_id='.$row['RID'].'" onclick="return deletechecked();">Remove

Friend</a></td>';

}

echo'</tr>';

}

}

}

echo '

</table>

</div>

</div>

</div>

</div>

<div class="top_links">

</div>';

}

}

?>

1.5. Group.php <?php

/**

* Group class to handle the group functionality, inherits

Page 14: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 14 | P a g e

* from the Page Class

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package group

*/

require_once("page.php");

require_once("home_tab.php");

require_once("browse.php");

require_once("privacy.php");

require_once("join.php");

require_once("message_center_tab.php");

require_once("friends_tab.php");

require_once("profile_tab.php");

require_once("members_tab.php");

require_once("label_tab.php");

class Group extends PageSuperClass

{

/**

* User's username

* @var string

*/

var $uname;

/**

* Group's name

* @var string

*/

var $name;

/**

* Type of user (user or group)

* @var string

*/

var $type;

/**

* Guest or not

* @var string

*/

var $guest;

/**

* Function to get the user's and group's info

*

* @param string

* @param string

* @param string

*/

function __construct($id, $name, $guest){

$this->uname = $id;

$this->name = $name;

$this->type = "group";

$this->guest = $guest;

}

/**

* Function to create a new member

*/

public function create_members()

{

$mem = new Members($this->uname, $this->fname, $this->lname, $this->type);

$mem -> create_main_content();

}

/**

* Function to display labeling conent

Page 15: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 15 | P a g e

*/

public function create_label()

{

make_label_content();

}

}

?>

1.6. Group_Tab.php <?php

/**

* Group Tab class and functions to handle the group tab functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package group tab

*/

class Group_Tab

{

/**

* User's username

* @var string

*/

var $uname;

/**

* User's first name

* @var string

*/

var $fname;

/**

* User's last name

* @var string

*/

var $lname;

/**

* If Guest

* @var string

*/

var $guest;

/**

* Function to get the user's and group's info

*

* @param string

* @param string

* @param string

* @param string

*/

function __construct($username, $firstname, $lastname, $guest){

$this->uname = $username;

$this->fname = $firstname;

$this->lname = $lastname;

$this->guest = $guest;

}

/**

* Function to display group tab's main content

*/

Page 16: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 16 | P a g e

public function create_main_content()

{

echo '

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<h3>Groups</h3>';

$results = run_query("SELECT `group`.groupname, UID, GID FROM membership LEFT JOIN `group`

ON membership.GID = `group`.ID WHERE UID = ".$this->uname." AND pending IS NULL AND

moderator IS NOT NULL ORDER BY `group`.groupname ASC");

while($row = mysql_fetch_array($results)){

echo '<a

href="index.php?loc=Home&type=group&id='.$row['GID'].'">'.$row['groupname'].'</a><br />';

}

echo'

</div>

</div>

</div>

</div>';

if(($this->uname == $_SESSION['userid']) && ($this->guest == "false") &&

($_SESSION[administrator] != 2)){

echo'

<div class="top_links">

<form name="fav" action="index.php?loc=Groups&action=create" method="post">

<input type="submit" value="Create Group" />

</form>

</div>';

}

else{

echo'

<div class="top_links">

</div>';

}

}

/**

* Function to handle the create group functionality

*/

public function create_create_group()

{

if($_SESSION[administrator] != 2){

?>

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<h3>Create a Group</h3>

<table cellpadding="5">

<form action="index.php?loc=Groups&action=validate" method="post">

<tr>

<td>Group Name<span class = "red">*</span>:</td><td><input type="text" name="name" value="<?

echo $_POST['name'];?>"/></td>

</tr>

<tr>

<td>Description<span class = "red">*</span>:</td><td><textarea name = "description" rows =

"5" cols = "20"><? echo $_POST['description'];?></textarea></td>

</tr>

<tr>

<td><input type="submit" name = "submit" value="Create" /></td>

</form>

<form name="cancel" action = "index.php?loc=Groups" method = "post">

<td><input type = "submit" value = "Cancel"></td></tr>

</form>

</table>

<span class = "red"><p>* = Required Field</p></span>

</div>

</div>

</div>

</div>

Page 17: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 17 | P a g e

<?php

}

else{

?>

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<h3>Sorry, Alumni can't create groups! Stop trying to cheat your way in!</h3>

</div>

</div>

</div>

</div>

<?

}

}

/**

* Function to further handle the create group functionality

*/

public function create_group_validate()

{

$name = $_POST['name'];

$description = $_POST['description'];

$flag = false;

$results = run_query("SELECT groupname FROM `group`");

while($row = mysql_fetch_array($results)){

if(strtolower($row['groupname']) == strtolower($name)){

$flag = true;

break;

}

}

if ((($name == "") || ($description == "")) || $flag){

if($flag){

$error = "That group name already exists. Please try another group name.";

}

else if(($name == "") && ($description == "")){

$error = "Please enter a group name and a description of the group.";

}

else if($name == ""){

$error = "Please enter a group name.";

}

else{

$error = "Please enter a description of the group.";

}

error_message("Error",$error);

$this->create_create_group();

}

else{

/* $q = "INSERT INTO `group` (groupname, `desc`) VALUES (?, ?)";

$params = array();

$params[0] = 'ss';

$params[1] = $name;

$params[2] = $description;

run_fail_query($q, $params); */

// run_query("INSERT INTO `group` (groupname, `desc`) VALUES ('".$name."',

'".$description."')");

$params = array();

$params[0] = 'ss';

$params[1] = $name;

$params[2] = $description;

run_baller_query("INSERT INTO `group` (groupname, `desc`) VALUES (?, ?)", $params);

// $results = run_query("SELECT ID From `group` WHERE groupname = '".$name."'");

$params = array();

$params[0] = 's';

$params[1] = $name;

$row = run_baller_query("SELECT ID From `group` WHERE groupname = ?", $params);

// $row = mysql_fetch_array($results);

Page 18: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 18 | P a g e

// run_query("INSERT INTO membership (UID, GID, pending, req_msg, resp_msg, moderator)

VALUES ('".$this->uname."', '".$row['ID']."', NULL, '', NULL, 1)");

$params = array();

$params[0] = 'ii';

$params[1] = $this->uname;

$params[2] = $row['ID'];

run_baller_query("INSERT INTO membership (UID, GID, pending, req_msg, resp_msg, moderator)

VALUES (?, ?, NULL, '', NULL, 1)", $params);

redirect("index.php?loc=Home&type=group&id=".$row['ID']."",0, "");

}

}

}

?>

1.7. Home_tab.php <?php

/**

* Home Tab class and functions to handle the home tab functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Home Tab

*/

class Home

{

/**

* User's username

* @var string

*/

var $uname;

/**

* User's firs tname

* @var string

*/

var $fname;

/**

* User's last name

* @var string

*/

var $lname;

/**

* User or Group

* @var string

*/

var $type;

/**

* If Guest

* @var string

*/

var $guest;

/**

* Function to get the user's and group's info

*

* @param string

* @param string

* @param string

* @param string

*/

Page 19: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 19 | P a g e

function __construct($username, $firstname, $lastname, $type, $guest){

$this->uname = $username;

$this->fname = $firstname;

$this->lname = $lastname;

$this->type = $type;

$this->guest = $guest;

}

/**

* Function to display home tab's main content

*/

public function create_main_content()

{

echo '

<div class="content_outer">

<div class="content_middle">

<div class="content">';

// $results = run_query("SELECT moderator FROM membership WHERE GID = ".$this->uname." AND

UID = ".$_SESSION['userid']."");

$params = array();

$params[0] = 'ii';

$params[1] = $this->uname;

$params[2] = $_SESSION['userid'];

$row = run_baller_query("SELECT moderator FROM membership WHERE GID = ? AND UID = ?",

$params);

// $row = mysql_fetch_array($results);

if((($this->uname == $_SESSION['userid']) || ($row['moderator'] == 1)) && ($this->guest ==

"false")){

echo'<ul id="ul1" class="draglist">';

$cls = "";

}

else{

echo'<ul id="ul1" class="draglist_no_move">';

$cls = "no_";

}

if($this->type == "group"){

$results = run_query("SELECT * FROM membership WHERE gtopmembers IS NOT NULL AND GID =

".$this->uname." ORDER BY gtopmembers ASC");

$count = 1;

while($row = mysql_fetch_array($results)){

// $results2 = run_query("SELECT * FROM user WHERE ID = ".$row['UID']."");

$params = array();

$params[0] = 'i';

$params[1] = $row['UID'];

$row2 = run_baller_query("SELECT firstname, lastname FROM user WHERE ID = ?", $params);

// $row2 = mysql_fetch_array($results2);

echo '<li class="list1" name ="'.$row['UID'].'" id="'.$cls.'li1_'.$count.'">

<div class="center">';

if($row['UID'] == $_SESSION['userid']){

echo'<a href="index.php?loc=Home"><h3>'.$row2['firstname'].'

'.$row2['lastname'].'</h3></a></div>';

}

else{

echo'<a href="index.php?loc=Home&type=user&id='.$row['UID'].'"><h3>'.$row2['firstname'].'

'.$row2['lastname'].'</h3></a></div>';

}

echo myTruncate($row['req_msg'], 390);

echo '</li>';

$count++;

}

}

else{

$results = run_query("SELECT * FROM membership WHERE utopmembers IS NOT NULL AND UID =

".$this->uname." ORDER BY utopmembers ASC");

$count = 1;

while($row = mysql_fetch_array($results)){

// $results2 = run_query("SELECT * FROM `group` WHERE ID = ".$row['GID']."");

$params = array();

$params[0] = 'i';

$params[1] = $row['GID'];

Page 20: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 20 | P a g e

$row2 = run_baller_query("SELECT groupname FROM `group` WHERE ID = ?", $params);

// $row2 = mysql_fetch_array($results2);

echo '<li class="list1" name ="'.$row['GID'].'" id="'.$cls.'li1_'.$count.'">

<div class="center"><a

href="index.php?loc=Home&type=group&id='.$row['GID'].'"><h3>'.$row2['groupname'].'</h3></a>

</div>

';

$temp_wall = new wall($row['GID'],"group", $guest);

$temp_wall->small_wall();

echo'</li>';

$count++;

}

}

echo'

</ul>

<div id = "content_height" style = "clear:both;">

</div>

</div>

</div>

</div>';

// $results = run_query("SELECT moderator FROM membership WHERE GID = ".$this->uname." AND

UID = ".$_SESSION['userid']."");

$params = array();

$params[0] = 'ii';

$params[1] = $this->uname;

$params[2] = $_SESSION['userid'];

$row = run_baller_query("SELECT moderator FROM membership WHERE GID = ? AND UID = ?",

$params);

// $row = mysql_fetch_array($results);

if((($this->uname == $_SESSION['userid']) && ($this->type == "user")) && ($this->guest ==

"false")){

echo'

<div class="top_links">

<form name="fav" action="index.php?loc=Home&action=pickfav" method="post">

<input type="submit" value="Pick Favorites" />

</form>

</div>

<script type="text/javascript">

var myrow = '.$count.';

var mycol = 3;

var page = "user_home";

var group = "-1";

</script>';

}

else if ((($row['moderator'] == 1) && ($this->type == "group")) && ($this->guest ==

"false")){

echo'

<div class="top_links">

<form name="fav" action="index.php?loc=Home&type=group&id='.$this->uname.'&action=pickfav"

method="post">

<input type="submit" value="Pick Favorites" />

</form>

</div>

<script type="text/javascript">

var myrow = '.$count.';

var mycol = 3;

var page = "group_home";

var group = '.$this->uname.';

</script>';

}

else {

echo'

<div class="top_links">

</div>';

}

?>

<script type="text/javascript" src="source_files/javascript/arrange.js">

</script>

<?php

}

Page 21: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 21 | P a g e

/**

* Function to display the User's or Group's top favorite friends

* or top Group friends

*/

public function create_main_content_fav()

{

if($_POST['submit'] == "Make Changes"){

$this->make_top_favs();

}

else if($_POST['submit'] == "Update Home"){

$this->make_group_top_favs();

}

?>

<script type="text/javascript" src="source_files/javascript/countchecks.js">

</script>

<?php

echo '

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">';

// $results = run_query("SELECT moderator FROM membership WHERE GID = ".$this->uname." AND

UID = ".$_SESSION['userid']."");

$params = array();

$params[0] = 'ii';

$params[1] = $this->uname;

$params[2] = $_SESSION['userid'];

$row = run_baller_query("SELECT moderator FROM membership WHERE GID = ? AND UID = ?",

$params);

// $row = mysql_fetch_array($results);

if(($row['moderator'] == 1) && ($this->type == "group")){

echo'

<h3>Select the Top Members</h3>

<p>Select the top members in your group to appear on the home page. You may choose up to 9

members</p>

<form name="checkb" action="index.php?loc=Home&type=group&id='.$this-

>uname.'&action=updatemem" method="post">

<table cellpadding="5">';

$results = run_query("SELECT user.firstname, user.lastname, UID, gtopmembers FROM membership

LEFT JOIN user ON membership.UID = user.ID WHERE membership.GID = ".$this->uname." AND

pending IS NULL ORDER BY user.firstname ASC");

while($row = mysql_fetch_array($results)){

if($row['gtopmembers'] != NULL){

$checked = "Checked";

}

else{

$checked = "";

}

echo '<tr>

<td>'.$row['firstname'].' '.$row['lastname'].'</td><td><input type="checkbox"

onClick="CountChecks(\'box'.$row['UID'].'\')" name="box'.$row['UID'].'" '.$checked.'"

/></td>

</tr>';

}

}

else{

echo'

<h3>Select Favorite Groups</h3>

<p>Select your favorite groups to appear on your Home tab. You may select up to 9

groups.</p>

<form name="checkb" action="index.php?loc=Home&action=pickfav" method="post">

<table cellpadding="5">';

$results = run_query("SELECT `group`.groupname, GID, utopmembers FROM membership LEFT JOIN

`group` ON membership.GID = `group`.ID WHERE membership.UID = ".$this->uname." AND pending

IS NULL AND moderator IS NOT NULL ORDER BY `group`.groupname ASC");

while($row = mysql_fetch_array($results)){

if($row['utopmembers'] != NULL){

$checked = "Checked";

}

else{

Page 22: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 22 | P a g e

$checked = "";

}

echo '<tr>

<td>'.$row['groupname'].'</td><td><input type="checkbox"

onClick="CountChecks(\'box'.$row['GID'].'\')" name="box'.$row['GID'].'" '.$checked.'"

/></td>

</tr>';

}

}

echo'

<tr><td><input type="submit" name = "submit" value="Make Changes" /></td></tr>

</table>

</form>

</div>

</div>

</div>

</div>';

}

/**

* Function to retreive and update the User's favorite groups

*/

public function make_top_favs(){

// $results = run_query("SELECT moderator FROM membership WHERE GID = ".$this->uname." AND

UID = ".$_SESSION['userid']."");

$params = array();

$params[0] = 'ii';

$params[1] = $this->uname;

$params[2] = $_SESSION['userid'];

$row = run_baller_query("SELECT moderator FROM membership WHERE GID = ? AND UID = ?",

$params);

// $row = mysql_fetch_array($results);

$mod = $row['moderator'];

if(($mod == 1) && ($this->type == "group")){

$results = run_query("SELECT UID FROM membership WHERE GID = ".$this->uname."");

while($row = mysql_fetch_array($results)){

run_query("UPDATE membership SET gtopmembers = NULL WHERE UID = ".$row['UID']." AND GID =

".$this->uname."");

}

}

else{

$results = run_query("SELECT GID FROM membership WHERE UID = ".$this->uname."");

while($row = mysql_fetch_array($results)){

run_query("UPDATE membership SET utopmembers = NULL WHERE GID = ".$row['GID']." AND UID =

".$this->uname."");

}

}

$count = 1;

foreach($_POST as $name => $value)

{

if ($name != "submit")

{

$a = explode("x", $name);

$id = $a[1];

if ($value == "on"){

if(($mod == 1) && ($this->type == "group")){

// run_query("UPDATE membership SET gtopmembers = ".$count." WHERE UID = ".$id." AND GID =

".$this->uname."");

$params = array();

$params[0] = 'iii';

$params[1] = $count;

$params[2] = $id;

$params[3] = $this->uname;

run_baller_query("UPDATE membership SET gtopmembers = ? WHERE UID = ? AND GID = ?",

$params);

}

else{

// run_query("UPDATE membership SET utopmembers = ".$count." WHERE GID = ".$id." AND UID =

".$this->uname."");

$params = array();

$params[0] = 'iii';

Page 23: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 23 | P a g e

$params[1] = $count;

$params[2] = $id;

$params[3] = $this->uname;

run_baller_query("UPDATE membership SET utopmembers = ? WHERE GID = ? AND UID = ?",

$params);

}

$count++;

}

}

}

error_message("Success!","Your favorite groups has been successfully updated!");

}

/**

* Function to retreive and update the Group's top members

*/

public function make_group_top_favs(){

// $results = run_query("SELECT moderator FROM membership WHERE GID = ".$this->uname." AND

UID = ".$_SESSION['userid']."");

$params = array();

$params[0] = 'ii';

$params[1] = $this->uname;

$params[2] = $_SESSION['userid'];

$row = run_baller_query("SELECT moderator FROM membership WHERE GID = ? AND UID = ?",

$params);

// $row = mysql_fetch_array($results);

$mod = $row['moderator'];

if(($mod == 1) && ($this->type == "group")){

$results = run_query("SELECT UID FROM membership WHERE GID = ".$this->uname."");

while($row = mysql_fetch_array($results)){

run_query("UPDATE membership SET gtopmembers = NULL WHERE UID = ".$row['UID']." AND GID =

".$this->uname."");

}

}

$count = 1;

foreach($_POST as $name => $value)

{

if ($name != "submit")

{

$a = explode("x", $name);

$id = $a[1];

if(($mod == 1) && ($this->type == "group")){

// run_query("UPDATE membership SET gtopmembers = ".$count.", req_msg = '".$value."' WHERE

UID = ".$id." AND GID = ".$this->uname."");

$params = array();

$params[0] = 'isii';

$params[1] = $count;

$params[2] = $value;

$params[3] = $id;

$params[4] = $this->uname;

run_baller_query("UPDATE membership SET gtopmembers = ?, req_msg = ? WHERE UID = ? AND GID =

?", $params);

$count++;

}

}

}

error_message("Success!","The top members have been successfully updated!");

}

/**

* Function to retreive and update the Group's highlighted member's involvement

*/

public function update_memembers(){

$mod = get_mod_status($this->uname);

echo '

<div class="content_outer">

<div class="content_middle">

<div class="content">

Page 24: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 24 | P a g e

<div class="readable">

<h3>Edit Member Involvement</h3>

<p>Please edit the involvement of the members appearing on the Home tab</p>

<form name="editmem" action="index.php?loc=Home&type=group&id='.$this-

>uname.'&action=pickfav" method="post">

<table>';

reset($_POST);

foreach($_POST as $name => $value){

if ($name != "submit")

{

$a = explode("x", $name);

$id = $a[1];

if(($mod == 1) && ($this->type == "group")){

// $results = run_query("SELECT user.firstname, user.lastname, req_msg FROM membership LEFT

JOIN user ON membership.UID = user.ID WHERE UID = ".$id." AND GID = ".$this->uname."");

$params = array();

$params[0] = 'ii';

$params[1] = $id;

$params[2] = $this->uname;

$row = run_baller_query("SELECT user.firstname, user.lastname, req_msg FROM membership LEFT

JOIN user ON membership.UID = user.ID WHERE UID = ? AND GID = ?", $params);

// $row = mysql_fetch_array($results);

echo '<tr><td>'.$row['firstname'].' '.$row['lastname'].'</td><td><textarea name =

"box'.$id.'" rows = "5" cols = "15">'.$row['req_msg'].'</textarea></td></tr>';

}

}

}

echo'

<tr><input type="submit" name = "submit" value="Update Home" /></tr>

</table>

</form>

</div>

</div>

</div>

</div>

';

}

}

?>

Page 25: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 25 | P a g e

1.8. Join.php <?php

/**

* Functions to handle the friend requesting, and group requesting

* and the group requesting another group for friendship

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Join

*/

/**

* Function to create the user requesting group join information

*

* @param string

* @param int

*/

function make_join_content($type, $id){

echo'

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<form name="send_request" action =

"index.php?loc=request&action=send&type='.$type.'&id='.$id.'" method="post">';

// $row = mysql_fetch_array(run_query("SELECT groupname FROM `group` WHERE ID = ".$id.""));

$params = array();

$params[0] = 'i';

$params[1] = $id;

$row = run_baller_query("SELECT groupname FROM `group` WHERE ID = ?", $params);

echo'

<p>Why would you like to join '.$row['groupname'].'? Feel free to describe your involvement

in the group or how you plan on becoming involved<span class = "red">*</span>.</p>

<textarea name = "reason" rows = "5" cols = "20">'.$_POST['reason'].'</textarea><br />

<input type="submit" name="submit" value="Send Request">

</form>

<span class = "red"><p>* = Required Field</p></span>

</div>

</div>

</div>

</div>

';

}

/**

* Function to send the user requesting group join information

*

* @param string

* @param int

*/

function make_join_content_send($type, $id){

if($_POST['reason'] == ""){

error_message("Error","Please fill out why you would like to join the group!");

make_join_content($type, $id);

}

else{

$row = mysql_fetch_array(run_query("SELECT * FROM membership WHERE UID =

".$_SESSION['userid']." AND GID = ".$id.""));

if ($row == FALSE){

// run_query("INSERT INTO membership (UID, GID, req_msg) VALUES (".$_SESSION['userid'].",

".$id.", '".$_POST['reason']."')");

$params = array();

$params[0] = 'iis';

$params[1] = $_SESSION['userid'];

$params[2] = $id;

$params[3] = $_POST['reason'];

run_baller_query("INSERT INTO membership (UID, GID, req_msg) VALUES (?, ?, ?)", $params);

Page 26: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 26 | P a g e

}

else{

// run_query("UPDATE membership SET req_msg = '".$_POST['reason']."', moderator = 0, pending

= '".date("H:i:s")."' WHERE UID = ".$_SESSION['userid']." and GID = ".$id."");

$params = array();

$params[0] = 'sii';

$params[1] = $_POST['reason'];

$params[2] = $_SESSION['userid'];

$params[3] = $id;

run_baller_query("UPDATE membership SET req_msg = ?, moderator = 0, pending =

'".date("H:i:s")."' WHERE UID = ? and GID = ?", $params);

}

redirect( "index.php?loc=Home&type=group&id=".$id."", 0, "" );

}

}

/**

* Function to send the friend request

*

* @param string

* @param int

*/

function send_friend_request($type, $id){

// run_query("INSERT INTO user_friend (RID, AID) VALUES (".$_SESSION['userid'].",

".$id.")");

$params = array();

$params[0] = 'ii';

$params[1] = $_SESSION['userid'];

$params[2] = $id;

run_baller_query("INSERT INTO user_friend (RID, AID) VALUES (?, ?)", $params);

redirect( "index.php?loc=Home&type=user&id=".$id."", 0, "" );

}

/**

* Function to accept or deny user friend request

*

* @param string

* @param int

* @param string

*/

function accept_deny_user_friend($type, $id, $action){

if($action == "accept"){

// run_query("UPDATE user_friend SET pending = NULL WHERE RID = ".$id." and AID =

".$_SESSION['userid']."");

$params = array();

$params[0] = 'ii';

$params[1] = $id;

$params[2] = $_SESSION['userid'];

run_baller_query("UPDATE user_friend SET pending = NULL WHERE RID = ? and AID = ?",

$params);

}

else if($action == "deny"){

// run_query("DELETE FROM user_friend WHERE RID = ".$id." and AID =

".$_SESSION['userid']."");

$params = array();

$params[0] = 'ii';

$params[1] = $id;

$params[2] = $_SESSION['userid'];

run_baller_query("DELETE FROM user_friend WHERE RID = ? and AID = ?", $params);

}

redirect( "index.php?loc=Message_Center", 0, "" );

}

/**

* Function to create the user requesting group join accept or deny information

* for the requested group

*

* @param string

* @param int

* @param int

Page 27: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 27 | P a g e

*/

function make_join_accept_deny($type, $id, $user_id){

echo'

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<form name="send_request" action =

"index.php?loc=request&action=acceptdeny&type='.$type.'&id='.$id.'&user_id='.$user_id.'"

method="post">';

// $row = mysql_fetch_array(run_query("SELECT firstname, lastname FROM user WHERE ID =

".$user_id.""));

$params = array();

$params[0] = 'i';

$params[1] = $user_id;

$row = run_baller_query("SELECT firstname, lastname FROM user WHERE ID = ?", $params);

// $row2 = mysql_fetch_array(run_query("SELECT req_msg FROM membership WHERE UID =

".$user_id." AND GID = ".$id.""));

$params = array();

$params[0] = 'ii';

$params[1] = $user_id;

$params[2] = $id;

$row2 = run_baller_query("SELECT req_msg FROM membership WHERE UID = ? AND GID = ?",

$params);

echo $row['firstname'].' '.$row['lastname'].' wants to join because "'.$row2['req_msg'].'".

<p>Please explain why you want to accept or deny '.$row['firstname'].' '.$row['lastname'].'.

Feel free to provide feedback as to why the person was denied or on their involvemnt in the

group if they are accepted<span class = "red">*</p>

<textarea name = "reason" rows = "5" cols = "20">'.$_POST['reason'].'</textarea><br />

<input type="submit" name="submit" value="Accept">

<input type="submit" name="submit" value="Deny">

</form>

<span class = "red"><p>* = Required Field</p></span>

</div>

</div>

</div>

</div>

';}

/**

* Function to create the user requesting group join accept or deny information

* for the request group

*

* @param string

* @param int

* @param int

*/

function acceptdeny($type, $id, $user_id){

if($_POST['reason'] == ""){

error_message("Error","Please fill out why you accepted or denied the person!");

make_join_accept_deny($type, $id, $user_id);

}

else{

if($_POST['submit'] == "Accept"){

// run_query("UPDATE membership SET pending = NULL, resp_msg = '".$_POST['reason']."' WHERE

UID = ".$user_id." and GID = ".$id."");

$params = array();

$params[0] = 'sii';

$params[1] = $_POST['reason'];

$params[2] = $user_id;

$params[3] = $id;

run_baller_query("UPDATE membership SET pending = NULL, resp_msg = ? WHERE UID = ? and GID =

?", $params);

}

else if($_POST['submit'] == "Deny"){

// run_query("UPDATE membership SET pending = NULL, resp_msg = '".$_POST['reason']."',

moderator = NULL WHERE UID = ".$user_id." and GID = ".$id."");

$params = array();

$params[0] = 'sii';

$params[1] = $_POST['reason'];

$params[2] = $user_id;

Page 28: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 28 | P a g e

$params[3] = $id;

run_baller_query("UPDATE membership SET pending = NULL, resp_msg = ?, moderator = NULL WHERE

UID = ? and GID = ?", $params);

}

redirect( "index.php?loc=Message_Center&type=group&id=".$id."", 0, "" );

}

}

/**

* Function to update that the response message has been seen and is set back to NULL

*

* @param string

* @param int

*/

function seen($type, $id){

// run_query("UPDATE membership SET resp_msg = NULL WHERE UID = ".$_SESSION['userid']." and

GID = ".$id."");

$params = array();

$params[0] = 'ii';

$params[1] = $_SESSION['userid'];

$params[2] = $id;

run_baller_query("UPDATE membership SET resp_msg = NULL WHERE UID = ? and GID = ?",

$params);

redirect( "index.php?loc=Message_Center", 0, "" );

}

/**

* Function to accept group friend request

*

* @param string

* @param int

* @param int

*/

function accept_group_friend($type, $id, $group_id){

// run_query("UPDATE group_friend SET pending = NULL WHERE RID = ".$group_id." and AID =

".$id."");

$params = array();

$params[0] = 'ii';

$params[1] = $group_id;

$params[2] = $id;

run_baller_query("UPDATE group_friend SET pending = NULL WHERE RID = ? and AID = ?",

$params);

redirect( "index.php?loc=Message_Center&type=group&id=".$id."", 0, "" );

}

/**

* Function to deny group friend request

*

* @param string

* @param int

* @param int

*/

function deny_group_friend($type, $id, $group_id){

// run_query("DELETE FROM group_friend WHERE RID = ".$group_id." and AID = ".$id."");

$params = array();

$params[0] = 'ii';

$params[1] = $group_id;

$params[2] = $id;

run_baller_query("DELETE FROM group_friend WHERE RID = ? and AID = ?", $params);

redirect( "index.php?loc=Message_Center&type=group&id=".$id."", 0, "" );

}

/**

* Function to send group friend request

*

Page 29: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 29 | P a g e

* @param string

* @param int

* @param int

*/

function send_group_friend_request($type, $id, $group_id){

// run_query("INSERT INTO group_friend (RID, AID) VALUES (".$id.", ".$group_id.")");

$params = array();

$params[0] = 'ii';

$params[1] = $id;

$params[2] = $group_id;

run_baller_query("INSERT INTO group_friend (RID, AID) VALUES (?, ?)", $params);

redirect( "index.php?loc=browse&type=group&id=".$id."", 0, "" );

}

/**

* Function to remove a group friend

*

* @param string

* @param int

* @param int

*/

function remove_friend($type, $id, $user_id){

// run_query("DELETE FROM user_friend WHERE (RID = ".$user_id." and AID =

".$_SESSION['userid'].") || (AID = ".$user_id." and RID = ".$_SESSION['userid'].")");

$params = array();

$params[0] = 'iiii';

$params[1] = $user_id;

$params[2] = $_SESSION['userid'];

$params[3] = $user_id;

$params[4] = $_SESSION['userid'];

run_baller_query("DELETE FROM user_friend WHERE (RID = ? and AID = ?) || (AID = ? and RID =

?)", $params);

redirect( "index.php?loc=Friends", 0, "" );

}

?>

1.9. Label_tab.php <?php

/**

* Functions to handle the label functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Label Tab

*/

/**

* Function to update labels

*/

function update_label()

{

// $results = run_query("DELETE FROM labeled WHERE GID = ".$_GET['id']."");

$params = array();

$params[0] = 'i';

$params[1] = $_GET['id'];

$results = run_baller_query("DELETE FROM labeled WHERE GID = ?", $params);

foreach($_POST as $name => $value)

{

if ($name != "submit")

{

if ($value == "met"){

// run_query("INSERT INTO labeled (GID, LID) VALUES (".$_GET['id'].", ".$name.")");

Page 30: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 30 | P a g e

$params = array();

$params[0] = 'ii';

$params[1] = $_GET['id'];

$params[2] = $name;

run_baller_query("INSERT INTO labeled (GID, LID) VALUES (?, ?)", $params);

}

}

}

}

/**

* Function to display the labels met or not met by each group

*/

function make_label_content()

{

if($_POST['submit'] == "Label"){

update_label();

error_message("Success","The group was properly labeled!");

}

echo'

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<center>

<table cellpadding="5">

<tr><th>Type of R</th><th>Met</th><th>Not Met</th></tr>

<form name = "label" action = "index.php?loc=label&type=group&id='.$_GET['id'].'" method =

"post">';

$results = run_query("SELECT * FROM label");

while ($row = mysql_fetch_array($results)){

$results2 = run_query("SELECT * FROM labeled WHERE GID = ".$_GET['id']." AND LID =

".$row['ID']."");

if(mysql_fetch_row($results2) == FALSE){

$m_checked = "";

$nm_checked = "Checked";

}

else{

$m_checked = "Checked";

$nm_checked = "";

}

echo '<tr><td>'.$row['label'].'</td><td><input type="radio" name="'.$row['ID'].'"

value="met" '.$m_checked.'></td><td><input type="radio" name="'.$row['ID'].'" value="notmet"

'.$nm_checked.'></td></tr> ';

}

echo'

<tr><td><input type="submit" name="submit" value="Label"></td></tr>

</form>

</table>

</center>

</div>

</div>

</div>

</div>

';

}

?>

Page 31: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 31 | P a g e

1.10. Login.php <?php

/**

* Functions to handle the login functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Login

*/

require_once("utilities.php");

/**

* Sets post variable of form submission

* @var string

*/

$action = $_POST['submit'];

/**

* Sets post variable of email submission

* @var string

*/

$id = $_POST['email'];

/**

* Sets post variable of password submission

* @var string

*/

$given_passwd = $_POST['pwd'];

if(($action == "Sign In") && ($id == "sbsAdministrator") && ($given_passwd == "poop123")){

session_start();

$_SESSION['authenticated'] = true;

$_SESSION['userid'] = $id;

$_SESSION['administrator'] = "superadmin";

header("Location: super_admin.php");

}

$a = explode("@", $id);

$ext = $a[1];

if($ext != "siena.edu"){

$q = "SELECT ID, password FROM guest WHERE username = ?";

$params = array();

$params[0] = 's';

$params[1] = $id;

$row = run_baller_query($q, $params);

}

else{

$q = "SELECT ID, password, usertype FROM user WHERE username = ?";

$params = array();

$params[0] = 's';

$params[1] = $id;

$row = run_baller_query($q, $params);

}

// $row = mysql_fetch_array($results);

$stored_passwd = $row['password'];

$given_passwd = md5(trim($given_passwd));

if(($action == "Sign In") && ($given_passwd == $stored_passwd)){

session_start();

$_SESSION['authenticated'] = true;

if ($ext != "siena.edu"){

$_SESSION['administrator'] = "guest";

$_SESSION['userid'] = -1;

}

else{

Page 32: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 32 | P a g e

$_SESSION['administrator'] = $row['usertype'];

$_SESSION['userid'] = $row['ID'];

}

if($ext != "siena.edu"){

header("Location: ../../index.php?loc=browse");

}

else{

header("Location: ../../index.php?loc=Home");

}

}

else{

make_header("Log In");

if($action == "Sign In"){

error_message("Error","Username and password do not match.");

}

echo'

<div id="container">

<div id = "header">

<h1>Welcome!</h1>

</div>

<div id = "content">

<h2>Login</h2>

<table>

<form action="login.php" method="post">

<tr>

<td>Email:</td><td><input type="text" name="email" value="'.$_POST['email'].'"/></td>

</tr>

<tr>

<td>Password:</td><td><input type="password" name="pwd" /></td>

</tr>

<tr>

<td><input type="submit" name = "submit" value="Sign In" /></td>

</tr>

</form>

</table>

<div class = "links">

<a href="register.php">Register</a> | <a href="forgot_password.php">Forgot Password?</a>

</div>

</div>

';

make_footer_unauth();

}

?>

1.11. Logout.php <?php

/**

* Logs out user by ending the session

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Logout

*/

include("utilities.php");

session_start();

session_destroy();

$_SESSION = array();

redirect( "../../", 0, "" );

?>

Page 33: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 33 | P a g e

Page 34: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 34 | P a g e

1.12. Members_tab.php <?php

/**

* Members class and functions to handle the Members Tab functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Members Tab

*/

class Members

{

/**

* User's username

* @var string

*/

var $uname;

/**

* User's firstrname

* @var string

*/

var $fname;

/**

* User's lastrname

* @var string

*/

var $lname;

/**

* Useror Group

* @var string

*/

var $type;

/**

* Function to get the user's and group's info

*

* @param string

* @param string

* @param string

* @param string

*/

function __construct($username, $firstname, $lastname, $type){

$this->uname = $username;

$this->fname = $firstname;

$this->lname = $lastname;

$this->type = $type;

}

/**

* Function to display member tab's main content

*/

public function create_main_content()

{

echo '<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">';

$results = run_query("SELECT user.firstname, user.lastname, UID, moderator FROM membership

LEFT JOIN user ON membership.UID = user.ID WHERE GID = ".$this->uname." AND moderator IS NOT

NULL AND pending IS NULL ORDER BY firstname ASC");

while($row = mysql_fetch_array($results)){

if($row['moderator'] == 1){

echo '<h3>Moderator</h3>';

Page 35: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 35 | P a g e

echo '<a href="index.php?loc=Home&type=user&id='.$row['UID'].'">'.$row['firstname'].'

'.$row['lastname'].'</a><br /><br /><h4>Members</h4>';

}

}

$results = run_query("SELECT user.firstname, user.lastname, UID, moderator FROM membership

LEFT JOIN user ON membership.UID = user.ID WHERE GID = ".$this->uname." AND moderator IS NOT

NULL AND pending IS NULL ORDER BY firstname ASC");

while($row = mysql_fetch_array($results)){

if($row['moderator'] != 1){

echo '<a href="index.php?loc=Home&type=user&id='.$row['UID'].'">'.$row['firstname'].'

'.$row['lastname'].'</a><br />';

}

}

echo '

</div>

</div>

</div>

</div>

<div class="top_links">

</div>';

}

}

?>

1.13. Message_center_tab.php <?php

/**

* Message Center class and functions to handle the home tab functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Message Center Tab

*/

class Message_Center

{

/**

* User's username

* @var string

*/

var $uname;

/**

* User's first name

* @var string

*/

var $fname;

/**

* User's last name

* @var string

*/

var $lname;

/**

* User or Group

* @var string

*/

var $type;

/**

* Function to get the user's and group's info

*

* @param string

Page 36: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 36 | P a g e

* @param string

* @param string

* @param string

*/

function __construct($username, $firstname, $lastname, $type){

$this->uname = $username;

$this->fname = $firstname;

$this->lname = $lastname;

$this->type = $type;

}

/**

* Function to display message center tab's main content

*/

public function create_main_content()

{

if($this->type == "group"){

$results = run_query("SELECT `group`.groupname, RID FROM group_friend LEFT JOIN `group` ON

group_friend.RID = `group`.ID WHERE AID = ".$this->uname." AND pending IS NOT NULL");

}

else{

$results = run_query("SELECT user.firstname, user.lastname, RID FROM user_friend LEFT JOIN

user ON user_friend.RID = user.ID WHERE AID = ".$_SESSION['userid']." AND pending IS NOT

NULL");

}

echo '

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<div id = "friend_center">

<h3>Friends Center</h3>

<table>';

while($row = mysql_fetch_array($results)){

if($this->type == "group"){

echo '<tr><td><a href =

"index.php?loc=Home&type=group&id='.$row['RID'].'">'.$row['groupname'].'</a>-</td><td><a

href="index.php?loc=request&type=group&id='.$this-

>uname.'&group_id='.$row['RID'].'&action=accept">Accept</a></td><td>/</td><td><a href =

"index.php?loc=request&type=group&id='.$this-

>uname.'&group_id='.$row['RID'].'&action=deny">Deny</a></td></tr>';

}

else{

echo '<tr><td><a href =

"index.php?loc=Home&type=user&id='.$row['RID'].'">'.$row['firstname'].'

'.$row['lastname'].'</a>-</td><td><a

href="index.php?loc=request&type=user&id='.$row['RID'].'&action=accept">Accept</a></td><td>/

</td><td><a href =

"index.php?loc=request&type=user&id='.$row['RID'].'&action=deny">Deny</a></td></tr>';

}

}

echo'

</table>

</div>

';

echo'

<div id = "group_center">';

if($this->type == "group"){

echo'<h3>Members Center</h3>';

$results = run_query("SELECT user.firstname, user.lastname, UID, req_msg FROM membership

LEFT JOIN user ON membership.UID = user.ID WHERE GID = ".$this->uname." AND pending IS NOT

NULL");

while($row = mysql_fetch_array($results)){

echo $row['firstname'].' '.$row['lastname'].' wants to become a member. <br /><a href =

"index.php?loc=request&type=group&id='.$this-

>uname.'&user_id='.$row['UID'].'&action=deal">Click Here</a> to accept or deny this

person.<br /><br />';

}

Page 37: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 37 | P a g e

}

else{

echo'<h3>Groups Center</h3>';

$results = run_query("SELECT `group`.groupname, GID, resp_msg, moderator FROM membership

LEFT JOIN `group` ON membership.GID = `group`.ID WHERE UID = ".$this->uname." AND resp_msg

IS NOT NULL");

while($row = mysql_fetch_array($results)){

echo $row['groupname'].' has ';

if($row['moderator'] != NULL){

echo'accepted';

}

else {

echo'denied';

}

echo' your request stating "'.$row['resp_msg'].'". <a href =

"index.php?loc=request&type=group&id='.$row['GID'].'&action=seen">Remove</a><br /><br />';

}

}

echo'

</div>

';

if($this->type == "user"){

echo'

<div id = "moderator_center">

<h3>Moderator Center</h3>';

$flag = false;

$results = run_query("SELECT `group`.groupname, GID FROM membership LEFT JOIN `group` ON

membership.GID = `group`.ID WHERE UID = ".$_SESSION['userid']." AND moderator = 1");

while($row = mysql_fetch_array($results)){

$results2 = run_query("SELECT pending FROM membership WHERE GID = ".$row['GID']." and

pending IS NOT NULL");

while($row2 = mysql_fetch_array($results2)){

$flag = true;

break;

}

if (!$flag){

$results2 = run_query("SELECT pending FROM group_friend WHERE AID = ".$row['GID']." and

pending IS NOT NULL");

while($row2 = mysql_fetch_array($results2)){

$flag = true;

break;

}

}

echo '<a href =

"index.php?loc=Message_Center&type=group&id='.$row['GID'].'">'.$row['groupname'].'</a>';

if ($flag){

echo '<img src="style/img/star.png" alt="star">';

}

echo '<br />';

$flag = false;

}

echo'

</div>';

}

echo '

</div>

</div>

</div>

</div>

<div class="top_links">

</div>';

}

}

?>

Page 38: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 38 | P a g e

1.14. Page.php <?php

/**

* Page Super class and functions to handle all the common functions

* between users and groups

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Page

*/

class PageSuperClass

{

function __construct()

{

}

/**

* Function to instantiate a new Home Class, handle the pick

* favorite and update member display for the Home Tab

*/

public function create_home()

{

$action = $_GET['action'];

$home = new Home($this->uname, $this->fname, $this->lname, $this->type, $this->guest);

if ($action == "pickfav"){

$home -> create_main_content_fav();

}

else if ($action == "updatemem"){

$home -> update_memembers();

}

else{

$home -> create_main_content();

}

}

/**

* Function to instantiate a new Profile Class and to handle the

* display of edit profile information, add content, upload photos and

* add photos

*/

public function create_profile()

{

$action = $_GET['action'];

$profile = new Profile($this->uname, $this->fname, $this->lname, $this->type, $this->guest);

if ($action == "edit"){

$profile -> edit_profile();

}

else if($action == "add"){

$profile -> add_content();

}

else if($action == "upload"){

$profile -> upload_photo();

}

else if($action == "add_photo"){

$profile -> add_photo();

}

else{

$profile -> create_main_content();

}

}

/**

* Function to instantiate a new Message Center Class and to display

* the main content

Page 39: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 39 | P a g e

*/

public function create_message_center()

{

$mc = new Message_Center($this->uname, $this->fname, $this->lname, $this->type);

$mc -> create_main_content();

}

/**

* Function to instantiate a new Friend Tab Class and to display

* the main content

*/

public function create_friends()

{

$friends = new Friend_Tab($this->uname, $this->fname, $this->lname, $this->type);

$friends -> create_main_content();

}

/**

* Function to display the main browser content

*/

public function browse()

{

make_browse_content();

}

/**

* Function to display the privacy content for this user

*/

public function privacy()

{

make_privacy_content($this->uname);

}

/**

* Function to handle the requests made by actions

* @param string

* @param int

*/

public function request($type, $id)

{

$action = $_GET['action'];

if($type == "user"){

if($action == "remove"){

$user_id = $_GET['user_id'];

remove_friend($type, $id, $user_id);

}

else if($action == ""){

send_friend_request($type, $id);

}

else{

accept_deny_user_friend($type, $id, $action);

}

}

else if ($action == "send"){

make_join_content_send($type, $id);

}

else if ($action == "deal"){

$user_id = $_GET['user_id'];

make_join_accept_deny($type, $id, $user_id);

}

else if ($action == "acceptdeny"){

$user_id = $_GET['user_id'];

acceptdeny($type, $id, $user_id);

}

else if ($action == "seen"){

seen($type, $id);

}

else if ($action == "accept"){

accept_group_friend($type, $id, $_GET['group_id']);

Page 40: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 40 | P a g e

}

else if ($action == "deny"){

deny_group_friend($type, $id, $_GET['group_id']);

}

else if ($action == "groupfriend"){

send_group_friend_request($type, $id, $_GET['group_id']);

}

else{

make_join_content($type, $id);

}

}

}?>

1.15. Privacy.php <?php

/**

* Functions to handle the privacy functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Privacy

*/

/**

* Function to displau the user's privacy settings and to

* change the settings from public to private

*

* @param int

*/

function make_privacy_content($id)

{

if($_GET['select'] == "public"){

// run_query("UPDATE user SET public = 1 WHERE ID = ".$id."");

$params = array();

$params[0] = 'i';

$params[1] = $id;

run_baller_query("UPDATE user SET public = 1 WHERE ID = ?", $params);

}

else if($_GET['select'] == "private"){

// run_query("UPDATE user SET public = 0 WHERE ID = ".$id."");

$params = array();

$params[0] = 'i';

$params[1] = $id;

run_baller_query("UPDATE user SET public = 0 WHERE ID = ?", $params);

}

//$results = run_query("SELECT public FROM user WHERE ID = ".$id."");

$params = array();

$params[0] = 'i';

$params[1] = $id;

$row = run_baller_query("SELECT public FROM user WHERE ID = ?", $params);

// $row = mysql_fetch_array($results);

if($row['public'] == 1)

{

$pub = "Checked";

}

else{

$priv = "Checked";

}

echo'

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

Page 41: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 41 | P a g e

<center>

<h3>Privacy Settings</h3>

<p>This option will make your entire page either public or private. If your page is private

all content is hidden except for

your profile picture and name to people who are not your friends.</p>

<form>

Public <input type="radio" onClick = "location.href=\'index.php?loc=privacy&select=public\'"

name="select" value="Public" '.$pub.'> | &nbsp;

Private <input type="radio" onClick =

"location.href=\'index.php?loc=privacy&select=private\'" name="select" value="Private"

'.$priv.'>

</form>

</center>

</div>

</div>

</div>

</div>

<div class="top_links">

</div>

';

}

?>

1.16. Profile.php <?php

/**

* Profile class and functions to handle the profile functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Profile

*/

class Profile

{

/**

* User's username

* @var string

*/

var $uname;

/**

* User's first name

* @var string

*/

var $fname;

/**

* User's last name

* @var string

*/

var $lname;

/**

* Function to get the user's and group's info

*

* @param string

* @param string

* @param string

*/

function __construct($username, $firstname, $lastname){

$this->uname = $username;

$this->fname = $firstname;

Page 42: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 42 | P a g e

$this->lname = $lastname;

}

/**

* Function to display profile's main content

*/

public function create_main_content()

{

echo '

<div id="main_content">

<div class="top_links">

<form name="fav" action="index.php?loc=Home&action=pickfav" method="post">

<input type="submit" value="Pick Favorites" />

</form>

</div>

</div>

';

}

/**

* Function to display profile's favorite main content

*/

public function create_main_content_fav()

{

echo '

<div id="main_content">

<div class="top_links">

</div>

Pick Fav

</div>

';

}

}

?>

1.17. Profile_tab.php <?php

/**

* Profile class and functions to handle the profile functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Profile

*/

class Profile

{

/**

* User's username

* @var string

*/

var $uname;

/**

* User's first name

* @var string

*/

var $fname;

/**

* User's last name

* @var string

*/

Page 43: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 43 | P a g e

var $lname;

/**

* User or Group

* @var string

*/

var $type;

/**

* Is guest

* @var string

*/

var $guest;

/**

* Function to get the user's and group's info

*

* @param string

* @param string

* @param string

* @param string

*/

function __construct($username, $firstname, $lastname, $type, $guest){

$this->uname = $username;

$this->fname = $firstname;

$this->lname = $lastname;

$this->type = $type;

$this->guest = $guest;

}

/**

* Function to display profile tab's main content

*/

public function create_main_content()

{

echo '

<div class="content_outer">

<div class="content_middle">

<div class="content">';

if($this->type == "group"){

$mod = get_mod_status($this->uname);

}

else{

$mod = -23;

}

if((($this->uname == $_SESSION['userid']) || (($mod == 1) && ($this->type = "group"))) &&

($this->guest == "false")){

echo'<ul id="ul1" class="draglist">';

$cls = "";

}

else{

echo'<ul id="ul1" class="draglist_no_move">';

$cls = "no_";

}

$count = 1;

if(($this->type == "group")){

$results = run_query("SELECT * FROM group_profile WHERE ID = ".$this->uname." ORDER BY

location ASC");

}

else{

$results = run_query("SELECT * FROM user_profile WHERE ID = ".$this->uname." ORDER BY

location ASC");

}

while($row = mysql_fetch_array($results)){

if($row['location'] == -1){

}

else{

if($row['type'] == 1){

Page 44: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 44 | P a g e

echo '<li class="list1" name ="'.$row['autonum'].'" id="'.$cls.'li1_'.$count.'"><div class =

"question">'.myTruncate($row['questionurl'], 70).'</div><div class =

"answer">'.myTruncate($row['anscaption'], 187).'</div></li>';

}

else{

echo '<li class="list1" name ="'.$row['autonum'].'" id="'.$cls.'li1_'.$count.'"><div class =

"prof_pic"><img src="'.$row['questionurl'].'" alt="pic" /></div><div class =

"caption">'.myTruncate($row['anscaption'], 85).'</div></li>';

}

$count++;

}

}

echo'

</ul>

<div id = "content_height" style = "clear:both;"></div>

</div>

</div>

</div>';

if((($this->uname == $_SESSION['userid']) && ($this->type == "user")) && ($this->guest ==

"false")){

echo'

<div class="top_links">

<form name="edit" class = "form_left" action="index.php?loc=Profile&action=edit"

method="post">

<input type="submit" value="Edit" />

</form>

<form name="upload" class = "form_left" action="index.php?loc=Profile&action=upload"

method="post">

<input type="submit" value="Upload Photo" />

</form>

</div>

<script type="text/javascript">

var myrow = '.$count.';

var mycol = 3;

var page = "user_profile";

var group = "-1";

</script>';

}

else if((($mod == 1) && ($this->type == "group")) && ($this->guest == "false")){

echo'

<div class="top_links">

<form name="edit" class = "form_left" action="index.php?loc=Profile&type=group&id='.$this-

>uname.'&action=edit" method="post">

<input type="submit" value="Edit" />

</form>

<form name="upload" class = "form_left" action="index.php?loc=Profile&type=group&id='.$this-

>uname.'&action=upload" method="post">

<input type="submit" value="Upload Photo" />

</form>

</div>

<script type="text/javascript">

var myrow = '.$count.';

var mycol = 3;

var page = "group_profile";

var group = '.$this->uname.';

</script>';

}

else {

echo'

<div class="top_links">

</div>

<script type="text/javascript">

var myrow = 0;

var mycol = 0;

var page = "";

var group = -7;

</script>';

}

?>

Page 45: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 45 | P a g e

<script type="text/javascript" src="source_files/javascript/arrange.js">

</script>

<?php

}

/**

* Function to display the edit profile tab's content

*/

public function edit_profile()

{

$mod = get_mod_status($this->uname);

echo '

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<h3>Add Content to your Profile</h3>

<table cellpadding="5">';

if(($mod ==1) && ($this->type == "group")){

echo'

<form name="content" action = "index.php?loc=Profile&type=group&id='.$this-

>uname.'&action=add" method = "post">';

}

else{

echo'

<form name="content" action = "index.php?loc=Profile&action=add" method = "post">';

}

echo'

<tr><td>Add a Question/Statement<span class = "red">*</span>:</td> <td><input type = "text"

name = "question" value = "'.$_POST['question'].'"></td></tr>

<tr><td>Write your Answer<span class = "red">*</span>:</td> <td><textarea rows = "6" cols =

"20" name = "answer">'.$_POST['answer'].'</textarea></td></tr>

<tr><td><input type = "submit" value = "Add"></td><td>

</form>';

if($this->type == "group"){

echo'

<form name="cancel" action = "index.php?loc=Profile&type=group&id='.$this->uname.'" method =

"post">';

}

else{

echo'

<form name="cancel" action = "index.php?loc=Profile" method = "post">';

}

echo'

<input type = "submit" value = "Cancel"></td>

</form>

</td>

</tr>

</table>

<span class = "red"><p>* = Required Field</p></span>

</div>

</div>

</div>

</div>

';

if(($this->uname == $_SESSION['userid']) && ($this->type == "user")){

echo'

<div class="top_links">

<form name="upload" class = "form_left" action="index.php?loc=Profile&action=upload"

method="post">

<input type="submit" value="Upload Photo" />

</form>

</div>';

}

else if(($mod == 1) && ($this->type == "group")){

echo'

<div class="top_links">

<form name="upload" class = "form_left" action="index.php?loc=Profile&type=group&id='.$this-

>uname.'&action=upload" method="post">

<input type="submit" value="Upload Photo" />

</form>

Page 46: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 46 | P a g e

</div>';

}

}

/**

* Function to handle the add profile tab's content and update the database

*/

public function add_content()

{

$mod = get_mod_status($this->uname);

if($_POST['question'] == "" || $_POST['answer'] == "" ){

if($_POST['question'] == "" && $_POST['answer'] == "" ){

$error = "Please fill out both fields";

}

else if($_POST['question'] == ""){

$error = "Please add a question/statement.";

}

else{

$error = "Please write your answer/response.";

}

error_message("Error",$error);

$this->edit_profile();

}

else if (($mod == 1) && ($this->type == "group")){

$results = run_query("SELECT location FROM group_profile WHERE ID = ".$this->uname." ORDER

BY location DESC");

$row = mysql_num_rows($results);

if($row == 0){

$count = 1;

}

else{

$row = mysql_fetch_array($results);

$count = $row['location'] + 1;

}

// run_query("INSERT INTO group_profile (ID, type, questionurl, anscaption, location) VALUES

(".$this->uname.", 1, '".$_POST['question']."', '".$_POST['answer']."', ".$count.")");

$params = array();

$params[0] = 'issi';

$params[1] = $this->uname;

$params[2] = $_POST['question'];

$params[3] = $_POST['answer'];

$params[4] = $count;

run_baller_query("INSERT INTO group_profile (ID, type, questionurl, anscaption, location)

VALUES (?, 1, ?, ?, ?)", $params);

redirect("index.php?loc=Profile&type=group&id=".$this->uname."", 0 , "");

}

else{

$results = run_query("SELECT location FROM user_profile WHERE ID = ".$this->uname." ORDER BY

location DESC");

$row = mysql_num_rows($results);

if($row == 0){

$count = 1;

}

else{

$row = mysql_fetch_array($results);

$count = $row['location'] + 1;

}

// run_query("INSERT INTO user_profile (ID, type, questionurl, anscaption, location) VALUES

(".$this->uname.", 1, '".$_POST['question']."', '".$_POST['answer']."', ".$count.")");

$params = array();

$params[0] = 'issi';

$params[1] = $this->uname;

$params[2] = $_POST['question'];

$params[3] = $_POST['answer'];

$params[4] = $count;

run_baller_query("INSERT INTO user_profile (ID, type, questionurl, anscaption, location)

VALUES (?, 1, ?, ?, ?)", $params);

redirect("index.php?loc=Profile", 0 , "");

}

Page 47: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 47 | P a g e

}

/**

* Function to handle/display the profile tab's upload photo content and update

* the database with changes

*/

public function upload_photo()

{

$mod = get_mod_status($this->uname);

echo '

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<h3>Add a Photo to your Profile</h3>

<table cellpadding="5">';

if($this->type == "group"){

echo'

<form enctype="multipart/form-data" name="content" action =

"index.php?loc=Profile&type=group&id='.$this->uname.'&action=add_photo" method = "post">';

}

else{

echo'

<form enctype="multipart/form-data" name="content" action =

"index.php?loc=Profile&action=add_photo" method = "post">';

}

echo'

<tr><td>Files must be 2mb or less and be a ".jpg" file type<span class = "red">*</span></td>

<td><input type = "file" name = "file" value = "'.$_POST['question'].'"></td></tr>

<tr><td>Add a Caption<span class = "red">*</span>:</td> <td><textarea rows = "6" cols = "20"

name = "caption">'.$_POST['caption'].'</textarea></td></tr>

<tr><td>Check here if you want this photo to be your profile picture:</td> <td><input type =

"checkbox" value = "on" name = "profile"></td></tr>

<tr><td><input type = "submit" value = "Upload"><td>

</form>';

if($this->type == "group"){

echo'

<form name="cancel" action = "index.php?loc=Profile&type=group&id='.$this->uname.'" method =

"post">';

}

else{

echo'

<form name="cancel" action = "index.php?loc=Profile" method = "post">';

}

echo'

<input type = "submit" value = "Cancel"></td>

</form>

</td>

</tr>

</table>

<span class = "red"><p>* = Required Field</p></span>

</div>

</div>

</div>

</div>

';

if(($this->uname == $_SESSION['userid']) && ($this->type == "user")){

echo'

<div class="top_links">

<form name="edit" class = "form_left" action="index.php?loc=Profile&action=edit"

method="post">

<input type="submit" value="Edit" />

</form>

</div>';

}

else if(($mod == 1) && ($this->type == "group")){

echo'

<div class="top_links">

Page 48: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 48 | P a g e

<form name="edit" class = "form_left" action="index.php?loc=Profile&type=group&id='.$this-

>uname.'&action=edit" method="post">

<input type="submit" value="Edit" />

</form>

</div>';

}

}

/**

* Function to handle the profile tab's add photo content and update

* the database with changes

*/

public function add_photo()

{

if($_POST['caption'] == "" ){

error_message("Error","Please fill out both fields");

$this->upload_photo();

}

else{

if ((($_FILES["file"]["type"] == "image/jpeg")

|| ($_FILES["file"]["type"] == "image/jpg"))

&& ($_FILES["file"]["size"] < 2000000))

{

if ($_FILES["file"]["error"] > 0)

{

echo "Return Code: " . $_FILES["file"]["error"] . "<br />";

}

else if(($_FILES["file"]["type"] == "image/jpeg")

|| ($_FILES["file"]["type"] == "image/pjpeg"))

{

/* echo "Upload: " . $_FILES["file"]["name"] . "<br />";

echo "Type: " . $_FILES["file"]["type"] . "<br />";

echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";

echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; */

if ($_POST['profile'] == "on"){

if($this->type == "group"){

// run_query("DELETE FROM group_profile WHERE location = -1 AND type = 2 AND ID = ".$this-

>uname."");

$params = array();

$params[0] = 'i';

$params[1] = $this->uname;

run_baller_query("DELETE FROM group_profile WHERE location = -1 AND type = 2 AND ID = ?",

$params);

$question = "photos/".$this->uname."_group_".$_FILES["file"]["name"].".jpg";

// run_query("INSERT INTO group_profile (ID, type, questionurl, anscaption, location) VALUES

(".$this->uname.", 2, '".$question."', '".$_POST['caption']."', -1)");

$params = array();

$params[0] = 'iss';

$params[1] = $this->uname;

$params[2] = $question;

$params[3] = $_POST['caption'];

run_baller_query("INSERT INTO group_profile (ID, type, questionurl, anscaption, location)

VALUES (?, 2, ?, ?, -1)", $params);

}

else{

// run_query("DELETE FROM user_profile WHERE location = -1 AND type = 2 AND ID = ".$this-

>uname."");

$params = array();

$params[0] = 'i';

$params[1] = $this->uname;

run_baller_query("DELETE FROM user_profile WHERE location = -1 AND type = 2 AND ID = ?",

$params);

$question = "photos/".$this->uname."_user_".$_FILES["file"]["name"].".jpg";

// run_query("INSERT INTO user_profile (ID, type, questionurl, anscaption, location) VALUES

(".$this->uname.", 2, '".$question."', '".$_POST['caption']."', -1)");

$params = array();

$params[0] = 'iss';

Page 49: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 49 | P a g e

$params[1] = $this->uname;

$params[2] = $question;

$params[3] = $_POST['caption'];

run_baller_query("INSERT INTO user_profile (ID, type, questionurl, anscaption, location)

VALUES (?, 2, ?, ?, -1)", $params);

}

}

else

{

if($this->type == "group"){

$results = run_query("SELECT location FROM group_profile WHERE ID = ".$this->uname." ORDER

BY location DESC");

}

else{

$results = run_query("SELECT location FROM user_profile WHERE ID = ".$this->uname." ORDER BY

location DESC");

}

$row = mysql_num_rows($results);

if($row == 0){

$count = 1;

}

else{

$row = mysql_fetch_array($results);

$count = $row['location'] + 1;

}

if($this->type == "group"){

$question = "photos/".$this->uname."_group_".$_FILES["file"]["name"].".jpg";

// run_query("INSERT INTO group_profile (ID, type, questionurl, anscaption, location) VALUES

(".$this->uname.", 2, '".$question."', '".$_POST['caption']."', ".$count.")");

$params = array();

$params[0] = 'issi';

$params[1] = $this->uname;

$params[2] = $question;

$params[3] = $_POST['caption'];

$params[4] = $count;

run_baller_query("INSERT INTO group_profile (ID, type, questionurl, anscaption, location)

VALUES (?, 2, ?, ?, ?)", $params);

}

else{

$question = "photos/".$this->uname."_user_".$_FILES["file"]["name"].".jpg";

// run_query("INSERT INTO user_profile (ID, type, questionurl, anscaption, location) VALUES

(".$this->uname.", 2, '".$question."', '".$_POST['caption']."', ".$count.")");

$params = array();

$params[0] = 'issi';

$params[1] = $this->uname;

$params[2] = $question;

$params[3] = $_POST['caption'];

$params[4] = $count;

run_baller_query("INSERT INTO user_profile (ID, type, questionurl, anscaption, location)

VALUES (?, 2, ?, ?, ?)", $params);

}

}

if ($_POST['profile'] == "on"){

if($this->type == "group"){

// $results = run_query("SELECT autonum FROM group_profile WHERE ID = '".$this->uname."' AND

location = -1 ORDER BY location DESC LIMIT 0, 1");

$params = array();

$params[0] = 'i';

$params[1] = $this->uname;

$row = run_baller_query("SELECT autonum FROM group_profile WHERE ID = ? AND location = -1

ORDER BY location DESC LIMIT 0, 1", $params);

}

else{

// $results = run_query("SELECT autonum FROM user_profile WHERE ID = '".$this->uname."' AND

location = -1 ORDER BY location DESC LIMIT 0, 1");

$params = array();

$params[0] = 'i';

Page 50: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 50 | P a g e

$params[1] = $this->uname;

$row = run_baller_query("SELECT autonum FROM user_profile WHERE ID = ? AND location = -1

ORDER BY location DESC LIMIT 0, 1", $params);

}

// $row = mysql_fetch_array($results);

if($this->type == "group"){

$place = "photos/".$this->uname."_group_".$row['autonum'].".jpg";

run_query("UPDATE group_profile SET questionurl = '".$place."' WHERE ID = '".$this->uname."'

AND location = -1");

}

else{

$place = "photos/".$this->uname."_user_".$row['autonum'].".jpg";

run_query("UPDATE user_profile SET questionurl = '".$place."' WHERE ID = '".$this->uname."'

AND location = -1");

}

}

else{

if($this->type == "group"){

// $results = run_query("SELECT autonum, location FROM group_profile WHERE ID = '".$this-

>uname."' ORDER BY location DESC LIMIT 0, 1");

$params = array();

$params[0] = 'i';

$params[1] = $this->uname;

$row = run_baller_query("SELECT autonum, location FROM group_profile WHERE ID = ? ORDER BY

location DESC LIMIT 0, 1", $params);

}

else{

// $results = run_query("SELECT autonum, location FROM user_profile WHERE ID = '".$this-

>uname."' ORDER BY location DESC LIMIT 0, 1");

$params = array();

$params[0] = 'i';

$params[1] = $this->uname;

$row = run_baller_query("SELECT autonum, location FROM user_profile WHERE ID = ? ORDER BY

location DESC LIMIT 0, 1", $params);

}

// $row = mysql_fetch_array($results);

if($this->type == "group"){

$place = "photos/".$this->uname."_group_".$row['autonum'].".jpg";

// run_query("UPDATE group_profile SET questionurl = '".$place."' WHERE ID = '".$this-

>uname."' AND location = ".$row['location']."");

$params = array();

$params[0] = 'sii';

$params[1] = $place;

$params[2] = $this->uname;

$params[3] = $row['location'];

run_baller_query("UPDATE group_profile SET questionurl = ? WHERE ID = ? AND location = ?",

$params);

}

else{

$place = "photos/".$this->uname."_user_".$row['autonum'].".jpg";

// run_query("UPDATE user_profile SET questionurl = '".$place."' WHERE ID = '".$this-

>uname."' AND location = ".$row['location']."");

$params = array();

$params[0] = 'sii';

$params[1] = $place;

$params[2] = $this->uname;

$params[3] = $row['location'];

run_baller_query("UPDATE user_profile SET questionurl = ? WHERE ID = ? AND location = ?",

$params);

}

}

move_uploaded_file($_FILES["file"]["tmp_name"], $place);

$save = $place;

$file = $place;

Page 51: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 51 | P a g e

list($width, $height) = getimagesize($file) ;

if($_POST['profile'] == "on"){

$size_w = 50;

$size_l = 50;

}

else{

$size_w = 200;

$size_l = 200;

}

$maxlength = $size_w;

$maxheight = $size_l;

$modwidth = $maxlength;

$diff = $width / $maxlength;

$modheight = $height / $diff;

$tn = imagecreatetruecolor($modwidth, $modheight) ;

$image = imagecreatefromjpeg($file) ;

imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;

imagejpeg($tn, $save, 100) ;

if($this->type == "group"){

redirect("index.php?loc=Profile&type=group&id=".$this->uname."",0,"");

}

else{

redirect("index.php?loc=Profile",0,"");

}

}

}

else

{

error_message("Error","The file was either larger than 2mb or not of the .jpg format.

Please try again.");

$this->upload_photo();

}

}

}

}

?>

1.18. Register.php <?php

/**

* Script to handle the register functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Register

*/

require_once("utilities.php");

/**

* Sets post variable of form submission

* @var string

*/

$action = $_POST['submit'];

/**

Page 52: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 52 | P a g e

* Sets post variable of the email submission

* @var string

*/

$email = $_POST['email'];

/**

* Sets post variable of the second email submission

* @var string

*/

$email2 = $_POST['email2'];

$a = explode("@", $email);

$username = $a[0];

$ext = $a[1];

if (($action == "Submit") && ($email == $email2) && ($email != "" && filter_var($email,

FILTER_VALIDATE_EMAIL))){

session_set_cookie_params(86400); // Sets the cookie to expire in 24 hours = 1440 minutes

= 8640 seconds

session_start(); // Starts a session on the server, creates SID, and transmits SID cookie

to client

$id = htmlspecialchars(session_id()); // Replaces special characters with html friendly

characters

$_SESSION['registration_email'] = $email; // Stores the user's email on the server (in a

session variable)

$_SESSION['registration_username'] = $email;

$code = rand(); // Generate a random code

$_SESSION['registration_code'] = $code; // Stores the user's random code on the server

(in a session variable)

/** Sends an email with a link to the verify script

* The link includes the SID, email, and random code

*/

mail($_POST['email'], "Saintbook - Registration", "

Saintbook - Registration

You are receiving this email because you have started the registration process.

Click on the following link to confirm your registration:

http://sb.sienacs.com/source_files/php_files/verify.php?PHPSESSID={$id}&email={$email}&co

de={$code}

If you cannot click the link, open the URL above by copying it to the address bar of your

web browser.");

/** Lets the user know an email was sent

*/

make_header("Register");

echo'

<div id="container">

<div id = "header">

<h1>Welcome!</h1>

</div>

<div id = "content">

<h2>Registration - Email</h2>

<b>Check your email (',$email,') and click the link to complete your registration.<br />

It may take a few minutes for the email to be sent. To complete the registration process,

your browser must allow cookies.</b>

<div class = "links">

<a href="login.php">Log In</a>

</div>

</div>

';

Page 53: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 53 | P a g e

make_footer_unauth();

}

else{

make_header("Register");

if ($action == "Submit"){

if($email != $email2){

$error = "The emails do not match, please try again.";

}

else{

$error = "The email entered is not valid. Please check to make sure it is a valid email and

try again.";

}

error_message("Error", $error);

}

echo'

<div id="container">

<div id = "header">

<h1>Welcome!</h1>

</div>

<div id = "content">

<h2>Registration</h2>

<table>

<form action="register.php" method="post">

<tr>

<td>Email:</td><td><input type="text" name="email" value="'.$_POST['email'].'"/></td>

</tr>

<tr>

<td>Email Confirmation:</td><td><input type="text" autocomplete="off" name="email2"

value="'.$_POST['email2'].'"/></td>

</tr>

<tr>

<td><input type="submit" name = "submit" value="Submit" /></td>

</tr>

</form>

</table>

<div class = "links">

<a href="login.php">Log In</a>

</div>

</div>';

make_footer_unauth();

}

?>

1.19. Super_admin.php <?php

/**

* Script to handle the Super Admin functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Super Admin

*/

require_once("utilities.php");

session_start();

if(($_SESSION['authenticated']) && ($_SESSION['administrator'] == "superadmin")){

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

Page 54: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 54 | P a g e

<head>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>

<title>SaintBook | Super Administrator</title>

<link rel="stylesheet" href="../../style/css/Authenticated.css" type="text/css"

media="screen" />

<script src="../javascript/jquery.js" type="text/javascript"></script>

<script src="../javascript/popup.js" type="text/javascript"></script>

</head>

<body>

<div id="container">

<div class="header">

<div id ="top_menu_left">

</div>

<div id ="top_menu_right">

<a href="logout.php">Logout</a>

</div>

<div class="main_logo"><a href="index.php?loc=Home"><img class="main_logo"

src="../../style/img/SB_oneline.png" alt="SaintBook Logo"/></a></div>

</div>

<div id="main_content">

<div class="content_outer">

<div class="content_middle">

<div class="content">

<div class="readable">

<center>

<a href="super_admin.php">List All</a> |

<a href="super_admin.php?letter=A">A</a> |

<a href="super_admin.php?letter=B">B</a> |

<a href="super_admin.php?letter=C">C</a> |

<a href="super_admin.php?letter=D">D</a> |

<a href="super_admin.php?letter=E">E</a> |

<a href="super_admin.php?letter=F">F</a> |

<a href="super_admin.php?letter=G">G</a> |

<a href="super_admin.php?letter=H">H</a> |

<a href="super_admin.php?letter=I">I</a> |

<a href="super_admin.php?letter=J">J</a> |

<a href="super_admin.php?letter=K">K</a> |

<a href="super_admin.php?letter=L">L</a> |

<a href="super_admin.php?letter=M">M</a> |

<a href="super_admin.php?letter=N">N</a> |

<a href="super_admin.php?letter=O">O</a> |

<a href="super_admin.php?letter=P">P</a> |

<a href="super_admin.php?letter=Q">Q</a> |

<a href="super_admin.php?letter=R">R</a> |

<a href="super_admin.php?letter=S">S</a> |

<a href="super_admin.php?letter=T">T</a> |

<a href="super_admin.php?letter=U">U</a> |

<a href="super_admin.php?letter=V">V</a> |

<a href="super_admin.php?letter=W">W</a> |

<a href="super_admin.php?letter=X">X</a> |

<a href="super_admin.php?letter=Y">Y</a> |

<a href="super_admin.php?letter=Z">Z</a>

</center>

<?php

$letter_test = $_GET['letter'];

if($_GET['user'] != ""){

if($_GET['type'] == "general"){

// run_query("UPDATE user SET usertype = 1 WHERE username = '".$_GET['user']."'");

$params = array();

$params[0] = 's';

$params[1] = $_GET['user'];

run_baller_query("UPDATE user SET usertype = 1 WHERE username = ?", $params);

}

else{

// run_query("UPDATE user SET usertype = 3 WHERE username = '".$_GET['user']."'");

$params = array();

$params[0] = 's';

$params[1] = $_GET['user'];

Page 55: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 55 | P a g e

run_baller_query("UPDATE user SET usertype = 3 WHERE username = ?", $params);

}

}

$results = run_query("SELECT username, firstname, lastname,

usertype FROM user ORDER BY lastname ASC");

echo '

<center>

<table border="1" cellpadding="5" style="margin-top:15px;">

<tr>

<th>User</th><th>General User</th><th>Administrator</th>

</tr>';

while ($row = mysql_fetch_array($results)){

if ($row['usertype']== 2){

}

else{

$name = $row['lastname'];

$name[0] = strtoupper($name[0]);

if (($name[0] == $letter_test) || ($letter_test == "")){

if ($row['usertype']== 1){

$user = "checked";

$admin = "";

}

else{

$admin = "checked";

$user = "";

}

echo'<tr><td>'.$row['lastname'].', '.$row['firstname'].'</td><td><input type="radio"

onClick =

"location.href=\'super_admin.php?user='.$row['username'].'&type=general&letter='.$_GET['lett

er'].'\'" name="'.$row['username'].'" value="General" '.$user.'></td><td><input type="radio"

onClick =

"location.href=\'super_admin.php?user='.$row['username'].'&type=admin&letter='.$_GET['letter

'].'\'" name="'.$row['username'].'" value="Admin" '.$admin.'></td></tr>';

}

}

}

echo '

</table>

</center>

</div>

</div>

</div>

</div>

</div>

<div id ="footer">

&copy; 2010 <a href="http://oraserv.cs.siena.edu/~perm_digevol/">Digital Evolutions</a> All

rights reserved

</div>

</body>

</html>

';

}

?>

Page 56: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 56 | P a g e

1.20. Updateorder.php <?php

/**

* Script to handle the Update Order of highlighted groups/members in

* the Home and Profile Page functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Update Order

*/

include("utilities.php");

session_start();

if ($_SESSION['authenticated']) {

$page = $_GET['page'];

$group = $_GET['group'];

/**

* Updates the users home page order

*/

if($page == "user_home"){

$results = run_query("SELECT GID FROM membership WHERE UID = ".$_SESSION['userid']."");

while($row = mysql_fetch_array($results)){

run_query("UPDATE membership SET utopmembers = NULL WHERE GID = ".$row['GID']." AND UID =

".$_SESSION['userid']."");

}

$ul1 = $_GET['ul1'];

//echo $ul1."<br>";

$a = explode(",", $ul1);

$count = 1;

foreach ($a as $x) {

// run_query("UPDATE membership SET utopmembers = ".$count." WHERE GID = ".$x." AND UID =

".$_SESSION['userid']."");

$params = array();

$params[0] = 'iii';

$params[1] = $count;

$params[2] = $x;

$params[3] = $_SESSION['userid'];

run_baller_query("UPDATE membership SET utopmembers = ? WHERE GID = ? AND UID = ?",

$params);

$count++;

}

}

/**

* Updates the user profile page order

*/

else if($page == "user_profile"){

$results = run_query("SELECT autonum, location FROM user_profile WHERE ID =

".$_SESSION['userid']."");

while($row = mysql_fetch_array($results)){

if($row['location'] == -1){

}

else{

// run_query("UPDATE user_profile SET location = NULL WHERE autonum = ".$row['autonum']."

AND ID = ".$_SESSION['userid']."");

$params = array();

$params[0] = 'ii';

$params[1] = $row['autonum'];

$params[2] = $_SESSION['userid'];

run_baller_query("UPDATE user_profile SET location = NULL WHERE autonum = ? AND ID = ?",

$params);

}

}

$ul1 = $_GET['ul1'];

//echo $ul1."<br>";

$a = explode(",", $ul1);

Page 57: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 57 | P a g e

$count = 1;

foreach ($a as $x) {

// run_query("UPDATE user_profile SET location = ".$count." WHERE autonum = ".$x." AND ID =

".$_SESSION['userid']."");

$params = array();

$params[0] = 'iii';

$params[1] = $count;

$params[2] = $x;

$params[3] = $_SESSION['userid'];

run_baller_query("UPDATE user_profile SET location = ? WHERE autonum = ? AND ID = ?",

$params);

$count++;

}

}

/*

* Updates the groups home page order

*/

else if($page == "group_home"){

$results = run_query("SELECT UID FROM membership WHERE GID = ".$group."");

while($row = mysql_fetch_array($results)){

run_query("UPDATE membership SET gtopmembers = NULL WHERE UID = ".$row['UID']." AND GID =

".$group."");

}

$ul1 = $_GET['ul1'];

//echo $ul1."<br>";

$a = explode(",", $ul1);

$count = 1;

foreach ($a as $x) {

// run_query("UPDATE membership SET gtopmembers = ".$count." WHERE UID = ".$x." AND GID =

".$group."");

$params = array();

$params[0] = 'iii';

$params[1] = $count;

$params[2] = $x;

$params[3] = $group;

run_baller_query("UPDATE membership SET gtopmembers = ? WHERE UID = ? AND GID = ?",

$params);

$count++;

}

}

/**

* Updates the groups profile page order

*/

else if($page == "group_profile"){

$results = run_query("SELECT autonum, location FROM group_profile WHERE ID = ".$group."");

while($row = mysql_fetch_array($results)){

if($row['location'] == -1){

}

else{

// run_query("UPDATE group_profile SET location = NULL WHERE autonum = ".$row['autonum']."

AND ID = ".$group."");

$params = array();

$params[0] = 'ii';

$params[1] = $row['autonum'];

$params[2] = $group;

run_baller_query("UPDATE group_profile SET location = NULL WHERE autonum = ? AND ID = ?",

$params);

}

}

$ul1 = $_GET['ul1'];

//echo $ul1."<br>";

$a = explode(",", $ul1);

$count = 1;

foreach ($a as $x) {

// run_query("UPDATE group_profile SET location = ".$count." WHERE autonum = ".$x." AND ID =

".$group."");

$params = array();

$params[0] = 'iii';

$params[1] = $count;

Page 58: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 58 | P a g e

$params[2] = $x;

$params[3] = $group;

run_baller_query("UPDATE group_profile SET location = ? WHERE autonum = ? AND ID = ?",

$params);

$count++;

}

}

}

?>

Page 59: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 59 | P a g e

1.21. User.php <?php

/**

* User class and functions to handle the User's functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package User

*/

require_once("page.php");

require_once("home_tab.php");

require_once("group_tab.php");

require_once("browse.php");

require_once("privacy.php");

require_once("join.php");

require_once("message_center_tab.php");

require_once("friends_tab.php");

require_once("profile_tab.php");

class User extends PageSuperClass

{

/**

* User's username

* @var string

*/

var $uname;

/**

* User's first name

* @var string

*/

var $fname;

/**

* User's last name

* @var string

*/

var $lname;

/**

* User or Group

* @var string

*/

var $type;

/**

* Is guest

* @var string

*/

var $guest;

/**

* Function to get the user's info

*

* @param string

* @param string

* @param string

* @param string

*/

function __construct($username, $firstname, $lastname, $guest){

$this->uname = $username;

$this->fname = $firstname;

$this->lname = $lastname;

$this->type = "user";

$this->guest = $guest;

}

Page 60: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 60 | P a g e

/**

* Function to instantiate a new Group class and to handle

* a User creating a group

*/

public function create_groups()

{

$action = $_GET['action'];

$group_tab = new Group_Tab($this->uname, $this->fname, $this->lname, $this->guest);

if ($action == "create"){

$group_tab -> create_create_group();

}

else if($action == "validate"){

$group_tab -> create_group_validate();

}

else{

$group_tab -> create_main_content();

}

}

}

?>

1.22. Utilities.php <?php

/**

* Functions to be included and used throughout SaintBook site which include

* making headers, footers, error messages and running safe sql queries

* depending on what type of user is logged in or not.

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package utilities

*/

/**

* Returns moderator status

* @param string

*/

function get_mod_status($group_id)

{

// $results = run_query("SELECT moderator FROM membership WHERE GID = ".$group_id." AND UID

= ".$_SESSION['userid']."");

$params = array();

$params[0] = 'ii';

$params[1] = $group_id;

$params[2] = $_SESSION['userid'];

$row = run_baller_query("SELECT moderator FROM membership WHERE GID = ? AND UID = ?",

$params);

// $row = mysql_fetch_array($results);

/**

* Sets moderator status determined by an int

* @var int

*/

$mod = $row['moderator'];

return $mod;

}

/**

* Creates the header based on $place

* @param string

*/

function make_header($place)

{

Page 61: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 61 | P a g e

echo'

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>

<title>SaintBook | ',$place,'</title>

<link rel="icon" href="../../style/img/favicon.png" type="image/ico"/>

<link rel="bookmark" href="../../style/img/favicon.png" type="image/ico"/>

<link rel="stylesheet" href="../../style/css/unAuthenticated.css" type="text/css"

media="screen" />

<link rel="stylesheet" href="style/css/unAuthenticated.css" type="text/css" media="screen"

/>

<script src="source_files/javascript/jquery.js" type="text/javascript"></script>

<script src="source_files/javascript/popup.js" type="text/javascript"></script>

<script src="source_files/javascript/dragdrop-min.js" type="text/javascript"></script>

<script src="source_files/javascript/yahoo-dom-event.js" type="text/javascript"></script>

<script src="../javascript/jquery.js" type="text/javascript"></script>

<script src="../javascript/popup.js" type="text/javascript"></script>

<script src="../javascript/dragdrop-min.js" type="text/javascript"></script>

<script src="../javascript/yahoo-dom-event.js" type="text/javascript"></script>

</head>

<body>

<img src="../../style/img/SB_oneline.png" id="center" alt="SaintBook Logo"/>

';

}

/**

* Creates the header when logged in with $place, $fname and $lname

*

* @param string

* @param string

* @param string

*/

function make_header_logged_in($place, $fname, $lname)

{

/**

* Gets if it is a group or user

* @var string

*/

$type = $_GET['type'];

if ($type != NULL){

}

else if($place == "Home"){

/**

* Sets home tab to be underlined

* @var string

*/

$home_underline = 'style="text-decoration:underline;"';

}

else if($place == "Profile"){

/**

* Sets profile tab to be underlined

* @var string

*/

$profile_underline = 'style="text-decoration:underline;"';

}

else if($place == "Friends"){

/**

* Sets friends tab to be underlined

* @var string

*/

$friends_underline = 'style="text-decoration:underline;"';

}

else if($place == "Groups"){

Page 62: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 62 | P a g e

/**

* Sets groups tab to be underlined

* @var string

*/

$groups_underline = 'style="text-decoration:underline;"';

}

else if($place == "Message_Center"){

/**

* Sets message center tab to be underlined

* @var string

*/

$mc_underline = 'style="text-decoration:underline;"';

}

/**

* If flag becomes true, star pops up on message center tab to let user know there

* is an update

*/

$flag = false;

/**

* Query to select the group id of the group being requested, where the requester is

* the logged in user and if they are a moderator

*/

$results = run_query("SELECT GID FROM membership WHERE UID = ".$_SESSION['userid']." AND

moderator = 1");

while($row = mysql_fetch_array($results)){

/**

* If you are a moderator, query to determine if the request is still pending

*/

$results2 = run_query("SELECT pending FROM membership WHERE GID = ".$row['GID']." and

pending IS NOT NULL");

while($row2 = mysql_fetch_array($results2)){

$flag = true;

break;

}

if (!$flag){

/**

* Query to determine if a user requested membership in the group you are a moderator of

*/

$results2 = run_query("SELECT pending FROM group_friend WHERE AID = ".$row['GID']." and

pending IS NOT NULL");

while($row2 = mysql_fetch_array($results2)){

$flag = true;

break;

}

}

}

if(!$flag){

/**

* Query to select the user id of the user that is logged in

*/

$results = run_query("SELECT AID FROM user_friend WHERE AID = ".$_SESSION['userid']." AND

pending IS NOT NULL");

while($row = mysql_fetch_array($results)){

$flag = true;

break;

}

}

if(!$flag){

/**

* Query to select the invited group ids where the user id is the logged in user and that

* there was no message sent back, if there is flag is true

*/

Page 63: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 63 | P a g e

$results = run_query("SELECT GID FROM membership WHERE UID = ".$_SESSION['userid']." AND

resp_msg IS NOT NULL");

while($row = mysql_fetch_array($results)){

$flag = true;

break;

}

}

/**

* Display html for header with the right main tab underlined

*/

echo'

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>

<title>SaintBook | ',$place,'</title>

<link rel="icon" href="../../style/img/favicon.png" type="image/ico"/>

<link rel="icon" href="style/img/favicon.png" type="image/ico"/>

<link rel="bookmark" href="../../style/img/favicon.png" type="image/ico"/>

<link rel="bookmark" href="style/img/favicon.png" type="image/ico"/>

<link rel="stylesheet" href="../../style/css/Authenticated.css" type="text/css"

media="screen" />

<link rel="stylesheet" href="style/css/Authenticated.css" type="text/css" media="screen" />

<script src="source_files/javascript/jquery.js" type="text/javascript"></script>

<script src="source_files/javascript/popup.js" type="text/javascript"></script>

<script src="source_files/javascript/yahoo-dom-event.js" type="text/javascript"></script>

<script src="source_files/javascript/dragdrop-min.js" type="text/javascript"></script>

<script src="source_files/javascript/animation-min.js" type="text/javascript"></script>

<script src="../javascript/jquery.js" type="text/javascript"></script>

<script src="../javascript/popup.js" type="text/javascript"></script>

</head>

<body>

<div id="container">

<div class="header">

<div id ="top_menu_left">

Welcome '.$fname.' '.$lname.'! <br /><br />

<ul>

<li '.$home_underline.'><a href="index.php?loc=Home">Home</a></li>

<li '.$profile_underline.'><a href="index.php?loc=Profile">Profile</a></li>

<li '.$friends_underline.'><a href="index.php?loc=Friends">Friends</a></li>

<li '.$groups_underline.'><a href="index.php?loc=Groups">Groups</a></li>

<li '.$mc_underline.'><a href="index.php?loc=Message_Center">Message Center</a></li>';

if($flag){

echo '<img src="style/img/star.png" alt="star">';

}

echo '

</ul>

</div>

<div id ="top_menu_right">

<a href="source_files/php_files/logout.php">Logout</a> | <a

href="index.php?loc=privacy">Privacy Settings</a><br />

<form name="browse" action="index.php?loc=browse" method="post">

<input type="submit" name = "Browse" value="Browse..." />

</form>

</div>

<div class="main_logo"><a href="index.php?loc=Home"><img class="main_logo"

src="style/img/SB_oneline.png" alt="SaintBook Logo"/></a></div>

';

}

/**

* Creates the header when logged in as guest

*

* @param

*/

function make_header_logged_in_guest($place)

{

echo'

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

Page 64: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 64 | P a g e

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>

<title>SaintBook | ',$place,'</title>

<link rel="icon" href="../../style/img/favicon.png" type="image/ico"/>

<link rel="icon" href="style/img/favicon.png" type="image/ico"/>

<link rel="bookmark" href="../../style/img/favicon.png" type="image/ico"/>

<link rel="bookmark" href="style/img/favicon.png" type="image/ico"/>

<link rel="stylesheet" href="../../style/css/Authenticated.css" type="text/css"

media="screen" />

<link rel="stylesheet" href="style/css/Authenticated.css" type="text/css" media="screen" />

<script src="source_files/javascript/jquery.js" type="text/javascript"></script>

<script src="source_files/javascript/popup.js" type="text/javascript"></script>

<script src="../javascript/jquery.js" type="text/javascript"></script>

<script src="../javascript/popup.js" type="text/javascript"></script>

</head>

<body>

<div id="container">

<div class="header">

<div id ="top_menu_left">

</div>

<div id ="top_menu_right">

<a href="source_files/php_files/logout.php">Logout</a> <br /><br />

<form name="browse" action="index.php?loc=browse" method="post">

<input type="submit" name = "Browse" value="Browse..." />

</form>

</div>

<div class="main_logo"><a href="index.php?loc=Home"><img class="main_logo"

src="style/img/SB_oneline.png" alt="SaintBook Logo"/></a></div>

';

}

/**

* Creates the header when logged in based on current user's $place, $fname and $lname

*

* @param string

* @param string

* @param string

*/

function make_current_user_header($place, $fname, $lname)

{

if($place == "Home"){

/**

* Sets home tab to be underlined

* @var string

*/

$home_underline = 'style="text-decoration:underline;"';

}

else if($place == "Profile"){

/**

* Sets profile tab to be underlined

* @var string

*/

$profile_underline = 'style="text-decoration:underline;"';

}

else if($place == "Friends"){

/**

* Sets friends tab to be underlined

* @var string

*/

$friends_underline = 'style="text-decoration:underline;"';

}

else if($place == "Groups"){

/**

* Sets groups tab to be underlined

* @var string

Page 65: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 65 | P a g e

*/

$groups_underline = 'style="text-decoration:underline;"';

}

else if($place == "Message_Center"){

/**

* Sets message center tab to be underlined

* @var string

*/

$mc_underline = 'style="text-decoration:underline;"';

}

else if($place == "Members"){

/**

* Sets members tab to be underlined

* @var string

*/

$member_underline = 'style="text-decoration:underline;"';

}

else if($place == "label"){

/**

* Sets label tab to be underlined

* @var string

*/

$label_underline = 'style="text-decoration:underline;"';

}

/**

* Gets if it is a group or user

* @var string

*/

$type = $_GET['type'];

/**

* Gets user id

* @var string

*/

$id = $_GET['id'];

if(($_SESSION['administrator'] != "guest") || ($type != "")){

/**

* If type given is the empty string, logged in user is viewing their own profile page

* Query to select the profile picture of the logged in user

* Display in the correct place in the header

*/

if($type == ""){

$row = mysql_fetch_array(run_query("SELECT questionurl FROM user_profile WHERE ID =

".$_SESSION['userid']." AND location = -1"));

/*$params = array();

$params[0] = 'i';

$params[1] = $_SESSION['userid'];

$row = run_baller_query("SELECT questionurl FROM user_profile WHERE ID = ? AND location = -

1", $params);*/

echo'

<div class="profile_image"><a href="index.php?loc=Home">';

if($row == FALSE){

echo' <img class ="prof_image" src="style/img/default_profile_pic.png" alt="Profile Image"

width="50" height="50"/>';

}

else{

echo' <img class ="prof_image" src="'.$row['questionurl'].'" alt="Profile Image" width="50"

height="50"/>';

}

echo'</a></div>';

}

/**

* If type given is a group, you are viewing a groups profile page

* Query to select the groups profile picture

* Display in the correct place in the header

Page 66: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 66 | P a g e

*/

else if($type == "group"){

$row = mysql_fetch_array(run_query("SELECT questionurl FROM group_profile WHERE ID =

".$_GET['id']." AND location = -1"));

/*$params = array();

$params[0] = 'i';

$params[1] = $_GET['id'];

$row = run_baller_query("SELECT questionurl FROM group_profile WHERE ID = ? AND location = -

1", $params);*/

echo'

<div class="profile_image"><a href="index.php?loc=Home&type='.$type.'&id='.$id.'">';

if($row == FALSE){

echo' <img class ="prof_image" src="style/img/default_profile_pic.png" alt="Profile Image"

width="50" height="50"/>';

}

else{

echo' <img class ="prof_image" src="'.$row['questionurl'].'" alt="Profile Image" width="50"

height="50"/>';

}

echo'</a></div>';

}

/**

* If type given is a user, you are viewing a users profile page

* Query to select the users profile picture

* Display in the correct place in the header

*/

else if($type == "user"){

// $row = mysql_fetch_array(run_query("SELECT questionurl FROM user_profile WHERE ID =

".$_GET['id']." AND location = -1"));

$params = array();

$params[0] = 'i';

$params[1] = $_GET['id'];

$row = run_baller_query("SELECT questionurl FROM user_profile WHERE ID = ? AND location = -

1", $params);

echo'

<div class="profile_image"><a href="index.php?loc=Home&type='.$type.'&id='.$id.'"><img class

="prof_image" src="'.$row['questionurl'].'" alt="Profile Image" width="50"

height="50"/></a></div>';

}

/**

* Display users first and last name

*/

echo'

<div class="profile_name">

<h2>'.$fname.' '.$lname.'</h2><br/>

';

/**

* If logged in user is viewing their own page

*/

if($type == ""){

$flag = false;

/**

* Query to select the group id of the group being requested, where the requester is

* the logged in user and if they are a moderator

*/

$results = run_query("SELECT GID FROM membership WHERE UID = ".$_SESSION['userid']." AND

moderator = 1");

while($row = mysql_fetch_array($results)){

/**

* If you are a moderator, query to determine if the request is still pending

*/

$results2 = run_query("SELECT pending FROM membership WHERE GID = ".$row['GID']." and

pending IS NOT NULL");

while($row2 = mysql_fetch_array($results2)){

$flag = true;

break;

Page 67: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 67 | P a g e

}

if (!$flag){

/**

* Query to determine if a user requested membership in the group you are a moderator of

*/

$results2 = run_query("SELECT pending FROM group_friend WHERE AID = ".$row['GID']." and

pending IS NOT NULL");

while($row2 = mysql_fetch_array($results2)){

$flag = true;

break;

}

}

}

if(!$flag){

/**

* Query to select the user id of the user that is logged in

*/

$results = run_query("SELECT AID FROM user_friend WHERE AID = ".$_SESSION['userid']." AND

pending IS NOT NULL");

while($row = mysql_fetch_array($results)){

$flag = true;

break;

}

}

if(!$flag){

/**

* Query to select the invited group ids where the user id is the logged in user and that

* there was no message sent back, if there is flag is true

*/

$results = run_query("SELECT GID FROM membership WHERE UID = ".$_SESSION['userid']." AND

resp_msg IS NOT NULL");

while($row = mysql_fetch_array($results)){

$flag = true;

break;

}

}

/**

* Display the main tabs with the right one underlined, with the star

* displayed on the message center tab

*/

echo'

<ul>

<li '.$home_underline.'><a href="index.php?loc=Home">Home</a></li>

<li '.$profile_underline.'><a href="index.php?loc=Profile">Profile</a></li>

<li '.$friends_underline.'><a href="index.php?loc=Friends">Friends</a></li>

<li '.$groups_underline.'><a href="index.php?loc=Groups">Groups</a></li>

<li '.$mc_underline.'><a href="index.php?loc=Message_Center">Message Center</a></li>';

if($flag){

echo '<img src="style/img/star.png" alt="star">';

}

echo'</ul>';

}

/**

* If logged in user is viewing a groups page

*/

else if($type == "group"){

/**

* Display the sub-menu tab with the correct tab underlined

*/

echo'

<ul>

<li '.$home_underline.'><a href="index.php?loc=Home&type=group&id='.$id.'">Home</a></li>

Page 68: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 68 | P a g e

<li '.$profile_underline.'><a

href="index.php?loc=Profile&type=group&id='.$id.'">Profile</a></li>

<li '.$friends_underline.'><a

href="index.php?loc=Friends&type=group&id='.$id.'">Friends</a></li>

<li '.$member_underline.'><a

href="index.php?loc=Members&type=group&id='.$id.'">Members</a></li>';

/**

* Determine if logged in user is the moderator of the group being viewed

*/

// $results = run_query("SELECT moderator FROM membership WHERE UID =

".$_SESSION['userid']." AND GID = ".$id."");

$params = array();

$params[0] = 'ii';

$params[1] = $_SESSION['userid'];

$params[2] = $id;

$row = run_baller_query("SELECT moderator FROM membership WHERE UID = ? AND GID = ?",

$params);

// $row = mysql_fetch_array($results);

$flag = false;

if($row['moderator'] == 1){

/**

* Same as above for displaying a page being viewed,

* but for the goup being displayed

*/

$results2 = run_query("SELECT pending FROM membership WHERE GID = ".$id." and pending IS NOT

NULL");

while($row2 = mysql_fetch_array($results2)){

$flag = true;

break;

}

if (!$flag){

$results2 = run_query("SELECT pending FROM group_friend WHERE AID = ".$id." and pending IS

NOT NULL");

while($row2 = mysql_fetch_array($results2)){

$flag = true;

break;

}

}

if(!$flag){

$results = run_query("SELECT AID FROM group_friend WHERE AID = ".$id." AND pending IS NOT

NULL");

while($row = mysql_fetch_array($results)){

$flag = true;

break;

}

}

echo'<li '.$mc_underline.'><a

href="index.php?loc=Message_Center&type=group&id='.$id.'">Message Center</a></li>';

if($flag){

echo '<img src="style/img/star.png" alt="star">';

}

}

/**

* Determine if logged in user is an admin or not

*/

// $row2 = mysql_fetch_array(run_query("SELECT usertype FROM user WHERE ID =

".$_SESSION['userid'].""));

$params = array();

$params[0] = 'i';

$params[1] = $_SESSION['userid'];

$row2 = run_baller_query("SELECT usertype FROM user WHERE ID = ?", $params);

if($row2['usertype'] == 3){

/**

* Displays label tab underlined

Page 69: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 69 | P a g e

*/

echo'<li '.$label_underline.'><a href="index.php?loc=label&type=group&id='.$id.'">Label

Group</a></li>';

}

echo'</ul>';

}

else{

/**

* If not on the label tab the right one underlined

*/

echo'

<ul>

<li '.$home_underline.'><a href="index.php?loc=Home&type='.$type.'&id='.$id.'">Home</a></li>

<li '.$profile_underline.'><a

href="index.php?loc=Profile&type='.$type.'&id='.$id.'">Profile</a></li>

<li '.$friends_underline.'><a

href="index.php?loc=Friends&type='.$type.'&id='.$id.'">Friends</a></li>

<li '.$groups_underline.'><a

href="index.php?loc=Groups&type='.$type.'&id='.$id.'">Groups</a></li>

</ul>

';

}

echo'

</div>';

/**

* If logged in user is viewing themself, these are the buttons that will be displayed in the

header

*/

if($type == ""){

}

/**

* If logged in user is viewing a group, when they are not the moderator

* and their as been no respond message to them if they already requested

* membership to this group, these are the buttons that will be displayed in the header

*/

else if(($type == "group") && ($_SESSION['administrator'] != "guest")){

$results = run_query("SELECT * FROM membership WHERE UID = ".$_SESSION['userid']." AND GID =

".$id."");

/* $params = array();

$params[0] = 'ii';

$params[1] = $_SESSION['userid'];

$params[2] = $id;

$row = run_baller_query("SELECT * FROM membership WHERE UID = ? AND GID = ?", $params); */

$row = mysql_fetch_array($results);

if(($row == FALSE) || (($row['moderator'] == NULL) && ($row['resp_msg'] == NULL))){

echo'

<div id ="top_menu_right">

<form name="request" action="index.php?loc=request&type=group&id='.$id.'" method="post">

<input type="submit" name = "request" value="Join Group" />

</form>

</div>

';

}

}

/**

* If logged in user is viewing another user, whether they are friends are not,

* these are the buttons that will be displayed in the header

*/

else if(($type == "user") && ($_SESSION['administrator'] != "guest")){

$results = run_query("SELECT * FROM user_friend WHERE (RID = ".$_SESSION['userid']." AND AID

= ".$id.") OR (AID = ".$_SESSION['userid']." AND RID = ".$id.")");

/* $params = array();

$params[0] = 'iiii';

$params[1] = $_SESSION['userid'];

$params[2] = $id;

$params[3] = $_SESSION['userid'];

Page 70: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 70 | P a g e

$params[4] = $id;

$row = run_baller_query("SELECT pending FROM user_friend WHERE (RID = ? AND AID = ?) OR (AID

= ? AND RID = ?)", $params); */

$row = mysql_fetch_array($results);

if($row == FALSE){

echo'

<div id ="top_menu_right">

<form name="request" action="index.php?loc=request&type=user&id='.$id.'" method="post">

<input type="submit" name = "request" value="Request Friendship" />

</form>

</div>

';

}

}

if((($type == "group") && (get_mod_status($id) == 1)) && ($_SESSION['administrator'] !=

"guest")){

echo'

<div id ="top_menu_right">

<form name="group_friend" action="index.php?loc=browse&type=group&id='.$id.'" method="post">

<input type="submit" value="Find Group Friends" />

</form>

</div>';

}

}

echo'

</div>

<div id="main_content">

';

}

/**

* Creates the footer

*/

function make_footer()

{

echo'

</div>

<div id ="footer">

&copy; 2010 <a href="http://oraserv.cs.siena.edu/~perm_digevol/">Digital Evolutions</a> All

rights reserved

</div>

</div>

</body>

</html>

';

}

/**

* Creates the footer when not logged in

*/

function make_footer_unauth()

{

echo'

<div id ="footer">

&copy; 2010 <a href="http://oraserv.cs.siena.edu/~perm_digevol/">Digital Evolutions</a> All

rights reserved

</div>

</div>

</body>

</html>

';

}

/**

* Displays error message

*

* @param string

*/

function error_message($title, $message)

{

echo'

Page 71: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 71 | P a g e

<div id="popupContact">

<a id="popupContactClose">x</a>

<h1>'.$title.'</h1>

<p id="contactArea">

',$message,'

<br/><br/>

<div class = "small">Press ESCAPE, Click on X (right-top) or Click Out from the popup to

close the popup!</div>

</p>

</div>

<div id="backgroundPopup"></div>';

}

/**

* Redirects the user using meta tags

*

* @param string

* @param int

* @param string

*/

function redirect( $url, $delay = 0, $message = "" )

{

echo "<meta http-equiv='Refresh' content='".$delay."; url=".$url."'>";

die( "<div style='font-family: Arial, Sans-serif; font-size: 12pt;' align=center>

".$message." </div>" );

}

/**

* Runs the passed query string

*

* @param string

*/

function run_query($q) {

$connection = mysql_connect("localhost", "sienasel_digevol", "coolkidz") or die ("ERROR: " .

mysql_error());

mysql_select_db("sienasel_sb", $connection) or die ("ERROR: " . mysql_error());

$results = mysql_query($q) or die ("ERROR: " . mysql_error());

mysql_close($connection);

return $results;

}

/**

* Runs the passed query string

*

* @param string

* @param array

*/

/* function run_fail_query($q, $arr) {

$mysqli = new mysqli("localhost", "sienasel_digevol", "coolkidz", "sienasel_sb");

if (mysqli_connect_errno()) {

printf("Connect failed: %s\n", mysqli_connect_error());

exit();

}

$stmt = $mysqli->prepare($q);

// $stmt->bind_param('sssd', $code, $language, $official, $percent);

call_user_func_array(array($stmt, "bind_param"), $arr);

$stmt->execute();

$stmt->close();

$mysqli->close();

} */

/**

* Checks connection to database then using protected statements

* connects to the database

*

* @param string

Page 72: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 72 | P a g e

* @param array

*/

function run_baller_query($q, $arr)

{

$mysqli = new mysqli("localhost", "sienasel_digevol", "coolkidz", "sienasel_sb");

if (mysqli_connect_errno()) {

printf("Connect failed: %s\n", mysqli_connect_error());

exit();

}

$stmt = $mysqli->prepare($q);

// $stmt->bind_param('sssd', $code, $language, $official, $percent);

call_user_func_array(array($stmt, "bind_param"), $arr);

$stmt->execute();

if ($meta = $stmt->result_metadata())

{

while($field = $meta->fetch_field())

{

$params[] = &$row[$field->name];

}

call_user_func_array(array($stmt, "bind_result"), $params);

}

$stmt->fetch();

$stmt->close();

$mysqli->close();

return $row;

}

/**

* Function to limit user on information submition on profile tab

*

* @param string

* @param int

* @param string

* @param string

*/

function myTruncate($string, $limit, $break=".", $pad="...") {

// return with no change if string is shorter than $limit

if(strlen($string) <= $limit) return $string;

// is $break present between $limit and the end of the string?

if(false !== ($breakpoint = $limit)) {

if($breakpoint < strlen($string) - 1){

$string = substr($string, 0, $breakpoint) . $pad;

}

}

return $string;

}

?>

1.23. Verify.php <?php

/**

* Functions to handle the registration validation functionality, after

* email is clicked and registering user is redirected back to SaintBook

* this will display and handle the Registration Contintued part

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Verify

*/

require_once("utilities.php");

Page 73: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 73 | P a g e

session_start();

$sid = $_GET['PHPSESSID'];

$given_email = $_GET['email'];

$given_code = $_GET['code'];

$submitted = $_GET['submitted'];

$actual_email = $_SESSION['registration_email'];

$actual_username = $_SESSION['registration_username'];

$actual_code = $_SESSION['registration_code'];

$password = $_POST['pwd'];

$password2 = $_POST['pwd2'];

$firstname = $_POST['fname'];

$lastname = $_POST['lname'];

$gradyear = $_POST['gradyear'];

$description = $_POST['description'];

if ( $given_email == $actual_email &&

$given_code == $actual_code &&

$given_code != "" &&

$given_email != "" &&

$password != "" &&

$password2 != "" &&

$description != "" &&

$firstname != "" &&

$lastname != "" &&

$password == $password2 &&

$submitted == "yes") {

$password = md5($_POST['pwd']); // Encrypt the password

$a = explode("@", $actual_email);

$ext = $a[1];

$date = getdate();

if($ext != "siena.edu"){

$params = array();

$params[0] = 'ssss';

$params[1] = $actual_email;

$params[2] = $password;

$params[3] = $firstname;

$params[4] = $lastname;

$q = "INSERT INTO guest (username, password, firstname, lastname) VALUES (?, ?, ?, ?)";

//$q = "INSERT INTO guest (username, password, firstname, lastname) VALUES ('$actual_email',

'$password', '$firstname', '$lastname')";

}

else{

if($gradyear < $date['year']){

$usertype = 2;

}

else{

$usertype = 1;

}

$params = array();

$params[0] = 'sssssii';

$params[1] = $actual_email;

$params[2] = $password;

$params[3] = $firstname;

$params[4] = $lastname;

$params[5] = $description;

$params[6] = $usertype;

$params[7] = $gradyear;

$q = "INSERT INTO user (username, password, firstname, lastname, `desc`, usertype, gradyear)

VALUES (?, ?, ?, ?, ?, ?, ?)";

// $q = "INSERT INTO user (username, password, firstname, lastname, `desc`, usertype,

gradyear) VALUES ('$actual_email', '$password', '$firstname', '$lastname', '$description',

$usertype, $gradyear)";

}

run_baller_query($q, $params);

// run_query($q);

session_destroy();

Page 74: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 74 | P a g e

make_header("Registration Continued");

echo'

<div id="container">

<div id = "header">

<h1>Welcome!</h1>

</div>

<div id = "content">

<h2>Registration Complete</h2>

<b>Congratulations! You have successfully registered. You may now log in using your email

and password. </b><br />

<div class = "links">

<a href="login.php">Log In</a>

</div>

</div>

';

make_footer_unauth();

}

else {

make_header("Registration Continued");

echo '

<div id="container_large">

<div id = "header">

<h1>Welcome!</h1>

</div>

<div id = "content_large">

<h2Email Verified</h2>

<p>Please enter the following information. Note that your username is the email you used to

register.</p>

<table>

<form method="post"

action="verify.php?PHPSESSID='.$sid.'&email='.$given_email.'&code='.$given_code.'&submitted=

yes">

<tr>

<td>Username:</td><td>'.$actual_username.'</td>

</tr>

<tr>

<td>First Name<span class = "red">*</span>:</td><td><input type="text" name="fname"

value="',$firstname,'"/></td>

</tr>

<tr>

<td>Last Name<span class = "red">*</span>:</td><td><input type="text" name="lname"

value="',$lastname,'"/></td>

</tr>

<tr>

<td>Graduation Year<span class = "red">*</span></td>

<td>

<select name = "gradyear">';

for($i = 2020; $i > 1950; $i--){

echo'<option value="'.$i.'">'.$i.'</option>';

}

echo'

</select>

</td>

</tr>

<tr>

<td>Enter a Description About Yourself<span class = "red">*</span>:</td><td><textarea name

="description" rows="5" cols="15"></textarea></td><td>

</tr>

<tr>

<td>Password<span class = "red">*</span>:</td><td><input type="password" name="pwd"

/></td><td>

</tr>

<tr>

<td>Password Again<span class = "red">*</span>:</td><td><input type="password" name="pwd2"

/></td><td>

</tr>

<tr>

<td><input type="submit" value="Complete Registration" /></td>

</tr>

Page 75: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 75 | P a g e

</form>

</table>

<span class = "red"><p>* = Required Field</p></span>

<div class = "links">

<a href="login.php">Log In</a>

</div>

</div>';

if ($submitted == "yes") {

if ($firstname == "")

$error = "Enter your first name.";

if ($lastname == "")

$error = "Enter your last name.";

if ($password == "")

$error = "You must enter a password.";

if ($password2 == "")

$error = "You must enter your password twice.";

if ($password != $password2)

$error = "Your passwords do not match.";

error_message("Registration Failed", $error);

}

make_footer_unauth();

}

?>

1.24. Wall.php <?php

/**

* Wall class and functions to handle the User's and Group's Wall functionality

*

* @author Alan Distasio

* @copyright Digital Evolutions (c), 2010

* @version 1.0

* @package Wall

*/

require_once("utilities.php");

class wall

{

/**

* The wall posts

* @access private

* @var string

*/

private $wallPosts;

/**

* User or Group

* @access private

* @var string

*/

private $type;

/**

* Queries

* @access private

* @var string

*/

private $result;

/**

Page 76: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 76 | P a g e

* User's first name

* @access private

* @var string

*/

private $fname;

/**

* User's last name

* @access private

* @var string

*/

private $lname;

/**

* User's group name

* @access private

* @var string

*/

private $gname;

/**

* Is guest

* @access private

* @var string

*/

private $guest;

/**

* Function to get the user's and group's info

*

* @param string

* @param string

* @param string

*/

function __construct($id,$type,$guest)

{

$this ->type = $type;

$this ->id = $id;

$this ->guest = $guest;

if($this->type == "user"){

// $results = run_query("SELECT firstname, lastname FROM user WHERE ID = ".$this->id."");

$params = array();

$params[0] = 'i';

$params[1] = $this->id;

$row = run_baller_query("SELECT firstname, lastname FROM user WHERE ID = ?", $params);

// $row = mysql_fetch_array($results);

$this->fname = $row['firstname'];

$this->lname = $row['lastname'];

}

else{

// $results = run_query("SELECT groupname FROM `group` WHERE ID = ".$this->id."");

$params = array();

$params[0] = 'i';

$params[1] = $this->id;

$row = run_baller_query("SELECT groupname FROM `group` WHERE ID = ?", $params);

// $row = mysql_fetch_array($results);

$this->gname = $row['groupname'];

}

}

/**

* Function to return most recent wall posts

*

* @param int

*/

public function get_recent($num)

{

if ($this->type == 'user')

{

Page 77: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 77 | P a g e

$this ->wallPosts = run_query("SELECT PID, WOID, UNIX_TIMESTAMP(timestamp) AS timestamp,

message, enabled FROM user_wall_post WHERE WOID = ".$this->id." ORDER BY timestamp DESC

LIMIT 0, ".$num."");

/* $params = array();

$params[0] = 'i';

$params[1] = $this->id;

$this ->wallPosts = run_baller_query("SELECT PID, WOID, UNIX_TIMESTAMP(timestamp) AS

timestamp, message, enabled FROM user_wall_post WHERE WOID = ? ORDER BY timestamp DESC LIMIT

0, ".$num."", $params); */

}

else if ($this->type == 'group')

{

$this ->wallPosts = run_query("SELECT UID, GID, UNIX_TIMESTAMP(timestamp) AS timestamp,

message, enabled FROM group_wall_post WHERE GID = ".$this->id." ORDER BY timestamp DESC

LIMIT 0, ".$num."");

/* $params = array();

$params[0] = 'i';

$this ->wallPosts = run_baller_query("SELECT UID, GID, UNIX_TIMESTAMP(timestamp) AS

timestamp, message, enabled FROM group_wall_post WHERE GID = ? ORDER BY timestamp DESC LIMIT

0, ".$num."", $params); */

}

return $this ->wallPosts;

}

/**

* Function to handle writing on User's or Group's wall

*/

public function write_post()

{

if($_POST['message'] == ""){

error_message("Error","Please enter a message!");

}

else{

if($this->type == "group"){

// run_query("INSERT INTO group_wall_post (UID, GID, message) VALUES

(".$_SESSION['userid'].", ".$this->id.", '".$_POST['message']."')");

$params = array();

$params[0] = 'iis';

$params[1] = $_SESSION['userid'];

$params[2] = $this->id;

$params[3] = $_POST['message'];

run_baller_query("INSERT INTO group_wall_post (UID, GID, message) VALUES (?, ?, ?)",

$params);

}

else{

// run_query("INSERT INTO user_wall_post (PID, WOID, message) VALUES

(".$_SESSION['userid'].", ".$this->id.", '".$_POST['message']."')");

$params = array();

$params[0] = 'iis';

$params[1] = $_SESSION['userid'];

$params[2] = $this->id;

$params[3] = $_POST['message'];

run_baller_query("INSERT INTO user_wall_post (PID, WOID, message) VALUES (?, ?, ?)",

$params);

}

}

$this->make_wall();

}

/**

* Function to display the User's or Group's wall

*/

public function make_wall()

{

$this->get_recent(10);

echo '<div id = "wall_outer">

<div id = "wall_middle">

<div id = "wall">';

if ($this->type == "user"){

echo '<h4>'.$this->fname.'\'s Wall</h4>';

Page 78: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 78 | P a g e

if($this->guest == "false"){

$row = mysql_fetch_row(run_query("SELECT * FROM user_friend WHERE (RID =

".$_SESSION['userid']." AND AID = ".$this->id.") || (AID = ".$_SESSION['userid']." AND RID =

".$this->id.")"));

/*$params = array();

$params[0] = 'iiii';

$params[1] = $_SESSION['userid'];

$params[2] = $this->id;

$params[3] = $_SESSION['userid'];

$params[4] = $this->id;

$row = run_baller_query("SELECT * FROM user_friend WHERE (RID = ? AND AID = ?) || (AID = ?

AND RID = ?)", $params);*/

if((($row != FALSE)&&($row[2] == NULL))|| ($_SESSION['userid'] == $this->id)){

if($_GET['type'] == "user"){

echo'<form name = "wall" action = "index.php?loc='.$_GET['loc'].'&type='.$this-

>type.'&id='.$this->id.'" method = "post">';

}

else{

echo'<form name = "wall" action = "index.php?loc='.$_GET['loc'].'" method = "post">';

}

echo 'Post on the Wall:<input type="submit" style = "float:right;" name="post" value =

"Post"><br />

<textarea name = "message" rows = "3" cols = "23"></textarea>

</form>';

}

}

}

else{

echo '<h4>'.$this->gname.'\'s Wall</h4>';

if($this->guest == "false"){

$row = mysql_fetch_row(run_query("SELECT * FROM membership WHERE UID =

".$_SESSION['userid']." AND GID = ".$this->id.""));

/*$params = array();

$params[0] = 'ii';

$params[1] = $_SESSION['userid'];

$params[2] = $this->id;

$row = run_baller_query("SELECT * FROM membership WHERE UID = ? AND GID = ?", $params);*/

if(($row != FALSE)&&($row[2] == NULL)&&($row[5] != NULL)){

echo'<form name = "wall" action = "index.php?loc='.$_GET['loc'].'&type=group&id='.$this-

>id.'" method = "post">';

echo 'Post on the Wall:<input type="submit" style = "float:right;" name="post" value =

"Post"><br />

<textarea name = "message" rows = "3" cols = "23"></textarea>

</form>';

}

}

}

echo'<ul>';

while($row = mysql_fetch_array($this->wallPosts)){

$date = $row['timestamp'] + 7200;

if($this->type == "user"){

// $use = mysql_fetch_array(run_query("SELECT firstname, lastname FROM user WHERE ID =

".$row['PID'].""));

$params = array();

$params[0] = 'i';

$params[1] = $row['PID'];

$use = run_baller_query("SELECT firstname, lastname FROM user WHERE ID = ?", $params);

if($row['PID'] == $_SESSION['userid']){

echo '<li><a href = "index.php?loc=Home">'.$use['firstname'].' '.$use['lastname'].'</a>

says:<br /><br />'.$row['message'].'<div class = "post">'.date("F j, Y, g:i a",

$date).'</div></li><br/>';

}

else{

echo '<li><a href = "index.php?loc=Home&type=user&id='.$row['PID'].'">'.$use['firstname'].'

'.$use['lastname'].'</a> says:<br /><br />'.$row['message'].'<div class = "post">'.date("F

j, Y, g:i a", $date).'</div></li><br/>';

}

}

else{

Page 79: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 79 | P a g e

// $use = mysql_fetch_array(run_query("SELECT firstname, lastname FROM user WHERE ID =

".$row['UID'].""));

$params = array();

$params[0] = 'i';

$params[1] = $row['UID'];

$use = run_baller_query("SELECT firstname, lastname FROM user WHERE ID = ?", $params);

if($row['UID'] == $_SESSION['userid']){

echo '<li><a href = "index.php?loc=Home">'.$use['firstname'].' '.$use['lastname'].'</a>

says:<br/><br />'.$row['message'].'<div class = "post">'.date("F j, Y, g:i a",

$date).'</div></li><br/>';

}

else{

echo '<li><a href = "index.php?loc=Home&type=user&id='.$row['UID'].'">'.$use['firstname'].'

'.$use['lastname'].'</a> says: <br /><br />'.$row['message'].'<div class = "post">'.date("F

j, Y, g:i a", $date).'</div></li><br/>';

}

}

}

echo'

</ul>

</div>

</div>

</div>';

}

/**

* Function to display the small version of the User's or Group's wall

*/

public function small_wall()

{

$this->get_recent(3);

echo'<ul>';

while($row = mysql_fetch_array($this->wallPosts)){

$date = $row['timestamp'] + 7200;

if($this->type == "user"){

// $use = mysql_fetch_array(run_query("SELECT firstname, lastname FROM user WHERE ID =

".$row['PID'].""));

$params = array();

$params[0] = 'i';

$params[1] = $row['PID'];

$use = run_baller_query("SELECT firstname, lastname FROM user WHERE ID = ?", $params);

if($row['PID'] == $_SESSION['userid']){

echo '<li><a href = "index.php?loc=Home">'.$use['firstname'].' '.$use['lastname'].'</a>

says:<br />'.myTruncate($row['message'], 35).'<div class = "post">'.date("F j, Y, g:i a",

$date).'</div></li>';

}

else{

echo '<li><a href = "index.php?loc=Home&type=user&id='.$row['PID'].'">'.$use['firstname'].'

'.$use['lastname'].'</a> says:<br />'.myTruncate($row['message'], 35).'<div class =

"post">'.date("F j, Y, g:i a", $date).'</div></li>';

}

}

else{

// $use = mysql_fetch_array(run_query("SELECT firstname, lastname FROM user WHERE ID =

".$row['UID'].""));

$params = array();

$params[0] = 'i';

$params[1] = $row['UID'];

$use = run_baller_query("SELECT firstname, lastname FROM user WHERE ID = ?", $params);

if($row['UID'] == $_SESSION['userid']){

echo '<li><a href = "index.php?loc=Home">'.$use['firstname'].' '.$use['lastname'].'</a>

says:<br />'.myTruncate($row['message'], 35).'<div class = "post">'.date("F j, Y, g:i a",

$date).'</div></li>';

}

else{

echo '<li><a href = "index.php?loc=Home&type=user&id='.$row['UID'].'">'.$use['firstname'].'

'.$use['lastname'].'</a> says:<br />'.myTruncate($row['message'], 35).'<div class =

"post">'.date("F j, Y, g:i a", $date).'</div></li>';

}

Page 80: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 80 | P a g e

}

}

echo'

</ul>';

}

}

?>

1.25. Arrange.js // JavaScript Document

(function() {

var r = myrow;

var c = mycol;

var update = page;

var groupNum = group;

var Dom = YAHOO.util.Dom;

var Event = YAHOO.util.Event;

var DDM = YAHOO.util.DragDropMgr;

//////////////////////////////////////////////////////////////////////////////

// example app

//////////////////////////////////////////////////////////////////////////////

YAHOO.example.DDApp = {

init: function() {

var rows=9,cols=1,i,j;

new YAHOO.util.DDTarget("ul1");

for (j=1;j<=r;j=j+1) {

new YAHOO.example.DDList("li1_" + j);

}

Event.on("showButton", "click", this.showOrder);

Event.on("switchButton", "click", this.switchStyles);

},

showOrder: function() {

//alert(update);

var ul1=Dom.get("ul1");

var out = "";

if (ul1 != null) {

var items = ul1.getElementsByTagName("li");

out = "ul1" + "=";

for (i=0;i<items.length;i=i+1) {

if (Dom.getAttribute(items[i],"name") != "msg"){

out += Dom.getAttribute(items[i],"name") + ",";

}

}

}

out = out.slice(0,-1);

out += "&page=" + update + "&group=" + groupNum;

//alert(out);

var xmlhttp = new XMLHttpRequest();

var url = "source_files/php_files/updateorder.php?" + out;

xmlhttp.open("GET",url,true);

//alert(url);

xmlhttp.send(null);

},

Page 81: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 81 | P a g e

switchStyles: function() {

Dom.get("ul1").className = "draglist_alt";

}

};

//////////////////////////////////////////////////////////////////////////////

// custom drag and drop implementation

//////////////////////////////////////////////////////////////////////////////

YAHOO.example.DDList = function(id, sGroup, config) {

YAHOO.example.DDList.superclass.constructor.call(this, id, sGroup, config);

this.logger = this.logger || YAHOO;

var el = this.getDragEl();

Dom.setStyle(el, "opacity", 0.67); // The proxy is slightly transparent

this.goingUp = false;

this.lastY = 0;

};

YAHOO.extend(YAHOO.example.DDList, YAHOO.util.DDProxy, {

startDrag: function(x, y) {

this.logger.log(this.id + " startDrag");

// make the proxy look like the source element

var dragEl = this.getDragEl();

var clickEl = this.getEl();

Dom.setStyle(clickEl, "visibility", "hidden");

dragEl.innerHTML = clickEl.innerHTML;

Dom.setStyle(dragEl, "background-image", Dom.getStyle(clickEl, "background-image"));

Dom.setStyle(dragEl, "background-repeat", Dom.getStyle(clickEl, "background-repeat"));

Dom.setStyle(dragEl, "border", "none");

},

endDrag: function(e) {

var srcEl = this.getEl();

var proxy = this.getDragEl();

// Show the proxy element and animate it to the src element's location

Dom.setStyle(proxy, "visibility", "");

var a = new YAHOO.util.Motion(

proxy, {

points: {

to: Dom.getXY(srcEl)

}

},

0.2,

YAHOO.util.Easing.easeOut

)

var proxyid = proxy.id;

var thisid = this.id;

// Hide the proxy and show the source element when finished with the animation

a.onComplete.subscribe(function() {

Dom.setStyle(proxyid, "visibility", "hidden");

Dom.setStyle(thisid, "visibility", "");

});

a.animate();

YAHOO.example.DDApp.showOrder();

},

onDragDrop: function(e, id) {

Page 82: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 82 | P a g e

// If there is one drop interaction, the li was dropped either on the list,

// or it was dropped on the current location of the source element.

if (DDM.interactionInfo.drop.length === 1) {

// The position of the cursor at the time of the drop (YAHOO.util.Point)

var pt = DDM.interactionInfo.point;

// The region occupied by the source element at the time of the drop

var region = DDM.interactionInfo.sourceRegion;

// Check to see if we are over the source element's location. We will

// append to the bottom of the list once we are sure it was a drop in

// the negative space (the area of the list without any list items)

if (!region.intersect(pt)) {

var destEl = Dom.get(id);

var destDD = DDM.getDDById(id);

destEl.appendChild(this.getEl());

destDD.isEmpty = false;

DDM.refreshCache();

}

}

},

onDrag: function(e) {

// Keep track of the direction of the drag for use during onDragOver

var y = Event.getPageY(e);

if (y < this.lastY) {

this.goingUp = true;

} else if (y > this.lastY) {

this.goingUp = false;

}

this.lastY = y;

},

onDragOver: function(e, id) {

var srcEl = this.getEl();

var destEl = Dom.get(id);

// We are only concerned with list items, we ignore the dragover

// notifications for the list.

if (destEl.nodeName.toLowerCase() == "li") {

var orig_p = srcEl.parentNode;

var p = destEl.parentNode;

if (this.goingUp) {

p.insertBefore(srcEl, destEl); // insert above

} else {

p.insertBefore(srcEl, destEl.nextSibling); // insert below

}

DDM.refreshCache();

}

}

});

Event.onDOMReady(YAHOO.example.DDApp.init, YAHOO.example.DDApp, true);

})();

Page 83: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 83 | P a g e

1.26. Check_delete.js // JavaScript Document

function deletechecked()

{

var answer = confirm("Remove User?")

if (answer){

document.messages.submit();

}

return false;

}

1.27. Countchecks.js // JavaScript Document

function CountChecks(which) {

var maxchecked = 9;

var count = 0;

for(i=0; i<document.checkb.elements.length; i++)

{

if(document.checkb.elements[i].checked == true) { count++; }

}

if(count > maxchecked) {

eval('document.checkb.' + which + '.checked = false');

alert('Sorry, only ' + maxchecked + ' may be checked.');

}

}

1.28. Locationchange.js // JavaScript Document

var xmlhttp

function changelocation(str)

{

alert("here");

if (str.length==0)

{

document.getElementById("location").innerHTML="";

return;

}

xmlhttp=GetXmlHttpObject();

if (xmlhttp==null)

{

alert ("Your browser does not support XMLHTTP!");

return;

}

alert(str);

var url="locationchange.php";

url=url+"?q="+str;

url=url+"&sid="+Math.random();

xmlhttp.onreadystatechange=stateChanged;

alert(url);

xmlhttp.open("GET",url,true);

xmlhttp.send(null);

}

function stateChanged()

{

Page 84: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 84 | P a g e

if (xmlhttp.readyState==4)

{

document.getElementById("tem").innerHTML=xmlhttp.responseText;

}

}

function GetXmlHttpObject()

{

if (window.XMLHttpRequest)

{

// code for IE7+, Firefox, Chrome, Opera, Safari

return new XMLHttpRequest();

}

if (window.ActiveXObject)

{

// code for IE6, IE5

return new ActiveXObject("Microsoft.XMLHTTP");

}

return null;

}

1.29. Popup.js /***************************/

//@Author: Adrian "yEnS" Mato Gondelle

//@website: www.yensdesign.com

//@email: [email protected]

//@license: Feel free to use it, but keep this credits please!

/***************************/

//SETTING UP OUR POPUP

//0 means disabled; 1 means enabled;

var popupStatus = 0;

//loading popup with jQuery magic!

function loadPopup(){

//loads popup only if it is disabled

if(popupStatus==0){

$("#backgroundPopup").css({

"opacity": "0.7"

});

$("#backgroundPopup").fadeIn("slow");

$("#popupContact").fadeIn("slow");

popupStatus = 1;

}

}

//disabling popup with jQuery magic!

function disablePopup(){

//disables popup only if it is enabled

if(popupStatus==1){

$("#backgroundPopup").fadeOut("slow");

$("#popupContact").fadeOut("slow");

popupStatus = 0;

}

}

//centering popup

function centerPopup(){

//request data for centering

var windowWidth = document.documentElement.clientWidth;

var windowHeight = document.documentElement.clientHeight;

var popupHeight = $("#popupContact").height();

var popupWidth = $("#popupContact").width();

//centering

$("#popupContact").css({

"position": "absolute",

"top": windowHeight/4-popupHeight/4,

Page 85: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 85 | P a g e

"left": windowWidth/2-popupWidth/2

});

//only need force for IE6

$("#backgroundPopup").css({

"height": windowHeight

});

}

//CONTROLLING EVENTS IN jQuery

$(document).ready(function(){

//LOADING POPUP

//Click the button event!

//centering with css

centerPopup();

//load popup

loadPopup();

//CLOSING POPUP

//Click the x event!

$("#popupContactClose").click(function(){

disablePopup();

});

//Click out event!

$("#backgroundPopup").click(function(){

disablePopup();

});

//Press Escape event!

$(document).keypress(function(e){

if(e.keyCode==27 && popupStatus==1){

disablePopup();

}

});

});

1.30. Authenticated.css body{

margin: 10px auto;

background:#EED980 none repeat scroll 0%;

line-height:1;

font-size: 12px;

font-family:arial,sans-serif;

height:100%;

}

#container {

/*background: url("img/site_design/bg_grad.jpg");*/

margin: 0px auto;

/*background-color:#008B20;*/

width:1008px;

min-height:550px;

}

.header {

padding-top: 5px;

width:1008px;

margin:0px;

height:120px;

color:#FFF;

background: url("img/header.png");

}

Page 86: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 86 | P a g e

.header a{

color:#FFF;

}

#top_menu_right{

float:right;

margin-right:25px;

margin-top:5px;

min-height:55px;

}

.main_logo{

width:350px;

margin: 0 auto;

height:55px;

}

#top_menu_left {

padding:0px 0px 0px 25px;;

margin-top:5px;

width:304px;

float:left;

min-height:55px;

}

#top_menu_left li{

display:inline;

float:left;

padding-right:10px;

}

#top_menu_left li a{

text-decoration:none;

}

#top_menu_left li a:hover{

color:#FF3;

}

#top_menu_left ul{

float:left;

padding:0px;

margin:0px;

}

.profile_name{

width:450px;

margin-top:5px;

float:left;

height:50px;

padding-left: 7px;

font-size:.8em;

}

.profile_name h2{

margin:0px;

padding:0px 0px 0px 4px;

}

.profile_name h3{

margin:0px;

padding:0px 0px 0px 4px;

}

.profile_name li{

display:inline;

padding:0px 5px;

font-size:1.2em;

}

Page 87: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 87 | P a g e

.profile_name li a{

text-decoration:none;

}

.profile_name li a:hover{

color:#FF3;

}

.profile_name ul{

margin:0px;

padding:0px;

}

.profile_image{

clear:left;

width:50px;

margin:5px 0px 0px 30px;

float:left;

height:50px;

padding:0px 5px;

}

.profile_image img{

border:none;

}

.center{

margin:0px auto;

}

.floatRt {

float:right;

margin:0px 20px 0px 0px;

}

.floatLt {

float: left;

padding-right:5px;

margin-left:25px;

}

.main_logo img{

border:none;

}

#current_user{

background: url("img/user_background.png");

width:242px;

height:45px;

margin:0px auto;

text-align:center;

}

#current_user h3{

padding:0px;

margin:0px;

}

#main_content{

width:958px;

margin-left:15px;

float:left;

clear:both;

background-color:#005B42;

padding:10px;

min-height:400px;

}

.bubble{

width:282px;

height:185px;

Page 88: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 88 | P a g e

float:left;

background: url("img/bubble_background.png") no-repeat;

margin-right: 20px;

margin-bottom:15px;

padding:5px;

}

.small{

font-size:.8em;

}

.red{

color:red;

}

.bubble a{

text-decoration:none;

}

.bubble h3{

margin:0px 0px 15px 0px;

padding:0px;

text-align:center;

}

.bubble h5{

padding:0px;

margin:0px;

display:inline;

}

.bubble .profile_pic{

clear:both;

float:left;

padding-right:5px;

}

.bubble p{

padding:0px 0px 10px 0px;

margin:0px;

font-size:.8em;

}

.bubble .date{

float:right;

font-size:.8em;

}

.bubble .right{

float:right;

margin-bottom:20px;

}

.top_links{

float:right;

width:230px;

display:inline;

margin-bottom:10px;

min-height:25px;

}

.form_left{

float:left;

}

.content_outer{

width:725px;

float:left;

background:url(img/content_bg_auth_middle.png);

Page 89: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 89 | P a g e

min-height:300px;

}

.content_outer .content_middle{

background:url(img/content_bg_auth_top.png) top left no-repeat;

min-height:350px;

}

.content_outer .content_middle .content{

background:url(img/content_bg_auth_bottom.png) bottom left no-repeat;

min-height:350px;

padding:10px;

}

.readable{

background:#F5F5DC;

min-height:350px;

padding:10px 15px;;

margin:10px;

text-align:center;

}

.readable table{

margin:0px auto;

}

.content h3{

text-align:center;

}

.content h4{

text-align:center;

}

#friend_center{

float:left;

min-height:250px;

width:300px;

border:3px groove black;

margin-bottom:15px;

}

#group_center{

float:right;

min-height:250px;

width:300px;

border:3px groove black;

margin-bottom:15px;

}

#moderator_center{

clear:both;

min-height:50px;

padding:10px;

border:3px groove black;

}

#wall_outer {

width: 230px;

float:right;

display:inline;

clear:right;

background:url(img/wall_background_middle.png);

}

#wall_outer #wall_middle {

background: url(img/wall_background_top.png) top left no-repeat;

}

#wall_outer #wall_middle #wall {

background: url(img/wall_background_bottom.png) bottom left no-repeat;

min-height:100px;

Page 90: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 90 | P a g e

padding:10px;

}

.post{

font-size:.8em;

margin-top:5px;

}

#wall ul{

list-style:none;

margin:0px;

padding:0px;

}

#wall li{

padding:5px 5px;

word-wrap: break-word;

}

#wall h4{

padding:0px 0px 10px 0px;

margin:0px;

text-decoration:underline;

text-align:center;

}

.wall h5{

padding:0px;

margin:0px;

display:inline;

}

.wall .profile_pic{

float:left;

padding-right:5px;

}

.wall p{

padding:0px 0px 10px 0px;

margin:0px;

}

.wall .date{

float:right;

font-size:.8em;

}

.wall .right{

float:right;

margin-bottom:20px;

}

.profile_name h2{

margin:0px;

}

.wall h7{

margin: 0px;

padding:0px;

}

#footer{

margin: 0px auto;

text-align:center;

padding-top:8px;

width:1002px;

color:white;

clear: both;

height:22px;

background: url("img/footer.png");

}

Page 91: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 91 | P a g e

#footer a{

color:white;

text-decoration:underline;

}

.moveable{

width:690px;

display:inline;

}

.center{

text-align:center;

}

.delete{

font-size:14px;

line-height:14px;

left:9px;

top:5px;

position:absolute;

color:red;

font-weight:700;

display:block;

}

/* CSS FOR MOVEABLE BOXES */

ul.draglist {

position: relative;

min-height:100px;

list-style: none;

margin:0px 0px 0px 0px;

width:700px;

padding:0;

}

ul.draglist li {

margin: 1px;

cursor: move;

zoom: 1;

}

ul.draglist_no_move {

position: relative;

min-height:100px;

list-style: none;

margin:0px 0px 0px 0px;

width:700px;

padding:0;

}

ul.draglist_no_move li {

margin: 1px;

zoom: 1;

}

li.list1 {

background-image:url(img/bubble_background.png);

background-repeat:no-repeat;

height:200px;

width:220px;

float:left;

margin:5px;

padding:5px;

}

li.list1 ul{

list-style:none;

Page 92: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 92 | P a g e

margin:0px;

padding:0px;

}

li.list1 li{

padding:5px 5px;

}

.prof_pic{

margin:7px auto 0px;

text-align:center;

}

.question{

margin:5px 0px;

padding:0px 5px;

height:3em;

text-align:center;

word-wrap: break-word;

}

.answer{

text-align:center;

padding:0px 7px;

max-height:12em;

word-wrap: break-word;

}

.caption{

padding:3px 10px;

font-size:.8em;

font-style:italic;

text-align:center;

}

/* CSS FOR POP UP BOX */

table {

border-collapse:separate;

border-spacing:0pt;

}

caption, th, td {

font-weight:normal;

text-align:left;

}

blockquote:before, blockquote:after, q:before, q:after {

content:"";

}

blockquote, q {

quotes:"" "";

}

a{

cursor: pointer;

text-decoration:none;

}

br.both{

clear:both;

}

#backgroundPopup{

display:none;

position:fixed;

_position:absolute; /* hack for internet explorer 6*/

height:100%;

width:100%;

top:0;

left:0;

background:#000000;

border:1px solid #cecece;

z-index:1;

}

#popupContact{

Page 93: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 93 | P a g e

display:none;

position:fixed;

_position:absolute; /* hack for internet explorer 6*/

height:150px;

width:398px;

background:#FFFFFF;

border:2px solid #cecece;

z-index:2;

padding:12px;

font-size:13px;

}

#popupContact h1{

text-align:left;

color:#6FA5FD;

font-size:22px;

font-weight:700;

border-bottom:1px dotted #D3D3D3;

padding-bottom:2px;

margin-bottom:20px;

}

#popupContactClose{

font-size:14px;

line-height:14px;

right:6px;

top:4px;

position:absolute;

color:#6fa5fd;

font-weight:700;

display:block;

}

#button{

text-align:center;

margin:100px;

}

1.31. Unauthenticated.css body{

margin: 0px auto;

background:#FDCA39 none repeat scroll 0%;

line-height:1;

font-size: 12px;

font-family:arial,sans-serif;

height:100%;

width:410px;

}

#container{

margin:0px auto;

background:url(img/background.png) no-repeat;

height:310px;

}

#container_large{

margin:10px auto;

background:url(img/background_large.png) no-repeat;

height:570px;

}

#header{

padding:5px 0px;

text-align:center;

height:50px;

color:#FFF;

}

Page 94: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 94 | P a g e

#content{

margin: 0px 17px;

padding:15px 15px 10px 10px;

height:180px;

background:url(img/content_bg.png) no-repeat;

}

#content_large{

margin: 0px 17px;

padding:15px 15px 10px 10px;

height:350px;

background:url(img/content_bg_large.png) no-repeat;

}

img.center{

margin:0px auto;

width:800px;

padding:0px;

}

#footer{

text-align:center;

color:#FFF;

}

#footer a{

color:#FFF;

text-decoration:underline;

}

.links{

margin-top:10px;

}

table {

border-collapse:separate;

border-spacing:0pt;

}

caption, th, td {

font-weight:normal;

text-align:left;

}

blockquote:before, blockquote:after, q:before, q:after {

content:"";

}

blockquote, q {

quotes:"" "";

}

a{

cursor: pointer;

text-decoration:none;

}

br.both{

clear:both;

}

#backgroundPopup{

display:none;

position:fixed;

_position:absolute; /* hack for internet explorer 6*/

height:100%;

width:100%;

top:0;

left:0;

background:#000000;

border:1px solid #cecece;

z-index:1;

}

#popupContact{

display:none;

position:fixed;

_position:absolute; /* hack for internet explorer 6*/

Page 95: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 95 | P a g e

height:150px;

width:398px;

background:#FFFFFF;

border:2px solid #cecece;

z-index:2;

padding:12px;

font-size:13px;

}

#popupContact h1{

text-align:left;

color:#6FA5FD;

font-size:22px;

font-weight:700;

border-bottom:1px dotted #D3D3D3;

padding-bottom:2px;

margin-bottom:20px;

}

#popupContactClose{

font-size:14px;

line-height:14px;

right:6px;

top:4px;

position:absolute;

color:#6fa5fd;

font-weight:700;

display:block;

}

#button{

text-align:center;

margin:100px;

}

Page 96: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 96 | P a g e

2 PhpDocumentor

PhpDocumentor is an auto-documentation tool for the php language, similar to Javadoc’s

for the Java language. PhpDocumentor is designed to make writing good documentation

for your PHP code easy. It can also generate nicely formatted web pages from your

documented source code for others to view and refer to. Similar to PHPUnit our client

asked Digital Evolutions to explore the possibilities of implementing PhpDocumentor

during the Detailed Design phase of the SaintBook project and by the project’s deadline a

basic level of implementation was able to be reached. If given as a requirement during

the Requirements Specification phase, Digital Evolutions would have had a much better

use of the tool and fuller use of its features.

To view the full user manual and documentation for PHP Documentor please visit their

web site at: http://www.phpdoc.org/.

Page 97: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 97 | P a g e

Below is a snippet of code that shows most of how PHP Documentor is used and the syntax that

it requires.

Page 98: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 98 | P a g e

At the beginning of every PHP file there is also an explanation of what this script is for or

the main functionality of the file.

The “/**” syntax represents the start of documentation block.

The “*/” syntax represents the end of the documentation block.

The “@author” syntax represents the programmer who wrote the PHP code for the

particular file.

The “@copyright” syntax represents is who this code is copyrighted to.

The “@version” syntax represents the current version of the project or sub project.

The “@package” syntax represents a related group of elements, i.e. Class or

procedural pages.

o For this file “group” is the package, being the group class page.

The “@var” syntax is to represent a variable.

o For the first variable “$uname”, there is a short description and after the tag it

requires what data type variable it is.

PHP Documentor also has the capability of generating web pages using your PHP source

code and the documentation blocks written above the code. It uses the comments

themselves to generate these pages, so if done right PHP Documentor will take your PHP

files and generate fully functional, web display documentation. This is very similar to

JavaDoc. It displays class hierarchies, methods, variables and all the descriptions nicely

and to be easily read.

Page 99: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 99 | P a g e

Below is a screenshot of one of our generated web pages, the one generated for the

“group.php” file as shown above.

This screenshot shows the generated documentation for the “group.php” file, as you can see

it grouped two different files since it begins with the same word. It nicely displays the top of

page details, the author, version and copyright. It also shows the classes that are within this

file.

Page 100: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 100 | P a g e

Here is a screenshot of the top of the class hierarchy for the “group” class. At the top it

shows the class it inherits from which for “group” is the “page” super class. Again this

generation shows the author, version, copyright and also has links to variables, methods and

other information pertaining to the “group” class.

Page 101: Appendix D: Source Code PhpDocumentororaserv.cs.siena.edu/~perm_digevol/documents/accept_test/Accepta… · Acceptance Test Appendix D: Source Code and PhpDocumentor SaintBook Requested

Digital Evolutions Appendix D: Source Code and PhpDocumentor 101 | P a g e

Below is another screenshot of a small portion of the class variables and methods for the

“group” class.

As you can see it shows the variables/methods descriptions and types. It also shows the line

number from the source code, parameters for the methods and what this method overrides

from the “page” super class.

These generated documentations are very useful and if another programmer or end-user

needs to look up something about the code or the software.