OSDN Git Service

BugTrack/2462 Customize Referrer Policy by HTML meta header
[pukiwiki/pukiwiki.git] / skin / keitai.skin.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: keitai.skin.php,v 1.16 2006/01/09 10:37:05 henoheno Exp $
4 // Copyright (C) 2003-2006 PukiWiki Developers Team
5 // License: GPL v2 or (at your option) any later version
6 //
7 // Skin for Embedded devices
8
9 // ----
10 // Prohibit direct access
11 if (! defined('UI_LANG')) die('UI_LANG is not set');
12
13 $pageno = (isset($vars['p']) && is_numeric($vars['p'])) ? $vars['p'] : 0;
14 $edit = (isset($vars['cmd'])    && $vars['cmd']    == 'edit') ||
15         (isset($vars['plugin']) && $vars['plugin'] == 'edit');
16
17 global $max_size, $accesskey, $menubar, $_symbol_anchor;
18 $max_size = --$max_size * 1024; // Make 1KByte spare (for $navi, etc)
19 $link = $_LINK;
20 $rw = ! PKWK_READONLY;
21
22 // ----
23 // Modify
24
25 // Ignore &dagger;s
26 $body = preg_replace('#<a[^>]+>' . preg_quote($_symbol_anchor, '#') . '</a>#', '', $body);
27
28 // Shrink IMG tags (= images) with character strings
29 // With ALT option
30 $body = preg_replace('#(<div[^>]+>)?(<a[^>]+>)?<img[^>]*alt="([^"]+)"[^>]*>(?(2)</a>)(?(1)</div>)#i', '[$3]', $body);
31 // Without ALT option
32 $body = preg_replace('#(<div[^>]+>)?(<a[^>]+>)?<img[^>]+>(?(2)</a>)(?(1)</div>)#i', '[img]', $body);
33
34 // ----
35
36 // Check content volume, Page numbers, divided by this skin
37 $pagecount = ceil(strlen($body) / $max_size);
38
39 // Too large contents to edit
40 if ($edit && $pagecount > 1)
41         die('Unable to edit: Too large contents for your device');
42
43 // Get one page
44 $body = substr($body, $pageno * $max_size, $max_size);
45
46 // ----
47 // Top navigation (text) bar
48
49 $navi = array();
50 $navi[] = '<a href="' . $link['top']  . '" ' . $accesskey . '="0">0.Top</a>';
51 if ($rw) {
52         $navi[] = '<a href="' . $link['new']  . '" ' . $accesskey . '="1">1.New</a>';
53         $navi[] = '<a href="' . $link['edit'] . '" ' . $accesskey . '="2">2.Edit</a>';
54         if ($is_read && $function_freeze) {
55                 if (! $is_freeze) {
56                         $navi[] = '<a href="' . $link['freeze']   . '" ' . $accesskey . '="3">3.Freeze</a>';
57                 } else {
58                         $navi[] = '<a href="' . $link['unfreeze'] . '" ' . $accesskey . '="3">3.Unfreeze</a>';
59                 }
60         }
61 }
62 $navi[] = '<a href="' . $script . '?' . pagename_urlencode($menubar) . '" ' . $accesskey . '="4">4.Menu</a>';
63 $navi[] = '<a href="' . $link['recent'] . '" ' . $accesskey . '="5">5.Recent</a>';
64
65 // Previous / Next block
66 if ($pagecount > 1) {
67         $prev = $pageno - 1;
68         $next = $pageno + 1;
69         if ($pageno > 0) {
70                 $navi[] = '<a href="' . $script . '?cmd=read&amp;page=' . $r_page .
71                         '&amp;p=' . $prev . '" ' . $accesskey . '="7">7.Prev</a>';
72         }
73         $navi[] = $next . '/' . $pagecount . ' ';
74         if ($pageno < $pagecount - 1) {
75                 $navi[] = '<a href="' . $script . '?cmd=read&amp;page=' . $r_page .
76                         '&amp;p=' . $next . '" ' . $accesskey . '="8">8.Next</a>';
77         }
78 }
79
80 $navi = join(' | ', $navi);
81
82 // ----
83 // Output HTTP headers
84 pkwk_headers_sent();
85 if(TRUE) {
86         // Force Shift JIS encode for Japanese embedded browsers and devices
87         header('Content-Type: text/html; charset=Shift_JIS');
88         $title = mb_convert_encoding($title, 'SJIS', SOURCE_ENCODING);
89         $body  = mb_convert_encoding($body,  'SJIS', SOURCE_ENCODING);
90 } else {
91         header('Content-Type: text/html; charset=' . CONTENT_CHARSET);
92 }
93
94 // Output
95 ?><html><head><title><?php
96         echo $title
97 ?></title></head><body><?php
98         echo $navi
99 ?><hr><?php
100         echo $body
101 ?></body></html>