OSDN Git Service

Added function pkwk_headers_sent() to care header()
authorhenoheno <henoheno>
Thu, 2 Dec 2004 11:42:37 +0000 (20:42 +0900)
committerhenoheno <henoheno>
Thu, 2 Dec 2004 11:42:37 +0000 (20:42 +0900)
21 files changed:
lib/auth.php
lib/file.php
lib/func.php
lib/html.php
plugin/amazon.inc.php
plugin/attach.inc.php
plugin/bugtrack.inc.php
plugin/dump.inc.php
plugin/edit.inc.php
plugin/interwiki.inc.php
plugin/lookup.inc.php
plugin/newpage.inc.php
plugin/pcomment.inc.php
plugin/ref.inc.php
plugin/rename.inc.php
plugin/rss.inc.php
plugin/rss10.inc.php
plugin/tb.inc.php
plugin/touchgraph.inc.php
plugin/tracker.inc.php
pukiwiki.ini.php

index 7f3d535..a49274d 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: auth.php,v 1.3 2004/10/07 13:25:41 henoheno Exp $
+// $Id: auth.php,v 1.4 2004/12/02 11:42:37 henoheno Exp $
 //
 
 // ÊÔ½¸ÉÔ²Äǽ¤Ê¥Ú¡¼¥¸¤òÊÔ½¸¤·¤è¤¦¤È¤·¤¿¤È¤­
@@ -97,6 +97,7 @@ function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot)
                || $auth_users[$_SERVER['PHP_AUTH_USER']] != $_SERVER['PHP_AUTH_PW'])
        {
                if ($auth_flag) {
+                       pkwk_headers_sent();
                        header('WWW-Authenticate: Basic realm="'.$_msg_auth.'"');
                        header('HTTP/1.0 401 Unauthorized');
                }
index 82b6c75..c84f661 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: file.php,v 1.7 2004/11/23 01:58:53 henoheno Exp $
+// $Id: file.php,v 1.8 2004/12/02 11:42:37 henoheno Exp $
 //
 
 // ¥½¡¼¥¹¤ò¼èÆÀ
@@ -261,9 +261,11 @@ function header_lastmod($page = NULL)
 {
        global $lastmod;
 
-       if ($lastmod && is_page($page))
+       if ($lastmod && is_page($page)) {
+               pkwk_headers_sent();
                header('Last-Modified: ' .
                        date('D, d M Y H:i:s', get_filetime($page)) . ' GMT');
+       }
 }
 
 // Á´¥Ú¡¼¥¸Ì¾¤òÇÛÎó¤Ë
index 98b6229..4de84ae 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: func.php,v 1.13 2004/11/23 14:00:11 henoheno Exp $
+// $Id: func.php,v 1.14 2004/12/02 11:42:37 henoheno Exp $
 //
 
 // Ê¸»úÎó¤¬InterWikiName¤«¤É¤¦¤«
@@ -375,6 +375,7 @@ EOD;
        if(defined('SKIN_FILE') && file_exists(SKIN_FILE) && is_readable(SKIN_FILE)) {
                catbody($title, $page, $body);
        } else {
+               pkwk_headers_sent();
                header('Content-Type: text/html; charset=euc-jp');
                print <<<EOD
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
index 6297a3b..2201bf1 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: html.php,v 1.16 2004/11/28 14:29:48 henoheno Exp $
+// $Id: html.php,v 1.17 2004/12/02 11:28:56 henoheno Exp $
 //
 
 // ËÜʸ¤ò½ÐÎÏ
@@ -376,4 +376,26 @@ function anchor_explode($page, $strict_editable = FALSE)
                return array ($s_page, $anchor, FALSE);
        }
 }
+
+// Check header()s were sent already, or
+// there're blank lines or something out of php blocks
+function pkwk_headers_sent()
+{
+       if(PKWK_OPTIMISE) return;
+
+       // PHP_VERSION >= 4.3.0
+       if(version_compare(PHP_VERSION, '4.3.0', '>=')) {
+               if (headers_sent($_file_sent, $_line_sent)) {
+                       print('Headers already sent at ' .
+                               htmlspecialchars($_file_sent) .
+                               ' line ' . $_line_sent . '.');
+                       exit;
+               }
+       } else {
+               if (headers_sent()) {
+                       print('Headers already sent.');
+                       exit;
+               }
+       }
+}
 ?>
index 0ef1c60..6c9bdcf 100644 (file)
@@ -44,7 +44,7 @@
 //
 
 /////////////////////////////////////////////////
-// $Id: amazon.inc.php,v 1.3 2004/10/10 10:20:59 henoheno Exp $
+// $Id: amazon.inc.php,v 1.4 2004/12/02 11:34:25 henoheno Exp $
 // - modified by arino <arino@users.sourceforge.jp>
 // -- replace plugin_amazon_get_page().
 // -- AMAZON_XML 'xml.amazon.com' -> 'xml.amazon.co.jp'
@@ -180,6 +180,7 @@ function plugin_amazon_action() {
   $r_page = $s_page . '/' . $asin;
   $r_page_url = rawurlencode($r_page);
 
+  pkwk_headers_sent();
   if ($edit_auth and (!isset($_SERVER['PHP_AUTH_USER']) or !array_key_exists($_SERVER['PHP_AUTH_USER'],$edit_auth_users) or
       $edit_auth_users[$_SERVER['PHP_AUTH_USER']] != $_SERVER['PHP_AUTH_PW'])) {
     header('Location: ' . get_script_uri() . '?cmd=read&page=' . $r_page_url);
index 33d20c5..8ed02f0 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-//  $Id: attach.inc.php,v 1.65 2004/11/27 11:02:34 henoheno Exp $
+//  $Id: attach.inc.php,v 1.66 2004/12/02 11:34:25 henoheno Exp $
 //
 
 /*
@@ -610,6 +610,7 @@ EOD;
                ini_set('default_charset', '');
                mb_http_output('pass');
 
+               pkwk_headers_sent();
                header('Content-Disposition: inline; filename="' . $filename . '"');
                header('Content-Length: ' . $this->size);
                header('Content-Type: '   . $this->type);
index 47990e1..f81cae8 100644 (file)
@@ -8,7 +8,7 @@
  * Êѹ¹ÍúÎò:
  *  2002.06.17: ºî¤ê»Ï¤á
  *
- * $Id: bugtrack.inc.php,v 1.17 2004/10/10 10:20:59 henoheno Exp $
+ * $Id: bugtrack.inc.php,v 1.18 2004/12/02 11:34:25 henoheno Exp $
  */
 
 function plugin_bugtrack_init()
@@ -43,6 +43,7 @@ function plugin_bugtrack_action()
 
        if ($post['mode'] == 'submit') {
                $page = plugin_bugtrack_write($post['base'], $post['pagename'], $post['summary'], $post['name'], $post['priority'], $post['state'], $post['category'], $post['version'], $post['body']);
+               pkwk_headers_sent();
                header('Location: ' . get_script_uri() . '?' . rawurlencode($page));
                die;
        }
index 010b62a..f0af2ea 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /////////////////////////////////////////////////
-// $Id: dump.inc.php,v 1.31 2004/10/31 07:55:24 henoheno Exp $
+// $Id: dump.inc.php,v 1.32 2004/12/02 11:34:25 henoheno Exp $
 // Originated as tarfile.inc.php by teanan / Interfair Laboratory 2004.
 
 // [¹¹¿·ÍúÎò]
@@ -206,6 +206,7 @@ function download_tarfile($tempnam, $arc_kind)
                $filename .= '.tar';
        }
 
+       pkwk_headers_sent();
        header('Content-Disposition: attachment; filename="' . $filename . '"');
        header('Content-Length: ' . $size);
        header('Content-Type: application/octet-stream');
index dec8454..b89a4ec 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: edit.inc.php,v 1.27 2004/11/24 12:29:21 henoheno Exp $
+// $Id: edit.inc.php,v 1.28 2004/12/02 11:36:52 henoheno Exp $
 //
 
 // Edit plugin
@@ -209,6 +209,7 @@ function plugin_edit_write()
                page_write($page, $postdata, $notimestamp);
 
                if ($postdata) {
+                       pkwk_headers_sent();
                        header('Location: ' . get_script_uri() . '?' . rawurlencode($page));
                        exit;
                }
@@ -225,6 +226,7 @@ function plugin_edit_write()
 function plugin_edit_cancel()
 {
        global $vars;
+       pkwk_headers_sent();
        header('Location: ' . get_script_uri() . '?' . rawurlencode($vars['page']));
        exit;
 }
index 72f1443..b97cea8 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: interwiki.inc.php,v 1.7 2004/07/31 03:09:20 henoheno Exp $
+// $Id: interwiki.inc.php,v 1.8 2004/12/02 11:35:02 henoheno Exp $
 //
 // InterWikiName¤ÎȽÊ̤ȥڡ¼¥¸¤Îɽ¼¨
 
@@ -38,6 +38,7 @@ function plugin_interwiki_action()
                return $retvars;
        }
 
+       pkwk_headers_sent();
        header("Location: $url");
        die();
 }
index b902db2..90ab614 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: lookup.inc.php,v 1.12 2004/11/23 09:16:32 henoheno Exp $
+// $Id: lookup.inc.php,v 1.13 2004/12/02 11:34:25 henoheno Exp $
 //
 // Lookup plugin
 
@@ -52,6 +52,7 @@ function plugin_lookup_action()
                return array(msg=>'Not found', body=>$msg);
        }
 
+       pkwk_headers_sent();
        header('Location: ' . $url); // Publish as GET method
        die();
 }
index 737b54d..281b52f 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: newpage.inc.php,v 1.10 2004/10/10 10:20:59 henoheno Exp $
+// $Id: newpage.inc.php,v 1.11 2004/12/02 11:39:08 henoheno Exp $
 
 function plugin_newpage_convert()
 {
@@ -43,6 +43,7 @@ function plugin_newpage_action()
                get_fullname($page,$vars['refer']) : $page);
        $r_refer = rawurlencode($vars['refer']);
 
+       pkwk_headers_sent();
        header('Location: ' . get_script_uri() . '?cmd=read&page=' . $r_page . '&refer=' . $r_refer);
        die();
 }
index d899ff2..4a9a7ad 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: pcomment.inc.php,v 1.34 2004/10/10 10:20:59 henoheno Exp $
+// $Id: pcomment.inc.php,v 1.35 2004/12/02 11:34:25 henoheno Exp $
 //
 
 /*
@@ -71,6 +71,7 @@ function plugin_pcomment_action()
                return $retval;
        }
 
+       pkwk_headers_sent();
        header('Location: ' . get_script_uri() . '?' . rawurlencode($refer));
        exit;
 }
index cdcc540..5198559 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: ref.inc.php,v 1.45 2004/11/27 11:02:34 henoheno Exp $
+// $Id: ref.inc.php,v 1.46 2004/12/02 11:34:25 henoheno Exp $
 //
 // Include an attached image-file as an inline-image
 
@@ -414,6 +414,7 @@ function plugin_ref_action()
        $size = filesize($ref);
 
        // Output
+       pkwk_headers_sent();
        header('Content-Disposition: inline; filename="' . $filename . '"');
        header('Content-Length: ' . $size);
        header('Content-Type: '   . $type);
index b4e41f4..b983c07 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: rename.inc.php,v 1.16 2004/10/10 10:20:59 henoheno Exp $
+// $Id: rename.inc.php,v 1.17 2004/12/02 11:37:53 henoheno Exp $
 //
 
 /*
@@ -472,6 +472,8 @@ function rename_proceed($pages, $files, $exists)
        {
                $page = RENAME_LOGPAGE;
        }
+
+       pkwk_headers_sent();
        header('Location: ' . get_script_uri() . '?' . rawurlencode($page));
        die();
 }
index 4801596..44ad964 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: rss.inc.php,v 1.10 2004/11/28 04:23:13 henoheno Exp $
+// $Id: rss.inc.php,v 1.11 2004/12/02 11:34:25 henoheno Exp $
 //
 // Publishing RSS feed of RecentChanges
 // HOW TO USE: rss.inc.php?ver=[0.91(default)|1.0|2.0]
@@ -74,6 +74,7 @@ EOD;
        }
 
        // Feeding start
+       pkwk_headers_sent();
        header('Content-type: application/xml');
        print '<?xml version="1.0" encoding="UTF-8"?>' . "\n\n";
 
index c014d57..3ce9196 100644 (file)
@@ -1,9 +1,10 @@
 <?php
 // RSS 1.0 plugin - had been merged into rss plugin
-// $Id: rss10.inc.php,v 1.15 2004/11/28 12:50:13 henoheno Exp $
+// $Id: rss10.inc.php,v 1.16 2004/12/02 11:34:25 henoheno Exp $
 
 function plugin_rss10_action()
 {
+       pkwk_headers_sent();
        header('Status: 301 Moved Permanently');
        header('Location: ' . $script . '?cmd=rss&ver=1.0'); // HTTP
        exit;
index b6df66c..f3cfd5b 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: tb.inc.php,v 1.13 2004/07/31 13:41:20 henoheno Exp $
+// $Id: tb.inc.php,v 1.14 2004/12/02 11:34:25 henoheno Exp $
 /*
  * PukiWiki TrackBack ¥×¥í¥°¥é¥à
  * (C) 2003, Katsumi Saito <katsumi@jo1upk.ymt.prug.or.jp>
@@ -109,6 +109,7 @@ function tb_save()
 // XML ·ë²Ì½ÐÎÏ
 function tb_xml_msg($rc, $msg)
 {
+       pkwk_headers_sent();
        header('Content-Type: text/xml');
        echo '<?xml version="1.0" encoding="iso-8859-1"?>';
        echo <<<EOD
@@ -170,6 +171,8 @@ EOD;
 </response>
 EOD;
        $rc = mb_convert_encoding($rc, 'UTF-8', SOURCE_ENCODING);
+
+       pkwk_headers_sent();
        header('Content-Type: text/xml');
        echo '<?xml version="1.0" encoding="utf-8" ?>';
        echo $rc;
@@ -242,6 +245,7 @@ EOD;
 </html>
 EOD;
        // BugTrack/466 ¥¨¥ó¥³¡¼¥É¸íǧÂкö
+       pkwk_headers_sent();
        header('Content-type: text/html; charset=UTF-8');
        echo '<?xml version="1.0" encoding="UTF-8"?>';
        echo mb_convert_encoding($msg, 'UTF-8', SOURCE_ENCODING);
index bd67e96..e54d504 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: touchgraph.inc.php,v 1.4 2004/07/31 03:09:20 henoheno Exp $
+// $Id: touchgraph.inc.php,v 1.5 2004/12/02 11:34:25 henoheno Exp $
 //
 // TouchGraph WikiBrowserÍѤΥ¤¥ó¥Ç¥Ã¥¯¥¹¤òºî¤ê¤Þ¤¹¡£
 //
@@ -17,6 +17,7 @@
 
 function plugin_touchgraph_action()
 {
+       pkwk_headers_sent();
        header('Content-type: text/plain');
        plugin_touchgraph_rel();
 //     plugin_touchgraph_ref(); // reverse
index 2d95237..8b0e737 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: tracker.inc.php,v 1.25 2004/11/30 13:15:40 henoheno Exp $
+// $Id: tracker.inc.php,v 1.26 2004/12/02 11:34:25 henoheno Exp $
 //
 
 // tracker_list¤Çɽ¼¨¤·¤Ê¤¤¥Ú¡¼¥¸Ì¾(Àµµ¬É½¸½¤Ç)
@@ -171,6 +171,7 @@ function plugin_tracker_action()
 
        $r_page = rawurlencode($page);
 
+       pkwk_headers_sent();
        header('Location: ' . get_script_uri() . '?' . $r_page);
        exit;
 }
index 3aa3edb..742bc63 100644 (file)
@@ -2,11 +2,20 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: pukiwiki.ini.php,v 1.98 2004/11/30 14:20:50 henoheno Exp $
+// $Id: pukiwiki.ini.php,v 1.99 2004/12/02 11:29:47 henoheno Exp $
 //
 // PukiWiki setting file
 
 /////////////////////////////////////////////////
+// Init
+
+if (! defined('PKWK_SAFE_MODE'))
+       define('PKWK_SAFE_MODE', FALSE);        // FALSE or TRUE
+
+if (! defined('PKWK_OPTIMISE'))
+       define('PKWK_OPTIMISE', FALSE); // FALSE or TRUE
+
+/////////////////////////////////////////////////
 // ½é´üÀßÄê (ʸ»ú¥¨¥ó¥³¡¼¥É¡¢¸À¸ì)
 
 // Internal Language ('en' or 'ja')