Skip to content

Commit

Permalink
adheres to PEAR
Browse files Browse the repository at this point in the history
  • Loading branch information
akhirakawa committed Dec 17, 2010
1 parent bd4a004 commit 116de88
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 57 deletions.
70 changes: 44 additions & 26 deletions flag_admin.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
<?php
session_start();
/*
* flag_admin.php
* PHP version 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to [email protected] so we can mail you a copy immediately.
*
* @category admin feature
* @author CSC-325 Database and Web Application Fall 2010 Class
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version 3.0
*/
session_start();
require_once 'global.php';
require_once 'header.php';

if(is_admin()) {
//check that user is admin
if(is_admin()) {
//check that user is admin

echo '<div class = "body">';
echo '<div class="col large">';
echo 'Administration page for flagged events<br><br><br>';
echo '<div class = "body">';
echo '<div class="col large">';
echo 'Administration page for flagged events<br><br><br>';

$flagged_query = "SELECT eventID, eventName, flaggedCount FROM events
WHERE events.flagged=1";
$flagged_result = mysql_query($flagged_query);
$flagged_query = "SELECT eventID, eventName, flaggedCount
FROM events
WHERE events.flagged=1";
$flagged_result = mysql_query($flagged_query);

if (mysql_num_rows($flagged_result) != 0) {
while($row = mysql_fetch_row($flagged_result)) {
echo '<a href="'.ed(false).'detailView.php?eventID='.$row[0].'">'.$row[1].'</a> has been flagged '.$row[2].' times';
echo '<br>';
echo '<a href="'.ed(false).'flag_reset.php?eventID='.$row[0].'"> I checked it dude. It is ok now... </a>';
echo '<br>';
echo '<br>';
}
}

} else {
header('Location: '.ed(false).'index.php');
exit();
if (mysql_num_rows($flagged_result) != 0) {
while($row = mysql_fetch_row($flagged_result)) {
echo '<a href="'.ed(false).'detailView.php?eventID='.$row[0]
.'">'.$row[1].'</a> has been flagged '.$row[2].' times';
echo '<br>';
echo '<a href="'.ed(false).'flag_reset.php?eventID='.$row[0]
.'"> I checked it dude. It is ok now... </a>';
echo '<br>';
echo '<br>';
}
}

} else {
header('Location: '.ed(false).'index.php');
exit();
}

echo '</div>';
include 'sidebar.php';
echo '</div>';
include 'footer.php';
echo '</div>';
include 'sidebar.php';
echo '</div>';
include 'footer.php';
?>
47 changes: 31 additions & 16 deletions flag_event.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
<?php
session_start();
require_once 'global.php';
/*
* flag_event
* PHP version 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to [email protected] so we can mail you a copy immediately.
*
* @category event feature
* @author CSC-325 Database and Web Application Fall 2010 Class
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version 3.0
*/
session_start();
require_once 'global.php';

// set table name
$eventID = addslashes($_GET["eventID"]);
// set table name
$eventID = addslashes($_GET["eventID"]);

//check that user is logged in and is either an admin or created the event
if(is_logged_in()) {
$userID = $_SESSION['userID'];
//check that user is logged in and is either an admin or created the event
if(is_logged_in()) {
$userID = $_SESSION['userID'];

//add flag
$flag_query = "UPDATE events
//add flag
$flag_query = "UPDATE events
SET
flagged=1,
flaggedCount = flaggedCount + 1
WHERE eventID='$eventID'";
$flag_result = mysql_query($flag_query);
$flag_result = mysql_query($flag_query);

header('Location: '.ed(false).'detailView.php?flag=true&eventID='.$eventID);
exit();
} else {
header('Location: '.ed(false).'detailView.php?eventID='.$eventID);
exit();
}
header('Location: '.ed(false).'detailView.php?flag=true&eventID='.$eventID);
exit();
} else {
header('Location: '.ed(false).'detailView.php?eventID='.$eventID);
exit();
}
?>
45 changes: 30 additions & 15 deletions flag_reset.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
<?php
session_start();
require_once 'global.php';
/*
* flag_reset : resets flag for an event to 0 in database
* PHP version 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to [email protected] so we can mail you a copy immediately.
*
* @category user functions
* @author CSC-325 Database and Web Application Fall 2010 Class
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version 3.0
*/
session_start();
require_once 'global.php';

// set table name
$eventID = addslashes($_GET["eventID"]);
// set table name
$eventID = addslashes($_GET["eventID"]);

//check that user is logged in and is either an admin or created the event
if(is_admin()) {
//check that user is logged in and is either an admin or created the event
if(is_admin()) {

//reset flag
$flag_query = "UPDATE events
//reset flag
$flag_query = "UPDATE events
SET
flagged=0
WHERE eventID='$eventID'";
$flag_result = mysql_query($flag_query);
$flag_result = mysql_query($flag_query);

header('Location: '.ed(false).'flag_admin.php');
exit();
} else {
header('Location: '.ed(false).'index.php');
exit();
}
header('Location: '.ed(false).'flag_admin.php');
exit();
} else {
header('Location: '.ed(false).'index.php');
exit();
}
?>

0 comments on commit 116de88

Please sign in to comment.