Location: PHPKode > projects > SiteX > photo.php
<?PHP
ob_start();
session_start();

include("includes/globals.php.inc");
include("includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");

protectComponentPage(2);

$photoid = intval($photoid);

// Protect private photo
if(sxPhotoUserAccess($photoid, $THIS_USER) == FALSE)
{
	header("Location: pictures.php");
	die();
}

$query = "SELECT * FROM $DB_Photos WHERE id='$photoid'";
$result = mysql_query($query, $Link) or queryError("11", mysql_error());
$sxPhoto = mysql_fetch_object($result);

$sxNewViews = $sxPhoto->views + 1;

$sxQuery2 = "UPDATE $DB_Photos SET views='$sxNewViews' WHERE id='$photoid'";
$sxResult2 = mysql_query($sxQuery2, $Link) or queryError("10", mysql_error());

$queryA = "SELECT * FROM $DB_Photos_Albums WHERE id='$albumid'";
$resultA = mysql_query($queryA, $Link) or queryError("12", mysql_error());
$ROWA = mysql_fetch_object($resultA);

if($sxSetup['GalleryUseKeywords'] == 1)
{
	$sxMetaAddendum = '';
	$first = true;
	$query2 = "SELECT * FROM $DB_Photos_Keywords WHERE photoid='$photoid' ORDER BY keyword";
	$result2 = mysql_query($query2, $Link) or queryError("11", mysql_error());
	while($ROW2 = mysql_fetch_object($result2))
	{
		if(!$first)
			$sxMetaAddendum .= ", ";
		$sxMetaAddendum .= $ROW2->keyword;
		$first = false;
	}
}

$sxTitleAddendum = getComponentName("2").' - '.$sxPhoto->name;
include("themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script> 
  <div class="bodyWrapper">
	<h1><?PHP echo getComponentName("2"); ?></h1>
	<?PHP
	if($albumid)
	{
		echo '<div style="text-align:right;font-size:10px;">';
		echo '<a href="album.php?albumid=' . $albumid . '&page=' . $page . '">' . $sxLang['PageButtonBackToAlbum'] . ' "' . $ROWA->name . '"</a>';
		echo '</div>';
	}
	?>
	<div style="padding-bottom:10px;"><br />
	<table width="<?PHP echo $sxThemeConfig['ContentWidth']-10; ?>" border="0" cellspacing="0" cellpadding="0" align="center">
	 <tr>
	  <td width="50%">
	  <?PHP
	  if(getPrevPhoto($photoid, $albumid))
		echo '<a name="photo_nav" href="' . $PHP_SELF . '?photoid=' . getPrevPhoto($photoid, $albumid) . '&albumid=' . $albumid . '&page=' . $page . '#photo_nav"><span class="sxSmallText">< ' . $sxLang['Previous'] . '</span></a>';
	  else
		echo '&nbsp;';
	  ?>
	  </td>
	  <td width="50%" align="right">
	  <?PHP
	  if(getNextPhoto($photoid, $albumid))
		echo '<a name="photo_nav" href="' . $PHP_SELF . '?photoid=' . getNextPhoto($photoid, $albumid) . '&albumid=' . $albumid . '&page=' . $page . '#photo_nav"><span class="sxSmallText">' . $sxLang['Next'] . ' ></span></a>';
	  else
		echo '&nbsp;';
	  ?>
	  </td>
	 </tr>
	</table>
	<?PHP
	
	if($sxSetup['AlbumShowPhotoName'] == 1) 
		echo '<span class="sxLargeText"><center>'. $sxPhoto->name .'</center></span><br />';
	else
		echo '<br />';

	echo '<center>';
	
	$sxEndLink = false;
  	list($w, $h) = getimagesize($sxContentDir['PhotoScaled'] . $sxPhoto->filename);
	
	// Link to fullsize image
	if($sxSetup['GalleryWatermarking'] != 2)
	{
		//echo '<div style="background:'. $sxThemeConfig['ScaledPhotoBGColor'] .' url(' . $sxContentDir['PhotoScaled'] . $sxPhoto->filename . ') no-repeat center center;" class="sxScaledPhoto">';
		echo '<table cellpadding="0" cellspacing="0" class="sxPhotoContainer"><tr><td valign="middle" class="sxScaledPhoto" >';
		// Add link to image that has a fullsize version
		if($sxPhoto->fullsize)
			echo '<a  href="' . $sxContentDir['PhotoFullsize'] . $sxPhoto->filename . '" rel="lightbox">';	
		// Blank placeholder image
		echo '<img id="photo" src="' . $sxContentDir['PhotoScaled'] . $sxPhoto->filename . '" alt="' . $sxPhoto->name . '" />';
		
		// Add link to image that has a fullsize version
		if($sxPhoto->fullsize)
			echo '</a>';
		
		echo '</td></tr></table>';
	}
		
	// Link to dynamic watermarked image
	elseif($sxSetup['GalleryWatermarking'] == 2)
	{
		$size_scaled = $sxSetup['GalleryMaxDimensionPhoto'] - 1;
		
		if(($sxPhoto->width > $size_scaled)OR($sxPhoto->height > $size_scaled))
		{
			$sxDimensions = resizeDimensions($sxPhoto->width, $sxPhoto->height, $size_scaled);
			$sxScaledWidth = $sxDimensions[0]+1;
			$sxScaledHeight = $sxDimensions[1]+1;
		}
		else
		{
			$sxScaledWidth = $sxPhoto->width;
			$sxScaledHeight = $sxPhoto->height;
		}
		echo '<table cellpadding="0" cellspacing="0" class="sxPhotoContainer"><tr><td valign="middle" class="sxScaledPhoto">';
		//echo '<div style="background:'. $sxThemeConfig['ScaledPhotoBGColor'] .' url(resampler.php?photoid=' . $sxPhoto->id . '&compression=90&width=' . $sxScaledWidth . '&height=' . $sxScaledHeight . ') no-repeat center center;" class="sxScaledPhoto">';

		// Add link to image that has a fullsize version		
		if($sxPhoto->fullsize)
			echo '<a href="resampler.php?photoid=' . $sxPhoto->id . '&full=1&compression=90&width=' . $sxPhoto->width . '&height=' . $sxPhoto->height . '" rel="lightbox">';
		
		// Blank placeholder image
		echo '<img class="sxScaledPhoto" src="resampler.php?photoid=' . $sxPhoto->id . '&compression=90&width=' . $sxScaledWidth . '&height=' . $sxScaledHeight . '" alt="' . $sxPhoto->name . '" />';
		
		// Add link to image that has a fullsize version
		if($sxPhoto->fullsize)
			echo '</a>';
		
		echo '</td></tr></table>';
	}
			
	echo '</center><br />';
	?>
	<?php 
  if ($sxThemeConfig['GalleryPhotoHideData'] == 1)
  echo '';
  else
  {
  ?>
	<span class="sxSmallText"><span class="shadowText"><center>[<?PHP echo $sxPhoto->width.' (' . $sxLang['Width'] . ') x ' . $sxPhoto->height . ' (' . $sxLang['Height'] . '), ' . number_format($sxPhoto->filesize) . ' ' . $sxByteUnits['KB'] . ', ' . number_format($sxNewViews) . ' ' . $sxLang['PhotoViews']; ?>]</center></span></span>
	<div style="padding-top:10px;"><br />
	<table width="<?PHP echo $sxThemeConfig['ContentWidth']-10; ?>" border="0" cellspacing="0" cellpadding="5" align="center">
	<?PHP
	if(($sxPhoto->fullsize)AND($sxSetup['GallerySelectSize'] == 1))
	{
		echo '<tr><td valign="top"><strong>' . $sxLang['PhotoViewHighRes'] . ': </strong><select name="menu1" onChange="MM_jumpMenu(\'parent\',this,0)">';
		echo '<option value="' . $PHP_SELF . '" selected>' . $sxLang['PhotoSelectDimensions'] . '</option>';
		echo '<option value="';
		
		// Change link for watermark
		if($sxSetup['GalleryWatermarking'] == 2)
			echo 'resampler.php?photoid=' . $sxPhoto->id. '&full=1&width=' . $sxPhoto->width . '&height=' . $sxPhoto->height . '&compression=90';
		else
			echo $sxContentDir['PhotoFullsize'] . $sxPhoto->filename;
			
		echo '">' . $sxLang['PhotoNativeSize'] . '</option>';
		
		for($i = 11; $i >= 9; $i--)
		{
			if(($sxPhoto->width > pow(2,$i))OR($sxPhoto->height > pow(2,$i)))
			{
				$dimensions = resizeDimensions($sxPhoto->width, $sxPhoto->height, pow(2,$i));
				echo ' <option value="resampler.php?photoid=' . $sxPhoto->id. '&full=1&width=' . $dimensions[0] . '&height=' . $dimensions[1] . '&compression=90">' . (int)$dimensions[0] . '(' . $sxLang['Width'] . ') x ' . (int)$dimensions[1] . '(' . $sxLang['Height'] . ')</option>';
			}
		}
		echo '</select><br /><br /></td>';
	}
	?><?PHP if($sxSetup['PhotoPurchase']){ echo '<td>'; ?>
	<form name="shutterfly" action="http://www.shutterfly.com/c4p/UpdateCart.jsp" method="post">
	  <input type="hidden" name="addim" 		value="1" />
	  <input type="hidden" name="protocol" 		value="SFP,100" />
	  <input type="hidden" name="pid" 			value="C4P" />
	  <input type="hidden" name="psid" 			value="AFFL" />
	  <input type="hidden" name="referid" 		value="0" />
	  <input type="hidden" name="returl" 		value="<?PHP echo "http://{$HTTP_HOST}{$REQUEST_URI}"; ?>" />
	  <input type="hidden" name="imraw-1" 		value="<?PHP echo $sxSetup['Url'].'/'; if(($sxPhoto->fullsize)AND($sxSetup['GalleryWatermarking'] != 2)) echo $sxContentDir['PhotoFullsize']; else echo $sxContentDir['PhotoScaled']; echo $sxPhoto->filename; ?>" />
	  <input type="hidden" name="imrawheight-1" value="<?PHP echo $sxPhoto->height; ?>" />
	  <input type="hidden" name="imrawwidth-1" 	value="<?PHP echo $sxPhoto->width; ?>" />
	  <input type="hidden" name="imthumb-1" 	value="<?PHP echo $sxSetup['Url'].'/'.$sxContentDir['PhotoThumb'].$sxPhoto->filename; ?>" />
	  <input type="hidden" name="imbkprntb-1" 	value="testing" />
	  <input type="submit" name="Submit" 		value="<?PHP echo $sxLang['PhotoOrderOnline']; ?>" class="sxButton" />
	</form><?PHP echo '</td></tr>'; } ?><tr>
	  <td valign="top" width="58%">
	    <?PHP if($sxSetup['AlbumShowPhotoCreated']){ ?><strong><?PHP echo $sxLang['GeneralItemDate']; ?>:</strong> <?PHP echo fetchDate($sxPhoto->timestamp, 3, 1); ?><br /><br /><?PHP } ?>
		<?PHP if($sxPhoto->photographer){ ?><strong><?PHP echo $sxLang['PhotoItemPhotographer']; ?>:</strong> <?PHP echo $sxPhoto->photographer; ?><br /><br /><?PHP } ?>
		<?PHP if($sxPhoto->description && $sxSetup['AlbumShowPhotoDescription']){ ?><strong><?PHP echo $sxLang['GeneralItemDescription']; ?>:</strong> <?PHP echo nl2br($sxPhoto->description); ?><br /><br /><?PHP } ?>&nbsp;</td>
	  <td valign="top">
	<?PHP
	if($sxSetup['CommentsEnabled'])
	{
		echo '<strong>' . $sxLang['CommentsItemComments'] . ':</strong><br />';
		echo '<a href="comments.php?previousPage=' . urlencode("http://{$HTTP_HOST}{$REQUEST_URI}") . '&sectionid=2&rowid=' . $sxPhoto->id . '">' . $sxLang['CommentsHeadingAdd'] . '</a><br />';
		if(objectNumComments($sxPhoto->id, 2))
		{
			echo '<a href="' . $PHP_SELF . '?photoid=' . $photoid . '&albumid=' . $albumid . '&page=' . $page . '&comments=' . $sxPhoto->id . '#comments">' . $sxLang['CommentsButtonView'] . ' (' . objectNumComments($sxPhoto->id, 2) . ')</a><br />';
		}
		echo '<br />';
	}
	
	echo '<strong>'.$sxLang['PhotoItemAlbums'].':</strong> <br />';

	$query2 = "SELECT * FROM $DB_Photos_Albums, $DB_Photos_Assoc WHERE $DB_Photos_Albums.id=$DB_Photos_Assoc.albumid AND $DB_Photos_Assoc.photoid='$photoid'";
	$result2 = mysql_query($query2, $Link) or queryError("11", mysql_error());
	while($ROW2 = mysql_fetch_object($result2))
	{
		echo '<a href="album.php?albumid=' . $ROW2->albumid . '">' . $ROW2->name . '</a><br />';
	}
	
	$first = true;
	$query2 = "SELECT * FROM $DB_Photos_Keywords WHERE photoid='$photoid' ORDER BY keyword";
	$result2 = mysql_query($query2, $Link) or queryError("11", mysql_error());
	if(mysql_num_rows($result2))
		echo '<br /><strong>'.$sxLang['PhotoItemKeywords'].':</strong><br/>';
	while($ROW2 = mysql_fetch_object($result2))
	{
		if(!$first)
			echo ", ";
		echo '<a href="search.php?type=photo_keyword&search=' . $ROW2->keyword . '">' . $ROW2->keyword . '</a>';
		$first = false;
	}
	?></td>
	 </tr>
	</table>
	<?PHP
	// View comments
	if(($comments == $sxPhoto->id)AND($sxSetup['CommentsEnabled']))
	{
		echo '<br /><br /><a name="comments"></a><div class="sxCommentsTable" style="width: '. $sxThemeConfig['ContentWidth'] .'-10px;">';
		echo '<div class="sxCommentsTableHeader"><strong>' . $sxLang['CommentsItemComments'] . '</strong></div><div style="padding-right:10px;padding-left:10px;padding-bottom:5px;">';
		
		$query2 = "SELECT * FROM $DB_Comments WHERE sectionid='2' AND rowid='$sxPhoto->id' ORDER BY timestamp DESC";
		$result2 = mysql_query($query2, $Link) or queryError("11", mysql_error());
		while($ROW2 = mysql_fetch_object($result2))
		{
			if($ROW2->email)
				echo '<a href="mailto:' . $ROW2->email . '">';
			echo '<strong>' . $ROW2->name . '</strong>';
			if($ROW2->email)
				echo '</a>';
			echo '<br /><strong>';
			echo fetchDate($ROW2->timestamp, 1, 1);
			echo '</strong><br />';
			echo nl2br($ROW2->comments);
			echo '<br /><br />';
		}
		
		if((userAdmin())OR((userEditor())AND($sxSetup['EditorRightsCommentsManager'])))
			echo '<p align="right"><a href="admin/comments_manager.php">' . $sxLang['CommentsManageHeading'] . '</a></p>';
		echo '</div></div>';
	}
	if((userAdmin())OR((userEditor())AND($sxSetup['EditorRightsPhotoEdit'])))
		echo '<br /><a href="admin/photo_edit.php?editid=' . $sxPhoto->id . '&sxPrevURL='.urlencode("http://{$HTTP_HOST}{$REQUEST_URI}").'">' . $sxLang['PhotoButtonEdit'] . '</a>';
}		
	?>

	</div>
	</div>
  </div>
<?PHP
include("themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX