OSDN Git Service

BugTrack/554 Enable to set $script manually
authorhenoheno <henoheno>
Mon, 11 Oct 2004 03:13:09 +0000 (12:13 +0900)
committerhenoheno <henoheno>
Mon, 11 Oct 2004 03:13:09 +0000 (12:13 +0900)
lib/func.php
lib/init.php

index 1d826c7..b282bf0 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: func.php,v 1.8 2004/10/10 10:20:59 henoheno Exp $
+// $Id: func.php,v 1.9 2004/10/11 03:13:09 henoheno Exp $
 //
 
 // Ê¸»úÎó¤¬InterWikiName¤«¤É¤¦¤«
@@ -516,31 +516,47 @@ function get_autolink_pattern_sub(& $pages, $start, $end, $pos)
 }
 
 // pukiwiki.php¥¹¥¯¥ê¥×¥È¤Îabsolute-uri¤òÀ¸À®
-function get_script_uri()
+function get_script_uri($init_uri = '')
 {
        static $script;
 
-       if (isset($script)) return $script;
+       if ($init_uri == '') {
+               if (isset($script)) return $script;
 
-       $script  = (SERVER_PORT == 443 ? 'https://' : 'http://');       // scheme
-       $script .= SERVER_NAME; // host
-       $script .= (SERVER_PORT == 80 ? '' : ':' . SERVER_PORT); // port
+               // Init automatically
+               $msg     = 'get_script_uri() failed: Please set $script at INI_FILE manually';
+               $script  = (SERVER_PORT == 443 ? 'https://' : 'http://'); // scheme
+               $script .= SERVER_NAME; // host
+               $script .= (SERVER_PORT == 80 ? '' : ':' . SERVER_PORT);  // port
 
-       // SCRIPT_NAME ¤¬'/'¤Ç»Ï¤Þ¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç(cgi¤Ê¤É) REQUEST_URI¤ò»È¤Ã¤Æ¤ß¤ë
-       $path    = SCRIPT_NAME;
-       if ($path{0} != '/') {
-               if (! isset($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI']{0} != '/')
-                       return FALSE;
+               // SCRIPT_NAME ¤¬'/'¤Ç»Ï¤Þ¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç(cgi¤Ê¤É) REQUEST_URI¤ò»È¤Ã¤Æ¤ß¤ë
+               $path    = SCRIPT_NAME;
+               if ($path{0} != '/') {
+                       if (! isset($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI']{0} != '/')
+                               die_message($msg);
 
-               // REQUEST_URI¤ò¥Ñ¡¼¥¹¤·¡¢pathÉôʬ¤À¤±¤ò¼è¤ê½Ð¤¹
-               $parse_url = parse_url($script.$_SERVER['REQUEST_URI']);
-               if (! isset($parse_url['path']) || $parse_url['path']{0} != '/')
-                       return FALSE;
+                       // REQUEST_URI¤ò¥Ñ¡¼¥¹¤·¡¢pathÉôʬ¤À¤±¤ò¼è¤ê½Ð¤¹
+                       $parse_url = parse_url($script . $_SERVER['REQUEST_URI']);
+                       if (! isset($parse_url['path']) || $parse_url['path']{0} != '/')
+                               die_message($msg);
 
-               $path = $parse_url['path'];
-       }
-       $script .= $path;       // path
+                       $path = $parse_url['path'];
+               }
+               $script .= $path; // path
+               if (! is_url($script, TRUE) && php_sapi_name() == 'cgi')
+                       die_message($msg);
+
+       } else {
+               // Init manually
+               if (isset($script))
+                       die_message('$script: Already init');
 
+               if(is_url($init_uri, TRUE)) {
+                       $script = $uri;
+               } else {
+                       die_message('$script: Invalid URI');
+               }
+       }
        return $script;
 }
 
index f645259..e9a0a24 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: init.php,v 1.11 2004/10/10 03:36:27 henoheno Exp $
+// $Id: init.php,v 1.12 2004/10/11 03:13:09 henoheno Exp $
 //
 
 /////////////////////////////////////////////////
@@ -79,10 +79,13 @@ $weeklabels = $_msg_week;
 
 /////////////////////////////////////////////////
 // INI_FILE: $script: ½é´üÀßÄê
-if (! isset($script) || $script == '') {
+
+if (isset($script)) {
+       // Init manually
+       get_script_uri($script);
+} else {
+       // Init automatically
        $script = get_script_uri();
-       if ($script === FALSE || (php_sapi_name() == 'cgi' && ! is_url($script, TRUE)))
-               die_message('get_script_uri() failed: Please set $script at INI_FILE manually.');
 }
 
 /////////////////////////////////////////////////