OSDN Git Service

BugTrack2/122: tempnam() fails when open_basedir is specified in php.ini
[pukiwiki/pukiwiki.git] / plugin / img.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: img.inc.php,v 1.14 2005/05/28 13:31:57 henoheno Exp $
4 //
5 // Inline-image plugin
6
7 define('PLUGIN_IMG_USAGE', '#img(): Usage: (URI-to-image[,right[,clear]])<br />' . "\n");
8 define('PLUGIN_IMG_CLEAR', '<div style="clear:both"></div>' . "\n"); // Stop word-wrapping
9
10 // Output inline-image tag from a URI
11 function plugin_img_convert()
12 {
13         if (PKWK_DISABLE_INLINE_IMAGE_FROM_URI)
14                 return '#img(): PKWK_DISABLE_INLINE_IMAGE_FROM_URI prohibits this' .
15                         '<br>' . "\n";
16
17         $args = func_get_args();
18
19         // Check the 2nd argument first, for compatibility
20         $arg = isset($args[1]) ? strtoupper($args[1]) : '';
21         if ($arg == '' || $arg == 'L' || $arg == 'LEFT') {
22                 $align = 'left';
23         } else if ($arg == 'R' || $arg == 'RIGHT') {
24                 $align = 'right';
25         } else {
26                 // Stop word-wrapping only (Ugly but compatible)
27                 // Short usage: #img(,clear)
28                 return PLUGIN_IMG_CLEAR;
29         }
30
31         $url = isset($args[0]) ? $args[0] : '';
32         if (! is_url($url) || ! preg_match('/\.(jpe?g|gif|png)$/i', $url))
33                 return PLUGIN_IMG_USAGE;
34
35         $arg = isset($args[2]) ? strtoupper($args[2]) : '';
36         $clear = ($arg == 'C' || $arg == 'CLEAR') ? PLUGIN_IMG_CLEAR : '';
37
38         return <<<EOD
39 <div style="float:$align;padding:.5em 1.5em .5em 1.5em">
40  <img src="$url" alt="" />
41 </div>$clear
42 EOD;
43 }
44 ?>