. */ include("./include/include.php"); if( (!isset($_SESSION['sess_uid']) || !($_SESSION['sess_uid']>=1)) AND !(isset($_GET['login']) OR isset($_POST['login'])) ) { // User needs to log in first header("location: ".$_SERVER['PHP_SELF']."?login"); exit; } page_header(); if( isset($_GET['reset']) ) { // Reset session vars for this page debug("Resetted session vars"); $_SESSION['bookadd_start']=NULL; $_SESSION['bookadd_count']=NULL; $_SESSION['bookadd_event']=NULL; $_SESSION['bookadd_sort']=NULL; $_SESSION['bookadd_total']=NULL; $_SESSION['bookadd_limit']=NULL; } // Set initial value if( $_SESSION['bookadd_total']<1 ) $_SESSION['bookadd_total']=99999; // Get event if( strlen(get_var("event"))>0 ) $_SESSION['bookadd_event']=strtolower(get_var("event")); // Get the sort order if( strlen(get_var("sort"))>0 ) $_SESSION['bookadd_sort']=get_var("sort"); switch( $_SESSION['bookadd_sort'] ) { case "title": $mysql_order="ORDER BY `title`, `datestart`, `dateend`"; break; default: $_SESSION['bookadd_sort']="date"; $mysql_order="ORDER BY `datestart` DESC, `dateend` DESC, `title`"; } // See if we should show all events, or only where the user uploaded photos if( strlen(get_var("limit"))>0 ) { $_SESSION['bookadd_limit']=get_var("limit"); $_SESSION['bookadd_total']=99999; $_SESSION['bookadd_start']=0; } if( $_SESSION['bookadd_limit']!="all" AND $_SESSION['bookadd_limit']!="photo_only" ) $_SESSION['bookadd_limit']="photo_only"; // Get count if( get_int("count")>0 ) $_SESSION['bookadd_count']=get_int("count"); if( $_SESSION['bookadd_count']<1 ) $_SESSION['bookadd_count']=$MAXLIST; // Get start if( strlen(get_var("start"))>0 ) $_SESSION['bookadd_start']=get_int("start"); if( $_SESSION['bookadd_start']<=0 ) $_SESSION['bookadd_start']=0; // Limit $mysql_limit="LIMIT ".$_SESSION['bookadd_count']." OFFSET ".$_SESSION['bookadd_start']; $cmd=get_var("cmd"); if( $cmd!="new" AND $cmd!="edit" AND $cmd!="del" ) $cmd="new"; if( ($cmd=="new" OR $cmd=="edit") AND isset($_POST['id']) AND isset($_POST['title']) AND isset($_POST['comment']) ) { // Book added/updated if( strlen($_POST['title'])<=3 ) { // No title echoln("Please provide a title for the book.

"); $id=get_int('id'); $Title=get_var('title'); $Comment=get_var('comment'); }else { // Ok if( get_int("id")>0 ) { // Update $query="UPDATE `book` SET `title`='".addslashes(get_var('title'))."', `comment`='".addslashes(get_var('comment'))."' WHERE `id`=".addslashes($_POST['id'])." AND `uid`=".addslashes($_SESSION['sess_uid']); }else { $query="INSERT INTO `book` (`uid`, `eventcode`, `title`, `comment`) VALUES (".addslashes($_SESSION['sess_uid']).", '".addslashes($_SESSION['bookadd_event'])."', '".addslashes(get_var('title'))."', '".addslashes(get_var('comment'))."')"; } if( doquery($query) ) { echoln("Book saved successfully.

"); }else { echoln("Failed saving book.

"); } } } if( $cmd=="del" ) { // Delete a book, but only if it is empty. $query="SELECT `title`, `photocount` FROM `book` WHERE `id`=".addslashes(get_int("id"))." AND `uid`=".addslashes($_SESSION['sess_uid']); if( mysql_num_rows( $res=doquery($query) )==1 ) { $row=mysql_fetch_array($res); if( $row['photocount']>0 ) { // There are still photos in this book, cannot delete echoln("There are still photos in this book. Delete them first before deleting the book.

"); }else { // Delete book $query="DELETE FROM `book` WHERE `id`=".addslashes(get_int("id"))." AND `uid`=".addslashes($_SESSION['sess_uid']); if( doquery($query) ) { echoln("Book '".$row['title']."' deleted successfully.

"); }else { echoln("Failed deleting book.

"); } } }else { // Book not found, cannot delete echoln("Book not found, cannot be deleted.

"); } $cmd="new"; } if( $_SESSION['bookadd_limit']=="all" ) { echoln("All events sorted by ".$_SESSION['bookadd_sort'].". "); echoln("Show only events with your photos."); echoln("

In case you want to add photos for an event that is not shown in this list, please contact"); echoln("the webmaster."); }else { echoln("Events with your photos sorted by ".$_SESSION['bookadd_sort'].". "); echoln("Show all events from Calendar of Events."); } $query="SELECT `event`.`eventcode` AS `eventcode`, `event`.`datestart` AS `datestart`, `event`.`dateend` AS `dateend`, `event`.`title` AS `title`, `event`.`location` AS `location`, COUNT(`book`.`id`) AS `books`, MIN(`book`.`id`) AS `book`, SUM(`book`.`photocount`) AS `photocount`, `event`.`documentid` AS `documentid` FROM `event`, `book` WHERE `event`.`eventcode`=`book`.`eventcode` AND `event`.`datestart`<='".addslashes(date("Y-m-d"))."'"; if( $_SESSION['bookadd_limit']=="photo_only" ) $query.=" AND `book`.`uid`=".addslashes($_SESSION['sess_uid']); else $query.=" AND (`book`.`uid`=0 OR `book`.`uid`=".addslashes($_SESSION['sess_uid']).")"; $query.=" GROUP BY `eventcode` $mysql_order $mysql_limit"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { if( mysql_num_rows($res)<$_SESSION['bookadd_count'] ) { // We reached the end of the list $_SESSION['bookadd_total']=$_SESSION['bookadd_start']+mysql_num_rows($res); } // Previous-next button $butprevnext="

"; if( $_SESSION['bookadd_start']>0 ) { $butprevnext.=""; $butprevnext.="\"Previous"; } $butprevnext.=" "; if( $_SESSION['bookadd_total']>=($_SESSION['bookadd_start']+$_SESSION['bookadd_count']) ) { $butprevnext.=""; $butprevnext.="\"Next"; } echoln($butprevnext); echoln("

"); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); $i=0; while( $row=mysql_fetch_array($res) ) { $i++; if( ($i%2)==1 ) echoln(" "); else echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); if( $_SESSION['bookadd_limit']=="all" ) { echoln(" "); }else { echoln(" "); } echoln(" "); echoln(" "); echoln(" "); if( strtolower($row['eventcode'])==$_SESSION['bookadd_event'] ) { if( ($i%2)==1 ) echoln(" "); else echoln(" "); echoln(" "); echoln(" "); echoln(" "); } } echoln("
StartEndTitleLocationBooksPhotos 
".substr(get_date($row['datestart']), 0, 5)."".get_date($row['dateend'])."".$row['title']."".$row['location']."".($row['books']-1)."".($row['books'])."".$row['photocount'].""); if( strlen($el=get_eventlink($row['eventcode'], $row['documentid']))>0 ) echoln(" ".$el."info"); echoln("
  "); $query2="SELECT `id`, `photocount`, `title`, `comment` FROM `book` WHERE `eventcode`='".addslashes($_SESSION['bookadd_event'])."' AND `uid`=".addslashes($_SESSION['sess_uid'])." ORDER BY `title`"; if( @mysql_num_rows( $res2=doquery($query2) )>0 ) { echoln("

"); echoln(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); $j=0; while( $row2=mysql_fetch_array($res2) ) { $j++; if( ($j%2)==1 ) echoln(" "); else echoln(" "); if( $cmd=="edit" AND $row2['id']==get_int("id") AND !isset($id) ) { $id=$row2['id']; $Title=$row2['title']; $Comment=$row2['comment']; echoln(" "); }else { echoln(" "); } echoln(" "); echoln(" "); echoln(" "); } echoln("
TitlePhotos 
".$row2['title']."".$row2['title']."".$row2['photocount'].""); echoln(" edit"); if( $row2['photocount']==0 ) echoln("  delete"); echoln("  photos"); echoln("
"); }else { echoln("

No books found"); } echoln("

"); echoln(" "); echoln(" "); echoln(" "); if( $cmd=="edit" ) { if( ($i%2)==0 ) echoln(" "); else echoln(" "); echoln(" "); echoln(" "); } if( ($i%2)==0 ) echoln(" "); else echoln(" "); echoln(" "); echoln(" "); echoln(" "); if( ($i%2)==0 ) echoln(" "); else echoln(" "); echoln(" "); echoln(" "); echoln(" "); if( ($i%2)==0 ) echoln(" "); else echoln(" "); echoln(" "); echoln(" "); echoln("
Add new book
 
Title:
Comment:

"); echoln(" "); echoln("    "); echoln("
"); echoln("

 "); echoln("

"); echoln($butprevnext); }else { $butprevnext.="

"; $butprevnext.=""; echoln($butprevnext); echoln("

No events found

"); echoln($butprevnext); } page_footer(); ?>