OSDN Git Service

added NucleusJP keyword
authorkimitake <kimitake@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Tue, 15 Mar 2005 07:59:27 +0000 (07:59 +0000)
committerkimitake <kimitake@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Tue, 15 Mar 2005 07:59:27 +0000 (07:59 +0000)
merged 3.2 code

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk@42 1ca29b6e-896d-4ea0-84a5-967f57386b96

utf8/nucleus/libs/globalfunctions.php

index 9fd88fa..0434808 100755 (executable)
@@ -2,7 +2,7 @@
 \r
 /**\r
   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
-  * Copyright (C) 2002-2004 The Nucleus Group\r
+  * Copyright (C) 2002-2005 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
@@ -10,6 +10,8 @@
   * of the License, or (at your option) any later version.\r
   * (see nucleus/documentation/index.html#license for more info)\r
   *\r
+  * $Id: globalfunctions.php,v 1.4 2005-03-15 07:59:27 kimitake Exp $\r
+  * $NucleusJP$\r
   */\r
 \r
 // needed if we include globalfunctions from install.php\r
@@ -20,7 +22,7 @@ checkVars(array('nucleus', 'CONF', 'DIR_LIBS', 'MYSQL_HOST', 'MYSQL_USER', 'MYSQ
 \r
 $CONF['debug'] = 0;\r
 \r
-$nucleus['version'] = 'v3.15';\r
+$nucleus['version'] = 'v3.2';\r
 if (getNucleusPatchLevel() > 0)\r
 {\r
        $nucleus['version'] .= '/' . getNucleusPatchLevel();\r
@@ -47,7 +49,7 @@ $CONF['alertOnSecurityRisk'] = 1;
   * returns the currently used version (100 = 1.00, 101 = 1.01, etc...)\r
   */\r
 function getNucleusVersion() {\r
-       return 315;\r
+       return 320;\r
 }\r
 \r
 /**\r
@@ -100,7 +102,7 @@ $errormessage       = '';
 $error                 = '';\r
 \r
 if (!headers_sent())\r
-       header('Generator: Nucleus ' . $nucleus['version']);\r
+       header('Generator: Nucleus CMS ' . $nucleus['version']);\r
 \r
 // include core classes that are needed for login & plugin handling\r
 include($DIR_LIBS . 'MEMBER.php');\r
@@ -135,7 +137,7 @@ if (($CONF['DisableJsTools'] == 0) && strstr(serverVar('HTTP_USER_AGENT'),'Mozil
 \r
 // login if cookies set\r
 \r
-$member = new MEMBER();\r
+$member =& new MEMBER();\r
 \r
 // login/logout when required or renew cookies\r
 if ($action == 'login') {\r
@@ -176,30 +178,36 @@ Backed out for now: See http://forum.nucleuscms.org/viewtopic.php?t=3684 for det
                ACTIONLOG::add(INFO, 'HTTP authentication failed for ' . $login);\r
 \r
                //Since bad credentials, generate an apropriate error page\r
-               header("WWW-Authenticate: Basic realm=\"Nucleus {$nucleus['version']}\"");\r
+               header("WWW-Authenticate: Basic realm=\"Nucleus CMS {$nucleus['version']}\"");\r
                header('HTTP/1.0 401 Unauthorized');\r
                echo 'Invalid username or password';\r
                exit;\r
        }\r
 */\r
 \r
-} elseif (($action == 'logout') && (!headers_sent()) && cookieVar('user')){\r
+} elseif (($action == 'logout') && (!headers_sent()) && cookieVar($CONF['CookiePrefix'] . 'user')){\r
        // remove cookies on logout\r
-       setcookie('user','',(time()-2592000),$CONF['CookiePath'],$CONF['CookieDomain'],$CONF['CookieSecure']);\r
-       setcookie('loginkey','',(time()-2592000),$CONF['CookiePath'],$CONF['CookieDomain'],$CONF['CookieSecure']);\r
-       $manager->notify('Logout',array('username' => cookieVar('user')));\r
-} elseif (cookieVar('user')) {\r
+       setcookie($CONF['CookiePrefix'] .'user','',(time()-2592000),$CONF['CookiePath'],$CONF['CookieDomain'],$CONF['CookieSecure']);\r
+       setcookie($CONF['CookiePrefix'] .'loginkey','',(time()-2592000),$CONF['CookiePath'],$CONF['CookieDomain'],$CONF['CookieSecure']);\r
+       $manager->notify('Logout',array('username' => cookieVar($CONF['CookiePrefix'] .'user')));\r
+} elseif (cookieVar($CONF['CookiePrefix'] .'user')) {\r
        // Cookie Authentication\r
-       $res = $member->cookielogin(cookieVar('user'), cookieVar('loginkey'));\r
+       $res = $member->cookielogin(cookieVar($CONF['CookiePrefix'] .'user'), cookieVar($CONF['CookiePrefix'] .'loginkey'));\r
 \r
        // renew cookies when not on a shared computer\r
-       if ($res && (cookieVar('sharedpc') != 1) && (!headers_sent()))\r
+       if ($res && (cookieVar($CONF['CookiePrefix'] .'sharedpc') != 1) && (!headers_sent()))\r
                $member->setCookies();\r
 }\r
 \r
 // login completed\r
 $manager->notify('PostAuthentication',array('loggedIn' => $member->isLoggedIn()));\r
 \r
+// first, let's see if the site is disabled or not\r
+if ($CONF['DisableSite'] && !$member->isAdmin()) {\r
+       redirect($CONF['DisableSiteURL']);\r
+       exit;\r
+}\r
+\r
 // load other classes\r
 include($DIR_LIBS . 'PARSER.php');\r
 include($DIR_LIBS . 'SKIN.php');\r
@@ -217,9 +225,9 @@ include($DIR_LIBS . 'SEARCH.php');
 // set lastVisit cookie (if allowed)\r
 if (!headers_sent()) {\r
        if ($CONF['LastVisit'])\r
-               setcookie('lastVisit',time(),time()+2592000,$CONF['CookiePath'],$CONF['CookieDomain'],$CONF['CookieSecure']);\r
+               setcookie($CONF['CookiePrefix'] .'lastVisit',time(),time()+2592000,$CONF['CookiePath'],$CONF['CookieDomain'],$CONF['CookieSecure']);\r
        else\r
-               setcookie('lastVisit','',(time()-2592000),$CONF['CookiePath'],$CONF['CookieDomain'],$CONF['CookieSecure']);\r
+               setcookie($CONF['CookiePrefix'] .'lastVisit','',(time()-2592000),$CONF['CookiePath'],$CONF['CookieDomain'],$CONF['CookieSecure']);\r
 }\r
 \r
 // read language file, only after user has been initialized\r
@@ -241,6 +249,14 @@ if (!defined('_MEMBERS_BYPASS'))
 \r
 */\r
 \r
+// make sure the archivetype skinvar keeps working when _ARCHIVETYPE_XXX not defined\r
+if (!defined('_ARCHIVETYPE_MONTH'))\r
+{\r
+       define('_ARCHIVETYPE_DAY','day');\r
+       define('_ARCHIVETYPE_MONTH','month');\r
+}\r
+\r
+\r
 // decode path_info\r
 if ($CONF['URLMode'] == 'pathinfo') {\r
        $data = explode("/",serverVar('PATH_INFO'));\r
@@ -331,7 +347,7 @@ function sendContentType($contenttype, $pagetype = '', $charset = _CHARSET) {
                                'pageType' => $pagetype\r
                        )\r
                );\r
-               \r
+\r
                // strip strange characters\r
                $contenttype = preg_replace('|[^a-z0-9-+./]|i', '', $contenttype);\r
                $charset = preg_replace('|[^a-z0-9-_]|i', '', $charset);\r
@@ -490,12 +506,17 @@ function selector() {
        global $imagepopup, $catid;\r
        global $manager;\r
 \r
-       // first, let's see if the site is disabled or not\r
-       if ($CONF['DisableSite'] && !$member->isAdmin()) {\r
-               redirect($CONF['DisableSiteURL']);\r
-               exit;\r
-       }\r
-\r
+       $actionNames = array('addcomment', 'sendmessage', 'createaccount', 'forgotpassword', 'votepositive', 'votenegative', 'plugin');\r
+       $action = requestVar('action');\r
+       if (in_array($action, $actionNames))\r
+       {\r
+               global $DIR_LIBS, $errormessage;\r
+               include_once($DIR_LIBS . 'ACTION.php');\r
+               $a =& new ACTION();\r
+               $errorInfo = $a->doAction($action);\r
+               if ($errorInfo)\r
+                       $errormessage = $errorInfo['message'];\r
+       }       \r
 \r
        // show error when headers already sent out\r
        if (headers_sent() && $CONF['alertOnHeadersSent']) {\r
@@ -647,7 +668,7 @@ function selector() {
                $skinid = $blog->getDefaultSkin();\r
 \r
        \r
-       $skin = new SKIN($skinid);\r
+       $skin =& new SKIN($skinid);\r
        if (!$skin->isValid)\r
                doError(_ERROR_NOSUCHSKIN);\r
 \r
@@ -663,16 +684,16 @@ function doError($msg, $skin = '') {
 \r
        if ($skin == '') {\r
                if (SKIN::existsID($skinid)) {\r
-                       $skin = new SKIN($skinid);\r
+                       $skin =& new SKIN($skinid);\r
                } elseif ($manager->existsBlogID($blogid)) {\r
                        $blog =& $manager->getBlog($blogid);\r
-                       $skin = new SKIN($blog->getDefaultSkin());\r
+                       $skin =& new SKIN($blog->getDefaultSkin());\r
                } elseif ($CONF['DefaultBlog']) {\r
                        $blog =& $manager->getBlog($CONF['DefaultBlog']);\r
-                       $skin = new SKIN($blog->getDefaultSkin());\r
+                       $skin =& new SKIN($blog->getDefaultSkin());\r
                } else {\r
                        // this statement should actually never be executed\r
-                       $skin = new SKIN($CONF['BaseSkin']);\r
+                       $skin =& new SKIN($CONF['BaseSkin']);\r
                }\r
        }\r
 \r
@@ -702,28 +723,6 @@ function isValidSkinName($name) {          return eregi('^[a-z0-9/]+$', $name); }
 function addBreaks($var) {                             return nl2br($var); }\r
 function removeBreaks($var) {                  return preg_replace("/<br \/>([\r\n])/","$1",$var); }\r
 \r
-/**\r
-  * Generate a 'pronouncable' password\r
-  * (http://www.zend.com/codex.php?id=215&single=1)\r
-  */\r
-function genPassword($length){\r
-\r
-    srand((double)microtime()*1000000);\r
-\r
-    $vowels = array('a', 'e', 'i', 'o', 'u');\r
-    $cons = array('b', 'c', 'd', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'u', 'v', 'w', 'tr',\r
-    'cr', 'br', 'fr', 'th', 'dr', 'ch', 'ph', 'wr', 'st', 'sp', 'sw', 'pr', 'sl', 'cl');\r
-\r
-    $num_vowels = count($vowels);\r
-    $num_cons = count($cons);\r
-\r
-    for($i = 0; $i < $length; $i++){\r
-        $password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)];\r
-    }\r
-\r
-    return substr($password, 0, $length);\r
-}\r
-\r
 // shortens a text string to maxlength ($toadd) is what needs to be added\r
 // at the end (end length is <= $maxlength)\r
 function shorten($text, $maxlength, $toadd) {\r
@@ -786,8 +785,8 @@ function selectLanguage($language) {
 }\r
 \r
 function parseFile($filename) {\r
-       $handler = new ACTIONS('fileparser');\r
-       $parser = new PARSER(SKIN::getAllowedActionsForType('fileparser'), $handler);\r
+       $handler =& new ACTIONS('fileparser');\r
+       $parser =& new PARSER(SKIN::getAllowedActionsForType('fileparser'), $handler);\r
        $handler->parser =& $parser;\r
 \r
        if (!file_exists($filename)) doError('A file is missing');\r
@@ -1073,7 +1072,7 @@ function checkVars($aVars)
                                || isset($HTTP_POST_FILES[$varName])\r
                        ){\r
                                die('Sorry. An error occurred.');\r
-                       }\r
+                       }               \r
                }\r
        }\r
 }\r