OSDN Git Service

Cleanup. Shrink string quotation.
authorhenoheno <henoheno>
Fri, 31 Dec 2004 10:51:47 +0000 (19:51 +0900)
committerhenoheno <henoheno>
Fri, 31 Dec 2004 10:51:47 +0000 (19:51 +0900)
count() => empty(). Added spaces.

lib/auth.php

index 5d8c34e..a0d3eed 100644 (file)
@@ -1,9 +1,8 @@
 <?php
-/////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
+// $Id: auth.php,v 1.6 2004/12/31 10:51:47 henoheno Exp $
 //
-// $Id: auth.php,v 1.5 2004/12/25 00:11:27 henoheno Exp $
-//
+// Basic authentication related functions
 
 // ÊÔ½¸ÉÔ²Äǽ¤Ê¥Ú¡¼¥¸¤òÊÔ½¸¤·¤è¤¦¤È¤·¤¿¤È¤­
 function check_editable($page, $auth_flag = TRUE, $exit_flag = TRUE)
@@ -17,10 +16,9 @@ function check_editable($page, $auth_flag = TRUE, $exit_flag = TRUE)
 
        $body = $title = str_replace('$1', htmlspecialchars(strip_bracket($page)), $_title_cannotedit);
 
-       if (is_freeze($page)) {
-               $body .= "(<a href=\"$script?cmd=unfreeze&amp;page=".
-                       rawurlencode($page)."\">$_msg_unfreeze</a>)";
-       }
+       if (is_freeze($page))
+               $body .= '(<a href="' . $script . '?cmd=unfreeze&amp;page=' .
+                       rawurlencode($page) . '">' . $_msg_unfreeze . '</a>)';
 
        $page = str_replace('$1', make_search($page), $_title_cannotedit);
 
@@ -39,9 +37,8 @@ function edit_auth($page, $auth_flag = TRUE, $exit_flag = TRUE)
 {
        global $edit_auth, $edit_auth_pages, $_title_cannotedit;
 
-       // ÊÔ½¸Ç§¾Ú¥Õ¥é¥°¤ò¥Á¥§¥Ã¥¯
-       return $edit_auth ?
-               basic_auth($page, $auth_flag, $exit_flag, $edit_auth_pages, $_title_cannotedit) : TRUE;
+       return $edit_auth ?  basic_auth($page, $auth_flag, $exit_flag,
+               $edit_auth_pages, $_title_cannotedit) : TRUE;
 }
 
 // ±ÜÍ÷ǧ¾Ú
@@ -49,12 +46,11 @@ function read_auth($page, $auth_flag = TRUE, $exit_flag = TRUE)
 {
        global $read_auth, $read_auth_pages, $_title_cannotread;
 
-       // ±ÜÍ÷ǧ¾Ú¥Õ¥é¥°¤ò¥Á¥§¥Ã¥¯
-       return $read_auth ?
-               basic_auth($page, $auth_flag, $exit_flag, $read_auth_pages, $_title_cannotread) : TRUE;
+       return $read_auth ?  basic_auth($page, $auth_flag, $exit_flag,
+               $read_auth_pages, $_title_cannotread) : TRUE;
 }
 
-// Basicǧ¾Ú
+// Basic authentication
 function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot)
 {
        global $auth_users, $auth_method_type;
@@ -72,22 +68,22 @@ function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot)
 
        // ¹çÃפ·¤¿¥Ñ¥¿¡¼¥ó¤ÇÄêµÁ¤µ¤ì¤¿¥æ¡¼¥¶¤Î¥ê¥¹¥È
        $user_list = array();
-       foreach($auth_pages as $key=>$val) {
+       foreach($auth_pages as $key=>$val)
                if (preg_match($key, $target_str))
                        $user_list = array_merge($user_list, explode(',', $val));
-       }
 
-       if (count($user_list) == 0) return TRUE; // À©¸Â¤Ê¤·
+       if (empty($user_list)) return TRUE; // No limit
 
        // PHP_AUTH* ÊÑ¿ô¤¬Ì¤ÄêµÁ¤Î¾ì¹ç
        $matches = array();
-       if (!isset($_SERVER['PHP_AUTH_USER'])
+       if (! isset($_SERVER['PHP_AUTH_USER'])
                && ! isset($_SERVER ['PHP_AUTH_PW'])
                && isset($_SERVER['HTTP_AUTHORIZATION'])
                && preg_match('/^Basic (.*)$/', $_SERVER['HTTP_AUTHORIZATION'], $matches))
        {
                // HTTP_AUTHORIZATION ÊÑ¿ô¤ò»ÈÍѤ·¤¿ Basic Ç§¾Ú
-               list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode($matches[1]));
+               list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
+                       explode(':', base64_decode($matches[1]));
        }
 
        // ¥æ¡¼¥¶¥ê¥¹¥È¤Ë´Þ¤Þ¤ì¤ë¤¤¤º¤ì¤«¤Î¥æ¡¼¥¶¤Èǧ¾Ú¤µ¤ì¤ì¤ÐOK
@@ -98,11 +94,12 @@ function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot)
        {
                pkwk_common_headers();
                if ($auth_flag) {
-                       header('WWW-Authenticate: Basic realm="'.$_msg_auth.'"');
+                       header('WWW-Authenticate: Basic realm="' . $_msg_auth . '"');
                        header('HTTP/1.0 401 Unauthorized');
                }
                if ($exit_flag) {
-                       $body = $title = str_replace('$1', htmlspecialchars(strip_bracket($page)), $title_cannot);
+                       $body = $title = str_replace('$1',
+                               htmlspecialchars(strip_bracket($page)), $title_cannot);
                        $page = str_replace('$1', make_search($page), $title_cannot);
                        catbody($title, $page, $body);
                        exit;