3 require_once('lib/stdlib.php');
6 if (preg_match('/^(http|ftp|https):\/\//i',$_REQUEST['url'])) {
9 list($usec, $sec) = explode(" ", microtime());
11 $fp = fopen('config/config.ini','r');
12 while($config = fgetcsv($fp,1024,';')) {
13 if (preg_match('/DATA_PATH/',$config[0])) {
14 list($key,$value) = split('=',$config[0]);
15 $data_path = trim($value).'/';
19 @mkdir($data_path."uploads/thumbs");
20 $file = $data_path."uploads/thumbs/image_" . ((float)$usec + (float)$sec);
21 $source = url_get_contents($_REQUEST['url']);
23 @$fp = fopen($file,'w+');
25 header ("Content-type: text/html");
26 echo "<html><head></head><body>ERROR : unable to open $file in write mode</body></html>";
32 @$fp = fopen($_REQUEST['url'],"r");
36 header ("Content-type: text/html");
37 echo "<html><head></head><body>Not an image</body></html>";
41 $file = $_REQUEST['url'];
45 list ($a, $b, $type, $attr) = @getimagesize ($file);
48 $type = basename ($_REQUEST['url']);
49 $type = preg_split ('/\./',$type);
50 $type = array_pop ($type);
55 if (function_exists("imagecreatefromjpeg"))
56 $img = @imagecreatefromjpeg ($file);
61 if (function_exists("imagecreatefrompng"))
62 $img = @imagecreatefrompng ($file);
67 if (function_exists("imagecreatefromgif"))
68 $img = @imagecreatefromgif ($file);
73 if (function_exists("imagecreatefromwbmp"))
74 $img = @imagecreatefromwbmp ($file);
79 if (function_exists("imagecreatefromxbm"))
80 $img = @imagecreatefromxbm ($file);
85 if (function_exists("imagecreatefromxpm"))
86 $img = @imagecreatefromxpm ($file);
91 if (function_exists("imagecreatefromgd"))
92 $img = @imagecreatefromgd ($file);
97 if (function_exists("imagecreatefromgd2"))
98 $img = @imagecreatefromgd2 ($file);
103 //we are not stupid...
104 header ("Content-type: text/html");
105 echo "<html><head></head><body>Not an image</body></html>";
110 $width = @imagesx($img);
111 $height = @imagesy($img);
113 $newwidth = $_REQUEST['width'];
114 if (empty($newidth)) $newidth = 50;
116 $newheight = $_REQUEST['height'];
117 if (empty($newheight)) $newheight = round($newwidth * ($height / $width)) ;
119 $thumb = imagecreate($newwidth, $newheight);
120 $img = imagecopyresampled($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
122 if ($remove == 1) unlink ($file);
124 header ("Content-type: image/png");
127 function show_plain () {
128 $mime = mime_content_type ($_REQUEST['url']);
129 header ("Content-type: $mime");
130 readfile($_REQUEST['url']);
136 $Log: not supported by cvs2svn $
143 // c-hanging-comment-ender-p: nil
144 // indent-tabs-mode: nil