OSDN Git Service

定数名修正(nucleus/language/english.php)
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / libs / globalfunctions.php
index 2ae695a..2b7aa02 100755 (executable)
@@ -2,7 +2,7 @@
 \r
 /*\r
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2007 The Nucleus Group\r
+ * Copyright (C) 2002-2009 The Nucleus Group\r
  *\r
  * This program is free software; you can redistribute it and/or\r
  * modify it under the terms of the GNU General Public License\r
  */\r
 /**\r
  * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2007 The Nucleus Group\r
- * @version $Id: globalfunctions.php,v 1.24 2008-02-08 09:31:22 kimitake Exp $\r
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group\r
+ * @version $Id$\r
  * $NucleusJP: globalfunctions.php,v 1.23.2.7 2008/02/05 08:30:08 kimitake Exp $\r
  */\r
 \r
 // needed if we include globalfunctions from install.php\r
 global $nucleus, $CONF, $DIR_LIBS, $DIR_LANG, $manager, $member;\r
 \r
-$nucleus['version'] = 'v3.4';\r
+$nucleus['version'] = 'v3.40RC';\r
 $nucleus['codename'] = '';\r
 \r
 checkVars(array('nucleus', 'CONF', 'DIR_LIBS', 'MYSQL_HOST', 'MYSQL_USER', 'MYSQL_PASSWORD', 'MYSQL_DATABASE', 'DIR_LANG', 'DIR_PLUGINS', 'HTTP_GET_VARS', 'HTTP_POST_VARS', 'HTTP_COOKIE_VARS', 'HTTP_ENV_VARS', 'HTTP_SESSION_VARS', 'HTTP_POST_FILES', 'HTTP_SERVER_VARS', 'GLOBALS', 'argv', 'argc', '_GET', '_POST', '_COOKIE', '_ENV', '_SESSION', '_SERVER', '_FILES'));\r
@@ -32,11 +32,6 @@ if ($CONF['debug']) {
        error_reporting(E_ERROR | E_WARNING | E_PARSE);\r
 }\r
 \r
-// Avoid notices\r
-if (!isset($CONF['Self'])) {\r
-       $CONF['Self'] = htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES);\r
-}\r
-\r
 /*\r
        Indicates when Nucleus should display startup errors. Set to 1 if you want\r
        the error enabled (default), false otherwise\r
@@ -51,15 +46,15 @@ if (!isset($CONF['Self'])) {
                more of the installation files (install.php, install.sql, upgrades/\r
                directory) are still on the server.\r
 */\r
-$CONF['alertOnHeadersSent'] = 1;\r
+$CONF['alertOnHeadersSent']  = 1;\r
 $CONF['alertOnSecurityRisk'] = 1;\r
-$CONF['ItemURL'] = $CONF['Self'];\r
-$CONF['ArchiveURL'] = $CONF['Self'];\r
-$CONF['ArchiveListURL'] = $CONF['Self'];\r
-$CONF['MemberURL'] = $CONF['Self'];\r
-$CONF['SearchURL'] = $CONF['Self'];\r
-$CONF['BlogURL'] = $CONF['Self'];\r
-$CONF['CategoryURL'] = $CONF['Self'];\r
+$CONF['ItemURL']             = $CONF['Self'];\r
+$CONF['ArchiveURL']          = $CONF['Self'];\r
+$CONF['ArchiveListURL']      = $CONF['Self'];\r
+$CONF['MemberURL']           = $CONF['Self'];\r
+$CONF['SearchURL']           = $CONF['Self'];\r
+$CONF['BlogURL']             = $CONF['Self'];\r
+$CONF['CategoryURL']         = $CONF['Self'];\r
 \r
 // switch URLMode back to normal when $CONF['Self'] ends in .php\r
 // this avoids urls like index.php/item/13/index.php/item/15\r
@@ -93,24 +88,24 @@ $orgRequestURI = serverVar('REQUEST_URI');
 sanitizeParams();\r
 \r
 // get all variables that can come from the request and put them in the global scope\r
-$blogid        = requestVar('blogid');\r
-$itemid        = intRequestVar('itemid');\r
-$catid = intRequestVar('catid');\r
-$skinid        = requestVar('skinid');\r
-$memberid = requestVar('memberid');\r
-$archivelist = requestVar('archivelist');\r
-$imagepopup = requestVar('imagepopup');\r
-$archive = requestVar('archive');\r
-$query = requestVar('query');\r
-$highlight = requestVar('highlight');\r
-$amount = requestVar('amount');\r
-$action = requestVar('action');\r
-$nextaction = requestVar('nextaction');\r
-$maxresults = requestVar('maxresults');\r
-$startpos = intRequestVar('startpos');\r
+$blogid       = requestVar('blogid');\r
+$itemid       = intRequestVar('itemid');\r
+$catid        = intRequestVar('catid');\r
+$skinid       = requestVar('skinid');\r
+$memberid     = requestVar('memberid');\r
+$archivelist  = requestVar('archivelist');\r
+$imagepopup   = requestVar('imagepopup');\r
+$archive      = requestVar('archive');\r
+$query        = requestVar('query');\r
+$highlight    = requestVar('highlight');\r
+$amount       = requestVar('amount');\r
+$action       = requestVar('action');\r
+$nextaction   = requestVar('nextaction');\r
+$maxresults   = requestVar('maxresults');\r
+$startpos     = intRequestVar('startpos');\r
 $errormessage = '';\r
-$error = '';\r
-$virtualpath = ((getVar('virtualpath') != null) ? getVar('virtualpath') : serverVar('PATH_INFO'));\r
+$error        = '';\r
+$virtualpath  = ((getVar('virtualpath') != null) ? getVar('virtualpath') : serverVar('PATH_INFO'));\r
 \r
 if (!headers_sent() ) {\r
        header('Generator: Nucleus CMS ' . $nucleus['version']);\r
@@ -161,6 +156,23 @@ register_shutdown_function('sql_disconnect');
 // read config\r
 getConfig();\r
 \r
+// Properly set $CONF['Self'] and others if it's not set... usually when we are access from admin menu\r
+if (!isset($CONF['Self'])) {\r
+       $CONF['Self'] = $CONF['IndexURL'];\r
+       // strip trailing /\r
+       if ($CONF['Self'][strlen($CONF['Self']) -1] == "/") {\r
+               $CONF['Self'] = substr($CONF['Self'], 0, strlen($CONF['Self']) -1);\r
+       }\r
+\r
+       $CONF['ItemURL']        = $CONF['Self'];\r
+       $CONF['ArchiveURL']     = $CONF['Self'];\r
+       $CONF['ArchiveListURL'] = $CONF['Self'];\r
+       $CONF['MemberURL']      = $CONF['Self'];\r
+       $CONF['SearchURL']      = $CONF['Self'];\r
+       $CONF['BlogURL']        = $CONF['Self'];\r
+       $CONF['CategoryURL']    = $CONF['Self'];\r
+}\r
+\r
 // automatically use simpler toolbar for mozilla\r
 if (($CONF['DisableJsTools'] == 0) && strstr(serverVar('HTTP_USER_AGENT'), 'Mozilla/5.0') && strstr(serverVar('HTTP_USER_AGENT'), 'Gecko') ) {\r
        $CONF['DisableJsTools'] = 2;\r
@@ -308,7 +320,7 @@ $language = getLanguageName();
 include($DIR_LANG . ereg_replace( '[\\|/]', '', $language) . '.php');\r
 \r
 // check if valid charset\r
-if (!encoding_check(false,false,_CHARSET)) {\r
+if (!encoding_check(false, false, _CHARSET)) {\r
        foreach(array($_REQUEST, $_SERVER) as $input) {\r
                array_walk($input, 'encoding_check');\r
        }\r
@@ -572,10 +584,10 @@ function sendContentType($contenttype, $pagetype = '', $charset = _CHARSET) {
  * Errors before the database connection has been made\r
  */\r
 function startUpError($msg, $title) {\r
-       if (!defined('_CHARSET')) define('_CHARSET','iso-8859-1');\r
+       if (!defined('_CHARSET')) define('_CHARSET', 'iso-8859-1');\r
        header('Content-Type: text/html; charset=' . _CHARSET);\r
        ?>\r
-       <html xmlns="http://www.w3.org/1999/xhtml">\r
+       <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>\r
                <head><meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET?>" />\r
                <title><?php echo htmlspecialchars($title)?></title></head>\r
                <body>\r
@@ -929,11 +941,11 @@ function selector() {
                global $startpos;\r
                $type = 'search';\r
                $query = stripslashes($query);\r
-               if(preg_match("/^(\xA1{2}|\xe3\x80{2}|\x20)+$/",$query)){\r
+               if(preg_match("/^(\xA1{2}|\xe3\x80{2}|\x20)+$/", $query)){\r
                                        $type = 'index';\r
                }\r
                $order = (_CHARSET == 'EUC-JP') ? 'EUC-JP, UTF-8,' : 'UTF-8, EUC-JP,';\r
-               $query = mb_convert_encoding($query, _CHARSET, $order.' JIS, SJIS, ASCII');\r
+               $query = mb_convert_encoding($query, _CHARSET, $order . ' JIS, SJIS, ASCII');\r
                if (is_numeric($blogid)) {\r
                        $blogid = intVal($blogid);\r
                } else {\r
@@ -1085,7 +1097,7 @@ function shorten($text, $maxlength, $toadd) {
 //     $trans = get_html_translation_table(HTML_ENTITIES);\r
        $trans = get_html_translation_table(HTML_SPECIALCHARS); // for Japanese\r
        $trans = array_flip($trans);\r
-       $text = strtr($text, $trans);\r
+       $text  = strtr($text, $trans);\r
 \r
        // 2. the actual shortening\r
        if (strlen($text) > $maxlength)\r
@@ -1922,7 +1934,7 @@ function revertArrayForSanitizing($array, &$dst)
  * - the URL will be stripped of illegal or dangerous characters\r
  */\r
 function redirect($url) {\r
-       $url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:@%]|i', '', $url);\r
+       $url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:@%*]|i', '', $url);\r
        header('Location: ' . $url);\r
        exit;\r
 }\r
@@ -2024,10 +2036,10 @@ function encode_desc(&$data)
     {   //_$to_entities = get_html_translation_table(HTML_ENTITIES);\r
         $to_entities = get_html_translation_table(HTML_SPECIALCHARS);\r
         $from_entities = array_flip($to_entities);\r
-        $data = str_replace('<br />','\n',$data); //hack\r
+        $data = str_replace('<br />', '\n', $data); //hack\r
         $data = strtr($data,$from_entities);\r
         $data = strtr($data,$to_entities);\r
-        $data = str_replace('\n','<br />',$data); //hack\r
+        $data = str_replace('\n', '<br />', $data); //hack\r
         return $data;\r
     }\r
  \r
@@ -2076,4 +2088,4 @@ function numberOfEventSubscriber($event) {
        return $obj->count;\r
 }\r
 \r
-?>\r
+?>
\ No newline at end of file