OSDN Git Service

BugTrack/2484 AutoTicketLink for JIRA: Support underscore key XX_X
[pukiwiki/pukiwiki.git] / plugin / external_link.inc.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // external_link.inc.php
4 // Copyright
5 //   2018 PukiWiki Development Team
6 // License: GPL v2 or (at your option) any later version
7 //
8 // PukiWiki External Link Plugin
9
10 function plugin_external_link_action()
11 {
12         global $vars, $external_link_cushion, $_external_link_messages;
13         $charset = CONTENT_CHARSET;
14         header('Content-Type: text/html; charset=' . $charset);
15         $valid_url = false;
16         if (isset($vars['url'])) {
17                 $url = $vars['url'];
18                 if (is_url($url)) {
19                         $valid_url = true;
20                 }
21         }
22         if (!$valid_url) {
23                 $error_message = <<< EOM
24 <html>
25   <body>
26     The URL is invalid.
27   </body>
28 </html>
29 EOM;
30                 print($error_message);
31                 exit;
32         }
33         $encoded_url = htmlsc($url);
34         $refreshwait = $external_link_cushion['wait_seconds'];
35         $h_title = htmlsc(str_replace('%s', $url, $_external_link_messages['page_title']));
36         $h_desc = htmlsc($_external_link_messages['desc']);
37         $h_wait = htmlsc(str_replace('%s', (string)$external_link_cushion['wait_seconds'],
38                 $_external_link_messages['wait_n_seconds']));
39         $body = <<< EOM
40 <html>
41   <head>
42     <meta http-equiv="Content-Type" content="text/html; charset=$charset" />
43     <meta http-equiv="Refresh" content="$refreshwait;URL=$encoded_url" />
44     <title>$h_title</title>
45   </head>
46   <body>
47                 <p>$h_desc</p>
48                 <p>$h_wait</p>
49                 <p><a href="$encoded_url">$encoded_url</a></p>
50   </body>
51 </html>
52 EOM;
53         print($body);
54         exit;
55 }