OSDN Git Service

original file
[nucleus-jp/nucleus-plugins.git] / trunk / NP_TinyMCE2j / tinymce2j / plugins / ibrowser / scripts / phpThumb / demo / phpThumb.demo.showpic.php
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 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
35 <html>
36 <head>
37         <title><?php echo @$_GET['title']; ?></title>
38
39         <script language="Javascript">
40         <!--
41         // http://www.xs4all.nl/~ppk/js/winprop.html
42         function CrossBrowserResizeInnerWindowTo(newWidth, newHeight) {
43                 if (self.innerWidth) {
44                         frameWidth  = self.innerWidth;
45                         frameHeight = self.innerHeight;
46                 } else if (document.documentElement && document.documentElement.clientWidth) {
47                         frameWidth  = document.documentElement.clientWidth;
48                         frameHeight = document.documentElement.clientHeight;
49                 } else if (document.body) {
50                         frameWidth  = document.body.clientWidth;
51                         frameHeight = document.body.clientHeight;
52                 } else {
53                         return false;
54                 }
55                 if (document.layers) {
56                         newWidth  -= (parent.outerWidth - parent.innerWidth);
57                         newHeight -= (parent.outerHeight - parent.innerHeight);
58                 }
59                 // original code
60                 //parent.window.resizeTo(newWidth, newHeight);
61
62                 // fixed code: James Heinrich, 20 Feb 2004
63                 parent.window.resizeBy(newWidth - frameWidth, newHeight - frameHeight);
64
65                 return true;
66         }
67         // -->
68         </script>
69 </head>
70 <body style="margin: 0px;">
71 <?php
72
73 if (get_magic_quotes_gpc()) {
74         $_GET['src'] = stripslashes($_GET['src']);
75 }
76
77 if ($imgdata = @getimagesize($_GET['src'])) {
78
79         // this would be an excellent place to put some caching stuff to avoid re-scanning every picture every time
80
81         // check for maximum dimensions to allow no-scrollbar window
82         echo '<script language="Javascript">'."\n";
83         echo 'if (((screen.width * 1.1) > '.$imgdata[0].') || ((screen.height * 1.1) > '.$imgdata[1].')) {'."\n";
84         // screen is large enough to fit whole picture on screen with 10% margin
85         echo 'document.writeln(\'<img src="'.$_GET['src'].'" border="0">\');';
86         echo 'CrossBrowserResizeInnerWindowTo('.$imgdata[0].', '.$imgdata[1].');'."\n";
87         echo '} else {'."\n";
88         // image is too large for screen: add scrollbars by putting the image inside an IFRAME
89         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>\');';
90         echo '}'."\n";
91         echo '</script>';
92
93 } else {
94
95         // cannot determine correct window size, or correct size too large: add scrollbars by putting the image inside an IFRAME
96         echo '<iframe width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="on" src="'.$_GET['src'].'"></iframe>';
97
98 }
99
100 ?>
101 </body>
102 </html>