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);
49 $type = basename ($_REQUEST['url']);
50 $type = preg_split ('/\./',$type);
51 $type = array_pop ($type);
58 if (function_exists("imagecreatefromjpeg"))
59 $img = @imagecreatefromjpeg ($file);
64 if (function_exists("imagecreatefrompng"))
65 $img = @imagecreatefrompng ($file);
70 if (function_exists("imagecreatefromgif"))
71 $img = @imagecreatefromgif ($file);
76 if (function_exists("imagecreatefromwbmp"))
77 $img = @imagecreatefromwbmp ($file);
82 if (function_exists("imagecreatefromxbm"))
83 $img = @imagecreatefromxbm ($file);
88 if (function_exists("imagecreatefromxpm"))
89 $img = @imagecreatefromxpm ($file);
94 if (function_exists("imagecreatefromgd"))
95 $img = @imagecreatefromgd ($file);
100 if (function_exists("imagecreatefromgd2"))
101 $img = @imagecreatefromgd2 ($file);
106 //we are not stupid...
107 header ("Content-type: text/html");
108 echo "<html><head></head><body>Not an image</body></html>";
113 $width = @imagesx($img);
114 $height = @imagesy($img);
116 $newwidth = $_REQUEST['width'];
117 if (empty($newidth)) $newidth = 50;
119 $newheight = $_REQUEST['height'];
120 if (empty($newheight)) $newheight = round($newwidth * ($height / $width)) ;
122 $thumb = imagecreate($newwidth, $newheight);
123 $img = imagecopyresampled($thumb, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
125 if ($remove == 1) unlink ($file);
127 header ("Content-type: image/png");
130 function show_plain () {
131 $mime = mime_content_type ($_REQUEST['url']);
132 header ("Content-type: $mime");
133 readfile($_REQUEST['url']);