session_start();
include('connection.php');
//pre-load header and title info
if (!isset($_GET['id']))
{
//no id set, go to index
header( 'Location: http://www.saberz.com/' ) ;
exit;
}
else
{
$id=mysql_real_escape_string($_GET['id']);
}
if (!file_exists('articles/'.$id.'/'.$id.'.xml'))
{
//no id set, go to index
header( 'Location: http://www.saberz.com/' ) ;
exit;
}
else
{
// xml exists, so load it.
$url = 'articles/'.$id.'/'.$id.'.xml';
// get xml file contents
$xml = simplexml_load_file($url);
$title = $xml->album["title"];
$xml_desc = $xml->album['desc'];
// set comment ID
$comment_id = $id;
//increase hit counter
mysql_query("UPDATE saberz_pages SET hits=hits+1 WHERE id='$id' ");
}
// get article info
$query="SELECT * FROM saberz_pages WHERE id='$id'";
$result=mysql_query($query);
$sql_date=mysql_result($result,0,"date");
$date=date("M j, Y", strtotime($sql_date));
$live=mysql_result($result,0,"live");
$title=mysql_result($result,0,"title");
$redirect=mysql_result($result,0,"redirect");
$author=mysql_result($result,0,"author");
$announcement=mysql_result($result,0,"announcement");
$photographer=mysql_result($result,0,"photographer");
$preview=mysql_result($result,0,"preview");
$nohits=mysql_result($result,0,"nohits");
$title_img=mysql_result($result,0,"title_img");
$img960=mysql_result($result,0,"img960");
$gallery=mysql_result($result,0,"gallery");
$galonly=mysql_result($result,0,"galonly");
$feature=mysql_result($result,0,"feature");
$comment_fb=mysql_result($result,0,"comment_fb");
$comment_dq=mysql_result($result,0,"comment_dq");
$desc=mysql_result($result,0,"desc");
$type=mysql_result($result,0,"type");
$tags=mysql_result($result,0,"tags");
$specs=mysql_result($result,0,"specs");
$hits=mysql_result($result,0,"hits");
if (!$live && !$preview && !$admin)
// article isn't live, preview bit is off, and user isn't admin; return to index
{
header( 'Location: http://www.saberz.com/' ) ;
exit;
}
if ($redirect && trim($redirect)!='' && !$admin) {
//article is a simple redirect
header( 'Location: '.$redirect ) ;
exit;
}
if (!mysql_result($result,0,"galonly"))
{
$related = true;
$article_title=mysql_result($result,0,"title");
$xml_desc = $xml->album['desc'];
}
else
{
$related = false;
}
if ($_REQUEST['num'] && $_REQUEST['num']!='' && file_exists('articles/'.$id.'/500/'.$id.'_'.mysql_real_escape_string($_REQUEST['num']).'.jpg')){
$fbthumb = mysql_real_escape_string($_REQUEST['num']);
$fburl = 'http://www.saberz.com/galleries.php?id='.$id.'&num='.$fbthumb;
}
else {
$fbthumb = $title_img;
$fburl = 'http://www.saberz.com/'.$id;
}
include('header_1.php');
?>
Saberz.com echo $titleconnector; ?> Gallery: echo $title; ?>
include('header_2.php');
include('navigation.php');
$showsidebar = false;
$gallerypage = true;
//Prepare album data
foreach($xml->album as $album)
{
$albumtitle = $album['title'];
}
//initialize $num
$num = mysql_real_escape_string($_GET['num']);
if (!isset($_GET['num']) || $_GET['num']='' || !file_exists('articles/'.$id.'/650/'.$id.'_'.$num.'.jpg')){
//no img number set, or file doesn't exist
//choose first image
$defaultIMG = 0;
$num = $xml->album[0]->img[$defaultIMG]["src"];
while (strtolower($num) == 'hr') {
//selected image is HR, choose next image
$defaultIMG = $defaultIMG + 1;
$num = $xml->album[0]->img[$defaultIMG]["src"];
}
}
$imgpath='';
if (file_exists('articles/'.$id.'/1500/'.$id.'_'.$num.'.jpg')){
$imgpath = 'articles/'.$id.'/1500/'.$id.'_'.$num.'.jpg';
$widepage = true;
$grid = 6;
$altbottom = true;
}
else if (file_exists('articles/'.$id.'/960/'.$id.'_'.$num.'.jpg')){
$imgpath = 'articles/'.$id.'/960/'.$id.'_'.$num.'.jpg';
$widepage = true;
$grid = 6;
$altbottom = true;
}
else {
$imgpath = 'articles/'.$id.'/650/'.$id.'_'.$num.'.jpg';
$widepage = false;
}
// set previous and next image numbers
$i = 0;
foreach($xml->album as $album)
{
foreach($album->img as $img)
{
if (strtolower($img['src'])=='hr') {
if ($img['hrdesc']) {
$hrtitle = $img['caption'];
$hrcaption = $img['hrdesc'];
}
else {
$hrtitle = '';
$hrcaption = '';
}
}
if ($img["src"]==$num)
{
$current = $album->img[$i];
$prevINC = 1;
$prev = $album->img[$i-$prevINC];
while (strtolower($prev['src']) == 'hr') {
//previous image is HR, choose the one before that
if ($i - $prevINC == 0) {
//image is first in the gallery
$prev = $current;
}
else {
$prevINC = $prevINC + 1;
$prev = $album->img[$i-$prevINC];
}
}
$nextINC = 1;
$next = $album->img[$i+$nextINC];
while (strtolower($next['src']) == 'hr') {
//next image is HR, choose the one after that
$nextINC = $nextINC + 1;
$next = $album->img[$i+$nextINC];
}
break;
}
$i = $i + 1;
}
}
//Set up gallery content div
include('mainpagestructure.php');
$widepage = true;
?>
titlebar();
//beginning of content
?>
// display navigation
?>
if (($hrtitle && trim($hrtitle)!='') || ($hrcaption && trim($hrcaption)!='') || ($current["caption"] && trim($current["caption"])!='')) { ?>
echo $current["caption"]; ?>
if ((!$hrcaption || trim($hrcaption)=='') && $hrtitle && trim($hrtitle)!='') { echo '
'.$hrtitle.' » '; }
if (trim($current["caption"])!='' && trim($hrcaption)!='') { echo '
'; }
if ($hrcaption && trim($hrcaption)!='') { echo '
'.$hrtitle.' » '.$hrcaption.''; }
?>
;
} ?>
//display grid
?>
if (($xml_desc && $xml_desc!='') || trim($announcement) != '') {
?>
if ($announcement && articleAnnounce($announcement)) {
?>
echo articleAnnounce($announcement); ?>
}
?>
echo $xml_desc; ?>
}
?>
if ($related)
//gallery is from an article, link to it
{
?>
}
?>
if ($redirect && trim($redirect!='') && $admin) {
echo 'Redirect:
'.$redirect.'';
}
else {
?>
postgrid($grid);
echo '
';
if (trim($tags[0])!= '') {
//there are tags, post related articles
index($id, $tags);
}
echo '
';
comments();
}
//end of gallery content
?>
include('foot_end.php');
?>