From 5d237604b82af87ac4efde81d8d5b1c02e8c448b Mon Sep 17 00:00:00 2001 From: Jing Tao Liu Date: Fri, 17 Dec 2010 08:16:23 -0600 Subject: [PATCH] finals stuff --- categoryAdmin2.php | 266 +++++++++++++++-------------- css/filter.css | 118 +++++++++++++ css/home.css | 5 + detailView.php | 12 +- filter.php | 129 ++++++++++++++ functions/filter_functions.php | 111 ++++++++++++ functions/functions.php | 1 + header.php | 6 + index.php | 22 ++- js/fancy_login.php | 2 +- js/main.php | 8 + results.php | 9 +- search.php | 1 + sidebar.php | 10 +- user_accounts/forgot_password.php | 64 ++++--- user_accounts/functions.php | 44 ++--- user_accounts/login_processing.php | 2 +- user_accounts/validate.php | 13 +- 18 files changed, 604 insertions(+), 219 deletions(-) create mode 100644 css/filter.css create mode 100644 filter.php create mode 100644 functions/filter_functions.php diff --git a/categoryAdmin2.php b/categoryAdmin2.php index f05df23..c201b25 100644 --- a/categoryAdmin2.php +++ b/categoryAdmin2.php @@ -1,149 +1,153 @@ - +
-
-
- - - - - - - - + +
CategoryRequestsDowngradeRename
+ + + + + + + $name){ - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; -} -?> -
CategoryRequestsDowngradeRename
" . $name . "" . $categoryRequests[$id] . "" . "
" . "
" . "
" . "
-
- - - - - -
- - - - - - - + while ($row = mysql_fetch_assoc($resultPerm)) { + $categoryNames[$row['categoryID']] = $row['categoryName']; + $categoryRequests[$row['categoryID']] = $row['requestCount']; + } + + foreach($categoryNames as $id => $name) : ?> + + + + + + +
CategoryRequestsUpgradeRename
+
+ + +
+ + + + + + + + $name) : ?> + + + + + + +
CategoryRequestsUpgradeRename
+
+ + - $name){ - echo "\n"; - echo "" . $name . "\n"; - echo "" . $tempCategoryRequests[$id] . "\n"; - echo "" . "
" . "\n"; - echo "" . "
" . "\n"; - echo "\n"; -} -?> - - - + -
+ --> + +
- - - diff --git a/css/filter.css b/css/filter.css new file mode 100644 index 0000000..e9efdb5 --- /dev/null +++ b/css/filter.css @@ -0,0 +1,118 @@ + +div.filter { + position: absolute; + top: 80px; left: -160px; + width: 130px; + margin: 0; + padding: 15px 15px 0 15px; + float: left; + background: #f3f3f3; + -moz-border-radius-topleft: 8px; + -moz-border-radius-bottomleft: 8px; + -webkit-border-top-left-radius: 8px; + -webkit-border-bottom-left-radius: 8px; + z-index: 0; +} + +div.filter { + position: relative; + top: 0; left: 0; + padding: 0; + width: 210px; +} + + div.filter h3 { + float: left; + position: relative; + top: -15px; left: -45px; + margin: 0 0 -5px 0; + padding: 10px 15px; + width: 160px; + height: 16px; + background: #e8e8e8; + -moz-border-radius-topleft: 8px; + -moz-border-radius-bottomleft: 8px; + -webkit-border-top-left-radius: 8px; + -webkit-border-bottom-left-radius: 8px; + } + + div.filter h3 { + display: none; + } + + div.filter h3 span.arrow { + position: absolute; + top: 0px; left: 0; + float: left; + margin: 0; + padding: 7px 0 13px 0; + width: 30px; + height: 16px; + font-size: 30px; + font-family: 'book antiqua','times new roman'; + line-height: 16px; + text-align: center; + color: #999; + background: #ddd; + cursor: pointer; + -moz-border-radius-topleft: 8px; + -moz-border-radius-bottomleft: 8px; + -webkit-border-top-left-radius: 8px; + -webkit-border-bottom-left-radius: 8px; + } + + div.filter h3 span.text { + position: absolute; + top: 1px; left: 45px; + line-height: 36px; + } + + div.filter span.cur { + float: left; + width: 100%; + margin: 0 0 15px 0; + font-size: 12px; + font-weight: bold; + color: #777; + } + + div.filter ul { + width: 100%; + float: left; + margin: 0 0 15px 0; + } + + div.filter ul li { + font-size: 14px; + line-height: 20px; + } + + div.filter ul li a.remove { + font-size: 12px; + font-weight: bold; + line-height: 20px; + } + + div.filter ul li div.indicator { + float: left; + margin: 5px 5px 5px 0; + width: 10px; + height: 10px; + background: #e6e6e6; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + } + + div.filter ul li.cur div.indicator { + font-size: 10px; + font-weight: bold; + line-height: 10px; + color: maroon; + text-align: center; + background: maroon; + } + + div.filter input[type=text] { + width: 180px; + margin: 0 0 5px 0; + } diff --git a/css/home.css b/css/home.css index 8460acd..5ad2b94 100755 --- a/css/home.css +++ b/css/home.css @@ -2,6 +2,7 @@ @import url('sidebar.css'); @import url('event_listing.css'); @import url('comments.css'); +@import url('filter.css'); body { font-family:helvetica,arial; @@ -47,6 +48,10 @@ h2.warning { color: firebrick; } +div { + position: relative; +} + div.wrap { margin: 0 auto; width: 960px; diff --git a/detailView.php b/detailView.php index 7a1cbda..727c029 100644 --- a/detailView.php +++ b/detailView.php @@ -108,12 +108,12 @@ - //Display 'like' feature from facebook -
- - - + +
+ +
+
- -

Comments

diff --git a/filter.php b/filter.php new file mode 100644 index 0000000..55c009d --- /dev/null +++ b/filter.php @@ -0,0 +1,129 @@ +
+

+ » + Filter Results +

+ + '; + echo '
  • Categories '.($admin ? '(manage)' : '').'
  • '; + $categories = get_category_list(); + + foreach ($categories as $row) { + $cat = $row[categoryName]; + if ($filter[categories] == $row[categoryName]) { + $temp_filter = remove_filter($raw_filter,'category'); + $url = filter_to_url($temp_filter); + + echo '
  • '; + echo $cat.' X
  • '; + } else { + $temp_filter = modify_filters($raw_filter,array('category'=>$cat)); + $url = filter_to_url($temp_filter); + + echo '
  • '; + echo ''.$cat.'
  • '; + } + } + echo ''; + + + // LOCATION FILTER LIST + echo ''; + + echo ''; + + /* echo ''; */ + ?> +
    + + diff --git a/functions/filter_functions.php b/functions/filter_functions.php new file mode 100644 index 0000000..29dc148 --- /dev/null +++ b/functions/filter_functions.php @@ -0,0 +1,111 @@ +'; print_r($arr); echo ''; + } + + + // FILTER MAIN FUNCTIONS + function get_current_filters () { + if (count($_GET) < 1) return array(); + + foreach($_GET as $field_name => $value) { + if (strlen($value) < 1) continue; + $filters[$field_name] = addslashes($value); + } + + unset($filters[w]); + /* unset($filters[t]); + unset($filters[submit]); + unset($filters[input]); */ + + return $filters; + } + + function translate_filter ($filter,$dir='db') { + /* Changes all $key values to proper database equivalents or vice + versa depending on the $dir parameter which specifies the direction + of the translation */ + + $url = array("category", "location", "start_date", "end_date"); + $db = array("categories", "locations", "startDate", "endDate"); + $return = array(); + + foreach ($filter as $key=>$val) { + if ($dir == 'db') $key = str_replace($url,$db,$key); + if ($dir == 'url') $key = str_replace($db,$url,$key); + $return[$key] = $val; + } + + return $return; + } + + function remove_filter ($filter,$remove) { + /* Given the filter key, unsets it from the array */ + unset($filter[$remove]); + return $filter; + } + + function modify_filters ($filter,$mods) { + /* $filter is an array of the current filters produced by the function + get_current_filters(), and $mods is an array of modifications to the filter + where $key=>$value are direct replacements or additions to the original + filter list $filter. */ + + $new_filter = array_merge($filter,$mods); + return $new_filter; + } + + function set_filters ($filter) { + foreach ($filter as $key=>$val) $_GET[$key] = $val; + return $_GET; + } + + function filter_to_url ($filter) { + /* Turns a filter into a usable URL, must provide url formatted $filter in + order to work properly. Use the translate_filter function. */ + + foreach ($filter as $key=>$param) $url[] = $key.'='.$param; + $url = implode('&',$url); + return '?'.$url; + } + + + // MISC FILTER FUNCTIONS + function create_w ($filter) { + /* Given a filter, creates an appropriate w variable (see results.php line ~100) + to describe the filters that are set. Must use URL translated filter in + order to work properly. Use the translate_filter function. */ + + if (isset($filter)) { } + + // probably not necessary... + } + + + // GENERAL DATABASE FUNCTIONS + function get_category_list ($perm = 1) { + /* Get list of categories from database, filter by permanent or not with + parameter $perm, where 1 is permanent and 0 is not. */ + + $query = 'SELECT * FROM categories WHERE permanent = '.$perm; + $result = mysql_query ($query); + while ($row = mysql_fetch_array($result)) $return[] = $row; + return $return; + } + + function get_location_list ($perm = 1) { + /* Same as get_category_list function except for loctions. */ + + $query = 'SELECT * FROM locations WHERE permanent = '.$perm; + $result = mysql_query ($query); + while ($row = mysql_fetch_array($result)) $return[] = $row; + return $return; + } +?> diff --git a/functions/functions.php b/functions/functions.php index 85b79f1..5e7832a 100644 --- a/functions/functions.php +++ b/functions/functions.php @@ -3,6 +3,7 @@ require_once 'user_session.php'; require_once 'query_events.php'; require_once 'display_events.php'; + require_once 'filter_functions.php'; function time_to_relative ($t) { $t = strtotime($t); diff --git a/header.php b/header.php index 7d074c9..09e03d5 100755 --- a/header.php +++ b/header.php @@ -34,6 +34,12 @@
    + + +
    diff --git a/index.php b/index.php index 314adc5..146935e 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,13 @@
    - Showing upcoming events + + + Sort by: Time Category @@ -44,3 +59,4 @@ + diff --git a/js/fancy_login.php b/js/fancy_login.php index 57662e3..9c495c7 100644 --- a/js/fancy_login.php +++ b/js/fancy_login.php @@ -92,6 +92,6 @@ }, function () { $(this).removeClass('hover'); }).click ( function () { - window.location = "user_accounts/change_password_form.php"; + window.location = "user_accounts/forgot_password.php"; }); }); diff --git a/js/main.php b/js/main.php index 8977ca7..4b42804 100644 --- a/js/main.php +++ b/js/main.php @@ -11,6 +11,14 @@ $('a.attend_event span.cancel').click ( function () { cancel_attend($(this)); }); + + $('div.filter h3 span.arrow').toggle ( function () { + $(this).parent().parent().animate({left:'0px'},250); + $(this).html("«"); + }, function () { + $(this).parent().parent().animate({left:'-160px'},250); + $(this).html("»"); + }); var attend_event = function (this_el) { if (this_el.hasClass('attending')) return false; diff --git a/results.php b/results.php index d2eae8b..691130a 100755 --- a/results.php +++ b/results.php @@ -20,12 +20,17 @@ $eventIDs = array(); } - $events = get_events($eventIDs,$sort,100); + $events = get_events($eventIDs,$sort,20); ?> - +
    +
    + +

    Event deleted successfully

    + +
    -
    + + + + ?>
    -
    +
    -->

    Tag Cloud

    diff --git a/user_accounts/forgot_password.php b/user_accounts/forgot_password.php index 29bff03..7123f8d 100755 --- a/user_accounts/forgot_password.php +++ b/user_accounts/forgot_password.php @@ -1,44 +1,38 @@ -
    -
    - -

    Reset Your Password

    - - - -

    Email address not recognized

    -
    -

    Your username: - - -

    - Enter your username below and a new password will be sent to your email. + You can change your password by going to "Settings" after you\'ve logged in.

    + +
    + + + +
    '; } -} else { -?> - - -

    Enter email address -

    -

    Your username: - - -

    - - - +
    +
    +

    Forgot Your Password?

    + A new password has been sent to your Grinnell e-mail address.'; + } else { + echo '

    Email address not recognized.

    '; + reset_form(); + } + else : + reset_form(); + endif; + ?>
    diff --git a/user_accounts/functions.php b/user_accounts/functions.php index d5fe0b6..3e47ad7 100755 --- a/user_accounts/functions.php +++ b/user_accounts/functions.php @@ -61,54 +61,40 @@ function randomPasswordGen($alpha=true) { function passwordReset ($email){ // create password and connect to database $new_password = randomPasswordGen(); - include '../functions/connection.php'; - $email = mysql_real_escape_string($email); + $email = mysql_real_escape_string($email); // Query for email in database - $query = "SELECT * FROM users WHERE email = '".$email."';"; - $result = mysql_query($query, $link); - - //if query was unsuccessful, print error and die - if (!$result) { - $message = "Error in query ($query): " . mysql_error(); - mysql_close($link); - die($message); - } - + $query = "SELECT * FROM users WHERE email = '$email'"; + $result = mysql_query($query); + // if email exists in database, change their password if ($result) { $np_md5 = md5($new_password); - $query2 = "UPDATE users - SET password = '$np_md5' - WHERE email = '$email';"; - $result2 = mysql_query($query2, $link); + $query = "UPDATE users SET password = '$np_md5' WHERE email = '$email';"; + $result = mysql_query($query); } - - + // If successful, send e-mail to user informing them of their new password - if ($result && (mysql_affected_rows($link))) { + if ($result) { // Message $message = ' -

    Your password for Grinnell Open Calender has been reset

    - Your new password is: '.$new_password.'



    +

    Here is your new password for Grinnell Open Calendar. Don\'t + forget to change it after you\'ve logged in.

    +

    New password: '.$new_password.'

    '; // Headers $header = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . - 'From: webmaster@grinnellopencalender.com' . "\r\n" . + 'From: Grinnell Open Calendar ' . "\r\n" . 'Reply-To: webmaster@grinnellopencalender.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); // Send Message - $sent = mail( $email, 'GOC Password Reset', $message, $header); - } else { - $sent = FALSE; + $sent = mail( $email, 'Grinnell Open Calendar Password Reset', $message, $header); + return true; } - - mysql_free_result($result); - mysql_close($link); - return $sent; + return false; } function changePassword($email, $old_pw, $new_pw, $new2_pw){ diff --git a/user_accounts/login_processing.php b/user_accounts/login_processing.php index 8a496ab..95e7460 100755 --- a/user_accounts/login_processing.php +++ b/user_accounts/login_processing.php @@ -17,7 +17,7 @@ if ($count == 1 && $row[confirmed] == null) { // Username and password match, continue login $_SESSION['sid'] = session_id(); - $_SESSION['email'] = $row['email']; + $_SESSION['email'] = $row['email']; $_SESSION['displayName'] = $row['displayName']; $_SESSION['userID'] = $row['userID']; $_SESSION['css'] = $row['css']; diff --git a/user_accounts/validate.php b/user_accounts/validate.php index 4a99691..2cdc345 100755 --- a/user_accounts/validate.php +++ b/user_accounts/validate.php @@ -7,27 +7,28 @@ $query = "SELECT * FROM users WHERE users.confirmed = $conf_num;"; $result = mysql_query($query); - if(!have_error($result, $query)) { + if($result) { $row = mysql_fetch_array($result,MYSQL_ASSOC); if($row[confirmed] == $conf_num) { + $query = "UPDATE users SET confirmed = null WHERE confirmed = $conf_num"; + $result = mysql_query($query); + $_POST['username'] = $row[displayName]; $_POST['password'] = $row[password]; - $_POST['static'] = true; - $login = require_once 'login_processing.php'; + $_POST['static'] = 'true'; + require_once 'login_processing.php'; require_once '../header.php'; echo "
    "; echo "
    "; - echo "

    Welcome $row[1]!

    "; + echo "

    Welcome $row[displayName]!

    "; echo '

    Your account has been successfully activated! Now you\'ll be able to add events for all to see, and view private Grinnell only events!

    '; echo '

    As always, remember that SELF GOV IS LOVE.

    '; - - $result = mysql_query("UPDATE users SET confirmed = null WHERE confirmed = $conf_num;"); } else { require_once '../header.php'; echo "
    ";