\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
* 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
\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
* 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
$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
\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
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
// 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
\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
'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
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
$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
\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
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
}\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
|| isset($HTTP_POST_FILES[$varName])\r
){\r
die('Sorry. An error occurred.');\r
- }\r
+ } \r
}\r
}\r
}\r