OSDN Git Service

# FIXED: atom.phpとxml-rss2.phpで_CHARSETをチェックして文字コード変換(Nicleus3.41 へアップグレード後 xml-rss2...
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / libs / globalfunctions.php
index 93deb47..3f11b48 100755 (executable)
@@ -20,7 +20,7 @@
 // needed if we include globalfunctions from install.php\r
 global $nucleus, $CONF, $DIR_LIBS, $DIR_LANG, $manager, $member;\r
 \r
-$nucleus['version'] = 'v3.40RC';\r
+$nucleus['version'] = 'v3.5SVN';\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
@@ -46,9 +46,10 @@ if ($CONF['debug']) {
                more of the installation files (install.php, install.sql, upgrades/\r
                directory) are still on the server.\r
 */\r
+\r
 $CONF['alertOnHeadersSent']  = 1;\r
 $CONF['alertOnSecurityRisk'] = 1;\r
-$CONF['ItemURL']             = $CONF['Self'];\r
+/*$CONF['ItemURL']             = $CONF['Self'];\r
 $CONF['ArchiveURL']          = $CONF['Self'];\r
 $CONF['ArchiveListURL']      = $CONF['Self'];\r
 $CONF['MemberURL']           = $CONF['Self'];\r
@@ -60,7 +61,7 @@ $CONF['CategoryURL']         = $CONF['Self'];
 // this avoids urls like index.php/item/13/index.php/item/15\r
 if (!isset($CONF['URLMode']) || (($CONF['URLMode'] == 'pathinfo') && (substr($CONF['Self'], strlen($CONF['Self']) - 4) == '.php'))) {\r
        $CONF['URLMode'] = 'normal';\r
-}\r
+}*/\r
 \r
 if (getNucleusPatchLevel() > 0) {\r
        $nucleus['version'] .= '/' . getNucleusPatchLevel();\r
@@ -105,6 +106,7 @@ $maxresults   = requestVar('maxresults');
 $startpos     = intRequestVar('startpos');\r
 $errormessage = '';\r
 $error        = '';\r
+$special      = requestVar('special');\r
 $virtualpath  = ((getVar('virtualpath') != null) ? getVar('virtualpath') : serverVar('PATH_INFO'));\r
 \r
 if (!headers_sent() ) {\r
@@ -118,7 +120,7 @@ include($DIR_LIBS . 'ACTIONLOG.php');
 include($DIR_LIBS . 'MANAGER.php');\r
 include($DIR_LIBS . 'PLUGIN.php');\r
 \r
-$manager =& MANAGER::instance();\r
+$manager = MANAGER::instance();\r
 \r
 // make sure there's no unnecessary escaping:\r
 set_magic_quotes_runtime(0);\r
@@ -164,13 +166,27 @@ if (!isset($CONF['Self'])) {
                $CONF['Self'] = substr($CONF['Self'], 0, strlen($CONF['Self']) -1);\r
        }\r
 \r
-       $CONF['ItemURL']        = $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
+       $CONF['CategoryURL']    = $CONF['Self'];*/\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
+// 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
+if (!isset($CONF['URLMode']) || (($CONF['URLMode'] == 'pathinfo') && (substr($CONF['Self'], strlen($CONF['Self']) - 4) == '.php'))) {\r
+       $CONF['URLMode'] = 'normal';\r
 }\r
 \r
 // automatically use simpler toolbar for mozilla\r
@@ -225,7 +241,7 @@ if ($action == 'login') {
                        $action = $nextaction;\r
                }\r
 \r
-               $manager->notify('LoginSuccess', array('member' => &$member) );\r
+               $manager->notify('LoginSuccess', array('member' => &$member, 'username' => $login) );\r
                $errormessage = '';\r
                ACTIONLOG::add(INFO, "Login successful for $login (sharedpc=$shared)");\r
        } else {\r
@@ -321,7 +337,7 @@ include($DIR_LANG . ereg_replace( '[\\|/]', '', $language) . '.php');
 \r
 // check if valid charset\r
 if (!encoding_check(false, false, _CHARSET)) {\r
-       foreach(array($_REQUEST, $_SERVER) as $input) {\r
+       foreach(array($_GET, $_POST) as $input) {\r
                array_walk($input, 'encoding_check');\r
        }\r
 }\r
@@ -345,6 +361,7 @@ if (!defined('_MEMBERS_BYPASS'))
 if (!defined('_ARCHIVETYPE_MONTH') ) {\r
        define('_ARCHIVETYPE_DAY', 'day');\r
        define('_ARCHIVETYPE_MONTH', 'month');\r
+       define('_ARCHIVETYPE_YEAR', 'year');\r
 }\r
 \r
 // decode path_info\r
@@ -374,7 +391,7 @@ if ($CONF['URLMode'] == 'pathinfo') {
                $CONF['CategoryKey'] = 'category';\r
        }\r
 \r
-       if ($CONF['SpecialskinKey'] == '') {\r
+       if (!isset($CONF['SpecialskinKey']) || $CONF['SpecialskinKey'] == '') {\r
                $CONF['SpecialskinKey'] = 'special';\r
        }\r
 \r
@@ -482,7 +499,7 @@ function intCookieVar($name) {
   * returns the currently used version (100 = 1.00, 101 = 1.01, etc...)\r
   */\r
 function getNucleusVersion() {\r
-       return 340;\r
+       return 341;\r
 }\r
 \r
 /**\r
@@ -495,6 +512,25 @@ function getNucleusPatchLevel() {
 }\r
 \r
 /**\r
+ * returns the latest version available for download from nucleuscms.org \r
+ * or false if unable to attain data\r
+ * format will be major.minor/patachlevel\r
+ * e.g. 3.41 or 3.41/02\r
+ */\r
+function getLatestVersion() {\r
+       if (!function_exists('curl_init')) return false;\r
+       $crl = curl_init();\r
+       $timeout = 5;\r
+       curl_setopt ($crl, CURLOPT_URL,'http://nucleuscms.org/version_check.php');\r
+       curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);\r
+       curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);\r
+       $ret = curl_exec($crl);\r
+       curl_close($crl);\r
+       return $ret;\r
+\r
+}\r
+\r
+/**\r
   * Connects to mysql server\r
   */\r
 function sql_connect() {\r
@@ -503,6 +539,18 @@ function sql_connect() {
        $MYSQL_CONN = @mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD) or startUpError('<p>Could not connect to MySQL database.</p>', 'Connect Error');\r
        mysql_select_db($MYSQL_DATABASE) or startUpError('<p>Could not select database: ' . mysql_error() . '</p>', 'Connect Error');\r
 \r
+/*/ <add for garble measure>\r
+       $resource = sql_query("show variables LIKE 'character_set_database'");\r
+       $fetchDat = mysql_fetch_assoc($resource);\r
+       $charset  = $fetchDat['Value'];\r
+       $mySqlVer = implode('.', array_map('intval', explode('.', mysql_get_server_info($MYSQL_CONN))));\r
+       if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') {\r
+               mysql_set_charset($charset);\r
+       } elseif ($mySqlVer >= '4.1.0') {\r
+               sql_query("SET NAMES " . $charset);\r
+       }\r
+// </add for garble measure>*/\r
+\r
        return $MYSQL_CONN;\r
 }\r
 \r
@@ -573,7 +621,7 @@ function sendContentType($contenttype, $pagetype = '', $charset = _CHARSET) {
 \r
                // check if valid charset\r
                if (!encoding_check(false,false,$charset)) {\r
-                       foreach(array($_REQUEST, $_SERVER) as $input) {\r
+                       foreach(array($_GET, $_POST) as $input) {\r
                                array_walk($input, 'encoding_check');\r
                        }\r
                }\r
@@ -677,7 +725,7 @@ function parseHighlight($query) {
        // get rid of quotes\r
        $query = preg_replace('/\'|"/', '', $query);\r
 \r
-       if (!query) {\r
+       if (!$query) {\r
                return array();\r
        }\r
 \r
@@ -686,9 +734,9 @@ function parseHighlight($query) {
        for ($i = 0; $i < count($aHighlight); $i++) {\r
                $aHighlight[$i] = trim($aHighlight[$i]);\r
 \r
-               if (strlen($aHighlight[$i]) < 3) {\r
-                       unset($aHighlight[$i]);\r
-               }\r
+//             if (strlen($aHighlight[$i]) < 3) {\r
+//                     unset($aHighlight[$i]);\r
+//             }\r
        }\r
 \r
        if (count($aHighlight) == 1) {\r
@@ -750,7 +798,7 @@ function getPluginNameFromPid($pid) {
 function selector() {\r
        global $itemid, $blogid, $memberid, $query, $amount, $archivelist, $maxresults;\r
        global $archive, $skinid, $blog, $memberinfo, $CONF, $member;\r
-       global $imagepopup, $catid;\r
+       global $imagepopup, $catid, $special;\r
        global $manager;\r
 \r
        $actionNames = array('addcomment', 'sendmessage', 'createaccount', 'forgotpassword', 'votepositive', 'votenegative', 'plugin');\r
@@ -773,14 +821,14 @@ function selector() {
                // try to get line number/filename (extra headers_sent params only exists in PHP 4.3+)\r
                if (function_exists('version_compare') && version_compare('4.3.0', phpversion(), '<=') ) {\r
                        headers_sent($hsFile, $hsLine);\r
-                       $extraInfo = ' in <code>' . $hsFile . '</code> line <code>' . $hsLine . '</code>';\r
+                       $extraInfo = sprintf(_GFUNCTIONS_HEADERSALREADYSENT_FILE,$hsFile,$hsLine);\r
                } else {\r
                        $extraInfo = '';\r
                }\r
 \r
                startUpError(\r
-                       '<p>The page headers have already been sent out' . $extraInfo . '. This could cause Nucleus not to work in the expected way.</p><p>Usually, this is caused by spaces or newlines at the end of the <code>config.php</code> file, at the end of the language file or at the end of a plugin file. Please check this and try again.</p><p>If you don\'t want to see this error message again, without solving the problem, set <code>$CONF[\'alertOnHeadersSent\']</code> in <code>globalfunctions.php</code> to <code>0</code></p>',\r
-                       'Page headers already sent'\r
+                       sprintf(_GFUNCTIONS_HEADERSALREADYSENT_TXT,$extraInfo),\r
+                       _GFUNCTIONS_HEADERSALREADYSENT_TITLE\r
                );\r
                exit;\r
        }\r
@@ -871,7 +919,7 @@ function selector() {
 \r
                // get next and prev month links ...\r
                global $archivenext, $archiveprev, $archivetype, $archivenextexists, $archiveprevexists;\r
-               \r
+\r
                // sql queries for the timestamp of the first and the last published item\r
                $query = "SELECT UNIX_TIMESTAMP(itime) as result FROM ".sql_table('item')." WHERE idraft=0 AND iblog=".(int)($blogid ? $blogid : $CONF['DefaultBlog'])." ORDER BY itime ASC";\r
                $first_timestamp=quickQuery ($query);\r
@@ -883,18 +931,18 @@ function selector() {
                if ($d != 0) {\r
                        $archivetype = _ARCHIVETYPE_DAY;\r
                        $t = mktime(0, 0, 0, $m, $d, $y);\r
-                       // one day has 24 * 60 * 60 = 86400 seconds                     \r
+                       // one day has 24 * 60 * 60 = 86400 seconds\r
                        $archiveprev = strftime('%Y-%m-%d', $t - 86400 );\r
-                       // check for published items                    \r
+                       // check for published items\r
                        if ($t > $first_timestamp) {\r
                                $archiveprevexists = true;\r
                        }\r
                        else {\r
                                $archiveprevexists = false;\r
                        }\r
-                       \r
+\r
                        // one day later\r
-                       $t += 86400; \r
+                       $t += 86400;\r
                        $archivenext = strftime('%Y-%m-%d', $t);\r
                        if ($t < $last_timestamp) {\r
                                $archivenextexists = true;\r
@@ -902,7 +950,28 @@ function selector() {
                        else {\r
                                $archivenextexists = false;\r
                        }\r
-                       \r
+\r
+               } elseif ($m == 0) {\r
+                       $archivetype = _ARCHIVETYPE_YEAR;\r
+                       $t = mktime(0, 0, 0, 12, 31, $y - 1);\r
+                       // one day before is in the previous year\r
+                       $archiveprev = strftime('%Y', $t);\r
+                       if ($t > $first_timestamp) {\r
+                               $archiveprevexists = true;\r
+                       }\r
+                       else {\r
+                               $archiveprevexists = false;\r
+                       }\r
+\r
+                       // timestamp for the next year\r
+                       $t = mktime(0, 0, 0, 1, 1, $y + 1);\r
+                       $archivenext = strftime('%Y', $t);\r
+                       if ($t < $last_timestamp) {\r
+                               $archivenextexists = true;\r
+                       }\r
+                       else {\r
+                               $archivenextexists = false;\r
+                       }\r
                } else {\r
                        $archivetype = _ARCHIVETYPE_MONTH;\r
                        $t = mktime(0, 0, 0, $m, 1, $y);\r
@@ -914,8 +983,8 @@ function selector() {
                        else {\r
                                $archiveprevexists = false;\r
                        }\r
-                       \r
-                       // timestamp for the next month                 \r
+\r
+                       // timestamp for the next month\r
                        $t = mktime(0, 0, 0, $m+1, 1, $y);\r
                        $archivenext = strftime('%Y-%m', $t);\r
                        if ($t < $last_timestamp) {\r
@@ -946,8 +1015,26 @@ function selector() {
                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
+//             $order = (_CHARSET == 'EUC-JP') ? 'EUC-JP, UTF-8,' : 'UTF-8, EUC-JP,';\r
+//             $query = mb_convert_encoding($query, _CHARSET, $order . ' JIS, SJIS, ASCII');\r
+               switch(strtolower(_CHARSET)){\r
+                       case 'utf-8':\r
+                               $order = 'ASCII, UTF-8, EUC-JP, JIS, SJIS, EUC-CN, ISO-8859-1';\r
+                               break;\r
+                       case 'gb2312':\r
+                               $order = 'ASCII, EUC-CN, EUC-JP, UTF-8, JIS, SJIS, ISO-8859-1';\r
+                               break;\r
+                       case 'shift_jis':\r
+                               // Note that shift_jis is only supported for output.\r
+                               // Using shift_jis in DB is prohibited.\r
+                               $order = 'ASCII, SJIS, EUC-JP, UTF-8, JIS, EUC-CN, ISO-8859-1';\r
+                               break;\r
+                       default:\r
+                               // euc-jp,iso-8859-x,windows-125x\r
+                               $order = 'ASCII, EUC-JP, UTF-8, JIS, SJIS, EUC-CN, ISO-8859-1';\r
+                               break;\r
+               }\r
+               $query = mb_convert_encoding($query, _CHARSET, $order);\r
                if (is_numeric($blogid)) {\r
                        $blogid = intVal($blogid);\r
                } else {\r
@@ -979,6 +1066,11 @@ function selector() {
                $type = 'index';\r
        }\r
 \r
+       // any type of skin with catid\r
+       if ($catid && !$blogid) {\r
+               $blogid = getBlogIDFromCatID($catid);\r
+       }\r
+\r
        // decide which blog should be displayed\r
        if (!$blogid) {\r
                $blogid = $CONF['DefaultBlog'];\r
@@ -993,7 +1085,12 @@ function selector() {
 \r
        // set catid if necessary\r
        if ($catid) {\r
-               $blog->setSelectedCategory($catid);\r
+               // check if the category is valid\r
+               if (!$blog->isValidCategory($catid)) {\r
+                       doError(_ERROR_NOSUCHCATEGORY);\r
+               } else {\r
+                       $blog->setSelectedCategory($catid);\r
+               }\r
        }\r
 \r
        // decide which skin should be used\r
@@ -1005,7 +1102,7 @@ function selector() {
                $skinid = $blog->getDefaultSkin();\r
        }\r
 \r
-       $special = requestVar('special');\r
+       //$special = requestVar('special'); //get at top of file as global\r
        if (!empty($special) && isValidShortName($special)) {\r
                $type = strtolower($special);\r
        }\r
@@ -1046,6 +1143,7 @@ function doError($msg, $skin = '') {
 \r
        }\r
 \r
+       $skinid = $skin->id;\r
        $errormessage = $msg;\r
        $skin->parse('error');\r
        exit;\r
@@ -1102,8 +1200,10 @@ function shorten($text, $maxlength, $toadd) {
        $text  = strtr($text, $trans);\r
 \r
        // 2. the actual shortening\r
-       if (strlen($text) > $maxlength)\r
-               $text = mb_strimwidth($text, 0, $maxlength, $toadd, _CHARSET);\r
+       if (strlen($text) > $maxlength) {\r
+//             $text = substr($text, 0, $maxlength - strlen($toadd) ) . $toadd;\r
+               $text = mb_strimwidth($text, 0, $maxlength, $toadd, _CHARSET); // for Japanese\r
+       }\r
        return $text;\r
 }\r
 \r
@@ -1167,7 +1267,7 @@ function parseFile($filename, $includeMode = 'normal', $includePrefix = '') {
        PARSER::setProperty('IncludePrefix', $includePrefix);\r
 \r
        if (!file_exists($filename) ) {\r
-               doError('A file is missing');\r
+               doError(_GFUNCTIONS_PARSEFILE_FILEMISSING);\r
        }\r
 \r
        $fsize = filesize($filename);\r
@@ -1203,11 +1303,13 @@ function help($id) {
 }\r
 \r
 function helpHtml($id) {\r
-       return helplink($id) . '<img src="documentation/icon-help.gif" width="15" height="15" alt="' . _HELP_TT . '" /></a>';\r
+       global $CONF;\r
+       return helplink($id) . '<img src="' . $CONF['AdminURL'] . 'documentation/icon-help.gif" width="15" height="15" alt="' . _HELP_TT . '" title="' . _HELP_TT . '" /></a>';\r
 }\r
 \r
 function helplink($id) {\r
-       return '<a href="documentation/help.html#'. $id . '" onclick="if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);">';\r
+       global $CONF;\r
+       return '<a href="' . $CONF['AdminURL'] . 'documentation/help.html#'. $id . '" onclick="if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);">';\r
 }\r
 \r
 function getMailFooter() {\r
@@ -1626,67 +1728,67 @@ function checkVars($aVars) {
 }\r
 \r
 \r
-/** \r
+/**\r
  * Sanitize parameters such as $_GET and $_SERVER['REQUEST_URI'] etc.\r
- * to avoid XSS \r
+ * to avoid XSS\r
  */\r
 function sanitizeParams()\r
 {\r
        global $HTTP_SERVER_VARS;\r
-       \r
+\r
        $array = array();\r
        $str = '';\r
        $frontParam = '';\r
-       \r
+\r
        // REQUEST_URI of $HTTP_SERVER_VARS\r
        $str =& $HTTP_SERVER_VARS["REQUEST_URI"];\r
        serverStringToArray($str, $array, $frontParam);\r
        sanitizeArray($array);\r
        arrayToServerString($array, $frontParam, $str);\r
-       \r
+\r
        // QUERY_STRING of $HTTP_SERVER_VARS\r
        $str =& $HTTP_SERVER_VARS["QUERY_STRING"];\r
        serverStringToArray($str, $array, $frontParam);\r
        sanitizeArray($array);\r
        arrayToServerString($array, $frontParam, $str);\r
-       \r
+\r
        if (phpversion() >= '4.1.0') {\r
                // REQUEST_URI of $_SERVER\r
                $str =& $_SERVER["REQUEST_URI"];\r
                serverStringToArray($str, $array, $frontParam);\r
                sanitizeArray($array);\r
                arrayToServerString($array, $frontParam, $str);\r
-       \r
+\r
                // QUERY_STRING of $_SERVER\r
                $str =& $_SERVER["QUERY_STRING"];\r
                serverStringToArray($str, $array, $frontParam);\r
                sanitizeArray($array);\r
                arrayToServerString($array, $frontParam, $str);\r
        }\r
-       \r
+\r
        // $_GET\r
        convArrayForSanitizing($_GET, $array);\r
        sanitizeArray($array);\r
        revertArrayForSanitizing($array, $_GET);\r
-       \r
+\r
        // $_REQUEST (only GET param)\r
        convArrayForSanitizing($_REQUEST, $array);\r
        sanitizeArray($array);\r
        revertArrayForSanitizing($array, $_REQUEST);\r
 }\r
 \r
-/** \r
+/**\r
  * Check ticket when not checked in plugin's admin page\r
  * to avoid CSRF.\r
  * Also avoid the access to plugin/index.php by guest user.\r
  */\r
 function ticketForPlugin(){\r
        global $CONF,$DIR_PLUGINS,$member,$ticketforplugin;\r
-       \r
+\r
        /* initialize */\r
        $ticketforplugin=array();\r
        $ticketforplugin['ticket']=false;\r
-       \r
+\r
        /* Check if using plugin's php file. */\r
        if ($p_translated=serverVar('PATH_TRANSLATED')) {\r
                if (!file_exists($p_translated)) $p_translated='';\r
@@ -1701,13 +1803,13 @@ function ticketForPlugin(){
        $p_translated=str_replace('\\','/',$p_translated);\r
        $d_plugins=str_replace('\\','/',$DIR_PLUGINS);\r
        if (strpos($p_translated,$d_plugins)!==0) return;// This isn't plugin php file.\r
-       \r
+\r
        /* Solve the plugin php file or admin directory */\r
        $phppath=substr($p_translated,strlen($d_plugins));\r
        $phppath=preg_replace('!^/!','',$phppath);// Remove the first "/" if exists.\r
        $path=preg_replace('/^NP_(.*)\.php$/','$1',$phppath); // Remove the first "NP_" and the last ".php" if exists.\r
        $path=preg_replace('!^([^/]*)/(.*)$!','$1',$path); // Remove the "/" and beyond.\r
-       \r
+\r
        /* Solve the plugin name. */\r
        $plugins=array();\r
        $query='SELECT pfile FROM '.sql_table('plugin');\r
@@ -1723,16 +1825,16 @@ function ticketForPlugin(){
                header("HTTP/1.0 404 Not Found");\r
                exit('');\r
        }\r
-       \r
+\r
        /* Return if not index.php */\r
        if ( $phppath!=strtolower($plugin_name).'/'\r
                && $phppath!=strtolower($plugin_name).'/index.php' ) return;\r
-       \r
+\r
        /* Exit if not logged in. */\r
-       if ( !$member->isLoggedIn() ) exit("You aren't logged in.");\r
-       \r
+       if ( !$member->isLoggedIn() ) exit(_GFUNCTIONS_YOU_AERNT_LOGGEDIN);\r
+\r
        global $manager,$DIR_LIBS,$DIR_LANG,$HTTP_GET_VARS,$HTTP_POST_VARS;\r
-       \r
+\r
        /* Check if this feature is needed (ie, if "$manager->checkTicket()" is not included in the script). */\r
        if (!($p_translated=serverVar('PATH_TRANSLATED'))) $p_translated=serverVar('SCRIPT_FILENAME');\r
        if ($file=@file($p_translated)) {\r
@@ -1742,7 +1844,7 @@ function ticketForPlugin(){
                        $prevline=$line;\r
                }\r
        }\r
-       \r
+\r
        /* Show a form if not valid ticket */\r
        if ( ( strstr(serverVar('REQUEST_URI'),'?') || serverVar('QUERY_STRING')\r
                        || strtoupper(serverVar('REQUEST_METHOD'))=='POST' )\r
@@ -1762,7 +1864,7 @@ function ticketForPlugin(){
                $oPluginAdmin = new PluginAdmin($plugin_name);\r
                $oPluginAdmin->start();\r
                echo '<p>' . _ERROR_BADTICKET . "</p>\n";\r
-               \r
+\r
                /* Show the form to confirm action */\r
                // PHP 4.0.x support\r
                $get=  (isset($_GET))  ? $_GET  : $HTTP_GET_VARS;\r
@@ -1793,11 +1895,11 @@ function ticketForPlugin(){
                echo '<input type="submit" value="'._YES.'" />&nbsp;&nbsp;&nbsp;&nbsp;';\r
                echo '<input type="button" value="'._NO.'" onclick="history.back(); return false;" />';\r
                echo "</form>\n";\r
-               \r
+\r
                $oPluginAdmin->end();\r
                exit;\r
        }\r
-       \r
+\r
        /* Create new ticket */\r
        $ticket=$manager->addTicketToUrl('');\r
        $ticketforplugin['ticket']=substr($ticket,strpos($ticket,'ticket=')+7);\r
@@ -1815,7 +1917,7 @@ function _addInputTags(&$keys,$prefix=''){
        }\r
 }\r
 \r
-/** \r
+/**\r
  * Convert the server string such as $_SERVER['REQUEST_URI']\r
  * to arry like arry['blogid']=1 and array['page']=2 etc.\r
  */\r
@@ -1833,7 +1935,7 @@ function serverStringToArray($str, &$array, &$frontParam)
                $args = $str;\r
                $frontParam = "";\r
        }\r
-       \r
+\r
        // If there is no args like blogid=1&page=2, return\r
        if (!strstr($str, "=") && !strlen($frontParam)) {\r
                $frontParam = $str;\r
@@ -1843,7 +1945,7 @@ function serverStringToArray($str, &$array, &$frontParam)
        $array = explode("&", $args);\r
 }\r
 \r
-/** \r
+/**\r
  * Convert array like array['blogid'] to server string\r
  * such as $_SERVER['REQUEST_URI']\r
  */\r
@@ -1859,14 +1961,14 @@ function arrayToServerString($array, $frontParam, &$str)
        }\r
 }\r
 \r
-/** \r
+/**\r
  * Sanitize array parameters.\r
  * This function checks both key and value.\r
  * - check key if it inclues " (double quote),  remove from array\r
  * - check value if it includes \ (escape sequece), remove remaining string\r
  */\r
 function sanitizeArray(&$array)\r
-{      \r
+{\r
        $excludeListForSanitization = array('query');\r
 //     $excludeListForSanitization = array();\r
 \r
@@ -1884,22 +1986,24 @@ function sanitizeArray(&$array)
                        $val = stripslashes($val);\r
                }\r
                $val = addslashes($val);\r
-               \r
+\r
                // if $key is included in exclude list, skip this param\r
                if (!in_array($key, $excludeListForSanitization)) {\r
-                               \r
+\r
                        // check value\r
-                       @list($val, $tmp) = explode('\\', $val);\r
-                       \r
+                       if (strpos($val, '\\')) {\r
+                               list($val, $tmp) = explode('\\', $val);\r
+                       }\r
+\r
                        // remove control code etc.\r
                        $val = strtr($val, "\0\r\n<>'\"", "       ");\r
-                               \r
+\r
                        // check key\r
                        if (preg_match('/\"/i', $key)) {\r
                                unset($array[$k]);\r
                                continue;\r
                        }\r
-                               \r
+\r
                        // set sanitized info\r
                        $array[$k] = sprintf("%s=%s", $key, $val);\r
                }\r
@@ -1968,7 +2072,7 @@ function stringToAttribute ($string) {
        $string = entity::named_to_numeric($string);\r
        $string = entity::normalize_numeric($string);\r
 \r
-       if (_CHARSET == 'UTF-8') {\r
+       if (strtoupper(_CHARSET) == 'UTF-8') {\r
                $string = entity::numeric_to_utf8($string);\r
        }\r
 \r
@@ -1987,7 +2091,7 @@ function stringToXML ($string) {
        $string = entity::named_to_numeric($string);\r
        $string = entity::normalize_numeric($string);\r
 \r
-       if (_CHARSET == 'UTF-8') {\r
+       if (strtoupper(_CHARSET) == 'UTF-8') {\r
                $string = entity::numeric_to_utf8($string);\r
        }\r
 \r
@@ -2035,16 +2139,17 @@ function _links_list() {
  * @todo document this\r
  */\r
 function encode_desc(&$data)\r
-    {   //_$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 = strtr($data,$from_entities);\r
-        $data = strtr($data,$to_entities);\r
-        $data = str_replace('\n', '<br />', $data); //hack\r
-        return $data;\r
-    }\r
\r
+{\r
+//     _$to_entities = get_html_translation_table(HTML_ENTITIES);\r
+       $to_entities = get_html_translation_table(HTML_SPECIALCHARS); // for Japanese\r
+       $from_entities = array_flip($to_entities);\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
+       return $data;\r
+}\r
+\r
 /**\r
  * Returns the Javascript code for a bookmarklet that works on most modern browsers\r
  *\r
@@ -2090,4 +2195,9 @@ function numberOfEventSubscriber($event) {
        return $obj->count;\r
 }\r
 \r
+function selectSpecialSkinType($id) {\r
+       global $special;\r
+       $special = strtolower($id);\r
+}\r
+\r
 ?>
\ No newline at end of file