. */ include("./include/include.php"); page_header(); if( isset($_GET['reset']) ) { // Reset session vars for this page $_SESSION['event_start']=NULL; $_SESSION['event_count']=NULL; $_SESSION['event_event']=NULL; $_SESSION['event_sort']=NULL; } $_SESSION['book_select']=$_SERVER['PHP_SELF']; // Set initial value if( !isset($_SESSION['event_total']) || $_SESSION['event_total']<1 ) $_SESSION['event_total']=99999; // See if we should limit to one event only if( ( isset($_GET['event']) OR isset($_GET['body']) ) AND isset($_GET['limit']) ) $_SESSION['event_limit']=true; // See if we should limit to one body only if( strlen(get_var("body"))>0 ) $_SESSION['event_body']=strtolower(get_var("body")); // Get event if( strlen(get_var("event"))>0 ) $_SESSION['event_event']=strtolower(get_var("event")); if( strlen(get_var("sort"))>0 ) $_SESSION['event_start']=0; // Reset if people choose menu item if( strlen(get_var("event"))>0 AND !isset($_SESSION['event_sort']) ) { // Person enters the site for a specific event $query="SELECT `event`.`eventcode` AS `eventcode` FROM `event`, `book` WHERE `event`.`eventcode`=`book`.`eventcode` AND "; if( $_SESSION['event_limit'] AND !isset($_SESSION['event_body']) ) { $query.="`event`.`eventcode`='".addslashes($_SESSION['event_event'])."' "; }else { $query.="(`book`.`photocount`>0 OR `event`.`eventcode`='".addslashes($_SESSION['event_event'])."') "; } if( isset($_SESSION['event_body']) ) $query.="AND (`event`.`bodycode`='".addslashes($_SESSION['event_body'])."' OR `event`.`bodycode2`='".addslashes($_SESSION['event_body'])."') "; $query.="GROUP BY `eventcode` ORDER BY `event`.`datestart` DESC, `event`.`dateend` DESC, `event`.`title`"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { debug("number of events found: ".mysql_num_rows($res)); $_SESSION['event_start']=0; while( $row=mysql_fetch_array( $res ) ) { if( strtolower($row['eventcode'])==$_SESSION['event_event'] ) break; $_SESSION['event_start']++; } if( $_SESSION['event_start']>=mysql_num_rows($res) ) $_SESSION['event_start']=0; } debug("start=".$_SESSION['event_start']); } // Get the sort order if( strlen(get_var("sort"))>0 ) $_SESSION['event_sort']=get_var("sort"); if( !isset($_SESSION['event_sort']) ) { $_SESSION['event_sort'] = "date"; } switch( $_SESSION['event_sort'] ) { case "title": $mysql_order="ORDER BY `title`, `datestart`, `dateend`"; break; default: $_SESSION['event_sort']="date"; $mysql_order="ORDER BY `datestart` DESC, `dateend` DESC, `title`"; } // Get count if( get_int("count")>0 ) $_SESSION['event_count']=get_int("count"); if( !isset($_SESSION['event_count']) || $_SESSION['event_count']<1 ) $_SESSION['event_count']=$MAXLIST; // Get start if( strlen(get_var("start"))>0 ) $_SESSION['event_start']=get_int("start"); if( !isset($_SESSION['event_start']) || $_SESSION['event_start']<=0 ) $_SESSION['event_start']=0; // Limit $mysql_limit="LIMIT ".$_SESSION['event_count']." OFFSET ".$_SESSION['event_start']; echoln("All events with photos sorted by ".$_SESSION['event_sort']); $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 "; if( isset($_SESSION['event_limit']) && $_SESSION['event_limit'] AND !isset($_SESSION['event_body']) ) { $query.="`event`.`eventcode`='".addslashes(isset($_SESSION['event_event']) ? $_SESSION['event_event'] : "")."' "; }else { $query.="(`book`.`photocount`>0 OR (`event`.`eventcode`='".addslashes(isset($_SESSION['event_event']) ? $_SESSION['event_event'] : "")."' AND (`book`.`photocount`>0 OR `book`.`uid`=0))) "; } if( isset($_SESSION['event_body']) ) $query.="AND (`event`.`bodycode`='".addslashes($_SESSION['event_body'])."' OR `event`.`bodycode2`='".addslashes($_SESSION['event_body'])."') "; $query.="GROUP BY `eventcode` $mysql_order $mysql_limit"; if( @mysql_num_rows( $res=doquery($query) )>0 ) { if( mysql_num_rows($res)<$_SESSION['event_count'] ) { // We reached the end of the list $_SESSION['event_total']=$_SESSION['event_start']+mysql_num_rows($res); } // Previous-next button $butprevnext="

"; if( $_SESSION['event_start']>0 ) { $butprevnext.=""; $butprevnext.="\"Previous"; } $butprevnext.=" "; if( $_SESSION['event_total']>=($_SESSION['event_start']+$_SESSION['event_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(" "); if( $row['books']==1 AND $row['photocount']==0 ) { echoln(" "); $row['books']=0; } elseif( $row['books']==1 ) echoln(" "); else echoln(" "); echoln(" "); if( isset($_SESSION['event_event']) && strtolower($row['eventcode'])==$_SESSION['event_event'] ) { echoln(" "); }else { echoln(" "); } echoln(" "); echoln(" "); echoln(" "); if( isset($_SESSION['event_event']) && strtolower($row['eventcode'])==$_SESSION['event_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['title']."".$row['title']."".$row['location']."".max(0, $row['books']-1)."".$row['books']."".$row['photocount'].""); #echoln(" add photos  "); if( strlen($el=get_eventlink($row['eventcode'], $row['documentid']))>0 ) echoln(" ".$el."info"); echoln("
  "); $query2="SELECT `book`.`id` AS `book`, `book`.`photocount` AS `photocount`, `book`.`title` AS `title`, `user`.`name` AS `owner` FROM `book`, `user` WHERE `book`.`uid`=`user`.`uid` AND `book`.`eventcode`='".addslashes($_SESSION['event_event'])."' AND `book`.`photocount`>0 ORDER BY `title`, `name`"; 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(" "); echoln(" "); echoln(" "); echoln(" "); echoln(" "); } echoln("
TitleOwnerPhotos
".$row2['title']."".$row2['owner']."".$row2['photocount']."

 "); }else { echoln("

No photos found

 "); } echoln("

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

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

No events found

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