codes****@googl*****
codes****@googl*****
2009年 3月 29日 (日) 22:40:01 JST
Author: mystralkk Date: Sun Mar 29 06:29:38 2009 New Revision: 1355 Added: trunk/geeklog-1-jp-extended/public_html/admin/install/core.js (contents, props changed) trunk/geeklog-1-jp-extended/public_html/admin/install/fb.php (contents, props changed) trunk/geeklog-1-jp-extended/public_html/admin/install/precheck.css (contents, props changed) trunk/geeklog-1-jp-extended/public_html/admin/install/precheck.js (contents, props changed) trunk/geeklog-1-jp-extended/public_html/admin/install/precheck.php (contents, props changed) Log: r1353の更新をgeeklog-1-jp-extendedにも適用します。 Added: trunk/geeklog-1-jp-extended/public_html/admin/install/core.js ============================================================================== --- (empty file) +++ trunk/geeklog-1-jp-extended/public_html/admin/install/core.js Sun Mar 29 06:29:38 2009 @@ -0,0 +1,338 @@ +/* +The MIT License + +Copyright (c) 2007 SitePoint Pty. Ltd. http://www.sitepoint.com/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +if (typeof Core == "undefined") { + +if (!window.$) { + window.$ = function(id) {return document.getElementById(id);}; +} + +var Core = {}; +// W3C DOM 2 Events model +if (document.addEventListener) { + Core.addEventListener = function(target, type, listener) + { + target.addEventListener(type, listener, false); + }; + + Core.removeEventListener = function(target, type, listener) + { + target.removeEventListener(type, listener, false); + }; + + Core.preventDefault = function(event) + { + event.preventDefault(); + }; + + Core.stopPropagation = function(event) + { + event.stopPropagation(); + }; +} else if (document.attachEvent) { + // Internet Explorer Events model + Core.addEventListener = function(target, type, listener) + { + // prevent adding the same listener twice, since DOM 2 Events ignores + // duplicates like this + if (Core._findListener(target, type, listener) != -1) return; + + // listener2 calls listener as a method of target in one of two ways, + // depending on what this version of IE supports, and passes it the global + // event object as an argument + var listener2 = function() + { + var event = window.event; + + if (Function.prototype.call) { + listener.call(target, event); + } else { + target._currentListener = listener; + target._currentListener(event); + target._currentListener = null; + } + }; + + // add listener2 using IE's attachEvent method + target.attachEvent("on" + type, listener2); + + // create an object describing this listener so we can clean it up later + var listenerRecord = + { + target: target, + type: type, + listener: listener, + listener2: listener2 + }; + + // get a reference to the window object containing target + var targetDocument = target.document || target; + var targetWindow = targetDocument.parentWindow; + + // create a unique ID for this listener + var listenerId = "l" + Core._listenerCounter++; + + // store a record of this listener in the window object + if (!targetWindow._allListeners) targetWindow._allListeners = {}; + targetWindow._allListeners[listenerId] = listenerRecord; + + // store this listener's ID in target + if (!target._listeners) target._listeners = []; + target._listeners[target._listeners.length] = listenerId; + + // set up Core._removeAllListeners to clean up all listeners on unload + if (!targetWindow._unloadListenerAdded) { + targetWindow._unloadListenerAdded = true; + targetWindow.attachEvent("onunload", Core._removeAllListeners); + } + }; + + Core.removeEventListener = function(target, type, listener) + { + // find out if the listener was actually added to target + var listenerIndex = Core._findListener(target, type, listener); + if (listenerIndex == -1) return; + + // get a reference to the window object containing target + var targetDocument = target.document || target; + var targetWindow = targetDocument.parentWindow; + + // obtain the record of the listener from the window object + var listenerId = target._listeners[listenerIndex]; + var listenerRecord = targetWindow._allListeners[listenerId]; + + // remove the listener, and remove its ID from target + target.detachEvent("on" + type, listenerRecord.listener2); + target._listeners.splice(listenerIndex, 1); + + // remove the record of the listener from the window object + delete targetWindow._allListeners[listenerId]; + }; + + Core.preventDefault = function(event) + { + event.returnValue = false; + }; + + Core.stopPropagation = function(event) + { + event.cancelBubble = true; + }; + + Core._findListener = function(target, type, listener) + { + // get the array of listener IDs added to target + var listeners = target._listeners; + if (!listeners) return -1; + + // get a reference to the window object containing target + var targetDocument = target.document || target; + var targetWindow = targetDocument.parentWindow; + + // searching backward (to speed up onunload processing), find the listener + for (var i = listeners.length - 1; i >= 0; i --) { + // get the listener's ID from target + var listenerId = listeners[i]; + + // get the record of the listener from the window object + var listenerRecord = targetWindow._allListeners[listenerId]; + + // compare type and listener with the retrieved record + if (listenerRecord.type == type && listenerRecord.listener == listener) { + return i; + } + } + return -1; + }; + + Core._removeAllListeners = function() + { + var targetWindow = this; + + for (id in targetWindow._allListeners) { + var listenerRecord = targetWindow._allListeners[id]; + listenerRecord.target.detachEvent("on" + listenerRecord.type, listenerRecord.listener2); + delete targetWindow._allListeners[id]; + } + }; + + Core._listenerCounter = 0; +} + +Core.addClass = function(target, theClass) +{ + if (!Core.hasClass(target, theClass)) { + if (target.className == "") { + target.className = theClass; + } else { + target.className += " " + theClass; + } + } +}; + +Core.getElementsByClass = function(theClass) +{ + var elementArray = []; + + if (typeof document.all != "undefined") { + elementArray = document.all; + } else { + elementArray = document.getElementsByTagName("*"); + } + + var matchedArray = []; + var pattern = new RegExp("(^| )" + theClass + "( |$)"); + + for (var i = 0; i < elementArray.length; i ++) { + if (pattern.test(elementArray[i].className)) { + matchedArray[matchedArray.length] = elementArray[i]; + } + } + + return matchedArray; +}; + +Core.hasClass = function(target, theClass) +{ + var pattern = new RegExp("(^| )" + theClass + "( |$)"); + + if (pattern.test(target.className)) { + return true; + } + + return false; +}; + +Core.removeClass = function(target, theClass) +{ + var pattern = new RegExp("(^| )" + theClass + "( |$)"); + + target.className = target.className.replace(pattern, "$1"); + target.className = target.className.replace(/ $/, ""); +}; + +Core.getComputedStyle = function(element, styleProperty) +{ + var computedStyle = null; + + if (typeof element.currentStyle != "undefined") { + computedStyle = element.currentStyle; + } else { + computedStyle = document.defaultView.getComputedStyle(element, null); + } + + return computedStyle[styleProperty]; +}; + +Core.start = function(runnable) +{ + var initOnce = function() + { + if (arguments.callee.done) { + return; + } else { + arguments.callee.done = true; + runnable.init(); + } + } + + Core.addEventListener(document, "DOMContentLoaded", initOnce); + Core.addEventListener(window, "load", initOnce); +}; + +/** +* @param hash options +* url: request URL +* method: "get" or "post" +* params: parameters +* onSuccess: call back functon +* onFail: call back functon +*/ +Core.Ajax = function(args) +{ + try { + var oReq = new XMLHttpRequest(); + } catch (e) { + try { + var oReq = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) { + var oReq = null; + return false; + } + } + + oReq.onreadystatechange = function() + { + if (oReq.readyState == 4) { + if (oReq.status == 200 || oReq.status == 304) { + if (typeof args.onSuccess == "function") { + args.onSuccess(oReq); + } else { + throw "onSuccess handler is not defined."; + } + } else { + if (typeof args.onFailure == "function") { + args.onFailure(oReq); + } else { + throw "onFailure handler is not defined."; + } + } + } + } + + if (args.method.toLowerCase() == "get") { + args.url += "?" + args.params; + args.params = null; + } + + oReq.open(args.method, args.url, true); + oReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + oReq.send(args.params); + return true; +}; + +/** +* Load JavaScript file dynamically +*/ +Core.loadJS = function(URL) +{ + var script = document.createElement("script"); + script.setAttribute("type", "text/javascript"); + script.src = URL; + document.getElementsByTagName("head")[0].appendChild(script); +}; + +/** +* Load CSS file dynamically +*/ +Core.loadCSS = function(URL) +{ + var link = document.createElement("link"); + link.setAttribute("type", "text/css"); + link.setAttribute("rel", "stylesheet"); + link.setAttribute("href", URL); + document.getElementsByTagName("head")[0].appendChild(link); +}; + +} // End of Core class Added: trunk/geeklog-1-jp-extended/public_html/admin/install/fb.php ============================================================================== --- (empty file) +++ trunk/geeklog-1-jp-extended/public_html/admin/install/fb.php Sun Mar 29 06:29:38 2009 @@ -0,0 +1,234 @@ +<?php + +// +---------------------------------------------------------------------------+ +// | Geeklog 1.5 | +// +---------------------------------------------------------------------------+ +// | public_html/admin/install/fb.php | +// | | +// | Part of Geeklog pre-installation check scripts | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2009 by the following authors: | +// | | +// | Authors: mystral-kk - geeklog AT mystral-kk DOT net | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +/** +* This script enables a Geeklog user to traverse the file tree and search for +* "db-config.php" visually. +* +* @author mystral-kk <geeklog AT mystral-kk DOT net> +* @date 2009-01-12 +* @version 1.3.0 +* @license GPLv2 or later +*/ +define('DS', DIRECTORY_SEPARATOR); +define('LB', "\n"); +define('OS_WIN', strcasecmp(substr(PHP_OS, 0, 3), 'WIN') === 0); +define('TARGET', 'db-config.php'); + +// Display an icon image + +if (isset($_GET['mode']) AND ($_GET['mode'] == 'img1')) { + header('Content-Type: image/gif'); + echo base64_decode( + 'R0lGODlhJAAZAOYAAP/zWf/bQP/aPv/4Xv/eQ//eO//8Yv7bNf//X//7Yv/3X//e' + . 'RPnWPMa5cNra 2f/bPPPy9MCuWcy2S/3+/tTT0PXTO/T0+//bO+bl5uzs7PDwZ/b' + . '4/fv8aoiIi8+8S8fIy8S7j/zY P//hObGyuv/cPu/NNpmRauzNRfTUQuDh6tPQlt' + . 'O/Tvv7+9e/QtPThbqnS7qrafrVNMjJ0Pv8//n5 /tvASeroXM/OyNTOp+/x+dDNh' + . 'Onoa7Ore8XDe/n5+Z6hqd7e3da7Rs/MuOfGOpWPed3ZZrOtk6Wa ZY+QlpeSefvf' + . 'RfrZO/7sUsq0VcWwTcvGqP/0WdvPYKGjrby7udC3SM+1RtPKipmanuHFRNrLV+3S' + . 'NvziSfT1a+bJTP3ZPPvzXOTidf3XLv/ZP/PWN6ugcrSxp8WsQ7y+ydfVcNPDUfnY' + . 'Pf/zUf/tTOfp 9MDCyeTkm/f5at3bWuXm7/XYQI+LdMLAsf/4VvzlSP/rUf/iSP/' + . 'nTf/uVf/+Zf/ZPv//Zv///yH5 BAAAAAAALAAAAAAkABkAAAf/gH+Cg4SFhTQQEB' + . 'YWGUAUDhOGhBMbOTOEM4sQGBRCOCA8PSo6YDs2 aBSSGxgOOFYNdSkON0IgDbcNR' + . 'XE2Nhp8CMB8fggqhhsgXSclMQdBETVYQ8thLRp+19jZw2+GFBEH Fw8CfRcH5hUn' + . '6VEc2u18LoYNFeN9fQ8VWCtZUUU7Guzt2vUwBCIGPQEVsuzgAgdgwIB8Bha60aJA' + . 'PS8rrAnzw6ejx48gf8Er1AbGATF9GKThYKBlApcvX7qcmSABgpGEaBgpQSLlCgUD' + . 'gA4YGnSoUAVC jSLQIcmNkwICGHj4AgWA1atYr1bFaoepoRQmo3rYQ7as2bNo11i' + . 'RpJOnVCZM7/DInUu3Ll02xSR9 qFKAgQQ9gAMLHkz4Tl5DckyqkbAlj+PHkCNHVo' + . 'JD0p8ZZYZckKCEwALPnz8TGD1atOfRc55Y/uOt gIQQAWLLji1gdu3YJEiIGKPac' + . 'g4eWqqEoFevuPE+Ah6IELGkQpAXN1b/mdKCyvDjxh8UKLAEhYQX JohcOeNDugMn' + . '1okn337hAgoPEUzQ6SBFRooN0gX9NiNg/XYUNTRhgglJdHDFCDJgwEJ+hUzxgggF' + . 'ANjEEUR0gMQPI3wABASRCDJBhwymQEYERxR4YYYOZFAeg9L5IIMUGH7gAAYQLMgi' + . 'i4xkUOON+QUC ADs=' + ); + exit; +} + +if (isset($_GET['mode']) AND ($_GET['mode'] == 'img2')) { + header('Content-Type: image/gif'); + echo base64_decode( + 'R0lGODlhEQAVAOZEAPr6+ubm5r6+vvLy8u7u7rOzs/f39/j39+np6aurq/Lx8v7/' + . '//r6+////vr7+u7u7+7v7u/v7vz8/Pf499HR0ff3+KampsHBwenp6PLy8fX19f/+' + . '//Hy8vf39vr5+u/u7/Lx8f38/fX19PDv7urr6vHw8by8vPf4+KCgoObm5evr6/r7' + . '++Dg4P38/OPj4+jp6e7v7/7+/u/v7+jp6OTk5Pj4+fj3+Nzc3MnJyf7+///+/uHh' + . '4fPz89/f3+Li4vv7+6Ojo6enp5ycnP///////wAAAAAAAAAAAAAAAAAAAAAAAAAA' + . 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + . 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + . 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + . 'AAAAAAAAAAAAAAAAACH5BAEAAEQALAAAAAARABUAAAfTgBQJFkGFhoeFQDgJBhI/' + . 'j5CRj0NAQT9DmJmampWXm5+YnUNCpKWmQqGWoKCVDA0LQzk6rzELDZgbG5U1Eqe+' + . 'IS2VHQDEACsMxQweDsyVPBU2BycGBgcT1tUGFZUlGr6nGiKVBAMcChnnCgPr6wog' + . 'lSQEBBEEEDIREA8PHyMEMJUzVPhCAaRgwQuVUiBAgOHFQgxANgkQEMRFgIsYA0TM' + . 'JKAAkSA7aPjaOKQjkY89fKhc6WOjyZNBUrJUGfHlyQQ3WPTYydOEzZOCCCEKcuGk' + . 'USKBAAA7' + ); + exit; +} + +if (isset($_GET['mode']) AND ($_GET['mode'] == 'imglogo')) { + header('Content-Type: image/jpeg'); + echo base64_decode( + '/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAACgAA/+4ADkFkb2Jl' + . 'AGTAAAAAAf/bAIQAFBAQGRIZJxcXJzImHyYyLiYmJiYuPjU1NTU1PkRBQUFBQUFE' + . 'RERERERERERERERERERERERERERERERERERERAEVGRkgHCAmGBgmNiYgJjZENisr' + . 'NkREREI1QkRERERERERERERERERERERERERERERERERERERERERERERERERE/8AA' + . 'EQgAOACXAwEiAAIRAQMRAf/EAI0AAQADAQEBAAAAAAAAAAAAAAADBAUBAgYBAQEB' + . 'AQEBAAAAAAAAAAAAAAABAwIEBRAAAQMCAwQIBAQEBwAAAAAAAQACAxEEIRIFMUFR' + . 'E2FxgZGhIlIU0TKSM7HBQmLwcoKiwiNDUyQ0BhEAAgICAgIBBAMAAAAAAAAAAAER' + . 'AhIDITFBUWFxkSIyQoIU/9oADAMBAAIRAxEAPwD7NFDcXDbdnMfUioFBxJoPFQCO' + . '4uPuHlM9DD5u127+n6kB7ub+K28rjV52Rs8zj2D8dipNfqE7hIGiMA/I84U6drif' + . 'pp0q81lvZNwysB2neeveSuC7MgrCwvHqPlHj8F0qt8+PYPBtp5PuTEDhE0N8TmPc' + . 'QuQN9tOYauLXtztzuLjVuDsT1tNOtRTvvyKsa0dWJ8VELh0kLJ34SQPGf+U+V39p' + . 'r1hdPW1XKU/oSTYREWZQiIgCIsS2v5ZLvIT5CXDKtKUdlZr+PJJNtEWLfX00NzkY' + . 'aNGXDilKO7xqG4NpERZlCIiAIiIDOkB1EOYCWwVLXOG15HDg0HftO7DE+X3E3tXU' + . 'NJYjkf2b+0UcpZQbN5mb9px/zW+k+sf4vq415M1rJg//AE5hy39f6T24j6V1Vw02' + . 'DM02393KZJauDdtd5Wpfag20o0CrjuUWkM5bZIzta+hWZrAcLhx4gZe74r2Qtm3G' + . '361XCOekWm/+gazGZoA4g/FVHas10khLDklblo7y13b8Tv2ArNgkgYKnF+Gx1HbM' + . 'c1AZK1rgMo4LZtoZIGumkiawDK5py0dWuO9zjh6j2LB2TeNK45cFIm65MIxHRuYU' + . 'Y52NQekOA20OK9m8vYKSSVofU3BVb+B0d+7LQB5ZK08TTL1YHMe1X5be/laWyGrT' + . 'txatdSSqssYfvsjL7dSYbfnndhl/dwWYL28uSXRVoNzQq8tu+GEEkFpd+k1xoprJ' + . 't26P/jny16Nq0WulU7LF88ZdEkuafqbpH8mb5jsOzsKoWZAvATszO/NSx2M/uGuk' + . 'LQ6od8wr3KnynTTFjdpLqLutafni1DrzHgGjdatI6QMttlaVpXMq2okm582Boyvc' + . 'F3S5mQTUlFCfKCf0lNU/7Z/pUrVVvhWsLHv2PBe1HUzA7lRfNvdwVEahdxEOeTQ+' + . 'puBXl1BenmbOZjXhVbGqlvtnZujL11XEVphTHLLtl7DdRYbczndhl/dwWSdQu5nE' + . 'srQbmt2KqA7kH05m99Ct3RsvIw21OZLUrqVrY5c/YnZmu1i4JFCBTdTai5KWe+Bb' + . '8udv5V8UW2FMcsF1MEln0iyp4TCw21aRP+y7/bfta3qqPL9PBaq8SxNmYY3irSKE' + . 'L5RoZcV01krJz5WTtFf2vH8UVq/sBdgEGjxsKy5Ld7Ipbd5zOidzWO9THbfGteld' + . 's5r1oDY2lzd2cYd+H4r1Vq3VbK2i1eHJz8E1tormvDpXAgY0bvUus3IbHyR8ztvU' + . 'pwy8kHncyP8AkFT4qJ1ja2/nndUnfI7amayV9tpx6SEeijeQOuo7aVvzGsRr1fFt' + . 'O1eRp147yGuXpdh+Kv3Eomi5drG5xBa5hDcratNRi7L4LUXK3usqqUTKnwWDOh0t' + . 'rYHQyGpca1G49CznaXdQk8vEcWup8F9Eild9035n2IMWz0qRsglmNKGtK1JXq302' + . 'SO65ppkBJB61sIj33c/KgQZWo6YZ3cyKmY/MOPSoJNKne9hJBwaHHqW4iLfdJL0I' + . 'MvUdM9weZHg/eDvVBulXTyGvFAN5dVfRold96rEQUXWUMVsYXmjdpcePFZbdKuAa' + . 'xuBaf1Nctm9tRdR5CaY1BWOdIuW4NIoeBWuq/Dm8NvlMjRSdABLyg4HENzbkWtBo' + . '+Rri8gvLXBvAEhFt/orOE/2JBsIiL5p2UrwGJ8dw0E5TkeGipyO6BwdlPVVd9xPJ' + . '9qKg9Upy+Aqe+iIgOe1mkxmmNPTEMg78XdzgpobOGE1YwB3q2u7ziiICdERAEREA' + . 'REQBERAEREAREQBERAf/2Q==' + ); + exit; +} + +/** +* Convert charset of a string to SJIS +*/ +function convertCharset($str) { + if (OS_WIN) { + return mb_convert_encoding($str, 'utf-8', 'sjis'); + } else { + return $str; + } +} + +if (isset($_GET['path'])) { + $path = $_GET['path']; +} else { + $path = dirname(__FILE__); +} +if (isset($_GET['mode'])) { + $mode = $_GET['mode']; +} else { + $mode = 'install'; +} + +$result = FALSE; +$header = <<<EOD +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html lang="ja"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <meta http-equiv="Content-Style-Type" content="text/css"> + <title>Geeklog インストール前 ファイルブラウザ</title> + <style type="text/css"> +<!-- +a { + color: blue; +} + +a:hover { + color: blue; + text-decoration: none; + color: white; + background-color: blue; +} + +a:visted { + color: blue; +} +--> +</style> +</head> +<body> +<h1>Geeklog インストール前 ファイルブラウザ</h1> +EOD; + +$body = '<p style="color: white; background-color: black;"><strong>現在のパ ス</strong>:' + . convertCharset($path) . '</p>' . LB; + +$parent = @realpath($path . DS . '..'); +if ($parent !== FALSE) { + $body .= '<p><a href="fb.php?mode=' . $mode . '&path=' + . rawurlencode($parent) . '">[一つ上のフォルダへ]</a></p>' . LB; +} + +if (($dh = @opendir($path)) === FALSE) { + $body .= '<p>エラー:ディレクトリを開けません。検索を終了します。</p>' . LB; +} else { + while (($entry = readdir($dh)) !== FALSE) { + $fullpath = $path . DS . $entry; + if (is_dir($fullpath)) { + if (($entry != '.') AND ($entry != '..')) { + $body .= '<img alt="フォルダのアイコン" src="fb.php?mode=img1"><a href="fb.php?mode=' + . $mode . '&path=' . rawurlencode($fullpath) . '">' + . htmlspecialchars(convertCharset($entry), ENT_QUOTES) + . '</a><br>' . LB; + } + } else { + if ($entry == TARGET) { + $body .= '<img alt="ファイルのアイコン" src="fb.php?mode=img2"> ' + . '<span style="color: white; background-color: green;">' + . TARGET . '</span> [<a href="precheck.php?mode=' + . $mode . '&step=2&path=' + . rawurlencode(dirname($fullpath) . DS) + . '">このファイルを使用する</a>]<br>' . LB; + $result = TRUE; + } + } + } + + closedir($dh); +} + +if ($result === TRUE) { + $msg = '<p style="padding: 5px; border: solid 2px #006633; background-color: #ccff99;"><strong>' . TARGET . '</strong>が見つかりまし た。このファイルでよければ、<strong>[このファイルを使用する]</strong>をクリ ックしてください。</p>' . LB; +} else { + $msg = '<p style="padding: 5px; border: solid 2px #cc3333; background-color: #ffccff;">下に表示されているリンクをクリックして、 <strong>' . TARGET . '</strong>を探してください。</p>' . LB; +} + +echo $header . $msg . $body; Added: trunk/geeklog-1-jp-extended/public_html/admin/install/precheck.css ============================================================================== --- (empty file) +++ trunk/geeklog-1-jp-extended/public_html/admin/install/precheck.css Sun Mar 29 06:29:38 2009 @@ -0,0 +1,140 @@ +/** +* CSS for precheck.php +* +* @author mystral-kk <geeklog AT mystral-kk DOT net> +* @date 2009-01-12 +* @version 1.3.0 +* @license GPLv2 or later +*/ + + @ charset "utf-8"; + +body { + margin-left: 30px; +} + +li { + margin: 10px; + line-height: 1.5em; +} + +code { + padding: 2px; background-color: black; color: white; +} + +h1 { + font-size: 1.8em; +} + +h2 { + clear: both; + margin-top: 20px; + font-size: 1.5em; + border-left: solid 10px #6b6bff; + padding-left: 5px; +} + +a { + color: blue; +} + +a:visited { + color: blue; +} + +a:hover { + text-decoration: none; + color: white; + background-color: blue; +} + +.good { + padding: 2px; + border: solid 1px #006633; + background-color: #ccff99; +} + +.warning { + padding: 2px; + border: solid 1px #ffcc00; + background-color: #ffff66; +} + + +.bad { + visibility: visible; + padding: 2px; + border: solid 1px #cc3333; + background-color: #ffccff; +} + +.hidden { + visibility: hidden; +} + +.infobox { + padding: 5px; + border: solid 1px #cc3333; + background-color: #ffccff; +} + +.large { + font-size: 1.8em; +} + +.small { + font-size: 0.8em; +} + +.center { + text-align: center; +} + +.right { + text-align: right; +} + +.normal { + color: #6b6bff; + font-weight: bold; + background-color: white; +} + +.hilight { + color: white; + font-weight: bold; + background-color: #6b6bff; +} + +.lbl { + display: block; + float: left; + width: 14em; +} + +div#container { + margin-top: 20px; + width: 780px; +} + +fieldset { + width: 660px; +} + +input:focus { + background-color: #ffff66; +} + +ul.navi { + margin: 0 0 30px 0; + padding: 0; +} + +ul.navi li { + margin: 0px; + padding: 1px; + float: left; + list-style: none; + font-size: 0.9em; + border: solid 1px black; +} Added: trunk/geeklog-1-jp-extended/public_html/admin/install/precheck.js ============================================================================== --- (empty file) +++ trunk/geeklog-1-jp-extended/public_html/admin/install/precheck.js Sun Mar 29 06:29:38 2009 @@ -0,0 +1,150 @@ +/** +* Check DB settings as a part of Precheck for Geeklog +* +* @author mystral-kk <geeklog AT mystral-kk DOT net> +* @date 2009-02-03 +* @version 1.3.2 +* @license GPLv2 or later +* @note This script (precheck.js) needs 'core.js' published +* by SitePoint Pty. Ltd. +*/ +var callback = { + /** + * Callback function when a database was selected + */ + showCountResult: function(req) { + var install_submit = $('install_submit'); + var db_name_warning = $('db_name_warning'); + + if ((req.responseText == '-ERR') || (parseInt(req.responseText) > 0)) { + install_submit.disabled = true; + Core.removeClass(db_name_warning, 'hidden'); + Core.addClass(db_name_warning, 'bad'); + } else { + install_submit.disabled = false; + Core.removeClass(db_name_warning, 'bad'); + Core.addClass(db_name_warning, 'hidden'); + } + }, + + /** + * Callback function when db_name selection was changed + */ + dbSelected: function() { + $('install_submit').disabled = true; + $('db_name_warning').setAttribute('class', 'hidden'); + + if ($('db_name').value != '--') { + var type = $('db_type').value; + var host = $('db_host').value; + var user = $('db_user').value; + var pass = $('db_pass').value; + var name = $('db_name').value; + var prefix = $('db_prefix').value; + var args = { + 'url': 'precheck.php', + 'method': 'get', + 'params': 'mode=counttable&type=' + type + '&host=' + host + '&user=' + user + '&pass=' + pass + '&name=' + name + '&prefix=' + prefix, + 'onSuccess': callback.showCountResult + } + + // prefix could be an empty string, so we don't check it here + if ((host != '') && (user != '') && (pass != '') && (name != '')) { + if (!Core.Ajax(args)) { + alert('サーバとの通信に失敗しました。'); + } + } + } + }, + + /** + * Callback function for Ajax + */ + showLookupResult: function(req) { + var db_name = $('db_name'); + var install_submit = $('install_submit'); + + if (req.responseText.substring(0, 4) == '-ERR') { + db_name.disabled = true; + install_submit.disabled = true; + if (req.responseText.length > 4) { + $('db_err').innerHTML = req.responseText.substring(4); + Core.addClass($('db_err'), 'bad'); + } + } else { + var dbs = req.responseText.split(';'); + while (db_name.length > 0) { + db_name.removeChild(db_name.childNodes[0]); + } + + var node = document.createElement('option'); + node.value = '--'; + node.appendChild(document.createTextNode('選択してください')); + db_name.appendChild(node); + + for (i in dbs) { + var db = dbs[i]; + if (db == 'mysql') { + continue; + } + var node = document.createElement('option'); + node.value = db; + node.appendChild(document.createTextNode(db)); + db_name.appendChild(node); + } + + db_name.disabled = false; + install_submit.disabled = true; + } + }, + + /** + * Callback function when <input> values were changed + */ + dataEntered: function() { + var type = $('db_type').value; + var host = $('db_host').value; + var user = $('db_user').value; + var pass = $('db_pass').value; + var args = { + 'url': 'precheck.php', + 'method': 'get', + 'params': 'mode=lookupdb&type=' + type + '&host=' + host + '&user=' + user + '&pass=' + pass, + 'onSuccess': callback.showLookupResult + } + if ((host != '') && (user != '') && (pass != '')) { + if (!Core.Ajax(args)) { + alert('サーバとの通信に失敗しました。'); + } + } + }, + + /** + * Change <input type="text"> element into <select> + */ + modifyDbnameField: function() { + var db_name_parent = $('db_name_parent'); + db_name_parent.removeChild($('db_name')); + + var select = document.createElement('select'); + select.setAttribute('id', 'db_name'); + select.setAttribute('name', 'db_name'); + select.setAttribute('disabled', true); + db_name_parent.appendChild(select); + }, + + /** + * Append event listeners + */ + init: function() { + this.modifyDbnameField(); + $('install_submit').setAttribute('disabled', true); + Core.addEventListener($('db_type'), 'change', this.dataEntered); + Core.addEventListener($('db_host'), 'keyup', this.dataEntered); + Core.addEventListener($('db_user'), 'keyup', this.dataEntered); + Core.addEventListener($('db_pass'), 'keyup', this.dataEntered); + Core.addEventListener($('db_name'), 'change', this.dbSelected); + } +} + +Core.start(callback); Added: trunk/geeklog-1-jp-extended/public_html/admin/install/precheck.php ============================================================================== --- (empty file) +++ trunk/geeklog-1-jp-extended/public_html/admin/install/precheck.php Sun Mar 29 06:29:38 2009 @@ -0,0 +1,970 @@ +<?php + +// +---------------------------------------------------------------------------+ +// | Geeklog 1.5 | +// +---------------------------------------------------------------------------+ +// | public_html/admin/install/precheck.php | +// | | +// | Part of Geeklog pre-installation check scripts | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2006-2009 by the following authors: | +// | | +// | Authors: mystral-kk - geeklog AT mystral-kk DOT net | +// +---------------------------------------------------------------------------+ +// | | +// | This program is free software; you can redistribute it and/or | +// | modify it under the terms of the GNU General Public License | +// | as published by the Free Software Foundation; either version 2 | +// | of the License, or (at your option) any later version. | +// | | +// | This program is distributed in the hope that it will be useful, | +// | but WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +// | GNU General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ + +/** +* This script tests the file and directory permissions, thus addressing the +* most common errors / omissions when setting up a new Geeklog site ... +* +* @author mystral-kk <geeklog AT mystral-kk DOT net> +* @date 2009-02-03 +* @version 1.3.2 +* @license GPLv2 or later +*/ +error_reporting(E_ALL); + +define('LB', "\n"); +define('DS', DIRECTORY_SEPARATOR); +define('GL_VERSION', '1.5.1'); +define('PRECHECK_VERSION', '1.3.2'); +define('THIS_SCRIPT', 'precheck.php'); +define('MIN_PHP_VERSION', '4.1.0'); +define('MIN_MYSQL_VERSION', '3.23.2'); + +$_CONF = array(); + +if (!is_callable('file_get_contents')) { + function file_get_contents($path) { + $retval = ''; + + if (($fp = fopen($fp, 'rb')) !== FALSE) { + while (!feof($fp)) { + $retval .= fread($fp, 8192); + } + + fclose($fp); + } else { + $retval = FALSE; + } + + return $retval; + } +} + +if (!is_callable('file_put_contents')) { + function file_put_contents($filename, $data) { + $retval = FALSE; + + if (($fh = @fopen($filename, 'r+b')) !== FALSE) { + if (flock($fh, LOCK_EX)) { + if (ftruncate($fh, 0)) { + if (rewind($fh)) { + $retval = fwrite($fh, $data); + } + } + } + + @fclose($fh); + } + + return $retval; + } +} + +class Precheck +{ + var $path_html; + var $path; + var $mode; + var $step; + var $fatal_error; + var $warning; + var $error; + + /** + * Constructor + * + * @access public + */ + function Precheck() + { + $this->fatal_error = $this->error = $this->warning = 0; + $this->path_html = realpath(dirname(__FILE__) . DS . '..' . DS . '..' . DS); + } + + /** + * Return HTML header and site header + * + * @access public + */ + function getHeader() + { + $retval = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' . LB + . '<html lang="ja">' . LB + . '<head>' . LB + . ' <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . LB + . ' <meta http-equiv="Content-Style-Type" content="text/css">' . LB + . ' <meta http-equiv="Pragma" content="no-cache">' . LB + . ' <link href="precheck.css" rel="stylesheet" type="text/css">' . LB; + + /** + * Let's include JavaScript + */ + if ($this->step == 4) { + $retval .= ' <script type="text/javascript" src="core.js"></script>' . LB + . ' <script type="text/javascript" src="precheck.js"></script>' . LB; + } + + $retval .= ' <title>Geeklog-' . GL_VERSION . ' Precheck-' + . PRECHECK_VERSION . '</title>' . LB + . '</head>' . LB + . '<body>' . LB + . '<img src="fb.php?mode=imglogo" alt="Geeklogのロゴ">' + . '<h1>Geeklog-' . GL_VERSION . ' インストール前チェック(v' + . PRECHECK_VERSION . ')</h1>' . LB; + return $retval; + } + + /** + * Return site footer and HTMl footer + * + * @access public + * @return string + */ + function getFooter() + { + $retval = '<hr>' . LB + . '<p class="center small"><a href="http://www.geeklog.jp/" title="Geeklog.jpのサイトへジャンプ">Geeklog Japanese</a> | <a href="http://wiki.geeklog.jp/" title="Wiki Documentへジャンプ">Wiki Document</a></p>' . LB + . '</body>' . LB + . '</html>' . LB; + return $retval; + } + + /** + * Return navigation bar + * + * @access public + * @return string + */ + function getNav() + { + $class1 = ($this->step == 1) ? 'hilight' : 'normal'; + $class2 = ($this->step == 2) ? 'hilight' : 'normal'; + $class3 = ($this->step == 3) ? 'hilight' : 'normal'; + $class4 = ($this->step == 4) ? 'hilight' : 'normal'; + + $retval = '<ul class="navi">' . LB + . ' <li class="' . $class1 . '">Step 1. db-config.phpパス確認</li>' . LB + . ' <li class="' . $class2 . '">Step 2. インストールタイプ選択 </li>' . LB + . ' <li class="' . $class3 . '">Step 3. 初期診断</li>' . LB + . ' <li class="' . $class4 . '">Step 4. データベース情報入力</li>' . LB + . '</ul><br>' . LB; + + return $retval; + } + + /** + * Escape a string so we can print it as HTML + * + * @access public + * @param str string + * @return string + */ + function esc($str) + { + return htmlspecialchars($str, ENT_QUOTES, 'utf-8'); + } + + /** + * Display error info and warning info neatly + * + * @access public + * @param msg string + * @return string + */ + function displayErrorAndWarning($msg) + { + $retval = '<span class="'; + if (($this->error == 0) AND ($this->warning == 0)) { + $retval .= 'good">OK</span>'; + } else { + $retval .= ($this->error > 0) ? 'bad' : 'none'; + $retval .= '">' . $this->error . '個のエラー</span>と'; + $retval .= '<span class="'; + $retval .= ($this->warning > 0) ? 'warning' : 'none'; + $retval .= '">' . $this->warning . '個の警告</span>'; + } + + if ($msg != '') { + $retval .= '<br>'; + if (($this->error == 0) AND ($this->warning == 0)) { + $retval .= '<p class="good">' . $msg . '</p>'; + } else { + $retval .= $msg; + } + } + + return $retval; + } + + /** + * Guess the pasth to db-config.php + * + * @access public + * @return mixed - string = path, FALSE = didn't find path + */ + function guessDbConfigPath() + { + global $_CONF; + + // Check if siteconfig.php exists and it is valid + clearstatcache(); + $siteconfig = realpath(dirname(__FILE__) . '/../../siteconfig.php'); + if (file_exists($siteconfig)) { + require_once $siteconfig; + if (isset($_CONF['path']) + AND ($_CONF['path'] != '/path/to/Geeklog/') + AND file_exists($_CONF['path'] . 'db-config.php')) { + return $_CONF['path']; + } + } + + // Check the parent directory of path_html + $path = realpath(dirname(__FILE__) . '/../../../'); + clearstatcache(); + return file_exists($path . 'db-config.php') ? $path : FALSE; + } + + /** + * Check the default setting of PHP + * + * @access public + * @return string + */ + function menuCheckPHPSettings() + { + $this->error = $this->warning = 0; + $retval = ''; + $php6 = (version_compare(PHP_VERSION, '6') >= 0); + + // magic_quotes_gpc + if (!$php6 AND @get_magic_quotes_gpc()) { + $retval .= '<li class="warning"><strong>magic_quotes_gpc</strong>がオン になっています。文字化けの原因になるので、<strong>httpd.conf</strong>か <strong>php.ini</strong>、<strong>.htaccess</strong>でオフにすることをお勧め します。[<a href="precheck.php?mode=info&item=magic_quotes_gpc">詳しくは こちら</a>]。</li>' . LB; + $this->warning ++; + } + + // magic_quotes_runtime + if (!$php6 AND @get_magic_quotes_runtime()) { + $retval .= '<li class="warning"><strong>magic_quotes_runtime</strong>が オンになっています。文字化けの原因になるので、 <strong>siteconfig.php</strong>か<strong>httpd.conf</strong>、 <strong>php.ini</strong>、<strong>.htaccess</strong>でオフにすることをお勧め します。[<a href="precheck.php?mode=info&item=magic_quotes_runtime">詳し くはこちら</a>]。</li>' . LB; + $this->warning ++; + } + + if (!is_callable('ini_get')) { + $retval .= '<li class="bad"><strong>ini_get()関数が無効になっているの で、PHPの設定をチェックできませんでした。Webサーバの管理者に依頼して、 <strong>php.ini</strong>の<strong>disabled_functions</strong>の設定値から <strong>ini_get</strong>を除外するよう依頼してください。</li>' . LB; + $this->error ++; + } else { + // display_errors + if (ini_get('display_errors')) { + $retval .= '<li class="warning"><strong>display_errors</strong>がオンに なっています。エラー発生時に重要な情報を漏洩する原因になるので、 <strong>siteconfig.php</strong>か<strong>httpd.conf</strong>、 <strong>php.ini</strong>、<strong>.htaccess</strong>でオフにすることをお勧め します。[<a href="precheck.php?mode=info&item=display_errors">詳しくはこ ちら</a>]。</li>' . LB; + $this->warning ++; + } + + // magic_quotes_sybase + if (!$php6 AND @ini_get('magic_quotes_sybase')) { + $retval .= '<li class="warning"><strong>magic_quotes_sybase</strong>が オンになっています。文字化けの原因になるので、 <strong>siteconfig.php</strong>か<strong>httpd.conf</strong>、 <strong>php.ini</strong>、<strong>.htaccess</strong>でオフにすることをお勧め します。[<a href="precheck.php?mode=info&item=magic_quotes_sybase">詳し くはこちら</a>]。</li>' . LB; + $this->warning ++; + } + + // mbstring.language + $mbstring_language = ini_get('mbstring.language'); + if (strcasecmp($mbstring_language, 'japanese')) { + if (!strcasecmp($mbstring_language, 'neutral')) { + $retval .= '<li class="warning"><strong>mbstring.language</strong>に <strong>neutral</strong>が設定されています。文字化けするようなら、 <strong>httpd.conf</strong>、<strong>php.ini</strong>、 <strong>.htaccess</strong>で<strong>Japanese</strong>に設定することをお勧め します。[<a href="precheck.php?mode=info&item=mbstring_language">詳しく はこちら</a>]。</li>' . LB; + $this->warning ++; + } else { + $retval .= '<li class="bad"><strong>mbstring.language</strong>に <strong>Japanese</strong>以外の言語が設定されているようです。文字化けの原因 になるので、<strong>httpd.conf</strong>、<strong>php.ini</strong>、 <strong>.htaccess</strong>で<strong>Japanese</strong>に設定することをお勧め します。[<a href="precheck.php?mode=info&item=mbstring_language">詳しく はこちら</a>]。</li>' . LB; + $this->error ++; + } + } + + // mbstring.http_output + $mbstring_http_output = ini_get('mbstring.http_output'); + if (!strcasecmp($mbstring_http_output, 'pass') + AND !strcasecmp($mbstring_http_output, 'utf-8')) { + $retval .= '<li class="bad"><strong>mbstring.http_output</strong>に特定 の文字セットが設定されているようです。文字化けの原因になるので、 <strong>siteconfig.php</strong>か<strong>httpd.conf</strong>、 <strong>php.ini</strong>、<strong>.htaccess</strong>で <strong>pass</strong>に設定することをお勧めします。[<a href="precheck.php?mode=info&item=mbstring_http_output">詳しくはこちら </a>]。</li>' . LB; + $this->error ++; + } + + $mbstring_encoding_translation = @ini_get('mbstring.encoding_translation'); + if ($mbstring_encoding_translation) { + $retval .= '<li class="bad"><strong>mbstring.encoding_translation</strong>が <strong>On</strong>になっています。文字化けやセキュリティ低下の原因になるの で、<strong>httpd.conf</strong>、<strong>php.ini</strong>、 <strong>.htaccess</strong>で<strong>Off</strong>に設定することをお勧めしま す。[<a href="precheck.php?mode=info&item=mbstring_encoding_translation">詳しく はこちら</a>]。</li>' . LB; + $this->error ++; + } + + // mbstring.internal_encoding + $mbstring_internal_encoding = ini_get('mbstring.internal_encoding'); + if (($mbstring_internal_encoding != '') + AND !strcasecmp($mbstring_internal_encoding, 'utf-8')) { + $retval .= '<li class="warning"><strong>mbstring.internal_encoding</strong>に特定の文字セッ トが設定されているようです。文字化けの原因になるので、 <strong>siteconfig.php</strong>か<strong>httpd.conf</strong>、 <strong>php.ini</strong>、<strong>.htaccess</strong>で <strong>utf-8</strong>に設定することをお勧めします。[<a href="precheck.php?mode=info&item=mbstring_internal_encoding">詳しくはこ ちら</a>]。</li>' . LB; + $this->warning ++; + } + + // default_charset + $default_charset = @ini_get('default_charset'); + if (($default_charset != '') + AND !strcasecmp($default_charset, 'utf-8')) { + $retval .= '<li class="bad"><strong>default_charset</strong>に特定の文 字セットが設定されているようです。文字化けの原因になるので、 <strong>siteconfig.php</strong>か<strong>httpd.conf</strong>、 <strong>php.ini</strong>、<strong>.htaccess</strong>で <strong>\'\'</strong>(空文字列)か<strong>utf-8</strong>に設定することをお 勧めします。[<a href="precheck.php?mode=info&item=default_charset">詳し くはこちら</a>]</li>' . LB; + $this->error ++; + } + + // register_globals + if (!$php6 AND @ini_get('register_globals')) { + $retval .= '<li class="warning"><strong>register_globals</strong>が <strong>On</strong>になっています。セキュリティを低下させる原因になるので、 <strong>httpd.conf</strong>、<strong>php.ini</strong>、 <strong>.htaccess</strong>で<strong>Off</strong>に設定することをお勧めしま す。[<a href="precheck.php?mode=info&item=register_globals">詳しくはこち ら</a>]</li>' . LB; + $this->warning ++; + } + } + + if ($retval != '') { + $retval = '<ul>' . LB . $retval . '</ul>' . LB; + } + + return $retval; + } + + /** + * Check write permissions of paths + * + * @access public + * @return string + */ + function menuCheckWritable() + { + $this->error = $this->warning = 0; + $retval = ''; + $path = $this->path; + $path_html = realpath(dirname(__FILE__) . '/../../'); + + // path_html/siteconfig.php + clearstatcache(); + if (!is_writable($path_html . 'siteconfig.php')) { + $retval .= '<li class="bad"><strong>公開領域/siteconfig.php</strong>が書 き込み禁止になっています。</li>' . LB; + $this->error ++; + } + + // path/db-config.php + clearstatcache(); + if (!is_writable($path . 'db-config.php')) { + $retval .= '<li class="bad"><strong>非公開領域/db-config.php</strong>が 書き込み禁止になっています。</li>' . LB; + $this->error ++; + } + + // path/data + clearstatcache(); + if (!is_writable($path . 'data' . DS)) { + $retval .= '<li class="bad"><strong>非公開領域/data</strong>が書き込み禁 止になっています。</li>' . LB; + $this->error ++; + } + + // path/backups + clearstatcache(); + if (!is_writable($path . 'backups' . DS)) { + $retval .= '<li class="bad"><strong>非公開領域/backups</strong>が書き込 み禁止になっています。</li>' . LB; + $this->error ++; + } + + // path/logs/error.log + clearstatcache(); + if (!is_writable($path . 'logs' . DS . 'error.log')) { + $retval .= '<li class="bad"><strong>非公開領域/logs/error.log</strong>が 書き込み禁止になっています。</li>' . LB; + $this->error ++; + } + + // path/logs/access.log + clearstatcache(); + if (!is_writable($path . 'logs' . DS . 'access.log')) { + $retval .= '<li class="bad"><strong>非公開領域 /logs/access.log</strong>が書き込み禁止になっています。</li>' . LB; + $this->error ++; + } + + // path/logs/spamx.log + clearstatcache(); + if (!is_writable($path . 'logs' . DS . 'spamx.log')) { + $retval .= '<li class="bad"><strong>非公開領域/logs/spamx.log</strong>が 書き込み禁止になっています。</li>' . LB; + $this->error ++; + } + + // path_html/backend/geeklog.rss + clearstatcache(); + if (!is_writable($this->path_html . 'backend' . DS . 'geeklog.rss')) { + $retval .= '<li class="bad"><strong>公開領域 /backend/geeklog.rss</strong>が書き込み禁止になっています。</li>' . LB; + $this->error ++; + } + + // path_html/backend + clearstatcache(); + if (!is_writable($this->path_html . 'backend' . DS)) { + $retval .= '<li class="bad"><strong>公開領域/backend</strong>が書き込み 禁止になっています。</li>' . LB; + $this->error ++; + } + + if ($retval != '') { + $retval = '<ul>' . LB . $retval . '</ul>' . LB; + } + + return $retval; + } + + /** + * Return a string of information + * + * @access public + * @param item string + * @return string + */ + function getInfo($item) + { + $retval = '<div class="infobox">' . LB; + + switch ($item) { + case 'magic_quotes_gpc': // INI_PERDIR + $retval .= '<p>(<strong>php.ini</strong>で設定する場合)</p>' . LB + . '<code>magic_quotes_gpc = Off</code>' . LB + . '<p><strong>.htaccess</strong>で設定する場合)</p>' . LB + . '<code>php_flag magic_quotes_gpc Off</code>' . LB; + break; + + case 'magic_quotes_runtime': // INI_ALL + $retval .= '<p>(<strong>php.ini</strong>で設定する場合)</p>' . LB + . '<code>magic_quotes_runtime = Off</code>' . LB + . '<p>(<strong>.htaccess</strong>で設定する場合)</p>' . LB + . '<code>php_flag magic_quotes_runtime Off</code>' . LB + . '<p>(<strong>siteconfig.php</strong>で設定する場合)</p>' . LB + . '<code>@set_magic_quotes_runtime(FALSE);</code>' . LB; + break; + + case 'display_errors': // INI_ALL + $retval .= '<p>(<strong>php.ini</strong>で設定する場合)</p>' . LB + . '<code>display_errors = Off</code>' . LB + . '<p>(<strong>.htaccess</strong>で設定する場合)</p>' . LB + . '<code>php_flag display_errors Off</code>' . LB + . '<p>(<strong>siteconfig.php</strong>で設定する場合)</p>' . LB + . '<code>@ini_set(\'display_errors\', FALSE);</code>' . LB; + break; + + case 'magic_quotes_sybase': // INI_ALL + $retval .= '<p>(<strong>php.ini</strong>で設定する場合)</p>' . LB + . '<code>magic_quotes_sybase = Off</code>' . LB + . '<p>(<strong>.htaccess</strong>で設定する場合)</p>' . LB + . '<code>php_flag magic_quotes_sybase Off</code>' . LB + . '<p>(<strong>siteconfig.php</strong>で設定する場合)</p>' . LB + . '<code>@ini_set(\'magic_quotes_sybase\', FALSE);</code>' . LB; + break; + + case 'mbstring_language': // INI_PERDIR + $retval .= '<p>(<strong>php.ini</strong>で設定する場合)</p>' . LB + . '<code>mbstring.language = Japanese</code>' . LB + . '<p><strong>.htaccess</strong>で設定する場合)</p>' . LB + . '<code>php_value mbstring.language Japanese</code>' . LB; + break; + + case 'mbstring_http_output': // INI_ALL + $retval .= '<p>(<strong>php.ini</strong>で設定する場合)</p>' . LB + . '<code>mbstring.http_output = pass</code>' . LB + . '<p>(<strong>.htaccess</strong>で設定する場合)</p>' . LB + . '<code>php_value mbstring.http_output pass</code>' . LB + . '<p>(<strong>siteconfig.php</strong>で設定する場合)</p>' . LB + . '<code>@ini_set(\'mbstring.http_output\', \'pass\');</code>' . LB; + break; + + case 'mbstring_encoding_translation': // INI_PERDIR + $retval .= '<p>(<strong>php.ini</strong>で設定する場合)</p>' . LB + . '<code>mbstring.encoding_translation = Off</code>' . LB + . '<p><strong>.htaccess</strong>で設定する場合)</p>' . LB + . '<code>php_flag mbstring.encoding_translation Off</code>' . LB; + break; + + case 'mbstring_internal_encoding': // INI_ALL + $retval .= '<p>(<strong>php.ini</strong>で設定する場合)</p>' . LB + . '<code>mbstring.internal_encoding = utf-8</code>' . LB + . '<p>(<strong>.htaccess</strong>で設定する場合)</p>' . LB + . '<code>php_value mbstring.internal_encoding utf-8</code>' . LB + . '<p>(<strong>siteconfig.php</strong>で設定する場合)</p>' . LB + . '<code>@ini_set(\'mbstring.internal_encoding\', \'utf-8\');</code>' . LB; + break; + + case 'default_charset': // INI_ALL + $retval .= '<p>(<strong>php.ini</strong>で設定する場合)</p>' . LB + . '<code>default_charset = utf-8</code>' . LB + . '<p>(<strong>.htaccess</strong>で設定する場合)</p>' . LB + . '<code>php_value default_charset utf-8</code>' . LB + . '<p>(<strong>siteconfig.php</strong>で設定する場合)</p>' . LB + . '<code>@ini_set(\'default_charset\', \'utf-8\');</code>' . LB; + break; + + case 'register_globals': // INI_PERDIR + $retval .= '<p>(<strong>php.ini</strong>で設定する場合)</p>' . LB + . '<code>register_globals = Off</code>' . LB + . '<p><strong>.htaccess</strong>で設定する場合)</p>' . LB + . '<code>php_flag register_globals Off</code>' . LB; + break; + + default: + $retval = '?'; + } + + $retval .= '</div>' . LB + . '<p><a href="javascript:history.back()" title="JavaScriptをOffにして いる場合は、ブラウザの「戻る」ボタンで戻ってください">元のページに戻る </a></p>' . LB; + return $retval; + } + + /** + * Write the system path into "siteconfig.php" + * + * @access public + * @return boolean TRUE = success, FALSE = otherwise + */ + function writeSiteconfig() + { + $siteconfig = realpath(dirname(__FILE__) . '/../../siteconfig.php'); + clearstatcache(); + if (file_exists($siteconfig)) { + $content = file_get_contents($siteconfig); + if ($content !== FALSE) { + $path = str_replace("'", "\\'", $this->path); + $content = str_replace('/path/to/Geeklog/', $path, $content); + if (file_put_contents($siteconfig, $content) !== FALSE) { + return TRUE; + } + } + } + + return FALSE; + } + + /** + * Step 0: Check PHP settings + * + * @access private + */ + function _step0() + { + $retval = ''; + if (version_compare(PHP_VERSION, MIN_PHP_VERSION) < 0) { + $retval .= '<p class="error">PHPのバージョンが低すぎます。最低でも' + . MIN_PHP_VERSION . 'が必要です。</p>' . LB; + $this->fatal_error ++; + } + + $extensions = get_loaded_extensions(); + $extensions = array_map('strtolower', $extensions); + if (!in_array('mysql', $extensions) AND !in_array('mssql', $extensions)) { + $retval .= '<p class="error">PHPにデータベースを利用する機能が組み込まれ ていません。</p>' . LB; + $this->fatal_error ++; + } + + if (!in_array('mbstring', $extensions)) { + $retval .= '<p class="error">PHPに日本語処理関数(mbstring)が組み込まれて いません。</p>' . LB; + $this->fatal_error ++; + } + + if ($retval != '') { + $retval = '<h2>Step 0. PHPの設定確認</h2>' . LB + . '<p class="bad">致命的なエラーが見つかったため、インストールできませ ん。表示された<strong>赤い背景のエラー</strong>を解決してから、もう一度チェ ックし直してください。' . LB + . $retval; + } + + return $retval; + } + + /** + * Step 1: Guess the path to "db-config.php" + * + * @access private + */ + function _step1() + { + $this->path = $this->guessDbConfigPath(); + if ($this->path != '') { + header('Location: ' . THIS_SCRIPT . '?path=' . rawurlencode($this->path)); + exit; + } else { + $retval = '<h2>Step 1. db-config.phpのパス確認</h2>' . LB + . '<p class="error"><code>db-config.php</code>の場所がわかりません。 [<a href="fb.php">ファイルブラウザで探す</a>]をクリックしてください。 </p>' . LB; + } + + return $retval; + } + + /** + * Step 2: Select install type + * + * @access private + */ + function _step2() + { + $path = rawurlencode($this->path); + $retval = '<h2>Step 2. インストールタイプを選択してください:</h2>' . LB + . '<p class="large center">' . LB + . '<a href="' . THIS_SCRIPT . '?step=3&mode=install&path=' + . $path . '">' + . $this->esc('新規インストール') . '</a> | ' + . '<a href="' . THIS_SCRIPT . '?step=3&mode=upgrade&path=' + . $path . '">' . $this->esc('アップグレード') . '</a></p>' . LB; + return $retval; + } + + /** + * Check PHP settings and path permissions + * + * @access private + */ + function _step3() + { + $retval = '<h2>Step 3. 初期診断:</h2>' . LB + . '<ol>' . LB + . '<li><strong>PHPの設定チェック</strong>:' + . $this->displayErrorAndWarning($this->menuCheckPHPSettings()) + . '</li>' . LB; + $this->fatal_error += $this->error; + + if ($this->mode == 'install') { + $retval .= '<li><strong>ディレクトリ・パスが書き込み可かどうかのチェック </strong>:' + . $this->displayErrorAndWarning($this->menuCheckWritable()) + . '</li>' . LB; + $this->fatal_error += $this->error; + } + + $retval .= '</ol>' . LB + . '<hr>' . LB + . '<h2>診断結果:</h2>' . LB; + if ($this->fatal_error > 0) { + $retval .= '<p class="bad">致命的なエラーが見つかったため、インストール できません。表示された<strong>赤い背景のエラー</strong>を解決してから、もう 一度チェックし直してください。なお、<strong>黄色い背景の警告</strong>の部分 はとりあえず無視しても構いませんが、いったんインストールに成功したら、修正し てください。[<a class="large" href="' . THIS_SCRIPT . '">チェックし直す </a>]</p>' . LB; + } else { + if ($this->mode == 'install') { + $target = 'precheck.php?mode=install&step=4&path=' + . rawurlencode($this->path); + } else { + global $_DB_host, $_DB_name, $_DB_user, $_DB_pass, $_DB_table_prefix, $_DB_dbms; + + require_once $this->path . 'db-config.php'; + $target = 'index.php?mode=upgrade&language=japanese_utf-8' + . '&dbconfig_path=' + . rawurlencode($this->path . 'db-config.php'); + } + + $retval .= '<p class="good">致命的なエラーはなさそうなので、インストール できます。続行するには、下の「続行する」をクリックしてください。</p>' . LB + . '<form action="' . $target. '" method="post">' . LB + . '<p class="center"><input class="large" type="submit" name="submit" value="続行する"></p>' . LB; + if ($this->mode == 'upgrade') { + $retval .= '<input type="hidden" name="db_host" value="' + . $_DB_host . '">' . LB + . '<input type="hidden" name="db_name" value="' + . $_DB_name . '">' . LB + . '<input type="hidden" name="db_user" value="' + . $_DB_user . '">' . LB + . '<input type="hidden" name="db_pass" value="' + . $_DB_pass . '">' . LB + . '<input type="hidden" name="db_prefix" value="' + . $_DB_table_prefix . '">' . LB + . '<input type="hidden" name="db_type" value="' + . $_DB_dbms . '">' . LB; + } + + $retval .= '</form>' . LB; + } + + return $retval; + } + + /** + * Step 4. Check DB settings + * + * @access private + */ + function _step4() + { + $this->writeSiteconfig(); + $mode = $this->mode; + $language = 'japanese_utf-8'; + $path = rawurlencode($this->path . 'db-config.php'); + + $params = "mode={$mode}&language={$language}&dbconfig_path={$path}"; + + $retval = <<<EOD +<div id="container"> + <h2>Step 4. データベース情報入力</h2> + <form action="index.php?{$params}" method="post"> + <fieldset> + <legend>情報</legend> + <p><label class="lbl right">データベースの種類:</label> + <select id="db_type" name="db_type"> + <option value="mysql" selected="selected">MySQL</option> + <option value="mysql-innodb">MySQL (InnoDB)</option> + <option value="mssql">Microsoft SQL</option> + </select> + <p id="db_err" class="right"></p> + </p> + <p><label class="lbl right">データベースのホスト名:</label> + <input type="text" id="db_host" name="db_host" size="30" maxlength="30" value="localhost"> + <p><label class="lbl right">データベースのユーザ名:</label> + <input type="text" id="db_user" name="db_user" size="30" maxlength="30"> + </p> + <p><label class="lbl right">データベースのパスワード:</label> + <input type="password" id="db_pass" name="db_pass" size="30" maxlength="30"> + </p> + <p><label class="lbl right">データベース名:</label> + <span id="db_name_parent"><input type="text" id="db_name" name="db_name" size="30" maxlength="30"></span><span id="db_name_warning" class="hidden">(エラー:テーブルが既に存在しています。)</span> + </p> + <p><label class="lbl right">データベースの接頭子:</label> + <input type="text" id="db_prefix" name="db_prefix" size="30" maxlength="30" value="gl_"> + </p> + <p><label class="lbl right">UTF-8を使用する:</label> + <input id="utf8on" type="radio" name="utf8" value="on" checked="checked"> + <label for="utf8on">はい</label> + <input id="utf8off" type="radio" name="utf8" value="off"> + <label for="utf8off">いいえ</label> + </p> + </fieldset> + <p class="center"> + <input id="install_submit" class="large" type="submit" value="インストー ラへ"> + </p> + </form> +</div> +EOD; + return $retval; + } + + /** + * Try to look up DB tables + * + * @access public + * @param string $_GET['type'], $_GET['host'], $_GET['user'], + * $_GET['name'], $_GET['pass'] + * @return string DB names separated by a semicolon when success, + * otherwise '-ERR'. + */ + function lookupDb() + { + $retval = array(); + $err = '-ERR'; + + $type = isset($_GET['type']) ? $_GET['type'] : ''; + $host = isset($_GET['host']) ? $_GET['host'] : ''; + $user = isset($_GET['user']) ? $_GET['user'] : ''; + $pass = isset($_GET['pass']) ? $_GET['pass'] : ''; + if ($host == 'localhost') { + $host = '127.0.0.1'; + } + + if (($type == 'mysql') OR ($type == 'mysql-innodb')) { + if (($db = @mysql_connect($host, $user, $pass)) === FALSE) { + return $err; + } + + $v = mysql_get_server_info($db); + if (version_compare($v, MIN_MYSQL_VERSION) < 0) { + $err .= 'MySQLのバージョン(<strong>' . $v . '</strong>)が低すぎます。最 低でも<strong>' . MIN_MYSQL_VERSION . '</strong>が必要です。'; + return $err; + } + + if (($result = @mysql_list_dbs($db)) === FALSE) { + return $err; + } + + while (($A = mysql_fetch_object($result)) !== FALSE) { + $retval[] = $A->Database; + } + + $retval = implode(';', $retval); + if ($retval == '') { + $err .= 'データベースが作成されていません。phpMyAdminなどを利用して、 データベースを作成してください。'; + } + + return $retval; + } else { + if (($db = @mssql_connect($host, $user, $pass)) === FALSE) { + return $err; + } + + + + return ''; + } + } + + /** + * Return the number of tables in a given database + * + * @access public + * @param string $_GET['type'], $_GET['host'], $_GET['user'], + * $_GET['name'], $_GET['pass'], $_GET['prefix'] + * @return string '-ERR' = DB error, otherwise a string representong the + * number of tables the given DB has + */ + function countTable() + { + $err = '-ERR'; + + $type = isset($_GET['type']) ? $_GET['type'] : ''; + $host = isset($_GET['host']) ? $_GET['host'] : ''; + $user = isset($_GET['user']) ? $_GET['user'] : ''; + $pass = isset($_GET['pass']) ? $_GET['pass'] : ''; + $name = isset($_GET['name']) ? $_GET['name'] : ''; + $prefix = isset($_GET['prefix']) ? $_GET['prefix'] : ''; + if ($host == 'localhost') { + $host = '127.0.0.1'; + } + + if (($type == 'mysql') OR ($type == 'mysql-innodb')) { + if (($db = @mysql_connect($host, $user, $pass)) === FALSE) { + return $err; + } + + if (mysql_select_db($name, $db) === FALSE) { + return $err; + } + + // '_' is a wild character in MySQL, so we have to escape it with '\' + $prefix = str_replace('_', '\\_', $prefix); + if (($result = mysql_query("SHOW TABLES LIKE '{$prefix}%'", $db)) === FALSE) { + return $err; + } else { + $num = mysql_num_rows($result); + } + + if ($num === FALSE) { + return $err; + } else { + return (string) $num; + } + } else { + if (($db = @mssql_connect($host, $user, $pass)) === FALSE) { + return $err; + } + + + + return $err; + } + } +} + +//============================================================================= +// MAIN +//============================================================================= + +/** +* step 1. Check the path to "db-config.php" +* v +* step 2. Select install type +* v +* step 3. Check PHP settings and path permissions -- upgrade --+ +* v | +* step 4. Check DB settings | +* v | +* step 5. Redirect to public_html/admin/install/index.php <----+ +*/ + +// Get the request vars +$step = 0; +if (isset($_GET['step'])) { + $step = intval($_GET['step']); +} else if (isset($_POST['step'])) { + $step = intval($_POST['step']); +} +if (($step < 1) OR ($step > 4)) { + $step = 0; +} + +$mode = ''; +if (isset($_GET['mode'])) { + $mode = $_GET['mode']; +} else if (isset($_POST['mode'])) { + $mode = $_POST['mode']; +} +if (!in_array($mode, array('install', 'upgrade', 'info', 'lookupdb', 'counttable'))) { + $step = 2; +} + +$path = ''; +if (isset($_GET['path'])) { + $path = $_GET['path']; +} else if (isset($_POST['path'])) { + $path = $_POST['path']; +} +if ($path == '') { + $step = 0; +} else { + $path = str_replace("\\", '/', $path); + $path = rawurldecode($path); +} + +$p = new Precheck; +$p->mode = $mode; +$p->step = $step; +$p->path = $path; + +if ($mode == 'lookupdb') { + $result = $p->lookupDb(); + header('Content-Type: text/plain'); + echo $result; + exit; +} else if ($mode == 'counttable') { + $result = $p->countTable(); + header('Content-Type: text/plain'); + echo $result; + exit; +} + +$display = $p->getHeader(); +if ($mode == 'info') { + $display .= $p->getInfo($_GET['item']); +} else { + $display .= $p->getNav(); + + switch ($step) { + case 0: // Check PHP setting + $temp = $p->_step0(); + if ($temp != '') { + $display .= $temp; + break; + } + + /* Fall through intentionally */ + + case 1: // Check the path to "db-config.php" + $display .= $p->_step1(); + break; + + case 2: // Select install type + $display .= $p->_step2(); + break; + + case 3: // Check PHP settings and path permissions + $display .= $p->_step3(); + break; + + case 4: // Check DB settings + $display .= $p->_step4(); + break; + } +} + +$display .= $p->getFooter(); +echo $display;