Beispiel #1
0
function plugin_preview_action()
{
    global $vars;
    $page = isset($vars['page']) ? $vars['page'] : '';
    $modified = 0;
    $response = new Response();
    if (!empty($page)) {
        $wiki = Factory::Wiki($page);
        if ($wiki->isReadable()) {
            $source = $wiki->get();
            array_splice($source, 10);
            $response->setStatusCode(Response::STATUS_CODE_200);
            $response->setContent('<' . '?xml version="1.0" encoding="UTF-8"?' . ">\n" . RendererFactory::factory($source));
            $headers = Header::getHeaders('text/xml', $wiki->time());
        } else {
            $response->setStatusCode(Response::STATUS_CODE_404);
            $headers = Header::getHeaders('text/xml');
        }
    } else {
        $response->setStatusCode(Response::STATUS_CODE_404);
        $headers = Header::getHeaders('text/xml');
    }
    $response->getHeaders()->addHeaders($headers);
    header($response->renderStatusLine());
    foreach ($response->getHeaders() as $_header) {
        header($_header->toString());
    }
    echo $response->getBody();
    exit;
}
Beispiel #2
0
function plugin_showrss_action()
{
    global $vars, $cache;
    // if (PKWK_SAFE_MODE) die_message('PKWK_SAFE_MODE prohibit this');
    if (Auth::check_role('safemode')) {
        Utility::dieMessage('PKWK_SAFE_MODE prohibits this');
    }
    if ($vars['feed']) {
        // ajaxによる読み込み
        $target = $vars['feed'];
        list($data, $time, $reason) = plugin_showrss_get_rss($vars['feed'], 1, true);
        $header = Header::getHeaders('aplication/xml', $time);
        if (empty($reason)) {
            Header::writeResponse($header, Response::STATUS_CODE_200, $data);
        } else {
            // とりあえずXMLでエラー
            Header::writeResponse($header, Response::STATUS_CODE_200, '<?xml version="1.0" encoding="UTF-8"?><response><error>1</error><message>' . Utility::htmlsc($reason) . '</message></response>');
        }
        exit;
    }
    $body = '';
    foreach (array('xml', 'mbstring') as $extension) {
        ${$extension} = extension_loaded($extension) ? '&color(green){Found};' : '&color(red){Not found};';
        $body .= '| ' . $extension . ' extension | ' . ${$extension} . ' |' . "\n";
    }
    return array('msg' => 'showrss_info', 'body' => convert_html($body));
}
Beispiel #3
0
function plugin_tooltip_action()
{
    global $vars;
    $term = isset($vars['q']) ? trim($vars['q']) : null;
    if (empty($term)) {
        exit;
    }
    $glossary = Glossary::getGlossary($term);
    $glossary_lastmod = Glossary::getGlossaryTime();
    // なんども通信するのを防ぐためlastmodを出力
    if ($glossary == FALSE) {
        exit;
    }
    $s_glossary = RendererFactory::factory($glossary);
    Header::writeResponse(Header::getHeaders('text/xml', $glossary_lastmod), 200, '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . $s_glossary);
}
Beispiel #4
0
function plugin_guiedit_send_ajax($postdata)
{
    $headers = Header::getHeaders('application/json');
    Header::writeResponse($headers, 200, json_encode(array('msg' => $postdata, 'taketime' => sprintf('%01.03f', getmicrotime() - MUTIME))));
    exit;
}
Beispiel #5
0
function pkwk_common_headers($modified = 0, $expire = 604800)
{
    $headers = Header::getHeaders('text/html', $modified, $expire);
    Header::writeResponse($headers, null);
}
Beispiel #6
0
function plugin_edit_honeypot()
{
    if (isset($vars['ajax'])) {
        $headers = Header::getHeaders('application/json');
        Header::writeResponse($headers, 200, Json::encode(array('posted' => false, 'message' => 'Sorry your post has been prohibited.', 'taketime' => Time::getTakeTime())));
        exit;
    }
    // SPAM Logging
    Utility::dump();
    // Same as "Cancel" action
    return plugin_edit_cancel();
}
Beispiel #7
0
 /**
  * エラーメッセージを表示
  * @param string $msg エラーメッセージ
  * @param string $title エラーのタイトル
  * @param int $http_code 出力するヘッダー
  */
 public static function dieMessage($msg = '', $error_title = '', $http_code = Response::STATUS_CODE_200)
 {
     global $_string, $_title, $_button, $vars;
     // エラーメッセージの内容
     if (!isset($vars['ajax'])) {
         $body[] = '<p>[ ';
         if (isset($vars['page']) && !empty($vars['page'])) {
             $body[] = '<a href="' . Factory::Wiki($vars['page'])->uri() . '">' . $_button['back'] . '</a> | ';
             $body[] = '<a href="' . Router::get_cmd_uri('edit', $vars['page']) . '">' . $_button['try_edit'] . '</a> | ';
         }
         $body[] = '<a href="' . Router::get_cmd_uri() . '">' . $_button['return_home'] . '</a> ]</p>';
     }
     $body[] = '<p class="alert alert-warning"><span class="fa fa-ban"></span> <strong>' . $_title['error'] . '</strong>';
     $body[] = PKWK_WARNING !== true || empty($msg) ? $msg = $_string['error_msg'] : $msg;
     $body[] = '</p>';
     if (DEBUG) {
         $body[] = '<div class="panel panel-info">';
         $body[] = '<div class="panel-heading"><span class="fa fa-info-circle"></span> Back Trace</div>';
         $body[] = '<div class="panel-body">';
         $body[] = '<ol>';
         foreach (debug_backtrace() as $k => $v) {
             if ($k < 2) {
                 continue;
             }
             array_walk($v['args'], function ($item, $key) {
                 $item = var_export($item, true);
             });
             $body[] = '<li>' . (isset($v['file']) ? $v['file'] : '?') . '(<var>' . (isset($v['line']) ? $v['line'] : '?') . '</var>):<br /><code>' . (isset($v['class']) ? '<strong>' . $v['class'] . '</strong>-&gt;' : '') . $v['function'] . '(<var>' . implode(', ', $v['args']) . '</var>)</code></li>' . "\n";
         }
         $body[] = '</ol>';
         $body[] = '</div>';
         $body[] = '</div>';
     }
     if (empty($error_title)) {
         $error_title = $_title['error'];
     }
     if (isset($vars['ajax'])) {
         $headers = Header::getHeaders('application/json');
         Header::writeResponse($headers, $http_code, Json::encode(array('posted' => false, 'title' => $error_title, 'body' => join("\n", $body), 'taketime' => Time::getTakeTime())));
     } else {
         new Render($error_title, join("\n", $body), $http_code);
         die(join("\n", $body));
     }
     die;
 }
Beispiel #8
0
 /**
  * Atom/rssを出力
  * string $page ページ名(ページ名が入っている場合はキャッシュは無効)
  * string $type rssかatomか。
  * boolean $force キャッシュ生成しない
  * return void
  */
 public static function getFeed($page = '', $type = 'rss', $force = false)
 {
     global $vars, $site_name, $site_logo, $modifier, $modifierlink, $_string, $cache;
     static $feed;
     // rss, atom以外はエラー
     if (!($type === 'rss' || $type === 'atom')) {
         throw new Exception('Recent::getFeed(): Unknown feed type.');
     }
     $content_type = $type === 'rss' ? 'application/rss+xml' : 'application/atom+xml';
     $body = '';
     if (empty($page)) {
         // recentキャッシュの更新チェック
         if ($cache['wiki']->getMetadata(self::RECENT_CACHE_NAME)['mtime'] > $cache['wiki']->getMetadata(self::FEED_CACHE_NAME)['mtime']) {
             $force = true;
         }
         if ($force) {
             // キャッシュ再生成
             unset($feed);
             $cache['wiki']->removeItem(self::FEED_CACHE_NAME);
         } else {
             if (!empty($feed)) {
                 // メモリにキャッシュがある場合
             } else {
                 if ($cache['wiki']->hasItem(self::FEED_CACHE_NAME)) {
                     // キャッシュから最終更新を読み込む
                     $feed = $cache['wiki']->getItem(self::FEED_CACHE_NAME);
                 }
             }
         }
     }
     if (empty($feed)) {
         // Feedを作る
         $feed = new Feed();
         // Wiki名
         $feed->setTitle($site_name);
         // Wikiのアドレス
         $feed->setLink(Router::get_script_absuri());
         // サイトのロゴ
         //$feed->setImage(array(
         //	'title'=>$site_name,
         //	'uri'=>$site_logo,
         //	'link'=>Router::get_script_absuri()
         //));
         // Feedの解説
         $feed->setDescription(sprintf($_string['feed_description'], $site_name));
         // Feedの発行者など
         $feed->addAuthor(array('name' => $modifier, 'uri' => $modifierlink));
         // feedの更新日時(生成された時間なので、この実装で問題ない)
         $feed->setDateModified(time());
         $feed->setDateCreated(time());
         // Feedの生成
         $feed->setGenerator(S_APPNAME, S_VERSION, 'http://pukiwiki.logue.be/');
         if (empty($page)) {
             // feedのアドレス
             // ※Zend\Feedの仕様上、&が自動的に&amp;に変更されてしまう
             $feed->setFeedLink(Router::get_cmd_uri('feed') . '&type=atom', 'atom');
             $feed->setFeedLink(Router::get_cmd_uri('feed'), 'rss');
             // PubSubHubbubの送信
             foreach (Ping::$pubsubhubbub_server as $uri) {
                 $feed->addHub($uri);
             }
         } else {
             $r_page = rawurlencode($page);
             $feed->setFeedLink(Router::get_cmd_uri('feed') . '&type=atom&refer=' . $r_page, 'atom');
             $feed->setFeedLink(Router::get_cmd_uri('feed') . '&refer=' . $r_page, 'rss');
         }
         $i = 0;
         // エントリを取得
         foreach (self::get() as $_page => $time) {
             // ページ名が指定されていた場合、そのページより下位の更新履歴のみ出力
             if (!empty($page) && strpos($_page, $page . '/') === false) {
                 continue;
             }
             $wiki = Factory::Wiki($_page);
             if ($wiki->isHidden()) {
                 continue;
             }
             $entry = $feed->createEntry();
             // ページのタイトル
             $entry->setTitle($wiki->title());
             // ページのアドレス
             $entry->setLink($wiki->uri());
             // ページの更新日時
             $entry->setDateModified($wiki->time());
             // ページの要約
             $entry->setDescription($wiki->description(self::FEED_ENTRY_DESCRIPTION_LENGTH));
             // 項目を追加
             $feed->addEntry($entry);
             $i++;
             if ($i >= self::RECENT_MAX_SHOW_PAGES) {
                 break;
             }
         }
         if (empty($page)) {
             // キャッシュに保存
             $cache['wiki']->setItem(self::FEED_CACHE_NAME, $feed);
         }
     }
     flush();
     $headers = Header::getHeaders($content_type);
     Header::writeResponse($headers, 200, $feed->export($type));
     //header('Content-Type: ' . $content_type);
     //echo $body;
     exit;
 }
Beispiel #9
0
function plugin_qrcode_action()
{
    global $vars;
    if (empty($vars['d'])) {
        // 透過PNG
        $buffer = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQI12NgYAAAAAMAASDVlMcAAAAASUVORK5CYII=');
    } else {
        $qr = new PHPQRCode\QRcode();
        // 宣言
        $qr->version = empty($vars['v']) ? 0 : $vars['v'];
        // バージョン
        $qr->mask = empty($vars['m']) ? PHPQRCode\Constants::QR_DEFAULT_MASK : $vars['m'];
        // 分割数
        $qr->count = empty($vars['n']) ? 1 : $vars['n'];
        //
        $qr->hint = empty($vars['h']) ? PHPQRCode\Constants::QR_MODE_AN : $vars['h'];
        // 文字コード
        //	$parity = (empty($vars['p'])) ? 0	: $vars['p'];	// パリティ(使用しない)
        $buffer = $qr->png(rawurldecode($vars['d']), false, empty($vars['e']) ? 'M' : $vars['e'], empty($vars['s']) ? 1 : $vars['s'], 2);
    }
    // 出力
    Header::writeResponse(Header::getHeaders('image/png'), 200, $buffer);
    exit;
}
Beispiel #10
0
function attach_list()
{
    global $vars, $_attach_messages, $_string;
    if (Auth::check_role('safemode')) {
        Utility::dieMessage($_string['prohibit']);
    }
    $page = isset($vars['page']) ? $vars['page'] : null;
    $refer = isset($vars['refer']) ? $vars['refer'] : $page;
    $type = isset($vars['type']) ? $vars['type'] : null;
    if (!empty($refer)) {
        $wiki = Factory::Wiki($refer);
        $wiki->isReadable();
        $attaches = $wiki->attach();
        if ($type === 'json') {
            $headers = Header::getHeaders('application/json');
            Header::writeResponse($headers, 200, Json::encode($attaches));
            exit;
        }
        // ページ別添付ファイル一覧
        $msg = str_replace('$1', Utility::htmlsc($refer), $_attach_messages['msg_listpage']);
        if (count($attaches) === 0) {
            return array('msg' => $msg, 'body' => 'No files uploaded.');
        }
        $ret[] = '<table class="table table-borderd plugin-attach-list" data-pagenate="true" data-sortable="true"><thead>';
        $ret[] = '<thead>';
        $ret[] = '<tr>';
        $ret[] = '<th>' . $_attach_messages['msg_file'] . '</th>';
        $ret[] = '<th>' . $_attach_messages['msg_filesize'] . '</th>';
        $ret[] = '<th>' . $_attach_messages['msg_type'] . '</th>';
        $ret[] = '<th>' . $_attach_messages['msg_date'] . '</th>';
        $ret[] = '</tr>';
        $ret[] = '</thead>';
        $ret[] = '<tbody>';
        foreach ($attaches as $name => $files) {
            unset($files['log']);
            foreach ($files as $backup => $file) {
                $attach = new Attach($refer, $name, $backup);
                $ret[] = '<tr>';
                if ($backup === 0) {
                    $ret[] = '<td>' . $attach->toString() . '</td>';
                } else {
                    $ret[] = '<td>' . $name . '<em>(Backup no.' . $backup . ')</em></td>';
                }
                $ret[] = '<td>' . $attach->getSize() . '</td>';
                $ret[] = '<td>' . $attach->getMime() . '</td>';
                $ret[] = '<td>' . $attach->getDate() . '</td>';
                $ret[] = '</tr>';
            }
        }
        $ret[] = '</tbody>';
        $ret[] = '</table>';
    } else {
        // 全ページ添付ファイル一覧
        $msg = $_attach_messages['msg_listall'];
        $ret[] = Listing::get('attach', 'attach');
    }
    return array('msg' => $msg, 'body' => join("\n", $ret));
}
Beispiel #11
0
 /**
  * 進捗状況表示(attachプラグインのpcmd=progressで出力)
  * @return void
  */
 public static function getUploadProgress()
 {
     $headers = Header::getHeaders('application/json');
     $progress = new SessionProgress();
     Header::writeResponse($headers, 200, Json::encode($progress->getProgress(PKWK_WIKI_NAMESPACE)));
     exit;
 }
Beispiel #12
0
 /**
  * コンストラクタ
  * @param string $title 題目
  * @param string $body 内容
  */
 public function __construct($title, $body, $http_code = Response::STATUS_CODE_200)
 {
     global $vars, $lastmod;
     $this->page = isset($vars['page']) ? $vars['page'] : null;
     $this->ajax = isset($vars['ajax']) ? $vars['ajax'] : null;
     $this->cmd = isset($vars['cmd']) ? $vars['cmd'] : 'read';
     // ※通常は空にならない
     $this->wiki = !empty($this->page) ? Factory::Wiki($this->page) : null;
     $this->title = $title;
     $this->body = $body;
     switch ($this->ajax) {
         case 'json':
             $content_type = 'application/json';
             $content = Json::encode(array('title' => $this->title, 'body' => $this->body, 'process_time' => Time::getTakeTime()));
             break;
         case 'xml':
             $content_type = 'application/xml';
             $content = '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . "\n" . '<response>' . "\n" . '<title>' . $this->title . '</title>' . "\n" . '<body><![CDATA[' . $this->body . ']]></body>' . "\n" . '<process_time>' . Time::getTakeTime() . '</process_time>' . "\n" . '</response>';
             break;
         case 'raw':
             $content_type = 'text/plain';
             $content = $this->body;
             break;
         default:
             // 厳格にXHTMLとして出力する場合は、ブラウザの対応状況を読んでapplication/xhtml+xmlを出力
             $content_type = self::USE_STRICT_XHTML === TRUE && strstr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') !== false ? 'application/xhtml+xml' : 'text/html';
             $content = self::getContent();
             break;
     }
     if (empty($this->page) || !$lastmod) {
         $headers = Header::getHeaders($content_type);
     } else {
         // ページ名が定義されている場合、最終更新日時をヘッダーに追加
         $headers = Header::getHeaders($content_type, $this->wiki->time());
     }
     Header::writeResponse($headers, $http_code, $content);
 }
Beispiel #13
0
function plugin_mixirss_action()
{
    global $vars, $get, $post, $rss_max, $rss_description, $page_title, $whatsnew;
    global $modifier;
    global $exclude_plugin;
    global $memcache;
    $version = isset($vars['ver']) ? $vars['ver'] : '';
    switch ($version) {
        case '':
            $version = '1.0';
            break;
            // mixi Default
        // mixi Default
        case '1':
            $version = '1.0';
            break;
        case '2':
            $version = '2.0';
            break;
        case '0.91':
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '1.0':
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '2.0':
            break;
        default:
            die('Invalid RSS version!!');
    }
    // Official Main routine ...
    $page_title_utf8 = mb_convert_encoding($page_title, 'UTF-8', SOURCE_ENCODING);
    $rss_description_utf8 = mb_convert_encoding(htmlspecialchars($rss_description), 'UTF-8', SOURCE_ENCODING);
    // Disable plugin
    $exclude_plugin[] = 'include';
    $self = get_script_absuri();
    change_uri('', 1);
    // Force absoluteURI.
    // Creating <item>
    $items = $rdf_li = '';
    foreach (Recent::get() as $page => $time) {
        $wiki = Factory::Wiki($page);
        $r_page = rawurlencode($page);
        $url = $wiki->uri();
        $title = mb_convert_encoding($page, 'UTF-8', SOURCE_ENCODING);
        switch ($version) {
            case '0.91':
                /* FALLTHROUGH */
            /* FALLTHROUGH */
            case '2.0':
                $date = get_date('D, d M Y H:i:s T', $time);
                $date = $version == '0.91' ? ' <description>' . $date . '</description>' : ' <pubDate>' . $date . '</pubDate>';
                $items .= <<<EOD
<item>
 <title>{$title}</title>
 <link>{$url}</link>
{$date}
</item>
EOD;
                break;
            case '1.0':
                // Add <item> into <items>
                //			$rdf_li .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                $date = substr_replace(get_date('Y-m-d\\TH:i:sO', $time), ':', -2, 0);
                if (plugin_mixirss_isValidDate(substr($page, -10)) && check_readable($page, false, false)) {
                    // for Calendar/MiniCalendar
                    $get['page'] = $post['page'] = $vars['page'] = $page;
                    $source = get_source($page);
                    $rdf_hx = '';
                    $rdf_lx = '';
                    $itemhx = '';
                    $itemlx = '';
                    while (!empty($source)) {
                        $line = array_shift($source);
                        if (preg_match('/^(\\*{1,3})(.*)\\[#([A-Za-z][\\w-]+)\\](.*)$/m', $line, $matches)) {
                            $anchortitle = strip_htmltag(RendererFactory::factory($matches[2]));
                            $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle);
                            $anchortitle = '<![CDATA[' . mb_convert_encoding($anchortitle, 'UTF-8', SOURCE_ENCODING) . '(' . $title . ')' . ']]>';
                            $sharp = '#';
                            $rdf_hx .= '    <rdf:li rdf:resource="' . $url . $sharp . $matches[3] . '" />' . "\n";
                            $itemhx .= <<<EOD
<item rdf:about="{$url}{$sharp}{$matches[3]}">
 <title>{$anchortitle}</title>
 <link>{$url}{$sharp}{$matches[3]}</link>
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}{$sharp}{$matches[3]}</dc:identifier>
</item>
EOD;
                        } else {
                            if (preg_match('/^(\\-{1,3})(.*)$/m', $line, $matches)) {
                                $anchortitle = strip_htmltag(RendererFactory::factory($matches[2]));
                                $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle);
                                $anchortitle = '<![CDATA[' . mb_convert_encoding($anchortitle, 'UTF-8', SOURCE_ENCODING) . '(' . $title . ')' . ']]>';
                                $sharp = '#';
                                $rdf_lx .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                                $itemlx .= <<<EOD
<item rdf:about="{$url}">
 <title>{$anchortitle}</title>
 <link>{$url}</link>
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}</dc:identifier>
</item>

EOD;
                            }
                        }
                    }
                    if ($itemhx != '') {
                        $rdf_li .= $rdf_hx;
                        $items .= $itemhx;
                    } else {
                        if ($itemlx != '') {
                            $rdf_li .= $rdf_lx;
                            $items .= $itemlx;
                        } else {
                            // default
                            $rdf_li .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                            $items .= <<<EOD
<item rdf:about="{$url}">
 <title>{$title}</title>
 <link>{$url}</link>
{$description}
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}</dc:identifier>
</item>

EOD;
                        }
                    }
                    // upk 2006-03-22
                    // } else if (check_readable($page,false,false) && !ereg(MIXIRSS_IGNORE_REGEX, $page)) {
                } else {
                    if ($wiki->isReadable()) {
                        $get['page'] = $post['page'] = $vars['page'] = $page;
                        //miko added
                        $description = strip_htmltag($wiki->render());
                        $description = mb_strimwidth(preg_replace("/[\r\n]/", ' ', $description), 0, MIXIRSS_DESCRIPTION_LENGTH, '...');
                        $description = ' <description><![CDATA[' . mb_convert_encoding($description, 'UTF-8', SOURCE_ENCODING) . ']]></description>';
                        //miko added
                        $rdf_li .= '    <rdf:li rdf:resource="' . $url . '" />' . "\n";
                        global $newtitle, $newbase;
                        if (isset($newbase) && $newbase != '') {
                            $anchortitle = $newtitle . ' (' . $title . ')';
                            $newtitle = $newbase = '';
                        } else {
                            $anchortitle = $title;
                        }
                        $items .= <<<EOD
<item rdf:about="{$url}">
 <title>{$anchortitle}</title>
 <link>{$url}</link>
{$description}
 <dc:date>{$date}</dc:date>
 <dc:identifier>{$url}</dc:identifier>
</item>

EOD;
                    }
                }
                break;
        }
    }
    // Feeding start
    $html = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
    $w_whatsnew = Factory::Wiki($whatsnew);
    $url_whatsnew = $w_whatsnew->uri();
    switch ($version) {
        case '0.91':
            $html .= '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"' . ' "http://my.netscape.com/publish/formats/rss-0.91.dtd">' . "\n";
            /* FALLTHROUGH */
        /* FALLTHROUGH */
        case '2.0':
            $html .= <<<EOD
<rss version="{$version}">
 <channel>
  <title><![CDATA[{$page_title_utf8}]]></title>
  <link>{$url_whatsnew}</link>
  <description><![CDATA[{$rss_description_utf8}]]></description>
  <language>ja</language>

{$items}
 </channel>
</rss>
EOD;
            break;
        case '1.0':
            $html .= <<<EOD
<rdf:RDF
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xml:lang="ja">
 <channel rdf:about="{$url_whatsnew}">
  <title><![CDATA[{$page_title_utf8}]]></title>
  <link>{$url_whatsnew}</link>
  <description><![CDATA[{$rss_description_utf8}]]></description>
  <items>
   <rdf:Seq>
{$rdf_li}
   </rdf:Seq>
  </items>
 </channel>

{$items}
</rdf:RDF>
EOD;
            break;
    }
    $header = Header::getHeaders('application/xml', $w_whatsnew->time());
    Header::writeResponse($header, 200, $html);
    exit;
}
Beispiel #14
0
function plugin_cache_ref_action()
{
    global $vars, $use_sendfile_header;
    $usage = 'Usage: cmd=cache_ref&amp;src=filename';
    if (!isset($vars['src'])) {
        return array('msg' => 'Invalid argument', 'body' => $usage);
    }
    $filename = rawurldecode($vars['src']);
    $ref = CACHE_DIR . $filename;
    $fileinfo = new SplFileInfo($ref);
    if (!$fileinfo->isFile() || !$fileinfo->isReadable()) {
        return array('msg' => 'Cache file not found', 'body' => $usage);
    }
    try {
        list($width, $height, $_type, $attr) = getimagesize($ref);
        switch ($_type) {
            case 1:
                $type = 'image/gif';
                break;
            case 2:
                $type = 'image/jpeg';
                break;
            case 3:
                $type = 'image/png';
                break;
            case 4:
                $type = 'application/x-shockwave-flash';
                break;
            default:
                return array('msg' => 'Seems not an image', 'body' => $usage);
        }
    } catch (Exception $e) {
        return array('msg' => 'Seems not an image', 'body' => $usage);
    }
    /*
    // Care for Japanese-character-included file name
    if (LANG == 'ja_JP') {
    	switch(UA_NAME . '/' . UA_PROFILE){
    	case 'Opera/default':
    		// Care for using _auto-encode-detecting_ function
    		$filename = mb_convert_encoding($filename, 'UTF-8', 'auto');
    		break;
    	case 'MSIE/default':
    		$filename = mb_convert_encoding($filename, 'SJIS', 'auto');
    		break;
    	}
    }
    */
    $filename = mb_convert_encoding($filename, 'UTF-8', 'auto');
    // Output
    ini_set('default_charset', '');
    mb_http_output('pass');
    // ヘッダー出力
    $header = Header::getHeaders($type, $fileinfo->getMTime());
    $header['Content-Disposition'] = 'inline; filename="' . $filename . '"';
    // ファイルサイズ
    $header['Content-Length'] = $fileinfo->getSize();
    if ($use_sendfile_header === true) {
        // for reduce server load
        $header['X-Sendfile'] = $fileinfo->getRealPath();
    }
    $obj = new SplFileObject($ref);
    // ファイルの読み込み
    $obj->openFile('rb');
    // ロック
    $obj->flock(LOCK_SH);
    ob_start(!DEBUG ? 'ob_gzhandler' : null);
    echo $obj->fpassthru();
    $content = ob_get_clean();
    // アンロック
    $obj->flock(LOCK_UN);
    // 念のためオブジェクトを開放
    unset($fileinfo, $obj);
    Header::writeResponse($header, Response::STATUS_CODE_200, $content);
}