Skip to content

Commit

Permalink
finals stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Jing Tao Liu committed Dec 17, 2010
2 parents 5d23760 + 1ef07e0 commit a38a4dc
Show file tree
Hide file tree
Showing 16 changed files with 338 additions and 128 deletions.
193 changes: 104 additions & 89 deletions categories.php
Original file line number Diff line number Diff line change
@@ -1,121 +1,136 @@
<?php
require_once 'global.php';
require_once 'header.php';
/*
* categories.php: Original Version of category management feature
* categoryAdmin2.php is current version
* 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 Administrator 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 1.0
* @deprecated File deprecated since version 3.0 categoryAdmin2.php
*/

/*Require html header and global variables*/
require_once 'global.php';
require_once 'header.php';

echo '<div class="body">';
echo '<div class="col large">';
echo '<div class="body">';
echo '<div class="col large">';

if ( $_POST )
{
$queryDelete = 'UPDATE categories SET permanent=0 WHERE categoryID = ';
$queryAdd = 'UPDATE categories SET permanent=1 WHERE categoryID = ';

$addArray = array_keys( $_POST, 'add' );
$deleteArray = array_keys( $_POST, 'delete' );
if ($_POST) {
$query_delete = 'UPDATE categories SET permanent=0 WHERE categoryID = ';
$query_add = 'UPDATE categories SET permanent=1 WHERE categoryID = ';
$add_array = array_keys($_POST, 'add');
$delete_array = array_keys($_POST, 'delete');

if ( $addArray )
{
$queryAdd .= implode( ' OR categoryID = ', $addArray );
$resultAdd = mysql_query($queryAdd);
echo mysql_error();
/* To do: error check */
}
if ($addArray) {
$query_add .= implode(' OR categoryID = ', $add_array);
$result_add = mysql_query($query_add);
echo mysql_error();
/* To do: error check */
}

if ( $deleteArray )
{
$queryDelete .= implode( ' OR categoryID = ', $deleteArray );
$resultDelete = mysql_query($queryDelete);
echo mysql_error();
/* To do: error check */
}
}
if ($delete_array) {
$query_delete .= implode(' OR categoryID = ', $delete_array);
$result_delete = mysql_query($query_delete);
echo mysql_error();
/* To do: error check */
}
}

$queryPerm = "SELECT * FROM categories
$query_perm = "SELECT * FROM categories
WHERE permanent=1
ORDER BY requestCount DESC,
categoryName ASC";

$resultPerm = mysql_query($queryPerm);
$result_perm = mysql_query($query_perm);

$queryTemp = "SELECT * FROM categories
$query_temp = "SELECT * FROM categories
WHERE permanent=0
ORDER BY requestCount DESC,
categoryName ASC";

$resultTemp = mysql_query($queryTemp);
?>
$result_temp = mysql_query($query_temp);
?>

<form name="categoryPerm" action="categories.php" method="post">
<table>
<tr>
<td colspan="3">
<h1>Permanent Categories</h1>
</td>
</tr>
<form name="categoryPerm" action="categories.php" method="post">
<table>
<tr>
<td colspan="3">
<h1>Permanent Categories</h1>
</td>
</tr>

<tr>
<th>Category</th>
<th>Requests</th>
<th>Delete</th>
</tr>
<tr>
<th>Category</th>
<th>Requests</th>
<th>Delete</th>
</tr>

<?php while ($row = mysql_fetch_assoc($resultPerm)) : ?>
<?php while ($row = mysql_fetch_assoc($resultPerm)) : ?>

<tr>
<td><?php echo $row['categoryName']; ?></td>
<td><?php echo $row['requestCount']; ?></td>
<td><input type="checkbox" name="<?php echo $row['categoryID']; ?>" value="delete"></td>
</tr>
<tr>
<td><?php echo $row['categoryName']; ?></td>
<td><?php echo $row['requestCount']; ?></td>
<td><input type="checkbox" name="<?php echo $row['categoryID']; ?>" value="delete"></td>
</tr>

<?php endwhile; ?>
<?php endwhile; ?>

<tr>
<td colspan="3">
<h1>Temporary Categories</h1>
</td>
</tr>
<tr>
<td colspan="3">
<h1>Temporary Categories</h1>
</td>
</tr>

<tr>
<th>Category</th>
<th>Requests</th>
<th>Add</th>
</tr>
<tr>
<th>Category</th>
<th>Requests</th>
<th>Add</th>
</tr>

<?php while ($row = mysql_fetch_assoc($resultTemp)) : ?>
<?php while ($row = mysql_fetch_assoc($resultTemp)) : ?>

<tr>
<td><?php echo $row['categoryName']; ?></td>
<td><?php echo $row['requestCount']; ?></td>
<td><input type="checkbox" name="<?php echo $row['categoryID']; ?>" value="add"></td>
</tr>
<tr>
<td><?php echo $row['categoryName']; ?></td>
<td><?php echo $row['requestCount']; ?></td>
<td><input type="checkbox" name="<?php echo $row['categoryID']; ?>" value="add"></td>
</tr>

<?php endwhile; ?>
<?php endwhile; ?>

</table>
</table>

<input type="submit" value="update">
</form>
<input type="submit" value="update">
</form>

<style type="text/css">
table {
margin: 10px 10px 10px 0;
}
<style type="text/css">
table {
margin: 10px 10px 10px 0;
}

td, th {
padding: 5px;
border: 1px solid #ccc;
}
td, th {
padding: 5px;
border: 1px solid #ccc;
}

th {
text-align: left;
font-size: 14px;
color: #555;
}
</style>
th {
text-align: left;
font-size: 14px;
color: #555;
}
</style>

<?php
echo '</div>';
require_once 'sidebar.php';
echo '</div>';
require_once 'footer.php';
<?php
echo '</div>';
require_once 'sidebar.php';
echo '</div>';
require_once 'footer.php';
?>
22 changes: 21 additions & 1 deletion categoryAdmin2.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
<?php
require_once 'global.php';
require_once 'header.php';
/*
* categoryAdmin2.php: Current version of category management
* 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 Administrator 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
*/

/*Require html header, global variables and all functions*/

require_once 'global.php';
require_once 'header.php';
?>

<!-- Permanent Categories Table -->
Expand Down Expand Up @@ -91,7 +111,7 @@
<button type='button' id='update'>Update</button>

<script type="text/javascript">
<!--

//function that adds input field if input for location/category drop down menu is other
$(document).ready(function(){
$("input[value='rename']").change ( function () {
Expand Down
12 changes: 6 additions & 6 deletions delete_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

//check if the user created the event
$query = "SELECT userID
FROM events
WHERE eventID = $eventID;";
FROM events
WHERE eventID = $eventID;";
$result = mysql_query($query);
$row = mysql_fetch_row($result);

//check if the user is an admin
$query = "SELECT accessLevel
FROM users
WHERE userID = $userID;";
FROM users
WHERE userID = $userID;";
$result = mysql_query($query);
$row2 = mysql_fetch_row($result);

Expand All @@ -41,7 +41,7 @@
exit();
}
} else {
header('Location: '.ed(false).'detailView.php?s=f&eventID='.$eventID);
header('Location: '.ed(false).'detailView.php?eventID='.$eventID);
exit();
}
?>
?>
16 changes: 13 additions & 3 deletions detailView.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
require_once "global.php";
require_once "header.php";
?>

<div class = "body">
<div class = "col large">

<?php

if ($_GET['flag'] == 'true') echo '<h1 class="head">Your report has been submitted to the administrators...</h1><hr>';

$eventID = htmlspecialchars($_GET['eventID']);
$eventArray = get_events(array($eventID));

Expand Down Expand Up @@ -65,7 +67,7 @@
<span>What: <span class="val"><?php echo $event[7]; ?></span></span>
<span>Where: <span class="val"><?php echo $event[6]; ?></span></span>
<span>Attending: <span class="val attend_count"><?php echo $event[9]; ?></span>
</span>
</span>

<?php display_attend($user[userID], $event[10]); ?>

Expand All @@ -85,6 +87,7 @@

<?php if(is_logged_in()) : ?>
<div class="details" id="addtag">
<a href="flag_event.php?eventID=<?php echo $eventID; ?>" class='attend_event'>Report!</a>
<a class="fake" id="fancy-login">
<span class="word">Add Tags</span>
<div class="login-form">
Expand All @@ -108,10 +111,17 @@
</div>
<?php endif; ?>

<<<<<<< HEAD
<!-- Display 'like' feature from facebook -->
<div class="details" id="facebook" padding="20px">
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="http://www.cs.grinnell.edu/~knolldug/GCal/detailView.php?eventID=<?php echo $eventID;?>" show_faces="true" width="450" font="arial"></fb:like>
=======
<div class="details" id="facebook" padding="20px">

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="http://www.cs.grinnell.edu/~knolldug/GCal/detailView.php?eventID=<?php echo $eventID;?>" show_faces="true" width="450" font="arial"></fb:like>
>>>>>>> 1ef07e0bea934714cba763681af66315bd2e000b
</div>

<div class="details" id="googleCal">
Expand All @@ -130,7 +140,7 @@ function date_to_string($array) {
$endingDate = explode("-", $array[0][4]);
$endingTime = explode(":", $array[0][5]);
$googleDate = sprintf("%04d%02d%02dT%02d%02d00Z/%04d%02d%02dT%02d%02d00Z",
$startingDate[1], $startingDate[1], $startingDate[2],
$startingDate[0], $startingDate[1], $startingDate[2],
($startingTime[0] + 6), $endingTime[1],
$endingDate[0], $endingDate[1], $endingDate[2],
($endingTime[0] + 06), $endingTime[1]);
Expand Down
2 changes: 1 addition & 1 deletion edit_submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$end_time = $end_temp[1];
$start = $start_date.' '.$start_time;
$end = $end_date.' '.$end_time;
if(($start < $right_now) || ($end < $right_now)) {
if(($end < $right_now) || ($end < $start)) {
header('Location: '.ed(false).'edit.php?time=f&s=t&eventID='.$eventID);
exit();
}
Expand Down
36 changes: 36 additions & 0 deletions flag_admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
session_start();
require_once 'global.php';
require_once 'header.php';

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>';

$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();
}

echo '</div>';
include 'sidebar.php';
echo '</div>';
include 'footer.php';
?>
Loading

0 comments on commit a38a4dc

Please sign in to comment.