root/devel-backup/units/phpthumb/phpThumb.demo.showpic.php

Revision 45, 4.4 kB (checked in by sven, 3 years ago)

dos2unix to clean line endings, set svn property eol-style native, some whitespace homogenisation

  • Property svn:eol-style set to native
Line 
1 <?php
2 //////////////////////////////////////////////////////////////
3 ///  phpThumb() by James Heinrich <info@silisoftware.com>   //
4 //        available at http://phpthumb.sourceforge.net     ///
5 //////////////////////////////////////////////////////////////
6 ///                                                         //
7 // See: phpthumb.readme.txt for usage instructions          //
8 //                                                         ///
9 //////////////////////////////////////////////////////////////
10 //                                                          //
11 // phpThumb.demo.showpic.php                                //
12 // James Heinrich <info@silisoftware.com>                   //
13 // 23 Feb 2004                                              //
14 //                                                          //
15 // This code is useful for popup pictures (e.g. thumbnails  //
16 // you want to show larger, such as a larger version of a   //
17 // product photo for example) but you don't know the image  //
18 // dimensions before popping up. This script displays the   //
19 // image with no window border, and resizes the window to   //
20 // the size it needs to be (usually better to spawn it      //
21 // large (600x400 for example) and let it auto-resize it    //
22 // smaller), and if the image is larger than 90% of the     //
23 // current screen area the window respawns itself with      //
24 // scrollbars.                                              //
25 //                                                          //
26 // Usage:                                                   //
27 // window.open('showpic.php?src=big.jpg&title=Big+picture', //
28 //   'popupwindowname',                                     //
29 //   'width=600,height=400,menubar=no,toolbar=no')          //
30 //                                                          //
31 // See demo linked from http://phpthumb.sourceforge.net    ///
32 //////////////////////////////////////////////////////////////
33 ?>
34
35 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
36 <html>
37 <head>
38     <title><?php echo @$_GET['title']; ?></title>
39
40     <script language="Javascript">
41     <!--
42     // http://www.xs4all.nl/~ppk/js/winprop.html
43     function CrossBrowserResizeInnerWindowTo(newWidth, newHeight) {
44         if (self.innerWidth) {
45             frameWidth  = self.innerWidth;
46             frameHeight = self.innerHeight;
47         } else if (document.documentElement && document.documentElement.clientWidth) {
48             frameWidth  = document.documentElement.clientWidth;
49             frameHeight = document.documentElement.clientHeight;
50         } else if (document.body) {
51             frameWidth  = document.body.clientWidth;
52             frameHeight = document.body.clientHeight;
53         } else {
54             return false;
55         }
56         if (document.layers) {
57             newWidth  -= (parent.outerWidth - parent.innerWidth);
58             newHeight -= (parent.outerHeight - parent.innerHeight);
59         }
60         // original code
61         //parent.window.resizeTo(newWidth, newHeight);
62
63         // fixed code: James Heinrich, 20 Feb 2004
64         parent.window.resizeBy(newWidth - frameWidth, newHeight - frameHeight);
65
66         return true;
67     }
68     // -->
69     </script>
70 </head>
71 <body style="margin: 0px;">
72 <?php
73
74 if (get_magic_quotes_gpc()) {
75     $_GET['src'] = stripslashes($_GET['src']);
76 }
77
78 if ($imgdata = @getimagesize($_GET['src'])) {
79
80     // this would be an excellent place to put some caching stuff to avoid re-scanning every picture every time
81
82     // check for maximum dimensions to allow no-scrollbar window
83     echo '<script language="Javascript">'."\n";
84     echo 'if (((screen.width * 1.1) > '.$imgdata[0].') || ((screen.height * 1.1) > '.$imgdata[1].')) {'."\n";
85     // screen is large enough to fit whole picture on screen with 10% margin
86     echo 'document.writeln(\'<img src="'.$_GET['src'].'" border="0">\');';
87     echo 'CrossBrowserResizeInnerWindowTo('.$imgdata[0].', '.$imgdata[1].');'."\n";
88     echo '} else {'."\n";
89     // image is too large for screen: add scrollbars by putting the image inside an IFRAME
90     echo 'document.writeln(\'<iframe width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="on" src="'.$_GET['src'].'">Your browser does not support the IFRAME tag. Please use one that does (IE, Firefox, etc).<br><img src="'.$_GET['src'].'"></iframe>\');';
91     echo '}'."\n";
92     echo '</script>';
93
94 } else {
95
96     // cannot determine correct window size, or correct size too large: add scrollbars by putting the image inside an IFRAME
97     echo '<iframe width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="on" src="'.$_GET['src'].'"></iframe>';
98
99 }
100
101 ?>
102 </body>
103 </html>
Note: See TracBrowser for help on using the browser.