diff --git a/cal.php b/cal.php
index c321813c3..5add222c2 100644
--- a/cal.php
+++ b/cal.php
@@ -63,7 +63,7 @@ CREATE TABLE phpcal (
* -2 = second-last
*/
function weekday($year, $month, $day, $which) {
- $ts = mktime(12,0,0,$month+(($which>0)?0:1),($which>0)?1:0,$year);
+ $ts = mktime(12,0,0,$month+(($which>0)?0:1),($which>0)?1:0,$year);
$done = false;
$match = 0;
$inc = 3600*24;
@@ -80,22 +80,22 @@ CREATE TABLE phpcal (
function load_unapproved_events() {
global $re;
$days = days();
- $result = mysql_query("select * from phpcal where approved=0 order by sdato");
+ $result = mysql_query("select phpcal.*, country.name as name from phpcal, country where phpcal.country=country.id and approved=0 order by sdato");
if(!$result) echo mysql_error();
else {
while($row = mysql_fetch_array($result)) {
switch($row['tipo']) {
case 1:
- $events[] = array($row['id'],$row['sdato'],$row['sdesc'],$row['ldesc'],$row['url']);
+ $events[] = array($row['id'],$row['sdato'],$row['sdesc'],$row['ldesc'],$row['url'], $row['name'], $row['category']);
break;
case 2:
- $events[] = array($row['id'],$row['sdato'].' to '.$row['edato'],$row['sdesc'],$row['ldesc'],$row['url']);
+ $events[] = array($row['id'],$row['sdato'].' to '.$row['edato'],$row['sdesc'],$row['ldesc'],$row['url'], $row['name'], $row['category']);
break;
case 3:
list($which,$day) = explode(':',$row['recur']);
- $events[] = array($row['id'],'Every '.$re[(int)$which].' '.$days[$day],$row['sdesc'],$row['ldesc'],$row['url']);
+ $events[] = array($row['id'],'Every '.$re[(int)$which].' '.$days[$day],$row['sdesc'],$row['ldesc'],$row['url'], $row['name'], $row['category']);
break;
- }
+ }
}
}
return $events;
@@ -192,7 +192,7 @@ CREATE TABLE phpcal (
?>
-
+
@@ -210,10 +210,10 @@ CREATE TABLE phpcal (
if($j==0) echo '| '.$days[$i]." | \n";
else {
if($j==1 && ($i-1)==$start) $day = 1;
- if($day && $day<=$last) {
- $label=$day;
- $col = '#f0f0f0';
- $bcol=$col;
+ if($day && $day<=$last) {
+ $label=$day;
+ $col = '#f0f0f0';
+ $bcol=$col;
$data = ' ';
if(is_array($events[$day])) {
$data = '';
@@ -229,18 +229,18 @@ CREATE TABLE phpcal (
}
if($day) $day++;
}
- echo "\n";
+ echo "\n";
}
?>
- |
> add event';
+ |
|---|
> add event';
else echo "$err";
echo " |
\n";
if($a) draw_add();?>
-> approve events' . " ($c event(s) pending)";
+ |
|---|
> approve events' . " ($c event(s) pending)";
else echo "$aerr";
if($ap) draw_app();
echo " |
|---|
\n";
@@ -248,15 +248,43 @@ echo "\n";
function draw_event($ev) {
global $re;
-
- $result = mysql_query("select * from phpcal where id=$ev");
+ $stmt = "select phpcal.*,country.name as cname from phpcal,country where phpcal.country = country.id and phpcal.id=$ev";
+ $result = mysql_query($stmt);
if(!$result) echo mysql_error();
else $event = mysql_fetch_array($result);
$days=days();
+ $cat = $event['category'];
+ switch($cat) {
+ case 1:
+ $category = "regional";
+ break;
+ case 2:
+ $category = "national";
+ break;
+ case 3:
+ $category = "international";
+ break;
+ default:
+ $category = "unknown";
+ }
?>
- | URL: ".$event['url']."\n";?> |
+ |
+
+Country: ". $event['cname'] : "" ;
+
+echo ((!isset($category)) || ($category != "unknown")) ? " Event Type: ". $category : "" ;
+
+if(strlen($event['url'])) {
+ echo " URL: ".$event['url']."\n";
+}
+?>
+ |
|
|
-| App. by: |
+| Approved by: |
|
|
-$v) {
$ldesc = nl2br($ldesc);
if(empty($sdesc)) {
$err = "You must provide a short description for your event - please correct this
\n";
- $a=1;
+ $a = 1;
+ } else
+ if (!$country) {
+ $err = "You must specify a country - please correct this
\n";
+ $a = 1;
+ } else
+ if (!$category){
+ $err = "You must specifiy the event category - please correct this
\n";
+ $a = 1;
} else
switch($type) {
case 'single':
@@ -393,7 +449,9 @@ foreach($re as $k=>$v) {
$err = "Invalid start date - please correct it
\n";
$a=1;
} else {
- mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by) values (0,'$syear-$smonth-$sday',NULL,NULL,'$sdesc','$url','$ldesc',1,0,NULL)") or $err=mysql_error();
+
+ mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by,country,category) values (0,'$syear-$smonth-$sday',NULL,NULL,'$sdesc','$url','$ldesc',1,0,NULL,'$country','$category')") or $err=mysql_error();
+
}
break;
case 'multi':
@@ -408,14 +466,18 @@ foreach($re as $k=>$v) {
} elseif($smonth==$emonth && $sday==$eday && $syear==$eyear) {
$err = "Your start and end dates are identical - please correct this
\n"; $a=1;
} else {
- mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by) values (0,'$syear-$smonth-$sday','$eyear-$emonth-$eday',NULL,'$sdesc','$url','$ldesc',2,0,NULL)") or $err=mysql_error();
+
+ mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by,country,category) values (0,'$syear-$smonth-$sday','$eyear-$emonth-$eday',NULL,'$sdesc','$url','$ldesc',2,0,NULL,'$country','$category')") or $err=mysql_error();
+
}
break;
case 'recur':
if(!is_numeric($recur) || !is_numeric($recur_day)) {
$err = "Recurring event sequence is invalid - please correct it
\n"; $a=1;
} else {
- mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by) values (0,NULL,NULL,'$recur:$recur_day','$sdesc','$url','$ldesc',3,0,NULL)") or $err=mysql_error();
+
+ mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by,country,category) values (0,NULL,NULL,'$recur:$recur_day','$sdesc','$url','$ldesc',3,0,NULL,'$country','$category')") or $err=mysql_error();
+
}
break;
}
@@ -435,7 +497,7 @@ foreach($re as $k=>$v) {
if(!$result) echo mysql_error();
}
}
-
+
} else {
echo "The username or password you supplied was incorrect.
\n";
$ap = 1;
@@ -469,7 +531,7 @@ foreach($re as $k=>$v) {
if($data) $data.="\n";
$data .= "$i,$cm,$cy,\"http://php.net/cal.php?cm=$cm&cy=$cy&ev=".$row['id']."\",\"".addslashes($row['sdesc']).'"';
}
- }
+ }
$nm--;
$cd = 1;
if($nm) {
@@ -479,5 +541,17 @@ foreach($re as $k=>$v) {
}
echo $data;
break;
- }
+ }
?>
+
+
+
+
+
+
+
+
+
+
+
+