diff -urN pukiwiki-1_5_0_utf8/cache/3A636F6E6669672F5061676552656164696E67.rel pukiwiki_1_5_1-beta1-f502_utf8/cache/3A636F6E6669672F5061676552656164696E67.rel --- pukiwiki-1_5_0_utf8/cache/3A636F6E6669672F5061676552656164696E67.rel 2006-06-04 13:34:41.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/cache/3A636F6E6669672F5061676552656164696E67.rel 2014-11-26 01:40:37.000000000 +0900 @@ -1 +1 @@ -PageReading :config/PageReading/dict :config/plugin/attach/mime-type :config/plugin/referer/config :config/plugin/tracker/default :config/plugin/tracker/default/form :config/plugin/tracker/default/list :config/plugin/tracker/default/page BracketName FormattingRules FrontPage Help InterWiki InterWikiName InterWikiSandBox MenuBar PHP PukiWiki RecentChanges SandBox WikiEngines WikiName WikiWikiWeb YukiWiki \ No newline at end of file +PageReading :config/PageReading/dict :config/plugin/attach/mime-type :config/plugin/tracker/default :config/plugin/tracker/default/form :config/plugin/tracker/default/list :config/plugin/tracker/default/page BracketName FormattingRules FrontPage Help InterWiki InterWikiName InterWikiSandBox MenuBar PHP PukiWiki RecentChanges SandBox WikiEngines WikiName WikiWikiWeb YukiWiki \ No newline at end of file diff -urN pukiwiki-1_5_0_utf8/cache/50756B6957696B692F312E342F4D616E75616C2F506C7567696E2F4F2D52.rel pukiwiki_1_5_1-beta1-f502_utf8/cache/50756B6957696B692F312E342F4D616E75616C2F506C7567696E2F4F2D52.rel --- pukiwiki-1_5_0_utf8/cache/50756B6957696B692F312E342F4D616E75616C2F506C7567696E2F4F2D52.rel 2006-06-04 13:34:41.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/cache/50756B6957696B692F312E342F4D616E75616C2F506C7567696E2F4F2D52.rel 2014-11-26 01:40:37.000000000 +0900 @@ -1 +1 @@ -PukiWiki MenuBar FrontPage PukiWiki/1.4/Manual/Plugin/A-D InterWiki RecentChanges WikiName BracketName RenameLog TrackBack \ No newline at end of file +PukiWiki MenuBar FrontPage PukiWiki/1.4/Manual/Plugin/A-D InterWiki RecentChanges WikiName BracketName RenameLog \ No newline at end of file diff -urN pukiwiki-1_5_0_utf8/cache/50756B6957696B692F312E342F4D616E75616C2F506C7567696E2F532D55.rel pukiwiki_1_5_1-beta1-f502_utf8/cache/50756B6957696B692F312E342F4D616E75616C2F506C7567696E2F532D55.rel --- pukiwiki-1_5_0_utf8/cache/50756B6957696B692F312E342F4D616E75616C2F506C7567696E2F532D55.rel 2006-06-04 13:34:41.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/cache/50756B6957696B692F312E342F4D616E75616C2F506C7567696E2F532D55.rel 2014-11-26 01:40:37.000000000 +0900 @@ -1 +1 @@ -PukiWiki PukiWiki/1.4/Manual/Plugin/A-D MenuBar TrackBack \ No newline at end of file +PukiWiki PukiWiki/1.4/Manual/Plugin/A-D MenuBar \ No newline at end of file diff -urN pukiwiki-1_5_0_utf8/cache/recent.dat pukiwiki_1_5_1-beta1-f502_utf8/cache/recent.dat --- pukiwiki-1_5_0_utf8/cache/recent.dat 2014-07-13 13:03:57.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/cache/recent.dat 1970-01-01 09:00:00.000000000 +0900 @@ -1,25 +0,0 @@ -1136849896 FrontPage -1136845400 InterWiki -1136836572 Help -1136836496 FormattingRules -1136835756 BracketName -1136835734 PukiWiki -1136835670 SandBox -1136835670 WikiEngines -1136835670 WikiWikiWeb -1136835670 WikiName -1136835670 YukiWiki -1136835669 PukiWiki/1.4/Manual/Plugin/S-U -1136835669 PukiWiki/1.4/Manual/Plugin/V-Z -1136835669 PukiWiki/1.4/Manual/Plugin/O-R -1136835669 PukiWiki/1.4/Manual/Plugin/A-D -1136835669 PukiWiki/1.4/Manual/Plugin/L-N -1136835669 PukiWiki/1.4/Manual/Plugin/E-G -1136835669 PukiWiki/1.4/Manual/Plugin/H-K -1136835668 PHP -1136835668 InterWikiName -1136835668 InterWikiSandBox -1136835668 PukiWiki/1.4/Manual -1136835668 PukiWiki/1.4/Manual/Plugin -1136835668 PukiWiki/1.4 -1136835668 MenuBar diff -urN pukiwiki-1_5_0_utf8/en.lng.php pukiwiki_1_5_1-beta1-f502_utf8/en.lng.php --- pukiwiki-1_5_0_utf8/en.lng.php 2014-07-13 13:03:57.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/en.lng.php 2016-02-13 03:40:31.000000000 +0900 @@ -1,8 +1,8 @@ The comment was added, alhough it may be inserted in the wrong position.
'; +$_comment_plugin_fail_msg = 'It seems that someone has already updated the page you were editing.
+ Failed to add the comment.
'; /////////////////////////////////////// // deleted.inc.php @@ -330,19 +329,6 @@
%s
'; /////////////////////////////////////// -// referer.inc.php -$_referer_msg = array( - 'msg_H0_Refer' => 'Referer', - 'msg_Hed_LastUpdate' => 'LastUpdate', - 'msg_Hed_1stDate' => 'First Register', - 'msg_Hed_RefCounter' => 'RefCounter', - 'msg_Hed_Referer' => 'Referer', - 'msg_Fmt_Date' => 'F j, Y, g:i A', - 'msg_Chr_uarr' => '⇑', - 'msg_Chr_darr' => '⇓', -); - -/////////////////////////////////////// // rename.inc.php $_rename_messages = array( 'err' => '

error:%s

', @@ -440,4 +426,12 @@ // yetlist.inc.php $_title_yetlist = 'List of pages which have not yet been created.'; $_err_notexist = 'All pages have been created.'; -?> + +/////////////////////////////////////// +// loginform.inc.php +$_loginform_messages = array( + 'username' => 'Username', + 'password' => 'Password', + 'login' => 'Log in', + 'invalid_username_or_password' => 'The username or password you entered is incorrect' +); diff -urN pukiwiki-1_5_0_utf8/.gitignore pukiwiki_1_5_1-beta1-f502_utf8/.gitignore --- pukiwiki-1_5_0_utf8/.gitignore 1970-01-01 09:00:00.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/.gitignore 2016-01-11 01:22:46.000000000 +0900 @@ -0,0 +1,19 @@ +/wiki +/attach +/backup +/cache +/counter +/diff + +/attach/*.[0-9] +/attach/*.log +/backup/*.gz +/cache/*.ref +/cache/*.rel +/counter/*.count +/diff/*.txt +/wiki/*.txt +/wiki.en/*.txt + +/nbproject/** + diff -urN pukiwiki-1_5_0_utf8/INSTALL.txt pukiwiki_1_5_1-beta1-f502_utf8/INSTALL.txt --- pukiwiki-1_5_0_utf8/INSTALL.txt 2014-07-13 13:03:56.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/INSTALL.txt 2016-02-08 03:09:10.000000000 +0900 @@ -1,14 +1,12 @@ 名前 PukiWiki - 自由にページを追加・削除・編集できるWebページ構築スクリプト - Version 1.5.0 - Copyright (C) - 2001-2005 PukiWiki Developers Team + Version 1.5.1 + Copyright + 2001-2016 PukiWiki Development Team 2001-2002 yu-ji (Based on PukiWiki 1.3 by yu-ji) License: GPL version 2 or (at your option) any later version - $Id: INSTALL.txt,v 1.8 2005/12/06 14:59:29 henoheno Exp $ - インストール PukiWikiはPHPスクリプトであるため、(例えばPerlのように)スクリプトに実行権 を付ける必要はありません。CGI起動でないのであれば、スクリプトの一行目を修 @@ -18,7 +16,7 @@ まサーバーに転送し、サーバー上で解凍(tar pzxf pukiwiki*.tar.gz) するだけ でパーミッションの設定も行われ、すぐに使い始める事ができるでしょう。 - スクリプトの中の日本語は(あれば、基本的に)EUC-JPで、また改行コードはLFで + スクリプトの中の日本語は(あれば、基本的に)UTF-8で、また改行コードはLFで 記述されています。スクリプトを直接編集する場合は、日本語文字コードと改行 コードの自動判別ができ、それを元のまま保存できるテキストエディタを使用し て下さい。 @@ -77,7 +75,6 @@ lib 755 ライブラリ plugin 755 プラグイン skin 755 スキン、CSS、JavaScirptファイル - trackback 777 TrackBackファイル格納ディレクトリ wiki 777 データの格納ディレクトリ ファイル パーミッション データの種類(参考) @@ -178,7 +175,7 @@ バックアップとリストア ページの最新データを収めているディレクトリ(デフォルトの名前は wiki)以下 を、また必要に応じて他のデータを収めているディレクトリ以下をバックアップし - て下さい。(同 attach, backup, cache, counter, diff, trackback) + て下さい。(同 attach, backup, cache, counter, diff) cacheディレクトリもバックアップすることをお薦めします。 1. cache/*.rel ファイルと cache/*.ref ファイルは linksプラグイン で再生 diff -urN pukiwiki-1_5_0_utf8/ja.lng.php pukiwiki_1_5_1-beta1-f502_utf8/ja.lng.php --- pukiwiki-1_5_0_utf8/ja.lng.php 2014-07-13 13:03:56.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/ja.lng.php 2016-02-13 03:40:31.000000000 +0900 @@ -1,8 +1,8 @@ コメントを追加しましたが、違う位置に挿入されているかもしれません。
'; +$_comment_plugin_fail_msg = 'あなたがこのページを編集している間に、他の人が同じページを更新してしまったようです。
+コメントの追加に失敗しました。
'; /////////////////////////////////////// // deleted.inc.php @@ -332,19 +331,6 @@
%s
'; /////////////////////////////////////// -// referer.inc.php -$_referer_msg = array( - 'msg_H0_Refer' => 'リンク元の表示', - 'msg_Hed_LastUpdate' => '最終更新日時', - 'msg_Hed_1stDate' => '初回登録日時', - 'msg_Hed_RefCounter' => 'カウンタ', - 'msg_Hed_Referer' => 'Referer', - 'msg_Fmt_Date' => 'Y年n月j日 H:i', - 'msg_Chr_uarr' => '↑', - 'msg_Chr_darr' => '↓', -); - -/////////////////////////////////////// // rename.inc.php $_rename_messages = array( 'err' => '

エラー:%s

', @@ -442,4 +428,12 @@ // yetlist.inc.php $_title_yetlist = '未作成のページ一覧'; $_err_notexist = '未作成のページはありません。'; -?> + +/////////////////////////////////////// +// loginform.inc.php +$_loginform_messages = array( + 'username' => 'ユーザー名:', + 'password' => 'パスワード:', + 'login' => 'ログイン', + 'invalid_username_or_password' => 'ユーザー名またはパスワードが違います' +); diff -urN pukiwiki-1_5_0_utf8/lib/auth.php pukiwiki_1_5_1-beta1-f502_utf8/lib/auth.php --- pukiwiki-1_5_0_utf8/lib/auth.php 2014-07-13 13:03:57.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/lib/auth.php 2016-02-13 09:45:44.000000000 +0900 @@ -8,6 +8,18 @@ define('PKWK_PASSPHRASE_LIMIT_LENGTH', 512); +///////////////////////////////////////////////// +// Auth type + +define('AUTH_TYPE_NONE', 0); +define('AUTH_TYPE_BASIC', 1); +define('AUTH_TYPE_EXTERNAL', 2); +define('AUTH_TYPE_FORM', 3); + +define('AUTH_TYPE_EXTERNAL_REMOTE_USER', 4); +define('AUTH_TYPE_EXTERNAL_X_FORWARDED_USER', 5); + + // Passwd-auth related ---- function pkwk_login($pass = '') @@ -168,8 +180,8 @@ // Basic authentication function basic_auth($page, $auth_flag, $exit_flag, $auth_pages, $title_cannot) { - global $auth_method_type, $auth_users, $_msg_auth; - + global $auth_method_type, $auth_users, $_msg_auth, $auth_user, $auth_groups; + global $auth_user_groups, $auth_type, $g_query_string; // Checked by: $target_str = ''; if ($auth_method_type == 'pagename') { @@ -186,31 +198,29 @@ if (empty($user_list)) return TRUE; // No limit $matches = array(); - if (! isset($_SERVER['PHP_AUTH_USER']) && - ! isset($_SERVER ['PHP_AUTH_PW']) && - isset($_SERVER['HTTP_AUTHORIZATION']) && - preg_match('/^Basic (.*)$/', $_SERVER['HTTP_AUTHORIZATION'], $matches)) - { - - // Basic-auth with $_SERVER['HTTP_AUTHORIZATION'] - list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = - explode(':', base64_decode($matches[1])); - } - if (PKWK_READONLY || - ! isset($_SERVER['PHP_AUTH_USER']) || - ! in_array($_SERVER['PHP_AUTH_USER'], $user_list) || - ! isset($auth_users[$_SERVER['PHP_AUTH_USER']]) || - pkwk_hash_compute( - $_SERVER['PHP_AUTH_PW'], - $auth_users[$_SERVER['PHP_AUTH_USER']] - ) !== $auth_users[$_SERVER['PHP_AUTH_USER']]) + ! $auth_user || + count(array_intersect($auth_user_groups, $user_list)) === 0) { // Auth failed pkwk_common_headers(); - if ($auth_flag) { - header('WWW-Authenticate: Basic realm="' . $_msg_auth . '"'); - header('HTTP/1.0 401 Unauthorized'); + if ($auth_flag && !$auth_user) { + if (AUTH_TYPE_BASIC === $auth_type) { + header('WWW-Authenticate: Basic realm="' . $_msg_auth . '"'); + header('HTTP/1.0 401 Unauthorized'); + } elseif (AUTH_TYPE_FORM === $auth_type) { + $url_after_login = get_script_uri() . '?' . $g_query_string; + $loginurl = get_script_uri() . '?plugin=loginform' + . '&page=' . rawurlencode($page) + . '&url_after_login=' . rawurlencode($url_after_login); + header('HTTP/1.0 302 Found'); + header('Location: ' . $loginurl); + } elseif (AUTH_TYPE_EXTERNAL === $auth_type) { + $url_after_login = get_script_uri() . '?' . $g_query_string; + $loginurl = get_auth_external_login_url($page, $url_after_login); + header('HTTP/1.0 302 Found'); + header('Location: ' . $loginurl); + } } if ($exit_flag) { $body = $title = str_replace('$1', @@ -224,4 +234,293 @@ return TRUE; } } -?> + +/** + * Send 401 if client send a invalid credentials + * + * @return true if valid, false if invalid credentials + */ +function ensure_valid_auth_user() +{ + global $auth_type, $auth_users, $_msg_auth, $auth_user, $auth_groups; + global $auth_user_groups, $auth_user_fullname; + global $ldap_user_account; + global $read_auth, $edit_auth; + if ($read_auth || $edit_auth) { + switch ($auth_type) { + case AUTH_TYPE_BASIC: + case AUTH_TYPE_FORM: + case AUTH_TYPE_EXTERNAL: + case AUTH_TYPE_EXTERNAL_REMOTE_USER: + case AUTH_TYPE_EXTERNAL_X_FORWARDED_USER: + break; + default: + // $auth_type is not valid, Set form auth as default + $auth_type = AUTH_TYPE_FORM; + } + } + switch ($auth_type) { + case AUTH_TYPE_BASIC: + { + if (isset($_SERVER['PHP_AUTH_USER'])) { + $user = $_SERVER['PHP_AUTH_USER']; + if (in_array($user, array_keys($auth_users))) { + if (pkwk_hash_compute( + $_SERVER['PHP_AUTH_PW'], + $auth_users[$user]) === $auth_users[$user]) { + $auth_user = $user; + $auth_user_fullname = $auth_user; + $auth_user_groups = get_groups_from_username($user); + return true; + } + } + header('WWW-Authenticate: Basic realm="' . $_msg_auth . '"'); + header('HTTP/1.0 401 Unauthorized'); + } + $auth_user = ''; + $auth_user_groups = get_groups_from_username($user); + return true; // no auth input + } + case AUTH_TYPE_FORM: + case AUTH_TYPE_EXTERNAL: + { + session_start(); + $user = ''; + $fullname = ''; + if (isset($_SESSION['authenticated_user'])) { + $user = $_SESSION['authenticated_user']; + if (isset($_SESSION['authenticated_user_fullname'])) { + $fullname = $_SESSION['authenticated_user_fullname']; + } else { + $fullname = $user; + if ($auth_type === AUTH_TYPE_EXTERNAL && $ldap_user_account) { + $ldap_user_info = ldap_get_simple_user_info($user); + if ($ldap_user_info) { + $fullname = $ldap_user_info['fullname']; + } + } + $_SESSION['authenticated_user_fullname'] = $fullname; + } + } + $auth_user = $user; + $auth_user_fullname = $fullname; + break; + } + case AUTH_TYPE_EXTERNAL_REMOTE_USER: + $auth_user = $_SERVER['REMOTE_USER']; + $auth_user_fullname = $auth_user; + break; + case AUTH_TYPE_EXTERNAL_X_FORWARDED_USER: + $auth_user = $_SERVER['HTTP_X_FORWARDED_USER']; + $auth_user_fullname = $auth_user; + break; + default: // AUTH_TYPE_NONE + $auth_user = ''; + $auth_user_fullname = ''; + break; + } + $auth_user_groups = get_groups_from_username($auth_user); + return true; // is not basic auth +} + +/** + * Return group name array whose group contains the user + * + * Result array contains reserved 'valid-user' group for all authenticated user + * @global array $auth_groups + * @param string $user + * @return array + */ +function get_groups_from_username($user) +{ + global $auth_groups; + if ($user !== '') { + $groups = array(); + foreach ($auth_groups as $group=>$users) { + $sp = explode(',', $users); + if (in_array($user, $sp)) { + $groups[] = $group; + } + } + // Implecit group that has same name as user itself + $groups[] = $user; + // 'valid-user' group for + $valid_user = 'valid-user'; + if (!in_array($valid_user, $groups)) { + $groups[] = $valid_user; + } + return $groups; + } + return array(); +} + +/** + * Get authenticated user name. + * + * @global type $auth_user + * @return type + */ +function get_auth_user() +{ + global $auth_user; + return $auth_user; +} + +/** + * Sign in with username and password + * + * @param String username + * @param String password + * @return true is sign in is OK + */ +function form_auth($username, $password) +{ + global $ldap_user_account, $auth_users; + $user = $username; + if ($ldap_user_account) { + // LDAP account + return ldap_auth($username, $password); + } else { + // Defined users in pukiwiki.ini.php + if (in_array($user, array_keys($auth_users))) { + if (pkwk_hash_compute( + $password, + $auth_users[$user]) === $auth_users[$user]) { + session_start(); + session_regenerate_id(true); // require: PHP5.1+ + $_SESSION['authenticated_user'] = $user; + $_SESSION['authenticated_user_fullname'] = $user; + return true; + } + } + } + return false; +} + +function ldap_auth($username, $password) +{ + global $ldap_server, $ldap_base_dn, $ldap_bind_dn, $ldap_bind_password; + $ldapconn = ldap_connect($ldap_server); + if ($ldapconn) { + ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); + ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0); + if (preg_match('#\$login\b#', $ldap_bind_dn)) { + // Bind by user credential + $bind_dn_user = preg_replace('#\$login#', $username, $ldap_bind_dn); + $ldap_bind_user = ldap_bind($ldapconn, $bind_dn_user, $password); + if ($ldap_bind_user) { + $user_info = get_ldap_user_info($ldapconn, $username, $ldap_base_dn); + if ($user_info) { + session_regenerate_id(true); // require: PHP5.1+ + $_SESSION['authenticated_user'] = $user_info['uid']; + $_SESSION['authenticated_user_fullname'] = $user_info['fullname']; + return true; + } + } + } else { + // Bind by bind dn + $ldap_bind = ldap_bind($ldapconn, $ldap_bind_dn, $ldap_bind_password); + if ($ldap_bind) { + $user_info = get_ldap_user_info($ldapconn, $username, $ldap_base_dn); + if ($user_info) { + $ldap_bind_user2 = ldap_bind($ldapconn, $user_info['dn'], $password); + if ($ldap_bind_user2) { + session_regenerate_id(true); // require: PHP5.1+ + $_SESSION['authenticated_user'] = $user_info['uid']; + $_SESSION['authenticated_user_fullname'] = $user_info['fullname']; + return true; + } + } + } + } + } + return false; +} + +// Get LDAP user info via bind DN +function ldap_get_simple_user_info($username) +{ + global $ldap_server, $ldap_base_dn, $ldap_bind_dn, $ldap_bind_password; + $ldapconn = ldap_connect($ldap_server); + if ($ldapconn) { + ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); + ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0); + // Bind by bind dn + $ldap_bind = ldap_bind($ldapconn, $ldap_bind_dn, $ldap_bind_password); + if ($ldap_bind) { + $user_info = get_ldap_user_info($ldapconn, $username, $ldap_base_dn); + if ($user_info) { + return $user_info; + } + } + } + return false; +} + +/** + * Search user and get 'dn', 'uid', 'fullname' and 'mail' + * @param type $ldapconn + * @param type $username + * @param type $base_dn + * @return boolean + */ +function get_ldap_user_info($ldapconn, $username, $base_dn) { + $filter = "(|(uid=$username)(sAMAccountName=$username))"; + $result1 = ldap_search($ldapconn, $base_dn, $filter, array('dn', 'uid', 'cn', 'samaccountname', 'displayname', 'mail')); + $entries = ldap_get_entries($ldapconn, $result1); + $info = $entries[0]; + if (isset($info['dn'])) { + $user_dn = $info['dn']; + $cano_username = $username; + if (isset($info['uid'][0])) { + $cano_username = $info['uid'][0]; + } elseif (isset($info['samaccountname'][0])) { + $cano_username = $info['samaccountname'][0]; + } + $cano_fullname = $username; + if (isset($info['displayname'][0])) { + $cano_fullname = $info['displayname'][0]; + } elseif (isset($info['cn'][0])) { + $cano_fullname = $info['cn'][0]; + } + return array( + 'dn' => $user_dn, + 'uid' => $cano_username, + 'fullname' => $cano_fullname, + 'mail' => $info['mail'][0] + ); + } + return false; +} + +/** + * Redirect after login. Need to assing location or page + * + * @param type $location + * @param type $page + */ +function form_auth_redirect($location, $page) +{ + header('HTTP/1.0 302 Found'); + if ($location) { + header('Location: ' . $location); + } else { + $url = get_script_uri() . '?' . $page; + header('Location: ' . $url); + } +} + +/** + * Get External Auth log-in URL + */ +function get_auth_external_login_url($page, $url_after_login) { + global $auth_external_login_url_base; + $sep = '&'; + if (strpos($auth_external_login_url_base, '?') === FALSE) { + $sep = '?'; + } + $url = $auth_external_login_url_base . $sep + . 'page=' . rawurlencode($page) + . '&url_after_login=' . rawurlencode($url_after_login); + return $url; +} diff -urN pukiwiki-1_5_0_utf8/lib/backup.php pukiwiki_1_5_1-beta1-f502_utf8/lib/backup.php --- pukiwiki-1_5_0_utf8/lib/backup.php 2014-07-13 13:03:57.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/lib/backup.php 2016-02-08 02:26:50.000000000 +0900 @@ -11,9 +11,8 @@ * @access public * @author * @create - * @version $Id: backup.php,v 1.13 2011/01/25 15:01:01 henoheno Exp $ * Copyright (C) - * 2002-2006 PukiWiki Developers Team + * 2002-2016 PukiWiki Development Team * 2001-2002 Originally written by yu-ji * License: GPL v2 or (at your option) any later version **/ @@ -29,14 +28,15 @@ * @return Void */ -function make_backup($page, $delete = FALSE) +function make_backup($page, $is_delete, $wikitext) { global $cycle, $maxage; global $do_backup, $del_backup; + global $auth_user; if (PKWK_READONLY || ! $do_backup) return; - if ($del_backup && $delete) { + if ($del_backup && $is_delete) { _backup_delete($page); return; } @@ -44,11 +44,25 @@ if (! is_page($page)) return; $lastmod = _backup_get_filetime($page); - if ($lastmod == 0 || UTIME - $lastmod > 60 * 60 * $cycle) + $backups = get_backup($page); + $is_author_differ = false; + $need_backup_by_time = $lastmod == 0 || UTIME - $lastmod > 60 * 60 * $cycle; + if (!$need_backup_by_time) { + // Backup file is saved recently, but the author may differ. + $last_content = get_source($page, TRUE, TRUE); + $m = array(); + $prev_author = null; + if (preg_match('/^#author\("([^"]+)","([^"]*)","([^"]*)"\)/m', $last_content, $m)) { + $prev_author = preg_replace('/^[^:]+:/', '', $m[2]); + } + if ($prev_author !== $auth_user) { + $is_author_differ = true; + } + } + if ($need_backup_by_time || $is_author_differ || $is_delete) { $backups = get_backup($page); $count = count($backups) + 1; - // 直後に1件追加するので、(最大件数 - 1)を超える要素を捨てる if ($count > $maxage) array_splice($backups, 0, $count - $maxage); @@ -65,12 +79,17 @@ $body = preg_replace('/^(' . preg_quote(PKWK_SPLITTER) . "\s\d+)$/", '$1 ', get_source($page)); $body = PKWK_SPLITTER . ' ' . get_filetime($page) . "\n" . join('', $body); $body = preg_replace("/\n*$/", "\n", $body); - + $body_on_delete = ''; + if ($is_delete) { + $body_on_delete = PKWK_SPLITTER . ' ' . UTIME . "\n" . $wikitext; + $body_on_delete = preg_replace("/\n*$/", "\n", $body_on_delete); + } $fp = _backup_fopen($page, 'wb') or die_message('Cannot open ' . htmlsc(_backup_get_filename($page)) . '
Maybe permission is not writable or filename is too long'); _backup_fputs($fp, $strout); _backup_fputs($fp, $body); + _backup_fputs($fp, $body_on_delete); _backup_fclose($fp); } } @@ -105,6 +124,11 @@ // Allocate $retvars[$_age] = array('time'=>$match[1], 'data'=>array()); + } else if (preg_match('/^\s*#author\("([^"]+)","([^"]+)","([^"]*)"\)/', $line, $match)) { + $retvars[$_age]['author_datetime'] = $match[1]; + $retvars[$_age]['author'] = $match[2]; + $retvars[$_age]['author_fullname'] = $match[3]; + $retvars[$_age]['data'][] = $line; } else { // The first ... the last line of the data $retvars[$_age]['data'][] = $line; @@ -306,4 +330,3 @@ array(); } } -?> diff -urN pukiwiki-1_5_0_utf8/lib/config.php pukiwiki_1_5_1-beta1-f502_utf8/lib/config.php --- pukiwiki-1_5_0_utf8/lib/config.php 2014-07-13 13:03:57.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/lib/config.php 2016-01-04 12:19:26.000000000 +0900 @@ -39,7 +39,7 @@ if (! is_page($this->page)) return FALSE; $this->objs = array(); - $obj = & new ConfigTable(''); + $obj = new ConfigTable(''); $matches = array(); foreach (get_source($this->page) as $line) { @@ -57,22 +57,22 @@ if ($level == 1) { $this->objs[$obj->title] = $obj; - $obj = & new ConfigTable($line); + $obj = new ConfigTable($line); } else { if (! is_a($obj, 'ConfigTable_Direct')) - $obj = & new ConfigTable_Direct('', $obj); + $obj = new ConfigTable_Direct('', $obj); $obj->set_key($line); } } else if ($head == '-' && $level > 1) { if (! is_a($obj, 'ConfigTable_Direct')) - $obj = & new ConfigTable_Direct('', $obj); + $obj = new ConfigTable_Direct('', $obj); $obj->add_value($line); } else if ($head == '|' && preg_match('/^\|(.+)\|\s*$/', $line, $matches)) { // Table row if (! is_a($obj, 'ConfigTable_Sequential')) - $obj = & new ConfigTable_Sequential('', $obj); + $obj = new ConfigTable_Sequential('', $obj); // Trim() each table cell $obj->add_value(array_map('trim', explode('|', $matches[1]))); } else { @@ -109,7 +109,7 @@ function & get_object($title) { if (! isset($this->objs[$title])) - $this->objs[$title] = & new ConfigTable('*' . trim($title) . "\n"); + $this->objs[$title] = new ConfigTable('*' . trim($title) . "\n"); return $this->objs[$title]; } @@ -221,4 +221,4 @@ return $retval; } } -?> + diff -urN pukiwiki-1_5_0_utf8/lib/convert_html.php pukiwiki_1_5_1-beta1-f502_utf8/lib/convert_html.php --- pukiwiki-1_5_0_utf8/lib/convert_html.php 2014-07-13 13:03:57.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/lib/convert_html.php 2016-01-04 12:19:26.000000000 +0900 @@ -19,7 +19,7 @@ if (! is_array($lines)) $lines = explode("\n", $lines); - $body = & new Body(++$contents_id); + $body = new Body(++$contents_id); $body->parse($lines); return $body->toString(); @@ -191,7 +191,7 @@ function & toPara($class = '') { - $obj = & new Paragraph('', $class); + $obj = new Paragraph('', $class); $obj->insert($this); return $obj; } @@ -572,7 +572,7 @@ $is_template = ($this->type == 'c'); $row = array(); foreach ($cells as $cell) - $row[] = & new TableCell($cell, $is_template); + $row[] = new TableCell($cell, $is_template); $this->elements[] = $row; } @@ -654,46 +654,61 @@ } } -// , title1 , title2 , title3 -// , cell1 , cell2 , cell3 -// , cell4 , cell5 , cell6 +// , cell1 , cell2 , cell3 +// , cell4 , cell5 , cell6 +// , cell7 , right,== +// ,left ,==, cell8 class YTable extends Element { - var $col; + var $col; // Number of columns - function YTable($_value) + // TODO: Seems unable to show literal '==' without tricks. + // But it will be imcompatible. + // TODO: Why toString() or toXHTML() here + function YTable($row = array('cell1 ', ' cell2 ', ' cell3')) { parent::Element(); - $align = $value = $matches = array(); - foreach($_value as $val) { - if (preg_match('/^(\s+)?(.+?)(\s+)?$/', $val, $matches)) { - $align[] =($matches[1] != '') ? - ((isset($matches[3]) && $matches[3] != '') ? - ' style="text-align:center"' : - ' style="text-align:right"' - ) : ''; - $value[] = $matches[2]; + $str = array(); + $col = count($row); + + $matches = $_value = $_align = array(); + foreach($row as $cell) { + if (preg_match('/^(\s+)?(.+?)(\s+)?$/', $cell, $matches)) { + if ($matches[2] == '==') { + // Colspan + $_value[] = FALSE; + $_align[] = FALSE; + } else { + $_value[] = $matches[2]; + if ($matches[1] == '') { + $_align[] = ''; // left + } else if (isset($matches[3])) { + $_align[] = 'center'; + } else { + $_align[] = 'right'; + } + } } else { - $align[] = ''; - $value[] = $val; + $_value[] = $cell; + $_align[] = ''; } } - $this->col = count($value); - $colspan = array(); - foreach ($value as $val) - $colspan[] = ($val == '==') ? 0 : 1; - $str = ''; - $count = count($value); - for ($i = 0; $i < $count; $i++) { - if ($colspan[$i]) { - while ($i + $colspan[$i] < $count && $value[$i + $colspan[$i]] == '==') - $colspan[$i]++; - $colspan[$i] = ($colspan[$i] > 1) ? ' colspan="' . $colspan[$i] . '"' : ''; - $str .= '' . make_link($value[$i]) . ''; - } + + for ($i = 0; $i < $col; $i++) { + if ($_value[$i] === FALSE) continue; + $colspan = 1; + while (isset($_value[$i + $colspan]) && $_value[$i + $colspan] === FALSE) ++$colspan; + $colspan = ($colspan > 1) ? ' colspan="' . $colspan . '"' : ''; + $align = $_align[$i] ? ' style="text-align:' . $_align[$i] . '"' : ''; + $str[] = ''; + $str[] = make_link($_value[$i]); + $str[] = ''; + unset($_value[$i], $_align[$i]); } - $this->elements[] = $str; + + $this->col = $col; + $this->elements[] = implode('', $str); } function canContain(& $obj) @@ -710,8 +725,9 @@ function toString() { $rows = ''; - foreach ($this->elements as $str) + foreach ($this->elements as $str) { $rows .= "\n" . '' . $str . '' . "\n"; + } $rows = $this->wrap($rows, 'table', ' class="style_table" cellspacing="1" border="0"'); return $this->wrap($rows, 'div', ' class="ie5"'); } @@ -814,7 +830,7 @@ function Body($id) { $this->id = $id; - $this->contents = & new Element(); + $this->contents = new Element(); $this->contents_last = & $this->contents; parent::Element(); } @@ -988,4 +1004,4 @@ $this->style = sprintf($_list_pad_str, $this->level, $margin, $margin); } } -?> + diff -urN pukiwiki-1_5_0_utf8/lib/diff.php pukiwiki_1_5_1-beta1-f502_utf8/lib/diff.php --- pukiwiki-1_5_0_utf8/lib/diff.php 2014-07-13 13:03:57.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/lib/diff.php 2014-12-03 02:24:21.000000000 +0900 @@ -2,7 +2,7 @@ // PukiWiki - Yet another WikiWikiWeb clone. // $Id: diff.php,v 1.10 2011/01/25 15:01:01 henoheno Exp $ // Copyright (C) -// 2003-2005 PukiWiki Developers Team +// 2003-2005, 2007 PukiWiki Developers Team // 2001-2002 Originally written by yu-ji // License: GPL v2 or (at your option) any later version // @@ -47,8 +47,8 @@ if (PKWK_DIFF_SHOW_CONFLICT_DETAIL) { global $do_update_diff_table; - - $do_update_diff_table = <<l : between backup data and stored page data.
r : between backup data and your post data.

@@ -60,29 +60,32 @@ EOD; $tags = array('th', 'th', 'td'); foreach ($arr as $_obj) { - $do_update_diff_table .= ''; + $table[] = ' '; $params = array($_obj->get('left'), $_obj->get('right'), $_obj->text()); - foreach ($params as $key=>$text) { - $text = htmlsc($text); - if (trim($text) == '') $text = ' '; - $do_update_diff_table .= '<' . $tags[$key] . - ' class="style_' . $tags[$key] . '">' . $text . + foreach ($params as $key => $text) { + $text = htmlsc(rtrim($text)); + if (empty($text)) $text = ' '; + $table[] = + ' <' . $tags[$key] . ' class="style_' . $tags[$key] . '">' . + $text . ''; } - $do_update_diff_table .= '' . "\n"; + $table[] = ' '; } - $do_update_diff_table .= '
' . "\n"; + $table[] = ''; + + $do_update_diff_table = implode("\n", $table) . "\n"; + unset($table); } - $body = ''; + $body = array(); foreach ($arr as $_obj) { - if ($_obj->get('left') != '-' && $_obj->get('right') != '-') - $body .= $_obj->text(); + if ($_obj->get('left') != '-' && $_obj->get('right') != '-') { + $body[] = $_obj->text(); + } } - $auto = 1; - - return array(rtrim($body) . "\n", $auto); + return array(rtrim(implode('', $body)) . "\n", 1); } diff -urN pukiwiki-1_5_0_utf8/lib/file.php pukiwiki_1_5_1-beta1-f502_utf8/lib/file.php --- pukiwiki-1_5_0_utf8/lib/file.php 2014-07-13 13:03:57.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/lib/file.php 2016-02-13 09:45:44.000000000 +0900 @@ -1,8 +1,8 @@ $reading) $body .= '-[[' . $page . ']] ' . $reading . "\n"; @@ -682,19 +767,6 @@ return $readings; } -// Get a list of encoded files (must specify a directory and a suffix) -function get_existfiles($dir, $ext) -{ - $pattern = '/^(?:[0-9A-F]{2})+' . preg_quote($ext, '/') . '$/'; - $aryret = array(); - $dp = @opendir($dir) or die_message($dir . ' is not found or not readable.'); - while ($file = readdir($dp)) - if (preg_match($pattern, $file)) - $aryret[] = $dir . $file; - closedir($dp); - return $aryret; -} - // Get a list of related pages of the page function links_get_related($page) { @@ -704,7 +776,7 @@ if (isset($links[$page])) return $links[$page]; // If possible, merge related pages generated by make_link() - $links[$page] = ($page == $vars['page']) ? $related : array(); + $links[$page] = ($page === $vars['page']) ? $related : array(); // Get repated pages from DB $links[$page] += links_get_related_db($vars['page']); @@ -789,4 +861,3 @@ htmlsc(basename($filename))); } } -?> diff -urN pukiwiki-1_5_0_utf8/lib/func.php pukiwiki_1_5_1-beta1-f502_utf8/lib/func.php --- pukiwiki-1_5_0_utf8/lib/func.php 2014-07-13 13:03:57.000000000 +0900 +++ pukiwiki_1_5_1-beta1-f502_utf8/lib/func.php 2016-01-09 00:20:02.000000000 +0900 @@ -267,7 +267,7 @@ if (empty($pages)) return str_replace('$1', $s_word, $_msg_notfoundresult); - ksort($pages); + ksort($pages, SORT_STRING); $retval = '