<?php
	/**
	 * Copyright 2005 Wim van Ravesteijn
	 *
	 * This file is part of AEGEE-Europe Photo Page.
	 *
	 * AEGEE-Europe Photo Page is free software: you can redistribute it
	 * and/or modify it under the terms of the GNU General Public License as
	 * published by the Free Software Foundation, either version 3 of the
	 * License, or (at your option) any later version.
	 *
	 * AEGEE-Europe Photo Page is distributed in the hope that it will be
	 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
	 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	 * GNU General Public License for more details.
	 *
	 * You should have received a copy of the GNU General Public License
	 * along with AEGEE-Europe Photo Page.  If not, see
	 * <http://www.gnu.org/licenses/>.
	 */
	include("./include/include.php");
	page_header();

	echoln("Welcome at the AEGEE Photo page. On this page you can find photos of a lot of AEGEE events. You can also upload your");
	echoln("own photos at this page. All you need is an AEGEE.org account. By using this page to publis your photos, everybody");
	echoln("can easily find them, also in the future, and you can be sure they will stay online.");

	$query="SELECT COUNT(`id`) AS `total` FROM `photo`";
	if( @mysql_num_rows( $res=doquery($query) )==1 ) {
		$row=mysql_fetch_array($res);
		$photocount=$row['total'];
		$query="SELECT COUNT(`id`) AS `total` FROM `book` WHERE `uid`>0 AND `photocount`>0";
		if( @mysql_num_rows( $res=doquery($query) )==1 ) {
			$row=mysql_fetch_array($res);
			$bookcount=$row['total'];
			$query="SELECT `event`.`eventcode` FROM `book`, `event`
							WHERE `book`.`eventcode`=`event`.`eventcode` AND `book`.`photocount`>0
							GROUP BY `event`.`eventcode`";
			if( @mysql_num_rows( $res=doquery($query) )>0 ) {
				//$row=mysql_fetch_array($res);
				$eventcount=mysql_num_rows($res);
				echoln("<p>There are currently ".number_format($photocount, 0, ",", ".")." photos online");
				echoln("  in ".number_format($bookcount, 0, ",", ".")." books.");
				echoln("  There are ".number_format($eventcount, 0, ",", ".")." events of which you can find photos on this page.");
			}
		}
	}

	$limit="LIMIT ".addslashes($MAXPHOTOTHUMBCOLS*2);
	$query="SELECT `id`, `book_id`, `nr`, `height_thumb` AS `height`, `width_thumb` AS `width`, `comment`, `date_add`
					FROM `photo` ORDER BY `date_add` DESC ".$limit;
	if( @mysql_num_rows( $res=doquery($query) )>0 ) {
		$thumbcellwidth="width=\"".(100/$MAXPHOTOTHUMBCOLS)."%\"";
		$i=0;
		while( $row=mysql_fetch_array($res) ) {
			if( $i==0 ) {
				echoln("<p>Newest photos (last one uploaded ".get_date($row['date_add'])."):");
				echoln("<p><table width=\"100%\">");
			}
			if( ($i%$MAXPHOTOTHUMBCOLS)==0 ) echoln("  <tr>");
			echoln("    <td height=\"125\" ".$thumbcellwidth." align=\"center\" valign=\"middle\">");
			if( strlen($row['comment'])>0 )
				echoln("      <a href=\"./photo.php?book=".$row['book_id']."&amp;photo=".$row['nr']."&amp;size=normal\" title=\"".$row['nr']." - ".$row['comment']."\"><img src=\"./image/photo.php?id=".$row['id']."&amp;size=thumb\" alt=\"".$row['nr']." - ".$row['comment']."\" border=\"0\" height=\"".$row['height']."\" width=\"".$row['width']."\"></a>");
			else
				echoln("      <a href=\"./photo.php?book=".$row['book_id']."&amp;photo=".$row['nr']."&amp;size=normal\" title=\"".$row['nr']."\"><img src=\"./image/photo.php?id=".$row['id']."&amp;size=thumb\" alt=\"".$row['nr']."\" border=\"0\" height=\"".$row['height']."\" width=\"".$row['width']."\"></a>");
			echoln("    </td>");
			if( ($i%$MAXPHOTOTHUMBCOLS)==($MAXPHOTOTHUMBCOLS-1) ) echoln("  </tr>");
			$i++;
		}
		while( ($i%$MAXPHOTOTHUMBCOLS)!=0 AND $_SESSION['photo_size']=="thumb" ) {
			echoln("    <td height=\"125\" ".$thumbcellwidth." align=\"center\" valign=\"middle\">");
			echoln("      &nbsp;");
			echoln("    </td>");
			if( ($i%$MAXPHOTOTHUMBCOLS)==($MAXPHOTOTHUMBCOLS-1) ) echoln("  </tr>");
			$i++;
		}
		echoln("</table>");
	}

	#echoln("<h3>How to upload your own photos</h3>");
	#echoln("To upload your photos of AEGEE events, you need an aegee.org account. This you can register yourself if you are");
	#echoln("member of AEGEE and have your membership card with CSN on it (this card is available at your local board in case");
	#echoln("you don't have one yet). Go to <a href=\"http://www.aegee.org/accounts/\" target=\"_blank\">www.aegee.org/accounts/</a> to register your account.");
	#echoln("<br>Go to \"Add photos\" and log in with your aegee.org account. This will show all events from the AEGEE-Europe");
	#echoln("Calendar of Events, with the most recent one at the top. Use the \"Next\" and \"Previous\" buttons to see older events.");
	#echoln("<br>When you find the events you want to add photos to, click on it. All the books you have created for this event will");
	#echoln("show up, as well as a box to add new books. Provide a title, and click on \"New book\". The book will now show above");
	#echoln("the box. You can edit and delete this book. Deleting is only possible when there are no photos in the book.");
	#echoln("Behind the books you just created, there is a link \"photos\". Click on it to add and edit photos of this book.");
	#echoln("<br>By clicking on the link \"Add new photos\" on the page for photos, you can add up to ".$MAXPHOTOSPERUPLOAD);
	#echoln("photos at once. This can be repeated as often as you like, but if you have a lot of photos, it might be an idea to");
	#echoln("split them into several books to have easier browsing of them (for example a book for every day, or parties separate).");
	#echoln("After adding the photos, you can change the order, as well as roting them to put them in the right direction. Adding");
	#echoln("comments later to the photos is possible as well.");

	page_footer();
?>