<?php
// Penguin Gallery http://www.penguintutor.com/penguingallery 
// Copyright 2009 Stewart Watkiss
/*  
	This file is a part of Penguin Gallery

	Penguin Gallery 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.

    Penguin Gallery 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 Penguin Gallery.  If not, see <http://www.gnu.org/licenses/>.
*/


// Returns user friendly name of Gallery for use in page title etc.
// Any errors we return a generic name - any real error messages will be caught by gallery.php and displayed in the text rather than the title


// Display visible parts of gallerysetup as we only want to use setup to get the title
$silentsetup = true;

if (defined('__DIR__')) {
	$galleryphpdir = __DIR__;
    }
    else {
        $galleryphpdir = dirname(__FILE__);
    }
$galleryphpdir .= "/";

// what gallery are we viewing - config file must match galleryname with .cfg
$galleryname = trim($_GET[galleryname]);
if ($galleryname == "") {$galleryname = "index";}
if (!preg_match('/^[\w-\/]+$/', $galleryname)) {echo "Gallery (powered by <a href=\"http://www.penguintutor.com/penguingallery\">PenguinGallery</a>)"; return;} 


// **** temporary - for now if index selected then we embed galleryindex.php into the file
// In future we will generate the preview index page
if ($galleryname == "index")
{
	echo "Index to photo galleries";
	return;
}


$galleryconfigfile = $galleryname.".cfg";

// Check no . in the configfile other than .cfg (security check)
if (!preg_match ('/^[\w-\/]+\.cfg$/', $galleryconfigfile))
{
	echo "Gallery (powered by <a href=\"http://www.penguintutor.com/penguingallery\">PenguinGallery</a>)";
	return;
}


// Setup variables based on files in folder
include ($galleryphpdir."gallerysetup.php");
if ($gallerytitle == "") {echo "Gallery (powered by <a href=\"http://www.penguintutor.com/penguingallery\">PenguinGallery</a>)";}
echo $gallerytitle;

?>

