'compound'); ////////////////////////////////////// function doAuth() { header('WWW-Authenticate: Basic realm="Protected Area"'); header('HTTP/1.0 401 Unauthorized'); echo 'Valid username / password required.'; exit; } function checkUser() { global $vu; $b = false; if($_SERVER['PHP_AUTH_USER']!='' && $_SERVER['PHP_AUTH_PW']!='') { if($vu[$_SERVER['PHP_AUTH_USER']] == $_SERVER['PHP_AUTH_PW']) $b = true; } return $b; } if(!checkUser()) doAuth(); ////////////////////////////////////// // set these variables for your MySQL $dbhost = 'localhost'; // usually localhost $dbuser = 'root'; // database username $dbpass = 'scanspeak'; // database password ////////////////////////////////////// $f = ($_GET['f'] != '')? $_GET['f']:$_POST['f']; $sf = ($_GET['sf'] != '')? $_GET['sf']:$_POST['sf']; if($f == 'cal') { $output = ''; $month = $_GET['month']; $year = $_GET['year']; if($month == '' && $year == '') { $time = time(); $month = date('n',$time); $year = date('Y',$time); } $date = getdate(mktime(0,0,0,$month,1,$year)); $today = getdate(); $hours = $today['hours']; $mins = $today['minutes']; $secs = $today['seconds']; if(strlen($hours)<2) $hours="0".$hours; if(strlen($mins)<2) $mins="0".$mins; if(strlen($secs)<2) $secs="0".$secs; $days=date("t",mktime(0,0,0,$month,1,$year)); $start = $date['wday']+1; $name = $date['month']; $year2 = $date['year']; $offset = $days + $start - 1; if($month==12) { $next=1; $nexty=$year + 1; } else { $next=$month + 1; $nexty=$year; } if($month==1) { $prev=12; $prevy=$year - 1; } else { $prev=$month - 1; $prevy=$year; } if($offset <= 28) $weeks=28; elseif($offset > 35) $weeks = 42; else $weeks = 35; $output .= " "; $col=1; $cur=1; $next=0; for($i=1;$i<=$weeks;$i++) { if($next==3) $next=0; if($col==1) $output.=""; $output.="
$name $year2
Sun Mon Tue Wed Thu Fri Sat
"; if($i <= ($days+($start-1)) && $i >= $start) { $m = ($month<10)? "0".$month:$month; $d = ($cur<10)? "0".$cur:$cur; $output.=" AJAX PHP Calendar Admin Tool
New Event"; $time = $_POST['date']." ".$_POST['hour'].":".$_POST['min'].":00"; if($sf == 'save') { $query = "INSERT INTO `events` (`date`,`heading`,`body`) VALUES ('".$time."','".$_POST['heading']."','".$_POST['event']."')"; mysql_query($query); if(mysql_error() != '') $err .= mysql_errno().": ".mysql_error()."
"; if($err!='') { echo " Sorry, a database error occured.
".$err; } else { echo " The event was stored successfully"; } } else if($sf == 'list') { ?>
Date / Time:

:

Heading:
Event:
(HTML is OK)

 
Edit / Delete Event"; if($sf == 'list') { $query = "SELECT `num`,`heading`,DATE_FORMAT(`date`,'%m-%d-%Y') as `fdate` FROM `events` ORDER BY `date` DESC"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $evtlist .= ""; } ?>
Event:
Delete Event
Date / Time:

:

Heading:
Event:
(HTML is OK)

 
"; if($err!='') { echo " Sorry, a database error occured.
".$err; } else { $status = ($cur>0)? "currently active.":"not currently active."; echo " The event was updated successfully."; } } } else if($f == 'delete') { mysql_query("DELETE FROM `events` WHERE `num`=".$_GET['num']); if(mysql_error() != '') $err .= mysql_errno().": ".mysql_error()."
"; if($err!='') { echo " Sorry, a database error occured.
".$err; } else { echo " The event was deleted successfully."; } } ?>
close