diff -u -r -N karmapools.orig/docs/Changelog karmapools/docs/Changelog
--- karmapools.orig/docs/Changelog 2004-09-11 15:43:16.000000000 -0500
+++ karmapools/docs/Changelog 2004-09-11 19:40:18.442265592 -0500
@@ -30,7 +30,6 @@
includes/globals.php: added defaults for popup window attributes.
-
Date: 2004-09-11 15:25
Patch: patch-0.0.2-01
Author: Mike Green
@@ -38,3 +37,11 @@
Added Changelog, popup windows, source code link.
Changed rules links to be popup windows.
+Date: 2004-09-11 19:36
+Patch: patch-0.0.2-02
+Author: Mike Green
+
+Added jump around links in the calendar. Added display of logged in
+user's picks when logged in. Added login/logout urls. Added banner
+image code. Yanked calendar display code out of pool.php and stuck
+it in includes/html.functions.php to keep it clean.
\ No newline at end of file
Files karmapools.orig/images/banner.png and karmapools/images/banner.png differ
diff -u -r -N karmapools.orig/includes/globals.php karmapools/includes/globals.php
--- karmapools.orig/includes/globals.php 2004-09-11 15:14:18.000000000 -0500
+++ karmapools/includes/globals.php 2004-09-11 16:24:57.000000000 -0500
@@ -15,8 +15,10 @@
define(DBU,"webuser");
define(DBP,"webuser");
-// defaults
+// defaults - comment out banner and url if you don't want it.
define(DEFAULT_SITE_TITLE,"Badpenguins Karma Pools");
+define(DEFAULT_SITE_BANNER,"images/banner.png");
+define(DEFAULT_BANNER_URL,"http://badpenguins.com/");
define(WARN_POSSIBLE_CHEATERS,true);
define(MAX_YEARS_FORWARD,10);
define(MAX_USER_ENTRIES,10);
diff -u -r -N karmapools.orig/includes/html.functions.php karmapools/includes/html.functions.php
--- karmapools.orig/includes/html.functions.php 2004-09-11 15:14:18.000000000 -0500
+++ karmapools/includes/html.functions.php 2004-09-11 19:01:28.556462072 -0500
@@ -9,6 +9,147 @@
/*****************************************************************************
*
*****************************************************************************/
+function displayPoolCalendar($echo=true,$pool_ar='',$cols='7') {
+
+if (!is_array($pool_ar)) { return false; }
+
+$info_ar = $pool_ar['info'];
+$entries_ar = $pool_ar['entries'];
+$dates_ar = $pool_ar['dates'];
+
+if (!is_array($info_ar) or !is_array($entries_ar) or !is_array($dates_ar)) {
+ return false;
+ }
+
+$start_date = $info_ar['pool_start'] . " 01:00:00";
+$end_date = $info_ar['pool_end'] . " 01:00:00";
+$start_ts = strtotime($start_date);
+$end_ts = strtotime($end_date);
+$cur_date = date('Y-m-d 01:00:00');
+$cur_ts = strtotime($cur_date);
+$pool_id = $info_ar['pool_id'];
+$pool_desc = stripslashes($info_ar['pool_desc']);
+
+$first_day = date('l',$start_ts);
+$first_mon = date('F',$start_ts);
+$first_year = date('Y',$start_ts);
+$last_year = $first_year;
+$last_month = $first_mon;
+$day_header = array("Monday","Tuesday","Wednesday","Thursday","Friday",
+ "Saturday","Sunday");
+// fix the calendar so that Monday is the first day
+$pad_cells = 0;
+for($j=0; $j < count($day_header); $j++) {
+ if ("$day_header[$j]" == "$first_day") {
+ $pad_cells = $j;
+ break;
+ }
+ }
+// manually create the first month/year header and
+// align the days_header up with monday.
+$col_ctr = 0;
+$mon_ctr = 0;
+$next_mon = $mon_ctr + 1;
+$next_qs = "#month_" . $next_mon;
+$next_url = ">";
+$html .= "";
+$html .= "| ";
+$html .= "";
+$html .= "$first_mon $first_year $next_url |
\n";
+$html .= "\n";
+foreach($day_header as $day) {
+ $html .= " | $day | \n";
+ }
+$html .= "
\n";
+if ($pad_cells > 0) {
+ $td = " N/A | \n";
+ $html .= "\n";
+ $html .= str_repeat($td,$pad_cells);
+ $col_ctr = $pad_cells;
+ }
+for($j=$start_ts; $j <= $end_ts; $j += (60*60*24)) {
+ $col_ctr++;
+ $cur_year = date('Y',$j);
+ $cur_month = date('F',$j);
+ $day_str = date('jS',$j);
+
+ if ($cur_ts > $j) { $expired = true; } else { $expired = false; }
+
+ if ("$cur_month" !== "$last_month" and $col_ctr == 1) {
+ $last_month = $cur_month;
+ $mon_ctr++;
+ $prev_mon = $mon_ctr - 1;
+ $prev_qs = "#month_" . $prev_mon;
+ $prev_url = "<";
+ $next_mon = $mon_ctr + 1;
+ $next_qs = "#month_" . $next_mon;
+ $next_url = ">";
+ $html .= "
";
+ $html .= "| ";
+ $html .= "";
+ $html .= "$prev_url $cur_month $cur_year";
+ $html .= " $next_url |
\n";
+ $html .= "\n";
+ foreach($day_header as $day) {
+ $html .= " | ";
+ $html .= "$day | \n";
+ }
+ $html .= "
\n";
+ }
+ if ("$cur_month" !== "$last_month") {
+ $day_str = substr($cur_month,0,3) . " $day_str";
+ }
+ if ( $col_ctr == 1 ) {
+ $html .= "\n";
+ }
+ $comp_date = date('Y-m-d',$j);
+ $username = false;
+ if (in_array($comp_date,$dates_ar)) {
+ $select_url = $day_str;
+ $username = $entries_ar["$comp_date"]['user_name'];
+ $picked = true;
+ } else {
+ $select_url = "$day_str";
+ $picked = false;
+ }
+ if ($expired) {
+ $select_url = $day_str;
+ if ($picked) {
+ $td_class = "exptak";
+ } else {
+ $td_class = "expire";
+ }
+ }
+ if ($picked and !$expired) { $td_class = "taken"; }
+ if (!$picked and !$expired) { $td_class = "avail"; }
+
+ $html .= " ";
+ $html .= "$select_url";
+ if ($username) { $html .= " $username"; }
+ $html .= " | \n";
+ if ( $col_ctr == 7) {
+ $html .= "
\n";
+ $col_ctr = 0;
+ }
+ }
+if ($col_ctr > 0 and $col_ctr <= 7) {
+ $td = " ";
+ $td .= "N/A | \n";
+ $html .= str_repeat($td,(7 - $col_ctr));
+ $html .= "\n";
+ }
+
+if ($echo) { echo $html; } else { return $html; }
+
+}
+
+/*****************************************************************************
+ *
+ *****************************************************************************/
function displayPoolList($echo=true,$order='',$cols=6) {
if ($order == '') { $order = "pool_name"; }
@@ -106,6 +247,33 @@
/*****************************************************************************
*
*****************************************************************************/
+function displayMyPicksList($echo=true,$pool_ar='') {
+
+if (!is_array($pool_ar['entries'])) { return false; }
+
+global $POOLSESS;
+$uid = $POOLSESS['uid'];
+$html = false;
+$picks = array();
+foreach($pool_ar['entries'] as $entry) {
+ if ($entry['user_id'] == $uid) {
+ $picks[] = $entry['date_guess'];
+ }
+ }
+if (count($picks) > 0) {
+ $html = "Your picks: ";
+ foreach($picks as $pick) {
+ $html .= "$pick ";
+ }
+ $html .= "
";
+ }
+if ($echo) { echo $html; } else { return $html; }
+
+}
+
+/*****************************************************************************
+ *
+ *****************************************************************************/
function pageFooter($echo=true) {
$html = "
";
@@ -140,6 +308,16 @@
$html .= "
$body\n";
+if($loadbanner and defined('DEFAULT_SITE_BANNER')) {
+ $img = "
";
+ if (defined('DEFAULT_BANNER_URL')) {
+ $html .= "";
+ $html .= "$img
";
+ } else {
+ $html .= "$img
";
+ }
+ }
+
if ($echo) { echo $html; } else { return $html; }
}
diff -u -r -N karmapools.orig/index.php karmapools/index.php
--- karmapools.orig/index.php 2004-09-11 15:14:14.000000000 -0500
+++ karmapools/index.php 2004-09-11 19:28:40.681341376 -0500
@@ -37,13 +37,15 @@
break;
// login
case LOGIN_QS:
+ if ($_REQUEST['ruri']) {
+ $POOLSESS['lasturi'] = $HTTP_REFERER;
+ }
if (!$confirm) { die(include("./login.php")); }
if (isLoggedIn()) { die ("Can't login again idiot"); }
-
isset($POOLSESS['lasturi']) ? $uri = $POOLSESS['lasturi'] :
$uri = "./";
-
if (authenticateLogin($_POST)) {
+ $POOLSESS['lasturi'] = false;
die(header("Location: $uri"));
} else {
$login_url = "./?a=" . LOGIN_QS;
diff -u -r -N karmapools.orig/list.php karmapools/list.php
--- karmapools.orig/list.php 2004-09-11 15:14:11.000000000 -0500
+++ karmapools/list.php 2004-09-11 19:33:54.135689072 -0500
@@ -7,6 +7,13 @@
if (basename($PHP_SELF) == basename(__FILE__)) { die("Access Denied"); }
$cols = 6;
$title = DEFAULT_SITE_TITLE . "::List Pools";
+if (isLoggedIn()) {
+ $logout = "";
+ } else {
+ $logout = "";
+ }
pageHeader(true,$title); tableOpen(true,array('width'=>'100%'));
?>
@@ -33,8 +40,8 @@
displayPoolList(true,$o,$cols); ?>
tableClose(); pageFooter(); ?>
diff -u -r -N karmapools.orig/pool.php karmapools/pool.php
--- karmapools.orig/pool.php 2004-09-11 15:14:13.000000000 -0500
+++ karmapools/pool.php 2004-09-11 19:24:32.366091032 -0500
@@ -5,9 +5,8 @@
* Created 2004-09-09 Mike Green *
*****************************************************************************/
if (basename($PHP_SELF) == basename(__FILE__)) { die("Access Denied"); }
-$cols = 7;
-$title = DEFAULT_SITE_TITLE . "::View Pool";
-
+$cols = 7;
+$title = DEFAULT_SITE_TITLE . "::View Pool";
$pool_ar = queryPoolInfo($pid);
if (!is_array($pool_ar)) {
$subtitle = "Query Pool Failure";
@@ -15,38 +14,14 @@
$html .= "Try Again later.";
die(include("message.php"));
}
-
-$info_ar = $pool_ar['info'];
-$entries_ar = $pool_ar['entries'];
-$dates_ar = $pool_ar['dates'];
-$start_date = $info_ar['pool_start'] . " 01:00:00";
-$end_date = $info_ar['pool_end'] . " 01:00:00";
-$start_ts = strtotime($start_date);
-$end_ts = strtotime($end_date);
-$cur_date = date('Y-m-d 01:00:00');
-$cur_ts = strtotime($cur_date);
-$pool_desc = stripslashes($info_ar['pool_desc']);
-
-$first_day = date('l',$start_ts);
-$first_mon = date('F',$start_ts);
-$first_year = date('Y',$start_ts);
-$last_year = $first_year;
-$last_month = $first_mon;
-$day_header = array("Monday","Tuesday","Wednesday","Thursday","Friday",
- "Saturday","Sunday");
-// fix the calendar so that Monday is the first day
-$pad_cells = 0;
-for($j=0; $j < count($day_header); $j++) {
- if ("$day_header[$j]" == "$first_day") {
- $pad_cells = $j;
- break;
- }
- }
-$legend_url = "./?a=" . VIEW_LEGEND_QS;
-$legend_lnk = popupLink("$legend_url","legend");
-$rules_url = "./?a=" . VIEW_RULES_QS;
-$attribs = array('width'=>"600",'height'=>"550");
-$rules_lnk = popupLink("$rules_url","rules",$attribs);
+$pool_desc = stripslashes($pool_ar['info']['pool_desc']);
+$legend_url = "./?a=" . VIEW_LEGEND_QS;
+$legend_lnk = popupLink("$legend_url","legend");
+$rules_url = "./?a=" . VIEW_RULES_QS;
+$attribs = array('width'=>"600",'height'=>"550");
+$rules_lnk = popupLink("$rules_url","rules",$attribs);
+$login_href = "Log In";
pageHeader(true,$title); tableOpen(true,array('width'=>'100%'));
?>
@@ -68,94 +43,12 @@
Pool Description: echo $pool_desc; ?>
} ?>
+ if (isLoggedIn()) { displayMyPicksList(true,$pool_ar); } else { ?>
+ Your Picks: echo $login_href; ?> to see.
+ } ?>
-
-// manually create the first month/year header and
-// align the days_header up with monday.
-$col_ctr = 0;
-$html = "";
-$html .= "| ";
-$html .= "$first_mon $first_year |
\n";
-$html .= "\n";
-foreach($day_header as $day) {
- $html.= " | $day | \n";
- }
-$html .= "
\n";
-if ($pad_cells > 0) {
- $td = " N/A | \n";
- $html .= "\n";
- $html .= str_repeat($td,$pad_cells);
- $col_ctr = $pad_cells;
- }
-echo $html;
-
-for($j=$start_ts; $j <= $end_ts; $j += (60*60*24)) {
- $col_ctr++;
- $cur_year = date('Y',$j);
- $cur_month = date('F',$j);
- $day_str = date('jS',$j);
-
- if ($cur_ts > $j) { $expired = true; } else { $expired = false; }
-
- if ("$cur_month" !== "$last_month" and $col_ctr == 1) {
- $last_month = $cur_month;
- $html = "
";
- $html .= "| ";
- $html .= "$cur_month $cur_year |
\n";
- $html .= "\n";
- echo $html;
- foreach($day_header as $day) {
- echo " | $day | \n";
- }
- echo "
\n";
- }
- if ("$cur_month" !== "$last_month") {
- $day_str = substr($cur_month,0,3) . " $day_str";
- }
- if ( $col_ctr == 1 ) {
- echo "\n";
- }
- $comp_date = date('Y-m-d',$j);
- $username = false;
- if (in_array($comp_date,$dates_ar)) {
- $select_url = $day_str;
- $username = $entries_ar["$comp_date"]['user_name'];
- $picked = true;
- } else {
- $select_url = "$day_str";
- $picked = false;
- }
- if ($expired) {
- $select_url = $day_str;
- if ($picked) {
- $td_class = "exptak";
- } else {
- $td_class = "expire";
- }
- }
- if ($picked and !$expired) { $td_class = "taken"; }
- if (!$picked and !$expired) { $td_class = "avail"; }
-
- $html = " $select_url";
- if ($username) { $html .= " $username"; }
- $html .= " | \n";
- echo $html;
- if ( $col_ctr == 7) {
- echo "
\n";
- $col_ctr = 0;
- }
- }
-if ($col_ctr > 0 and $col_ctr <= 7) {
- $td = " N/A | \n";
- $html = str_repeat($td,(7 - $col_ctr));
- echo $html . "\n";
- }
-?>
+ displayPoolCalendar(true,$pool_ar); ?>
diff -u -r -N karmapools.orig/style.css karmapools/style.css
--- karmapools.orig/style.css 2004-09-11 15:14:12.000000000 -0500
+++ karmapools/style.css 2004-09-11 16:29:52.000000000 -0500
@@ -4,7 +4,8 @@
* Distributed under the terms of the GNU General Public License v2 *
* Created 2004-09-09 Mike Green *
*****************************************************************************/
-body { margin-top:20; background-color:#000000; color:#ffffff;
+body { margin-top:5; margin-left:5; margin-right:5;
+ background-color:#000000; color:#ffffff;
font-family:verdana,arial,lelvetica; font-weight:normal;
font-size:11.5px; }
a:link { color:#000000; text-decoration:none; }