Location: PHPKode > scripts > TinyWebGallery > tinywebgallery/i_frames/i_popup.php
<?php
/*************************  
  Copyright (c) 2004-2010 TinyWebGallery
  written by Michael Dempfle
 
  This program is free software; you can redistribute it and/or modify 
  it under the terms of the TinyWebGallery license (based on the GNU  
  General Public License as published by the Free Software Foundation;  
  either version 2 of the License, or (at your option) any later version. 
  See license.txt for details.
 
  TWG version: 1.8
 
  $Date: 2009-06-17 22:57:10 +0200 (Mi, 17 Jun 2009) $
  $Revision: 73 $
**********************************************/

define('_VALID_TWG', '42');
include "i_basic.inc.php";
// the next wo are for a direct call of the random image!
if (isset($_GET['twg_random'])) {
    if (isset($_SESSION['twg_random' . $_GET['twg_random']])) {
        $image = replaceInput($_SESSION['twg_random' . $_GET['twg_random']]);
        $image_enc = urlencode($image);
    } else { // if external html page was open toooo long we jump to the first image
        $image = "x";
        $image_enc = "x";
    }
}

if (isset($_GET['twg_random'])) {
    if (isset($_SESSION['twg_random_album' . $_GET['twg_random']])) {
        $twg_album = replaceInput($_SESSION['twg_random_album' . $_GET['twg_random']]);
        $album_enc = urlencode($twg_album);
    } else { // if external html page was open toooo long we jump to the first image
        $twg_album = false;
        $album_enc = false;
    }
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?php echo $image;
?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../style.css" >
<script type="text/javascript">
var myWidth = 0, myHeight = 0;

function fitWindow(id)
{
  var OriginalWidth = 0, OriginalHeight = 0;
  bild = document.getElementById(id);
	if (OriginalWidth == 0 && OriginalHeight == 0)
	{
		 document.body.style.display = "block";
		 bild.style.display       = "block";
 		 OriginalWidth  = bild.width;
		 OriginalHeight = bild.height;
	}
	if (((screen.width-180)>bild.width) && ((screen.height-100)>bild.height)) {
	  window.resizeTo(900, 600);
	  getInnerWidth();
	  offsetx = 900 - myWidth;
	  offsety = 600 - myHeight;
	  window.resizeTo(bild.width + offsetx, bild.height + offsety);
	  document.title=document.title + "  " + OriginalWidth  + "x" + OriginalHeight + " (100%)";
	} else { // pic is larger than screen
	  factor = bild.width/bild.height;
	  factorscreen = screen.width/screen.height;

	  if (factor > factorscreen) {
	    // width of screen!
	    window.resizeTo(screen.width-100, (screen.width-100)/factor);
	    getInnerWidth();
	    yoff = ((myWidth / myHeight) - factor) * myHeight;
	    window.resizeBy(0 , yoff);
	  } else {
	    // height of screen!
	    window.resizeTo(((screen.height-60)*factor), (screen.height-60));
	    window.resizeBy(-35, 0);
	  }

	  getInnerWidth();
	  if (Math.abs(((myWidth / myHeight) - factor)*100) < 20) {
		  bild.width=myWidth;
		  bild.height=myHeight;
		  percent = Math.round((bild.width / OriginalWidth) * 100);
		  document.title=document.title + "  " + OriginalWidth  + "x" + OriginalHeight + " (" + percent + "%)";
		  pos = (screen.width-myWidth)/2;
	    window.moveTo(pos ,0);
	  } else { // Opera or settings that don't allow to resize the browser !
	    newFactor = myWidth / myHeight;
	    if (newFactor > factor) { // height is restricting
	      bild.width=myHeight*factor;
	      bild.height=myHeight;
	    } else {  // width is restricting !
	      bild.width=myWidth;
	      bild.height=myWidth/factor;
	    }
	  }
	}
}

function getInnerWidth() {
	if( typeof( window.innerHeight ) == 'number' ) {
		//Non-IE
		myWidth =  window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement &&
			( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
}
</script>
</head>
<body class="twg_body_popup" onload="javascript:fitWindow('popimage');"><?php
if (isset($_GET["direct"])) {
    $href = $_GET["direct"];
    $href = urldecode($href);
} else {
    $href = sprintf("../image.php?twg_album=%s&amp;twg_show=%s", $album_enc, $image_enc);
}

if ($click_on_popup_dl_image) {
    $click = "";
} else {
    $click = "onclick='self.close();') ";
}

echo "<div style='z-index:1191'>";
if (!isset($_GET["direct"])) {
  echo "<a href='" . $href . "'>";
}
echo "<img style='border:none' alt='' " . $click . " id='popimage' src='" . $href . "'>";
if (!isset($_GET["direct"])) {
  echo "</a>";
}
echo "</div>";

?></body>
</html>
Return current item: TinyWebGallery