diff -x .svn -aruN 3.41.src/action.php 3.51.src/action.php
--- 3.41.src/action.php	2009-03-15 22:31:36.000000000 -0500
+++ 3.51.src/action.php	2009-11-01 14:54:08.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * File containing actions that can be performed by visitors of the site,
  * like adding comments, etc...
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: action.php 1194 2007-09-05 05:49:25Z kimitake $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: action.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 $CONF = array();
diff -x .svn -aruN 3.41.src/atom.php 3.51.src/atom.php
--- 3.41.src/atom.php	2009-03-15 22:31:36.000000000 -0500
+++ 3.51.src/atom.php	2009-11-01 14:54:08.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,8 +13,8 @@
 /**
  * Nucleus Atom Syndication
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: atom.php 1116 2007-02-03 08:24:29Z kimitake $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: atom.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 header('Pragma: no-cache');
diff -x .svn -aruN 3.41.src/config.php 3.51.src/config.php
--- 3.41.src/config.php	2009-04-15 13:25:21.000000000 -0500
+++ 3.51.src/config.php	2010-01-12 17:16:05.000000000 -0600
@@ -6,6 +6,11 @@
 	$MYSQL_PASSWORD = '[% mysql_pass %]';
 	$MYSQL_DATABASE = '[% ncls %]';
 	$MYSQL_PREFIX = '[% table_prefix %]_';
+	// new in 3.50. first element is db handler, the second is the db driver used by the handler
+	// default is $MYSQL_HANDLER = array('mysql','mysql');
+	//$MYSQL_HANDLER = array('mysql','mysql');
+	//$MYSQL_HANDLER = array('pdo','mysql');
+	$MYSQL_HANDLER = array('mysql','');
 
 	// main nucleus directory
 	$DIR_NUCLEUS = '[% installdir %]/nucleus/';
diff -x .svn -aruN 3.41.src/createaccount.php 3.51.src/createaccount.php
--- 3.41.src/createaccount.php	2009-03-15 22:31:38.000000000 -0500
+++ 3.51.src/createaccount.php	2009-11-01 14:54:08.000000000 -0600
@@ -35,7 +35,7 @@
 	
 		Login Name (required): 
 		<br />
-		<input name="name" size="20" maxlength="16" /> <small>(only a-z, 0-9)</small>
+		<input name="name" size="32" maxlength="32" /> <small>(only a-z, 0-9)</small>
 		<br />
 		<br />		
 		Real Name (required): 
@@ -87,7 +87,7 @@
 	
 		Login Name (required): 
 		<br />
-		<input name="name" size="20" maxlength="16" <?php if(isset($_POST['name'])){echo 'value="'.$_POST['name'].'"';}?>/> <small>(only a-z, 0-9)</small>
+		<input name="name" size="32" maxlength="32" <?php if(isset($_POST['name'])){echo 'value="'.$_POST['name'].'"';}?>/> <small>(only a-z, 0-9)</small>
 		<br />
 		<br />		
 		Real Name (required): 
diff -x .svn -aruN 3.41.src/install_lang_english.php 3.51.src/install_lang_english.php
--- 3.41.src/install_lang_english.php	2009-03-15 22:31:38.000000000 -0500
+++ 3.51.src/install_lang_english.php	2009-11-01 14:54:08.000000000 -0600
@@ -139,7 +139,7 @@
 define('_TEXT16',	'<p>If you don\\\'t delete these files, you won\\\'t be able to open the admin area</p>');
 
 define('_HEADER11',	'Visit your web site');
-define('_TEXT16',	'Your web site is now ready to use.');
+define('_TEXT16_H',	'Your web site is now ready to use.');
 define('_TEXT16_L1',	'Login to the admin area to configure your site');
 define('_TEXT16_L2',	'Visit your site now');
 
@@ -147,9 +147,9 @@
 
 define('_BUTTON1',	'Install Nucleus');
 
-define('_1ST_POST_TITLE',	'Welcome to Nucleus CMS v3.4');
+define('_1ST_POST_TITLE',	'Welcome to Nucleus CMS v3.5');
 define('_1ST_POST',	'This is the first post on your Nucleus CMS. Nucleus offers you the building blocks you need to create a web presence. Whether you want to
 create a personal blog, a family page, or an online business site, Nucleus CMS can help you achieve your goals.<br /> <br /> We\\\'ve loaded this first entry with links and information to get you started. Though you can delete this entry, it will eventually scroll off the main page as you add content to your site. Add your comments while you learn to work with Nucleus CMS, or bookmark this page so you can come back to it when you need to.');
-define('_1ST_POST2',	'<b>Home - <a href=\"http://nucleuscms.org/\" title=\"Nucleus CMS home\">nucleuscms.org</a></b><br /> Welcome to the world of Nucleus CMS. In 2001 a set of PHP scripts were let loose on the open Internet. Those scripts, which took user-generated data and used it to dynamically create html pages, contained the ideas and the algorithms that are the core of today\\\'s Nucleus CMS. Though Nucleus CMS 3.4 is far more flexible and powerful than the scripts from which it emerged, it still expresses the values that guided its birth: flexibility, security, and computational elegance.<br /> <br /> Thanks to an international community of sophisticated developers and designers, Nucleus CMS remains simple enough for anyone to learn, and expandable enough to allow you to build almost any website you can imagine. Nucleus CMS lets you integrate text, images, and user comments in a seamless package that will make your web presence as serious, professional, personal, or fun as you want it to be. We hope you enjoy its power.<br /> <br /> <b>Documentation - <a href=\"http://docs.nucleuscms.org/\" title=\"Nucleus CMS Documentation\">docs.nucleuscms.org</a></b><br /> The install process places a <a href=\"nucleus/documentation/\">user</a> and a <a href=\"nucleus/documentation/devdocs/\">developer</a> documentation on your web server. Pop-up <a href=\"/nucleus/documentation/help.html\">help</a> is available throughout the administration area to assist you in maintaining and customizing your site. When in the Nucleus CMS admin area, click on this symbol <img src=\"nucleus/documentation/icon-help.gif\" width=\"15\" height=\"15\" alt=\"help icon\" /> for context-sensitive help. You can also read this documentation online under <a href=\"http://docs.nucleuscms.org/\" title=\"Nucleus CMS Documentation\">docs.nucleuscms.org</a>.<br /> <br /> <b>Frequently Asked Questions - <a nicetitle=\"Nucleus CMS FAQ\" href=\"http://faq.nucleuscms.org/\">faq.nucleuscms.org</a></b><br /> If you need more information about managing, extending or troubleshooting your Nucleus CMS the Nucleus FAQ is the first place to search information. Over 170 frequently asked questions are answered from experienced Nucleus users.<br /> <br /> <b>Support - <a href=\"http://forum.nucleuscms.org/\" title=\"Nucleus CMS Support Forum\">forum.nucleuscms.org</a></b><br /> Should you require assistance, please don\\\'t hesitate to <a href=\"http://forum.nucleuscms.org/faq.php\">join</a> the 6,800+ registered users on our forums. With its built-in search capability of the 73,000+ posted articles, your answers are just a few clicks away. Remember: almost any question you think of has already been asked on the forums, and almost anything you want to do with Nucleus has been tried and explained there. Be sure to check them out.<br /> <br /> <b>Demonstration - <a href=\"http://demo.nucleuscms.org/\" title=\"Nucleus CMS Demonstration\">demo.nucleuscms.org</a></b><br /> Want to play around, test changes or tell a friend or relative about Nucleus CMS? Visit our live <a href=\"http://demo.nucleuscms.org/\">demo site</a>.<br /> <br /> <b>Skins - <a href=\"http://skins.nucleuscms.org/\" title=\"Nucleus CMS Skins\">skins.nucleuscms.org</a></b><br /> The combination of multi-weblogs and skins/templates make for a powerful duo in personalizing your site or designing one for a friend, relative or business client. Import new skins to change the look of your website, or create your own skins and share them with the Nucleus community! Help designing or modifying skins is only a few clicks away in the Nucleus forums.<br /> <br /> <b>Plugins - <a href=\"http://plugins.nucleuscms.org/\" title=\"Nucleus plugins\">plugins.nucleuscms.org</a></b><br /> Looking to add some extra functionality to the base Nucleus CMS package? Our <a href=\"http://wiki.nucleuscms.org/plugin\">plugin repository</a> gives you plenty of ways to extend and expand what Nucleus CMS can do; your imagination and creativity are the only limit on how Nucleus CMS can work for you.<br /> <br /> <b>Development - <a href=\"http://dev.nucleuscms.org/\" title=\"Nucleus Development\">dev.nucleuscms.org</a></b><br /> If you need more information about the Nucleus development you can find Informations in the developer documents at <a href=\"http://dev.nucleuscms.org/\" title=\"Nucleus Development\">dev.nucleuscms.org</a> or in the <a href=\"http://forum.nucleuscms.org/\">Support Forum</a>. Sourceforge.net graciously hosts our <a href=\"http://sourceforge.net/projects/nucleuscms/\">Open Source project page</a> which contains our software downloads and CVS repository.<br /> <br /> <b>Donators</b><br /> We would like to thank these <a href=\"http://nucleuscms.org/donators.php\">nice people</a> for their <a href=\"http://nucleuscms.org/donate.php\">support</a>. <em>Thanks all!</em><br /> <br /> <b>Vote for Nucleus CMS</b><br /> Like Nucleus CMS? Vote for us at <a href=\"http://www.hotscripts.com/Detailed/13368.html?RID=nucleus@demuynck.org\">HotScripts</a> and <a href=\"http://www.opensourcecms.com/index.php?option=content&task=view&id=145\">opensourceCMS</a>.<br /> <br /> <b>License</b><br /> When we speak of free software, we are referring to freedom, not price. Our <a href=\"http://www.gnu.org/licenses/gpl.html\">General Public Licenses</a> are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.');
+define('_1ST_POST2',	'<b>Home - <a href=\"http://nucleuscms.org/\" title=\"Nucleus CMS home\">nucleuscms.org</a></b><br /> Welcome to the world of Nucleus CMS. In 2001 a set of PHP scripts were let loose on the open Internet. Those scripts, which took user-generated data and used it to dynamically create html pages, contained the ideas and the algorithms that are the core of today\\\'s Nucleus CMS. Though Nucleus CMS 3.5 is far more flexible and powerful than the scripts from which it emerged, it still expresses the values that guided its birth: flexibility, security, and computational elegance.<br /> <br /> Thanks to an international community of sophisticated developers and designers, Nucleus CMS remains simple enough for anyone to learn, and expandable enough to allow you to build almost any website you can imagine. Nucleus CMS lets you integrate text, images, and user comments in a seamless package that will make your web presence as serious, professional, personal, or fun as you want it to be. We hope you enjoy its power.<br /> <br /> <b>Documentation - <a href=\"http://docs.nucleuscms.org/\" title=\"Nucleus CMS Documentation\">docs.nucleuscms.org</a></b><br /> The install process places a <a href=\"nucleus/documentation/\">user</a> and a <a href=\"nucleus/documentation/devdocs/\">developer</a> documentation on your web server. Pop-up <a href=\"/nucleus/documentation/help.html\">help</a> is available throughout the administration area to assist you in maintaining and customizing your site. When in the Nucleus CMS admin area, click on this symbol <img src=\"nucleus/documentation/icon-help.gif\" width=\"15\" height=\"15\" alt=\"help icon\" /> for context-sensitive help. You can also read this documentation online under <a href=\"http://docs.nucleuscms.org/\" title=\"Nucleus CMS Documentation\">docs.nucleuscms.org</a>.<br /> <br /> <b>Frequently Asked Questions - <a nicetitle=\"Nucleus CMS FAQ\" href=\"http://faq.nucleuscms.org/\">faq.nucleuscms.org</a></b><br /> If you need more information about managing, extending or troubleshooting your Nucleus CMS the Nucleus FAQ is the first place to search information. Over 170 frequently asked questions are answered from experienced Nucleus users.<br /> <br /> <b>Support - <a href=\"http://forum.nucleuscms.org/\" title=\"Nucleus CMS Support Forum\">forum.nucleuscms.org</a></b><br /> Should you require assistance, please don\\\'t hesitate to <a href=\"http://forum.nucleuscms.org/faq.php\">join</a> the 6,800+ registered users on our forums. With its built-in search capability of the 73,000+ posted articles, your answers are just a few clicks away. Remember: almost any question you think of has already been asked on the forums, and almost anything you want to do with Nucleus has been tried and explained there. Be sure to check them out.<br /> <br /> <b>Demonstration - <a href=\"http://demo.nucleuscms.org/\" title=\"Nucleus CMS Demonstration\">demo.nucleuscms.org</a></b><br /> Want to play around, test changes or tell a friend or relative about Nucleus CMS? Visit our live <a href=\"http://demo.nucleuscms.org/\">demo site</a>.<br /> <br /> <b>Skins - <a href=\"http://skins.nucleuscms.org/\" title=\"Nucleus CMS Skins\">skins.nucleuscms.org</a></b><br /> The combination of multi-weblogs and skins/templates make for a powerful duo in personalizing your site or designing one for a friend, relative or business client. Import new skins to change the look of your website, or create your own skins and share them with the Nucleus community! Help designing or modifying skins is only a few clicks away in the Nucleus forums.<br /> <br /> <b>Plugins - <a href=\"http://plugins.nucleuscms.org/\" title=\"Nucleus plugins\">plugins.nucleuscms.org</a></b><br /> Looking to add some extra functionality to the base Nucleus CMS package? Our <a href=\"http://wiki.nucleuscms.org/plugin\">plugin repository</a> gives you plenty of ways to extend and expand what Nucleus CMS can do; your imagination and creativity are the only limit on how Nucleus CMS can work for you.<br /> <br /> <b>Development - <a href=\"http://dev.nucleuscms.org/\" title=\"Nucleus Development\">dev.nucleuscms.org</a></b><br /> If you need more information about the Nucleus development you can find Informations in the developer documents at <a href=\"http://dev.nucleuscms.org/\" title=\"Nucleus Development\">dev.nucleuscms.org</a> or in the <a href=\"http://forum.nucleuscms.org/\">Support Forum</a>. Sourceforge.net graciously hosts our <a href=\"http://sourceforge.net/projects/nucleuscms/\">Open Source project page</a> which contains our software downloads and CVS repository.<br /> <br /> <b>Donators</b><br /> We would like to thank these <a href=\"http://nucleuscms.org/donators.php\">nice people</a> for their <a href=\"http://nucleuscms.org/donate.php\">support</a>. <em>Thanks all!</em><br /> <br /> <b>Vote for Nucleus CMS</b><br /> Like Nucleus CMS? Vote for us at <a href=\"http://www.hotscripts.com/Detailed/13368.html?RID=nucleus@demuynck.org\">HotScripts</a> and <a href=\"http://www.opensourcecms.com/index.php?option=content&task=view&id=145\">opensourceCMS</a>.<br /> <br /> <b>License</b><br /> When we speak of free software, we are referring to freedom, not price. Our <a href=\"http://www.gnu.org/licenses/gpl.html\">General Public Licenses</a> are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.');
 
 ?>
diff -x .svn -aruN 3.41.src/nucleus/bookmarklet.php 3.51.src/nucleus/bookmarklet.php
--- 3.41.src/nucleus/bookmarklet.php	2009-03-15 22:31:36.000000000 -0500
+++ 3.51.src/nucleus/bookmarklet.php	2009-11-01 14:54:08.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * in order to use this.
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: bookmarklet.php 1281 2008-10-24 06:01:23Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: bookmarklet.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 // bookmarklet is part of admin area (might need XML-RPC)
@@ -105,10 +105,6 @@
 	if ($result['status'] == 'newcategory') {
 		$message = 'Item was added, and a new category was created. <a href="index.php?action=categoryedit&amp;blogid=' . $blogid . '&amp;catid=' . $result['catid'] . '" onclick="if (event &amp;&amp; event.preventDefault) event.preventDefault(); window.open(this.href); return false;" title="Opens in new window">Click here to edit the name and description of the category.</a>';
 		$extrahead = '';
-	} elseif ( (postVar('actiontype') == 'addnow') && $blog->sendPing() ) {
-		$message = 'Item was added successfully. Now pinging weblogs.com. Please hold on... (can take a while)';
-		$pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid) );
-		$extrahead = '<meta http-equiv="refresh" content="1; url=' . htmlspecialchars($pingUrl) . '" />';
 	} else {
 		$message = _ITEM_ADDED;
 		$extrahead = '';
diff -x .svn -aruN 3.41.src/nucleus/documentation/devdocs/plugins.html 3.51.src/nucleus/documentation/devdocs/plugins.html
--- 3.41.src/nucleus/documentation/devdocs/plugins.html	2009-03-15 22:31:36.000000000 -0500
+++ 3.51.src/nucleus/documentation/devdocs/plugins.html	2009-11-01 14:54:02.000000000 -0600
@@ -1,7 +1,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
 <head>
-	<!-- $Id: plugins.html 1304 2009-01-20 20:36:52Z ftruscot $ -->
+	<!-- $Id: plugins.html 1393 2009-07-24 21:06:40Z ftruscot $ -->
 	<title>Nucleus - Plugin API</title>
 	<link rel="stylesheet" type="text/css" href="styles/manual.css" />
 	<style type="text/css">
@@ -153,6 +153,8 @@
 		{
 			case 'SqlTablePrefix':
 				return 1;
+			case 'SqlApi':
+				return 1;
 			default:
 				return 0;
 		}
@@ -630,6 +632,8 @@
 		<td><dl>
 			<dt class="obj ref">member</dt>
 			<dd><code>MEMBER</code> object</dd>
+			<dt class="ro">username</dt>
+			<dd>login name that was used in the login attempt</dd>
 		</dl></td>
 	</tr>
 	<tr>
@@ -1568,16 +1572,20 @@
 			<dd>Integer indicating whether local authentication should be tried after an unsuccessful authentication by your plugin. 1 means yes, 0 means no. 1 is the default.</dd>
 		</dl></td>
 	</tr>
-<!--
+
 	<tr>
-		<td></td>
-		<td></td>
+		<td>PrePasswordSet</td>
+		<td>(v3.50)  Called when user tries to set password in admin area or during activation. Allows for plugins to enforce password complexity rules.</td>
 		<td><dl>
-			<dt></dt>
-			<dd></dd>
+			<dt class="ro">password</dt>
+			<dd>String containing the user-entered password.</dd>
+			<dt class="ref">errormessage</dt>
+			<dd>String containing the error message the user should see upon failure. Should be left blank if no validation error occurs.</dd>
+			<dt class="ref">valid</dt>
+			<dd>Boolean indicating whether the proposed password is valid. Default is true. Plugin code should check this value to verify it is not already false before processing a password</dd>
 		</dl></td>
 	</tr>
-	<tr>
+<!--	<tr>
 		<td></td>
 		<td></td>
 		<td><dl>
@@ -1888,9 +1896,14 @@
 
 <p>Up to v2.0, accessing the nucleus tables was just a matter of performing an SQL query on one of the <code>nucleus_</code> tables. Since it is possible to use a custom table name in Nucleus versions >2.0, some precautions are needed in plugin development:</p>
 
+<p>As of v3.5, Nucleus is moving toward support for database handlers different from MySQL, such as PDO. Though, this support is beta in version 3.5, plugin developers need to start making their plugins compatible with the new sql_* api used to implement the generic database calls. 
+Essentially, you need onnly replace any mysql_* functions with sql_*, e.g. <code>mysql_fetch_assoc($result)</code> becomes <code>sql_fetch_assoc($result)</code>. 
+you must do this for every interaction with the database. Be sure to indicate that you support the SqlApi feature as indicated below, and that you set the minNucleusVersion to 350, like this: <br /><code>function getMinNucleusVersion( return '350';)</code></p>
+
 <ol>
 	<li>Instead of using a fixed tablename like <code>nucleus_item</code>, use the global function <code>sql_table('item')</code> to generate the prefixed tablename</li>
 	<li>Make sure your plugin returns <code>1</code> (<code>true</code>) when <code>supportsFeature('SqlTablePrefix')</code> is called on it. If it doesn't, you won't be able to load the plugin on Nucleus versions > 2.0 when a custom prefix has been set (as a precaution)</li>
+	<li>v3.5+. Make sure your plugin returns <code>1</code> (<code>true</code>) when <code>supportsFeature('SqlApi')</code> is called on it. If it doesn't, you won't be able to load the plugin on Nucleus versions > 3.5 when a user is using a non-mysql database backend (as a precaution)</li>
 </ol>
 
 <p class="note">Note that the <code>sql_table</code> global function in not available in Nucleus versions up to v2.0. If you use this method and want your plugin to work on Nucleus versions &lt;= 2.0, add the following snippet of code on top of your plugin class:</p>
diff -x .svn -aruN 3.41.src/nucleus/documentation/devdocs/sqltables.html 3.51.src/nucleus/documentation/devdocs/sqltables.html
--- 3.41.src/nucleus/documentation/devdocs/sqltables.html	2009-03-15 22:31:36.000000000 -0500
+++ 3.51.src/nucleus/documentation/devdocs/sqltables.html	2009-11-01 14:54:02.000000000 -0600
@@ -1,7 +1,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
 <head>
-	<!-- $Id: sqltables.html 1296 2009-01-13 20:27:04Z ftruscot $ -->
+	<!-- $Id: sqltables.html 1377 2009-07-10 07:39:01Z ehui $ -->
 	<title>Nucleus - SQL Table Structure</title>
 	<link rel="stylesheet" type="text/css" href="styles/manual.css" />
 	<style type="text/css">
@@ -229,12 +229,6 @@
 	<td>Allow comments by non-registered members? (1=true/0=false)</td>
 
 </tr><tr>
-	<td class="notnull toremove">bsendping</td>
-	<td>tinyint(2)</td>
-	<td>'0'</td>
-	<td>Send a ping to various weblog listing services on update? (1=true/0=false) This option is only visible when NP_Ping plugin is installed</td>
-
-</tr><tr>
 	<td class="notnull toremove">bconvertbreaks</td>
 	<td>tinyint(2)</td>
 	<td>'1'</td>
diff -x .svn -aruN 3.41.src/nucleus/documentation/help.html 3.51.src/nucleus/documentation/help.html
--- 3.41.src/nucleus/documentation/help.html	2009-03-15 22:31:36.000000000 -0500
+++ 3.51.src/nucleus/documentation/help.html	2009-11-01 14:54:08.000000000 -0600
@@ -1,7 +1,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-	<!-- $Id: help.html 1317 2009-02-06 19:11:24Z ftruscot $ -->
+	<!-- $Id: help.html 1405 2009-08-14 15:56:06Z ftruscot $ -->
 
 	<title>Nucleus Admin Help</title>
 	<style type="text/css">
@@ -603,6 +603,12 @@
 </tr><tr>
 	<td>catdesc</td>
 	<td>Category description</td>
+</tr><tr>
+	<td>catiscurrent</td>
+	<td>yes if category is currently selected, no if it is not. Useful to style current category.</td>
+</tr><tr>
+	<td>currentcat</td>
+	<td>Synonym of catiscurrent</td>
 </tr></table>
 
 <p><a href="#categorylistexample">View an example</a></p>
@@ -1936,6 +1942,81 @@
 
 </div>
 
+<div class="page">
+<a name="skinvar-archiveyearlist"></a>
+<h1>Skinvar: archiveyearlist</h1>
+
+<p>
+The same as the <a href="#skinvar-archivelist">archivelist</a> skinvar, but shows an entry for each <em>year</em> instead of for each <em>month</em>
+</p>
+
+<h2>Arguments</h2>
+<p>
+	Required
+	<ul>
+		<li><strong>template</strong>: name of the template to use</li>
+	</ul>
+	Optional
+	<ul>
+		<li><strong><em>category</em></strong> name of the category to show</li>
+		<li><strong><em>limit</em></strong>: limits the amount of links shown (e.g. if you only want to show links to the past 3 years)</li>
+	</ul>
+</p>
+
+<h2>Skintypes</h2>
+
+<p>
+index, archive, archivelist, search, item
+</p>
+
+
+<h2>Examples</h2>
+
+<pre>
+&lt;%archiveyearlist(mytemplate)%&gt;
+&lt;%archiveyearlist(mytemplate,mycategory)%&gt;
+</pre>
+
+</div>
+
+
+<div class="page">
+<a name="skinvar-otherarchiveyearlist"></a>
+<h1>Skinvar: otherarchiveyearlist</h1>
+
+<p>
+The same as the <a href="#skinvar-otherarchivelist">otherarchivelist</a> skinvar, but shows an entry for each <em>year</em> instead of for each <em>month</em>
+
+</p>
+
+<h2>Arguments</h2>
+<p>
+	Required
+	<ul>
+		<li><strong>blogname</strong>: name of the blog</li>
+		<li><strong>template</strong>: name of the template to use</li>
+	</ul>
+	Optional
+	<ul>
+		<li><strong><em>category</em></strong>: name of the category to show</li>
+	</ul>
+</p>
+
+<h2>Skintypes</h2>
+
+<p>
+all
+</p>
+
+<h2>Examples</h2>
+
+<pre>
+&lt;%otherarchiveyearlist(yourblog,mytemplate)%&gt;
+&lt;%otherarchiveyearlist(yourblog,mytemplate,mycategory)%&gt;
+</pre>
+
+</div>
+
 
 
 <div class="page">
@@ -3587,6 +3668,38 @@
 </div>
 
 
+<div class="page">
+<a name="skinvar-sticky"></a>
+<h1>Skinvar: sticky</h1>
+
+<p>
+Inserts the indicated item into the skin.
+</p>
+
+<h2>Arguments</h2>
+<p>
+	Required:
+	<ul>
+		<li><strong>itemid</strong>: id of the item to show</li>
+		<li><strong>template</strong>: name of the template to use</li>
+	</ul>
+</p>
+
+<h2>Skintypes</h2>
+
+<p>
+all
+</p>
+
+<h2>Examples</h2>
+
+<pre>
+&lt;%sticky(11,default/index)%&gt;
+</pre>
+
+</div>
+
+
 
 <div class="page">
 <a name="templatevars-overview"></a>
@@ -3800,6 +3913,9 @@
 	<td>userwebsite</td>
 	<td>the URL of the users website, empty if the URL was not provided by the user</td>
 </tr><tr>
+	<td>userwebsitelink</td>
+	<td>a smart link to URL for non members, or the member detail page for members. Note: this link already includes the &lt;a href="..."&gt; and &lt;/a&gt; tags ! (when no valid URL, only the name of the member will be shown)</td>
+</tr><tr>
 	<td>memberid</td>
 	<td>ID of the member (0 for non-members)</td>
 </tr><tr>
@@ -4363,6 +4479,24 @@
 <p>
 Note that the responsibility for plugins is entirely with the plugin author. He should make sure that everything works fine.
 </p>
+<a name="getplugins"></a>
+<p>
+There are two main repositories where you can find plugins for Nucleus CMS:
+</p>
+<ul>
+	<li><a href="http://wiki.nucleuscms.org/plugin" title="Plugin Wiki">English</a></li>
+	<li><a href="http://japan.nucleuscms.org/wiki/plugins" title="Japanese Plugin Wiki">Japanese</a></li>
+</ul>
+<p>
+Neither or these repositories is entirely complete. You will find some plugins in one, but not in the other, and vice versa. 
+Do not be scared off of one or the other on account of language, as there are a few free translation services on the Internet that 
+will help you get by.
+</p>
+Another resource that will help you while working with plugins is the search function at the 
+<a href="http://forum.nucleuscms.org/" title="Support Forum">support forum</a>. You will even find some 
+smaller plugins on the forum that never made it to the wiki.
+<p>
+</p>
 </div>
 
 <div class="page">
diff -x .svn -aruN 3.41.src/nucleus/documentation/history.html 3.51.src/nucleus/documentation/history.html
--- 3.41.src/nucleus/documentation/history.html	2009-03-15 22:31:36.000000000 -0500
+++ 3.51.src/nucleus/documentation/history.html	2009-11-01 14:54:08.000000000 -0600
@@ -2,7 +2,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us">
 <head>
-	<!-- $Id: history.html 1356 2009-03-15 21:21:25Z kaigreve $ -->
+	<!-- $Id: history.html 1421 2009-11-01 13:45:44Z kaigreve $ -->
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
     <meta http-equiv="Content-Style-Type" content="text/css" />
     <meta http-equiv="Content-Script-Type" content="text/javascript" />
@@ -28,6 +28,55 @@
 
 <ul>
 	<li>
+		<strong>Nucleus v3.51 (November 1, 2009)</strong>
+		<ul>
+			<li>FIX: fix warning caused by unreachable code in PDO (admun)</li>
+			<li>FIX: fix typo in NP_Ping (admun)</li>
+			<li>FIX: fix typo in XMLRPC api (admun)</li>
+			<li>FIX: Bug in upgrade procedure where no check to verify new column does not currently exist before running the add query. See <a href="http://forum.nucleuscms.org/viewtopic.php?t=19170" title="Upgrade Bug Report">this thread</a> (ftruscot)</li>
+			<li>FIX: Bug where activation not completed. See <a href="http://forum.nucleuscms.org/viewtopic.php?t=19176" title="Activation Bug Report">this thread</a> (ftruscot)</li>
+		</ul>
+	</li>
+	<li>
+		<strong>Nucleus v3.50 (September 19, 2009)</strong>
+		<ul>
+			<li>FIX: enhancements to language and input escaping in NP_SecurityEnforcer as suggeted in Japanese forum. (ftruscot)</li>
+			<li>FIX: bug in install.php when shell_exec not available and bug in MANAger.php when certain language constant not defined. Suggestions by shizuki, added by ftruscot.</li>
+			<li>ADD: Comment template variable userwebsitelink which acts like userlink, but only shows web address and never email. (ftruscot)</li>
+			<li>ADD: 2 Category List template variables, catiscurrent and its synonym, currentcat. (ftruscot)</li>
+			<li>ADD: code to warn if using a non-mysql database handler and a plugin does not supportsFeature 'SqlApi'. (ftruscot)</li>
+			<li>CHANGE: set php setting, display_errors, to 0 when not in debug mode to keep users with poorly configured servers from displaying errors on the page. (ftruscot)</li>
+			<li>FIX: PHP5.3 warning caused by MANAGER::notify(). See <a href="http://forum.nucleuscms.org/viewtopic.php?t=18997" title="php 5.3 Error">this thread</a>. (ftruscot)</li>
+			<li>FIX: bookmarklet unaware of character set being used. Fix suggested by wgroleau. (ftruscot)</li>
+			<li>FIX: super-admin disallowed from uploading files if not on any teamlists. (ftruscot)</li>
+			<li>ADD: $CONF['ActivationDays'] variable to control days before activation expire. Manually set in config.php if needed (no admin interface). (ftruscot)</li>
+			<li>CHANGE:Notify ITEM link after karma votes(ACTION.php). (shizuki)</li>
+			<li>CHANGE:Remove bsendping col from nucleus_blog table(install.sql/upgrade3.5.php). (shizuki)</li>
+			<li>ADD:sql_field_name function for backup class(mysql.php/pdo.php). (shizuki)</li>
+			<li>FIX:Fix short open tag(NP_Ping.php). (shizuki)</li>
+			<li>CHANGED: NP_Ping and related infrastructure changes. (admun)</li>
+			<li>ADDED: upgrade code for 3.5 in upgrades folder. Includes notices about end of PHP4 support and info on 2 new plugins included in plugins folder. (ftruscot)</li>
+			<li>CHANGED: modified upgrade functions to use 3 digit version indicators everywhere. i.e. 340 instead of 34. (ftruscot)</li>
+			<li>CHANGED: increased length of displayname, mname, to 32 characters. (ftruscot)</li>
+			<li>CHANGED: modified install.php and sql_* handlers to allow installation using PDO. Activation is manual and not intended for public consumption in 3.50. Only tested for pdo-mysql handler. (ftruscot)</li>
+			<li>ADDED/CHANGED: extended sql_* api to cover all mysql_* functions used in core. Functions loaded from nucleus/libs/sql/ folder. See <a href="http://wakka.xiffy.nl/planning:3.50#mysql_api_warning" title="sql API">here</a>. (ftruscot)</li>
+			<li>ADDED: NP_Text plugin to core installation. Makes distribution of internationalised plugins easier. See <a href="http://forum.nucleuscms.org/viewtopic.php?t=15005" title="forgotpassword">this thread</a>. (ftruscot)</li>
+			<li>ADDED: links in plugins help of help.html to link to two main plugin repositories. See <a href="http://forum.nucleuscms.org/viewtopic.php?t=18214" title="forgotpassword">this thread</a>. (ftruscot)</li>
+			<li>ADDED: selectSpecialSkinType() function to globalfunctions.php. (ftruscot)</li>
+			<li>ADDED: Check in ADMIN.php pagehead() function to display alert if newer version is available. new function, getLatestVersion() in globalfunctions.php, and new files on nucleuscms.org, version_check.php, to serve latest version. (ftruscot)</li>
+			<li>ADDED: skinvar for all skin types to display a sticky item from any blog anywhere. (ftruscot)</li>
+			<li>REMOVED: check on canlogin during forgotpassword process. See <a href="http://forum.nucleuscms.org/viewtopic.php?t=18753" title="forgotpassword">this thread</a>. Suggestion by phillip_r. (ftruscot)</li>
+			<li>ADDED: div with id of adminwrapper around contents of admin page for improved control of admin page look. See <a href="http://forum.nucleuscms.org/viewtopic.php?t=18551" title="adminwrapper">this thread</a>. Suggestion by monkeybrain. (ftruscot)</li>
+			<li>ADDED: NP_SecurityEnforcer plugin to core installation. It can be set to enforce password length and complexity rules, as well as maximum failed login attempts. Put in plugin so can be superceded later by better techniques. (ftruscot)</li>
+			<li>CHANGED: LoginSuccess event in globalfunctions.php to inlcude <i>username</i> in the data array to specify the login name entered by the user. (ftruscot)</li>
+			<li>FIXED: backup.php, _backup_dump_structure() function, to use SHOW CREATE TABLE <i>name</i>, to generate table creation SQL. Adds ENGINE, AUTO_INCREMENT, and DEFAULT CHARSET. (ftruscot)</li>
+			<li>ADDED: PrePasswordSet event in ADMIN.php to allow plugin to enforce any password length or complexity rules for improved security. (ftruscot)</li>
+			<li>FIXED: When inclusion tried to do the special skin type by skin of error types, $skinid wasn't set.(yu/shizuki)</li>
+			<li>CHANGED: move send update ping option override to NP_Ping</li>
+			<li>ADDED: Year-based archives and archivelists, adds archiveyearlist and otherarchiveyearlist skin vars (ftruscot)</li>
+		</ul>
+	</li>
+	<li>
 		<strong>Nucleus v3.41 (March 15, 2009)</strong>
 		<ul>
 			<li>FIXED: Reduce PHP Notices caused by undefined variables and wrong offsets (shizuki, kaigreve)</li>
@@ -41,6 +90,8 @@
 			<li>FIXED: Add missing language item to english-utf-8.php (admun)</li>
 			<li>FIXED: CONF['Self'] merging error in globalfunctions.php (admun)</li>
 		</ul>
+	</li>
+	<li>
 		<strong>Nucleus v3.40 (February 14, 2009)</strong>
 		<ul>
 			<li>ADDED: check cmail column to separate to URL and cemail when Nucleus upgrade to 3.3 or later. (kimitake/katsumi)(added by shizuki from Ver.jp)</li>
diff -x .svn -aruN 3.41.src/nucleus/documentation/tips.html 3.51.src/nucleus/documentation/tips.html
--- 3.41.src/nucleus/documentation/tips.html	2009-03-15 22:31:36.000000000 -0500
+++ 3.51.src/nucleus/documentation/tips.html	2009-11-01 14:54:08.000000000 -0600
@@ -3,7 +3,7 @@
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-	<!-- $Id: tips.html 1207 2007-10-04 23:14:09Z kaigreve $ -->
+	<!-- $Id: tips.html 1368 2009-06-17 22:18:57Z ftruscot $ -->
 	<title>Nucleus - Tips and suggestions</title>
 	<link rel="stylesheet" type="text/css" href="styles/manual.css" />
 </head>
@@ -257,6 +257,13 @@
 </tr><tr>
 	<td><code>selectLanguage('french');</code></td>
 	<td>Makes sure a certain language gets used (note: might produce PHP warnings)</td>
+</tr><tr>
+	<td><code>selectSpecialSkinType('construction');</code></td>
+	<td>Makes sure a certain special skin type gets used (note: if used by itself, it will only show that special skin type). Try this to show the special page only to non-members: <pre><code>if (!$member->isLoggedIn()) {
+	selectSpecialSkinType('login');
+}</code></pre> or this to show the special skin type only for the main page: <pre><code>if (empty($blogid) && empty($catid) && empty($itemid)&& empty($archive) && empty($archivelist)) {
+	selectSpecialSkinType('welcome');
+}</code></pre></td>
 </tr></table>
 
 <p>
@@ -345,7 +352,7 @@
 
 <p><strong>Note:</strong> You may want to keep your static content in a file called <code>About.html</code> in the <code>skins/default/</code> directory (if using the default skin) and instead of typing the content of the page in the skin part, just put <code>&lt;%include(About.html)%&gt;</code>. There's almost no restriction on what these pages can contain.</p>
 
-<p>(Tip from  <a href="http://www.iai.com/">ftruscot</a>)</p>
+<p>(Tip from  <a href="http://revcetera.com/ftruscot">ftruscot</a>)</p>
 
 </body>
 </html>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/index.php 3.51.src/nucleus/index.php
--- 3.41.src/nucleus/index.php	2009-03-15 22:31:36.000000000 -0500
+++ 3.51.src/nucleus/index.php	2009-11-01 14:54:08.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -11,8 +11,8 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: index.php 1279 2008-10-23 08:18:26Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: index.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 	// we are using admin stuff:
 	$CONF = array();
diff -x .svn -aruN 3.41.src/nucleus/javascript/admin.js 3.51.src/nucleus/javascript/admin.js
--- 3.41.src/nucleus/javascript/admin.js	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/javascript/admin.js	2009-11-01 14:54:00.000000000 -0600
@@ -1,6 +1,6 @@
 /**
   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
-  * Copyright (C) 2002-2007 The Nucleus Group
+  * Copyright (C) 2002-2009 The Nucleus Group
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
@@ -10,7 +10,7 @@
   *  
   * Some JavaScript code for the admin area
   *
-  * $Id: admin.js 1143 2007-05-10 08:39:46Z kimitake $
+  * $Id: admin.js 1388 2009-07-18 06:31:28Z shizuki $
   */
 
 function help(url) {
diff -x .svn -aruN 3.41.src/nucleus/javascript/bookmarklet.js 3.51.src/nucleus/javascript/bookmarklet.js
--- 3.41.src/nucleus/javascript/bookmarklet.js	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/javascript/bookmarklet.js	2009-11-01 14:54:00.000000000 -0600
@@ -1,6 +1,6 @@
 /**
   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
-  * Copyright (C) 2002-2007 The Nucleus Group
+  * Copyright (C) 2002-2009 The Nucleus Group
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
@@ -10,7 +10,7 @@
   *  
   * Some JavaScript code for the bookmarklets
   *
-  * $Id: bookmarklet.js 1116 2007-02-03 08:24:29Z kimitake $
+  * $Id: bookmarklet.js 1388 2009-07-18 06:31:28Z shizuki $
   */
 
 /**
diff -x .svn -aruN 3.41.src/nucleus/javascript/compatibility.js 3.51.src/nucleus/javascript/compatibility.js
--- 3.41.src/nucleus/javascript/compatibility.js	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/javascript/compatibility.js	2009-11-01 14:54:00.000000000 -0600
@@ -1,6 +1,6 @@
 /**
   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
-  * Copyright (C) 2002-2007 The Nucleus Group
+  * Copyright (C) 2002-2009 The Nucleus Group
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
   *
   * That's basically it :)
   *
-  * $Id: compatibility.js 1116 2007-02-03 08:24:29Z kimitake $
+  * $Id: compatibility.js 1388 2009-07-18 06:31:28Z shizuki $
   */
 
 // to get the script working when page is sent as application/xhtml+xml
diff -x .svn -aruN 3.41.src/nucleus/javascript/edit.js 3.51.src/nucleus/javascript/edit.js
--- 3.41.src/nucleus/javascript/edit.js	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/javascript/edit.js	2009-11-01 14:54:00.000000000 -0600
@@ -1,6 +1,6 @@
 /**
   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
-  * Copyright (C) 2002-2007 The Nucleus Group
+  * Copyright (C) 2002-2009 The Nucleus Group
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
@@ -11,7 +11,7 @@
   * This file contains functions to allow adding items from inside the weblog.
   * Also contains code to avoid submitting form data twice.
   *
-  * $Id: edit.js 1278 2008-10-23 04:54:08Z shizuki $
+  * $Id: edit.js 1388 2009-07-18 06:31:28Z shizuki $
   */
 
 var nucleusConvertBreaks = true;
diff -x .svn -aruN 3.41.src/nucleus/javascript/numbercheck.js 3.51.src/nucleus/javascript/numbercheck.js
--- 3.41.src/nucleus/javascript/numbercheck.js	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/javascript/numbercheck.js	2009-11-01 14:54:00.000000000 -0600
@@ -1,6 +1,6 @@
 /**
   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
-  * Copyright (C) 2002-2007 The Nucleus Group
+  * Copyright (C) 2002-2009 The Nucleus Group
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
@@ -11,7 +11,7 @@
   * script the check (on the clientside) if a entered value
   * is a valid number and remove the invalid chars
   *
-  * $Id: numbercheck.js 1116 2007-02-03 08:24:29Z kimitake $
+  * $Id: numbercheck.js 1388 2009-07-18 06:31:28Z shizuki $
   */
 
 function checkNumeric(f)
diff -x .svn -aruN 3.41.src/nucleus/javascript/opennew.js 3.51.src/nucleus/javascript/opennew.js
--- 3.41.src/nucleus/javascript/opennew.js	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/javascript/opennew.js	2009-11-01 14:54:00.000000000 -0600
@@ -1,6 +1,6 @@
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -8,7 +8,7 @@
  * of the License, or (at your option) any later version.
  * (see nucleus/documentation/index.html#license for more info)
  *
- * $Id: opennew.js 1116 2007-02-03 08:24:29Z kimitake $
+ * $Id: opennew.js 1388 2009-07-18 06:31:28Z shizuki $
  *
  * JavaScript to open non-local links in a new window.
  *
diff -x .svn -aruN 3.41.src/nucleus/javascript/templateEdit.js 3.51.src/nucleus/javascript/templateEdit.js
--- 3.41.src/nucleus/javascript/templateEdit.js	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/javascript/templateEdit.js	2009-11-01 14:54:00.000000000 -0600
@@ -1,6 +1,6 @@
 /**
   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
-  * Copyright (C) 2002-2007 The Nucleus Group
+  * Copyright (C) 2002-2009 The Nucleus Group
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
@@ -12,7 +12,7 @@
   *
   * @require compatibility.js
   *
-  * $Id: templateEdit.js 1116 2007-02-03 08:24:29Z kimitake $
+  * $Id: templateEdit.js 1388 2009-07-18 06:31:28Z shizuki $
   */
 
 var amountOfFields = 1;
diff -x .svn -aruN 3.41.src/nucleus/javascript/xmlhttprequest.js 3.51.src/nucleus/javascript/xmlhttprequest.js
--- 3.41.src/nucleus/javascript/xmlhttprequest.js	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/javascript/xmlhttprequest.js	2009-11-01 14:54:00.000000000 -0600
@@ -1,6 +1,6 @@
 /**
   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
-  * Copyright (C) 2002-2007 The Nucleus Group
+  * Copyright (C) 2002-2009 The Nucleus Group
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
@@ -39,7 +39,7 @@
   *     <input type="button" name="autosavenow" value="AutoSave now" onclick="autoSaveDraft();" />
   *
   *
-  * $Id: xmlhttprequest.js 1116 2007-02-03 08:24:29Z kimitake $
+  * $Id: xmlhttprequest.js 1388 2009-07-18 06:31:28Z shizuki $
   */
 
 /**
diff -x .svn -aruN 3.41.src/nucleus/language/english.php 3.51.src/nucleus/language/english.php
--- 3.41.src/nucleus/language/english.php	2009-03-15 22:31:28.000000000 -0500
+++ 3.51.src/nucleus/language/english.php	2009-11-01 14:53:44.000000000 -0600
@@ -17,10 +17,20 @@
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: english.php 1349 2009-03-13 13:42:10Z kaigreve $
+ * @version $Id: english.php 1393 2009-07-24 21:06:40Z ftruscot $
  */
 
 /********************************************
+ *        Start New for 3.50                *
+ ********************************************/
+define('_PLUGS_TITLE_GETPLUGINS',		'get more plugins...');
+define('_ARCHIVETYPE_YEAR', 'year');
+define('_ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE',		'Newer Version Available');
+define('_ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT',		'Upgrade available: v');
+define('_MANAGER_PLUGINSQLAPI_NOTSUPPORT', "Plugin %s was not loaded (does not support SqlApi and you are trying to use a non-mysql db)");
+
+
+/********************************************
  *        Start New for 3.40                *
  ********************************************/
 
@@ -88,7 +98,7 @@
 define('_BOOKMARKLET_NEW_CATEGORY',					'Item was added, and a new category was created. ');
 define('_BOOKMARKLET_NEW_CATEGORY_EDIT',			'Click here to edit the name and description of the category.');
 define('_BOOKMARKLET_NEW_WINDOW',					'Opens in new window');
-define('_BOOKMARKLET_SEND_PING',					'Item was added successfully. Now pinging weblogs.com. Please hold on... (can take a while)');
+define('_BOOKMARKLET_SEND_PING',					'Item was added successfully. Now pinging weblogs.com. Please hold on... (can take a while)'); // NOTE: This string is no longer in used
 
 // END merge UTF-8 and EUC-JP
 
@@ -104,12 +114,11 @@
 define('_WARNINGTXT_NOTDELMEDIAFILES',				'Please note that media files will <b>NOT</b> be deleted. (At least not in this Nucleus version)');	// <add by shizuki />
 
 // send Weblogupdate.ping
-define('_UPDATEDPING_MESSAGE',						'<h2>Site Updated, Now pinging various weblog listing services...</h2><p>This can take a while...</p><p>If you aren\'t automatically passed through, ');
-define('_UPDATEDPING_GOPINGPAGE',					'try again');
-define('_UPDATEDPING_PINGING',						'Pinging services, please wait...');
-define('_UPDATEDPING_VIEWITEM',						'View list of recent items for ');
-define('_UPDATEDPING_VISITOWNSITE',					'Visit your own site');
-define('_UPDATEDPING_GOSENDPING',					'Send Update ping');
+define('_UPDATEDPING_MESSAGE',						'<h2>Site Updated, Now pinging various weblog listing services...</h2><p>This can take a while...</p><p>If you aren\'t automatically passed through, '); // NOTE: This string is no longer in used
+define('_UPDATEDPING_GOPINGPAGE',					'try again'); // NOTE: This string is no longer in used
+define('_UPDATEDPING_PINGING',						'Pinging services, please wait...'); // NOTE: This string is no longer in used
+define('_UPDATEDPING_VIEWITEM',						'View list of recent items for '); // NOTE: This string is no longer in used
+define('_UPDATEDPING_VISITOWNSITE',					'Visit your own site'); // NOTE: This string is no longer in used
 
 // General category
 define('_EBLOGDEFAULTCATEGORY_NAME',				'General');
@@ -1001,7 +1010,7 @@
 define('_EBLOG_NOTIFY_COMMENT',		'New comments');
 define('_EBLOG_NOTIFY_KARMA',		'New karma votes');
 define('_EBLOG_NOTIFY_ITEM',		'New weblog items');
-define('_EBLOG_PING',				'Ping weblog listing service on update?');
+define('_EBLOG_PING',				'Ping weblog listing service on update?'); // NOTE: This string is no longer in used
 define('_EBLOG_MAXCOMMENTS',		'Max Amount of comments');
 define('_EBLOG_UPDATE',				'Update file');
 define('_EBLOG_OFFSET',				'Time Offset');
diff -x .svn -aruN 3.41.src/nucleus/libs/ACTIONLOG.php 3.51.src/nucleus/libs/ACTIONLOG.php
--- 3.41.src/nucleus/libs/ACTIONLOG.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/libs/ACTIONLOG.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,8 +13,8 @@
  * Actionlog class for Nucleus
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: ACTIONLOG.php 1125 2007-02-22 16:10:29Z kaigreve $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: ACTIONLOG.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 define('ERROR',1);		// only errors
 define('WARNING',2);	// errors and warnings
diff -x .svn -aruN 3.41.src/nucleus/libs/ACTION.php 3.51.src/nucleus/libs/ACTION.php
--- 3.41.src/nucleus/libs/ACTION.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/libs/ACTION.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * Actions that can be called via action.php
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: ACTION.php 1287 2008-12-12 18:50:10Z ftruscot $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: ACTION.php 1378 2009-07-10 14:03:01Z shizuki $
  */
 class ACTION
 {
@@ -210,7 +210,7 @@
 		$initialPwd = md5(uniqid(rand(), true));
 
 		// create member (non admin/can not login/no notes/random string as password)
-		$name = shorten(postVar('name'),16,'');
+		$name = shorten(postVar('name'),32,'');
 		$r = MEMBER::create($name, postVar('realname'), $initialPwd, postVar('email'), postVar('url'), 0, 0, '');
 
 			if ($r != 1) {
@@ -228,6 +228,8 @@
 			redirect(postVar('desturl'));
 		} else {
 			echo _MSG_ACTIVATION_SENT;
+			echo '<br /><br />Return to <a href="'.$CONF['IndexURL'].'" title="'.$CONF['SiteName'].'">'.$CONF['SiteName'].'</a>';
+			echo "\n</body>\n</html>";
 		}
 		exit;
 	}
@@ -242,9 +244,11 @@
 		if (!MEMBER::exists($membername))
 			doError(_ERROR_NOSUCHMEMBER);
 		$mem = MEMBER::createFromName($membername);
-
-		if (!$mem->canLogin())
-			doError(_ERROR_NOLOGON_NOACTIVATE);
+		
+		/* below keeps regular users from resetting passwords using forgot password feature
+		     Removing for now until clear why it is required.*/
+		/*if (!$mem->canLogin())
+			doError(_ERROR_NOLOGON_NOACTIVATE);*/
 
 		// check if e-mail address is correct
 		if (!($mem->getEmail() == postVar('email')))
@@ -257,6 +261,7 @@
 			redirect(postVar('url'));
 		} else {
 			echo _MSG_ACTIVATION_SENT;
+			echo '<br /><br />Return to <a href="'.$CONF['IndexURL'].'" title="'.$CONF['SiteName'].'">'.$CONF['SiteName'].'</a>';
 		}
 		exit;
 	}
@@ -294,14 +299,25 @@
 				break;
 		}
 
-		$blogid = getBlogIDFromItemID($itemid);
+//		$blogid = getBlogIDFromItemID($itemid);
 		$blog =& $manager->getBlog($blogid);
 
 		// send email to notification address, if any
 		if ($blog->getNotifyAddress() && $blog->notifyOnVote()) {
 
 			$mailto_msg = _NOTIFY_KV_MSG . ' ' . $itemid . "\n";
-			$mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $itemid . "\n\n";
+//			if ($CONF['URLMode'] == 'pathinfo') {
+//				$itemLink = createItemLink(intval($itemid));
+//			} else {
+//				$itemLink = $CONF['IndexURL'] . createItemLink(intval($itemid));
+//			}
+//			$mailto_msg .= $CONF['IndexURL'] . 'index.php?itemid=' . $itemid . "\n\n";
+            $itemLink = createItemLink(intval($itemid));
+            $temp = parse_url($itemLink);
+            if (!$temp['scheme']) {
+                $itemLink = $CONF['IndexURL'] . $itemLink;
+            }
+			$mailto_msg .= $itemLink . "\n\n";
 			if ($member->isLoggedIn()) {
 				$mailto_msg .= _NOTIFY_MEMBER . ' ' . $member->getDisplayName() . ' (ID=' . $member->getID() . ")\n";
 			}
@@ -320,11 +336,12 @@
 
 
 		$refererUrl = serverVar('HTTP_REFERER');
-		if ($refererUrl)
+		if ($refererUrl) {
 			$url = $refererUrl;
-		else
-			$url = $CONF['IndexURL'] . 'index.php?itemid=' . $itemid;
-
+		} else {
+//			$url = $CONF['IndexURL'] . 'index.php?itemid=' . $itemid;
+			$url = $itemLink;
+		}
 		redirect($url);
 		exit;
 	}
@@ -380,7 +397,7 @@
 			echo $manager->getNewTicket();
 		}
 		else {
-			echo 'err:' . _ERROR_BADTICKET;
+            echo _ERROR . ':' . _ERROR_BADTICKET;
 		}
 		return false;
 	}
@@ -401,7 +418,7 @@
 			}
 		}
 		else {
-			echo 'err:' . _ERROR_BADTICKET;
+            echo _ERROR . ':' . _ERROR_BADTICKET;
 		}
 		return false;
 	}
diff -x .svn -aruN 3.41.src/nucleus/libs/ACTIONS.php 3.51.src/nucleus/libs/ACTIONS.php
--- 3.41.src/nucleus/libs/ACTIONS.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/ACTIONS.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -17,8 +17,8 @@
  * SKIN::getAllowedActionsForType($type) method
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: ACTIONS.php 1279 2008-10-23 08:18:26Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: ACTIONS.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 class ACTIONS extends BaseActions {
@@ -458,13 +458,15 @@
 			array_shift($args);
 			// implode
 			$format=implode(',',$args);
-		} elseif ($d == 0) {
+		} elseif ($d == 0 && $m !=0) {
 			$format = '%B %Y';
+		} elseif ($m == 0) {
+			$format = '%Y';			
 		} else {
 			$format = '%d %B %Y';
 		}
 
-		echo strftime($format,mktime(0,0,0,$m,$d?$d:1,$y));
+		echo strftime($format,mktime(0,0,0,$m?$m:1,$d?$d:1,$y));
 	}
 
 	/**
@@ -498,7 +500,16 @@
 		$blog->showArchiveList($template, 'month', $limit);
 		$this->_postBlogContent('archivelist',$blog);
 	}
-
+		
+	function parse_archiveyearlist($template, $category = 'all', $limit = 0) {
+		global $blog;
+		if ($category == 'all') $category = '';
+		$this->_preBlogContent('archivelist',$blog);
+		$this->_setBlogCategory($blog, $category);
+		$blog->showArchiveList($template, 'year', $limit);
+		$this->_postBlogContent('archivelist',$blog);
+	}
+	
 	/**
 	 * Parse skinvar archivetype
 	 */
@@ -1058,6 +1069,19 @@
 		$b->showArchiveList($template, 'month', $limit);
 		$this->_postBlogContent('otherarchivelist',$b);
 	}
+		
+	/**
+	 * Parse skinvar otherarchiveyearlist
+	 */
+	function parse_otherarchiveyearlist($blogname, $template, $category = 'all', $limit = 0) {
+		global $manager;
+		if ($category == 'all') $category = '';
+		$b =& $manager->getBlog(getBlogIDFromName($blogname));
+		$this->_setBlogCategory($b, $category);
+		$this->_preBlogContent('otherarchivelist',$b);
+		$b->showArchiveList($template, 'year', $limit);
+		$this->_postBlogContent('otherarchivelist',$b);
+	}	
 	
 	/**
 	 * Parse skinvar otherblog
@@ -1323,6 +1347,22 @@
 		global $nucleus;
 		echo 'Nucleus CMS ' . $nucleus['version'];
 	}
+	
+	/**
+	 * Parse skinvar sticky
+	 */
+	function parse_sticky($itemnumber = 0, $template = '') {
+		global $manager;
+		
+		$itemnumber = intval($itemnumber);
+		$itemarray = array($itemnumber);
+
+		$b =& $manager->getBlog(getBlogIDFromItemID($itemnumber));
+		$this->_preBlogContent('sticky',$b);
+		$this->amountfound = $b->readLogFromList($itemarray, $template);
+		$this->_postBlogContent('sticky',$b);
+	}
+
 
 }
 ?>
diff -x .svn -aruN 3.41.src/nucleus/libs/ADMIN.php 3.51.src/nucleus/libs/ADMIN.php
--- 3.41.src/nucleus/libs/ADMIN.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/libs/ADMIN.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,8 +13,9 @@
  * The code for the Nucleus admin area
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: ADMIN.php 1352 2009-03-14 02:14:10Z ehui $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: ADMIN.php 1416 2009-09-24 15:58:08Z ftruscot $
+
  */
 
 if ( !function_exists('requestVar') ) exit;
@@ -25,3472 +26,3343 @@
  */
 class ADMIN {
 
-	/**
-	 * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
-	 */
-	var $action;
-
-	/**
-	 * Class constructor
-	 */
-	function ADMIN() {
-
-	}
-
-	/**
-	 * Executes an action
-	 *
-	 * @param string $action action to be performed
-	 */
-	function action($action) {
-		global $CONF, $manager;
-
-		// list of action aliases
-		$alias = array(
-			'login' => 'overview',
-			'' => 'overview'
-		);
-
-		if (isset($alias[$action]))
-			$action = $alias[$action];
-
-		$methodName = 'action_' . $action;
-
-		$this->action = strtolower($action);
-
-		// check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
-		// is an action that requires user interaction before something is actually done)
-		// all safe actions are in this array:
-		$aActionsNotToCheck = array(
-			'showlogin',
-			'login',
-			'overview',
-			'itemlist',
-			'blogcommentlist',
-			'bookmarklet',
-			'blogsettings',
-			'banlist',
-			'deleteblog',
-			'editmembersettings',
-			'browseownitems',
-			'browseowncomments',
-			'createitem',
-			'itemedit',
-			'itemmove',
-			'categoryedit',
-			'categorydelete',
-			'manage',
-			'actionlog',
-			'settingsedit',
-			'backupoverview',
-			'pluginlist',
-			'createnewlog',
-			'usermanagement',
-			'skinoverview',
-			'templateoverview',
-			'skinieoverview',
-			'itemcommentlist',
-			'commentedit',
-			'commentdelete',
-			'banlistnewfromitem',
-			'banlistdelete',
-			'itemdelete',
-			'manageteam',
-			'teamdelete',
-			'banlistnew',
-			'memberedit',
-			'memberdelete',
-			'pluginhelp',
-			'pluginoptions',
-			'plugindelete',
-			'skinedittype',
-			'skinremovetype',
-			'skindelete',
-			'skinedit',
-			'templateedit',
-			'templatedelete',
-			'activate',
-			'systemoverview'
-		);
+    /**
+     * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
+     */
+    var $action;
+
+    /**
+     * Class constructor
+     */
+    function ADMIN() {
+
+    }
+
+    /**
+     * Executes an action
+     *
+     * @param string $action action to be performed
+     */
+    function action($action) {
+        global $CONF, $manager;
+
+        // list of action aliases
+        $alias = array(
+            'login' => 'overview',
+            '' => 'overview'
+        );
+
+        if (isset($alias[$action]))
+            $action = $alias[$action];
+
+        $methodName = 'action_' . $action;
+
+        $this->action = strtolower($action);
+
+        // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
+        // is an action that requires user interaction before something is actually done)
+        // all safe actions are in this array:
+        $aActionsNotToCheck = array(
+            'showlogin',
+            'login',
+            'overview',
+            'itemlist',
+            'blogcommentlist',
+            'bookmarklet',
+            'blogsettings',
+            'banlist',
+            'deleteblog',
+            'editmembersettings',
+            'browseownitems',
+            'browseowncomments',
+            'createitem',
+            'itemedit',
+            'itemmove',
+            'categoryedit',
+            'categorydelete',
+            'manage',
+            'actionlog',
+            'settingsedit',
+            'backupoverview',
+            'pluginlist',
+            'createnewlog',
+            'usermanagement',
+            'skinoverview',
+            'templateoverview',
+            'skinieoverview',
+            'itemcommentlist',
+            'commentedit',
+            'commentdelete',
+            'banlistnewfromitem',
+            'banlistdelete',
+            'itemdelete',
+            'manageteam',
+            'teamdelete',
+            'banlistnew',
+            'memberedit',
+            'memberdelete',
+            'pluginhelp',
+            'pluginoptions',
+            'plugindelete',
+            'skinedittype',
+            'skinremovetype',
+            'skindelete',
+            'skinedit',
+            'templateedit',
+            'templatedelete',
+            'activate',
+            'systemoverview'
+        );
 /*
-		// the rest of the actions needs to be checked
-		$aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'sendping', 'rawping', 'activatesetpwd');
+        // the rest of the actions needs to be checked
+        $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd');
 */
-		if (!in_array($this->action, $aActionsNotToCheck))
-		{
-			if (!$manager->checkTicket())
-				$this->error(_ERROR_BADTICKET);
-		}
-
-		if (method_exists($this, $methodName))
-			call_user_func(array(&$this, $methodName));
-		else
-			$this->error(_BADACTION . htmlspecialchars(" ($action)"));
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_showlogin() {
-		global $error;
-		$this->action_login($error);
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_login($msg = '', $passvars = 1) {
-		global $member;
-
-		// skip to overview when allowed
-		if ($member->isLoggedIn() && $member->canLogin()) {
-			$this->action_overview();
-			exit;
-		}
-
-		$this->pagehead();
-
-		echo '<h2>', _LOGIN ,'</h2>';
-		if ($msg) echo _MESSAGE , ': ', htmlspecialchars($msg);
-		?>
-
-		<form action="index.php" method="post"><p>
-		<?php echo _LOGIN_NAME; ?> <br /><input name="login"  tabindex="10" />
-		<br />
-		<?php echo _LOGIN_PASSWORD; ?> <br /><input name="password"  tabindex="20" type="password" />
-		<br />
-		<input name="action" value="login" type="hidden" />
-		<br />
-		<input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
-		<br />
-		<small>
-			<input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
-			<br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
-		</small>
-		<?php			// pass through vars
-
-			$oldaction = postVar('oldaction');
-			if (  ($oldaction != 'logout')  && ($oldaction != 'login')  && $passvars ) {
-				passRequestVars();
-			}
-
-
-		?>
-		</p></form>
-		<?php		$this->pagefoot();
-	}
-
-
-	/**
-	 * provides a screen with the overview of the actions available
-	 * @todo document parameter
-	 */
-	function action_overview($msg = '') {
-		global $member;
-
-		$this->pagehead();
-
-		if ($msg)
-			echo _MESSAGE , ': ', $msg;
-
-		/* ---- add items ---- */
-		echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
-
-		$showAll = requestVar('showall');
-
-		if (($member->isAdmin()) && ($showAll == 'yes')) {
-			// Super-Admins have access to all blogs! (no add item support though)
-			$query =  'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
-				   . ' FROM ' . sql_table('blog')
-				   . ' ORDER BY bname';
-		} else {
-			$query =  'SELECT bnumber, bname, tadmin, burl, bshortname'
-				   . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
-				   . ' WHERE tblog=bnumber and tmember=' . $member->getID()
-				   . ' ORDER BY bname';
-		}
-		$template['content'] = 'bloglist';
-		$template['superadmin'] = $member->isAdmin();
-		$amount = showlist($query,'table',$template);
-
-		if (($showAll != 'yes') && ($member->isAdmin())) {
-			$total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
-			if ($total > $amount)
-				echo '<p><a href="index.php?action=overview&amp;showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
-		}
-
-		if ($amount == 0)
-			echo _OVERVIEW_NOBLOGS;
-
-		if ($amount != 0) {
-			echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
-			$query =  'SELECT ititle, inumber, bshortname'
-				   . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
-				   . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
-			$template['content'] = 'draftlist';
-			$amountdrafts = showlist($query, 'table', $template);
-			if ($amountdrafts == 0)
-				echo _OVERVIEW_NODRAFTS;
-		}
-
-		/* ---- user settings ---- */
-		echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
-		echo '<ul>';
-		echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
-		echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
-		echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
-		echo '</ul>';
-
-		/* ---- general settings ---- */
-		if ($member->isAdmin()) {
-			echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
-			echo '<ul>';
-			echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
-			echo '</ul>';
-		}
-
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * Returns a link to a weblog
-	 * @param object BLOG
-	 */
-	function bloglink(&$blog) {
-		return '<a href="'.htmlspecialchars($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. htmlspecialchars( $blog->getName() ) .'</a>';
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_manage($msg = '') {
-		global $member;
-
-		$member->isAdmin() or $this->disallow();
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-
-		if ($msg)
-			echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
-
-
-		echo '<h2>' . _MANAGE_GENERAL. '</h2>';
-
-		echo '<ul>';
-		echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
-		echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
-		echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
-		echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
-		echo '</ul>';
-
-		echo '<h2>' . _MANAGE_SKINS . '</h2>';
-		echo '<ul>';
-		echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
-		echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
-		echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
-		echo '</ul>';
-
-		echo '<h2>' . _MANAGE_EXTRA . '</h2>';
-		echo '<ul>';
-		echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
-		echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
-		echo '</ul>';
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_itemlist($blogid = '') {
-		global $member, $manager, $CONF;
-
-		if ($blogid == '')
-			$blogid = intRequestVar('blogid');
-
-		$member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
-
-		$this->pagehead();
-		$blog =& $manager->getBlog($blogid);
-
-		echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-		echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
-
-		// start index
-		if (postVar('start'))
-			$start = intPostVar('start');
-		else
-			$start = 0;
-
-		if ($start == 0)
-			echo '<p><a href="index.php?action=createitem&amp;blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
-
-		// amount of items to show
-		if (postVar('amount'))
-			$amount = intPostVar('amount');
-		else {
-			$amount = intval($CONF['DefaultListSize']);
-			if ($amount < 1)
-				$amount = 10;
-		}
-
-		$search = postVar('search');	// search through items
-
-		$query =  'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
-			   . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
-			   . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
-
-		if ($search)
-			$query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))';
-
-		// non-blog-admins can only edit/delete their own items
-		if (!$member->blogAdminRights($blogid))
-			$query .= ' and iauthor=' . $member->getID();
-
-
-		$query .= ' ORDER BY itime DESC'
-				. " LIMIT $start,$amount";
-
-		$template['content'] = 'itemlist';
-		$template['now'] = $blog->getCorrectTime(time());
-
-		$manager->loadClass("ENCAPSULATE");
-		$navList =& new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
-		$navList->showBatchList('item',$query,'table',$template);
-
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_batchitem() {
-		global $member, $manager;
-
-		// check if logged in
-		$member->isLoggedIn() or $this->disallow();
-
-		// more precise check will be done for each performed operation
-
-		// get array of itemids from request
-		$selected = requestIntArray('batch');
-		$action = requestVar('batchaction');
-
-		// Show error when no items were selected
-		if (!is_array($selected) || sizeof($selected) == 0)
-			$this->error(_BATCH_NOSELECTION);
-
-		// On move: when no destination blog/category chosen, show choice now
-		$destCatid = intRequestVar('destcatid');
-		if (($action == 'move') && (!$manager->existsCategory($destCatid)))
-			$this->batchMoveSelectDestination('item',$selected);
-
-		// On delete: check if confirmation has been given
-		if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
-			$this->batchAskDeleteConfirmation('item',$selected);
-
-		$this->pagehead();
-
-		echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
-		echo '<h2>',_BATCH_ITEMS,'</h2>';
-		echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
-		echo '<ul>';
-
-
-		// walk over all itemids and perform action
-		foreach ($selected as $itemid) {
-			$itemid = intval($itemid);
-			echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
-
-			// perform action, display errors if needed
-			switch($action) {
-				case 'delete':
-					$error = $this->deleteOneItem($itemid);
-					break;
-				case 'move':
-					$error = $this->moveOneItem($itemid, $destCatid);
-					break;
-				default:
-					$error = _BATCH_UNKNOWN . htmlspecialchars($action);
-			}
-
-			echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
-			echo '</li>';
-		}
-
-		echo '</ul>';
-		echo '<b>',_BATCH_DONE,'</b>';
-
-		$this->pagefoot();
-
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_batchcomment() {
-		global $member;
-
-		// check if logged in
-		$member->isLoggedIn() or $this->disallow();
-
-		// more precise check will be done for each performed operation
-
-		// get array of itemids from request
-		$selected = requestIntArray('batch');
-		$action = requestVar('batchaction');
-
-		// Show error when no items were selected
-		if (!is_array($selected) || sizeof($selected) == 0)
-			$this->error(_BATCH_NOSELECTION);
-
-		// On delete: check if confirmation has been given
-		if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
-			$this->batchAskDeleteConfirmation('comment',$selected);
-
-		$this->pagehead();
-
-		echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
-		echo '<h2>',_BATCH_COMMENTS,'</h2>';
-		echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
-		echo '<ul>';
-
-		// walk over all itemids and perform action
-		foreach ($selected as $commentid) {
-			$commentid = intval($commentid);
-			echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
-
-			// perform action, display errors if needed
-			switch($action) {
-				case 'delete':
-					$error = $this->deleteOneComment($commentid);
-					break;
-				default:
-					$error = _BATCH_UNKNOWN . htmlspecialchars($action);
-			}
-
-			echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
-			echo '</li>';
-		}
-
-		echo '</ul>';
-		echo '<b>',_BATCH_DONE,'</b>';
-
-		$this->pagefoot();
-
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_batchmember() {
-		global $member;
-
-		// check if logged in and admin
-		($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
-
-		// get array of itemids from request
-		$selected = requestIntArray('batch');
-		$action = requestVar('batchaction');
-
-		// Show error when no members selected
-		if (!is_array($selected) || sizeof($selected) == 0)
-			$this->error(_BATCH_NOSELECTION);
-
-		// On delete: check if confirmation has been given
-		if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
-			$this->batchAskDeleteConfirmation('member',$selected);
-
-		$this->pagehead();
-
-		echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
-		echo '<h2>',_BATCH_MEMBERS,'</h2>';
-		echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
-		echo '<ul>';
-
-		// walk over all itemids and perform action
-		foreach ($selected as $memberid) {
-			$memberid = intval($memberid);
-			echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
-
-			// perform action, display errors if needed
-			switch($action) {
-				case 'delete':
-					$error = $this->deleteOneMember($memberid);
-					break;
-				case 'setadmin':
-					// always succeeds
-					sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
-					$error = '';
-					break;
-				case 'unsetadmin':
-					// there should always remain at least one super-admin
-					$r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
-					if (mysql_num_rows($r) < 2)
-						$error = _ERROR_ATLEASTONEADMIN;
-					else
-						sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
-					break;
-				default:
-					$error = _BATCH_UNKNOWN . htmlspecialchars($action);
-			}
-
-			echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
-			echo '</li>';
-		}
-
-		echo '</ul>';
-		echo '<b>',_BATCH_DONE,'</b>';
-
-		$this->pagefoot();
-
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_batchteam() {
-		global $member;
-
-		$blogid = intRequestVar('blogid');
-
-		// check if logged in and admin
-		($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
-
-		// get array of itemids from request
-		$selected = requestIntArray('batch');
-		$action = requestVar('batchaction');
-
-		// Show error when no members selected
-		if (!is_array($selected) || sizeof($selected) == 0)
-			$this->error(_BATCH_NOSELECTION);
-
-		// On delete: check if confirmation has been given
-		if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
-			$this->batchAskDeleteConfirmation('team',$selected);
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manageteam&amp;blogid=',$blogid,'">(',_BACK,')</a></p>';
-
-		echo '<h2>',_BATCH_TEAM,'</h2>';
-		echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
-		echo '<ul>';
-
-		// walk over all itemids and perform action
-		foreach ($selected as $memberid) {
-			$memberid = intval($memberid);
-			echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
-
-			// perform action, display errors if needed
-			switch($action) {
-				case 'delete':
-					$error = $this->deleteOneTeamMember($blogid, $memberid);
-					break;
-				case 'setadmin':
-					// always succeeds
-					sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
-					$error = '';
-					break;
-				case 'unsetadmin':
-					// there should always remain at least one admin
-					$r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
-					if (mysql_num_rows($r) < 2)
-						$error = _ERROR_ATLEASTONEBLOGADMIN;
-					else
-						sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
-					break;
-				default:
-					$error = _BATCH_UNKNOWN . htmlspecialchars($action);
-			}
-
-			echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
-			echo '</li>';
-		}
-
-		echo '</ul>';
-		echo '<b>',_BATCH_DONE,'</b>';
-
-		$this->pagefoot();
-
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_batchcategory() {
-		global $member, $manager;
-
-		// check if logged in
-		$member->isLoggedIn() or $this->disallow();
-
-		// more precise check will be done for each performed operation
-
-		// get array of itemids from request
-		$selected = requestIntArray('batch');
-		$action = requestVar('batchaction');
-
-		// Show error when no items were selected
-		if (!is_array($selected) || sizeof($selected) == 0)
-			$this->error(_BATCH_NOSELECTION);
-
-		// On move: when no destination blog chosen, show choice now
-		$destBlogId = intRequestVar('destblogid');
-		if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
-			$this->batchMoveCategorySelectDestination('category',$selected);
-
-		// On delete: check if confirmation has been given
-		if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
-			$this->batchAskDeleteConfirmation('category',$selected);
-
-		$this->pagehead();
-
-		echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
-		echo '<h2>',BATCH_CATEGORIES,'</h2>';
-		echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
-		echo '<ul>';
-
-		// walk over all itemids and perform action
-		foreach ($selected as $catid) {
-			$catid = intval($catid);
-			echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
-
-			// perform action, display errors if needed
-			switch($action) {
-				case 'delete':
-					$error = $this->deleteOneCategory($catid);
-					break;
-				case 'move':
-					$error = $this->moveOneCategory($catid, $destBlogId);
-					break;
-				default:
-					$error = _BATCH_UNKNOWN . htmlspecialchars($action);
-			}
-
-			echo '<b>',($error ? 'Error: '.$error : _BATCH_SUCCESS),'</b>';
-			echo '</li>';
-		}
-
-		echo '</ul>';
-		echo '<b>',_BATCH_DONE,'</b>';
-
-		$this->pagefoot();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function batchMoveSelectDestination($type, $ids) {
-		global $manager;
-		$this->pagehead();
-		?>
-		<h2><?php echo _MOVE_TITLE?></h2>
-		<form method="post" action="index.php"><div>
-
-			<input type="hidden" name="action" value="batch<?php echo $type?>" />
-			<input type="hidden" name="batchaction" value="move" />
-			<?php
-				$manager->addTicketHidden();
-
-				// insert selected item numbers
-				$idx = 0;
-				foreach ($ids as $id)
-					echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
-
-				// show blog/category selection list
-				$this->selectBlogCategory('destcatid');
-
-			?>
-
-
-			<input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
-
-		</div></form>
-		<?php		$this->pagefoot();
-		exit;
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function batchMoveCategorySelectDestination($type, $ids) {
-		global $manager;
-		$this->pagehead();
-		?>
-		<h2><?php echo _MOVECAT_TITLE?></h2>
-		<form method="post" action="index.php"><div>
-
-			<input type="hidden" name="action" value="batch<?php echo $type?>" />
-			<input type="hidden" name="batchaction" value="move" />
-			<?php
-				$manager->addTicketHidden();
-
-				// insert selected item numbers
-				$idx = 0;
-				foreach ($ids as $id)
-					echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
-
-				// show blog/category selection list
-				$this->selectBlog('destblogid');
-
-			?>
-
-
-			<input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
-
-		</div></form>
-		<?php		$this->pagefoot();
-		exit;
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function batchAskDeleteConfirmation($type, $ids) {
-		global $manager;
+        if (!in_array($this->action, $aActionsNotToCheck))
+        {
+            if (!$manager->checkTicket())
+                $this->error(_ERROR_BADTICKET);
+        }
+
+        if (method_exists($this, $methodName))
+            call_user_func(array(&$this, $methodName));
+        else
+            $this->error(_BADACTION . htmlspecialchars(" ($action)"));
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_showlogin() {
+        global $error;
+        $this->action_login($error);
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_login($msg = '', $passvars = 1) {
+        global $member;
+
+        // skip to overview when allowed
+        if ($member->isLoggedIn() && $member->canLogin()) {
+            $this->action_overview();
+            exit;
+        }
+
+        $this->pagehead();
+
+        echo '<h2>', _LOGIN ,'</h2>';
+        if ($msg) echo _MESSAGE , ': ', htmlspecialchars($msg);
+        ?>
+
+        <form action="index.php" method="post"><p>
+        <?php echo _LOGIN_NAME; ?> <br /><input name="login"  tabindex="10" />
+        <br />
+        <?php echo _LOGIN_PASSWORD; ?> <br /><input name="password"  tabindex="20" type="password" />
+        <br />
+        <input name="action" value="login" type="hidden" />
+        <br />
+        <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
+        <br />
+        <small>
+            <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
+            <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
+        </small>
+        <?php           // pass through vars
+
+            $oldaction = postVar('oldaction');
+            if (  ($oldaction != 'logout')  && ($oldaction != 'login')  && $passvars ) {
+                passRequestVars();
+            }
+
+
+        ?>
+        </p></form>
+        <?php       $this->pagefoot();
+    }
+
+
+    /**
+     * provides a screen with the overview of the actions available
+     * @todo document parameter
+     */
+    function action_overview($msg = '') {
+        global $member;
+
+        $this->pagehead();
+
+        if ($msg)
+            echo _MESSAGE , ': ', $msg;
+
+        /* ---- add items ---- */
+        echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
+
+        $showAll = requestVar('showall');
+
+        if (($member->isAdmin()) && ($showAll == 'yes')) {
+            // Super-Admins have access to all blogs! (no add item support though)
+            $query =  'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
+                   . ' FROM ' . sql_table('blog')
+                   . ' ORDER BY bname';
+        } else {
+            $query =  'SELECT bnumber, bname, tadmin, burl, bshortname'
+                   . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
+                   . ' WHERE tblog=bnumber and tmember=' . $member->getID()
+                   . ' ORDER BY bname';
+        }
+        $template['content'] = 'bloglist';
+        $template['superadmin'] = $member->isAdmin();
+        $amount = showlist($query,'table',$template);
+
+        if (($showAll != 'yes') && ($member->isAdmin())) {
+            $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
+            if ($total > $amount)
+                echo '<p><a href="index.php?action=overview&amp;showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
+        }
+
+        if ($amount == 0)
+            echo _OVERVIEW_NOBLOGS;
+
+        if ($amount != 0) {
+            echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
+            $query =  'SELECT ititle, inumber, bshortname'
+                   . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
+                   . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
+            $template['content'] = 'draftlist';
+            $amountdrafts = showlist($query, 'table', $template);
+            if ($amountdrafts == 0)
+                echo _OVERVIEW_NODRAFTS;
+        }
+
+        /* ---- user settings ---- */
+        echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
+        echo '<ul>';
+        echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
+        echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
+        echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
+        echo '</ul>';
+
+        /* ---- general settings ---- */
+        if ($member->isAdmin()) {
+            echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
+            echo '<ul>';
+            echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
+            echo '</ul>';
+        }
+
+
+        $this->pagefoot();
+    }
+
+    /**
+     * Returns a link to a weblog
+     * @param object BLOG
+     */
+    function bloglink(&$blog) {
+        return '<a href="'.htmlspecialchars($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. htmlspecialchars( $blog->getName() ) .'</a>';
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_manage($msg = '') {
+        global $member;
+
+        $member->isAdmin() or $this->disallow();
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
+
+        if ($msg)
+            echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
+
+
+        echo '<h2>' . _MANAGE_GENERAL. '</h2>';
+
+        echo '<ul>';
+        echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
+        echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
+        echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
+        echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
+        echo '</ul>';
+
+        echo '<h2>' . _MANAGE_SKINS . '</h2>';
+        echo '<ul>';
+        echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
+        echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
+        echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
+        echo '</ul>';
+
+        echo '<h2>' . _MANAGE_EXTRA . '</h2>';
+        echo '<ul>';
+        echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
+        echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
+        echo '</ul>';
+
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_itemlist($blogid = '') {
+        global $member, $manager, $CONF;
+
+        if ($blogid == '')
+            $blogid = intRequestVar('blogid');
+
+        $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
+
+        $this->pagehead();
+        $blog =& $manager->getBlog($blogid);
+
+        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
+        echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
+
+        // start index
+        if (postVar('start'))
+            $start = intPostVar('start');
+        else
+            $start = 0;
+
+        if ($start == 0)
+            echo '<p><a href="index.php?action=createitem&amp;blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
+
+        // amount of items to show
+        if (postVar('amount'))
+            $amount = intPostVar('amount');
+        else {
+            $amount = intval($CONF['DefaultListSize']);
+            if ($amount < 1)
+                $amount = 10;
+        }
+
+        $search = postVar('search');    // search through items
+
+        $query =  'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
+               . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
+               . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
+
+        if ($search)
+            $query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))';
+
+        // non-blog-admins can only edit/delete their own items
+        if (!$member->blogAdminRights($blogid))
+            $query .= ' and iauthor=' . $member->getID();
+
+
+        $query .= ' ORDER BY itime DESC'
+                . " LIMIT $start,$amount";
+
+        $template['content'] = 'itemlist';
+        $template['now'] = $blog->getCorrectTime(time());
+
+        $manager->loadClass("ENCAPSULATE");
+        $navList =& new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
+        $navList->showBatchList('item',$query,'table',$template);
+
+
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_batchitem() {
+        global $member, $manager;
+
+        // check if logged in
+        $member->isLoggedIn() or $this->disallow();
+
+        // more precise check will be done for each performed operation
+
+        // get array of itemids from request
+        $selected = requestIntArray('batch');
+        $action = requestVar('batchaction');
+
+        // Show error when no items were selected
+        if (!is_array($selected) || sizeof($selected) == 0)
+            $this->error(_BATCH_NOSELECTION);
+
+        // On move: when no destination blog/category chosen, show choice now
+        $destCatid = intRequestVar('destcatid');
+        if (($action == 'move') && (!$manager->existsCategory($destCatid)))
+            $this->batchMoveSelectDestination('item',$selected);
+
+        // On delete: check if confirmation has been given
+        if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
+            $this->batchAskDeleteConfirmation('item',$selected);
+
+        $this->pagehead();
+
+        echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
+        echo '<h2>',_BATCH_ITEMS,'</h2>';
+        echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
+        echo '<ul>';
+
+
+        // walk over all itemids and perform action
+        foreach ($selected as $itemid) {
+            $itemid = intval($itemid);
+            echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
+
+            // perform action, display errors if needed
+            switch($action) {
+                case 'delete':
+                    $error = $this->deleteOneItem($itemid);
+                    break;
+                case 'move':
+                    $error = $this->moveOneItem($itemid, $destCatid);
+                    break;
+                default:
+                    $error = _BATCH_UNKNOWN . htmlspecialchars($action);
+            }
+
+            echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
+            echo '</li>';
+        }
+
+        echo '</ul>';
+        echo '<b>',_BATCH_DONE,'</b>';
+
+        $this->pagefoot();
+
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_batchcomment() {
+        global $member;
+
+        // check if logged in
+        $member->isLoggedIn() or $this->disallow();
+
+        // more precise check will be done for each performed operation
+
+        // get array of itemids from request
+        $selected = requestIntArray('batch');
+        $action = requestVar('batchaction');
+
+        // Show error when no items were selected
+        if (!is_array($selected) || sizeof($selected) == 0)
+            $this->error(_BATCH_NOSELECTION);
+
+        // On delete: check if confirmation has been given
+        if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
+            $this->batchAskDeleteConfirmation('comment',$selected);
+
+        $this->pagehead();
+
+        echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
+        echo '<h2>',_BATCH_COMMENTS,'</h2>';
+        echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
+        echo '<ul>';
+
+        // walk over all itemids and perform action
+        foreach ($selected as $commentid) {
+            $commentid = intval($commentid);
+            echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
+
+            // perform action, display errors if needed
+            switch($action) {
+                case 'delete':
+                    $error = $this->deleteOneComment($commentid);
+                    break;
+                default:
+                    $error = _BATCH_UNKNOWN . htmlspecialchars($action);
+            }
+
+            echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
+            echo '</li>';
+        }
+
+        echo '</ul>';
+        echo '<b>',_BATCH_DONE,'</b>';
+
+        $this->pagefoot();
+
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_batchmember() {
+        global $member;
+
+        // check if logged in and admin
+        ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
+
+        // get array of itemids from request
+        $selected = requestIntArray('batch');
+        $action = requestVar('batchaction');
+
+        // Show error when no members selected
+        if (!is_array($selected) || sizeof($selected) == 0)
+            $this->error(_BATCH_NOSELECTION);
+
+        // On delete: check if confirmation has been given
+        if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
+            $this->batchAskDeleteConfirmation('member',$selected);
+
+        $this->pagehead();
+
+        echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
+        echo '<h2>',_BATCH_MEMBERS,'</h2>';
+        echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
+        echo '<ul>';
+
+        // walk over all itemids and perform action
+        foreach ($selected as $memberid) {
+            $memberid = intval($memberid);
+            echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
+
+            // perform action, display errors if needed
+            switch($action) {
+                case 'delete':
+                    $error = $this->deleteOneMember($memberid);
+                    break;
+                case 'setadmin':
+                    // always succeeds
+                    sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
+                    $error = '';
+                    break;
+                case 'unsetadmin':
+                    // there should always remain at least one super-admin
+                    $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
+                    if (sql_num_rows($r) < 2)
+                        $error = _ERROR_ATLEASTONEADMIN;
+                    else
+                        sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
+                    break;
+                default:
+                    $error = _BATCH_UNKNOWN . htmlspecialchars($action);
+            }
+
+            echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
+            echo '</li>';
+        }
+
+        echo '</ul>';
+        echo '<b>',_BATCH_DONE,'</b>';
+
+        $this->pagefoot();
+
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_batchteam() {
+        global $member;
+
+        $blogid = intRequestVar('blogid');
+
+        // check if logged in and admin
+        ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
+
+        // get array of itemids from request
+        $selected = requestIntArray('batch');
+        $action = requestVar('batchaction');
+
+        // Show error when no members selected
+        if (!is_array($selected) || sizeof($selected) == 0)
+            $this->error(_BATCH_NOSELECTION);
+
+        // On delete: check if confirmation has been given
+        if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
+            $this->batchAskDeleteConfirmation('team',$selected);
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manageteam&amp;blogid=',$blogid,'">(',_BACK,')</a></p>';
+
+        echo '<h2>',_BATCH_TEAM,'</h2>';
+        echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
+        echo '<ul>';
+
+        // walk over all itemids and perform action
+        foreach ($selected as $memberid) {
+            $memberid = intval($memberid);
+            echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
+
+            // perform action, display errors if needed
+            switch($action) {
+                case 'delete':
+                    $error = $this->deleteOneTeamMember($blogid, $memberid);
+                    break;
+                case 'setadmin':
+                    // always succeeds
+                    sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
+                    $error = '';
+                    break;
+                case 'unsetadmin':
+                    // there should always remain at least one admin
+                    $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
+                    if (sql_num_rows($r) < 2)
+                        $error = _ERROR_ATLEASTONEBLOGADMIN;
+                    else
+                        sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
+                    break;
+                default:
+                    $error = _BATCH_UNKNOWN . htmlspecialchars($action);
+            }
+
+            echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
+            echo '</li>';
+        }
+
+        echo '</ul>';
+        echo '<b>',_BATCH_DONE,'</b>';
+
+        $this->pagefoot();
+
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_batchcategory() {
+        global $member, $manager;
+
+        // check if logged in
+        $member->isLoggedIn() or $this->disallow();
+
+        // more precise check will be done for each performed operation
+
+        // get array of itemids from request
+        $selected = requestIntArray('batch');
+        $action = requestVar('batchaction');
+
+        // Show error when no items were selected
+        if (!is_array($selected) || sizeof($selected) == 0)
+            $this->error(_BATCH_NOSELECTION);
+
+        // On move: when no destination blog chosen, show choice now
+        $destBlogId = intRequestVar('destblogid');
+        if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
+            $this->batchMoveCategorySelectDestination('category',$selected);
+
+        // On delete: check if confirmation has been given
+        if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
+            $this->batchAskDeleteConfirmation('category',$selected);
+
+        $this->pagehead();
+
+        echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
+        echo '<h2>',BATCH_CATEGORIES,'</h2>';
+        echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
+        echo '<ul>';
+
+        // walk over all itemids and perform action
+        foreach ($selected as $catid) {
+            $catid = intval($catid);
+            echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
+
+            // perform action, display errors if needed
+            switch($action) {
+                case 'delete':
+                    $error = $this->deleteOneCategory($catid);
+                    break;
+                case 'move':
+                    $error = $this->moveOneCategory($catid, $destBlogId);
+                    break;
+                default:
+                    $error = _BATCH_UNKNOWN . htmlspecialchars($action);
+            }
+
+            echo '<b>',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),'</b>';
+            echo '</li>';
+        }
+
+        echo '</ul>';
+        echo '<b>',_BATCH_DONE,'</b>';
+
+        $this->pagefoot();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function batchMoveSelectDestination($type, $ids) {
+        global $manager;
+        $this->pagehead();
+        ?>
+        <h2><?php echo _MOVE_TITLE?></h2>
+        <form method="post" action="index.php"><div>
+
+            <input type="hidden" name="action" value="batch<?php echo $type?>" />
+            <input type="hidden" name="batchaction" value="move" />
+            <?php
+                $manager->addTicketHidden();
+
+                // insert selected item numbers
+                $idx = 0;
+                foreach ($ids as $id)
+                    echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
+
+                // show blog/category selection list
+                $this->selectBlogCategory('destcatid');
+
+            ?>
+
+
+            <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
+
+        </div></form>
+        <?php       $this->pagefoot();
+        exit;
+    }
+
+    /**
+     * @todo document this
+     */
+    function batchMoveCategorySelectDestination($type, $ids) {
+        global $manager;
+        $this->pagehead();
+        ?>
+        <h2><?php echo _MOVECAT_TITLE?></h2>
+        <form method="post" action="index.php"><div>
+
+            <input type="hidden" name="action" value="batch<?php echo $type?>" />
+            <input type="hidden" name="batchaction" value="move" />
+            <?php
+                $manager->addTicketHidden();
+
+                // insert selected item numbers
+                $idx = 0;
+                foreach ($ids as $id)
+                    echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
+
+                // show blog/category selection list
+                $this->selectBlog('destblogid');
+
+            ?>
+
+
+            <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
+
+        </div></form>
+        <?php       $this->pagefoot();
+        exit;
+    }
+
+    /**
+     * @todo document this
+     */
+    function batchAskDeleteConfirmation($type, $ids) {
+        global $manager;
+
+        $this->pagehead();
+        ?>
+        <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
+        <form method="post" action="index.php"><div>
+
+            <input type="hidden" name="action" value="batch<?php echo $type?>" />
+            <?php $manager->addTicketHidden() ?>
+            <input type="hidden" name="batchaction" value="delete" />
+            <input type="hidden" name="confirmation" value="yes" />
+            <?php               // insert selected item numbers
+                $idx = 0;
+                foreach ($ids as $id)
+                    echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
+
+                // add hidden vars for team & comment
+                if ($type == 'team')
+                {
+                    echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
+                }
+                if ($type == 'comment')
+                {
+                    echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
+                }
+
+            ?>
+
+            <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
+
+        </div></form>
+        <?php       $this->pagefoot();
+        exit;
+    }
+
+
+    /**
+     * Inserts a HTML select element with choices for all categories to which the current
+     * member has access
+     * @see function selectBlog
+     */
+    function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
+        ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
+    }
+
+    /**
+     * Inserts a HTML select element with choices for all blogs to which the user has access
+     *      mode = 'blog' => shows blognames and values are blogids
+     *      mode = 'category' => show category names and values are catids
+     *
+     * @param $iForcedBlogInclude
+     *      ID of a blog that always needs to be included, without checking if the
+     *      member is on the blog team (-1 = none)
+     * @todo document parameters
+     */
+    function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
+        global $member, $CONF;
+
+        // 0. get IDs of blogs to which member can post items (+ forced blog)
+        $aBlogIds = array();
+        if ($iForcedBlogInclude != -1)
+            $aBlogIds[] = intval($iForcedBlogInclude);
+
+        if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))
+            $queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
+        else
+            $queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
+        $rblogids = sql_query($queryBlogs);
+        while ($o = sql_fetch_object($rblogids))
+            if ($o->bnumber != $iForcedBlogInclude)
+                $aBlogIds[] = intval($o->bnumber);
+
+        if (count($aBlogIds) == 0)
+            return;
+
+        echo '<select name="',$name,'" tabindex="',$tabindex,'">';
+
+        // 1. select blogs (we'll create optiongroups)
+        // (only select those blogs that have the user on the team)
+        $queryBlogs =  'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
+        $blogs = sql_query($queryBlogs);
+        if ($mode == 'category') {
+            if (sql_num_rows($blogs) > 1)
+                $multipleBlogs = 1;
+
+            while ($oBlog = sql_fetch_object($blogs)) {
+                if ($multipleBlogs)
+                    echo '<optgroup label="',htmlspecialchars($oBlog->bname),'">';
+
+                // show selection to create new category when allowed/wanted
+                if ($showNewCat) {
+                    // check if allowed to do so
+                    if ($member->blogAdminRights($oBlog->bnumber))
+                        echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
+                }
+
+                // 2. for each category in that blog
+                $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
+                while ($oCat = sql_fetch_object($categories)) {
+                    if ($oCat->catid == $selected)
+                        $selectText = ' selected="selected" ';
+                    else
+                        $selectText = '';
+                    echo '<option value="',$oCat->catid,'" ', $selectText,'>',htmlspecialchars($oCat->cname),'</option>';
+                }
+
+                if ($multipleBlogs)
+                    echo '</optgroup>';
+            }
+        } else {
+            // blog mode
+            while ($oBlog = sql_fetch_object($blogs)) {
+                echo '<option value="',$oBlog->bnumber,'"';
+                if ($oBlog->bnumber == $selected)
+                    echo ' selected="selected"';
+                echo'>',htmlspecialchars($oBlog->bname),'</option>';
+            }
+        }
+        echo '</select>';
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_browseownitems() {
+        global $member, $manager, $CONF;
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
+        echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
+
+        // start index
+        if (postVar('start'))
+            $start = intPostVar('start');
+        else
+            $start = 0;
+
+        // amount of items to show
+        if (postVar('amount'))
+            $amount = intPostVar('amount');
+        else {
+            $amount = intval($CONF['DefaultListSize']);
+            if ($amount < 1)
+                $amount = 10;
+        }
+
+        $search = postVar('search');    // search through items
+
+        $query =  'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
+               . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
+               . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
+
+        if ($search)
+            $query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))';
+
+        $query .= ' ORDER BY itime DESC'
+                . " LIMIT $start,$amount";
+
+        $template['content'] = 'itemlist';
+        $template['now'] = time();
+
+        $manager->loadClass("ENCAPSULATE");
+        $navList =& new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
+        $navList->showBatchList('item',$query,'table',$template);
+
+        $this->pagefoot();
+
+    }
+
+    /**
+     * Show all the comments for a given item
+     * @param int $itemid
+     */
+    function action_itemcommentlist($itemid = '') {
+        global $member, $manager, $CONF;
+
+        if ($itemid == '')
+            $itemid = intRequestVar('itemid');
+
+        // only allow if user is allowed to alter item
+        $member->canAlterItem($itemid) or $this->disallow();
+
+        $blogid = getBlogIdFromItemId($itemid);
+
+        $this->pagehead();
+
+        // start index
+        if (postVar('start'))
+            $start = intPostVar('start');
+        else
+            $start = 0;
+
+        // amount of items to show
+        if (postVar('amount'))
+            $amount = intPostVar('amount');
+        else {
+            $amount = intval($CONF['DefaultListSize']);
+            if ($amount < 1)
+                $amount = 10;
+        }
+
+        $search = postVar('search');
+
+        echo '<p>(<a href="index.php?action=itemlist&amp;blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
+        echo '<h2>',_COMMENTS,'</h2>';
+
+        $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem FROM ' . sql_table('comment') . ' LEFT OUTER JOIN ' . sql_table('member') . ' ON mnumber = cmember WHERE citem = ' . $itemid;
+
+        if ($search)
+            $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
+
+        $query .= ' ORDER BY ctime ASC'
+                . " LIMIT $start,$amount";
+
+        $template['content'] = 'commentlist';
+        $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
+
+        $manager->loadClass("ENCAPSULATE");
+        $navList =& new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
+        $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
+
+        $this->pagefoot();
+    }
+
+    /**
+     * Browse own comments
+     */
+    function action_browseowncomments() {
+        global $member, $manager, $CONF;
+
+        // start index
+        if (postVar('start'))
+            $start = intPostVar('start');
+        else
+            $start = 0;
+
+        // amount of items to show
+        if (postVar('amount'))
+            $amount = intPostVar('amount');
+        else {
+            $amount = intval($CONF['DefaultListSize']);
+            if ($amount < 1)
+                $amount = 10;
+        }
+
+        $search = postVar('search');
+
+
+        $query =  'SELECT cbody, cuser, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cmember=' . $member->getID();
+
+        if ($search)
+            $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
+
+        $query .= ' ORDER BY ctime DESC'
+                . " LIMIT $start,$amount";
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
+        echo '<h2>', _COMMENTS_YOUR ,'</h2>';
+
+        $template['content'] = 'commentlist';
+        $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
+
+        $manager->loadClass("ENCAPSULATE");
+        $navList =& new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
+        $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
+
+        $this->pagefoot();
+    }
+
+    /**
+     * Browse all comments for a weblog
+     * @param int $blogid
+     */
+    function action_blogcommentlist($blogid = '')
+    {
+        global $member, $manager, $CONF;
+
+        if ($blogid == '')
+            $blogid = intRequestVar('blogid');
+        else
+            $blogid = intval($blogid);
+
+        $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
+
+        // start index
+        if (postVar('start'))
+            $start = intPostVar('start');
+        else
+            $start = 0;
+
+        // amount of items to show
+        if (postVar('amount'))
+            $amount = intPostVar('amount');
+        else {
+            $amount = intval($CONF['DefaultListSize']);
+            if ($amount < 1)
+                $amount = 10;
+        }
+
+        $search = postVar('search');        // search through comments
+
+
+        $query =  'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cblog=' . intval($blogid);
+
+        if ($search != '')
+            $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
+
+
+        $query .= ' ORDER BY ctime DESC'
+                . " LIMIT $start,$amount";
+
+
+        $blog =& $manager->getBlog($blogid);
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
+        echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
+
+        $template['content'] = 'commentlist';
+        $template['canAddBan'] = $member->blogAdminRights($blogid);
+
+        $manager->loadClass("ENCAPSULATE");
+        $navList =& new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
+        $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
+
+        $this->pagefoot();
+    }
+
+    /**
+     * Provide a page to item a new item to the given blog
+     */
+    function action_createitem() {
+        global $member, $manager;
+
+        $blogid = intRequestVar('blogid');
+
+        // check if allowed
+        $member->teamRights($blogid) or $this->disallow();
+
+        $memberid = $member->getID();
+
+        $blog =& $manager->getBlog($blogid);
+
+        $this->pagehead();
+
+        // generate the add-item form
+        $formfactory =& new PAGEFACTORY($blogid);
+        $formfactory->createAddForm('admin');
+
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_itemedit() {
+        global $member, $manager;
+
+        $itemid = intRequestVar('itemid');
+
+        // only allow if user is allowed to alter item
+        $member->canAlterItem($itemid) or $this->disallow();
+
+        $item =& $manager->getItem($itemid,1,1);
+        $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
+
+        $manager->notify('PrepareItemForEdit', array('item' => &$item));
+
+        if ($blog->convertBreaks()) {
+            $item['body'] = removeBreaks($item['body']);
+            $item['more'] = removeBreaks($item['more']);
+        }
+
+        // form to edit blog items
+        $this->pagehead();
+        $formfactory =& new PAGEFACTORY($blog->getID());
+        $formfactory->createEditForm('admin',$item);
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_itemupdate() {
+        global $member, $manager, $CONF;
+
+        $itemid = intRequestVar('itemid');
+        $catid = postVar('catid');
+
+        // only allow if user is allowed to alter item
+        $member->canUpdateItem($itemid, $catid) or $this->disallow();
+
+        $actiontype = postVar('actiontype');
+
+        // delete actions are handled by itemdelete (which has confirmation)
+        if ($actiontype == 'delete') {
+            $this->action_itemdelete();
+            return;
+        }
+
+        $body   = postVar('body');
+        $title  = postVar('title');
+        $more   = postVar('more');
+        $closed = intPostVar('closed');
+        $draftid = intPostVar('draftid');
+
+        // default action = add now
+        if (!$actiontype)
+            $actiontype='addnow';
+
+        // create new category if needed
+        if (strstr($catid,'newcat')) {
+            // get blogid
+            list($blogid) = sscanf($catid,"newcat-%d");
+
+            // create
+            $blog =& $manager->getBlog($blogid);
+            $catid = $blog->createNewCategory();
+
+            // show error when sth goes wrong
+            if (!$catid)
+                $this->doError(_ERROR_CATCREATEFAIL);
+        }
+
+        /*
+            set some variables based on actiontype
+
+            actiontypes:
+                draft items -> addnow, addfuture, adddraft, delete
+                non-draft items -> edit, changedate, delete
+
+            variables set:
+                $timestamp: set to a nonzero value for future dates or date changes
+                $wasdraft: set to 1 when the item used to be a draft item
+                $publish: set to 1 when the edited item is not a draft
+        */
+        $blogid =  getBlogIDFromItemID($itemid);
+        $blog   =& $manager->getBlog($blogid);
+
+        $wasdrafts = array('adddraft', 'addfuture', 'addnow');
+        $wasdraft  = in_array($actiontype, $wasdrafts) ? 1 : 0;
+        $publish   = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
+        if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
+            $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
+        } else {
+            $timestamp =0;
+        }
+
+        // edit the item for real
+        ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
+
+        $this->updateFuturePosted($blogid);
+
+        if ($draftid > 0) {
+            // delete permission is checked inside ITEM::delete()
+            ITEM::delete($draftid);
+        }
+
+        // show category edit window when we created a new category
+        // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
+        if ($catid != intPostVar('catid')) {
+            $this->action_categoryedit(
+                $catid,
+                $blog->getID(),
+                $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
+            );
+        } else {
+            // TODO: set start item correctly for itemlist
+            $this->action_itemlist(getBlogIDFromItemID($itemid));
+        }
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_itemdelete() {
+        global $member, $manager;
+
+        $itemid = intRequestVar('itemid');
+
+        // only allow if user is allowed to alter item
+        $member->canAlterItem($itemid) or $this->disallow();
+
+        if (!$manager->existsItem($itemid,1,1))
+            $this->error(_ERROR_NOSUCHITEM);
+
+        $item =& $manager->getItem($itemid,1,1);
+        $title = htmlspecialchars(strip_tags($item['title']));
+        $body = strip_tags($item['body']);
+        $body = htmlspecialchars(shorten($body,300,'...'));
+
+        $this->pagehead();
+        ?>
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+
+            <p><?php echo _CONFIRMTXT_ITEM?></p>
+
+            <div class="note">
+                <b>"<?php echo  $title ?>"</b>
+                <br />
+                <?php echo $body?>
+            </div>
+
+            <form method="post" action="index.php"><div>
+                <input type="hidden" name="action" value="itemdeleteconfirm" />
+                <?php $manager->addTicketHidden() ?>
+                <input type="hidden" name="itemid" value="<?php echo  $itemid; ?>" />
+                <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>"  tabindex="10" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_itemdeleteconfirm() {
+        global $member;
+
+        $itemid = intRequestVar('itemid');
+
+        // only allow if user is allowed to alter item
+        $member->canAlterItem($itemid) or $this->disallow();
+
+        // get blogid first
+        $blogid = getBlogIdFromItemId($itemid);
+
+        // delete item (note: some checks will be performed twice)
+        $this->deleteOneItem($itemid);
+
+        $this->action_itemlist($blogid);
+    }
+
+    /**
+     * Deletes one item and returns error if something goes wrong
+     * @param int $itemid
+     */
+    function deleteOneItem($itemid) {
+        global $member, $manager;
+
+        // only allow if user is allowed to alter item (also checks if itemid exists)
+        if (!$member->canAlterItem($itemid))
+            return _ERROR_DISALLOWED;
+
+        // need to get blogid before the item is deleted
+        $blogid = getBlogIDFromItemId($itemid);
+
+        $manager->loadClass('ITEM');
+        ITEM::delete($itemid);
+
+        // update blog's futureposted
+        $this->updateFuturePosted($blogid);
+    }
+
+    /**
+     * Update a blog's future posted flag
+     * @param int $blogid
+     */
+    function updateFuturePosted($blogid) {
+        global $manager;
+
+        $blog =& $manager->getBlog($blogid);
+        $currenttime = $blog->getCorrectTime(time());
+        $result = sql_query("SELECT * FROM ".sql_table('item').
+            " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
+        if (sql_num_rows($result) > 0) {
+                $blog->setFuturePost();
+        }
+        else {
+                $blog->clearFuturePost();
+        }
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_itemmove() {
+        global $member, $manager;
+
+        $itemid = intRequestVar('itemid');
+
+        // only allow if user is allowed to alter item
+        $member->canAlterItem($itemid) or $this->disallow();
+
+        $item =& $manager->getItem($itemid,1,1);
+
+        $this->pagehead();
+        ?>
+            <h2><?php echo _MOVE_TITLE?></h2>
+            <form method="post" action="index.php"><div>
+                <input type="hidden" name="action" value="itemmoveto" />
+                <input type="hidden" name="itemid" value="<?php echo  $itemid; ?>" />
 
-		$this->pagehead();
-		?>
-		<h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
-		<form method="post" action="index.php"><div>
-
-			<input type="hidden" name="action" value="batch<?php echo $type?>" />
-			<?php $manager->addTicketHidden() ?>
-			<input type="hidden" name="batchaction" value="delete" />
-			<input type="hidden" name="confirmation" value="yes" />
-			<?php				// insert selected item numbers
-				$idx = 0;
-				foreach ($ids as $id)
-					echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
-
-				// add hidden vars for team & comment
-				if ($type == 'team')
-				{
-					echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
-				}
-				if ($type == 'comment')
-				{
-					echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
-				}
-
-			?>
-
-			<input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
-
-		</div></form>
-		<?php		$this->pagefoot();
-		exit;
-	}
-
-
-	/**
-	 * Inserts a HTML select element with choices for all categories to which the current
-	 * member has access
-	 * @see function selectBlog
-	 */
-	function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
-		ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
-	}
-
-	/**
-	 * Inserts a HTML select element with choices for all blogs to which the user has access
-	 *		mode = 'blog' => shows blognames and values are blogids
-	 *		mode = 'category' => show category names and values are catids
-	 *
-	 * @param $iForcedBlogInclude
-	 *		ID of a blog that always needs to be included, without checking if the
-	 *		member is on the blog team (-1 = none)
-	 * @todo document parameters
-	 */
-	function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
-		global $member, $CONF;
-
-		// 0. get IDs of blogs to which member can post items (+ forced blog)
-		$aBlogIds = array();
-		if ($iForcedBlogInclude != -1)
-			$aBlogIds[] = intval($iForcedBlogInclude);
-
-		if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))
-			$queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
-		else
-			$queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
-		$rblogids = sql_query($queryBlogs);
-		while ($o = mysql_fetch_object($rblogids))
-			if ($o->bnumber != $iForcedBlogInclude)
-				$aBlogIds[] = intval($o->bnumber);
-
-		if (count($aBlogIds) == 0)
-			return;
-
-		echo '<select name="',$name,'" tabindex="',$tabindex,'">';
-
-		// 1. select blogs (we'll create optiongroups)
-		// (only select those blogs that have the user on the team)
-		$queryBlogs =  'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
-		$blogs = sql_query($queryBlogs);
-		if ($mode == 'category') {
-			if (mysql_num_rows($blogs) > 1)
-				$multipleBlogs = 1;
-
-			while ($oBlog = mysql_fetch_object($blogs)) {
-				if ($multipleBlogs)
-					echo '<optgroup label="',htmlspecialchars($oBlog->bname),'">';
-
-				// show selection to create new category when allowed/wanted
-				if ($showNewCat) {
-					// check if allowed to do so
-					if ($member->blogAdminRights($oBlog->bnumber))
-						echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
-				}
-
-				// 2. for each category in that blog
-				$categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
-				while ($oCat = mysql_fetch_object($categories)) {
-					if ($oCat->catid == $selected)
-						$selectText = ' selected="selected" ';
-					else
-						$selectText = '';
-					echo '<option value="',$oCat->catid,'" ', $selectText,'>',htmlspecialchars($oCat->cname),'</option>';
-				}
-
-				if ($multipleBlogs)
-					echo '</optgroup>';
-			}
-		} else {
-			// blog mode
-			while ($oBlog = mysql_fetch_object($blogs)) {
-				echo '<option value="',$oBlog->bnumber,'"';
-				if ($oBlog->bnumber == $selected)
-					echo ' selected="selected"';
-				echo'>',htmlspecialchars($oBlog->bname),'</option>';
-			}
-		}
-		echo '</select>';
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_browseownitems() {
-		global $member, $manager, $CONF;
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-		echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
-
-		// start index
-		if (postVar('start'))
-			$start = intPostVar('start');
-		else
-			$start = 0;
-
-		// amount of items to show
-		if (postVar('amount'))
-			$amount = intPostVar('amount');
-		else {
-			$amount = intval($CONF['DefaultListSize']);
-			if ($amount < 1)
-				$amount = 10;
-		}
-
-		$search = postVar('search');	// search through items
-
-		$query =  'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
-			   . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
-			   . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
-
-		if ($search)
-			$query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))';
-
-		$query .= ' ORDER BY itime DESC'
-				. " LIMIT $start,$amount";
-
-		$template['content'] = 'itemlist';
-		$template['now'] = time();
-
-		$manager->loadClass("ENCAPSULATE");
-		$navList =& new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
-		$navList->showBatchList('item',$query,'table',$template);
-
-		$this->pagefoot();
-
-	}
-
-	/**
-	 * Show all the comments for a given item
-	 * @param int $itemid
-	 */
-	function action_itemcommentlist($itemid = '') {
-		global $member, $manager, $CONF;
-
-		if ($itemid == '')
-			$itemid = intRequestVar('itemid');
-
-		// only allow if user is allowed to alter item
-		$member->canAlterItem($itemid) or $this->disallow();
-
-		$blogid = getBlogIdFromItemId($itemid);
-
-		$this->pagehead();
-
-		// start index
-		if (postVar('start'))
-			$start = intPostVar('start');
-		else
-			$start = 0;
-
-		// amount of items to show
-		if (postVar('amount'))
-			$amount = intPostVar('amount');
-		else {
-			$amount = intval($CONF['DefaultListSize']);
-			if ($amount < 1)
-				$amount = 10;
-		}
-
-		$search = postVar('search');
-
-		echo '<p>(<a href="index.php?action=itemlist&amp;blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
-		echo '<h2>',_COMMENTS,'</h2>';
-
-		$query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem FROM ' . sql_table('comment') . ' LEFT OUTER JOIN ' . sql_table('member') . ' ON mnumber = cmember WHERE citem = ' . $itemid;
-
-		if ($search)
-			$query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
-
-		$query .= ' ORDER BY ctime ASC'
-				. " LIMIT $start,$amount";
-
-		$template['content'] = 'commentlist';
-		$template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
-
-		$manager->loadClass("ENCAPSULATE");
-		$navList =& new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
-		$navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * Browse own comments
-	 */
-	function action_browseowncomments() {
-		global $member, $manager, $CONF;
-
-		// start index
-		if (postVar('start'))
-			$start = intPostVar('start');
-		else
-			$start = 0;
-
-		// amount of items to show
-		if (postVar('amount'))
-			$amount = intPostVar('amount');
-		else {
-			$amount = intval($CONF['DefaultListSize']);
-			if ($amount < 1)
-				$amount = 10;
-		}
-
-		$search = postVar('search');
-
-
-		$query =  'SELECT cbody, cuser, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cmember=' . $member->getID();
-
-		if ($search)
-			$query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
-
-		$query .= ' ORDER BY ctime DESC'
-				. " LIMIT $start,$amount";
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-		echo '<h2>', _COMMENTS_YOUR ,'</h2>';
-
-		$template['content'] = 'commentlist';
-		$template['canAddBan'] = 0;	// doesn't make sense to allow banning yourself
-
-		$manager->loadClass("ENCAPSULATE");
-		$navList =& new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
-		$navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * Browse all comments for a weblog
-	 * @param int $blogid
-	 */
-	function action_blogcommentlist($blogid = '')
-	{
-		global $member, $manager, $CONF;
-
-		if ($blogid == '')
-			$blogid = intRequestVar('blogid');
-		else
-			$blogid = intval($blogid);
-
-		$member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
-
-		// start index
-		if (postVar('start'))
-			$start = intPostVar('start');
-		else
-			$start = 0;
-
-		// amount of items to show
-		if (postVar('amount'))
-			$amount = intPostVar('amount');
-		else {
-			$amount = intval($CONF['DefaultListSize']);
-			if ($amount < 1)
-				$amount = 10;
-		}
-
-		$search = postVar('search');		// search through comments
-
-
-		$query =  'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cblog=' . intval($blogid);
-
-		if ($search != '')
-			$query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
-
-
-		$query .= ' ORDER BY ctime DESC'
-				. " LIMIT $start,$amount";
-
-
-		$blog =& $manager->getBlog($blogid);
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-		echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
-
-		$template['content'] = 'commentlist';
-		$template['canAddBan'] = $member->blogAdminRights($blogid);
-
-		$manager->loadClass("ENCAPSULATE");
-		$navList =& new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
-		$navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * Provide a page to item a new item to the given blog
-	 */
-	function action_createitem() {
-		global $member, $manager;
-
-		$blogid = intRequestVar('blogid');
-
-		// check if allowed
-		$member->teamRights($blogid) or $this->disallow();
-
-		$memberid = $member->getID();
-
-		$blog =& $manager->getBlog($blogid);
-
-		$this->pagehead();
-
-		// generate the add-item form
-		$formfactory =& new PAGEFACTORY($blogid);
-		$formfactory->createAddForm('admin');
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_itemedit() {
-		global $member, $manager;
-
-		$itemid = intRequestVar('itemid');
-
-		// only allow if user is allowed to alter item
-		$member->canAlterItem($itemid) or $this->disallow();
-
-		$item =& $manager->getItem($itemid,1,1);
-		$blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
-
-		$manager->notify('PrepareItemForEdit', array('item' => &$item));
-
-		if ($blog->convertBreaks()) {
-			$item['body'] = removeBreaks($item['body']);
-			$item['more'] = removeBreaks($item['more']);
-		}
-
-		// form to edit blog items
-		$this->pagehead();
-		$formfactory =& new PAGEFACTORY($blog->getID());
-		$formfactory->createEditForm('admin',$item);
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_itemupdate() {
-		global $member, $manager, $CONF;
-
-		$itemid = intRequestVar('itemid');
-		$catid = postVar('catid');
-
-		// only allow if user is allowed to alter item
-		$member->canUpdateItem($itemid, $catid) or $this->disallow();
-
-		$actiontype = postVar('actiontype');
-
-		// delete actions are handled by itemdelete (which has confirmation)
-		if ($actiontype == 'delete') {
-			$this->action_itemdelete();
-			return;
-		}
-
-		$body 	= postVar('body');
-		$title 	= postVar('title');
-		$more 	= postVar('more');
-		$closed = intPostVar('closed');
-		$draftid = intPostVar('draftid');
-
-		// default action = add now
-		if (!$actiontype)
-			$actiontype='addnow';
-
-		// create new category if needed
-		if (strstr($catid,'newcat')) {
-			// get blogid
-			list($blogid) = sscanf($catid,"newcat-%d");
-
-			// create
-			$blog =& $manager->getBlog($blogid);
-			$catid = $blog->createNewCategory();
-
-			// show error when sth goes wrong
-			if (!$catid)
-				$this->doError(_ERROR_CATCREATEFAIL);
-		}
-
-		/*
-			set some variables based on actiontype
-
-			actiontypes:
-				draft items -> addnow, addfuture, adddraft, delete
-				non-draft items -> edit, changedate, delete
-
-			variables set:
-				$timestamp: set to a nonzero value for future dates or date changes
-				$wasdraft: set to 1 when the item used to be a draft item
-				$publish: set to 1 when the edited item is not a draft
-		*/
-/*<del by shizuki>
-		switch ($actiontype) {
-			case 'adddraft':
-				$publish = 0;
-				$wasdraft = 1;
-				$timestamp = 0;
-				break;
-			case 'addfuture':
-				$wasdraft = 1;
-				$publish = 1;
-				$timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
-				break;
-			case 'addnow':
-				$wasdraft = 1;
-				$publish = 1;
-				$timestamp = 0;
-				break;
-			case 'changedate':
-				$timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
-				$publish = 1;
-				$wasdraft = 0;
-				break;
-			case 'backtodrafts':
-				$wasdraft = 0;
-				$publish = 0;
-				$timestamp = 0;
-				break;
-			case 'edit':
-			default:
-				$publish = 1;
-				$wasdraft = 0;
-				$timestamp = 0;
-		}
-</del by shizuki>*/
-// <add by shizuki>
-		$blogid =  getBlogIDFromItemID($itemid);
-		$blog   =& $manager->getBlog($blogid);
-
-		$wasdrafts = array('adddraft', 'addfuture', 'addnow');
-		$wasdraft  = in_array($actiontype, $wasdrafts) ? 1 : 0;
-		$publish   = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
-		if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
-			$timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
-		} else {
-			$timestamp =0;
-		}
-		$doping = ($publish && $timestamp < $blog->getCorrectTime() && postVar('dosendping')) ? 1 : 0;
-// </add by shizuki>
-
-		// edit the item for real
-		ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
-
-/* <del by shizuki>
-		$blogid = getBlogIDFromItemID($itemid);
-		$blog =& $manager->getBlog($blogid);
-
-		$isFuture = 0;
-		if ($timestamp > $blog->getCorrectTime(time())) {
-			$isFuture = 1;
-		}
-
-</del by shizuki>*/
-		$this->updateFuturePosted($blogid);
-
-		if ($draftid > 0) {
-			// delete permission is checked inside ITEM::delete()
-			ITEM::delete($draftid);
-		}
-
-//		if (!$closed && $publish && $wasdraft && $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0 && !$isFuture) {
-		if (!$closed && $doping && $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0) {		//<mod by shizuki />
-			$this->action_sendping($blogid);
-			return;
-		}
-
-		// show category edit window when we created a new category
-		// ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
-		if ($catid != intPostVar('catid')) {
-			$this->action_categoryedit(
-				$catid,
-				$blog->getID(),
-				$CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
-			);
-		} else {
-			// TODO: set start item correctly for itemlist
-			$this->action_itemlist(getBlogIDFromItemID($itemid));
-		}
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_itemdelete() {
-		global $member, $manager;
-
-		$itemid = intRequestVar('itemid');
-
-		// only allow if user is allowed to alter item
-		$member->canAlterItem($itemid) or $this->disallow();
-
-		if (!$manager->existsItem($itemid,1,1))
-			$this->error(_ERROR_NOSUCHITEM);
-
-		$item =& $manager->getItem($itemid,1,1);
-		$title = htmlspecialchars(strip_tags($item['title']));
-		$body = strip_tags($item['body']);
-		$body = htmlspecialchars(shorten($body,300,'...'));
-
-		$this->pagehead();
-		?>
-			<h2><?php echo _DELETE_CONFIRM?></h2>
-
-			<p><?php echo _CONFIRMTXT_ITEM?></p>
-
-			<div class="note">
-				<b>"<?php echo  $title ?>"</b>
-				<br />
-				<?php echo $body?>
-			</div>
-
-			<form method="post" action="index.php"><div>
-				<input type="hidden" name="action" value="itemdeleteconfirm" />
-				<?php $manager->addTicketHidden() ?>
-				<input type="hidden" name="itemid" value="<?php echo  $itemid; ?>" />
-				<input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>"  tabindex="10" />
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_itemdeleteconfirm() {
-		global $member;
-
-		$itemid = intRequestVar('itemid');
-
-		// only allow if user is allowed to alter item
-		$member->canAlterItem($itemid) or $this->disallow();
-
-		// get blogid first
-		$blogid = getBlogIdFromItemId($itemid);
-
-		// delete item (note: some checks will be performed twice)
-		$this->deleteOneItem($itemid);
-
-		$this->action_itemlist($blogid);
-	}
-
-	/**
-	 * Deletes one item and returns error if something goes wrong
-	 * @param int $itemid
-	 */
-	function deleteOneItem($itemid) {
-		global $member, $manager;
-
-		// only allow if user is allowed to alter item (also checks if itemid exists)
-		if (!$member->canAlterItem($itemid))
-			return _ERROR_DISALLOWED;
-
-		// need to get blogid before the item is deleted
-		$blogid = getBlogIDFromItemId($itemid);
-
-		$manager->loadClass('ITEM');
-		ITEM::delete($itemid);
-
-		// update blog's futureposted
-		$this->updateFuturePosted($blogid);
-	}
-
-	/**
-	 * Update a blog's future posted flag
-	 * @param int $blogid
-	 */
-	function updateFuturePosted($blogid) {
-		global $manager;
-
-		$blog =& $manager->getBlog($blogid);
-		$currenttime = $blog->getCorrectTime(time());
-		$result = sql_query("SELECT * FROM ".sql_table('item').
-			" WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
-		if (mysql_num_rows($result) > 0) {
-				$blog->setFuturePost();
-		}
-		else {
-				$blog->clearFuturePost();
-		}
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_itemmove() {
-		global $member, $manager;
-
-		$itemid = intRequestVar('itemid');
-
-		// only allow if user is allowed to alter item
-		$member->canAlterItem($itemid) or $this->disallow();
-
-		$item =& $manager->getItem($itemid,1,1);
-
-		$this->pagehead();
-		?>
-			<h2><?php echo _MOVE_TITLE?></h2>
-			<form method="post" action="index.php"><div>
-				<input type="hidden" name="action" value="itemmoveto" />
-				<input type="hidden" name="itemid" value="<?php echo  $itemid; ?>" />
-
-				<?php
-
-					$manager->addTicketHidden();
-					$this->selectBlogCategory('catid',$item['catid'],10,1);
-				?>
-
-				<input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_itemmoveto() {
-		global $member, $manager;
-
-		$itemid = intRequestVar('itemid');
-		$catid = requestVar('catid');
-
-		// create new category if needed
-		if (strstr($catid,'newcat')) {
-			// get blogid
-			list($blogid) = sscanf($catid,'newcat-%d');
-
-			// create
-			$blog =& $manager->getBlog($blogid);
-			$catid = $blog->createNewCategory();
-
-			// show error when sth goes wrong
-			if (!$catid)
-				$this->doError(_ERROR_CATCREATEFAIL);
-		}
-
-		// only allow if user is allowed to alter item
-		$member->canUpdateItem($itemid, $catid) or $this->disallow();
-
-		$old_blogid = getBlogIDFromItemId($itemid);
-
-		ITEM::move($itemid, $catid);
-
-		// set the futurePosted flag on the blog
-		$this->updateFuturePosted(getBlogIDFromItemId($itemid));
-
-		// reset the futurePosted in case the item is moved from one blog to another
-		$this->updateFuturePosted($old_blogid);
-
-		if ($catid != intRequestVar('catid'))
-			$this->action_categoryedit($catid, $blog->getID());
-		else
-			$this->action_itemlist(getBlogIDFromCatID($catid));
-	}
-
-	/**
-	 * Moves one item to a given category (category existance should be checked by caller)
-	 * errors are returned
-	 * @param int $itemid
-	 * @param int $destCatid category ID to which the item will be moved
-	 */
-	function moveOneItem($itemid, $destCatid) {
-		global $member;
-
-		// only allow if user is allowed to move item
-		if (!$member->canUpdateItem($itemid, $destCatid))
-			return _ERROR_DISALLOWED;
-
-		ITEM::move($itemid, $destCatid);
-	}
-
-	/**
-	 * Adds a item to the chosen blog
-	 */
-	function action_additem() {
-		global $member, $manager, $CONF;
-
-		$manager->loadClass('ITEM');
-
-		$result = ITEM::createFromRequest();
-
-		if ($result['status'] == 'error')
-			$this->error($result['message']);
-
-		$blogid = getBlogIDFromItemID($result['itemid']);
-		$blog =& $manager->getBlog($blogid);
-/* <del by shizuki>
-		$pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid));
-
-		if ($result['status'] == 'newcategory')
-			$this->action_categoryedit(
-				$result['catid'],
-				$blogid,
-				$blog->sendPing() && numberOfEventSubscriber('SendPing') > 0 ? $pingUrl : ''
-			);
-		elseif ((postVar('actiontype') == 'addnow') && $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0)
-			$this->action_sendping($blogid);
-		else
-			$this->action_itemlist($blogid);
-</del by shizuki>*/
-// <add by shizuki>
-		$btimestamp = $blog->getCorrectTime();
-		$bPingInfo  = ($blog->sendPing() && numberOfEventSubscriber('SendPing') > 0);
-		$item       = $manager->getItem(intval($result['itemid']), 1, 1);
-		$iPingInfo  = (!$item['draft'] && postVar('dosendping') && $item['timestamp'] <= $btimestamp);
-		if ($iPingInfo && $bPingInfo) {
-			$nextAction = 'sendping';
-		} else {
-			$nextAction = 'itemlist';
-		}
-		if ($result['status'] == 'newcategory') {
-//			$distURI = ($nextAction == 'sendping') ? $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action='
-//					 . $nextAction . '&blogid=' . intval($blogid)) :
-//					   '';
-			$distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=' . $nextAction . '&blogid=' . intval($blogid));
-			$this->action_categoryedit($result['catid'], $blogid, $distURI);
-		} else {
-			$methodName = 'action_' . $nextAction;
-			call_user_func(array(&$this, $methodName), $blogid);
-		}
-//</add by shizuki>
-	}
-
-	/**
-	 * Shows a window that says we're about to ping.
-	 * immediately refresh to the real pinging page, which will
-	 * show an error, or redirect to the blog.
-	 *
-	 * @param int $blogid ID of blog for which ping needs to be sent out
-	 */
-	function action_sendping($blogid = -1) {
-		global $member, $manager;
-
-		if ($blogid == -1)
-			$blogid = intRequestVar('blogid');
-
-		$member->isLoggedIn() or $this->disallow();
-
-		$rawPingUrl = $manager->addTicketToUrl('index.php?action=rawping&blogid=' . intval($blogid));
-
-		$this->pagehead('<meta http-equiv="refresh" content="1; url='.htmlspecialchars($rawPingUrl).'" />');
-		echo _UPDATEDPING_MESSAGE;
-		?>
-		<a href="index.php?action=rawping&amp;blogid=<?php echo $blogid?>"><?php echo _UPDATEDPING_GOPINGPAGE ?></a>
-		</p>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * Sends the real ping (can take up to 10 seconds!)
-	 */
-	function action_rawping() {
-		global $manager;
-		// TODO: checks?
-
-		$blogid = intRequestVar('blogid');
-		$blog =& $manager->getBlog($blogid);
-
-		$this->pagehead();
-
-		?>
-
-		<h2><?php echo _UPDATEDPING_PINGING ?></h2>
-		<div class='note'>
                 <?php
 
-		// send sendPing event
-		$manager->notify('SendPing', array('blogid' => $blogid));
-
+                    $manager->addTicketHidden();
+                    $this->selectBlogCategory('catid',$item['catid'],10,1);
                 ?>
-                </div>
-
-		<ul>
-			<li><a href="index.php?action=itemlist&amp;blogid=<?php echo $blog->getID()?>"><?php echo _UPDATEDPING_VIEWITEM . htmlspecialchars($blog->getName())?></a></li>
-			<li><a href="<?php echo $blog->getURL()?>"><?php echo _UPDATEDPING_VISITOWNSITE ?></a></li>
-		</ul>
-
-		<?php		$this->pagefoot();
-	}
-
-	/**
-	 * Allows to edit previously made comments
-	 */
-	function action_commentedit() {
-		global $member, $manager;
-
-		$commentid = intRequestVar('commentid');
-
-		$member->canAlterComment($commentid) or $this->disallow();
-
-		$comment = COMMENT::getComment($commentid);
-
-		$manager->notify('PrepareCommentForEdit',array('comment' => &$comment));
-
-		// change <br /> to \n
-		$comment['body'] = str_replace('<br />','',$comment['body']);
-
-		$comment['body'] = eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>","\\1",$comment['body']);
-
-		$this->pagehead();
-
-		?>
-		<h2><?php echo _EDITC_TITLE?></h2>
-
-		<form action="index.php" method="post"><div>
-
-		<input type="hidden" name="action" value="commentupdate" />
-		<?php $manager->addTicketHidden(); ?>
-		<input type="hidden" name="commentid" value="<?php echo  $commentid; ?>" />
-		<table><tr>
-			<th colspan="2"><?php echo _EDITC_TITLE?></th>
-		</tr><tr>
-			<td><?php echo _EDITC_WHO?></td>
-			<td>
-			<?php				if ($comment['member'])
-					echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
-				else
-					echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
-			?>
-			</td>
-		</tr><tr>
-			<td><?php echo _EDITC_WHEN?></td>
-			<td><?php echo  date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
-		</tr><tr>
-			<td><?php echo _EDITC_HOST?></td>
-			<td><?php echo  $comment['host']; ?></td>
-		</tr>
-		<tr>
-			<td><?php echo _EDITC_URL; ?></td>
-			<td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
-		</tr>
-		<tr>
-			<td><?php echo _EDITC_EMAIL; ?></td>
-			<td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
-		</tr>
-		<tr>
-			<td><?php echo _EDITC_TEXT?></td>
-			<td>
-				<textarea name="body" tabindex="10" rows="10" cols="50"><?php					// htmlspecialchars not needed (things should be escaped already)
-					echo $comment['body'];
-				?></textarea>
-			</td>
-		</tr><tr>
-			<td><?php echo _EDITC_EDIT?></td>
-			<td><input type="submit"  tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
-		</tr></table>
-
-		</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_commentupdate() {
-		global $member, $manager;
-
-		$commentid = intRequestVar('commentid');
-
-		$member->canAlterComment($commentid) or $this->disallow();
-
-		$url = postVar('url');
-		$email = postVar('email');
-		$body = postVar('body');
-
-		// intercept words that are too long
-		if (eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}",$body) != false)
-			$this->error(_ERROR_COMMENT_LONGWORD);
-
-		// check length
-		if (strlen($body)<3)
-			$this->error(_ERROR_COMMENT_NOCOMMENT);
-		if (strlen($body)>5000)
-			$this->error(_ERROR_COMMENT_TOOLONG);
-
-
-		// prepare body
-		$body = COMMENT::prepareBody($body);
-
-		// call plugins
-		$manager->notify('PreUpdateComment',array('body' => &$body));
-
-		$query = 'UPDATE ' . sql_table('comment')
-			   . " SET cmail = '" . addslashes($url) . "', cemail = '" . addslashes($email) . "', cbody = '" . addslashes($body) . "'"
-			   . " WHERE cnumber = " . $commentid;
-		sql_query($query);
-
-		// get itemid
-		$res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
-		$o = mysql_fetch_object($res);
-		$itemid = $o->citem;
-
-		if ($member->canAlterItem($itemid))
-			$this->action_itemcommentlist($itemid);
-		else
-			$this->action_browseowncomments();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_commentdelete() {
-		global $member, $manager;
-
-		$commentid = intRequestVar('commentid');
-
-		$member->canAlterComment($commentid) or $this->disallow();
-
-		$comment = COMMENT::getComment($commentid);
-
-		$body = strip_tags($comment['body']);
-		$body = htmlspecialchars(shorten($body, 300, '...'));
-
-		if ($comment['member'])
-			$author = $comment['member'];
-		else
-			$author = $comment['user'];
-
-		$this->pagehead();
-		?>
-
-			<h2><?php echo _DELETE_CONFIRM?></h2>
-
-			<p><?php echo _CONFIRMTXT_COMMENT?></p>
-
-			<div class="note">
-			<b><?php echo _EDITC_WHO?>:</b> <?php echo  $author ?>
-			<br />
-			<b><?php echo _EDITC_TEXT?>:</b> <?php echo  $body ?>
-			</div>
-
-			<form method="post" action="index.php"><div>
-				<input type="hidden" name="action" value="commentdeleteconfirm" />
-				<?php $manager->addTicketHidden() ?>
-				<input type="hidden" name="commentid" value="<?php echo  $commentid; ?>" />
-				<input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_commentdeleteconfirm() {
-		global $member;
-
-		$commentid = intRequestVar('commentid');
-
-		// get item id first
-		$res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
-		$o = mysql_fetch_object($res);
-		$itemid = $o->citem;
-
-		$error = $this->deleteOneComment($commentid);
-		if ($error)
-			$this->doError($error);
-
-		if ($member->canAlterItem($itemid))
-			$this->action_itemcommentlist($itemid);
-		else
-			$this->action_browseowncomments();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function deleteOneComment($commentid) {
-		global $member, $manager;
-
-		$commentid = intval($commentid);
-
-		if (!$member->canAlterComment($commentid))
-			return _ERROR_DISALLOWED;
-
-		$manager->notify('PreDeleteComment', array('commentid' => $commentid));
-
-		// delete the comments associated with the item
-		$query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
-		sql_query($query);
-
-		$manager->notify('PostDeleteComment', array('commentid' => $commentid));
-
-		return '';
-	}
-
-	/**
-	 * Usermanagement main
-	 */
-	function action_usermanagement() {
-		global $member, $manager;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-		echo '<h2>' . _MEMBERS_TITLE .'</h2>';
-
-		echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
-
-		// show list of members with actions
-		$query =  'SELECT *'
-			   . ' FROM '.sql_table('member');
-		$template['content'] = 'memberlist';
-		$template['tabindex'] = 10;
-
-		$manager->loadClass("ENCAPSULATE");
-		$batch =& new BATCH('member');
-		$batch->showlist($query,'table',$template);
-
-		echo '<h3>' . _MEMBERS_NEW .'</h3>';
-		?>
-			<form method="post" action="index.php" name="memberedit"><div>
-
-			<input type="hidden" name="action" value="memberadd" />
-			<?php $manager->addTicketHidden() ?>
-
-			<table>
-			<tr>
-				<th colspan="2"><?php echo _MEMBERS_NEW?></th>
-			</tr><tr>
-				<td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
-				<br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
-				</td>
-				<td><input tabindex="10010" name="name" size="16" maxlength="16" /></td>
-			</tr><tr>
-				<td><?php echo _MEMBERS_REALNAME?></td>
-				<td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
-			</tr><tr>
-				<td><?php echo _MEMBERS_PWD?></td>
-				<td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
-			</tr><tr>
-				<td><?php echo _MEMBERS_REPPWD?></td>
-				<td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
-			</tr><tr>
-				<td><?php echo _MEMBERS_EMAIL?></td>
-				<td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
-			</tr><tr>
-				<td><?php echo _MEMBERS_URL?></td>
-				<td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
-			</tr><tr>
-				<td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
-				<td><?php $this->input_yesno('admin',0,10060); ?> </td>
-			</tr><tr>
-				<td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
-				<td><?php $this->input_yesno('canlogin',1,10070); ?></td>
-			</tr><tr>
-				<td><?php echo _MEMBERS_NOTES?></td>
-				<td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
-			</tr><tr>
-				<td><?php echo _MEMBERS_NEW?></td>
-				<td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
-			</tr></table>
-
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * Edit member settings
-	 */
-	function action_memberedit() {
-		$this->action_editmembersettings(intRequestVar('memberid'));
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_editmembersettings($memberid = '') {
-		global $member, $manager, $CONF;
-
-		if ($memberid == '')
-			$memberid = $member->getID();
-
-		// check if allowed
-		($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-
-		$extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
-		$this->pagehead($extrahead);
-
-		// show message to go back to member overview (only for admins)
-		if ($member->isAdmin())
-			echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
-		else
-			echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
-
-		echo '<h2>' . _MEMBERS_EDIT . '</h2>';
-
-		$mem = MEMBER::createFromID($memberid);
-
-		?>
-		<form method="post" action="index.php" name="memberedit"><div>
-
-		<input type="hidden" name="action" value="changemembersettings" />
-		<input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />
-		<?php $manager->addTicketHidden() ?>
-
-		<table><tr>
-			<th colspan="2"><?php echo _MEMBERS_EDIT?></th>
-		</tr><tr>
-			<td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
-				<br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
-			</td>
-			<td>
-			<?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
-				<input name="name" tabindex="10" maxlength="16" size="16" value="<?php echo  htmlspecialchars($mem->getDisplayName()); ?>" />
-			<?php } else {
-				echo htmlspecialchars($member->getDisplayName());
-			   }
-			?>
-			</td>
-		</tr><tr>
-			<td><?php echo _MEMBERS_REALNAME?></td>
-			<td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo  htmlspecialchars($mem->getRealName()); ?>" /></td>
-		</tr><tr>
-		<?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
-			<td><?php echo _MEMBERS_PWD?></td>
-			<td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
-		</tr><tr>
-			<td><?php echo _MEMBERS_REPPWD?></td>
-			<td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
-		<?php } ?>
-		</tr><tr>
-			<td><?php echo _MEMBERS_EMAIL?>
-				<br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
-			</td>
-			<td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo  htmlspecialchars($mem->getEmail()); ?>" /></td>
-		</tr><tr>
-			<td><?php echo _MEMBERS_URL?></td>
-			<td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo  htmlspecialchars($mem->getURL()); ?>" /></td>
-		<?php // only allow to change this by super-admins
-		   // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
-		   if ($member->isAdmin()) {
-		?>
-			</tr><tr>
-				<td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
-				<td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
-			</tr><tr>
-				<td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
-				<td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
-		<?php } ?>
-		</tr><tr>
-			<td><?php echo _MEMBERS_NOTES?></td>
-			<td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo  htmlspecialchars($mem->getNotes()); ?>" /></td>
-		</tr><tr>
-			<td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>
-			</td>
-			<td>
-
-				<select name="deflang" tabindex="85">
-					<option value=""><?php echo _MEMBERS_USESITELANG?></option>
-				<?php				// show a dropdown list of all available languages
-				global $DIR_LANG;
-				$dirhandle = opendir($DIR_LANG);
-				while ($filename = readdir($dirhandle)) {
-					if (ereg("^(.*)\.php$",$filename,$matches)) {
-						$name = $matches[1];
-						echo "<option value='$name'";
-						if ($name == $mem->getLanguage())
-							echo " selected='selected'";
-						echo ">$name</option>";
-					}
-				}
-				closedir($dirhandle);
-
-				?>
-				</select>
-
-			</td>
-		</tr>
-		<tr>
-			<td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
-			<td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
-		</tr>
-		<?php
-			// plugin options
-			$this->_insertPluginOptions('member',$memberid);
-		?>
-		<tr>
-			<th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
-		</tr><tr>
-			<td><?php echo _MEMBERS_EDIT?></td>
-			<td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
-		</tr></table>
-
-		</div></form>
-
-		<?php
-			echo '<h3>',_PLUGINS_EXTRA,'</h3>';
-
-			$manager->notify(
-				'MemberSettingsFormExtras',
-				array(
-					'member' => &$mem
-				)
-			);
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_changemembersettings() {
-		global $member, $CONF, $manager;
-
-		$memberid = intRequestVar('memberid');
-
-		// check if allowed
-		($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-
-		$name			= trim(strip_tags(postVar('name')));
-		$realname		= trim(strip_tags(postVar('realname')));
-		$password		= postVar('password');
-		$repeatpassword	= postVar('repeatpassword');
-		$email			= strip_tags(postVar('email'));
-		$url			= strip_tags(postVar('url'));
-
-		// Sometimes user didn't prefix the URL with http://, this cause a malformed URL. Let's fix it.
-		if (!eregi("^https?://", $url))
-			$url = "http://".$url;
-
-		$admin			= postVar('admin');
-		$canlogin		= postVar('canlogin');
-		$notes			= strip_tags(postVar('notes'));
-		$deflang		= postVar('deflang');
-
-		$mem = MEMBER::createFromID($memberid);
-
-		if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
-
-			if (!isValidDisplayName($name))
-				$this->error(_ERROR_BADNAME);
-
-			if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
-				$this->error(_ERROR_NICKNAMEINUSE);
-
-			if ($password != $repeatpassword)
-				$this->error(_ERROR_PASSWORDMISMATCH);
-
-			if ($password && (strlen($password) < 6))
-				$this->error(_ERROR_PASSWORDTOOSHORT);
-		}
-
-		if (!isValidMailAddress($email))
-			$this->error(_ERROR_BADMAILADDRESS);
-
-
-		if (!$realname)
-			$this->error(_ERROR_REALNAMEMISSING);
-
-		if (($deflang != '') && (!checkLanguage($deflang)))
-			$this->error(_ERROR_NOSUCHLANGUAGE);
-
-		// check if there will remain at least one site member with both the logon and admin rights
-		// (check occurs when taking away one of these rights from such a member)
-		if (    (!$admin && $mem->isAdmin() && $mem->canLogin())
-			 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
-		   )
-		{
-			$r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
-			if (mysql_num_rows($r) < 2)
-				$this->error(_ERROR_ATLEASTONEADMIN);
-		}
-
-		if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
-			$mem->setDisplayName($name);
-			if ($password)
-				$mem->setPassword($password);
-		}
-
-		$oldEmail = $mem->getEmail();
-
-		$mem->setRealName($realname);
-		$mem->setEmail($email);
-		$mem->setURL($url);
-		$mem->setNotes($notes);
-		$mem->setLanguage($deflang);
-
-
-		// only allow super-admins to make changes to the admin status
-		if ($member->isAdmin()) {
-			$mem->setAdmin($admin);
-			$mem->setCanLogin($canlogin);
-		}
-
-		$autosave = postVar ('autosave');
-		$mem->setAutosave($autosave);
-
-		$mem->write();
-
-		// store plugin options
-		$aOptions = requestArray('plugoption');
-		NucleusPlugin::_applyPluginOptions($aOptions);
-		$manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
-
-		// if email changed, generate new password
-		if ($oldEmail != $mem->getEmail())
-		{
-			$mem->sendActivationLink('addresschange', $oldEmail);
-			// logout member
-			$mem->newCookieKey();
-
-			// only log out if the member being edited is the current member.
-			if ($member->getID() == $memberid)
-				$member->logout();
-			$this->action_login(_MSG_ACTIVATION_SENT, 0);
-			return;
-		}
-
-
-		if (  ( $mem->getID() == $member->getID() )
-		   && ( $mem->getDisplayName() != $member->getDisplayName() )
-		   ) {
-			$mem->newCookieKey();
-			$member->logout();
-			$this->action_login(_MSG_LOGINAGAIN, 0);
-		} else {
-			$this->action_overview(_MSG_SETTINGSCHANGED);
-		}
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_memberadd() {
-		global $member, $manager;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		if (postVar('password') != postVar('repeatpassword'))
-			$this->error(_ERROR_PASSWORDMISMATCH);
-		if (strlen(postVar('password')) < 6)
-			$this->error(_ERROR_PASSWORDTOOSHORT);
-
-		$res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
-		if ($res != 1)
-			$this->error($res);
-
-		// fire PostRegister event
-		$newmem = new MEMBER();
-		$newmem->readFromName(postVar('name'));
-		$manager->notify('PostRegister',array('member' => &$newmem));
-
-		$this->action_usermanagement();
-	}
-
-	/**
-	 * Account activation
-	 *
-	 * @author dekarma
-	 */
-	function action_activate() {
-
-		$key = getVar('key');
-		$this->_showActivationPage($key);
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function _showActivationPage($key, $message = '')
-	{
-		global $manager;
-
-		// clean up old activation keys
-		MEMBER::cleanupActivationTable();
-
-		// get activation info
-		$info = MEMBER::getActivationInfo($key);
-
-		if (!$info)
-			$this->error(_ERROR_ACTIVATE);
 
-		$mem = MEMBER::createFromId($info->vmember);
+                <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_itemmoveto() {
+        global $member, $manager;
+
+        $itemid = intRequestVar('itemid');
+        $catid = requestVar('catid');
+
+        // create new category if needed
+        if (strstr($catid,'newcat')) {
+            // get blogid
+            list($blogid) = sscanf($catid,'newcat-%d');
+
+            // create
+            $blog =& $manager->getBlog($blogid);
+            $catid = $blog->createNewCategory();
+
+            // show error when sth goes wrong
+            if (!$catid)
+                $this->doError(_ERROR_CATCREATEFAIL);
+        }
+
+        // only allow if user is allowed to alter item
+        $member->canUpdateItem($itemid, $catid) or $this->disallow();
+
+        $old_blogid = getBlogIDFromItemId($itemid);
+
+        ITEM::move($itemid, $catid);
+
+        // set the futurePosted flag on the blog
+        $this->updateFuturePosted(getBlogIDFromItemId($itemid));
+
+        // reset the futurePosted in case the item is moved from one blog to another
+        $this->updateFuturePosted($old_blogid);
+
+        if ($catid != intRequestVar('catid'))
+            $this->action_categoryedit($catid, $blog->getID());
+        else
+            $this->action_itemlist(getBlogIDFromCatID($catid));
+    }
+
+    /**
+     * Moves one item to a given category (category existance should be checked by caller)
+     * errors are returned
+     * @param int $itemid
+     * @param int $destCatid category ID to which the item will be moved
+     */
+    function moveOneItem($itemid, $destCatid) {
+        global $member;
+
+        // only allow if user is allowed to move item
+        if (!$member->canUpdateItem($itemid, $destCatid))
+            return _ERROR_DISALLOWED;
+
+        ITEM::move($itemid, $destCatid);
+    }
+
+    /**
+     * Adds a item to the chosen blog
+     */
+    function action_additem() {
+        global $manager, $CONF;
+
+        $manager->loadClass('ITEM');
+
+        $result = ITEM::createFromRequest();
+
+        if ($result['status'] == 'error')
+            $this->error($result['message']);
+
+        $blogid = getBlogIDFromItemID($result['itemid']);
+        $blog =& $manager->getBlog($blogid);
+        $btimestamp = $blog->getCorrectTime();
+        $item       = $manager->getItem(intval($result['itemid']), 1, 1);
+
+        if ($result['status'] == 'newcategory') {
+            $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
+            $this->action_categoryedit($result['catid'], $blogid, $distURI);
+        } else {
+            $methodName = 'action_itemList';
+            call_user_func(array(&$this, $methodName), $blogid);
+        }
+    }
+
+    /**
+     * Allows to edit previously made comments
+     */
+    function action_commentedit() {
+        global $member, $manager;
+
+        $commentid = intRequestVar('commentid');
+
+        $member->canAlterComment($commentid) or $this->disallow();
+
+        $comment = COMMENT::getComment($commentid);
+
+        $manager->notify('PrepareCommentForEdit',array('comment' => &$comment));
+
+        // change <br /> to \n
+        $comment['body'] = str_replace('<br />','',$comment['body']);
+
+        $comment['body'] = eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>","\\1",$comment['body']);
+
+        $this->pagehead();
+
+        ?>
+        <h2><?php echo _EDITC_TITLE?></h2>
+
+        <form action="index.php" method="post"><div>
+
+        <input type="hidden" name="action" value="commentupdate" />
+        <?php $manager->addTicketHidden(); ?>
+        <input type="hidden" name="commentid" value="<?php echo  $commentid; ?>" />
+        <table><tr>
+            <th colspan="2"><?php echo _EDITC_TITLE?></th>
+        </tr><tr>
+            <td><?php echo _EDITC_WHO?></td>
+            <td>
+            <?php               if ($comment['member'])
+                    echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
+                else
+                    echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
+            ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _EDITC_WHEN?></td>
+            <td><?php echo  date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
+        </tr><tr>
+            <td><?php echo _EDITC_HOST?></td>
+            <td><?php echo  $comment['host']; ?></td>
+        </tr>
+        <tr>
+            <td><?php echo _EDITC_URL; ?></td>
+            <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
+        </tr>
+        <tr>
+            <td><?php echo _EDITC_EMAIL; ?></td>
+            <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
+        </tr>
+        <tr>
+            <td><?php echo _EDITC_TEXT?></td>
+            <td>
+                <textarea name="body" tabindex="10" rows="10" cols="50"><?php                   // htmlspecialchars not needed (things should be escaped already)
+                    echo $comment['body'];
+                ?></textarea>
+            </td>
+        </tr><tr>
+            <td><?php echo _EDITC_EDIT?></td>
+            <td><input type="submit"  tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
+        </tr></table>
+
+        </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_commentupdate() {
+        global $member, $manager;
+
+        $commentid = intRequestVar('commentid');
+
+        $member->canAlterComment($commentid) or $this->disallow();
+
+        $url = postVar('url');
+        $email = postVar('email');
+        $body = postVar('body');
+
+        // intercept words that are too long
+        if (eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}",$body) != false)
+            $this->error(_ERROR_COMMENT_LONGWORD);
+
+        // check length
+        if (strlen($body)<3)
+            $this->error(_ERROR_COMMENT_NOCOMMENT);
+        if (strlen($body)>5000)
+            $this->error(_ERROR_COMMENT_TOOLONG);
+
+
+        // prepare body
+        $body = COMMENT::prepareBody($body);
+
+        // call plugins
+        $manager->notify('PreUpdateComment',array('body' => &$body));
+
+        $query = 'UPDATE ' . sql_table('comment')
+               . " SET cmail = '" . addslashes($url) . "', cemail = '" . addslashes($email) . "', cbody = '" . addslashes($body) . "'"
+               . " WHERE cnumber = " . $commentid;
+        sql_query($query);
+
+        // get itemid
+        $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
+        $o = sql_fetch_object($res);
+        $itemid = $o->citem;
+
+        if ($member->canAlterItem($itemid))
+            $this->action_itemcommentlist($itemid);
+        else
+            $this->action_browseowncomments();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_commentdelete() {
+        global $member, $manager;
+
+        $commentid = intRequestVar('commentid');
+
+        $member->canAlterComment($commentid) or $this->disallow();
+
+        $comment = COMMENT::getComment($commentid);
+
+        $body = strip_tags($comment['body']);
+        $body = htmlspecialchars(shorten($body, 300, '...'));
+
+        if ($comment['member'])
+            $author = $comment['member'];
+        else
+            $author = $comment['user'];
+
+        $this->pagehead();
+        ?>
+
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+
+            <p><?php echo _CONFIRMTXT_COMMENT?></p>
+
+            <div class="note">
+            <b><?php echo _EDITC_WHO?>:</b> <?php echo  $author ?>
+            <br />
+            <b><?php echo _EDITC_TEXT?>:</b> <?php echo  $body ?>
+            </div>
+
+            <form method="post" action="index.php"><div>
+                <input type="hidden" name="action" value="commentdeleteconfirm" />
+                <?php $manager->addTicketHidden() ?>
+                <input type="hidden" name="commentid" value="<?php echo  $commentid; ?>" />
+                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_commentdeleteconfirm() {
+        global $member;
+
+        $commentid = intRequestVar('commentid');
+
+        // get item id first
+        $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
+        $o = sql_fetch_object($res);
+        $itemid = $o->citem;
+
+        $error = $this->deleteOneComment($commentid);
+        if ($error)
+            $this->doError($error);
+
+        if ($member->canAlterItem($itemid))
+            $this->action_itemcommentlist($itemid);
+        else
+            $this->action_browseowncomments();
+    }
+
+    /**
+     * @todo document this
+     */
+    function deleteOneComment($commentid) {
+        global $member, $manager;
+
+        $commentid = intval($commentid);
+
+        if (!$member->canAlterComment($commentid))
+            return _ERROR_DISALLOWED;
+
+        $manager->notify('PreDeleteComment', array('commentid' => $commentid));
+
+        // delete the comments associated with the item
+        $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
+        sql_query($query);
+
+        $manager->notify('PostDeleteComment', array('commentid' => $commentid));
+
+        return '';
+    }
+
+    /**
+     * Usermanagement main
+     */
+    function action_usermanagement() {
+        global $member, $manager;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+
+        echo '<h2>' . _MEMBERS_TITLE .'</h2>';
+
+        echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
+
+        // show list of members with actions
+        $query =  'SELECT *'
+               . ' FROM '.sql_table('member');
+        $template['content'] = 'memberlist';
+        $template['tabindex'] = 10;
+
+        $manager->loadClass("ENCAPSULATE");
+        $batch =& new BATCH('member');
+        $batch->showlist($query,'table',$template);
+
+        echo '<h3>' . _MEMBERS_NEW .'</h3>';
+        ?>
+            <form method="post" action="index.php" name="memberedit"><div>
+
+            <input type="hidden" name="action" value="memberadd" />
+            <?php $manager->addTicketHidden() ?>
+
+            <table>
+            <tr>
+                <th colspan="2"><?php echo _MEMBERS_NEW?></th>
+            </tr><tr>
+                <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
+                <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
+                </td>
+                <td><input tabindex="10010" name="name" size="32" maxlength="32" /></td>
+            </tr><tr>
+                <td><?php echo _MEMBERS_REALNAME?></td>
+                <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
+            </tr><tr>
+                <td><?php echo _MEMBERS_PWD?></td>
+                <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
+            </tr><tr>
+                <td><?php echo _MEMBERS_REPPWD?></td>
+                <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
+            </tr><tr>
+                <td><?php echo _MEMBERS_EMAIL?></td>
+                <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
+            </tr><tr>
+                <td><?php echo _MEMBERS_URL?></td>
+                <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
+            </tr><tr>
+                <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
+                <td><?php $this->input_yesno('admin',0,10060); ?> </td>
+            </tr><tr>
+                <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
+                <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
+            </tr><tr>
+                <td><?php echo _MEMBERS_NOTES?></td>
+                <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
+            </tr><tr>
+                <td><?php echo _MEMBERS_NEW?></td>
+                <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
+            </tr></table>
+
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * Edit member settings
+     */
+    function action_memberedit() {
+        $this->action_editmembersettings(intRequestVar('memberid'));
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_editmembersettings($memberid = '') {
+        global $member, $manager, $CONF;
+
+        if ($memberid == '')
+            $memberid = $member->getID();
+
+        // check if allowed
+        ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
+
+        $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
+        $this->pagehead($extrahead);
+
+        // show message to go back to member overview (only for admins)
+        if ($member->isAdmin())
+            echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
+        else
+            echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
+
+        echo '<h2>' . _MEMBERS_EDIT . '</h2>';
+
+        $mem = MEMBER::createFromID($memberid);
+
+        ?>
+        <form method="post" action="index.php" name="memberedit"><div>
+
+        <input type="hidden" name="action" value="changemembersettings" />
+        <input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />
+        <?php $manager->addTicketHidden() ?>
+
+        <table><tr>
+            <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
+        </tr><tr>
+            <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
+                <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
+            </td>
+            <td>
+            <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
+                <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo  htmlspecialchars($mem->getDisplayName()); ?>" />
+            <?php } else {
+                echo htmlspecialchars($member->getDisplayName());
+               }
+            ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _MEMBERS_REALNAME?></td>
+            <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo  htmlspecialchars($mem->getRealName()); ?>" /></td>
+        </tr><tr>
+        <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
+            <td><?php echo _MEMBERS_PWD?></td>
+            <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
+        </tr><tr>
+            <td><?php echo _MEMBERS_REPPWD?></td>
+            <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
+        <?php } ?>
+        </tr><tr>
+            <td><?php echo _MEMBERS_EMAIL?>
+                <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
+            </td>
+            <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo  htmlspecialchars($mem->getEmail()); ?>" /></td>
+        </tr><tr>
+            <td><?php echo _MEMBERS_URL?></td>
+            <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo  htmlspecialchars($mem->getURL()); ?>" /></td>
+        <?php // only allow to change this by super-admins
+           // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
+           if ($member->isAdmin()) {
+        ?>
+            </tr><tr>
+                <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
+                <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
+            </tr><tr>
+                <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
+                <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
+        <?php } ?>
+        </tr><tr>
+            <td><?php echo _MEMBERS_NOTES?></td>
+            <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo  htmlspecialchars($mem->getNotes()); ?>" /></td>
+        </tr><tr>
+            <td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>
+            </td>
+            <td>
+
+                <select name="deflang" tabindex="85">
+                    <option value=""><?php echo _MEMBERS_USESITELANG?></option>
+                <?php               // show a dropdown list of all available languages
+                global $DIR_LANG;
+                $dirhandle = opendir($DIR_LANG);
+                while ($filename = readdir($dirhandle)) {
+                    if (ereg("^(.*)\.php$",$filename,$matches)) {
+                        $name = $matches[1];
+                        echo "<option value='$name'";
+                        if ($name == $mem->getLanguage())
+                            echo " selected='selected'";
+                        echo ">$name</option>";
+                    }
+                }
+                closedir($dirhandle);
 
-		if (!$mem)
-			$this->error(_ERROR_ACTIVATE);
-
-		$text = '';
-		$title = '';
-		$bNeedsPasswordChange = true;
-
-		switch ($info->vtype)
-		{
-			case 'forgot':
-				$title = _ACTIVATE_FORGOT_TITLE;
-				$text = _ACTIVATE_FORGOT_TEXT;
-				break;
-			case 'register':
-				$title = _ACTIVATE_REGISTER_TITLE;
-				$text = _ACTIVATE_REGISTER_TEXT;
-				break;
-			case 'addresschange':
-				$title = _ACTIVATE_CHANGE_TITLE;
-				$text = _ACTIVATE_CHANGE_TEXT;
-				$bNeedsPasswordChange = false;
-				MEMBER::activate($key);
-				break;
-		}
+                ?>
+                </select>
 
-		$aVars = array(
-			'memberName' => htmlspecialchars($mem->getDisplayName())
-		);
-		$title = TEMPLATE::fill($title, $aVars);
-		$text = TEMPLATE::fill($text, $aVars);
+            </td>
+        </tr>
+        <tr>
+            <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
+            <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
+        </tr>
+        <?php
+            // plugin options
+            $this->_insertPluginOptions('member',$memberid);
+        ?>
+        <tr>
+            <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
+        </tr><tr>
+            <td><?php echo _MEMBERS_EDIT?></td>
+            <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
+        </tr></table>
+
+        </div></form>
+
+        <?php
+            echo '<h3>',_PLUGINS_EXTRA,'</h3>';
+
+            $manager->notify(
+                'MemberSettingsFormExtras',
+                array(
+                    'member' => &$mem
+                )
+            );
+
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_changemembersettings() {
+        global $member, $CONF, $manager;
+
+        $memberid = intRequestVar('memberid');
+
+        // check if allowed
+        ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
+
+        $name           = trim(strip_tags(postVar('name')));
+        $realname       = trim(strip_tags(postVar('realname')));
+        $password       = postVar('password');
+        $repeatpassword = postVar('repeatpassword');
+        $email          = strip_tags(postVar('email'));
+        $url            = strip_tags(postVar('url'));
+
+        // Sometimes user didn't prefix the URL with http://, this cause a malformed URL. Let's fix it.
+        if (!eregi("^https?://", $url))
+            $url = "http://".$url;
+
+        $admin          = postVar('admin');
+        $canlogin       = postVar('canlogin');
+        $notes          = strip_tags(postVar('notes'));
+        $deflang        = postVar('deflang');
+
+        $mem = MEMBER::createFromID($memberid);
+
+        if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
+
+            if (!isValidDisplayName($name))
+                $this->error(_ERROR_BADNAME);
+
+            if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
+                $this->error(_ERROR_NICKNAMEINUSE);
+
+            if ($password != $repeatpassword)
+                $this->error(_ERROR_PASSWORDMISMATCH);
+
+            if ($password && (strlen($password) < 6))
+                $this->error(_ERROR_PASSWORDTOOSHORT);
+                
+            $pwdvalid = true;
+            $pwderror = '';
+            $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
+            if (!$pwdvalid) {
+                $this->error($pwderror);
+            }
+        }
+
+        if (!isValidMailAddress($email))
+            $this->error(_ERROR_BADMAILADDRESS);
+
+
+        if (!$realname)
+            $this->error(_ERROR_REALNAMEMISSING);
+
+        if (($deflang != '') && (!checkLanguage($deflang)))
+            $this->error(_ERROR_NOSUCHLANGUAGE);
+
+        // check if there will remain at least one site member with both the logon and admin rights
+        // (check occurs when taking away one of these rights from such a member)
+        if (    (!$admin && $mem->isAdmin() && $mem->canLogin())
+             || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
+           )
+        {
+            $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
+            if (sql_num_rows($r) < 2)
+                $this->error(_ERROR_ATLEASTONEADMIN);
+        }
+
+        if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
+            $mem->setDisplayName($name);
+            if ($password)
+                $mem->setPassword($password);
+        }
+
+        $oldEmail = $mem->getEmail();
+
+        $mem->setRealName($realname);
+        $mem->setEmail($email);
+        $mem->setURL($url);
+        $mem->setNotes($notes);
+        $mem->setLanguage($deflang);
+
+
+        // only allow super-admins to make changes to the admin status
+        if ($member->isAdmin()) {
+            $mem->setAdmin($admin);
+            $mem->setCanLogin($canlogin);
+        }
+
+        $autosave = postVar ('autosave');
+        $mem->setAutosave($autosave);
+
+        $mem->write();
+
+        // store plugin options
+        $aOptions = requestArray('plugoption');
+        NucleusPlugin::_applyPluginOptions($aOptions);
+        $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
+
+        // if email changed, generate new password
+        if ($oldEmail != $mem->getEmail())
+        {
+            $mem->sendActivationLink('addresschange', $oldEmail);
+            // logout member
+            $mem->newCookieKey();
+
+            // only log out if the member being edited is the current member.
+            if ($member->getID() == $memberid)
+                $member->logout();
+            $this->action_login(_MSG_ACTIVATION_SENT, 0);
+            return;
+        }
+
+
+        if (  ( $mem->getID() == $member->getID() )
+           && ( $mem->getDisplayName() != $member->getDisplayName() )
+           ) {
+            $mem->newCookieKey();
+            $member->logout();
+            $this->action_login(_MSG_LOGINAGAIN, 0);
+        } else {
+            $this->action_overview(_MSG_SETTINGSCHANGED);
+        }
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_memberadd() {
+        global $member, $manager;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        if (postVar('password') != postVar('repeatpassword'))
+            $this->error(_ERROR_PASSWORDMISMATCH);
+        if (strlen(postVar('password')) < 6)
+            $this->error(_ERROR_PASSWORDTOOSHORT);
+
+        $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
+        if ($res != 1)
+            $this->error($res);
+
+        // fire PostRegister event
+        $newmem = new MEMBER();
+        $newmem->readFromName(postVar('name'));
+        $manager->notify('PostRegister',array('member' => &$newmem));
+
+        $this->action_usermanagement();
+    }
+
+    /**
+     * Account activation
+     *
+     * @author dekarma
+     */
+    function action_activate() {
+
+        $key = getVar('key');
+        $this->_showActivationPage($key);
+    }
+
+    /**
+     * @todo document this
+     */
+    function _showActivationPage($key, $message = '')
+    {
+        global $manager;
+
+        // clean up old activation keys
+        MEMBER::cleanupActivationTable();
+
+        // get activation info
+        $info = MEMBER::getActivationInfo($key);
+
+        if (!$info)
+            $this->error(_ERROR_ACTIVATE);
+
+        $mem = MEMBER::createFromId($info->vmember);
+
+        if (!$mem)
+            $this->error(_ERROR_ACTIVATE);
+
+        $text = '';
+        $title = '';
+        $bNeedsPasswordChange = true;
+
+        switch ($info->vtype)
+        {
+            case 'forgot':
+                $title = _ACTIVATE_FORGOT_TITLE;
+                $text = _ACTIVATE_FORGOT_TEXT;
+                break;
+            case 'register':
+                $title = _ACTIVATE_REGISTER_TITLE;
+                $text = _ACTIVATE_REGISTER_TEXT;
+                break;
+            case 'addresschange':
+                $title = _ACTIVATE_CHANGE_TITLE;
+                $text = _ACTIVATE_CHANGE_TEXT;
+                $bNeedsPasswordChange = false;
+                MEMBER::activate($key);
+                break;
+        }
+
+        $aVars = array(
+            'memberName' => htmlspecialchars($mem->getDisplayName())
+        );
+        $title = TEMPLATE::fill($title, $aVars);
+        $text = TEMPLATE::fill($text, $aVars);
+
+        $this->pagehead();
+
+            echo '<h2>' , $title, '</h2>';
+            echo '<p>' , $text, '</p>';
+
+            if ($message != '')
+            {
+                echo '<p class="error">',$message,'</p>';
+            }
 
-		$this->pagehead();
+            if ($bNeedsPasswordChange)
+            {
+                ?>
+                    <div><form action="index.php" method="post">
 
-			echo '<h2>' , $title, '</h2>';
-			echo '<p>' , $text, '</p>';
+                        <input type="hidden" name="action" value="activatesetpwd" />
+                        <?php $manager->addTicketHidden() ?>
+                        <input type="hidden" name="key" value="<?php echo htmlspecialchars($key) ?>" />
+
+                        <table><tr>
+                            <td><?php echo _MEMBERS_PWD?></td>
+                            <td><input type="password" maxlength="40" size="16" name="password" /></td>
+                        </tr><tr>
+                            <td><?php echo _MEMBERS_REPPWD?></td>
+                            <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
+                        <?php
+
+                            global $manager;
+                            $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
+
+                        ?>
+                        </tr><tr>
+                            <td><?php echo _MEMBERS_SETPWD ?></td>
+                            <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
+                        </tr></table>
 
-			if ($message != '')
-			{
-				echo '<p class="error">',$message,'</p>';
-			}
 
-			if ($bNeedsPasswordChange)
-			{
-				?>
-					<div><form action="index.php" method="post">
+                    </form></div>
 
-						<input type="hidden" name="action" value="activatesetpwd" />
-						<?php $manager->addTicketHidden() ?>
-						<input type="hidden" name="key" value="<?php echo htmlspecialchars($key) ?>" />
+                <?php
 
-						<table><tr>
-							<td><?php echo _MEMBERS_PWD?></td>
-							<td><input type="password" maxlength="40" size="16" name="password" /></td>
-						</tr><tr>
-							<td><?php echo _MEMBERS_REPPWD?></td>
-							<td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
-						<?php
+            }
 
-							global $manager;
-							$manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
+        $this->pagefoot();
 
-						?>
-						</tr><tr>
-							<td><?php echo _MEMBERS_SETPWD ?></td>
-							<td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
-						</tr></table>
+    }
 
+    /**
+     * Account activation - set password part
+     *
+     * @author dekarma
+     */
+    function action_activatesetpwd() {
 
-					</form></div>
+        $key = postVar('key');
 
-				<?php
+        // clean up old activation keys
+        MEMBER::cleanupActivationTable();
 
-			}
+        // get activation info
+        $info = MEMBER::getActivationInfo($key);
 
-		$this->pagefoot();
+        if (!$info || ($info->type == 'addresschange'))
+            return $this->_showActivationPage($key, _ERROR_ACTIVATE);
 
-	}
+        $mem = MEMBER::createFromId($info->vmember);
 
-	/**
-	 * Account activation - set password part
-	 *
-	 * @author dekarma
-	 */
-	function action_activatesetpwd() {
+        if (!$mem)
+            return $this->_showActivationPage($key, _ERROR_ACTIVATE);
 
-		$key = postVar('key');
+        $password       = postVar('password');
+        $repeatpassword = postVar('repeatpassword');
 
-		// clean up old activation keys
-		MEMBER::cleanupActivationTable();
+        if ($password != $repeatpassword)
+            return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
 
-		// get activation info
-		$info = MEMBER::getActivationInfo($key);
+        if ($password && (strlen($password) < 6))
+            return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
+            
+        $pwdvalid = true;
+        $pwderror = '';
+		global $manager;
+        $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
+        if (!$pwdvalid) {
+            return $this->_showActivationPage($key,$pwderror);
+        }
+
+        $error = '';
+        
+        $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
+        if ($error != '')
+            return $this->_showActivationPage($key, $error);
+
+
+        // set password
+        $mem->setPassword($password);
+        $mem->write();
+
+        // do the activation
+        MEMBER::activate($key);
+
+        $this->pagehead();
+            echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
+            echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
+        $this->pagefoot();
+    }
+
+    /**
+     * Manage team
+     */
+    function action_manageteam() {
+        global $member, $manager;
+
+        $blogid = intRequestVar('blogid');
+
+        // check if allowed
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $this->pagehead();
+
+        echo "<p><a href='index.php?action=blogsettings&amp;blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
+
+        echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
+
+        echo '<h3>' . _TEAM_CURRENT . '</h3>';
+
+
+
+        $query =  'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
+               . ' FROM '.sql_table('member').', '.sql_table('team')
+               . ' WHERE tmember=mnumber and tblog=' . $blogid;
+
+        $template['content'] = 'teamlist';
+        $template['tabindex'] = 10;
+
+        $manager->loadClass("ENCAPSULATE");
+        $batch =& new BATCH('team');
+        $batch->showlist($query, 'table', $template);
+
+        ?>
+            <h3><?php echo _TEAM_ADDNEW?></h3>
+
+            <form method='post' action='index.php'><div>
+
+            <input type='hidden' name='action' value='teamaddmember' />
+            <input type='hidden' name='blogid' value='<?php echo  $blogid; ?>' />
+            <?php $manager->addTicketHidden() ?>
+
+            <table><tr>
+                <td><?php echo _TEAM_CHOOSEMEMBER?></td>
+                <td><?php                   // TODO: try to make it so only non-team-members are listed
+                    $query =  'SELECT mname as text, mnumber as value'
+                           . ' FROM '.sql_table('member');
+
+                    $template['name'] = 'memberid';
+                    $template['tabindex'] = 10000;
+                    showlist($query,'select',$template);
+                ?></td>
+            </tr><tr>
+                <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
+                <td><?php $this->input_yesno('admin',0,10020); ?></td>
+            </tr><tr>
+                <td><?php echo _TEAM_ADD?></td>
+                <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
+            </tr></table>
+
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * Add member to team
+     */
+    function action_teamaddmember() {
+        global $member, $manager;
+
+        $memberid = intPostVar('memberid');
+        $blogid = intPostVar('blogid');
+        $admin = intPostVar('admin');
+
+        // check if allowed
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $blog =& $manager->getBlog($blogid);
+        if (!$blog->addTeamMember($memberid, $admin))
+            $this->error(_ERROR_ALREADYONTEAM);
+
+        $this->action_manageteam();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_teamdelete() {
+        global $member, $manager;
+
+        $memberid = intRequestVar('memberid');
+        $blogid = intRequestVar('blogid');
+
+        // check if allowed
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $teammem = MEMBER::createFromID($memberid);
+        $blog =& $manager->getBlog($blogid);
+
+        $this->pagehead();
+        ?>
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+
+            <p><?php echo _CONFIRMTXT_TEAM1?><b><?php echo  htmlspecialchars($teammem->getDisplayName()) ?></b><?php echo _CONFIRMTXT_TEAM2?><b><?php echo  htmlspecialchars(strip_tags($blog->getName())) ?></b>
+            </p>
+
+
+            <form method="post" action="index.php"><div>
+            <input type="hidden" name="action" value="teamdeleteconfirm" />
+            <?php $manager->addTicketHidden() ?>
+            <input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />
+            <input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />
+            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_teamdeleteconfirm() {
+        global $member;
+
+        $memberid = intRequestVar('memberid');
+        $blogid = intRequestVar('blogid');
+
+        $error = $this->deleteOneTeamMember($blogid, $memberid);
+        if ($error)
+            $this->error($error);
+
+
+        $this->action_manageteam();
+    }
+
+    /**
+     * @todo document this
+     */
+    function deleteOneTeamMember($blogid, $memberid) {
+        global $member, $manager;
+
+        $blogid = intval($blogid);
+        $memberid = intval($memberid);
+
+        // check if allowed
+        if (!$member->blogAdminRights($blogid))
+            return _ERROR_DISALLOWED;
+
+        // check if: - there remains at least one blog admin
+        //           - (there remains at least one team member)
+        $tmem = MEMBER::createFromID($memberid);
+
+        $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
+
+        if ($tmem->isBlogAdmin($blogid)) {
+            // check if there are more blog members left and at least one admin
+            // (check for at least two admins before deletion)
+            $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
+            $r = sql_query($query);
+            if (sql_num_rows($r) < 2)
+                return _ERROR_ATLEASTONEBLOGADMIN;
+        }
+
+        $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
+        sql_query($query);
+
+        $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
+
+        return '';
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_teamchangeadmin() {
+        global $member;
+
+        $blogid = intRequestVar('blogid');
+        $memberid = intRequestVar('memberid');
+
+        // check if allowed
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $mem = MEMBER::createFromID($memberid);
+
+        // don't allow when there is only one admin at this moment
+        if ($mem->isBlogAdmin($blogid)) {
+            $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
+            if (sql_num_rows($r) == 1)
+                $this->error(_ERROR_ATLEASTONEBLOGADMIN);
+        }
+
+        if ($mem->isBlogAdmin($blogid))
+            $newval = 0;
+        else
+            $newval = 1;
+
+        $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
+        sql_query($query);
+
+        // only show manageteam if member did not change its own admin privileges
+        if ($member->isBlogAdmin($blogid))
+            $this->action_manageteam();
+        else
+            $this->action_overview(_MSG_ADMINCHANGED);
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_blogsettings() {
+        global $member, $manager;
+
+        $blogid = intRequestVar('blogid');
+
+        // check if allowed
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $blog =& $manager->getBlog($blogid);
+
+        $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
+        $this->pagehead($extrahead);
+
+        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
+        ?>
+        <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
+
+        <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
+
+        <p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>
+        <?php
+            $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
+            $aMemberNames = array();
+            while ($o = sql_fetch_object($res))
+                array_push($aMemberNames, htmlspecialchars($o->mname) . ' (' . htmlspecialchars($o->mrealname). ')');
+            echo implode(',', $aMemberNames);
+        ?>
+        </p>
+
+
+
+        <p>
+        <a href="index.php?action=manageteam&amp;blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
+        </p>
+
+        <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
+
+        <form method="post" action="index.php"><div>
+
+        <input type="hidden" name="action" value="blogsettingsupdate" />
+        <?php $manager->addTicketHidden() ?>
+        <input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />
+        <table><tr>
+            <td><?php echo _EBLOG_NAME?></td>
+            <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo  htmlspecialchars($blog->getName()) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
+                <?php echo _EBLOG_SHORTNAME_EXTRA?>
+            </td>
+            <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo  htmlspecialchars($blog->getShortName()) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_DESC?></td>
+            <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo  htmlspecialchars($blog->getDescription()) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_URL?></td>
+            <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo  htmlspecialchars($blog->getURL()) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_DEFSKIN?>
+                <?php help('blogdefaultskin'); ?>
+            </td>
+            <td>
+                <?php
+                    $query =  'SELECT sdname as text, sdnumber as value'
+                           . ' FROM '.sql_table('skin_desc');
+                    $template['name'] = 'defskin';
+                    $template['selected'] = $blog->getDefaultSkin();
+                    $template['tabindex'] = 50;
+                    showlist($query,'select',$template);
+                ?>
 
-		if (!$info || ($info->type == 'addresschange'))
-			return $this->_showActivationPage($key, _ERROR_ACTIVATE);
+            </td>
+        </tr><tr>
+            <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
+            </td>
+            <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
+            </td>
+            <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_DISABLECOMMENTS?>
+            </td>
+            <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_ANONYMOUS?>
+            </td>
+            <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
+        </tr><tr>
+    <td><?php echo _EBLOG_REQUIREDEMAIL?>
+         </td>
+         <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
+      </tr><tr>
+            <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
+            <td><input name="notify" tabindex="80" maxlength="60" size="40" value="<?php echo  htmlspecialchars($blog->getNotifyAddress()); ?>" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_NOTIFY_ON?></td>
+            <td>
+                <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
+                    <?php if  ($blog->notifyOnComment()) echo "checked='checked'" ?>
+                /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
+                <br />
+                <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
+                    <?php if  ($blog->notifyOnVote()) echo "checked='checked'" ?>
+                /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
+                <br />
+                <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
+                    <?php if  ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
+                /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
+            </td>
+        </tr><tr>
+            <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
+            <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo  htmlspecialchars($blog->getMaxComments()); ?>" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
+            <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo  htmlspecialchars($blog->getUpdateFile()) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_DEFCAT?></td>
+            <td>
+                <?php
+                    $query =  'SELECT cname as text, catid as value'
+                           . ' FROM '.sql_table('category')
+                           . ' WHERE cblog=' . $blog->getID();
+                    $template['name'] = 'defcat';
+                    $template['selected'] = $blog->getDefaultCategory();
+                    $template['tabindex'] = 110;
+                    showlist($query,'select',$template);
+                ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
+                <br /><?php echo _EBLOG_STIME?> <b><?php echo  strftime("%H:%M",time()); ?></b>
+                <br /><?php echo _EBLOG_BTIME?> <b><?php echo  strftime("%H:%M",$blog->getCorrectTime()); ?></b>
+                </td>
+            <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo  htmlspecialchars($blog->getTimeOffset()); ?>" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
+            <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
+        </tr>
+        <?php
+            // plugin options
+            $this->_insertPluginOptions('blog',$blogid);
+        ?>
+        <tr>
+            <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
+        </tr><tr>
+            <td><?php echo _EBLOG_CHANGE?></td>
+            <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
+        </tr></table>
+
+        </div></form>
+
+        <h3><?php echo _EBLOG_CAT_TITLE?></h3>
+
+
+        <?php
+        $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
+        $template['content'] = 'categorylist';
+        $template['tabindex'] = 200;
+
+        $manager->loadClass("ENCAPSULATE");
+        $batch =& new BATCH('category');
+        $batch->showlist($query,'table',$template);
+
+        ?>
+
+
+        <form action="index.php" method="post"><div>
+        <input name="action" value="categorynew" type="hidden" />
+        <?php $manager->addTicketHidden() ?>
+        <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
+
+        <table><tr>
+            <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
+        </tr><tr>
+            <td><?php echo _EBLOG_CAT_NAME?></td>
+            <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_CAT_DESC?></td>
+            <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_CAT_CREATE?></td>
+            <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
+        </tr></table>
+
+        </div></form>
+
+        <?php
+
+            echo '<h3>',_PLUGINS_EXTRA,'</h3>';
+
+            $manager->notify(
+                'BlogSettingsFormExtras',
+                array(
+                    'blog' => &$blog
+                )
+            );
+
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_categorynew() {
+        global $member, $manager;
+
+        $blogid = intRequestVar('blogid');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $cname = postVar('cname');
+        $cdesc = postVar('cdesc');
+
+        if (!isValidCategoryName($cname))
+            $this->error(_ERROR_BADCATEGORYNAME);
+
+        $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . addslashes($cname).'\' and cblog=' . intval($blogid);
+        $res = sql_query($query);
+        if (sql_num_rows($res) > 0)
+            $this->error(_ERROR_DUPCATEGORYNAME);
+
+        $blog       =& $manager->getBlog($blogid);
+        $newCatID   =  $blog->createNewCategory($cname, $cdesc);
+
+        $this->action_blogsettings();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
+        global $member, $manager;
+
+        if ($blogid == '')
+            $blogid = intGetVar('blogid');
+        else
+            $blogid = intval($blogid);
+        if ($catid == '')
+            $catid = intGetVar('catid');
+        else
+            $catid = intval($catid);
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
+        $obj = sql_fetch_object($res);
+
+        $cname = $obj->cname;
+        $cdesc = $obj->cdesc;
+
+        $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
+        $this->pagehead($extrahead);
+
+        echo "<p><a href='index.php?action=blogsettings&amp;blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
+
+        ?>
+        <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo htmlspecialchars($cname)?>'</h2>
+        <form method='post' action='index.php'><div>
+        <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
+        <input name="catid" type="hidden" value="<?php echo $catid?>" />
+        <input name="desturl" type="hidden" value="<?php echo htmlspecialchars($desturl) ?>" />
+        <input name="action" type="hidden" value="categoryupdate" />
+        <?php $manager->addTicketHidden(); ?>
+
+        <table><tr>
+            <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
+        </tr><tr>
+            <td><?php echo _EBLOG_CAT_NAME?></td>
+            <td><input type="text" name="cname" value="<?php echo htmlspecialchars($cname)?>" size="40" maxlength="40" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_CAT_DESC?></td>
+            <td><input type="text" name="cdesc" value="<?php echo htmlspecialchars($cdesc)?>" size="40" maxlength="200" /></td>
+        </tr>
+        <?php
+            // insert plugin options
+            $this->_insertPluginOptions('category',$catid);
+        ?>
+        <tr>
+            <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
+        </tr><tr>
+            <td><?php echo _EBLOG_CAT_UPDATE?></td>
+            <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
+        </tr></table>
+
+        </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_categoryupdate() {
+        global $member, $manager;
+
+        $blogid = intPostVar('blogid');
+        $catid = intPostVar('catid');
+        $cname = postVar('cname');
+        $cdesc = postVar('cdesc');
+        $desturl = postVar('desturl');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        if (!isValidCategoryName($cname))
+            $this->error(_ERROR_BADCATEGORYNAME);
+
+        $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . addslashes($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
+        $res = sql_query($query);
+        if (sql_num_rows($res) > 0)
+            $this->error(_ERROR_DUPCATEGORYNAME);
+
+        $query =  'UPDATE '.sql_table('category').' SET'
+               . " cname='" . addslashes($cname) . "',"
+               . " cdesc='" . addslashes($cdesc) . "'"
+               . " WHERE catid=" . $catid;
+
+        sql_query($query);
+
+        // store plugin options
+        $aOptions = requestArray('plugoption');
+        NucleusPlugin::_applyPluginOptions($aOptions);
+        $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
+
+
+        if ($desturl) {
+            redirect($desturl);
+            exit;
+        } else {
+            $this->action_blogsettings();
+        }
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_categorydelete() {
+        global $member, $manager;
+
+        $blogid = intRequestVar('blogid');
+        $catid = intRequestVar('catid');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $blog =& $manager->getBlog($blogid);
+
+        // check if the category is valid
+        if (!$blog->isValidCategory($catid))
+            $this->error(_ERROR_NOSUCHCATEGORY);
+
+        // don't allow deletion of default category
+        if ($blog->getDefaultCategory() == $catid)
+            $this->error(_ERROR_DELETEDEFCATEGORY);
+
+        // check if catid is the only category left for blogid
+        $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
+        $res = sql_query($query);
+        if (sql_num_rows($res) == 1)
+            $this->error(_ERROR_DELETELASTCATEGORY);
+
+
+        $this->pagehead();
+        ?>
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+
+            <div>
+            <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo  htmlspecialchars($blog->getCategoryName($catid))?></b>
+            </div>
+
+            <form method="post" action="index.php"><div>
+            <input type="hidden" name="action" value="categorydeleteconfirm" />
+            <?php $manager->addTicketHidden() ?>
+            <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
+            <input type="hidden" name="catid" value="<?php echo $catid?>" />
+            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_categorydeleteconfirm() {
+        global $member, $manager;
+
+        $blogid = intRequestVar('blogid');
+        $catid = intRequestVar('catid');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $error = $this->deleteOneCategory($catid);
+        if ($error)
+            $this->error($error);
+
+        $this->action_blogsettings();
+    }
+
+    /**
+     * @todo document this
+     */
+    function deleteOneCategory($catid) {
+        global $manager, $member;
+
+        $catid = intval($catid);
+
+        $blogid = getBlogIDFromCatID($catid);
+
+        if (!$member->blogAdminRights($blogid))
+            return ERROR_DISALLOWED;
+
+        // get blog
+        $blog =& $manager->getBlog($blogid);
+
+        // check if the category is valid
+        if (!$blog || !$blog->isValidCategory($catid))
+            return _ERROR_NOSUCHCATEGORY;
+
+        $destcatid = $blog->getDefaultCategory();
+
+        // don't allow deletion of default category
+        if ($blog->getDefaultCategory() == $catid)
+            return _ERROR_DELETEDEFCATEGORY;
+
+        // check if catid is the only category left for blogid
+        $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
+        $res = sql_query($query);
+        if (sql_num_rows($res) == 1)
+            return _ERROR_DELETELASTCATEGORY;
+
+        $manager->notify('PreDeleteCategory', array('catid' => $catid));
+
+        // change category for all items to the default category
+        $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
+        sql_query($query);
+
+        // delete all associated plugin options
+        NucleusPlugin::_deleteOptionValues('category', $catid);
+
+        // delete category
+        $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
+        sql_query($query);
+
+        $manager->notify('PostDeleteCategory', array('catid' => $catid));
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function moveOneCategory($catid, $destblogid) {
+        global $manager, $member;
+
+        $catid = intval($catid);
+        $destblogid = intval($destblogid);
+
+        $blogid = getBlogIDFromCatID($catid);
+
+        // mover should have admin rights on both blogs
+        if (!$member->blogAdminRights($blogid))
+            return _ERROR_DISALLOWED;
+        if (!$member->blogAdminRights($destblogid))
+            return _ERROR_DISALLOWED;
+
+        // cannot move to self
+        if ($blogid == $destblogid)
+            return _ERROR_MOVETOSELF;
+
+        // get blogs
+        $blog =& $manager->getBlog($blogid);
+        $destblog =& $manager->getBlog($destblogid);
+
+        // check if the category is valid
+        if (!$blog || !$blog->isValidCategory($catid))
+            return _ERROR_NOSUCHCATEGORY;
+
+        // don't allow default category to be moved
+        if ($blog->getDefaultCategory() == $catid)
+            return _ERROR_MOVEDEFCATEGORY;
+
+        $manager->notify(
+            'PreMoveCategory',
+            array(
+                'catid' => &$catid,
+                'sourceblog' => &$blog,
+                'destblog' => &$destblog
+            )
+        );
+
+        // update comments table (cblog)
+        $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
+        $items = sql_query($query);
+        while ($oItem = sql_fetch_object($items)) {
+            sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
+        }
+
+        // update items (iblog)
+        $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
+        sql_query($query);
+
+        // move category
+        $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
+        sql_query($query);
+
+        $manager->notify(
+            'PostMoveCategory',
+            array(
+                'catid' => &$catid,
+                'sourceblog' => &$blog,
+                'destblog' => $destblog
+            )
+        );
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_blogsettingsupdate() {
+        global $member, $manager;
+
+        $blogid = intRequestVar('blogid');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $blog =& $manager->getBlog($blogid);
+
+        $notify         = trim(postVar('notify'));
+        $shortname      = trim(postVar('shortname'));
+        $updatefile     = trim(postVar('update'));
+
+        $notifyComment  = intPostVar('notifyComment');
+        $notifyVote     = intPostVar('notifyVote');
+        $notifyNewItem  = intPostVar('notifyNewItem');
+
+        if ($notifyComment == 0)    $notifyComment = 1;
+        if ($notifyVote == 0)       $notifyVote = 1;
+        if ($notifyNewItem == 0)    $notifyNewItem = 1;
+
+        $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
+
+
+        if ($notify) {
+            $not =& new NOTIFICATION($notify);
+            if (!$not->validAddresses())
+                $this->error(_ERROR_BADNOTIFY);
+
+        }
+
+        if (!isValidShortName($shortname))
+            $this->error(_ERROR_BADSHORTBLOGNAME);
+
+        if (($blog->getShortName() != $shortname) && $manager->existsBlog($shortname))
+            $this->error(_ERROR_DUPSHORTBLOGNAME);
+
+        // check if update file is writable
+        if ($updatefile && !is_writeable($updatefile))
+            $this->error(_ERROR_UPDATEFILE);
+
+        $blog->setName(trim(postVar('name')));
+        $blog->setShortName($shortname);
+        $blog->setNotifyAddress($notify);
+        $blog->setNotifyType($notifyType);
+        $blog->setMaxComments(postVar('maxcomments'));
+        $blog->setCommentsEnabled(postVar('comments'));
+        $blog->setTimeOffset(postVar('timeoffset'));
+        $blog->setUpdateFile($updatefile);
+        $blog->setURL(trim(postVar('url')));
+        $blog->setDefaultSkin(intPostVar('defskin'));
+        $blog->setDescription(trim(postVar('desc')));
+        $blog->setPublic(postVar('public'));
+        $blog->setConvertBreaks(intPostVar('convertbreaks'));
+        $blog->setAllowPastPosting(intPostVar('allowpastposting'));
+        $blog->setDefaultCategory(intPostVar('defcat'));
+        $blog->setSearchable(intPostVar('searchable'));
+        $blog->setEmailRequired(intPostVar('reqemail'));
+
+        $blog->writeSettings();
+
+        // store plugin options
+        $aOptions = requestArray('plugoption');
+        NucleusPlugin::_applyPluginOptions($aOptions);
+        $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
+
+
+        $this->action_overview(_MSG_SETTINGSCHANGED);
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_deleteblog() {
+        global $member, $CONF, $manager;
+
+        $blogid = intRequestVar('blogid');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        // check if blog is default blog
+        if ($CONF['DefaultBlog'] == $blogid)
+            $this->error(_ERROR_DELDEFBLOG);
+
+        $blog =& $manager->getBlog($blogid);
+
+        $this->pagehead();
+        ?>
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+
+            <p><?php echo _WARNINGTXT_BLOGDEL?>
+            </p>
+
+            <div>
+            <?php echo _CONFIRMTXT_BLOG?><b><?php echo  htmlspecialchars($blog->getName())?></b>
+            </div>
+
+            <form method="post" action="index.php"><div>
+            <input type="hidden" name="action" value="deleteblogconfirm" />
+            <?php $manager->addTicketHidden() ?>
+            <input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />
+            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_deleteblogconfirm() {
+        global $member, $CONF, $manager;
+
+        $blogid = intRequestVar('blogid');
+
+        $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        // check if blog is default blog
+        if ($CONF['DefaultBlog'] == $blogid)
+            $this->error(_ERROR_DELDEFBLOG);
+
+        // delete all comments
+        $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
+        sql_query($query);
+
+        // delete all items
+        $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
+        sql_query($query);
+
+        // delete all team members
+        $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
+        sql_query($query);
+
+        // delete all bans
+        $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
+        sql_query($query);
+
+        // delete all categories
+        $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
+        sql_query($query);
+
+        // delete all associated plugin options
+        NucleusPlugin::_deleteOptionValues('blog', $blogid);
+
+        // delete the blog itself
+        $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
+        sql_query($query);
+
+        $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
+
+        $this->action_overview(_DELETED_BLOG);
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_memberdelete() {
+        global $member, $manager;
+
+        $memberid = intRequestVar('memberid');
+
+        ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
+
+        $mem = MEMBER::createFromID($memberid);
+
+        $this->pagehead();
+        ?>
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+
+            <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo htmlspecialchars($mem->getDisplayName()) ?></b>
+            </p>
+
+            <p>
+            <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
+            </p>
+
+            <form method="post" action="index.php"><div>
+            <input type="hidden" name="action" value="memberdeleteconfirm" />
+            <?php $manager->addTicketHidden() ?>
+            <input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />
+            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_memberdeleteconfirm() {
+        global $member;
+
+        $memberid = intRequestVar('memberid');
+
+        ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
+
+        $error = $this->deleteOneMember($memberid);
+        if ($error)
+            $this->error($error);
+
+        if ($member->isAdmin())
+            $this->action_usermanagement();
+        else
+            $this->action_overview(_DELETED_MEMBER);
+    }
+
+    /**
+     * @static
+     * @todo document this
+     */
+    function deleteOneMember($memberid) {
+        global $manager;
+
+        $memberid = intval($memberid);
+        $mem = MEMBER::createFromID($memberid);
+
+        if (!$mem->canBeDeleted())
+            return _ERROR_DELETEMEMBER;
+
+        $manager->notify('PreDeleteMember', array('member' => &$mem));
+
+        /* unlink comments from memberid */
+        if ($memberid) {
+            $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. addslashes($mem->getDisplayName())
+                        .'" WHERE cmember='.$memberid;
+            sql_query($query);
+        }
+
+        $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
+        sql_query($query);
+
+        $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
+        sql_query($query);
+
+        $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
+        sql_query($query);
+
+        // delete all associated plugin options
+        NucleusPlugin::_deleteOptionValues('member', $memberid);
+
+        $manager->notify('PostDeleteMember', array('member' => &$mem));
+
+        return '';
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_createnewlog() {
+        global $member, $CONF, $manager;
+
+        // Only Super-Admins can do this
+        $member->isAdmin() or $this->disallow();
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+        ?>
+        <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
+
+        <h3><?php echo _ADMIN_NOTABILIA ?></h3>
+
+        <p><?php echo _ADMIN_PLEASE_READ ?></p>
+
+        <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
+
+        <ol>
+            <li><?php echo _ADMIN_SIMPLE_WAY ?></li>
+            <li><?php echo _ADMIN_ADVANCED_WAY ?></li>
+        </ol>
+
+        <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
+
+        <p>
+        <?php echo _EBLOG_CREATE_TEXT?>
+        </p>
+
+        <form method="post" action="index.php"><div>
+
+        <input type="hidden" name="action" value="addnewlog" />
+        <?php $manager->addTicketHidden() ?>
+
+
+        <table><tr>
+            <td><?php echo _EBLOG_NAME?></td>
+            <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_SHORTNAME?>
+                <?php help('shortblogname'); ?>
+            </td>
+            <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_DESC?></td>
+            <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_DEFSKIN?>
+                <?php help('blogdefaultskin'); ?>
+            </td>
+            <td>
+                <?php
+                    $query =  'SELECT sdname as text, sdnumber as value'
+                           . ' FROM '.sql_table('skin_desc');
+                    $template['name'] = 'defskin';
+                    $template['tabindex'] = 50;
+                    $template['selected'] = $CONF['BaseSkin'];  // set default selected skin to be globally defined base skin
+                    showlist($query,'select',$template);
+                ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _EBLOG_OFFSET?>
+                <?php help('blogtimeoffset'); ?>
+                <br /><?php echo _EBLOG_STIME?> <b><?php echo  strftime("%H:%M",time()); ?></b>
+            </td>
+            <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_ADMIN?>
+                <?php help('teamadmin'); ?>
+            </td>
+            <td><?php echo _EBLOG_ADMIN_MSG?></td>
+        </tr><tr>
+            <td><?php echo _EBLOG_CREATE?></td>
+            <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
+        </tr></table>
+
+        </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_addnewlog() {
+        global $member, $manager, $CONF;
+
+        // Only Super-Admins can do this
+        $member->isAdmin() or $this->disallow();
+
+        $bname          = trim(postVar('name'));
+        $bshortname     = trim(postVar('shortname'));
+        $btimeoffset    = postVar('timeoffset');
+        $bdesc          = trim(postVar('desc'));
+        $bdefskin       = postVar('defskin');
+
+        if (!isValidShortName($bshortname))
+            $this->error(_ERROR_BADSHORTBLOGNAME);
+
+        if ($manager->existsBlog($bshortname))
+            $this->error(_ERROR_DUPSHORTBLOGNAME);
+
+        $manager->notify(
+            'PreAddBlog',
+            array(
+                'name' => &$bname,
+                'shortname' => &$bshortname,
+                'timeoffset' => &$btimeoffset,
+                'description' => &$bdesc,
+                'defaultskin' => &$bdefskin
+            )
+        );
+
+
+        // add slashes for sql queries
+        $bname =        addslashes($bname);
+        $bshortname =   addslashes($bshortname);
+        $btimeoffset =  addslashes($btimeoffset);
+        $bdesc =        addslashes($bdesc);
+        $bdefskin =     addslashes($bdefskin);
+
+        // create blog
+        $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
+        sql_query($query);
+        $blogid = sql_insert_id();
+        $blog   =& $manager->getBlog($blogid);
+
+        // create new category
+        $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
+        $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
+        $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
+        sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
+//		sql_query(sprintf($sql, sql_table('category'), $blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC));
+//		sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
+        $catid = sql_insert_id();
 
-		$mem = MEMBER::createFromId($info->vmember);
+        // set as default category
+        $blog->setDefaultCategory($catid);
+        $blog->writeSettings();
 
-		if (!$mem)
-			return $this->_showActivationPage($key, _ERROR_ACTIVATE);
+        // create team member
+        $memberid = $member->getID();
+        $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
+        sql_query($query);
 
-		$password 		= postVar('password');
-		$repeatpassword	= postVar('repeatpassword');
+        $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
+        $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
 
-		if ($password != $repeatpassword)
-			return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
+        $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
+        //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
 
-		if ($password && (strlen($password) < 6))
-			return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
 
-		$error = '';
-		global $manager;
-		$manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
-		if ($error != '')
-			return $this->_showActivationPage($key, $error);
-
-
-		// set password
-		$mem->setPassword($password);
-		$mem->write();
-
-		// do the activation
-		MEMBER::activate($key);
-
-		$this->pagehead();
-			echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
-			echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
-		$this->pagefoot();
-	}
-
-	/**
-	 * Manage team
-	 */
-	function action_manageteam() {
-		global $member, $manager;
-
-		$blogid = intRequestVar('blogid');
-
-		// check if allowed
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$this->pagehead();
-
-		echo "<p><a href='index.php?action=blogsettings&amp;blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
-
-		echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
-
-		echo '<h3>' . _TEAM_CURRENT . '</h3>';
-
-
-
-		$query =  'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
-			   . ' FROM '.sql_table('member').', '.sql_table('team')
-			   . ' WHERE tmember=mnumber and tblog=' . $blogid;
-
-		$template['content'] = 'teamlist';
-		$template['tabindex'] = 10;
-
-		$manager->loadClass("ENCAPSULATE");
-		$batch =& new BATCH('team');
-		$batch->showlist($query, 'table', $template);
-
-		?>
-			<h3><?php echo _TEAM_ADDNEW?></h3>
-
-			<form method='post' action='index.php'><div>
-
-			<input type='hidden' name='action' value='teamaddmember' />
-			<input type='hidden' name='blogid' value='<?php echo  $blogid; ?>' />
-			<?php $manager->addTicketHidden() ?>
-
-			<table><tr>
-				<td><?php echo _TEAM_CHOOSEMEMBER?></td>
-				<td><?php					// TODO: try to make it so only non-team-members are listed
-					$query =  'SELECT mname as text, mnumber as value'
-						   . ' FROM '.sql_table('member');
-
-					$template['name'] = 'memberid';
-					$template['tabindex'] = 10000;
-					showlist($query,'select',$template);
-				?></td>
-			</tr><tr>
-				<td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
-				<td><?php $this->input_yesno('admin',0,10020); ?></td>
-			</tr><tr>
-				<td><?php echo _TEAM_ADD?></td>
-				<td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
-			</tr></table>
-
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * Add member to team
-	 */
-	function action_teamaddmember() {
-		global $member, $manager;
-
-		$memberid = intPostVar('memberid');
-		$blogid = intPostVar('blogid');
-		$admin = intPostVar('admin');
-
-		// check if allowed
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$blog =& $manager->getBlog($blogid);
-		if (!$blog->addTeamMember($memberid, $admin))
-			$this->error(_ERROR_ALREADYONTEAM);
-
-		$this->action_manageteam();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_teamdelete() {
-		global $member, $manager;
-
-		$memberid = intRequestVar('memberid');
-		$blogid = intRequestVar('blogid');
-
-		// check if allowed
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$teammem = MEMBER::createFromID($memberid);
-		$blog =& $manager->getBlog($blogid);
-
-		$this->pagehead();
-		?>
-			<h2><?php echo _DELETE_CONFIRM?></h2>
-
-			<p><?php echo _CONFIRMTXT_TEAM1?><b><?php echo  htmlspecialchars($teammem->getDisplayName()) ?></b><?php echo _CONFIRMTXT_TEAM2?><b><?php echo  htmlspecialchars(strip_tags($blog->getName())) ?></b>
-			</p>
-
-
-			<form method="post" action="index.php"><div>
-			<input type="hidden" name="action" value="teamdeleteconfirm" />
-			<?php $manager->addTicketHidden() ?>
-			<input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />
-			<input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />
-			<input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_teamdeleteconfirm() {
-		global $member;
-
-		$memberid = intRequestVar('memberid');
-		$blogid = intRequestVar('blogid');
-
-		$error = $this->deleteOneTeamMember($blogid, $memberid);
-		if ($error)
-			$this->error($error);
-
-
-		$this->action_manageteam();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function deleteOneTeamMember($blogid, $memberid) {
-		global $member, $manager;
-
-		$blogid = intval($blogid);
-		$memberid = intval($memberid);
-
-		// check if allowed
-		if (!$member->blogAdminRights($blogid))
-			return _ERROR_DISALLOWED;
-
-		// check if: - there remains at least one blog admin
-		//           - (there remains at least one team member)
-		$tmem = MEMBER::createFromID($memberid);
-
-		$manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
-
-		if ($tmem->isBlogAdmin($blogid)) {
-			// check if there are more blog members left and at least one admin
-			// (check for at least two admins before deletion)
-			$query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
-			$r = sql_query($query);
-			if (mysql_num_rows($r) < 2)
-				return _ERROR_ATLEASTONEBLOGADMIN;
-		}
-
-		$query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
-		sql_query($query);
-
-		$manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
-
-		return '';
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_teamchangeadmin() {
-		global $member;
-
-		$blogid = intRequestVar('blogid');
-		$memberid = intRequestVar('memberid');
-
-		// check if allowed
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$mem = MEMBER::createFromID($memberid);
-
-		// don't allow when there is only one admin at this moment
-		if ($mem->isBlogAdmin($blogid)) {
-			$r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
-			if (mysql_num_rows($r) == 1)
-				$this->error(_ERROR_ATLEASTONEBLOGADMIN);
-		}
-
-		if ($mem->isBlogAdmin($blogid))
-			$newval = 0;
-		else
-			$newval = 1;
-
-		$query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
-		sql_query($query);
-
-		// only show manageteam if member did not change its own admin privileges
-		if ($member->isBlogAdmin($blogid))
-			$this->action_manageteam();
-		else
-			$this->action_overview(_MSG_ADMINCHANGED);
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_blogsettings() {
-		global $member, $manager;
-
-		$blogid = intRequestVar('blogid');
-
-		// check if allowed
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$blog =& $manager->getBlog($blogid);
-
-		$extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
-		$this->pagehead($extrahead);
-
-		echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-		?>
-		<h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
-
-		<h3><?php echo _EBLOG_TEAM_TITLE?></h3>
-
-		<p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>
-		<?php
-			$res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
-			$aMemberNames = array();
-			while ($o = mysql_fetch_object($res))
-				array_push($aMemberNames, htmlspecialchars($o->mname) . ' (' . htmlspecialchars($o->mrealname). ')');
-			echo implode(',', $aMemberNames);
-		?>
-		</p>
-
-
-
-		<p>
-		<a href="index.php?action=manageteam&amp;blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
-		</p>
-
-		<h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
-
-		<form method="post" action="index.php"><div>
-
-		<input type="hidden" name="action" value="blogsettingsupdate" />
-		<?php $manager->addTicketHidden() ?>
-		<input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />
-		<table><tr>
-			<td><?php echo _EBLOG_NAME?></td>
-			<td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo  htmlspecialchars($blog->getName()) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
-				<?php echo _EBLOG_SHORTNAME_EXTRA?>
-			</td>
-			<td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo  htmlspecialchars($blog->getShortName()) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_DESC?></td>
-			<td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo  htmlspecialchars($blog->getDescription()) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_URL?></td>
-			<td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo  htmlspecialchars($blog->getURL()) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_DEFSKIN?>
-				<?php help('blogdefaultskin'); ?>
-			</td>
-			<td>
-				<?php
-					$query =  'SELECT sdname as text, sdnumber as value'
-						   . ' FROM '.sql_table('skin_desc');
-					$template['name'] = 'defskin';
-					$template['selected'] = $blog->getDefaultSkin();
-					$template['tabindex'] = 50;
-					showlist($query,'select',$template);
-				?>
-
-			</td>
-		</tr><tr>
-			<td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
-			</td>
-			<td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
-			</td>
-			<td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_DISABLECOMMENTS?>
-			</td>
-			<td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_ANONYMOUS?>
-			</td>
-			<td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
-		</tr><tr>
-	<td><?php echo _EBLOG_REQUIREDEMAIL?>
-		 </td>
-		 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
-	  </tr><tr>
-			<td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
-			<td><input name="notify" tabindex="80" maxlength="60" size="40" value="<?php echo  htmlspecialchars($blog->getNotifyAddress()); ?>" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_NOTIFY_ON?></td>
-			<td>
-				<input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
-					<?php if  ($blog->notifyOnComment()) echo "checked='checked'" ?>
-				/><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
-				<br />
-				<input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
-					<?php if  ($blog->notifyOnVote()) echo "checked='checked'" ?>
-				/><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
-				<br />
-				<input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
-					<?php if  ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
-				/><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
-			</td>
-		</tr><tr>
-		<?php
-		if (numberOfEventSubscriber('SendPing') > 0) {
-		?>
-			<td><?php echo _EBLOG_PING?> <?php help('sendping'); ?></td>
-			<td><?php $this->input_yesno('sendping',$blog->sendPing(),85); ?></td>
-		</tr><tr>
-		<?php
-		}
-		?>
-			<td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
-			<td><input name="maxcomments" tabindex="90" size="3" value="<?php echo  htmlspecialchars($blog->getMaxComments()); ?>" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
-			<td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo  htmlspecialchars($blog->getUpdateFile()) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_DEFCAT?></td>
-			<td>
-				<?php
-					$query =  'SELECT cname as text, catid as value'
-						   . ' FROM '.sql_table('category')
-						   . ' WHERE cblog=' . $blog->getID();
-					$template['name'] = 'defcat';
-					$template['selected'] = $blog->getDefaultCategory();
-					$template['tabindex'] = 110;
-					showlist($query,'select',$template);
-				?>
-			</td>
-		</tr><tr>
-			<td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
-				<br /><?php echo _EBLOG_STIME?> <b><?php echo  strftime("%H:%M",time()); ?></b>
-				<br /><?php echo _EBLOG_BTIME?> <b><?php echo  strftime("%H:%M",$blog->getCorrectTime()); ?></b>
-				</td>
-			<td><input name="timeoffset" tabindex="120" size="3" value="<?php echo  htmlspecialchars($blog->getTimeOffset()); ?>" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
-			<td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
-		</tr>
-		<?php
-			// plugin options
-			$this->_insertPluginOptions('blog',$blogid);
-		?>
-		<tr>
-			<th colspan="2"><?php echo _EBLOG_CHANGE?></th>
-		</tr><tr>
-			<td><?php echo _EBLOG_CHANGE?></td>
-			<td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
-		</tr></table>
-
-		</div></form>
-
-		<h3><?php echo _EBLOG_CAT_TITLE?></h3>
-
-
-		<?php
-		$query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
-		$template['content'] = 'categorylist';
-		$template['tabindex'] = 200;
-
-		$manager->loadClass("ENCAPSULATE");
-		$batch =& new BATCH('category');
-		$batch->showlist($query,'table',$template);
-
-		?>
-
-
-		<form action="index.php" method="post"><div>
-		<input name="action" value="categorynew" type="hidden" />
-		<?php $manager->addTicketHidden() ?>
-		<input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
-
-		<table><tr>
-			<th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
-		</tr><tr>
-			<td><?php echo _EBLOG_CAT_NAME?></td>
-			<td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_CAT_DESC?></td>
-			<td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_CAT_CREATE?></td>
-			<td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
-		</tr></table>
-
-		</div></form>
-
-		<?php
-
-			echo '<h3>',_PLUGINS_EXTRA,'</h3>';
-
-			$manager->notify(
-				'BlogSettingsFormExtras',
-				array(
-					'blog' => &$blog
-				)
-			);
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_categorynew() {
-		global $member, $manager;
-
-		$blogid = intRequestVar('blogid');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$cname = postVar('cname');
-		$cdesc = postVar('cdesc');
-
-		if (!isValidCategoryName($cname))
-			$this->error(_ERROR_BADCATEGORYNAME);
-
-		$query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . addslashes($cname).'\' and cblog=' . intval($blogid);
-		$res = sql_query($query);
-		if (mysql_num_rows($res) > 0)
-			$this->error(_ERROR_DUPCATEGORYNAME);
-
-		$blog 		=& $manager->getBlog($blogid);
-		$newCatID	=  $blog->createNewCategory($cname, $cdesc);
-
-		$this->action_blogsettings();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
-		global $member, $manager;
-
-		if ($blogid == '')
-			$blogid = intGetVar('blogid');
-		else
-			$blogid = intval($blogid);
-		if ($catid == '')
-			$catid = intGetVar('catid');
-		else
-			$catid = intval($catid);
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
-		$obj = mysql_fetch_object($res);
-
-		$cname = $obj->cname;
-		$cdesc = $obj->cdesc;
-
-		$extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
-		$this->pagehead($extrahead);
-
-		echo "<p><a href='index.php?action=blogsettings&amp;blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
-
-		?>
-		<h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo htmlspecialchars($cname)?>'</h2>
-		<form method='post' action='index.php'><div>
-		<input name="blogid" type="hidden" value="<?php echo $blogid?>" />
-		<input name="catid" type="hidden" value="<?php echo $catid?>" />
-		<input name="desturl" type="hidden" value="<?php echo htmlspecialchars($desturl) ?>" />
-		<input name="action" type="hidden" value="categoryupdate" />
-		<?php $manager->addTicketHidden(); ?>
-
-		<table><tr>
-			<th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
-		</tr><tr>
-			<td><?php echo _EBLOG_CAT_NAME?></td>
-			<td><input type="text" name="cname" value="<?php echo htmlspecialchars($cname)?>" size="40" maxlength="40" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_CAT_DESC?></td>
-			<td><input type="text" name="cdesc" value="<?php echo htmlspecialchars($cdesc)?>" size="40" maxlength="200" /></td>
-		</tr>
-		<?php
-			// insert plugin options
-			$this->_insertPluginOptions('category',$catid);
-		?>
-		<tr>
-			<th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
-		</tr><tr>
-			<td><?php echo _EBLOG_CAT_UPDATE?></td>
-			<td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
-		</tr></table>
-
-		</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_categoryupdate() {
-		global $member, $manager;
-
-		$blogid = intPostVar('blogid');
-		$catid = intPostVar('catid');
-		$cname = postVar('cname');
-		$cdesc = postVar('cdesc');
-		$desturl = postVar('desturl');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		if (!isValidCategoryName($cname))
-			$this->error(_ERROR_BADCATEGORYNAME);
-
-		$query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . addslashes($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
-		$res = sql_query($query);
-		if (mysql_num_rows($res) > 0)
-			$this->error(_ERROR_DUPCATEGORYNAME);
-
-		$query =  'UPDATE '.sql_table('category').' SET'
-			   . " cname='" . addslashes($cname) . "',"
-			   . " cdesc='" . addslashes($cdesc) . "'"
-			   . " WHERE catid=" . $catid;
-
-		sql_query($query);
-
-		// store plugin options
-		$aOptions = requestArray('plugoption');
-		NucleusPlugin::_applyPluginOptions($aOptions);
-		$manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
-
-
-		if ($desturl) {
-			redirect($desturl);
-			exit;
-		} else {
-			$this->action_blogsettings();
-		}
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_categorydelete() {
-		global $member, $manager;
-
-		$blogid = intRequestVar('blogid');
-		$catid = intRequestVar('catid');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$blog =& $manager->getBlog($blogid);
-
-		// check if the category is valid
-		if (!$blog->isValidCategory($catid))
-			$this->error(_ERROR_NOSUCHCATEGORY);
-
-		// don't allow deletion of default category
-		if ($blog->getDefaultCategory() == $catid)
-			$this->error(_ERROR_DELETEDEFCATEGORY);
-
-		// check if catid is the only category left for blogid
-		$query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
-		$res = sql_query($query);
-		if (mysql_num_rows($res) == 1)
-			$this->error(_ERROR_DELETELASTCATEGORY);
-
-
-		$this->pagehead();
-		?>
-			<h2><?php echo _DELETE_CONFIRM?></h2>
-
-			<div>
-			<?php echo _CONFIRMTXT_CATEGORY?><b><?php echo  htmlspecialchars($blog->getCategoryName($catid))?></b>
-			</div>
-
-			<form method="post" action="index.php"><div>
-			<input type="hidden" name="action" value="categorydeleteconfirm" />
-			<?php $manager->addTicketHidden() ?>
-			<input type="hidden" name="blogid" value="<?php echo $blogid?>" />
-			<input type="hidden" name="catid" value="<?php echo $catid?>" />
-			<input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_categorydeleteconfirm() {
-		global $member, $manager;
-
-		$blogid = intRequestVar('blogid');
-		$catid = intRequestVar('catid');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$error = $this->deleteOneCategory($catid);
-		if ($error)
-			$this->error($error);
-
-		$this->action_blogsettings();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function deleteOneCategory($catid) {
-		global $manager, $member;
-
-		$catid = intval($catid);
-
-		$manager->notify('PreDeleteCategory', array('catid' => $catid));
-
-		$blogid = getBlogIDFromCatID($catid);
-
-		if (!$member->blogAdminRights($blogid))
-			return ERROR_DISALLOWED;
-
-		// get blog
-		$blog =& $manager->getBlog($blogid);
-
-		// check if the category is valid
-		if (!$blog || !$blog->isValidCategory($catid))
-			return _ERROR_NOSUCHCATEGORY;
-
-		$destcatid = $blog->getDefaultCategory();
-
-		// don't allow deletion of default category
-		if ($blog->getDefaultCategory() == $catid)
-			return _ERROR_DELETEDEFCATEGORY;
-
-		// check if catid is the only category left for blogid
-		$query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
-		$res = sql_query($query);
-		if (mysql_num_rows($res) == 1)
-			return _ERROR_DELETELASTCATEGORY;
-
-		// change category for all items to the default category
-		$query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
-		sql_query($query);
-
-		// delete all associated plugin options
-		NucleusPlugin::_deleteOptionValues('category', $catid);
-
-		// delete category
-		$query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
-		sql_query($query);
-
-		$manager->notify('PostDeleteCategory', array('catid' => $catid));
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function moveOneCategory($catid, $destblogid) {
-		global $manager, $member;
-
-		$catid = intval($catid);
-		$destblogid = intval($destblogid);
-
-		$blogid = getBlogIDFromCatID($catid);
-
-		// mover should have admin rights on both blogs
-		if (!$member->blogAdminRights($blogid))
-			return _ERROR_DISALLOWED;
-		if (!$member->blogAdminRights($destblogid))
-			return _ERROR_DISALLOWED;
-
-		// cannot move to self
-		if ($blogid == $destblogid)
-			return _ERROR_MOVETOSELF;
-
-		// get blogs
-		$blog =& $manager->getBlog($blogid);
-		$destblog =& $manager->getBlog($destblogid);
-
-		// check if the category is valid
-		if (!$blog || !$blog->isValidCategory($catid))
-			return _ERROR_NOSUCHCATEGORY;
-
-		// don't allow default category to be moved
-		if ($blog->getDefaultCategory() == $catid)
-			return _ERROR_MOVEDEFCATEGORY;
-
-		$manager->notify(
-			'PreMoveCategory',
-			array(
-				'catid' => &$catid,
-				'sourceblog' => &$blog,
-				'destblog' => &$destblog
-			)
-		);
-
-		// update comments table (cblog)
-		$query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
-		$items = sql_query($query);
-		while ($oItem = mysql_fetch_object($items)) {
-			sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
-		}
-
-		// update items (iblog)
-		$query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
-		sql_query($query);
-
-		// move category
-		$query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
-		sql_query($query);
-
-		$manager->notify(
-			'PostMoveCategory',
-			array(
-				'catid' => &$catid,
-				'sourceblog' => &$blog,
-				'destblog' => $destblog
-			)
-		);
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_blogsettingsupdate() {
-		global $member, $manager;
-
-		$blogid = intRequestVar('blogid');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$blog =& $manager->getBlog($blogid);
-
-		$notify			= trim(postVar('notify'));
-		$shortname		= trim(postVar('shortname'));
-		$updatefile		= trim(postVar('update'));
-
-		$notifyComment	= intPostVar('notifyComment');
-		$notifyVote		= intPostVar('notifyVote');
-		$notifyNewItem	= intPostVar('notifyNewItem');
-
-		if ($notifyComment == 0)	$notifyComment = 1;
-		if ($notifyVote == 0)		$notifyVote = 1;
-		if ($notifyNewItem == 0)	$notifyNewItem = 1;
-
-		$notifyType = $notifyComment * $notifyVote * $notifyNewItem;
-
-
-		if ($notify) {
-			$not =& new NOTIFICATION($notify);
-			if (!$not->validAddresses())
-				$this->error(_ERROR_BADNOTIFY);
-
-		}
-
-		if (!isValidShortName($shortname))
-			$this->error(_ERROR_BADSHORTBLOGNAME);
-
-		if (($blog->getShortName() != $shortname) && $manager->existsBlog($shortname))
-			$this->error(_ERROR_DUPSHORTBLOGNAME);
-
-		// check if update file is writable
-		if ($updatefile && !is_writeable($updatefile))
-			$this->error(_ERROR_UPDATEFILE);
-
-		$blog->setName(trim(postVar('name')));
-		$blog->setShortName($shortname);
-		$blog->setNotifyAddress($notify);
-		$blog->setNotifyType($notifyType);
-		$blog->setMaxComments(postVar('maxcomments'));
-		$blog->setCommentsEnabled(postVar('comments'));
-		$blog->setTimeOffset(postVar('timeoffset'));
-		$blog->setUpdateFile($updatefile);
-		$blog->setURL(trim(postVar('url')));
-		$blog->setDefaultSkin(intPostVar('defskin'));
-		$blog->setDescription(trim(postVar('desc')));
-		$blog->setPublic(postVar('public'));
-		$blog->setPingUserland(postVar('sendping'));
-		$blog->setConvertBreaks(intPostVar('convertbreaks'));
-		$blog->setAllowPastPosting(intPostVar('allowpastposting'));
-		$blog->setDefaultCategory(intPostVar('defcat'));
-		$blog->setSearchable(intPostVar('searchable'));
-		$blog->setEmailRequired(intPostVar('reqemail'));
-
-		$blog->writeSettings();
-
-		// store plugin options
-		$aOptions = requestArray('plugoption');
-		NucleusPlugin::_applyPluginOptions($aOptions);
-		$manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
-
-
-		$this->action_overview(_MSG_SETTINGSCHANGED);
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_deleteblog() {
-		global $member, $CONF, $manager;
-
-		$blogid = intRequestVar('blogid');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		// check if blog is default blog
-		if ($CONF['DefaultBlog'] == $blogid)
-			$this->error(_ERROR_DELDEFBLOG);
-
-		$blog =& $manager->getBlog($blogid);
-
-		$this->pagehead();
-		?>
-			<h2><?php echo _DELETE_CONFIRM?></h2>
-
-			<p><?php echo _WARNINGTXT_BLOGDEL?>
-			</p>
-
-			<div>
-			<?php echo _CONFIRMTXT_BLOG?><b><?php echo  htmlspecialchars($blog->getName())?></b>
-			</div>
-
-			<form method="post" action="index.php"><div>
-			<input type="hidden" name="action" value="deleteblogconfirm" />
-			<?php $manager->addTicketHidden() ?>
-			<input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />
-			<input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_deleteblogconfirm() {
-		global $member, $CONF, $manager;
-
-		$blogid = intRequestVar('blogid');
-
-		$manager->notify('PreDeleteBlog', array('blogid' => $blogid));
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		// check if blog is default blog
-		if ($CONF['DefaultBlog'] == $blogid)
-			$this->error(_ERROR_DELDEFBLOG);
-
-		// delete all comments
-		$query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
-		sql_query($query);
-
-		// delete all items
-		$query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
-		sql_query($query);
-
-		// delete all team members
-		$query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
-		sql_query($query);
-
-		// delete all bans
-		$query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
-		sql_query($query);
-
-		// delete all categories
-		$query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
-		sql_query($query);
-
-		// delete all associated plugin options
-		NucleusPlugin::_deleteOptionValues('blog', $blogid);
-
-		// delete the blog itself
-		$query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
-		sql_query($query);
-
-		$manager->notify('PostDeleteBlog', array('blogid' => $blogid));
-
-		$this->action_overview(_DELETED_BLOG);
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_memberdelete() {
-		global $member, $manager;
-
-		$memberid = intRequestVar('memberid');
-
-		($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-
-		$mem = MEMBER::createFromID($memberid);
-
-		$this->pagehead();
-		?>
-			<h2><?php echo _DELETE_CONFIRM?></h2>
-
-			<p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo htmlspecialchars($mem->getDisplayName()) ?></b>
-			</p>
-
-			<p>
-			<?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
-			</p>
-
-			<form method="post" action="index.php"><div>
-			<input type="hidden" name="action" value="memberdeleteconfirm" />
-			<?php $manager->addTicketHidden() ?>
-			<input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />
-			<input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_memberdeleteconfirm() {
-		global $member;
-
-		$memberid = intRequestVar('memberid');
-
-		($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-
-		$error = $this->deleteOneMember($memberid);
-		if ($error)
-			$this->error($error);
-
-		if ($member->isAdmin())
-			$this->action_usermanagement();
-		else
-			$this->action_overview(_DELETED_MEMBER);
-	}
-
-	/**
-	 * @static
-	 * @todo document this
-	 */
-	function deleteOneMember($memberid) {
-		global $manager;
 
-		$memberid = intval($memberid);
-		$mem = MEMBER::createFromID($memberid);
+        $manager->notify(
+            'PostAddBlog',
+            array(
+                'blog' => &$blog
+            )
+        );
 
-		if (!$mem->canBeDeleted())
-			return _ERROR_DELETEMEMBER;
+        $manager->notify(
+            'PostAddCategory',
+            array(
+                'blog' => &$blog,
+                'name' => _EBLOGDEFAULTCATEGORY_NAME,
+                'description' => _EBLOGDEFAULTCATEGORY_DESC,
+                'catid' => $catid
+            )
+        );
 
-		$manager->notify('PreDeleteMember', array('member' => &$mem));
+        $this->pagehead();
+        ?>
+        <h2><?php echo _BLOGCREATED_TITLE ?></h2>
 
-		/* unlink comments from memberid */
-		if ($memberid) {
-			$query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. addslashes($mem->getDisplayName())
-						.'" WHERE cmember='.$memberid;
-			sql_query($query);
-		}
-
-		$query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
-		sql_query($query);
-
-		$query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
-		sql_query($query);
-
-		$query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
-		sql_query($query);
-
-		// delete all associated plugin options
-		NucleusPlugin::_deleteOptionValues('member', $memberid);
-
-		$manager->notify('PostDeleteMember', array('member' => &$mem));
-
-		return '';
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_createnewlog() {
-		global $member, $CONF, $manager;
-
-		// Only Super-Admins can do this
-		$member->isAdmin() or $this->disallow();
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-		?>
-		<h2><?php echo _EBLOG_CREATE_TITLE?></h2>
-
-		<h3><?php echo _ADMIN_NOTABILIA ?></h3>
-
-		<p><?php echo _ADMIN_PLEASE_READ ?></p>
-
-		<p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
-
-		<ol>
-			<li><?php echo _ADMIN_SIMPLE_WAY ?></li>
-			<li><?php echo _ADMIN_ADVANCED_WAY ?></li>
-		</ol>
-
-		<h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
-
-		<p>
-		<?php echo _EBLOG_CREATE_TEXT?>
-		</p>
-
-		<form method="post" action="index.php"><div>
-
-		<input type="hidden" name="action" value="addnewlog" />
-		<?php $manager->addTicketHidden() ?>
-
-
-		<table><tr>
-			<td><?php echo _EBLOG_NAME?></td>
-			<td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_SHORTNAME?>
-				<?php help('shortblogname'); ?>
-			</td>
-			<td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_DESC?></td>
-			<td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_DEFSKIN?>
-				<?php help('blogdefaultskin'); ?>
-			</td>
-			<td>
-				<?php
-					$query =  'SELECT sdname as text, sdnumber as value'
-						   . ' FROM '.sql_table('skin_desc');
-					$template['name'] = 'defskin';
-					$template['tabindex'] = 50;
-					$template['selected'] = $CONF['BaseSkin'];	// set default selected skin to be globally defined base skin
-					showlist($query,'select',$template);
-				?>
-			</td>
-		</tr><tr>
-			<td><?php echo _EBLOG_OFFSET?>
-				<?php help('blogtimeoffset'); ?>
-				<br /><?php echo _EBLOG_STIME?> <b><?php echo  strftime("%H:%M",time()); ?></b>
-			</td>
-			<td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_ADMIN?>
-				<?php help('teamadmin'); ?>
-			</td>
-			<td><?php echo _EBLOG_ADMIN_MSG?></td>
-		</tr><tr>
-			<td><?php echo _EBLOG_CREATE?></td>
-			<td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
-		</tr></table>
-
-		</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_addnewlog() {
-		global $member, $manager, $CONF;
-
-		// Only Super-Admins can do this
-		$member->isAdmin() or $this->disallow();
-
-		$bname			= trim(postVar('name'));
-		$bshortname		= trim(postVar('shortname'));
-		$btimeoffset	= postVar('timeoffset');
-		$bdesc			= trim(postVar('desc'));
-		$bdefskin		= postVar('defskin');
-
-		if (!isValidShortName($bshortname))
-			$this->error(_ERROR_BADSHORTBLOGNAME);
-
-		if ($manager->existsBlog($bshortname))
-			$this->error(_ERROR_DUPSHORTBLOGNAME);
-
-		$manager->notify(
-			'PreAddBlog',
-			array(
-				'name' => &$bname,
-				'shortname' => &$bshortname,
-				'timeoffset' => &$btimeoffset,
-				'description' => &$bdesc,
-				'defaultskin' => &$bdefskin
-			)
-		);
-
-
-		// add slashes for sql queries
-		$bname = 		addslashes($bname);
-		$bshortname = 	addslashes($bshortname);
-		$btimeoffset = 	addslashes($btimeoffset);
-		$bdesc = 		addslashes($bdesc);
-		$bdefskin = 	addslashes($bdefskin);
-
-		// create blog
-		$query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
-		sql_query($query);
-		$blogid	= mysql_insert_id();
-		$blog	=& $manager->getBlog($blogid);
-
-		// create new category
-		$catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
-		$catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
-		$sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
-		sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
-//		sql_query(sprintf($sql, sql_table('category'), $blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC));
-//		sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
-		$catid = mysql_insert_id();
+        <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, htmlspecialchars($bname)) ?></p>
 
-		// set as default category
-		$blog->setDefaultCategory($catid);
-		$blog->writeSettings();
-
-		// create team member
-		$memberid = $member->getID();
-		$query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
-		sql_query($query);
-
-		$itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
-		$itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
-
-		$blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
-		//$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
-
-		$manager->notify(
-			'PostAddBlog',
-			array(
-				'blog' => &$blog
-			)
-		);
-
-		$manager->notify(
-			'PostAddCategory',
-			array(
-				'blog' => &$blog,
-				'name' => _EBLOGDEFAULTCATEGORY_NAME,
-				'description' => _EBLOGDEFAULTCATEGORY_DESC,
-				'catid' => $catid
-			)
-		);
-
-		$this->pagehead();
-		?>
-		<h2><?php echo _BLOGCREATED_TITLE ?></h2>
-
-		<p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, htmlspecialchars($bname)) ?></p>
-
-		<ol>
-			<li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, htmlspecialchars($bshortname)) ?></a></li>
-			<li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
-		</ol>
+        <ol>
+            <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, htmlspecialchars($bshortname)) ?></a></li>
+            <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
+        </ol>
 
-		<h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, htmlspecialchars($bshortname)) ?></a></h3>
+        <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, htmlspecialchars($bshortname)) ?></a></h3>
 
-		<p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, htmlspecialchars($bshortname)) ?></p>
+        <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, htmlspecialchars($bshortname)) ?></p>
 <pre><code>&lt;?php
 
 $CONF['Self'] = '<b><?php echo htmlspecialchars($bshortname)?>.php</b>';
@@ -3502,3100 +3374,3113 @@
 
 ?&gt;</code></pre>
 
-		<p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
+        <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
+
+        <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
 
-		<p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
+        <form action="index.php" method="post"><div>
+            <input type="hidden" name="action" value="addnewlog2" />
+            <?php $manager->addTicketHidden() ?>
+            <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
+            <table><tr>
+                <td><?php echo _EBLOG_URL?></td>
+                <td><input name="url" maxlength="100" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
+            </tr><tr>
+                <td><?php echo _EBLOG_CREATE?></td>
+                <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
+            </tr></table>
+        </div></form>
+
+        <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
+
+        <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
+
+        <form action="index.php" method="post"><div>
+            <input type="hidden" name="action" value="addnewlog2" />
+            <?php $manager->addTicketHidden() ?>
+            <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
+            <table><tr>
+                <td><?php echo _EBLOG_URL?></td>
+                <td><input name="url" maxlength="100" size="40" /></td>
+            </tr><tr>
+                <td><?php echo _EBLOG_CREATE?></td>
+                <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
+            </tr></table>
+        </div></form>
+
+        <?php       $this->pagefoot();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_addnewlog2() {
+        global $member, $manager;
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $burl   = requestVar('url');
+        $blogid = intRequestVar('blogid');
+
+        $blog =& $manager->getBlog($blogid);
+        $blog->setURL(trim($burl));
+        $blog->writeSettings();
+
+        $this->action_overview(_MSG_NEWBLOG);
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinieoverview() {
+        global $member, $DIR_LIBS, $manager;
+
+        $member->isAdmin() or $this->disallow();
+
+        // load skinie class
+        include_once($DIR_LIBS . 'skinie.php');
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+
+    ?>
+        <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
+
+                <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
+                <?php                   global $DIR_SKINS;
+
+                    $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
+
+                    if (sizeof($candidates) > 0) {
+                        ?>
+                            <form method="post" action="index.php"><div>
+                                <input type="hidden" name="action" value="skinieimport" />
+                                <?php $manager->addTicketHidden() ?>
+                                <input type="hidden" name="mode" value="file" />
+                                <select name="skinfile" id="skinie_import_local">
+                                <?php                                   foreach ($candidates as $skinname => $skinfile) {
+                                        $html = htmlspecialchars($skinfile);
+                                        echo '<option value="',$html,'">',$skinname,'</option>';
+                                    }
+                                ?>
+                                </select>
+                                <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
+                            </div></form>
+                        <?php                   } else {
+                        echo _SKINIE_NOCANDIDATES;
+                    }
+                ?>
+                </p>
+
+                <p><em><?php echo _OR?></em></p>
 
-		<form action="index.php" method="post"><div>
-			<input type="hidden" name="action" value="addnewlog2" />
-			<?php $manager->addTicketHidden() ?>
-			<input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
-			<table><tr>
-				<td><?php echo _EBLOG_URL?></td>
-				<td><input name="url" maxlength="100" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
-			</tr><tr>
-				<td><?php echo _EBLOG_CREATE?></td>
-				<td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
-			</tr></table>
-		</div></form>
-
-		<h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
-
-		<p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
-
-		<form action="index.php" method="post"><div>
-			<input type="hidden" name="action" value="addnewlog2" />
-			<?php $manager->addTicketHidden() ?>
-			<input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
-			<table><tr>
-				<td><?php echo _EBLOG_URL?></td>
-				<td><input name="url" maxlength="100" size="40" /></td>
-			</tr><tr>
-				<td><?php echo _EBLOG_CREATE?></td>
-				<td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
-			</tr></table>
-		</div></form>
-
-		<?php		$this->pagefoot();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_addnewlog2() {
-		global $member, $manager;
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$burl	= requestVar('url');
-		$blogid	= intRequestVar('blogid');
-
-		$blog =& $manager->getBlog($blogid);
-		$blog->setURL(trim($burl));
-		$blog->writeSettings();
-
-		$this->action_overview(_MSG_NEWBLOG);
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinieoverview() {
-		global $member, $DIR_LIBS, $manager;
-
-		$member->isAdmin() or $this->disallow();
-
-		// load skinie class
-		include_once($DIR_LIBS . 'skinie.php');
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-	?>
-		<h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
-
-				<p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
-				<?php					global $DIR_SKINS;
-
-					$candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
-
-					if (sizeof($candidates) > 0) {
-						?>
-							<form method="post" action="index.php"><div>
-								<input type="hidden" name="action" value="skinieimport" />
-								<?php $manager->addTicketHidden() ?>
-								<input type="hidden" name="mode" value="file" />
-								<select name="skinfile" id="skinie_import_local">
-								<?php									foreach ($candidates as $skinname => $skinfile) {
-										$html = htmlspecialchars($skinfile);
-										echo '<option value="',$html,'">',$skinname,'</option>';
-									}
-								?>
-								</select>
-								<input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
-							</div></form>
-						<?php					} else {
-						echo _SKINIE_NOCANDIDATES;
-					}
-				?>
-				</p>
-
-				<p><em><?php echo _OR?></em></p>
-
-				<form method="post" action="index.php"><p>
-					<?php $manager->addTicketHidden() ?>
-					<input type="hidden" name="action" value="skinieimport" />
-					<input type="hidden" name="mode" value="url" />
-					<label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
-					<input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
-					<input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
-				</p></form>
-
-
-		<h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
-		<form method="post" action="index.php"><div>
-			<input type="hidden" name="action" value="skinieexport" />
-			<?php $manager->addTicketHidden() ?>
-
-			<p><?php echo _SKINIE_EXPORT_INTRO?></p>
-
-			<table><tr>
-				<th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
-			</tr><tr>
-	<?php		// show list of skins
-		$res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
-		while ($skinObj = mysql_fetch_object($res)) {
-			$id = 'skinexp' . $skinObj->sdnumber;
-			echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']"  id="',$id,'" />';
-			echo '<label for="',$id,'">',htmlspecialchars($skinObj->sdname),'</label></td>';
-			echo '<td>',htmlspecialchars($skinObj->sddesc),'</td>';
-			echo '</tr><tr>';
-		}
-
-		echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
-
-		// show list of templates
-		$res = sql_query('SELECT * FROM '.sql_table('template_desc'));
-		while ($templateObj = mysql_fetch_object($res)) {
-			$id = 'templateexp' . $templateObj->tdnumber;
-			echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
-			echo '<label for="',$id,'">',htmlspecialchars($templateObj->tdname),'</label></td>';
-			echo '<td>',htmlspecialchars($templateObj->tddesc),'</td>';
-			echo '</tr><tr>';
-		}
-
-	?>
-				<th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
-			</tr><tr>
-				<td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
-			</tr><tr>
-				<th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
-			</tr><tr>
-				<td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
-			</tr></table>
-		</div></form>
-
-	<?php
-		$this->pagefoot();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinieimport() {
-		global $member, $DIR_LIBS, $DIR_SKINS, $manager;
-
-		$member->isAdmin() or $this->disallow();
-
-		// load skinie class
-		include_once($DIR_LIBS . 'skinie.php');
-
-		$skinFileRaw= postVar('skinfile');
-		$mode 		= postVar('mode');
-
-		$importer =& new SKINIMPORT();
-
-		// get full filename
-		if ($mode == 'file')
-		{
-			$skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
-
-			// backwards compatibilty (in v2.0, exports were saved as skindata.xml)
-			if (!file_exists($skinFile))
-				$skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
-		} else {
-			$skinFile = $skinFileRaw;
-		}
-
-		// read only metadata
-		$error = $importer->readFile($skinFile, 1);
-
-		// clashes
-		$skinNameClashes = $importer->checkSkinNameClashes();
-		$templateNameClashes = $importer->checkTemplateNameClashes();
-		$hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes)	> 0);
-
-		if ($error) $this->error($error);
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
-		?>
-		<h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
-
-		<ul>
-			<li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
-			<li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
-			<li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
-			<?php
-				if ($hasNameClashes)
-				{
-			?>
-			<li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
-			<li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
-			<?php
-				} // if (hasNameClashes)
-			?>
-		</ul>
-
-		<form method="post" action="index.php"><div>
-			<input type="hidden" name="action" value="skiniedoimport" />
-			<?php $manager->addTicketHidden() ?>
-			<input type="hidden" name="skinfile" value="<?php echo htmlspecialchars(postVar('skinfile'))?>" />
-			<input type="hidden" name="mode" value="<?php echo htmlspecialchars($mode)?>" />
-			<input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
-			<?php
-				if ($hasNameClashes)
-				{
-			?>
-			<br />
-			<input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
-			<?php
-				} // if (hasNameClashes)
-			?>
-		</div></form>
-
-
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skiniedoimport() {
-		global $member, $DIR_LIBS, $DIR_SKINS;
-
-		$member->isAdmin() or $this->disallow();
-
-		// load skinie class
-		include_once($DIR_LIBS . 'skinie.php');
-
-		$skinFileRaw= postVar('skinfile');
-		$mode		= postVar('mode');
-
-		$allowOverwrite = intPostVar('overwrite');
-
-		// get full filename
-		if ($mode == 'file')
-		{
-			$skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
-
-			// backwards compatibilty (in v2.0, exports were saved as skindata.xml)
-			if (!file_exists($skinFile))
-				$skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
-
-		} else {
-			$skinFile = $skinFileRaw;
-		}
-
-		$importer =& new SKINIMPORT();
-
-		$error = $importer->readFile($skinFile);
-
-		if ($error)
-			$this->error($error);
-
-		$error = $importer->writeToDatabase($allowOverwrite);
-
-		if ($error)
-			$this->error($error);
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-	?>
-		<h2><?php echo _SKINIE_DONE?></h2>
-
-		<ul>
-			<li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
-			<li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
-			<li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
-		</ul>
-
-	<?php		$this->pagefoot();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinieexport() {
-		global $member, $DIR_LIBS;
-
-		$member->isAdmin() or $this->disallow();
-
-		// load skinie class
-		include_once($DIR_LIBS . 'skinie.php');
-
-		$aSkins = requestIntArray('skin');
-		$aTemplates = requestIntArray('template');
-
-		if (!is_array($aTemplates)) $aTemplates = array();
-		if (!is_array($aSkins)) $aSkins = array();
-
-		$skinList = array_keys($aSkins);
-		$templateList = array_keys($aTemplates);
-
-		$info = postVar('info');
-
-		$exporter =& new SKINEXPORT();
-		foreach ($skinList as $skinId) {
-			$exporter->addSkin($skinId);
-		}
-		foreach ($templateList as $templateId) {
-			$exporter->addTemplate($templateId);
-		}
-		$exporter->setInfo($info);
-
-		$exporter->export();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_templateoverview() {
-		global $member, $manager;
-
-		$member->isAdmin() or $this->disallow();
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-		echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
-		echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
-
-		$query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
-		$template['content'] = 'templatelist';
-		$template['tabindex'] = 10;
-		showlist($query,'table',$template);
-
-		echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
-
-		?>
-		<form method="post" action="index.php"><div>
-
-		<input name="action" value="templatenew" type="hidden" />
-		<?php $manager->addTicketHidden() ?>
-		<table><tr>
-			<td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
-			<td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
-		</tr><tr>
-			<td><?php echo _TEMPLATE_DESC?></td>
-			<td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
-		</tr><tr>
-			<td><?php echo _TEMPLATE_CREATE?></td>
-			<td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
-		</tr></table>
-
-		</div></form>
-
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_templateedit($msg = '') {
-		global $member, $manager;
-
-		$templateid = intRequestVar('templateid');
-
-		$member->isAdmin() or $this->disallow();
-
-		$extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
-		$extrahead .= '<script type="text/javascript">setTemplateEditText("'.addslashes(_EDITTEMPLATE_EMPTY).'");</script>';
-
-		$this->pagehead($extrahead);
-
-		$templatename = TEMPLATE::getNameFromId($templateid);
-		$templatedescription = TEMPLATE::getDesc($templateid);
-		$template =& $manager->getTemplate($templatename);
-
-		?>
-		<p>
-		<a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
-		</p>
-
-		<h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo  htmlspecialchars($templatename); ?>'</h2>
-
-		<?php					if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
-		?>
-
-		<p><?php echo _TEMPLATE_EDIT_MSG?></p>
-
-		<form method="post" action="index.php">
-		<div>
-
-		<input type="hidden" name="action" value="templateupdate" />
-		<?php $manager->addTicketHidden() ?>
-		<input type="hidden" name="templateid" value="<?php echo  $templateid; ?>" />
-
-		<table><tr>
-			<th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
-		</tr><tr>
-			<td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
-			<td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo  htmlspecialchars($templatename) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _TEMPLATE_DESC?></td>
-			<td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo  htmlspecialchars($templatedescription) ?>" /></td>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
-		</tr><tr>
-			<td><?php echo _TEMPLATE_UPDATE?></td>
-			<td>
-				<input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
-				<input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
-			</td>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
+                <form method="post" action="index.php"><p>
+                    <?php $manager->addTicketHidden() ?>
+                    <input type="hidden" name="action" value="skinieimport" />
+                    <input type="hidden" name="mode" value="url" />
+                    <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
+                    <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
+                    <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
+                </p></form>
+
+
+        <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
+        <form method="post" action="index.php"><div>
+            <input type="hidden" name="action" value="skinieexport" />
+            <?php $manager->addTicketHidden() ?>
+
+            <p><?php echo _SKINIE_EXPORT_INTRO?></p>
+
+            <table><tr>
+                <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
+            </tr><tr>
+    <?php       // show list of skins
+        $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
+        while ($skinObj = sql_fetch_object($res)) {
+            $id = 'skinexp' . $skinObj->sdnumber;
+            echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']"  id="',$id,'" />';
+            echo '<label for="',$id,'">',htmlspecialchars($skinObj->sdname),'</label></td>';
+            echo '<td>',htmlspecialchars($skinObj->sddesc),'</td>';
+            echo '</tr><tr>';
+        }
+
+        echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
+
+        // show list of templates
+        $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
+        while ($templateObj = sql_fetch_object($res)) {
+            $id = 'templateexp' . $templateObj->tdnumber;
+            echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
+            echo '<label for="',$id,'">',htmlspecialchars($templateObj->tdname),'</label></td>';
+            echo '<td>',htmlspecialchars($templateObj->tddesc),'</td>';
+            echo '</tr><tr>';
+        }
+
+    ?>
+                <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
+            </tr><tr>
+                <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
+            </tr><tr>
+                <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
+            </tr><tr>
+                <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
+            </tr></table>
+        </div></form>
+
+    <?php
+        $this->pagefoot();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinieimport() {
+        global $member, $DIR_LIBS, $DIR_SKINS, $manager;
+
+        $member->isAdmin() or $this->disallow();
+
+        // load skinie class
+        include_once($DIR_LIBS . 'skinie.php');
+
+        $skinFileRaw= postVar('skinfile');
+        $mode       = postVar('mode');
+
+        $importer =& new SKINIMPORT();
+
+        // get full filename
+        if ($mode == 'file')
+        {
+            $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
+
+            // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
+            if (!file_exists($skinFile))
+                $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
+        } else {
+            $skinFile = $skinFileRaw;
+        }
+
+        // read only metadata
+        $error = $importer->readFile($skinFile, 1);
+
+        // clashes
+        $skinNameClashes = $importer->checkSkinNameClashes();
+        $templateNameClashes = $importer->checkTemplateNameClashes();
+        $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
+
+        if ($error) $this->error($error);
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
+        ?>
+        <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
+
+        <ul>
+            <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
+            <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
+            <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
+            <?php
+                if ($hasNameClashes)
+                {
+            ?>
+            <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
+            <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
+            <?php
+                } // if (hasNameClashes)
+            ?>
+        </ul>
+
+        <form method="post" action="index.php"><div>
+            <input type="hidden" name="action" value="skiniedoimport" />
+            <?php $manager->addTicketHidden() ?>
+            <input type="hidden" name="skinfile" value="<?php echo htmlspecialchars(postVar('skinfile'))?>" />
+            <input type="hidden" name="mode" value="<?php echo htmlspecialchars($mode)?>" />
+            <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
+            <?php
+                if ($hasNameClashes)
+                {
+            ?>
+            <br />
+            <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
+            <?php
+                } // if (hasNameClashes)
+            ?>
+        </div></form>
+
+
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skiniedoimport() {
+        global $member, $DIR_LIBS, $DIR_SKINS;
+
+        $member->isAdmin() or $this->disallow();
+
+        // load skinie class
+        include_once($DIR_LIBS . 'skinie.php');
+
+        $skinFileRaw= postVar('skinfile');
+        $mode       = postVar('mode');
+
+        $allowOverwrite = intPostVar('overwrite');
+
+        // get full filename
+        if ($mode == 'file')
+        {
+            $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
+
+            // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
+            if (!file_exists($skinFile))
+                $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
+
+        } else {
+            $skinFile = $skinFileRaw;
+        }
+
+        $importer =& new SKINIMPORT();
+
+        $error = $importer->readFile($skinFile);
+
+        if ($error)
+            $this->error($error);
+
+        $error = $importer->writeToDatabase($allowOverwrite);
+
+        if ($error)
+            $this->error($error);
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+    ?>
+        <h2><?php echo _SKINIE_DONE?></h2>
+
+        <ul>
+            <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
+            <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
+            <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
+        </ul>
+
+    <?php       $this->pagefoot();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinieexport() {
+        global $member, $DIR_LIBS;
+
+        $member->isAdmin() or $this->disallow();
+
+        // load skinie class
+        include_once($DIR_LIBS . 'skinie.php');
+
+        $aSkins = requestIntArray('skin');
+        $aTemplates = requestIntArray('template');
+
+        if (!is_array($aTemplates)) $aTemplates = array();
+        if (!is_array($aSkins)) $aSkins = array();
+
+        $skinList = array_keys($aSkins);
+        $templateList = array_keys($aTemplates);
+
+        $info = postVar('info');
+
+        $exporter =& new SKINEXPORT();
+        foreach ($skinList as $skinId) {
+            $exporter->addSkin($skinId);
+        }
+        foreach ($templateList as $templateId) {
+            $exporter->addTemplate($templateId);
+        }
+        $exporter->setInfo($info);
+
+        $exporter->export();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_templateoverview() {
+        global $member, $manager;
+
+        $member->isAdmin() or $this->disallow();
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+
+        echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
+        echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
+
+        $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
+        $template['content'] = 'templatelist';
+        $template['tabindex'] = 10;
+        showlist($query,'table',$template);
+
+        echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
+
+        ?>
+        <form method="post" action="index.php"><div>
+
+        <input name="action" value="templatenew" type="hidden" />
+        <?php $manager->addTicketHidden() ?>
+        <table><tr>
+            <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
+            <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
+        </tr><tr>
+            <td><?php echo _TEMPLATE_DESC?></td>
+            <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
+        </tr><tr>
+            <td><?php echo _TEMPLATE_CREATE?></td>
+            <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
+        </tr></table>
+
+        </div></form>
+
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_templateedit($msg = '') {
+        global $member, $manager;
+
+        $templateid = intRequestVar('templateid');
+
+        $member->isAdmin() or $this->disallow();
+
+        $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
+        $extrahead .= '<script type="text/javascript">setTemplateEditText("'.addslashes(_EDITTEMPLATE_EMPTY).'");</script>';
+
+        $this->pagehead($extrahead);
+
+        $templatename = TEMPLATE::getNameFromId($templateid);
+        $templatedescription = TEMPLATE::getDesc($templateid);
+        $template =& $manager->getTemplate($templatename);
+
+        ?>
+        <p>
+        <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
+        </p>
+
+        <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo  htmlspecialchars($templatename); ?>'</h2>
+
+        <?php                   if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
+        ?>
+
+        <p><?php echo _TEMPLATE_EDIT_MSG?></p>
+
+        <form method="post" action="index.php">
+        <div>
+
+        <input type="hidden" name="action" value="templateupdate" />
+        <?php $manager->addTicketHidden() ?>
+        <input type="hidden" name="templateid" value="<?php echo  $templateid; ?>" />
+
+        <table><tr>
+            <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
+        </tr><tr>
+            <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
+            <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo  htmlspecialchars($templatename) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _TEMPLATE_DESC?></td>
+            <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo  htmlspecialchars($templatedescription) ?>" /></td>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
+        </tr><tr>
+            <td><?php echo _TEMPLATE_UPDATE?></td>
+            <td>
+                <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
+                <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
+            </td>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
 <?php	$this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
-	$this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
-	$this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
-	$this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
-	$this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
-	$this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
+    $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
+    $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
+    $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
+    $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
+    $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
 <?php	$this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
-	$this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
-	$this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
-	$this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
-	$this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
-	$this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
-	$this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
+    $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
+    $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
+    $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
+    $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
+    $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
+    $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
 <?php
-	$this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
+    $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
 <?php	$this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
 <?php	$this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
-	$this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
-	$this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
+    $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
+    $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
 <?php	$this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
-	$this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
-	$this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
+    $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
+    $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
 <?php	$this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
-	$this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
-	$this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
+    $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
+    $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
 <?php	$this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
-	$this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
-	$this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
-	$this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
-	$this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
+    $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
+    $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
+    $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
+    $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
 <?php	$this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
-	$this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
-	$this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
+    $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
+    $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
 <?php	$this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
-	$this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
+    $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
 <?php
-		$tab = 600;
-		$pluginfields = array();
-		$manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
-
-		foreach ($pluginfields as $pfkey=>$pfvalue) {
-			echo "</tr><tr>\n";
-			echo '<th colspan="2">'.htmlentities($pfkey)."</th>\n";
-			foreach ($pfvalue as $pffield=>$pfdesc) {
-				$this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
-			}
-		}
+        $tab = 600;
+        $pluginfields = array();
+        $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
+
+        foreach ($pluginfields as $pfkey=>$pfvalue) {
+            echo "</tr><tr>\n";
+            echo '<th colspan="2">'.htmlentities($pfkey)."</th>\n";
+            foreach ($pfvalue as $pffield=>$pfdesc) {
+                $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
+            }
+        }
 ?>
-		</tr><tr>
-			<th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
-		</tr><tr>
-			<td><?php echo _TEMPLATE_UPDATE?></td>
-			<td>
-				<input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
-				<input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
-			</td>
-		</tr></table>
-
-		</div>
-		</form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
-		static $count = 1;
-		if (!isset($template[$name])) $template[$name] = '';
-	?>
-		</tr><tr>
-			<td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
-			<td id="td<?php echo $count?>"><textarea class="templateedit" name="<?php echo $name?>" tabindex="<?php echo $tabindex?>" cols="50" rows="<?php echo $big?10:5?>" id="textarea<?php echo $count?>"><?php echo  htmlspecialchars($template[$name]); ?></textarea></td>
-	<?php		$count++;
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_templateupdate() {
-		global $member,$manager;
-
-		$templateid = intRequestVar('templateid');
-
-		$member->isAdmin() or $this->disallow();
-
-		$name = postVar('tname');
-		$desc = postVar('tdesc');
-
-		if (!isValidTemplateName($name))
-			$this->error(_ERROR_BADTEMPLATENAME);
-
-		if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
-			$this->error(_ERROR_DUPTEMPLATENAME);
-
-
-		$name = addslashes($name);
-		$desc = addslashes($desc);
-
-		// 1. Remove all template parts
-		$query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
-		sql_query($query);
-
-		// 2. Update description
-		$query =  'UPDATE '.sql_table('template_desc').' SET'
-			   . " tdname='" . $name . "',"
-			   . " tddesc='" . $desc . "'"
-			   . " WHERE tdnumber=" . $templateid;
-		sql_query($query);
-
-		// 3. Add non-empty template parts
-		$this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
-		$this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
-		$this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
-		$this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
-		$this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
-		$this->addToTemplate($templateid, 'NEW', postVar('NEW'));
-		$this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
-		$this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
-		$this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
-		$this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
-		$this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
-		$this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
-		$this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
-		$this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
-		$this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
-		$this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
-		$this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
-		$this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
-		$this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
-		$this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
-		$this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
-		$this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
-		$this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
-		$this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
-		$this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
-		$this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
-		$this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
-		$this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
-		$this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
-		$this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
-		$this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
-		$this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
-		$this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
-		$this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
-
-		$pluginfields = array();
-		$manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
-		foreach ($pluginfields as $pfkey=>$pfvalue) {
-			foreach ($pfvalue as $pffield=>$pfdesc) {
-				$this->addToTemplate($templateid, $pffield, postVar($pffield));
-			}
-		}
-
-		// jump back to template edit
-		$this->action_templateedit(_TEMPLATE_UPDATED);
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function addToTemplate($id, $partname, $content) {
-		$partname = addslashes($partname);
-		$content = addslashes($content);
-
-		$id = intval($id);
-
-		// don't add empty parts:
-		if (!trim($content)) return -1;
-
-		$query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
-			   . "VALUES ($id, '$partname', '$content')";
-		sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . mysql_error());
-		return mysql_insert_id();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_templatedelete() {
-		global $member, $manager;
-
-		$member->isAdmin() or $this->disallow();
-
-		$templateid = intRequestVar('templateid');
-		// TODO: check if template can be deleted
-
-		$this->pagehead();
-
-		$name = TEMPLATE::getNameFromId($templateid);
-		$desc = TEMPLATE::getDesc($templateid);
-
-		?>
-			<h2><?php echo _DELETE_CONFIRM?></h2>
-
-			<p>
-			<?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo htmlspecialchars($name)?></b> (<?php echo  htmlspecialchars($desc) ?>)
-			</p>
-
-			<form method="post" action="index.php"><div>
-				<input type="hidden" name="action" value="templatedeleteconfirm" />
-				<?php $manager->addTicketHidden() ?>
-				<input type="hidden" name="templateid" value="<?php echo  $templateid ?>" />
-				<input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_templatedeleteconfirm() {
-		global $member, $manager;
-
-		$templateid = intRequestVar('templateid');
-
-		$member->isAdmin() or $this->disallow();
-
-		$manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
-
-		// 1. delete description
-		sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
-
-		// 2. delete parts
-		sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
-
-		$manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
-
-		$this->action_templateoverview();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_templatenew() {
-		global $member;
-
-		$member->isAdmin() or $this->disallow();
-
-		$name = postVar('name');
-		$desc = postVar('desc');
-
-		if (!isValidTemplateName($name))
-			$this->error(_ERROR_BADTEMPLATENAME);
-
-		if (TEMPLATE::exists($name))
-			$this->error(_ERROR_DUPTEMPLATENAME);
-
-		$newTemplateId = TEMPLATE::createNew($name, $desc);
-
-		$this->action_templateoverview();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_templateclone() {
-		global $member;
-
-		$templateid = intRequestVar('templateid');
-
-		$member->isAdmin() or $this->disallow();
-
-		// 1. read old template
-		$name = TEMPLATE::getNameFromId($templateid);
-		$desc = TEMPLATE::getDesc($templateid);
-
-		// 2. create desc thing
-		$name = "cloned" . $name;
-
-		// if a template with that name already exists:
-		if (TEMPLATE::exists($name)) {
-			$i = 1;
-			while (TEMPLATE::exists($name . $i))
-				$i++;
-			$name .= $i;
-		}
-
-		$newid = TEMPLATE::createNew($name, $desc);
-
-		// 3. create clone
-		// go through parts of old template and add them to the new one
-		$res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
-		while ($o = mysql_fetch_object($res)) {
-			$this->addToTemplate($newid, $o->tpartname, $o->tcontent);
-		}
-
-		$this->action_templateoverview();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinoverview() {
-		global $member, $manager;
-
-		$member->isAdmin() or $this->disallow();
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-		echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
-
-		echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
-
-		$query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
-		$template['content'] = 'skinlist';
-		$template['tabindex'] = 10;
-		showlist($query,'table',$template);
-
-		echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
-
-		?>
-		<form method="post" action="index.php">
-		<div>
-
-		<input name="action" value="skinnew" type="hidden" />
-		<?php $manager->addTicketHidden() ?>
-		<table><tr>
-			<td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
-			<td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
-		</tr><tr>
-			<td><?php echo _SKIN_DESC?></td>
-			<td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
-		</tr><tr>
-			<td><?php echo _SKIN_CREATE?></td>
-			<td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
-		</tr></table>
-
-		</div>
-		</form>
-
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinnew() {
-		global $member;
-
-		$member->isAdmin() or $this->disallow();
-
-		$name = trim(postVar('name'));
-		$desc = trim(postVar('desc'));
-
-		if (!isValidSkinName($name))
-			$this->error(_ERROR_BADSKINNAME);
-
-		if (SKIN::exists($name))
-			$this->error(_ERROR_DUPSKINNAME);
-
-		$newId = SKIN::createNew($name, $desc);
-
-		$this->action_skinoverview();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinedit() {
-		global $member, $manager;
-
-		$skinid = intRequestVar('skinid');
-
-		$member->isAdmin() or $this->disallow();
-
-		$skin =& new SKIN($skinid);
-
-		$this->pagehead();
-		?>
-		<p>
-			<a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
-		</p>
-		<h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo  $skin->getName() ?>'</h2>
-
-		<h3><?php echo _SKIN_PARTS_TITLE?></h3>
-		<?php echo _SKIN_PARTS_MSG?>
-		<ul>
-			<li><a tabindex="10" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=index"><?php echo _SKIN_PART_MAIN?></a> <?php help('skinpartindex')?></li>
-			<li><a tabindex="20" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=item"><?php echo _SKIN_PART_ITEM?></a> <?php help('skinpartitem')?></li>
-			<li><a tabindex="30" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=archivelist"><?php echo _SKIN_PART_ALIST?></a> <?php help('skinpartarchivelist')?></li>
-			<li><a tabindex="40" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=archive"><?php echo _SKIN_PART_ARCHIVE?></a> <?php help('skinpartarchive')?></li>
-			<li><a tabindex="50" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=search"><?php echo _SKIN_PART_SEARCH?></a> <?php help('skinpartsearch')?></li>
-			<li><a tabindex="60" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=error"><?php echo _SKIN_PART_ERROR?></a> <?php help('skinparterror')?></li>
-			<li><a tabindex="70" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=member"><?php echo _SKIN_PART_MEMBER?></a> <?php help('skinpartmember')?></li>
-			<li><a tabindex="75" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=imagepopup"><?php echo _SKIN_PART_POPUP?></a> <?php help('skinpartimagepopup')?></li>
-		</ul>
-
-		<?php
-
-		$query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
-		$res = sql_query($query);
-
-		echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
-		echo '<form method="get" action="index.php">' . "\r\n";
-		echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
-		echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
-		echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
-		echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
-		echo '</form>' . "\r\n";
-
-		if ($res && mysql_num_rows($res) > 0) {
-			echo '<ul>';
-			$tabstart = 75;
-
-			while ($row = mysql_fetch_assoc($res)) {
-				echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&amp;skinid=' . $skinid . '&amp;type=' . htmlspecialchars(strtolower($row['stype'])) . '">' . htmlspecialchars(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&amp;skinid=' . $skinid . '&amp;type=' . htmlspecialchars(strtolower($row['stype'])) . '">remove</a>)</li>';
-			}
-
-			echo '</ul>';
-		}
-
-		?>
-
-		<h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
-		<form method="post" action="index.php">
-		<div>
-
-		<input type="hidden" name="action" value="skineditgeneral" />
-		<?php $manager->addTicketHidden() ?>
-		<input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
-		<table><tr>
-			<td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
-			<td><input name="name" tabindex="90" value="<?php echo  htmlspecialchars($skin->getName()) ?>" maxlength="20" size="20" /></td>
-		</tr><tr>
-			<td><?php echo _SKIN_DESC?></td>
-			<td><input name="desc" tabindex="100" value="<?php echo  htmlspecialchars($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
-		</tr><tr>
-			<td><?php echo _SKIN_TYPE?></td>
-			<td><input name="type" tabindex="110" value="<?php echo  htmlspecialchars($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
-		</tr><tr>
-			<td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
-			<td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
-		</tr><tr>
-			<td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
-			<td><input name="inc_prefix" tabindex="130" value="<?php echo  htmlspecialchars($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
-		</tr><tr>
-			<td><?php echo _SKIN_CHANGE?></td>
-			<td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
-		</tr></table>
-
-		</div>
-		</form>
-
-
-		<?php		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skineditgeneral() {
-		global $member;
-
-		$skinid = intRequestVar('skinid');
-
-		$member->isAdmin() or $this->disallow();
-
-		$name = postVar('name');
-		$desc = postVar('desc');
-		$type = postVar('type');
-		$inc_mode = postVar('inc_mode');
-		$inc_prefix = postVar('inc_prefix');
-
-		$skin =& new SKIN($skinid);
-
-		// 1. Some checks
-		if (!isValidSkinName($name))
-			$this->error(_ERROR_BADSKINNAME);
-
-		if (($skin->getName() != $name) && SKIN::exists($name))
-			$this->error(_ERROR_DUPSKINNAME);
-
-		if (!$type) $type = 'text/html';
-		if (!$inc_mode) $inc_mode = 'normal';
-
-		// 2. Update description
-		$skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
-
-		$this->action_skinedit();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinedittype($msg = '') {
-		global $member, $manager;
-
-		$skinid = intRequestVar('skinid');
-		$type = requestVar('type');
-
-		$member->isAdmin() or $this->disallow();
-
-		$type = trim($type);
-		$type = strtolower($type);
-
-		if (!isValidShortName($type)) {
-			$this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
-		}
-
-		$skin =& new SKIN($skinid);
-
-		$friendlyNames = SKIN::getFriendlyNames();
-
-		$this->pagehead();
-		?>
-		<p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
-
-		<h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo htmlspecialchars($skin->getName()) ?>': <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
-
-		<?php			if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
-		?>
-
-
-		<form method="post" action="index.php">
-		<div>
-
-		<input type="hidden" name="action" value="skinupdate" />
-		<?php $manager->addTicketHidden() ?>
-		<input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
-		<input type="hidden" name="type" value="<?php echo  $type ?>" />
-
-		<input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
-		<input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
-		(skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
-		<?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-			help('skinpart' . $type);
-		} else {
-			help('skinpartspecial');
-		}?>
-		<br />
-
-		<textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo  htmlspecialchars($skin->getContent($type)) ?></textarea>
-
-		<br />
-		<input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
-		<input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
-		(skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
-
-		<br /><br />
-		<?php echo _SKIN_ALLOWEDVARS?>
-		<?php			$actions = SKIN::getAllowedActionsForType($type);
-
-			sort($actions);
-
-			while ($current = array_shift($actions)) {
-				// skip deprecated vars
-				if ($current == 'ifcat') continue;
-				if ($current == 'imagetext') continue;
-				if ($current == 'vars') continue;
-
-				echo helplink('skinvar-' . $current) . "$current</a>";
-				if (count($actions) != 0) echo ", ";
-			}
-		echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
-		$query = 'SELECT bshortname, bname FROM '.sql_table('blog');
-		showlist($query,'table',array('content'=>'shortblognames'));
-		echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
-		$query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
-		showlist($query,'table',array('content'=>'shortnames'));
-		echo '</div></form>';
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinupdate() {
-		global $member;
-
-		$skinid = intRequestVar('skinid');
-		$content = trim(postVar('content'));
-		$type = postVar('type');
-
-		$member->isAdmin() or $this->disallow();
-
-		$skin =& new SKIN($skinid);
-		$skin->update($type, $content);
-
-		$this->action_skinedittype(_SKIN_UPDATED);
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skindelete() {
-		global $member, $manager, $CONF;
-
-		$skinid = intRequestVar('skinid');
-
-		$member->isAdmin() or $this->disallow();
-
-		// don't allow default skin to be deleted
-		if ($skinid == $CONF['BaseSkin'])
-			$this->error(_ERROR_DEFAULTSKIN);
-
-		// don't allow deletion of default skins for blogs
-		$query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
-		$r = sql_query($query);
-		if ($o = mysql_fetch_object($r))
-			$this->error(_ERROR_SKINDEFDELETE . htmlspecialchars($o->bname));
-
-		$this->pagehead();
-
-		$skin =& new SKIN($skinid);
-		$name = $skin->getName();
-		$desc = $skin->getDescription();
-
-		?>
-			<h2><?php echo _DELETE_CONFIRM?></h2>
-
-			<p>
-				<?php echo _CONFIRMTXT_SKIN?><b><?php echo htmlspecialchars($name) ?></b> (<?php echo  htmlspecialchars($desc)?>)
-			</p>
-
-			<form method="post" action="index.php"><div>
-				<input type="hidden" name="action" value="skindeleteconfirm" />
-				<?php $manager->addTicketHidden() ?>
-				<input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
-				<input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skindeleteconfirm() {
-		global $member, $CONF, $manager;
-
-		$skinid = intRequestVar('skinid');
-
-		$member->isAdmin() or $this->disallow();
-
-		// don't allow default skin to be deleted
-		if ($skinid == $CONF['BaseSkin'])
-			$this->error(_ERROR_DEFAULTSKIN);
-
-		// don't allow deletion of default skins for blogs
-		$query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
-		$r = sql_query($query);
-		if ($o = mysql_fetch_object($r))
-			$this->error(_ERROR_SKINDEFDELETE .$o->bname);
-
-		$manager->notify('PreDeleteSkin', array('skinid' => $skinid));
-
-		// 1. delete description
-		sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
-
-		// 2. delete parts
-		sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
-
-		$manager->notify('PostDeleteSkin', array('skinid' => $skinid));
-
-		$this->action_skinoverview();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinremovetype() {
-		global $member, $manager, $CONF;
-
-		$skinid = intRequestVar('skinid');
-		$skintype = requestVar('type');
-
-		if (!isValidShortName($skintype)) {
-			$this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-		}
-
-		$member->isAdmin() or $this->disallow();
-
-		// don't allow default skinparts to be deleted
-		if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-			$this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-		}
-
-		$this->pagehead();
-
-		$skin =& new SKIN($skinid);
-		$name = $skin->getName();
-		$desc = $skin->getDescription();
-
-		?>
-			<h2><?php echo _DELETE_CONFIRM?></h2>
-
-			<p>
-				<?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo htmlspecialchars($skintype); ?> (<?php echo htmlspecialchars($name); ?>)</b> (<?php echo  htmlspecialchars($desc)?>)
-			</p>
-
-			<form method="post" action="index.php"><div>
-				<input type="hidden" name="action" value="skinremovetypeconfirm" />
-				<?php $manager->addTicketHidden() ?>
-				<input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
-				<input type="hidden" name="type" value="<?php echo htmlspecialchars($skintype); ?>" />
-				<input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-			</div></form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinremovetypeconfirm() {
-		global $member, $CONF, $manager;
-
-		$skinid = intRequestVar('skinid');
-		$skintype = requestVar('type');
-
-		if (!isValidShortName($skintype)) {
-			$this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-		}
-
-		$member->isAdmin() or $this->disallow();
-
-		// don't allow default skinparts to be deleted
-		if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-			$this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-		}
-
-		$manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
-
-		// delete part
-		sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
-
-		$manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
-
-		$this->action_skinedit();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_skinclone() {
-		global $member;
-
-		$skinid = intRequestVar('skinid');
-
-		$member->isAdmin() or $this->disallow();
-
-		// 1. read skin to clone
-		$skin =& new SKIN($skinid);
-
-		$name = "clone_" . $skin->getName();
-
-		// if a skin with that name already exists:
-		if (SKIN::exists($name)) {
-			$i = 1;
-			while (SKIN::exists($name . $i))
-				$i++;
-			$name .= $i;
-		}
-
-		// 2. create skin desc
-		$newid = SKIN::createNew(
-			$name,
-			$skin->getDescription(),
-			$skin->getContentType(),
-			$skin->getIncludeMode(),
-			$skin->getIncludePrefix()
-		);
-
-
-		// 3. clone
-		/*
-		$this->skinclonetype($skin, $newid, 'index');
-		$this->skinclonetype($skin, $newid, 'item');
-		$this->skinclonetype($skin, $newid, 'archivelist');
-		$this->skinclonetype($skin, $newid, 'archive');
-		$this->skinclonetype($skin, $newid, 'search');
-		$this->skinclonetype($skin, $newid, 'error');
-		$this->skinclonetype($skin, $newid, 'member');
-		$this->skinclonetype($skin, $newid, 'imagepopup');
-		*/
-
-		$query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
-		$res = sql_query($query);
-		while ($row = mysql_fetch_assoc($res)) {
-			$this->skinclonetype($skin, $newid, $row['stype']);
-		}
-
-		$this->action_skinoverview();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function skinclonetype($skin, $newid, $type) {
-		$newid = intval($newid);
-		$content = $skin->getContent($type);
-		if ($content) {
-			$query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". addslashes($content)."', '". addslashes($type)."')";
-			sql_query($query);
-		}
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_settingsedit() {
-		global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
-
-		$member->isAdmin() or $this->disallow();
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-		?>
-
-		<h2><?php echo _SETTINGS_TITLE?></h2>
-
-		<form action="index.php" method="post">
-		<div>
-
-		<input type="hidden" name="action" value="settingsupdate" />
-		<?php $manager->addTicketHidden() ?>
-
-		<table><tr>
-			<th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
-		</tr><tr>
-			<td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
-			<td>
-				<?php
-					$query =  'SELECT bname as text, bnumber as value'
-						   . ' FROM '.sql_table('blog');
-					$template['name'] = 'DefaultBlog';
-					$template['selected'] = $CONF['DefaultBlog'];
-					$template['tabindex'] = 10;
-					showlist($query,'select',$template);
-				?>
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
-			<td>
-				<?php
-					$query =  'SELECT sdname as text, sdnumber as value'
-						   . ' FROM '.sql_table('skin_desc');
-					$template['name'] = 'BaseSkin';
-					$template['selected'] = $CONF['BaseSkin'];
-					$template['tabindex'] = 1;
-					showlist($query,'select',$template);
-				?>
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_ADMINMAIL?></td>
-			<td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo  htmlspecialchars($CONF['AdminEmail']) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_SITENAME?></td>
-			<td><input name="SiteName" tabindex="10020" size="40" value="<?php echo  htmlspecialchars($CONF['SiteName']) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_SITEURL?></td>
-			<td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo  htmlspecialchars($CONF['IndexURL']) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_ADMINURL?></td>
-			<td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo  htmlspecialchars($CONF['AdminURL']) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
-			<td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo  htmlspecialchars($CONF['PluginURL']) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
-			<td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo  htmlspecialchars($CONF['SkinsURL']) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
-			<td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo  htmlspecialchars($CONF['ActionURL']) ?>" /></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>
-			</td>
-			<td>
-
-				<select name="Language" tabindex="10050">
-				<?php				// show a dropdown list of all available languages
-				global $DIR_LANG;
-				$dirhandle = opendir($DIR_LANG);
-				while ($filename = readdir($dirhandle)) {
-					if (ereg("^(.*)\.php$",$filename,$matches)) {
-						$name = $matches[1];
-						echo "<option value='$name'";
-						if ($name == $CONF['Language'])
-							echo " selected='selected'";
-						echo ">$name</option>";
-					}
-				}
-				closedir($dirhandle);
-
-				?>
-				</select>
-
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
-			</td>
-			<td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
-					<br />
-				<?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo  htmlspecialchars($CONF['DisableSiteURL'])?>" />
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_DIRS?></td>
-			<td><?php echo  htmlspecialchars($DIR_NUCLEUS) ?>
-				<i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_DBLOGIN?></td>
-			<td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
-		</tr><tr>
-			<td>
-			<?php
-				echo _SETTINGS_JSTOOLBAR
-				/* =_SETTINGS_DISABLEJS
-
-					I temporary changed the meaning of DisableJsTools, until I can find a good
-					way to select the javascript version to use
-
-					now, its:
-						0 : IE
-						1 : all javascript disabled
-						2 : 'simpler' javascript (for mozilla/opera/mac)
-				*/
-			   ?>
-			</td>
-			<td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
-				<select name="DisableJsTools" tabindex="10075">
-			<?php					$extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
-					echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
-					$extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
-					echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
-					$extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
-					echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
-			?>
-				</select>
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
-					   <td><?php
-
-					   $this->input_yesno('URLMode',$CONF['URLMode'],10077,
-							  'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
-
-					   echo ' ', _SETTINGS_URLMODE_HELP;
-
-							 ?>
-
-					   </td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
-					   <td><?php
-
-						$this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
-
-							 ?>
-
-					   </td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
-			<td>
-			<?php
-				if (!array_key_exists('DefaultListSize',$CONF)) {
-					sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
-					$CONF['DefaultListSize'] = 10;
-				}
-			?>
-				<input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo  htmlspecialchars((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
-			</td>
-		</tr><tr>
-			<th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
-		</tr><tr>
-			<td><?php echo _SETTINGS_MEDIADIR?></td>
-			<td><?php echo  htmlspecialchars($DIR_MEDIA) ?>
-				<i><?php echo _SETTINGS_SEECONFIGPHP?></i>
-				<?php			    	if (!is_dir($DIR_MEDIA))
-						echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
-					if (!is_readable($DIR_MEDIA))
-						echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
-					if (!is_writeable($DIR_MEDIA))
-						echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
-				?>
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_MEDIAURL?></td>
-			<td>
-				<input name="MediaURL" tabindex="10080" size="40" value="<?php echo  htmlspecialchars($CONF['MediaURL']) ?>" />
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
-			<td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
-			<td>
-				<input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo  htmlspecialchars($CONF['AllowedTypes']) ?>" />
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
-			<td>
-				<input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo  htmlspecialchars($CONF['MaxUploadSize']) ?>" />
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_MEDIAPREFIX?></td>
-			<td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
-
-		</tr><tr>
-			<th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
-		</tr><tr>
-			<td><?php echo _SETTINGS_CHANGELOGIN?></td>
-			<td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_ALLOWCREATE?>
-				<?php help('allowaccountcreation'); ?>
-			</td>
-			<td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
-				<br /><?php echo _SETTINGS_NEWLOGIN2?>
-			</td>
-			<td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_MEMBERMSGS?>
-				<?php help('messageservice'); ?>
-			</td>
-			<td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_NONMEMBERMSGS?>
-				<?php help('messageservice'); ?>
-			</td>
-			<td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_PROTECTMEMNAMES?>
-				<?php help('protectmemnames'); ?>
-			</td>
-			<td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
-			</td>
-
-
-
-		</tr><tr>
-			<th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
-		</tr><tr>
-			<td><?php echo _SETTINGS_COOKIEPREFIX?></td>
-			<td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo  htmlspecialchars($CONF['CookiePrefix'])?>" /></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
-			<td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo  htmlspecialchars($CONF['CookieDomain'])?>" /></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_COOKIEPATH?></td>
-			<td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo  htmlspecialchars($CONF['CookiePath'])?>" /></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_COOKIESECURE?></td>
-			<td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_COOKIELIFE?></td>
-			<td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
-							  1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
-			</td>
-		</tr><tr>
-			<td><?php echo _SETTINGS_LASTVISIT?></td>
-			<td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
-
-
-
-		</tr><tr>
-			<th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
-		</tr><tr>
-			<td><?php echo _SETTINGS_UPDATE?></td>
-			<td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
-		</tr></table>
-
-		</div>
-		</form>
-
-		<?php
-			echo '<h2>',_PLUGINS_EXTRA,'</h2>';
-
-			$manager->notify(
-				'GeneralSettingsFormExtras',
-				array()
-			);
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_settingsupdate() {
-		global $member, $CONF;
-
-		$member->isAdmin() or $this->disallow();
-
-		// check if email address for admin is valid
-		if (!isValidMailAddress(postVar('AdminEmail')))
-			$this->error(_ERROR_BADMAILADDRESS);
-
-
-		// save settings
-		$this->updateConfig('DefaultBlog',		postVar('DefaultBlog'));
-		$this->updateConfig('BaseSkin',			postVar('BaseSkin'));
-		$this->updateConfig('IndexURL',			postVar('IndexURL'));
-		$this->updateConfig('AdminURL',			postVar('AdminURL'));
-		$this->updateConfig('PluginURL',		postVar('PluginURL'));
-		$this->updateConfig('SkinsURL',			postVar('SkinsURL'));
-		$this->updateConfig('ActionURL',		postVar('ActionURL'));
-		$this->updateConfig('Language',			postVar('Language'));
-		$this->updateConfig('AdminEmail',		postVar('AdminEmail'));
-		$this->updateConfig('SessionCookie',	postVar('SessionCookie'));
-		$this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
-		$this->updateConfig('AllowMemberMail',	postVar('AllowMemberMail'));
-		$this->updateConfig('NonmemberMail',	postVar('NonmemberMail'));
-		$this->updateConfig('ProtectMemNames',	postVar('ProtectMemNames'));
-		$this->updateConfig('SiteName',			postVar('SiteName'));
-		$this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
-		$this->updateConfig('DisableSite',		postVar('DisableSite'));
-		$this->updateConfig('DisableSiteURL',	postVar('DisableSiteURL'));
-		$this->updateConfig('LastVisit',		postVar('LastVisit'));
-		$this->updateConfig('MediaURL',			postVar('MediaURL'));
-		$this->updateConfig('AllowedTypes',		postVar('AllowedTypes'));
-		$this->updateConfig('AllowUpload',		postVar('AllowUpload'));
-		$this->updateConfig('MaxUploadSize',	postVar('MaxUploadSize'));
-		$this->updateConfig('MediaPrefix',		postVar('MediaPrefix'));
-		$this->updateConfig('AllowLoginEdit',	postVar('AllowLoginEdit'));
-		$this->updateConfig('DisableJsTools',	postVar('DisableJsTools'));
-		$this->updateConfig('CookieDomain',		postVar('CookieDomain'));
-		$this->updateConfig('CookiePath',		postVar('CookiePath'));
-		$this->updateConfig('CookieSecure',		postVar('CookieSecure'));
-		$this->updateConfig('URLMode',			postVar('URLMode'));
-		$this->updateConfig('CookiePrefix',		postVar('CookiePrefix'));
-		$this->updateConfig('DebugVars',			postVar('DebugVars'));
-		$this->updateConfig('DefaultListSize',			postVar('DefaultListSize'));
-
-		// load new config and redirect (this way, the new language will be used is necessary)
-		// note that when changing cookie settings, this redirect might cause the user
-		// to have to log in again.
-		getConfig();
-		redirect($CONF['AdminURL'] . '?action=manage');
-		exit;
-
-	}
-
-	/**
-	 *  Give an overview over the used system
-	 */
-	function action_systemoverview() {
-		global $member, $nucleus, $CONF;
-
-		$this->pagehead();
-
-		echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
-
-		if ($member->isLoggedIn() && $member->isAdmin()) {
-
-			// Information about the used PHP and MySQL installation
-			echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n";
-
-			// Version of PHP MySQL
-			echo "<table>\n";
-			echo "\t<tr>\n";
-			echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
-			echo "\t\t" . '<td>' . phpversion() . "</td>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
-			echo "\t\t" . '<td>' . mysql_get_server_info() . ' (' . mysql_get_client_info() . ')' . "</td>\n";
-			echo "\t</tr>";
-			echo "</table>\n";
-
-			// Important PHP settings
-			echo "<table>\n";
-			echo "\t<tr>\n";
-			echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td width="50%">magic_quotes_gpc' . "</td>\n";
-			$mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
-			echo "\t\t" . '<td>' . $mqg . "</td>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td>magic_quotes_runtime' . "</td>\n";
-			$mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
-			echo "\t\t" . '<td>' . $mqr . "</td>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td>register_globals' . "</td>\n";
-			$rg = ini_get('register_globals') ? 'On' : 'Off';
-			echo "\t\t" . '<td>' . $rg . "</td>\n";
-			echo "\t</tr>";
-			echo "</table>\n";
-
-			// Information about GD library
-			$gdinfo = gd_info();
-			echo "<table>\n";
-			echo "\t<tr>";
-			echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
-			echo "\t</tr>\n";
-			foreach ($gdinfo as $key=>$value) {
-				if (is_bool($value)) {
-					$value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
-				} else {
-					$value = htmlspecialchars($value, ENT_QUOTES);
-				}
-				echo "\t<tr>";
-				echo "\t\t" . '<td width="50%">' . $key . "</td>\n";
-				echo "\t\t" . '<td>' . $value . "</td>\n";
-				echo "\t</tr>\n";
-			}
-			echo "</table>\n";
-
-			// Check if special modules are loaded
-			ob_start();
-			phpinfo(INFO_MODULES);
-			$im = ob_get_contents();
-			ob_clean();
-			echo "<table>\n";
-			echo "\t<tr>";
-			echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td width="50%">mod_rewrite' . "</td>\n";
-			$modrewrite = (strstr($im, 'mod_rewrite') != '') ?
-						_ADMIN_SYSTEMOVERVIEW_ENABLE :
-						_ADMIN_SYSTEMOVERVIEW_DISABLE;
-			echo "\t\t" . '<td>' . $modrewrite . "</td>\n";
-			echo "\t</tr>\n";
-			echo "</table>\n";
-
-			// Information about the used Nucleus CMS
-			echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
-			global $nucleus;
-			$nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
-			$np = getNucleusPatchLevel();
-			echo "<table>\n";
-			echo "\t<tr>";
-			echo "\t\t" . '<th colspan="2">Nucleus CMS' . "</th>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
-			echo "\t\t" . '<td>' . $nv . "</td>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
-			echo "\t\t" . '<td>' . $np . "</td>\n";
-			echo "\t</tr>\n";
-			echo "</table>\n";
-
-			// Important settings of the installation
-			echo "<table>\n";
-			echo "\t<tr>";
-			echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td width="50%">' . '$CONF[' . "'Self']</td>\n";
-			echo "\t\t" . '<td>' . $CONF['Self'] . "</td>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td width="50%">' . '$CONF[' . "'ItemURL']</td>\n";
-			echo "\t\t" . '<td>' . $CONF['ItemURL'] . "</td>\n";
-			echo "\t</tr><tr>\n";
-			echo "\t\t" . '<td width="50%">' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
-			$ohs = $CONF['alertOnHeadersSent'] ?
-						_ADMIN_SYSTEMOVERVIEW_ENABLE :
-						_ADMIN_SYSTEMOVERVIEW_DISABLE;
-			echo "\t\t" . '<td>' . $ohs . "</td>\n";
-			echo "\t</tr>\n";
-			echo "</table>\n";
-
-			// Link to the online version test at the Nucleus CMS website
-			echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
-			if ($nucleus['codename'] != '') {
-				$codenamestring = ' &quot;' . $nucleus['codename'] . '&quot;';
-			} else {
-				$codenamestring = '';
-			}
-			echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
-			$checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
-			echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
-			echo 'Nucleus CMS ' . $nv . $codenamestring;
-			echo '</a>';
-		//echo '<br />';
-		}
-		else {
-			echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
-		}
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function updateConfig($name, $val) {
-		$name = addslashes($name);
-		$val = trim(addslashes($val));
-
-		$query = 'UPDATE '.sql_table('config')
-			   . " SET value='$val'"
-			   . " WHERE name='$name'";
-
-		sql_query($query) or die("Query error: " . mysql_error());
-		return mysql_insert_id();
-	}
-
-	/**
-	 * Error message
-	 * @param string $msg message that will be shown
-	 */
-	function error($msg) {
-		$this->pagehead();
-		?>
-		<h2>Error!</h2>
-		<?php		echo $msg;
-		echo "<br />";
-		echo "<a href='index.php' onclick='history.back()'>"._BACK."</a>";
-		$this->pagefoot();
-		exit;
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function disallow() {
-		ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
-
-		$this->error(_ERROR_DISALLOWED);
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function pagehead($extrahead = '') {
-		global $member, $nucleus, $CONF, $manager;
-
-		$manager->notify(
-			'AdminPrePageHead',
-			array(
-				'extrahead' => &$extrahead,
-				'action' => $this->action
-			)
-		);
-
-		$baseUrl = htmlspecialchars($CONF['AdminURL']);
-
-		?>
-		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-		<html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>
-		<head>
-			<meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
-			<title><?php echo htmlspecialchars($CONF['SiteName'])?> - Admin</title>
-			<link rel="stylesheet" title="Nucleus Admin Default" type="text/css" href="<?php echo $baseUrl?>styles/admin.css" />
-			<link rel="stylesheet" title="Nucleus Admin Default" type="text/css"
-			href="<?php echo $baseUrl?>styles/addedit.css" />
-
-			<script type="text/javascript" src="<?php echo $baseUrl?>javascript/edit.js"></script>
-			<script type="text/javascript" src="<?php echo $baseUrl?>javascript/admin.js"></script>
-			<script type="text/javascript" src="<?php echo $baseUrl?>javascript/compatibility.js"></script>
-
-	  <meta http-equiv='Pragma' content='no-cache' />
-	  <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />
-	  <meta http-equiv='Expires' content='-1' />
-
-			<?php echo $extrahead?>
-		</head>
-		<body>
-		<div class="header">
-		<h1><?php echo htmlspecialchars($CONF['SiteName'])?></h1>
-		</div>
-		<div id="container">
-		<div id="content">
-		<div class="loginname">
-		<?php			if ($member->isLoggedIn())
-				echo _LOGGEDINAS . ' ' . $member->getDisplayName()
-					." - <a href='index.php?action=logout'>" . _LOGOUT. "</a>"
-					. "<br /><a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
-			else
-				echo '<a href="index.php?action=showlogin" title="Log in">' , _NOTLOGGEDIN , '</a> <br />';
-
-			echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a>";
-
-			echo '<br />(';
-
-			$codenamestring = ($nucleus['codename']!='')? ' &quot;'.$nucleus['codename'].'&quot;':'';
-
-			if ($member->isLoggedIn() && $member->isAdmin()) {
-				$checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
-				echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
-			} else {
-				echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
-			}
-			echo ')';
-		echo '</div>';
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function pagefoot() {
-		global $action, $member, $manager;
-
-		$manager->notify(
-			'AdminPrePageFoot',
-			array(
-				'action' => $this->action
-			)
-		);
-
-		if ($member->isLoggedIn() && ($action != 'showlogin')) {
-			?>
-			<h2><?php echo  _LOGOUT ?></h2>
-			<ul>
-				<li><a href="index.php?action=overview"><?php echo  _BACKHOME?></a></li>
-				<li><a href='index.php?action=logout'><?php echo  _LOGOUT?></a></li>
-			</ul>
-			<?php		}
-		?>
-			<div class="foot">
-				<a href="<?php echo _ADMINPAGEFOOT_OFFICIALURL ?>">Nucleus CMS</a> &copy; 2002-<?php echo date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT; ?>
-				-
-				<a href="<?php echo _ADMINPAGEFOOT_DONATEURL ?>"><?php echo _ADMINPAGEFOOT_DONATE ?></a>
-			</div>
-
-			</div><!-- content -->
-
-			<div id="quickmenu">
-
-				<?php				// ---- user settings ----
-				if (($action != 'showlogin') && ($member->isLoggedIn())) {
-					echo '<ul>';
-					echo '<li><a href="index.php?action=overview">',_QMENU_HOME,'</a></li>';
-					echo '</ul>';
-
-					echo '<h2>',_QMENU_ADD,'</h2>';
-					echo '<form method="get" action="index.php"><div>';
-					echo '<input type="hidden" name="action" value="createitem" />';
-
-						$showAll = requestVar('showall');
-						if (($member->isAdmin()) && ($showAll == 'yes')) {
-							// Super-Admins have access to all blogs! (no add item support though)
-							$query =  'SELECT bnumber as value, bname as text'
-								   . ' FROM ' . sql_table('blog')
-								   . ' ORDER BY bname';
-						} else {
-							$query =  'SELECT bnumber as value, bname as text'
-								   . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
-								   . ' WHERE tblog=bnumber and tmember=' . $member->getID()
-								   . ' ORDER BY bname';
-						}
-						$template['name'] = 'blogid';
-						$template['tabindex'] = 15000;
-						$template['extra'] = _QMENU_ADD_SELECT;
-						$template['selected'] = -1;
-						$template['shorten'] = 10;
-						$template['shortenel'] = '';
-						$template['javascript'] = 'onchange="return form.submit()"';
-						showlist($query,'select',$template);
-
-					echo '</div></form>';
-
-					echo '<h2>' . $member->getDisplayName(). '</h2>';
-					echo '<ul>';
-					echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . '</a></li>';
-					echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . '</a></li>';
-					echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . '</a></li>';
-					echo '</ul>';
-
-
-
-
-					// ---- general settings ----
-					if ($member->isAdmin()) {
-
-						echo '<h2>',_QMENU_MANAGE,'</h2>';
-
-						echo '<ul>';
-						echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . '</a></li>';
-						echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . '</a></li>';
-						echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . '</a></li>';
-						echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . '</a></li>';
-						echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . '</a></li>';
-						echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . '</a></li>';
-						echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . '</a></li>';
-						echo '</ul>';
-
-						echo '<h2>',_QMENU_LAYOUT,'</h2>';
-						echo '<ul>';
-						echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . '</a></li>';
-						echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . '</a></li>';
-						echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . '</a></li>';
-						echo '</ul>';
-
-					}
-
-					$aPluginExtras = array();
-					$manager->notify(
-						'QuickMenu',
-						array(
-							'options' => &$aPluginExtras
-						)
-					);
-					if (count($aPluginExtras) > 0)
-					{
-						echo '<h2>', _QMENU_PLUGINS, '</h2>';
-						echo '<ul>';
-						foreach ($aPluginExtras as $aInfo)
-						{
-							echo '<li><a href="'.htmlspecialchars($aInfo['url']).'" title="'.htmlspecialchars($aInfo['tooltip']).'">'.htmlspecialchars($aInfo['title']).'</a></li>';
-						}
-						echo '</ul>';
-					}
-
-				} else if (($action == 'activate') || ($action == 'activatesetpwd')) {
-
-					echo '<h2>', _QMENU_ACTIVATE, '</h2>', _QMENU_ACTIVATE_TEXT;
-				} else {
-					// introduction text on login screen
-					echo '<h2>', _QMENU_INTRO, '</h2>', _QMENU_INTRO_TEXT;
-				}
-				?>
-			</div>
-
-			<!-- content / quickmenu container -->
-			</div>
-
-
-			</body>
-			</html>
-		<?php	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_regfile() {
-		global $member, $CONF;
-
-		$blogid = intRequestVar('blogid');
-
-		$member->teamRights($blogid) or $this->disallow();
-
-		// header-code stolen from phpMyAdmin
-		// REGEDIT and bookmarklet code stolen from GreyMatter
-
-		$sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
-
-		header('Content-Type: application/octetstream');
-		header('Content-Disposition: filename="nucleus.reg"');
-		header('Pragma: no-cache');
-		header('Expires: 0');
-
-		echo "REGEDIT4\n";
-		echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
-		echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
-		echo '"contexts"=hex:31';
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_bookmarklet() {
-		global $member, $manager;
-
-		$blogid = intRequestVar('blogid');
-
-		$member->teamRights($blogid) or $this->disallow();
-
-		$blog =& $manager->getBlog($blogid);
-		$bm = getBookmarklet($blogid);
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-
-		?>
-
-		<h2><?php echo _BOOKMARKLET_TITLE ?></h2>
-
-		<p>
-		<?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
-		</p>
-
-		<h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
-		<p>
-			<?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
-			<br />
-			<br />
-			<?php echo '<a href="' . htmlspecialchars($bm, ENT_QUOTES) . '">' . sprintf(_BOOKMARKLET_ANCHOR, htmlspecialchars($blog->getName(), ENT_QUOTES)) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
-		</p>
-
-		<h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
-		<p>
-			<?php
-				$url = 'index.php?action=regfile&blogid=' . intval($blogid);
-				$url = $manager->addTicketToUrl($url);
-			?>
-			<?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . htmlspecialchars($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
-		</p>
-
-		<p>
-			<?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
-		</p>
-
-		<h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
-		<p>
-			<?php echo _BOOKMARKLET_DELETEBAR ?>
-		</p>
-
-		<p>
-			<?php echo _BOOKMARKLET_DELETERIGHTT ?>
-		</p>
-
-		<ol>
-			<li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
-			<li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
-			<li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
-			<li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
-			<li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
-		</ol>
-
-		<?php
-		$this->pagefoot();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_actionlog() {
-		global $member, $manager;
-
-		$member->isAdmin() or $this->disallow();
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-		$url = $manager->addTicketToUrl('index.php?action=clearactionlog');
-
-		?>
-			<h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
-			<p><a href="<?php echo htmlspecialchars($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
-		<?php
-		echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
-
-		$query =  'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
-		$template['content'] = 'actionlist';
-		$amount = showlist($query,'table',$template);
-
-		$this->pagefoot();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_banlist() {
-		global $member, $manager;
-
-		$blogid = intRequestVar('blogid');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$blog =& $manager->getBlog($blogid);
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-
-		echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
-
-		$query =  'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
-		$template['content'] = 'banlist';
-		$amount = showlist($query,'table',$template);
-
-		if ($amount == 0)
-			echo _BAN_NONE;
-
-		echo '<h2>'._BAN_NEW_TITLE.'</h2>';
-		echo "<p><a href='index.php?action=banlistnew&amp;blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
-
-
-		$this->pagefoot();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_banlistdelete() {
-		global $member, $manager;
-
-		$blogid = intRequestVar('blogid');
-		$iprange = requestVar('iprange');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$blog =& $manager->getBlog($blogid);
-		$banBlogName =  htmlspecialchars($blog->getName(), ENT_QUOTES);
-
-		$this->pagehead();
-		?>
-			<h2><?php echo _BAN_REMOVE_TITLE?></h2>
-
-			<form method="post" action="index.php">
-
-			<h3><?php echo _BAN_IPRANGE?></h3>
-
-			<p>
-				<?php echo _CONFIRMTXT_BAN?> <?php echo htmlspecialchars($iprange) ?>
-				<input name="iprange" type="hidden" value="<?php echo htmlspecialchars($iprange)?>" />
-			</p>
-
-			<h3><?php echo _BAN_BLOGS?></h3>
-
-			<div>
-				<input type="hidden" name="blogid" value="<?php echo $blogid?>" />
-				<input name="allblogs" type="radio" value="0" id="allblogs_one" />
-				<label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
-				<br />
-				<input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
-			</div>
-
-			<h3><?php echo _BAN_DELETE_TITLE?></h3>
-
-			<div>
-				<?php $manager->addTicketHidden() ?>
-				<input type="hidden" name="action" value="banlistdeleteconfirm" />
-				<input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-			</div>
-
-			</form>
-		<?php
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_banlistdeleteconfirm() {
-		global $member, $manager;
-
-		$blogid = intPostVar('blogid');
-		$allblogs = postVar('allblogs');
-		$iprange = postVar('iprange');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$deleted = array();
-
-		if (!$allblogs) {
-			if (BAN::removeBan($blogid, $iprange))
-				array_push($deleted, $blogid);
-		} else {
-			// get blogs fot which member has admin rights
-			$adminblogs = $member->getAdminBlogs();
-			foreach ($adminblogs as $blogje) {
-				if (BAN::removeBan($blogje, $iprange))
-					array_push($deleted, $blogje);
-			}
-		}
-
-		if (sizeof($deleted) == 0)
-			$this->error(_ERROR_DELETEBAN);
-
-		$this->pagehead();
-
-		echo '<a href="index.php?action=banlist&amp;blogid=',$blogid,'">(',_BACK,')</a>';
-		echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
-		echo "<p>"._BAN_REMOVED_TEXT."</p>";
-
-		echo "<ul>";
-		foreach ($deleted as $delblog) {
-			$b =& $manager->getBlog($delblog);
-			echo "<li>" . htmlspecialchars($b->getName()). "</li>";
-		}
-		echo "</ul>";
-
-		$this->pagefoot();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_banlistnewfromitem() {
-		$this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_banlistnew($blogid = '') {
-		global $member, $manager;
-
-		if ($blogid == '')
-			$blogid = intRequestVar('blogid');
-
-		$ip = requestVar('ip');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		$blog =& $manager->getBlog($blogid);
-
-		$this->pagehead();
-		?>
-		<h2><?php echo _BAN_ADD_TITLE?></h2>
-
-
-		<form method="post" action="index.php">
-
-		<h3><?php echo _BAN_IPRANGE?></h3>
-
-		<p><?php echo _BAN_IPRANGE_TEXT?></p>
-
-		<div class="note">
-			<strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
-			<?php echo _BAN_EXAMPLE_TEXT ?>
-		</div>
-
-		<div>
-		<?php
-		if ($ip) {
-			$iprangeVal = htmlspecialchars($ip, ENT_QUOTES);
-		?>
-			<input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
-			<label for="ip_fixed"><?php echo $iprangeVal ?></label>
-			<br />
-			<input name="iprange" type="radio" value="custom" id="ip_custom" />
-			<label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
-			<input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
-		<?php
-		} else {
-			echo "<input name='iprange' value='custom' type='hidden' />";
-			echo "<input name='customiprange' value='' maxlength='15' size='15' />";
-		}
-		?>
-		</div>
-
-		<h3><?php echo _BAN_BLOGS?></h3>
-
-		<p><?php echo _BAN_BLOGS_TEXT?></p>
-
-		<div>
-			<input type="hidden" name="blogid" value="<?php echo $blogid?>" />
-			<input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo htmlspecialchars($blog->getName())?>'</label>
-			<br />
-			<input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
-		</div>
-
-		<h3><?php echo _BAN_REASON_TITLE?></h3>
-
-		<p><?php echo _BAN_REASON_TEXT?></p>
-
-		<div><textarea name="reason" cols="40" rows="5"></textarea></div>
-
-		<h3><?php echo _BAN_ADD_TITLE?></h3>
-
-		<div>
-			<input name="action" type="hidden" value="banlistadd" />
-			<?php $manager->addTicketHidden() ?>
-			<input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
-		</div>
-
-		</form>
-
-		<?php		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_banlistadd() {
-		global $member;
-
-		$blogid = 		intPostVar('blogid');
-		$allblogs = 	postVar('allblogs');
-		$iprange = 		postVar('iprange');
-		if ($iprange == "custom")
-			$iprange = postVar('customiprange');
-		$reason = 		postVar('reason');
-
-		$member->blogAdminRights($blogid) or $this->disallow();
-
-		// TODO: check IP range validity
-
-		if (!$allblogs) {
-			if (!BAN::addBan($blogid, $iprange, $reason))
-				$this->error(_ERROR_ADDBAN);
-		} else {
-			// get blogs fot which member has admin rights
-			$adminblogs = $member->getAdminBlogs();
-			$failed = 0;
-			foreach ($adminblogs as $blogje) {
-				if (!BAN::addBan($blogje, $iprange, $reason))
-					$failed = 1;
-			}
-			if ($failed)
-				$this->error(_ERROR_ADDBAN);
-		}
-
-		$this->action_banlist();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_clearactionlog() {
-		global $member;
-
-		$member->isAdmin() or $this->disallow();
-
-		ACTIONLOG::clear();
-
-		$this->action_manage(_MSG_ACTIONLOGCLEARED);
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_backupoverview() {
-		global $member, $manager;
-
-		$member->isAdmin() or $this->disallow();
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-		?>
-		<h2><?php echo _BACKUPS_TITLE?></h2>
-
-		<h3><?php echo _BACKUP_TITLE?></h3>
-
-		<p><?php echo _BACKUP_INTRO?></p>
-
-		<form method="post" action="index.php"><p>
-		<input type="hidden" name="action" value="backupcreate" />
-		<?php $manager->addTicketHidden() ?>
-
-		<input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
-		<br />
-		<input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
-		<br /><br />
-		<input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
-
-		</p></form>
-
-		<div class="note"><?php echo _BACKUP_NOTE?></div>
-
-
-		<h3><?php echo _RESTORE_TITLE?></h3>
-
-		<div class="note"><?php echo _RESTORE_NOTE?></div>
-
-		<p><?php echo _RESTORE_INTRO?></p>
-
-		<form method="post" action="index.php" enctype="multipart/form-data"><p>
-			<input type="hidden" name="action" value="backuprestore" />
-			<?php $manager->addTicketHidden() ?>
-			<input name="backup_file" type="file" tabindex="30" />
-			<br /><br />
-			<input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
-			<br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
-			<br /><?php echo _RESTORE_WARNING?>
-		</p></form>
-
-		<?php		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_backupcreate() {
-		global $member, $DIR_LIBS;
-
-		$member->isAdmin() or $this->disallow();
-
-		// use compression ?
-		$useGzip = intval(postVar('gzip'));
-
-		include($DIR_LIBS . 'backup.php');
-
-		// try to extend time limit
-		// (creating/restoring dumps might take a while)
-		@set_time_limit(1200);
-
-		$bu = new Backup();
-		$bu->do_backup($useGzip);
-		exit;
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_backuprestore() {
-		global $member, $DIR_LIBS;
-
-		$member->isAdmin() or $this->disallow();
-
-		if (intPostVar('letsgo') != 1)
-			$this->error(_ERROR_BACKUP_NOTSURE);
-
-		include($DIR_LIBS . 'backup.php');
-
-		// try to extend time limit
-		// (creating/restoring dumps might take a while)
-		@set_time_limit(1200);
-
-		$bu = new Backup();
-		$message = $bu->do_restore();
-		if ($message != '')
-			$this->error($message);
-
-		$this->pagehead();
-		?>
-		<h2><?php echo _RESTORE_COMPLETE?></h2>
-		<?php		$this->pagefoot();
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_pluginlist() {
-		global $member, $manager;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-		echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
-
-		echo '<h3>' , _PLUGS_TITLE_INSTALLED , '</h3>';
-
-
-		$query =  'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
-
-		$template['content'] = 'pluginlist';
-		$template['tabindex'] = 10;
-		showlist($query, 'table', $template);
-
-		?>
-			<h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
-
-			<p><?php echo _PLUGS_TEXT_UPDATE?></p>
-
-			<form method="post" action="index.php"><div>
-				<input type="hidden" name="action" value="pluginupdate" />
-				<?php $manager->addTicketHidden() ?>
-				<input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
-			</div></form>
-
-			<h3><?php echo _PLUGS_TITLE_NEW?></h3>
-
-			<?php				// find a list of possibly non-installed plugins
-				$candidates = array();
-				global $DIR_PLUGINS;
-				$dirhandle = opendir($DIR_PLUGINS);
-				while ($filename = readdir($dirhandle)) {
-					if (ereg('^NP_(.*)\.php$',$filename,$matches)) {
-						$name = $matches[1];
-						// only show in list when not yet installed
-						$res = sql_query('SELECT * FROM '.sql_table('plugin').' WHERE pfile="NP_'.addslashes($name).'"');
-						if (mysql_num_rows($res) == 0)
-							array_push($candidates,$name);
-					}
-				}
-				closedir($dirhandle);
-
-				if (sizeof($candidates) > 0) {
-			?>
-
-			<p><?php echo _PLUGS_ADD_TEXT?></p>
-
-
-			<form method='post' action='index.php'><div>
-				<input type='hidden' name='action' value='pluginadd' />
-				<?php $manager->addTicketHidden() ?>
-				<select name="filename" tabindex="30">
-				<?php					foreach($candidates as $name)
-						echo '<option value="NP_',$name,'">',htmlspecialchars($name),'</option>';
-				?>
-				</select>
-				<input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
-			</div></form>
-
-		<?php			} else {	// sizeof(candidates) == 0
-				echo '<p>',_PLUGS_NOCANDIDATES,'</p>';
-			}
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_pluginhelp() {
-		global $member, $manager, $DIR_PLUGINS, $CONF;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		$plugid = intGetVar('plugid');
-
-		if (!$manager->pidInstalled($plugid))
-			$this->error(_ERROR_NOSUCHPLUGIN);
-
-		$plugName = getPluginNameFromPid($plugid);
-
-		$this->pagehead();
-
-		echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
-
-		echo '<h2>',_PLUGS_HELP_TITLE,': ',htmlspecialchars($plugName),'</h2>';
-
-		$plug =& $manager->getPlugin($plugName);
-		$helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
-
-		if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
-			@readfile($helpFile);
-		} else {
-			echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
-			echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
-		}
-
-
-		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_pluginadd() {
-		global $member, $manager, $DIR_PLUGINS;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		$name = postVar('filename');
-
-		if ($manager->pluginInstalled($name))
-			$this->error(_ERROR_DUPPLUGIN);
-		if (!checkPlugin($name))
-			$this->error(_ERROR_PLUGFILEERROR . ' (' . htmlspecialchars($name) . ')');
-
-		// get number of currently installed plugins
-		$res = sql_query('SELECT * FROM '.sql_table('plugin'));
-		$numCurrent = mysql_num_rows($res);
-
-		// plugin will be added as last one in the list
-		$newOrder = $numCurrent + 1;
-
-		$manager->notify(
-			'PreAddPlugin',
-			array(
-				'file' => &$name
-			)
-		);
-
-		// do this before calling getPlugin (in case the plugin id is used there)
-		$query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.addslashes($name).'")';
-		sql_query($query);
-		$iPid = mysql_insert_id();
-
-		$manager->clearCachedInfo('installedPlugins');
-
-		// Load the plugin for condition checking and instalation
-		$plugin =& $manager->getPlugin($name);
-
-		// check if it got loaded (could have failed)
-		if (!$plugin)
-		{
-			sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
-			$manager->clearCachedInfo('installedPlugins');
-			$this->error(_ERROR_PLUGIN_LOAD);
-		}
-
-		// check if plugin needs a newer Nucleus version
-		if (getNucleusVersion() < $plugin->getMinNucleusVersion())
-		{
-			// uninstall plugin again...
-			$this->deleteOnePlugin($plugin->getID());
-
-			// ...and show error
-			$this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars($plugin->getMinNucleusVersion()));
-		}
-
-		// check if plugin needs a newer Nucleus version
-		if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
-		{
-			// uninstall plugin again...
-			$this->deleteOnePlugin($plugin->getID());
-
-			// ...and show error
-			$this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
-		}
-
-		$pluginList = $plugin->getPluginDep();
-		foreach ($pluginList as $pluginName)
-		{
-
-			$res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
-			if (mysql_num_rows($res) == 0)
-			{
-				// uninstall plugin again...
-				$this->deleteOnePlugin($plugin->getID());
-
-				$this->error(sprintf(_ERROR_INSREQPLUGIN, htmlspecialchars($pluginName, ENT_QUOTES)));
-			}
-		}
-
-		// call the install method of the plugin
-		$plugin->install();
-
-		$manager->notify(
-			'PostAddPlugin',
-			array(
-				'plugin' => &$plugin
-			)
-		);
-
-		// update all events
-		$this->action_pluginupdate();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_pluginupdate() {
-		global $member, $manager;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		// delete everything from plugin_events
-		sql_query('DELETE FROM '.sql_table('plugin_event'));
-
-		// loop over all installed plugins
-		$res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
-		while($o = mysql_fetch_object($res)) {
-			$pid = $o->pid;
-			$plug =& $manager->getPlugin($o->pfile);
-			if ($plug)
-			{
-				$eventList = $plug->getEventList();
-				foreach ($eventList as $eventName)
-					sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.addslashes($eventName).'\')');
-			}
-		}
+        </tr><tr>
+            <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
+        </tr><tr>
+            <td><?php echo _TEMPLATE_UPDATE?></td>
+            <td>
+                <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
+                <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
+            </td>
+        </tr></table>
+
+        </div>
+        </form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
+        static $count = 1;
+        if (!isset($template[$name])) $template[$name] = '';
+    ?>
+        </tr><tr>
+            <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
+            <td id="td<?php echo $count?>"><textarea class="templateedit" name="<?php echo $name?>" tabindex="<?php echo $tabindex?>" cols="50" rows="<?php echo $big?10:5?>" id="textarea<?php echo $count?>"><?php echo  htmlspecialchars($template[$name]); ?></textarea></td>
+    <?php       $count++;
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_templateupdate() {
+        global $member,$manager;
+
+        $templateid = intRequestVar('templateid');
+
+        $member->isAdmin() or $this->disallow();
+
+        $name = postVar('tname');
+        $desc = postVar('tdesc');
+
+        if (!isValidTemplateName($name))
+            $this->error(_ERROR_BADTEMPLATENAME);
+
+        if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
+            $this->error(_ERROR_DUPTEMPLATENAME);
+
+
+        $name = addslashes($name);
+        $desc = addslashes($desc);
+
+        // 1. Remove all template parts
+        $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
+        sql_query($query);
+
+        // 2. Update description
+        $query =  'UPDATE '.sql_table('template_desc').' SET'
+               . " tdname='" . $name . "',"
+               . " tddesc='" . $desc . "'"
+               . " WHERE tdnumber=" . $templateid;
+        sql_query($query);
+
+        // 3. Add non-empty template parts
+        $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
+        $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
+        $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
+        $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
+        $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
+        $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
+        $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
+        $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
+        $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
+        $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
+        $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
+        $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
+        $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
+        $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
+        $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
+        $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
+        $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
+        $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
+        $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
+        $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
+        $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
+        $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
+        $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
+        $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
+        $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
+        $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
+        $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
+        $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
+        $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
+        $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
+        $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
+        $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
+        $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
+        $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
+
+        $pluginfields = array();
+        $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
+        foreach ($pluginfields as $pfkey=>$pfvalue) {
+            foreach ($pfvalue as $pffield=>$pfdesc) {
+                $this->addToTemplate($templateid, $pffield, postVar($pffield));
+            }
+        }
+
+        // jump back to template edit
+        $this->action_templateedit(_TEMPLATE_UPDATED);
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function addToTemplate($id, $partname, $content) {
+        $partname = addslashes($partname);
+        $content = addslashes($content);
+
+        $id = intval($id);
+
+        // don't add empty parts:
+        if (!trim($content)) return -1;
+
+        $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
+               . "VALUES ($id, '$partname', '$content')";
+        sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
+        return sql_insert_id();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_templatedelete() {
+        global $member, $manager;
+
+        $member->isAdmin() or $this->disallow();
+
+        $templateid = intRequestVar('templateid');
+        // TODO: check if template can be deleted
+
+        $this->pagehead();
+
+        $name = TEMPLATE::getNameFromId($templateid);
+        $desc = TEMPLATE::getDesc($templateid);
+
+        ?>
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+
+            <p>
+            <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo htmlspecialchars($name)?></b> (<?php echo  htmlspecialchars($desc) ?>)
+            </p>
+
+            <form method="post" action="index.php"><div>
+                <input type="hidden" name="action" value="templatedeleteconfirm" />
+                <?php $manager->addTicketHidden() ?>
+                <input type="hidden" name="templateid" value="<?php echo  $templateid ?>" />
+                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_templatedeleteconfirm() {
+        global $member, $manager;
+
+        $templateid = intRequestVar('templateid');
+
+        $member->isAdmin() or $this->disallow();
+
+        $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
+
+        // 1. delete description
+        sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
+
+        // 2. delete parts
+        sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
+
+        $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
+
+        $this->action_templateoverview();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_templatenew() {
+        global $member;
+
+        $member->isAdmin() or $this->disallow();
+
+        $name = postVar('name');
+        $desc = postVar('desc');
+
+        if (!isValidTemplateName($name))
+            $this->error(_ERROR_BADTEMPLATENAME);
+
+        if (TEMPLATE::exists($name))
+            $this->error(_ERROR_DUPTEMPLATENAME);
+
+        $newTemplateId = TEMPLATE::createNew($name, $desc);
+
+        $this->action_templateoverview();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_templateclone() {
+        global $member;
+
+        $templateid = intRequestVar('templateid');
+
+        $member->isAdmin() or $this->disallow();
+
+        // 1. read old template
+        $name = TEMPLATE::getNameFromId($templateid);
+        $desc = TEMPLATE::getDesc($templateid);
+
+        // 2. create desc thing
+        $name = "cloned" . $name;
+
+        // if a template with that name already exists:
+        if (TEMPLATE::exists($name)) {
+            $i = 1;
+            while (TEMPLATE::exists($name . $i))
+                $i++;
+            $name .= $i;
+        }
+
+        $newid = TEMPLATE::createNew($name, $desc);
+
+        // 3. create clone
+        // go through parts of old template and add them to the new one
+        $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
+        while ($o = sql_fetch_object($res)) {
+            $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
+        }
+
+        $this->action_templateoverview();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinoverview() {
+        global $member, $manager;
+
+        $member->isAdmin() or $this->disallow();
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+
+        echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
+
+        echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
+
+        $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
+        $template['content'] = 'skinlist';
+        $template['tabindex'] = 10;
+        showlist($query,'table',$template);
+
+        echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
+
+        ?>
+        <form method="post" action="index.php">
+        <div>
+
+        <input name="action" value="skinnew" type="hidden" />
+        <?php $manager->addTicketHidden() ?>
+        <table><tr>
+            <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
+            <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
+        </tr><tr>
+            <td><?php echo _SKIN_DESC?></td>
+            <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
+        </tr><tr>
+            <td><?php echo _SKIN_CREATE?></td>
+            <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
+        </tr></table>
+
+        </div>
+        </form>
+
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinnew() {
+        global $member;
+
+        $member->isAdmin() or $this->disallow();
+
+        $name = trim(postVar('name'));
+        $desc = trim(postVar('desc'));
+
+        if (!isValidSkinName($name))
+            $this->error(_ERROR_BADSKINNAME);
+
+        if (SKIN::exists($name))
+            $this->error(_ERROR_DUPSKINNAME);
+
+        $newId = SKIN::createNew($name, $desc);
+
+        $this->action_skinoverview();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinedit() {
+        global $member, $manager;
+
+        $skinid = intRequestVar('skinid');
+
+        $member->isAdmin() or $this->disallow();
+
+        $skin =& new SKIN($skinid);
+
+        $this->pagehead();
+        ?>
+        <p>
+            <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
+        </p>
+        <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo  $skin->getName() ?>'</h2>
+
+        <h3><?php echo _SKIN_PARTS_TITLE?></h3>
+        <?php echo _SKIN_PARTS_MSG?>
+        <ul>
+            <li><a tabindex="10" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=index"><?php echo _SKIN_PART_MAIN?></a> <?php help('skinpartindex')?></li>
+            <li><a tabindex="20" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=item"><?php echo _SKIN_PART_ITEM?></a> <?php help('skinpartitem')?></li>
+            <li><a tabindex="30" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=archivelist"><?php echo _SKIN_PART_ALIST?></a> <?php help('skinpartarchivelist')?></li>
+            <li><a tabindex="40" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=archive"><?php echo _SKIN_PART_ARCHIVE?></a> <?php help('skinpartarchive')?></li>
+            <li><a tabindex="50" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=search"><?php echo _SKIN_PART_SEARCH?></a> <?php help('skinpartsearch')?></li>
+            <li><a tabindex="60" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=error"><?php echo _SKIN_PART_ERROR?></a> <?php help('skinparterror')?></li>
+            <li><a tabindex="70" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=member"><?php echo _SKIN_PART_MEMBER?></a> <?php help('skinpartmember')?></li>
+            <li><a tabindex="75" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=imagepopup"><?php echo _SKIN_PART_POPUP?></a> <?php help('skinpartimagepopup')?></li>
+        </ul>
+
+        <?php
+
+        $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
+        $res = sql_query($query);
+
+        echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
+        echo '<form method="get" action="index.php">' . "\r\n";
+        echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
+        echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
+        echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
+        echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
+        echo '</form>' . "\r\n";
+
+        if ($res && sql_num_rows($res) > 0) {
+            echo '<ul>';
+            $tabstart = 75;
+
+            while ($row = sql_fetch_assoc($res)) {
+                echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&amp;skinid=' . $skinid . '&amp;type=' . htmlspecialchars(strtolower($row['stype'])) . '">' . htmlspecialchars(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&amp;skinid=' . $skinid . '&amp;type=' . htmlspecialchars(strtolower($row['stype'])) . '">remove</a>)</li>';
+            }
+
+            echo '</ul>';
+        }
+
+        ?>
+
+        <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
+        <form method="post" action="index.php">
+        <div>
+
+        <input type="hidden" name="action" value="skineditgeneral" />
+        <?php $manager->addTicketHidden() ?>
+        <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
+        <table><tr>
+            <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
+            <td><input name="name" tabindex="90" value="<?php echo  htmlspecialchars($skin->getName()) ?>" maxlength="20" size="20" /></td>
+        </tr><tr>
+            <td><?php echo _SKIN_DESC?></td>
+            <td><input name="desc" tabindex="100" value="<?php echo  htmlspecialchars($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
+        </tr><tr>
+            <td><?php echo _SKIN_TYPE?></td>
+            <td><input name="type" tabindex="110" value="<?php echo  htmlspecialchars($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
+        </tr><tr>
+            <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
+            <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
+        </tr><tr>
+            <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
+            <td><input name="inc_prefix" tabindex="130" value="<?php echo  htmlspecialchars($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
+        </tr><tr>
+            <td><?php echo _SKIN_CHANGE?></td>
+            <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
+        </tr></table>
+
+        </div>
+        </form>
+
+
+        <?php       $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skineditgeneral() {
+        global $member;
+
+        $skinid = intRequestVar('skinid');
+
+        $member->isAdmin() or $this->disallow();
+
+        $name = postVar('name');
+        $desc = postVar('desc');
+        $type = postVar('type');
+        $inc_mode = postVar('inc_mode');
+        $inc_prefix = postVar('inc_prefix');
+
+        $skin =& new SKIN($skinid);
+
+        // 1. Some checks
+        if (!isValidSkinName($name))
+            $this->error(_ERROR_BADSKINNAME);
+
+        if (($skin->getName() != $name) && SKIN::exists($name))
+            $this->error(_ERROR_DUPSKINNAME);
+
+        if (!$type) $type = 'text/html';
+        if (!$inc_mode) $inc_mode = 'normal';
+
+        // 2. Update description
+        $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
+
+        $this->action_skinedit();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinedittype($msg = '') {
+        global $member, $manager;
+
+        $skinid = intRequestVar('skinid');
+        $type = requestVar('type');
+
+        $member->isAdmin() or $this->disallow();
+
+        $type = trim($type);
+        $type = strtolower($type);
+
+        if (!isValidShortName($type)) {
+            $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
+        }
+
+        $skin =& new SKIN($skinid);
+
+        $friendlyNames = SKIN::getFriendlyNames();
+
+        $this->pagehead();
+        ?>
+        <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
+
+        <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo htmlspecialchars($skin->getName()) ?>': <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
+
+        <?php           if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
+        ?>
+
+
+        <form method="post" action="index.php">
+        <div>
+
+        <input type="hidden" name="action" value="skinupdate" />
+        <?php $manager->addTicketHidden() ?>
+        <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
+        <input type="hidden" name="type" value="<?php echo  $type ?>" />
+
+        <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
+        <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
+        (skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
+        <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
+            help('skinpart' . $type);
+        } else {
+            help('skinpartspecial');
+        }?>
+        <br />
+
+        <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo  htmlspecialchars($skin->getContent($type)) ?></textarea>
+
+        <br />
+        <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
+        <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
+        (skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
+
+        <br /><br />
+        <?php echo _SKIN_ALLOWEDVARS?>
+        <?php           $actions = SKIN::getAllowedActionsForType($type);
+
+            sort($actions);
+
+            while ($current = array_shift($actions)) {
+                // skip deprecated vars
+                if ($current == 'ifcat') continue;
+                if ($current == 'imagetext') continue;
+                if ($current == 'vars') continue;
+
+                echo helplink('skinvar-' . $current) . "$current</a>";
+                if (count($actions) != 0) echo ", ";
+            }
+        echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
+        $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
+        showlist($query,'table',array('content'=>'shortblognames'));
+        echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
+        $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
+        showlist($query,'table',array('content'=>'shortnames'));
+        echo '</div></form>';
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinupdate() {
+        global $member;
+
+        $skinid = intRequestVar('skinid');
+        $content = trim(postVar('content'));
+        $type = postVar('type');
+
+        $member->isAdmin() or $this->disallow();
+
+        $skin =& new SKIN($skinid);
+        $skin->update($type, $content);
+
+        $this->action_skinedittype(_SKIN_UPDATED);
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skindelete() {
+        global $member, $manager, $CONF;
+
+        $skinid = intRequestVar('skinid');
+
+        $member->isAdmin() or $this->disallow();
+
+        // don't allow default skin to be deleted
+        if ($skinid == $CONF['BaseSkin'])
+            $this->error(_ERROR_DEFAULTSKIN);
+
+        // don't allow deletion of default skins for blogs
+        $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
+        $r = sql_query($query);
+        if ($o = sql_fetch_object($r))
+            $this->error(_ERROR_SKINDEFDELETE . htmlspecialchars($o->bname));
+
+        $this->pagehead();
+
+        $skin =& new SKIN($skinid);
+        $name = $skin->getName();
+        $desc = $skin->getDescription();
+
+        ?>
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+
+            <p>
+                <?php echo _CONFIRMTXT_SKIN?><b><?php echo htmlspecialchars($name) ?></b> (<?php echo  htmlspecialchars($desc)?>)
+            </p>
+
+            <form method="post" action="index.php"><div>
+                <input type="hidden" name="action" value="skindeleteconfirm" />
+                <?php $manager->addTicketHidden() ?>
+                <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
+                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skindeleteconfirm() {
+        global $member, $CONF, $manager;
+
+        $skinid = intRequestVar('skinid');
+
+        $member->isAdmin() or $this->disallow();
+
+        // don't allow default skin to be deleted
+        if ($skinid == $CONF['BaseSkin'])
+            $this->error(_ERROR_DEFAULTSKIN);
+
+        // don't allow deletion of default skins for blogs
+        $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
+        $r = sql_query($query);
+        if ($o = sql_fetch_object($r))
+            $this->error(_ERROR_SKINDEFDELETE .$o->bname);
+
+        $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
+
+        // 1. delete description
+        sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
+
+        // 2. delete parts
+        sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
+
+        $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
+
+        $this->action_skinoverview();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinremovetype() {
+        global $member, $manager, $CONF;
+
+        $skinid = intRequestVar('skinid');
+        $skintype = requestVar('type');
+
+        if (!isValidShortName($skintype)) {
+            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+        }
+
+        $member->isAdmin() or $this->disallow();
+
+        // don't allow default skinparts to be deleted
+        if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
+            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+        }
+
+        $this->pagehead();
+
+        $skin =& new SKIN($skinid);
+        $name = $skin->getName();
+        $desc = $skin->getDescription();
+
+        ?>
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+
+            <p>
+                <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo htmlspecialchars($skintype); ?> (<?php echo htmlspecialchars($name); ?>)</b> (<?php echo  htmlspecialchars($desc)?>)
+            </p>
+
+            <form method="post" action="index.php"><div>
+                <input type="hidden" name="action" value="skinremovetypeconfirm" />
+                <?php $manager->addTicketHidden() ?>
+                <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
+                <input type="hidden" name="type" value="<?php echo htmlspecialchars($skintype); ?>" />
+                <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinremovetypeconfirm() {
+        global $member, $CONF, $manager;
+
+        $skinid = intRequestVar('skinid');
+        $skintype = requestVar('type');
+
+        if (!isValidShortName($skintype)) {
+            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+        }
+
+        $member->isAdmin() or $this->disallow();
+
+        // don't allow default skinparts to be deleted
+        if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
+            $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
+        }
+
+        $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
+
+        // delete part
+        sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
+
+        $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
+
+        $this->action_skinedit();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_skinclone() {
+        global $member;
+
+        $skinid = intRequestVar('skinid');
+
+        $member->isAdmin() or $this->disallow();
+
+        // 1. read skin to clone
+        $skin =& new SKIN($skinid);
+
+        $name = "clone_" . $skin->getName();
+
+        // if a skin with that name already exists:
+        if (SKIN::exists($name)) {
+            $i = 1;
+            while (SKIN::exists($name . $i))
+                $i++;
+            $name .= $i;
+        }
+
+        // 2. create skin desc
+        $newid = SKIN::createNew(
+            $name,
+            $skin->getDescription(),
+            $skin->getContentType(),
+            $skin->getIncludeMode(),
+            $skin->getIncludePrefix()
+        );
+
+
+        // 3. clone
+        /*
+        $this->skinclonetype($skin, $newid, 'index');
+        $this->skinclonetype($skin, $newid, 'item');
+        $this->skinclonetype($skin, $newid, 'archivelist');
+        $this->skinclonetype($skin, $newid, 'archive');
+        $this->skinclonetype($skin, $newid, 'search');
+        $this->skinclonetype($skin, $newid, 'error');
+        $this->skinclonetype($skin, $newid, 'member');
+        $this->skinclonetype($skin, $newid, 'imagepopup');
+        */
+
+        $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
+        $res = sql_query($query);
+        while ($row = sql_fetch_assoc($res)) {
+            $this->skinclonetype($skin, $newid, $row['stype']);
+        }
+
+        $this->action_skinoverview();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function skinclonetype($skin, $newid, $type) {
+        $newid = intval($newid);
+        $content = $skin->getContent($type);
+        if ($content) {
+            $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". addslashes($content)."', '". addslashes($type)."')";
+            sql_query($query);
+        }
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_settingsedit() {
+        global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
+
+        $member->isAdmin() or $this->disallow();
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+        ?>
+
+        <h2><?php echo _SETTINGS_TITLE?></h2>
+
+        <form action="index.php" method="post">
+        <div>
+
+        <input type="hidden" name="action" value="settingsupdate" />
+        <?php $manager->addTicketHidden() ?>
+
+        <table><tr>
+            <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
+        </tr><tr>
+            <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
+            <td>
+                <?php
+                    $query =  'SELECT bname as text, bnumber as value'
+                           . ' FROM '.sql_table('blog');
+                    $template['name'] = 'DefaultBlog';
+                    $template['selected'] = $CONF['DefaultBlog'];
+                    $template['tabindex'] = 10;
+                    showlist($query,'select',$template);
+                ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
+            <td>
+                <?php
+                    $query =  'SELECT sdname as text, sdnumber as value'
+                           . ' FROM '.sql_table('skin_desc');
+                    $template['name'] = 'BaseSkin';
+                    $template['selected'] = $CONF['BaseSkin'];
+                    $template['tabindex'] = 1;
+                    showlist($query,'select',$template);
+                ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_ADMINMAIL?></td>
+            <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo  htmlspecialchars($CONF['AdminEmail']) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_SITENAME?></td>
+            <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo  htmlspecialchars($CONF['SiteName']) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_SITEURL?></td>
+            <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo  htmlspecialchars($CONF['IndexURL']) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_ADMINURL?></td>
+            <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo  htmlspecialchars($CONF['AdminURL']) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
+            <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo  htmlspecialchars($CONF['PluginURL']) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
+            <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo  htmlspecialchars($CONF['SkinsURL']) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
+            <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo  htmlspecialchars($CONF['ActionURL']) ?>" /></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>
+            </td>
+            <td>
+
+                <select name="Language" tabindex="10050">
+                <?php               // show a dropdown list of all available languages
+                global $DIR_LANG;
+                $dirhandle = opendir($DIR_LANG);
+                while ($filename = readdir($dirhandle)) {
+                    if (ereg("^(.*)\.php$",$filename,$matches)) {
+                        $name = $matches[1];
+                        echo "<option value='$name'";
+                        if ($name == $CONF['Language'])
+                            echo " selected='selected'";
+                        echo ">$name</option>";
+                    }
+                }
+                closedir($dirhandle);
 
-		redirect('?action=pluginlist');
-//		$this->action_pluginlist();
-	}
+                ?>
+                </select>
 
-	/**
-	 * @todo document this
-	 */
-	function action_plugindelete() {
-		global $member, $manager;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		$pid = intGetVar('plugid');
-
-		if (!$manager->pidInstalled($pid))
-			$this->error(_ERROR_NOSUCHPLUGIN);
-
-		$this->pagehead();
-		?>
-			<h2><?php echo _DELETE_CONFIRM?></h2>
-
-			<p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
-
-			<form method="post" action="index.php"><div>
-			<?php $manager->addTicketHidden() ?>
-			<input type="hidden" name="action" value="plugindeleteconfirm" />
-			<input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
-			<input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-			</div></form>
-		<?php		$this->pagefoot();
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_plugindeleteconfirm() {
-		global $member, $manager;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		$pid = intPostVar('plugid');
-
-		$error = $this->deleteOnePlugin($pid, 1);
-		if ($error) {
-			$this->error($error);
-		}
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
+            </td>
+            <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
+                    <br />
+                <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo  htmlspecialchars($CONF['DisableSiteURL'])?>" />
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_DIRS?></td>
+            <td><?php echo  htmlspecialchars($DIR_NUCLEUS) ?>
+                <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_DBLOGIN?></td>
+            <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
+        </tr><tr>
+            <td>
+            <?php
+                echo _SETTINGS_JSTOOLBAR
+                /* =_SETTINGS_DISABLEJS
+
+                    I temporary changed the meaning of DisableJsTools, until I can find a good
+                    way to select the javascript version to use
+
+                    now, its:
+                        0 : IE
+                        1 : all javascript disabled
+                        2 : 'simpler' javascript (for mozilla/opera/mac)
+                */
+               ?>
+            </td>
+            <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
+                <select name="DisableJsTools" tabindex="10075">
+            <?php                   $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
+                    echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
+                    $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
+                    echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
+                    $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
+                    echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
+            ?>
+                </select>
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
+                       <td><?php
+
+                       $this->input_yesno('URLMode',$CONF['URLMode'],10077,
+                              'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
+
+                       echo ' ', _SETTINGS_URLMODE_HELP;
+
+                             ?>
+
+                       </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
+                       <td><?php
+
+                        $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
+
+                             ?>
+
+                       </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
+            <td>
+            <?php
+                if (!array_key_exists('DefaultListSize',$CONF)) {
+                    sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
+                    $CONF['DefaultListSize'] = 10;
+                }
+            ?>
+                <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo  htmlspecialchars((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
+            </td>
+        </tr><tr>
+            <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
+        </tr><tr>
+            <td><?php echo _SETTINGS_MEDIADIR?></td>
+            <td><?php echo  htmlspecialchars($DIR_MEDIA) ?>
+                <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
+                <?php                   if (!is_dir($DIR_MEDIA))
+                        echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
+                    if (!is_readable($DIR_MEDIA))
+                        echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
+                    if (!is_writeable($DIR_MEDIA))
+                        echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
+                ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_MEDIAURL?></td>
+            <td>
+                <input name="MediaURL" tabindex="10080" size="40" value="<?php echo  htmlspecialchars($CONF['MediaURL']) ?>" />
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
+            <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
+            <td>
+                <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo  htmlspecialchars($CONF['AllowedTypes']) ?>" />
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
+            <td>
+                <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo  htmlspecialchars($CONF['MaxUploadSize']) ?>" />
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
+            <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
+
+        </tr><tr>
+            <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
+        </tr><tr>
+            <td><?php echo _SETTINGS_CHANGELOGIN?></td>
+            <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_ALLOWCREATE?>
+                <?php help('allowaccountcreation'); ?>
+            </td>
+            <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
+                <br /><?php echo _SETTINGS_NEWLOGIN2?>
+            </td>
+            <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_MEMBERMSGS?>
+                <?php help('messageservice'); ?>
+            </td>
+            <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_NONMEMBERMSGS?>
+                <?php help('messageservice'); ?>
+            </td>
+            <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
+                <?php help('protectmemnames'); ?>
+            </td>
+            <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
+            </td>
+
+
+
+        </tr><tr>
+            <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
+        </tr><tr>
+            <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
+            <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo  htmlspecialchars($CONF['CookiePrefix'])?>" /></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
+            <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo  htmlspecialchars($CONF['CookieDomain'])?>" /></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_COOKIEPATH?></td>
+            <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo  htmlspecialchars($CONF['CookiePath'])?>" /></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_COOKIESECURE?></td>
+            <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_COOKIELIFE?></td>
+            <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
+                              1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
+            </td>
+        </tr><tr>
+            <td><?php echo _SETTINGS_LASTVISIT?></td>
+            <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
+
+
+
+        </tr><tr>
+            <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
+        </tr><tr>
+            <td><?php echo _SETTINGS_UPDATE?></td>
+            <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
+        </tr></table>
+
+        </div>
+        </form>
+
+        <?php
+            echo '<h2>',_PLUGINS_EXTRA,'</h2>';
+
+            $manager->notify(
+                'GeneralSettingsFormExtras',
+                array()
+            );
+
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_settingsupdate() {
+        global $member, $CONF;
+
+        $member->isAdmin() or $this->disallow();
+
+        // check if email address for admin is valid
+        if (!isValidMailAddress(postVar('AdminEmail')))
+            $this->error(_ERROR_BADMAILADDRESS);
+
+
+        // save settings
+        $this->updateConfig('DefaultBlog',      postVar('DefaultBlog'));
+        $this->updateConfig('BaseSkin',         postVar('BaseSkin'));
+        $this->updateConfig('IndexURL',         postVar('IndexURL'));
+        $this->updateConfig('AdminURL',         postVar('AdminURL'));
+        $this->updateConfig('PluginURL',        postVar('PluginURL'));
+        $this->updateConfig('SkinsURL',         postVar('SkinsURL'));
+        $this->updateConfig('ActionURL',        postVar('ActionURL'));
+        $this->updateConfig('Language',         postVar('Language'));
+        $this->updateConfig('AdminEmail',       postVar('AdminEmail'));
+        $this->updateConfig('SessionCookie',    postVar('SessionCookie'));
+        $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
+        $this->updateConfig('AllowMemberMail',  postVar('AllowMemberMail'));
+        $this->updateConfig('NonmemberMail',    postVar('NonmemberMail'));
+        $this->updateConfig('ProtectMemNames',  postVar('ProtectMemNames'));
+        $this->updateConfig('SiteName',         postVar('SiteName'));
+        $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
+        $this->updateConfig('DisableSite',      postVar('DisableSite'));
+        $this->updateConfig('DisableSiteURL',   postVar('DisableSiteURL'));
+        $this->updateConfig('LastVisit',        postVar('LastVisit'));
+        $this->updateConfig('MediaURL',         postVar('MediaURL'));
+        $this->updateConfig('AllowedTypes',     postVar('AllowedTypes'));
+        $this->updateConfig('AllowUpload',      postVar('AllowUpload'));
+        $this->updateConfig('MaxUploadSize',    postVar('MaxUploadSize'));
+        $this->updateConfig('MediaPrefix',      postVar('MediaPrefix'));
+        $this->updateConfig('AllowLoginEdit',   postVar('AllowLoginEdit'));
+        $this->updateConfig('DisableJsTools',   postVar('DisableJsTools'));
+        $this->updateConfig('CookieDomain',     postVar('CookieDomain'));
+        $this->updateConfig('CookiePath',       postVar('CookiePath'));
+        $this->updateConfig('CookieSecure',     postVar('CookieSecure'));
+        $this->updateConfig('URLMode',          postVar('URLMode'));
+        $this->updateConfig('CookiePrefix',     postVar('CookiePrefix'));
+        $this->updateConfig('DebugVars',            postVar('DebugVars'));
+        $this->updateConfig('DefaultListSize',          postVar('DefaultListSize'));
+
+        // load new config and redirect (this way, the new language will be used is necessary)
+        // note that when changing cookie settings, this redirect might cause the user
+        // to have to log in again.
+        getConfig();
+        redirect($CONF['AdminURL'] . '?action=manage');
+        exit;
+
+    }
+
+    /**
+     *  Give an overview over the used system
+     */
+    function action_systemoverview() {
+        global $member, $nucleus, $CONF;
+
+        $this->pagehead();
+
+        echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
+
+        if ($member->isLoggedIn() && $member->isAdmin()) {
+
+            // Information about the used PHP and MySQL installation
+            echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n";
+
+            // Version of PHP MySQL
+            echo "<table>\n";
+            echo "\t<tr>\n";
+            echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
+            echo "\t\t" . '<td>' . phpversion() . "</td>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
+            echo "\t\t" . '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
+            echo "\t</tr>";
+            echo "</table>\n";
+
+            // Important PHP settings
+            echo "<table>\n";
+            echo "\t<tr>\n";
+            echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td width="50%">magic_quotes_gpc' . "</td>\n";
+            $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
+            echo "\t\t" . '<td>' . $mqg . "</td>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td>magic_quotes_runtime' . "</td>\n";
+            $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
+            echo "\t\t" . '<td>' . $mqr . "</td>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td>register_globals' . "</td>\n";
+            $rg = ini_get('register_globals') ? 'On' : 'Off';
+            echo "\t\t" . '<td>' . $rg . "</td>\n";
+            echo "\t</tr>";
+            echo "</table>\n";
+
+            // Information about GD library
+            $gdinfo = gd_info();
+            echo "<table>\n";
+            echo "\t<tr>";
+            echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
+            echo "\t</tr>\n";
+            foreach ($gdinfo as $key=>$value) {
+                if (is_bool($value)) {
+                    $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
+                } else {
+                    $value = htmlspecialchars($value, ENT_QUOTES);
+                }
+                echo "\t<tr>";
+                echo "\t\t" . '<td width="50%">' . $key . "</td>\n";
+                echo "\t\t" . '<td>' . $value . "</td>\n";
+                echo "\t</tr>\n";
+            }
+            echo "</table>\n";
+
+            // Check if special modules are loaded
+            ob_start();
+            phpinfo(INFO_MODULES);
+            $im = ob_get_contents();
+            ob_clean();
+            echo "<table>\n";
+            echo "\t<tr>";
+            echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td width="50%">mod_rewrite' . "</td>\n";
+            $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
+                        _ADMIN_SYSTEMOVERVIEW_ENABLE :
+                        _ADMIN_SYSTEMOVERVIEW_DISABLE;
+            echo "\t\t" . '<td>' . $modrewrite . "</td>\n";
+            echo "\t</tr>\n";
+            echo "</table>\n";
+
+            // Information about the used Nucleus CMS
+            echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
+            global $nucleus;
+            $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
+            $np = getNucleusPatchLevel();
+            echo "<table>\n";
+            echo "\t<tr>";
+            echo "\t\t" . '<th colspan="2">Nucleus CMS' . "</th>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
+            echo "\t\t" . '<td>' . $nv . "</td>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
+            echo "\t\t" . '<td>' . $np . "</td>\n";
+            echo "\t</tr>\n";
+            echo "</table>\n";
+
+            // Important settings of the installation
+            echo "<table>\n";
+            echo "\t<tr>";
+            echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td width="50%">' . '$CONF[' . "'Self']</td>\n";
+            echo "\t\t" . '<td>' . $CONF['Self'] . "</td>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td width="50%">' . '$CONF[' . "'ItemURL']</td>\n";
+            echo "\t\t" . '<td>' . $CONF['ItemURL'] . "</td>\n";
+            echo "\t</tr><tr>\n";
+            echo "\t\t" . '<td width="50%">' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
+            $ohs = $CONF['alertOnHeadersSent'] ?
+                        _ADMIN_SYSTEMOVERVIEW_ENABLE :
+                        _ADMIN_SYSTEMOVERVIEW_DISABLE;
+            echo "\t\t" . '<td>' . $ohs . "</td>\n";
+            echo "\t</tr>\n";
+            echo "</table>\n";
+
+            // Link to the online version test at the Nucleus CMS website
+            echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
+            if ($nucleus['codename'] != '') {
+                $codenamestring = ' &quot;' . $nucleus['codename'] . '&quot;';
+            } else {
+                $codenamestring = '';
+            }
+            echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
+            $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
+            echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
+            echo 'Nucleus CMS ' . $nv . $codenamestring;
+            echo '</a>';
+        //echo '<br />';
+        }
+        else {
+            echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
+        }
+
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function updateConfig($name, $val) {
+        $name = addslashes($name);
+        $val = trim(addslashes($val));
+
+        $query = 'UPDATE '.sql_table('config')
+               . " SET value='$val'"
+               . " WHERE name='$name'";
+
+        sql_query($query) or die("Query error: " . sql_error());
+        return sql_insert_id();
+    }
+
+    /**
+     * Error message
+     * @param string $msg message that will be shown
+     */
+    function error($msg) {
+        $this->pagehead();
+        ?>
+        <h2>Error!</h2>
+        <?php       echo $msg;
+        echo "<br />";
+        echo "<a href='index.php' onclick='history.back()'>"._BACK."</a>";
+        $this->pagefoot();
+        exit;
+    }
+
+    /**
+     * @todo document this
+     */
+    function disallow() {
+        ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
+
+        $this->error(_ERROR_DISALLOWED);
+    }
+
+    /**
+     * @todo document this
+     */
+    function pagehead($extrahead = '') {
+        global $member, $nucleus, $CONF, $manager;
+
+        $manager->notify(
+            'AdminPrePageHead',
+            array(
+                'extrahead' => &$extrahead,
+                'action' => $this->action
+            )
+        );
+
+        $baseUrl = htmlspecialchars($CONF['AdminURL']);
+
+        ?>
+        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+        <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>
+        <head>
+            <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
+            <title><?php echo htmlspecialchars($CONF['SiteName'])?> - Admin</title>
+            <link rel="stylesheet" title="Nucleus Admin Default" type="text/css" href="<?php echo $baseUrl?>styles/admin.css" />
+            <link rel="stylesheet" title="Nucleus Admin Default" type="text/css"
+            href="<?php echo $baseUrl?>styles/addedit.css" />
+
+            <script type="text/javascript" src="<?php echo $baseUrl?>javascript/edit.js"></script>
+            <script type="text/javascript" src="<?php echo $baseUrl?>javascript/admin.js"></script>
+            <script type="text/javascript" src="<?php echo $baseUrl?>javascript/compatibility.js"></script>
+
+      <meta http-equiv='Pragma' content='no-cache' />
+      <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />
+      <meta http-equiv='Expires' content='-1' />
+
+            <?php echo $extrahead?>
+        </head>
+        <body>
+        <div id="adminwrapper">
+        <div class="header">
+        <h1><?php echo htmlspecialchars($CONF['SiteName'])?></h1>
+        </div>
+        <div id="container">
+        <div id="content">
+        <div class="loginname">
+        <?php           if ($member->isLoggedIn())
+                echo _LOGGEDINAS . ' ' . $member->getDisplayName()
+                    ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a>"
+                    . "<br /><a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
+            else
+                echo '<a href="index.php?action=showlogin" title="Log in">' , _NOTLOGGEDIN , '</a> <br />';
+
+            echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a>";
+
+            echo '<br />(';
+
+            $codenamestring = ($nucleus['codename']!='')? ' &quot;'.$nucleus['codename'].'&quot;':'';
+
+            if ($member->isLoggedIn() && $member->isAdmin()) {
+                $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
+                echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
+                $newestVersion = getLatestVersion();
+                $newestCompare = str_replace('/','.',$newestVersion);
+                $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
+                if ($newestVersion && version_compare($newestCompare,$currentVersion) > 0) {
+                    echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE.'">'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT.$newestVersion.'</a>';
+                }
+            } else {
+                echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
+            }
+            echo ')';
+        echo '</div>';
+    }
+
+    /**
+     * @todo document this
+     */
+    function pagefoot() {
+        global $action, $member, $manager;
+
+        $manager->notify(
+            'AdminPrePageFoot',
+            array(
+                'action' => $this->action
+            )
+        );
+
+        if ($member->isLoggedIn() && ($action != 'showlogin')) {
+            ?>
+            <h2><?php echo  _LOGOUT ?></h2>
+            <ul>
+                <li><a href="index.php?action=overview"><?php echo  _BACKHOME?></a></li>
+                <li><a href='index.php?action=logout'><?php echo  _LOGOUT?></a></li>
+            </ul>
+            <?php       }
+        ?>
+            <div class="foot">
+                <a href="<?php echo _ADMINPAGEFOOT_OFFICIALURL ?>">Nucleus CMS</a> &copy; 2002-<?php echo date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT; ?>
+                -
+                <a href="<?php echo _ADMINPAGEFOOT_DONATEURL ?>"><?php echo _ADMINPAGEFOOT_DONATE ?></a>
+            </div>
+
+            </div><!-- content -->
+
+            <div id="quickmenu">
+
+                <?php               // ---- user settings ----
+                if (($action != 'showlogin') && ($member->isLoggedIn())) {
+                    echo '<ul>';
+                    echo '<li><a href="index.php?action=overview">',_QMENU_HOME,'</a></li>';
+                    echo '</ul>';
+
+                    echo '<h2>',_QMENU_ADD,'</h2>';
+                    echo '<form method="get" action="index.php"><div>';
+                    echo '<input type="hidden" name="action" value="createitem" />';
+
+                        $showAll = requestVar('showall');
+                        if (($member->isAdmin()) && ($showAll == 'yes')) {
+                            // Super-Admins have access to all blogs! (no add item support though)
+                            $query =  'SELECT bnumber as value, bname as text'
+                                   . ' FROM ' . sql_table('blog')
+                                   . ' ORDER BY bname';
+                        } else {
+                            $query =  'SELECT bnumber as value, bname as text'
+                                   . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
+                                   . ' WHERE tblog=bnumber and tmember=' . $member->getID()
+                                   . ' ORDER BY bname';
+                        }
+                        $template['name'] = 'blogid';
+                        $template['tabindex'] = 15000;
+                        $template['extra'] = _QMENU_ADD_SELECT;
+                        $template['selected'] = -1;
+                        $template['shorten'] = 10;
+                        $template['shortenel'] = '';
+                        $template['javascript'] = 'onchange="return form.submit()"';
+                        showlist($query,'select',$template);
+
+                    echo '</div></form>';
+
+                    echo '<h2>' . $member->getDisplayName(). '</h2>';
+                    echo '<ul>';
+                    echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . '</a></li>';
+                    echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . '</a></li>';
+                    echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . '</a></li>';
+                    echo '</ul>';
+
+
+
+
+                    // ---- general settings ----
+                    if ($member->isAdmin()) {
+
+                        echo '<h2>',_QMENU_MANAGE,'</h2>';
+
+                        echo '<ul>';
+                        echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . '</a></li>';
+                        echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . '</a></li>';
+                        echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . '</a></li>';
+                        echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . '</a></li>';
+                        echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . '</a></li>';
+                        echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . '</a></li>';
+                        echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . '</a></li>';
+                        echo '</ul>';
+
+                        echo '<h2>',_QMENU_LAYOUT,'</h2>';
+                        echo '<ul>';
+                        echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . '</a></li>';
+                        echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . '</a></li>';
+                        echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . '</a></li>';
+                        echo '</ul>';
+
+                    }
+
+                    $aPluginExtras = array();
+                    $manager->notify(
+                        'QuickMenu',
+                        array(
+                            'options' => &$aPluginExtras
+                        )
+                    );
+                    if (count($aPluginExtras) > 0)
+                    {
+                        echo '<h2>', _QMENU_PLUGINS, '</h2>';
+                        echo '<ul>';
+                        foreach ($aPluginExtras as $aInfo)
+                        {
+                            echo '<li><a href="'.htmlspecialchars($aInfo['url']).'" title="'.htmlspecialchars($aInfo['tooltip']).'">'.htmlspecialchars($aInfo['title']).'</a></li>';
+                        }
+                        echo '</ul>';
+                    }
+
+                } else if (($action == 'activate') || ($action == 'activatesetpwd')) {
+
+                    echo '<h2>', _QMENU_ACTIVATE, '</h2>', _QMENU_ACTIVATE_TEXT;
+                } else {
+                    // introduction text on login screen
+                    echo '<h2>', _QMENU_INTRO, '</h2>', _QMENU_INTRO_TEXT;
+                }
+                ?>
+            </div>
 
-		redirect('?action=pluginlist');
-//		$this->action_pluginlist();
-	}
+            <!-- content / quickmenu container -->
+            <div class="clear"></div>    <!-- new -->
+            </div>
 
-	/**
-	 * @todo document this
-	 */
-	function deleteOnePlugin($pid, $callUninstall = 0) {
-		global $manager;
+            <!-- adminwrapper -->    <!-- new -->
+            </div>     <!-- new -->
+            </body> 
+            </html>
+        <?php   }
 
-		$pid = intval($pid);
+    /**
+     * @todo document this
+     */
+    function action_regfile() {
+        global $member, $CONF;
 
-		if (!$manager->pidInstalled($pid))
-			return _ERROR_NOSUCHPLUGIN;
+        $blogid = intRequestVar('blogid');
 
-		$name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
+        $member->teamRights($blogid) or $this->disallow();
 
-/*		// call the unInstall method of the plugin
-		if ($callUninstall) {
-			$plugin =& $manager->getPlugin($name);
-			if ($plugin) $plugin->unInstall();
-		}*/
-
-		// check dependency before delete
-		$res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
-		while($o = mysql_fetch_object($res)) {
-			$plug =& $manager->getPlugin($o->pfile);
-			if ($plug)
-			{
-				$depList = $plug->getPluginDep();
-				foreach ($depList as $depName)
-				{
-					if ($name == $depName)
-					{
-						return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
-					}
-				}
-			}
-		}
-
-		$manager->notify('PreDeletePlugin', array('plugid' => $pid));
-
-		// call the unInstall method of the plugin
-		if ($callUninstall) {
-			$plugin =& $manager->getPlugin($name);
-			if ($plugin) $plugin->unInstall();
-		}
-
-		// delete all subscriptions
-		sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
-
-		// delete all options
-		// get OIDs from plugin_option_desc
-		$res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
-		$aOIDs = array();
-		while ($o = mysql_fetch_object($res)) {
-			array_push($aOIDs, $o->oid);
-		}
-
-		// delete from plugin_option and plugin_option_desc
-		sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
-		if (count($aOIDs) > 0)
-			sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
-
-		// update order numbers
-		$res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
-		$o = mysql_fetch_object($res);
-		sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
-
-		// delete row
-		sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
-
-		$manager->clearCachedInfo('installedPlugins');
-		$manager->notify('PostDeletePlugin', array('plugid' => $pid));
-
-		return '';
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_pluginup() {
-		global $member, $manager;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		$plugid = intGetVar('plugid');
-
-		if (!$manager->pidInstalled($plugid))
-			$this->error(_ERROR_NOSUCHPLUGIN);
-
-		// 1. get old order number
-		$res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
-		$o = mysql_fetch_object($res);
-		$oldOrder = $o->porder;
-
-		// 2. calculate new order number
-		$newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
-
-		// 3. update plug numbers
-		sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
-		sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
-
-		//$this->action_pluginlist();
-		// To avoid showing ticket in the URL, redirect to pluginlist, instead.
-		redirect('?action=pluginlist');
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_plugindown() {
-		global $member, $manager;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		$plugid = intGetVar('plugid');
-		if (!$manager->pidInstalled($plugid))
-			$this->error(_ERROR_NOSUCHPLUGIN);
-
-		// 1. get old order number
-		$res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
-		$o = mysql_fetch_object($res);
-		$oldOrder = $o->porder;
-
-		$res = sql_query('SELECT * FROM '.sql_table('plugin'));
-		$maxOrder = mysql_num_rows($res);
-
-		// 2. calculate new order number
-		$newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
-
-		// 3. update plug numbers
-		sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
-		sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
-
-		//$this->action_pluginlist();
-		// To avoid showing ticket in the URL, redirect to pluginlist, instead.
-		redirect('?action=pluginlist');
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_pluginoptions($message = '') {
-		global $member, $manager;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		$pid = intRequestVar('plugid');
-		if (!$manager->pidInstalled($pid))
-			$this->error(_ERROR_NOSUCHPLUGIN);
-
-		$extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
-		$pluginName = htmlspecialchars(getPluginNameFromPid($pid), ENT_QUOTES);
-		$this->pagehead($extrahead);
-
-		?>
-			<p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>
-
-			<h2><?php echo sprintf(_PLUGIN_OPTIONS_TITLE, $pluginName) ?></h2>
-
-			<?php if  ($message) echo $message?>
-
-			<form action="index.php" method="post">
-			<div>
-				<input type="hidden" name="action" value="pluginoptionsupdate" />
-				<input type="hidden" name="plugid" value="<?php echo $pid?>" />
-
-		<?php
-
-		$manager->addTicketHidden();
-
-		$aOptions = array();
-		$aOIDs = array();
-		$query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
-		$r = sql_query($query);
-		while ($o = mysql_fetch_object($r)) {
-			array_push($aOIDs, $o->oid);
-			$aOptions[$o->oid] = array(
-						'oid' => $o->oid,
-						'value' => $o->odef,
-						'name' => $o->oname,
-						'description' => $o->odesc,
-						'type' => $o->otype,
-						'typeinfo' => $o->oextra,
-						'contextid' => 0
-			);
-		}
-		// fill out actual values
-		if (count($aOIDs) > 0) {
-			$r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
-			while ($o = mysql_fetch_object($r))
-				$aOptions[$o->oid]['value'] = $o->ovalue;
-		}
-
-		// call plugins
-		$manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));
-
-		$template['content'] = 'plugoptionlist';
-		$amount = showlist($aOptions,'table',$template);
-		if ($amount == 0)
-			echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
-
-		?>
-			</div>
-			</form>
-		<?php		$this->pagefoot();
-
-
-
-	}
-
-	/**
-	 * @todo document this
-	 */
-	function action_pluginoptionsupdate() {
-		global $member, $manager;
-
-		// check if allowed
-		$member->isAdmin() or $this->disallow();
-
-		$pid = intRequestVar('plugid');
-		if (!$manager->pidInstalled($pid))
-			$this->error(_ERROR_NOSUCHPLUGIN);
-
-		$aOptions = requestArray('plugoption');
-		NucleusPlugin::_applyPluginOptions($aOptions);
-
-		$manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
-
-		$this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
-	}
-
-	/**
-	 * @static
-	 * @todo document this
-	 */
-	function _insertPluginOptions($context, $contextid = 0) {
-		// get all current values for this contextid
-		// (note: this might contain doubles for overlapping contextids)
-		$aIdToValue = array();
-		$res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
-		while ($o = mysql_fetch_object($res)) {
-			$aIdToValue[$o->oid] = $o->ovalue;
-		}
-
-		// get list of oids per pid
-		$query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
-			   . ' WHERE opid=pid and ocontext=\''.addslashes($context).'\' ORDER BY porder, oid ASC';
-		$res = sql_query($query);
-		$aOptions = array();
-		while ($o = mysql_fetch_object($res)) {
-			if (in_array($o->oid, array_keys($aIdToValue)))
-				$value = $aIdToValue[$o->oid];
-			else
-				$value = $o->odef;
-
-			array_push($aOptions, array(
-				'pid' => $o->pid,
-				'pfile' => $o->pfile,
-				'oid' => $o->oid,
-				'value' => $value,
-				'name' => $o->oname,
-				'description' => $o->odesc,
-				'type' => $o->otype,
-				'typeinfo' => $o->oextra,
-				'contextid' => $contextid,
-				'extra' => ''
-			));
-		}
+        // header-code stolen from phpMyAdmin
+        // REGEDIT and bookmarklet code stolen from GreyMatter
 
-		global $manager;
-		$manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
+        $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
+
+
+        header('Content-Type: application/octetstream');
+        header('Content-Disposition: filename="nucleus.reg"');
+        header('Pragma: no-cache');
+        header('Expires: 0');
+
+        echo "REGEDIT4\n";
+        echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
+        echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
+        echo '"contexts"=hex:31';
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_bookmarklet() {
+        global $member, $manager;
+
+        $blogid = intRequestVar('blogid');
+
+        $member->teamRights($blogid) or $this->disallow();
+
+        $blog =& $manager->getBlog($blogid);
+        $bm = getBookmarklet($blogid);
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
+
+        ?>
+
+        <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
+
+        <p>
+        <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
+        </p>
+
+        <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
+        <p>
+            <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
+            <br />
+            <br />
+            <?php echo '<a href="' . htmlspecialchars($bm, ENT_QUOTES) . '">' . sprintf(_BOOKMARKLET_ANCHOR, htmlspecialchars($blog->getName(), ENT_QUOTES)) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
+        </p>
+
+        <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
+        <p>
+            <?php
+                $url = 'index.php?action=regfile&blogid=' . intval($blogid);
+                $url = $manager->addTicketToUrl($url);
+            ?>
+            <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . htmlspecialchars($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
+        </p>
+
+        <p>
+            <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
+        </p>
+
+        <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
+        <p>
+            <?php echo _BOOKMARKLET_DELETEBAR ?>
+        </p>
+
+        <p>
+            <?php echo _BOOKMARKLET_DELETERIGHTT ?>
+        </p>
+
+        <ol>
+            <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
+            <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
+            <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
+            <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
+            <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
+        </ol>
+
+        <?php
+        $this->pagefoot();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_actionlog() {
+        global $member, $manager;
+
+        $member->isAdmin() or $this->disallow();
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+
+        $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
+
+        ?>
+            <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
+            <p><a href="<?php echo htmlspecialchars($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
+        <?php
+        echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
+
+        $query =  'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
+        $template['content'] = 'actionlist';
+        $amount = showlist($query,'table',$template);
+
+        $this->pagefoot();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_banlist() {
+        global $member, $manager;
+
+        $blogid = intRequestVar('blogid');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $blog =& $manager->getBlog($blogid);
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
+
+        echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
+
+        $query =  'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
+        $template['content'] = 'banlist';
+        $amount = showlist($query,'table',$template);
+
+        if ($amount == 0)
+            echo _BAN_NONE;
+
+        echo '<h2>'._BAN_NEW_TITLE.'</h2>';
+        echo "<p><a href='index.php?action=banlistnew&amp;blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
+
+
+        $this->pagefoot();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_banlistdelete() {
+        global $member, $manager;
+
+        $blogid = intRequestVar('blogid');
+        $iprange = requestVar('iprange');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $blog =& $manager->getBlog($blogid);
+        $banBlogName =  htmlspecialchars($blog->getName(), ENT_QUOTES);
+
+        $this->pagehead();
+        ?>
+            <h2><?php echo _BAN_REMOVE_TITLE?></h2>
+
+            <form method="post" action="index.php">
+
+            <h3><?php echo _BAN_IPRANGE?></h3>
+
+            <p>
+                <?php echo _CONFIRMTXT_BAN?> <?php echo htmlspecialchars($iprange) ?>
+                <input name="iprange" type="hidden" value="<?php echo htmlspecialchars($iprange)?>" />
+            </p>
+
+            <h3><?php echo _BAN_BLOGS?></h3>
+
+            <div>
+                <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
+                <input name="allblogs" type="radio" value="0" id="allblogs_one" />
+                <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
+                <br />
+                <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
+            </div>
+
+            <h3><?php echo _BAN_DELETE_TITLE?></h3>
+
+            <div>
+                <?php $manager->addTicketHidden() ?>
+                <input type="hidden" name="action" value="banlistdeleteconfirm" />
+                <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            </div>
 
+            </form>
+        <?php
+        $this->pagefoot();
+    }
 
-		$iPrevPid = -1;
-		foreach ($aOptions as $aOption) {
+    /**
+     * @todo document this
+     */
+    function action_banlistdeleteconfirm() {
+        global $member, $manager;
 
-			// new plugin?
-			if ($iPrevPid != $aOption['pid']) {
-				$iPrevPid = $aOption['pid'];
-
-				echo '<tr><th colspan="2">Options for ', htmlspecialchars($aOption['pfile']),'</th></tr>';
-			}
-
-			$meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
-			if (@$meta['access'] != 'hidden') {
-				echo '<tr>';
-				listplug_plugOptionRow($aOption);
-				echo '</tr>';
-			}
-
-		}
-
-
-	}
-
-	/**
-	 * Helper functions to create option forms etc.
-	 * @todo document parameters
-	 */
-	function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {
-		$id = htmlspecialchars($name);
-		$id = str_replace('[','-',$id);
-		$id = str_replace(']','-',$id);
-		$id1 = $id . htmlspecialchars($value1);
-		$id2 = $id . htmlspecialchars($value2);
-
-		if ($name=="admin") {
-			echo '<input onclick="selectCanLogin(true);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
-	   	} else {
-			echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
-		}
-
-			if ($checkedval == $value1)
-				echo "tabindex='$tabindex' checked='checked'";
-			echo ' id="'.$id1.'" /><label for="'.$id1.'">' . $yesval . '</label>';
-		echo ' ';
-		if ($name=="admin") {
-			echo '<input onclick="selectCanLogin(false);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
-		} else {
-			echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
-		}
-			if ($checkedval != $value1)
-				echo "tabindex='$tabindex' checked='checked'";
-			if ($isAdmin && $name=="canlogin")
-				echo ' disabled="disabled"';
-			echo ' id="'.$id2.'" /><label for="'.$id2.'">' . $noval . '</label>';
-	}
+        $blogid = intPostVar('blogid');
+        $allblogs = postVar('allblogs');
+        $iprange = postVar('iprange');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $deleted = array();
+
+        if (!$allblogs) {
+            if (BAN::removeBan($blogid, $iprange))
+                array_push($deleted, $blogid);
+        } else {
+            // get blogs fot which member has admin rights
+            $adminblogs = $member->getAdminBlogs();
+            foreach ($adminblogs as $blogje) {
+                if (BAN::removeBan($blogje, $iprange))
+                    array_push($deleted, $blogje);
+            }
+        }
+
+        if (sizeof($deleted) == 0)
+            $this->error(_ERROR_DELETEBAN);
+
+        $this->pagehead();
+
+        echo '<a href="index.php?action=banlist&amp;blogid=',$blogid,'">(',_BACK,')</a>';
+        echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
+        echo "<p>"._BAN_REMOVED_TEXT."</p>";
+
+        echo "<ul>";
+        foreach ($deleted as $delblog) {
+            $b =& $manager->getBlog($delblog);
+            echo "<li>" . htmlspecialchars($b->getName()). "</li>";
+        }
+        echo "</ul>";
+
+        $this->pagefoot();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_banlistnewfromitem() {
+        $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_banlistnew($blogid = '') {
+        global $member, $manager;
+
+        if ($blogid == '')
+            $blogid = intRequestVar('blogid');
+
+        $ip = requestVar('ip');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        $blog =& $manager->getBlog($blogid);
+
+        $this->pagehead();
+        ?>
+        <h2><?php echo _BAN_ADD_TITLE?></h2>
+
+
+        <form method="post" action="index.php">
+
+        <h3><?php echo _BAN_IPRANGE?></h3>
+
+        <p><?php echo _BAN_IPRANGE_TEXT?></p>
+
+        <div class="note">
+            <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
+            <?php echo _BAN_EXAMPLE_TEXT ?>
+        </div>
+
+        <div>
+        <?php
+        if ($ip) {
+            $iprangeVal = htmlspecialchars($ip, ENT_QUOTES);
+        ?>
+            <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
+            <label for="ip_fixed"><?php echo $iprangeVal ?></label>
+            <br />
+            <input name="iprange" type="radio" value="custom" id="ip_custom" />
+            <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
+            <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
+        <?php
+        } else {
+            echo "<input name='iprange' value='custom' type='hidden' />";
+            echo "<input name='customiprange' value='' maxlength='15' size='15' />";
+        }
+        ?>
+        </div>
+
+        <h3><?php echo _BAN_BLOGS?></h3>
+
+        <p><?php echo _BAN_BLOGS_TEXT?></p>
+
+        <div>
+            <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
+            <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo htmlspecialchars($blog->getName())?>'</label>
+            <br />
+            <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
+        </div>
+
+        <h3><?php echo _BAN_REASON_TITLE?></h3>
+
+        <p><?php echo _BAN_REASON_TEXT?></p>
+
+        <div><textarea name="reason" cols="40" rows="5"></textarea></div>
+
+        <h3><?php echo _BAN_ADD_TITLE?></h3>
+
+        <div>
+            <input name="action" type="hidden" value="banlistadd" />
+            <?php $manager->addTicketHidden() ?>
+            <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
+        </div>
+
+        </form>
+
+        <?php       $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_banlistadd() {
+        global $member;
+
+        $blogid =       intPostVar('blogid');
+        $allblogs =     postVar('allblogs');
+        $iprange =      postVar('iprange');
+        if ($iprange == "custom")
+            $iprange = postVar('customiprange');
+        $reason =       postVar('reason');
+
+        $member->blogAdminRights($blogid) or $this->disallow();
+
+        // TODO: check IP range validity
+
+        if (!$allblogs) {
+            if (!BAN::addBan($blogid, $iprange, $reason))
+                $this->error(_ERROR_ADDBAN);
+        } else {
+            // get blogs fot which member has admin rights
+            $adminblogs = $member->getAdminBlogs();
+            $failed = 0;
+            foreach ($adminblogs as $blogje) {
+                if (!BAN::addBan($blogje, $iprange, $reason))
+                    $failed = 1;
+            }
+            if ($failed)
+                $this->error(_ERROR_ADDBAN);
+        }
+
+        $this->action_banlist();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_clearactionlog() {
+        global $member;
+
+        $member->isAdmin() or $this->disallow();
+
+        ACTIONLOG::clear();
+
+        $this->action_manage(_MSG_ACTIONLOGCLEARED);
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_backupoverview() {
+        global $member, $manager;
+
+        $member->isAdmin() or $this->disallow();
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+        ?>
+        <h2><?php echo _BACKUPS_TITLE?></h2>
+
+        <h3><?php echo _BACKUP_TITLE?></h3>
+
+        <p><?php echo _BACKUP_INTRO?></p>
+
+        <form method="post" action="index.php"><p>
+        <input type="hidden" name="action" value="backupcreate" />
+        <?php $manager->addTicketHidden() ?>
+
+        <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
+        <br />
+        <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
+        <br /><br />
+        <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
+
+        </p></form>
+
+        <div class="note"><?php echo _BACKUP_NOTE?></div>
+
+
+        <h3><?php echo _RESTORE_TITLE?></h3>
+
+        <div class="note"><?php echo _RESTORE_NOTE?></div>
+
+        <p><?php echo _RESTORE_INTRO?></p>
+
+        <form method="post" action="index.php" enctype="multipart/form-data"><p>
+            <input type="hidden" name="action" value="backuprestore" />
+            <?php $manager->addTicketHidden() ?>
+            <input name="backup_file" type="file" tabindex="30" />
+            <br /><br />
+            <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
+            <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
+            <br /><?php echo _RESTORE_WARNING?>
+        </p></form>
+
+        <?php       $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_backupcreate() {
+        global $member, $DIR_LIBS;
+
+        $member->isAdmin() or $this->disallow();
+
+        // use compression ?
+        $useGzip = intval(postVar('gzip'));
+
+        include($DIR_LIBS . 'backup.php');
+
+        // try to extend time limit
+        // (creating/restoring dumps might take a while)
+        @set_time_limit(1200);
+
+        $bu = new Backup();
+        $bu->do_backup($useGzip);
+        exit;
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_backuprestore() {
+        global $member, $DIR_LIBS;
+
+        $member->isAdmin() or $this->disallow();
+
+        if (intPostVar('letsgo') != 1)
+            $this->error(_ERROR_BACKUP_NOTSURE);
+
+        include($DIR_LIBS . 'backup.php');
+
+        // try to extend time limit
+        // (creating/restoring dumps might take a while)
+        @set_time_limit(1200);
+
+        $bu = new Backup();
+        $message = $bu->do_restore();
+        if ($message != '')
+            $this->error($message);
+
+        $this->pagehead();
+        ?>
+        <h2><?php echo _RESTORE_COMPLETE?></h2>
+        <?php       $this->pagefoot();
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_pluginlist() {
+        global $member, $manager;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
+
+        echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
+
+        echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' &nbsp;&nbsp;<span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
+
+
+        $query =  'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
+
+        $template['content'] = 'pluginlist';
+        $template['tabindex'] = 10;
+        showlist($query, 'table', $template);
+
+        ?>
+            <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
+
+            <p><?php echo _PLUGS_TEXT_UPDATE?></p>
+
+            <form method="post" action="index.php"><div>
+                <input type="hidden" name="action" value="pluginupdate" />
+                <?php $manager->addTicketHidden() ?>
+                <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
+            </div></form>
+
+            <h3><?php echo _PLUGS_TITLE_NEW?></h3>
+
+            <?php               // find a list of possibly non-installed plugins
+                $candidates = array();
+                global $DIR_PLUGINS;
+                $dirhandle = opendir($DIR_PLUGINS);
+                while ($filename = readdir($dirhandle)) {
+                    if (ereg('^NP_(.*)\.php$',$filename,$matches)) {
+                        $name = $matches[1];
+                        // only show in list when not yet installed
+                        $res = sql_query('SELECT * FROM '.sql_table('plugin').' WHERE pfile="NP_'.addslashes($name).'"');
+                        if (sql_num_rows($res) == 0)
+                            array_push($candidates,$name);
+                    }
+                }
+                closedir($dirhandle);
+
+                if (sizeof($candidates) > 0) {
+            ?>
+
+            <p><?php echo _PLUGS_ADD_TEXT?></p>
+
+
+            <form method='post' action='index.php'><div>
+                <input type='hidden' name='action' value='pluginadd' />
+                <?php $manager->addTicketHidden() ?>
+                <select name="filename" tabindex="30">
+                <?php                   foreach($candidates as $name)
+                        echo '<option value="NP_',$name,'">',htmlspecialchars($name),'</option>';
+                ?>
+                </select>
+                <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
+            </div></form>
+
+        <?php           } else {    // sizeof(candidates) == 0
+                echo '<p>',_PLUGS_NOCANDIDATES,'</p>';
+            }
+
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_pluginhelp() {
+        global $member, $manager, $DIR_PLUGINS, $CONF;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        $plugid = intGetVar('plugid');
+
+        if (!$manager->pidInstalled($plugid))
+            $this->error(_ERROR_NOSUCHPLUGIN);
+
+        $plugName = getPluginNameFromPid($plugid);
+
+        $this->pagehead();
+
+        echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
+
+        echo '<h2>',_PLUGS_HELP_TITLE,': ',htmlspecialchars($plugName),'</h2>';
+
+        $plug =& $manager->getPlugin($plugName);
+        $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
+
+        if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
+            @readfile($helpFile);
+        } else {
+            echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
+            echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
+        }
+
+
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_pluginadd() {
+        global $member, $manager, $DIR_PLUGINS;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        $name = postVar('filename');
+
+        if ($manager->pluginInstalled($name))
+            $this->error(_ERROR_DUPPLUGIN);
+        if (!checkPlugin($name))
+            $this->error(_ERROR_PLUGFILEERROR . ' (' . htmlspecialchars($name) . ')');
+
+        // get number of currently installed plugins
+        $res = sql_query('SELECT * FROM '.sql_table('plugin'));
+        $numCurrent = sql_num_rows($res);
+
+        // plugin will be added as last one in the list
+        $newOrder = $numCurrent + 1;
+
+        $manager->notify(
+            'PreAddPlugin',
+            array(
+                'file' => &$name
+            )
+        );
+
+        // do this before calling getPlugin (in case the plugin id is used there)
+        $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.addslashes($name).'")';
+        sql_query($query);
+        $iPid = sql_insert_id();
+
+        $manager->clearCachedInfo('installedPlugins');
+
+        // Load the plugin for condition checking and instalation
+        $plugin =& $manager->getPlugin($name);
+
+        // check if it got loaded (could have failed)
+        if (!$plugin)
+        {
+            sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
+            $manager->clearCachedInfo('installedPlugins');
+            $this->error(_ERROR_PLUGIN_LOAD);
+        }
+
+        // check if plugin needs a newer Nucleus version
+        if (getNucleusVersion() < $plugin->getMinNucleusVersion())
+        {
+            // uninstall plugin again...
+            $this->deleteOnePlugin($plugin->getID());
+
+            // ...and show error
+            $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars($plugin->getMinNucleusVersion()));
+        }
+
+        // check if plugin needs a newer Nucleus version
+        if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
+        {
+            // uninstall plugin again...
+            $this->deleteOnePlugin($plugin->getID());
+
+            // ...and show error
+            $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
+        }
+
+        $pluginList = $plugin->getPluginDep();
+        foreach ($pluginList as $pluginName)
+        {
+
+            $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
+            if (sql_num_rows($res) == 0)
+            {
+                // uninstall plugin again...
+                $this->deleteOnePlugin($plugin->getID());
+
+                $this->error(sprintf(_ERROR_INSREQPLUGIN, htmlspecialchars($pluginName, ENT_QUOTES)));
+            }
+        }
+
+        // call the install method of the plugin
+        $plugin->install();
+
+        $manager->notify(
+            'PostAddPlugin',
+            array(
+                'plugin' => &$plugin
+            )
+        );
+
+        // update all events
+        $this->action_pluginupdate();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_pluginupdate() {
+        global $member, $manager, $CONF;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        // delete everything from plugin_events
+        sql_query('DELETE FROM '.sql_table('plugin_event'));
+
+        // loop over all installed plugins
+        $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
+        while($o = sql_fetch_object($res)) {
+            $pid = $o->pid;
+            $plug =& $manager->getPlugin($o->pfile);
+            if ($plug)
+            {
+                $eventList = $plug->getEventList();
+                foreach ($eventList as $eventName)
+                    sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.addslashes($eventName).'\')');
+            }
+        }
+
+        redirect($CONF['AdminURL'] . '?action=pluginlist');
+//		$this->action_pluginlist();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_plugindelete() {
+        global $member, $manager;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        $pid = intGetVar('plugid');
+
+        if (!$manager->pidInstalled($pid))
+            $this->error(_ERROR_NOSUCHPLUGIN);
+
+        $this->pagehead();
+        ?>
+            <h2><?php echo _DELETE_CONFIRM?></h2>
+
+            <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
+
+            <form method="post" action="index.php"><div>
+            <?php $manager->addTicketHidden() ?>
+            <input type="hidden" name="action" value="plugindeleteconfirm" />
+            <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
+            <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
+            </div></form>
+        <?php
+        $this->pagefoot();
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_plugindeleteconfirm() {
+        global $member, $manager, $CONF;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        $pid = intPostVar('plugid');
+
+        $error = $this->deleteOnePlugin($pid, 1);
+        if ($error) {
+            $this->error($error);
+        }
+
+        redirect($CONF['AdminURL'] . '?action=pluginlist');
+//		$this->action_pluginlist();
+    }
+
+    /**
+     * @todo document this
+     */
+    function deleteOnePlugin($pid, $callUninstall = 0) {
+        global $manager;
+
+        $pid = intval($pid);
+
+        if (!$manager->pidInstalled($pid))
+            return _ERROR_NOSUCHPLUGIN;
+
+        $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
+
+/*		// call the unInstall method of the plugin
+        if ($callUninstall) {
+            $plugin =& $manager->getPlugin($name);
+            if ($plugin) $plugin->unInstall();
+        }*/
+
+        // check dependency before delete
+        $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
+        while($o = sql_fetch_object($res)) {
+            $plug =& $manager->getPlugin($o->pfile);
+            if ($plug)
+            {
+                $depList = $plug->getPluginDep();
+                foreach ($depList as $depName)
+                {
+                    if ($name == $depName)
+                    {
+                        return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
+                    }
+                }
+            }
+        }
+
+        $manager->notify('PreDeletePlugin', array('plugid' => $pid));
+
+        // call the unInstall method of the plugin
+        if ($callUninstall) {
+            $plugin =& $manager->getPlugin($name);
+            if ($plugin) $plugin->unInstall();
+        }
+
+        // delete all subscriptions
+        sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
+
+        // delete all options
+        // get OIDs from plugin_option_desc
+        $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
+        $aOIDs = array();
+        while ($o = sql_fetch_object($res)) {
+            array_push($aOIDs, $o->oid);
+        }
+
+        // delete from plugin_option and plugin_option_desc
+        sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
+        if (count($aOIDs) > 0)
+            sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
+
+        // update order numbers
+        $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
+        $o = sql_fetch_object($res);
+        sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
+
+        // delete row
+        sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
+
+        $manager->clearCachedInfo('installedPlugins');
+        $manager->notify('PostDeletePlugin', array('plugid' => $pid));
+
+        return '';
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_pluginup() {
+        global $member, $manager, $CONF;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        $plugid = intGetVar('plugid');
+
+        if (!$manager->pidInstalled($plugid))
+            $this->error(_ERROR_NOSUCHPLUGIN);
+
+        // 1. get old order number
+        $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
+        $o = sql_fetch_object($res);
+        $oldOrder = $o->porder;
+
+        // 2. calculate new order number
+        $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
+
+        // 3. update plug numbers
+        sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
+        sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
+
+        //$this->action_pluginlist();
+        // To avoid showing ticket in the URL, redirect to pluginlist, instead.
+        redirect($CONF['AdminURL'] . '?action=pluginlist');
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_plugindown() {
+        global $member, $manager, $CONF;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        $plugid = intGetVar('plugid');
+        if (!$manager->pidInstalled($plugid))
+            $this->error(_ERROR_NOSUCHPLUGIN);
+
+        // 1. get old order number
+        $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
+        $o = sql_fetch_object($res);
+        $oldOrder = $o->porder;
+
+        $res = sql_query('SELECT * FROM '.sql_table('plugin'));
+        $maxOrder = sql_num_rows($res);
+
+        // 2. calculate new order number
+        $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
+
+        // 3. update plug numbers
+        sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
+        sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
+
+        //$this->action_pluginlist();
+        // To avoid showing ticket in the URL, redirect to pluginlist, instead.
+        redirect($CONF['AdminURL'] . '?action=pluginlist');
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_pluginoptions($message = '') {
+        global $member, $manager;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        $pid = intRequestVar('plugid');
+        if (!$manager->pidInstalled($pid))
+            $this->error(_ERROR_NOSUCHPLUGIN);
+
+        $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
+        $pluginName = htmlspecialchars(getPluginNameFromPid($pid), ENT_QUOTES);
+        $this->pagehead($extrahead);
+
+        ?>
+            <p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>
+
+            <h2><?php echo sprintf(_PLUGIN_OPTIONS_TITLE, $pluginName) ?></h2>
+
+            <?php if  ($message) echo $message?>
+
+            <form action="index.php" method="post">
+            <div>
+                <input type="hidden" name="action" value="pluginoptionsupdate" />
+                <input type="hidden" name="plugid" value="<?php echo $pid?>" />
+
+        <?php
+
+        $manager->addTicketHidden();
+
+        $aOptions = array();
+        $aOIDs = array();
+        $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
+        $r = sql_query($query);
+        while ($o = sql_fetch_object($r)) {
+            array_push($aOIDs, $o->oid);
+            $aOptions[$o->oid] = array(
+                        'oid' => $o->oid,
+                        'value' => $o->odef,
+                        'name' => $o->oname,
+                        'description' => $o->odesc,
+                        'type' => $o->otype,
+                        'typeinfo' => $o->oextra,
+                        'contextid' => 0
+            );
+        }
+        // fill out actual values
+        if (count($aOIDs) > 0) {
+            $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
+            while ($o = sql_fetch_object($r))
+                $aOptions[$o->oid]['value'] = $o->ovalue;
+        }
+
+        // call plugins
+        $manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));
+
+        $template['content'] = 'plugoptionlist';
+        $amount = showlist($aOptions,'table',$template);
+        if ($amount == 0)
+            echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
+
+        ?>
+            </div>
+            </form>
+        <?php       $this->pagefoot();
+
+
+
+    }
+
+    /**
+     * @todo document this
+     */
+    function action_pluginoptionsupdate() {
+        global $member, $manager;
+
+        // check if allowed
+        $member->isAdmin() or $this->disallow();
+
+        $pid = intRequestVar('plugid');
+        if (!$manager->pidInstalled($pid))
+            $this->error(_ERROR_NOSUCHPLUGIN);
+
+        $aOptions = requestArray('plugoption');
+        NucleusPlugin::_applyPluginOptions($aOptions);
+
+        $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
+
+        $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
+    }
+
+    /**
+     * @static
+     * @todo document this
+     */
+    function _insertPluginOptions($context, $contextid = 0) {
+        // get all current values for this contextid
+        // (note: this might contain doubles for overlapping contextids)
+        $aIdToValue = array();
+        $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
+        while ($o = sql_fetch_object($res)) {
+            $aIdToValue[$o->oid] = $o->ovalue;
+        }
+
+        // get list of oids per pid
+        $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
+               . ' WHERE opid=pid and ocontext=\''.addslashes($context).'\' ORDER BY porder, oid ASC';
+        $res = sql_query($query);
+        $aOptions = array();
+        while ($o = sql_fetch_object($res)) {
+            if (in_array($o->oid, array_keys($aIdToValue)))
+                $value = $aIdToValue[$o->oid];
+            else
+                $value = $o->odef;
+
+            array_push($aOptions, array(
+                'pid' => $o->pid,
+                'pfile' => $o->pfile,
+                'oid' => $o->oid,
+                'value' => $value,
+                'name' => $o->oname,
+                'description' => $o->odesc,
+                'type' => $o->otype,
+                'typeinfo' => $o->oextra,
+                'contextid' => $contextid,
+                'extra' => ''
+            ));
+        }
+
+        global $manager;
+        $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
+
+
+        $iPrevPid = -1;
+        foreach ($aOptions as $aOption) {
+
+            // new plugin?
+            if ($iPrevPid != $aOption['pid']) {
+                $iPrevPid = $aOption['pid'];
+                if (!defined('_PLUGIN_OPTIONS_TITLE')) {
+                    define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
+                }
+                echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, htmlspecialchars($aOption['pfile'], ENT_QUOTES)).'</th></tr>';
+            }
+
+            $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
+            if (@$meta['access'] != 'hidden') {
+                echo '<tr>';
+                listplug_plugOptionRow($aOption);
+                echo '</tr>';
+            }
+
+        }
+
+
+    }
+
+    /**
+     * Helper functions to create option forms etc.
+     * @todo document parameters
+     */
+    function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {
+        $id = htmlspecialchars($name);
+        $id = str_replace('[','-',$id);
+        $id = str_replace(']','-',$id);
+        $id1 = $id . htmlspecialchars($value1);
+        $id2 = $id . htmlspecialchars($value2);
+
+        if ($name=="admin") {
+            echo '<input onclick="selectCanLogin(true);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
+        } else {
+            echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
+        }
+
+            if ($checkedval == $value1)
+                echo "tabindex='$tabindex' checked='checked'";
+            echo ' id="'.$id1.'" /><label for="'.$id1.'">' . $yesval . '</label>';
+        echo ' ';
+        if ($name=="admin") {
+            echo '<input onclick="selectCanLogin(false);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
+        } else {
+            echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
+        }
+            if ($checkedval != $value1)
+                echo "tabindex='$tabindex' checked='checked'";
+            if ($isAdmin && $name=="canlogin")
+                echo ' disabled="disabled"';
+            echo ' id="'.$id2.'" /><label for="'.$id2.'">' . $noval . '</label>';
+    }
 
 } // class ADMIN
 
diff -x .svn -aruN 3.41.src/nucleus/libs/backup.php 3.51.src/nucleus/libs/backup.php
--- 3.41.src/nucleus/libs/backup.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/backup.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -15,8 +15,8 @@
  * Based on code in phpBB (http://phpBB.sourceforge.net)
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: backup.php 1281 2008-10-24 06:01:23Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: backup.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 
@@ -72,7 +72,7 @@
 		// catch all output generated by plugins
 		ob_start();
 		$res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
-		while ($plugName = mysql_fetch_object($res)) {
+		while ($plugName = sql_fetch_object($res)) {
 			$plug =& $manager->getPlugin($plugName->pfile);
 			if ($plug) $tables = array_merge($tables, (array) $plug->getTableList());
 		}
@@ -158,6 +158,20 @@
 	
 		// add command to drop table on restore
 		echo "DROP TABLE IF EXISTS $tablename;\n";
+		$result = sql_query("SHOW CREATE TABLE $tablename");
+		$create = sql_fetch_assoc($result);
+		echo $create['Create Table'];
+		echo ";\n\n";
+	}
+	
+	/**
+	  * Creates a dump of the table structure for one table
+	  */
+/* replaced by code above in 3.5
+	function _backup_dump_structure($tablename) {
+	
+		// add command to drop table on restore
+		echo "DROP TABLE IF EXISTS $tablename;\n";
 		echo "CREATE TABLE $tablename(\n";
 	
 		//
@@ -220,6 +234,7 @@
 	
 		echo "\n);\n\n";
 	}
+*/
 
 	/**
 	 * Returns the field named for the given table in the 
@@ -239,7 +254,7 @@
 	
 			$fields = array();
 			for ($j = 0; $j < $num_fields; $j++) {
-				$fields[] = mysql_field_name($result, $j);
+				$fields[] = sql_field_name($result, $j);
 			}
 	
 	/*	}*/
@@ -254,12 +269,12 @@
 		//
 		// Grab the data from the table.
 		//
-		$result = mysql_query("SELECT * FROM $tablename");
+		$result = sql_query("SELECT * FROM $tablename");
 	
-		if(mysql_num_rows($result) > 0)
+		if(sql_num_rows($result) > 0)
 			echo "\n#\n# Table Data for $tablename\n#\n";
 			
-		$num_fields = mysql_num_fields($result);
+		$num_fields = sql_num_fields($result);
 		
 		//
 		// Compose fieldname list
@@ -269,7 +284,7 @@
 		//
 		// Loop through the resulting rows and build the sql statement.
 		//
-		while ($row = mysql_fetch_array($result))
+		while ($row = sql_fetch_array($result))
 		{
 			// Start building the SQL statement.
 	
@@ -388,8 +403,8 @@
 				// DEBUG
 	//			debug("Executing: " . htmlspecialchars($sql) . "\n");
 	
-				$result = mysql_query($sql);
-				if (!$result) debug('SQL Error: ' . mysql_error());
+				$result = sql_query($sql);
+				if (!$result) debug('SQL Error: ' . sql_error());
 	
 			}
 		}
diff -x .svn -aruN 3.41.src/nucleus/libs/BAN.php 3.51.src/nucleus/libs/BAN.php
--- 3.41.src/nucleus/libs/BAN.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/BAN.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,8 +13,8 @@
  * PHP class responsible for ban-management.
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: BAN.php 1116 2007-02-03 08:24:29Z kimitake $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: BAN.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 class BAN {
@@ -29,7 +29,7 @@
 		$blogid = intval($blogid);
 		$query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid;
 		$res = sql_query($query);
-		while ($obj = mysql_fetch_object($res)) {
+		while ($obj = sql_fetch_object($res)) {
 			$found = strpos ($ip, $obj->iprange);
 			if (!($found === false))
 				// found a match!
@@ -84,7 +84,7 @@
 		$query = 'DELETE FROM '.sql_table('ban')." WHERE blogid=$blogid and iprange='" .addslashes($iprange). "'";
 		sql_query($query);
 
-		$result = (mysql_affected_rows() > 0);
+		$result = (sql_affected_rows() > 0);
 
 		$manager->notify('PostDeleteBan', array('blogid' => $blogid, 'range' => $iprange));
 
diff -x .svn -aruN 3.41.src/nucleus/libs/BaseActions.php 3.51.src/nucleus/libs/BaseActions.php
--- 3.41.src/nucleus/libs/BaseActions.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/BaseActions.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,8 +16,8 @@
  * It should never be used on it's own
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: BaseActions.php 1282 2008-10-27 06:32:05Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: BaseActions.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 class BaseActions {
@@ -81,26 +81,13 @@
 		if (!$skin->isValid && !file_exists($file)) {
 			return;
 		}
-		$parts = explode('|', $filename, 2);
-		if ($skin->getContent($parts[0])) {
-			$contents = $skin->getContent($parts[0]);
-		} else {
-			$filename = $this->getIncludeFileName($filename);
-			if (!file_exists($filename)) return '';
-
-			$fsize = filesize($filename);
-
-			// nothing to include
-			if ($fsize <= 0) return;
-
-			$this->level = $this->level + 1;
-
-			// read file
-			$fd = fopen ($filename, 'r');
-			$contents = fread ($fd, $fsize);
-			fclose ($fd);
+		$contents = $skin->getContent($filename);
+		if (!$contents) {
+            if (!file_exists($file)) return;
+            $contents = file_get_contents($file);
+            if (empty($contents)) return;
 		}
-
+		$this->level = $this->level + 1;
 		// parse file contents
 		$this->parser->parse($contents);
 
diff -x .svn -aruN 3.41.src/nucleus/libs/BLOG.php 3.51.src/nucleus/libs/BLOG.php
--- 3.41.src/nucleus/libs/BLOG.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/libs/BLOG.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -15,8 +15,8 @@
  * on the screen
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: BLOG.php 1353 2009-03-14 13:12:55Z kaigreve $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: BLOG.php 1398 2009-08-05 22:14:07Z ftruscot $
  */
 
 if ( !function_exists('requestVar') ) exit;
@@ -78,12 +78,15 @@
 	 * @param $template
 	 *		String representing the template name to be used
 	 */
-	function showArchive($templatename, $year, $month, $day=0) {
+	function showArchive($templatename, $year, $month=0, $day=0) {
 
 		// create extra where clause for select query
-		if ($day == 0) {
+		if ($day == 0 && $month != 0) {
 			$timestamp_start = mktime(0,0,0,$month,1,$year);
 			$timestamp_end = mktime(0,0,0,$month+1,1,$year);  // also works when $month==12
+		} elseif ($month == 0) {
+			$timestamp_start = mktime(0,0,0,1,1,$year);
+			$timestamp_end = mktime(0,0,0,12,31,$year);  // also works when $month==12
 		} else {
 			$timestamp_start = mktime(0,0,0,$month,$day,$year);
 			$timestamp_end = mktime(0,0,0,$month,$day+1,$year);
@@ -170,7 +173,7 @@
 
 		// loop over all items
 		$old_date = 0;
-		while ($item = mysql_fetch_object($items)) {
+		while ($item = sql_fetch_object($items)) {
 
 			$item->timestamp = strtotime($item->itime);	// string timestamp -> unix timestamp
 
@@ -209,7 +212,7 @@
 
 		}
 
-		$numrows = mysql_num_rows($items);
+		$numrows = sql_num_rows($items);
 
 		// add another date footer if there was at least one item
 		if (($numrows > 0) && $dateheads) {
@@ -218,7 +221,7 @@
 			$manager->notify('PostDateFoot',array('blog' => &$this, 'timestamp' => strtotime($old_date)));
 		}
 
-		mysql_free_result($items);	// free memory
+		sql_free_result($items);	// free memory
 
 		return $numrows;
 
@@ -270,7 +273,7 @@
 		$query = 'INSERT INTO '.sql_table('item').' (ITITLE, IBODY, IMORE, IBLOG, IAUTHOR, ITIME, ICLOSED, IDRAFT, ICAT, IPOSTED) '
 			   . "VALUES ('$title', '$body', '$more', $blogid, $authorid, '$timestamp', $closed, $draft, $catid, $posted)";
 		sql_query($query);
-		$itemid = mysql_insert_id();
+		$itemid = sql_insert_id();
 
 		$manager->notify('PostAddItem',array('itemid' => $itemid));
 
@@ -343,7 +346,7 @@
 				$i = 1;
 
 				$res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cname='".$catName.$i."' and cblog=".$this->getID());
-				while (mysql_num_rows($res) > 0)
+				while (sql_num_rows($res) > 0)
 				{
 					$i++;
 					$res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cname='".$catName.$i."' and cblog=".$this->getID());
@@ -363,7 +366,7 @@
 
 			$query = 'INSERT INTO '.sql_table('category').' (cblog, cname, cdesc) VALUES (' . $this->getID() . ", '" . addslashes($catName) . "', '" . addslashes($catDescription) . "')";
 			sql_query($query);
-			$catid = mysql_insert_id();
+			$catid = sql_insert_id();
 
 			$manager->notify(
 				'PostAddCategory',
@@ -563,7 +566,9 @@
 		$template =& $manager->getTemplate($template);
 		$data['blogid'] = $this->getID();
 
-		echo TEMPLATE::fill($template['ARCHIVELIST_HEADER'],$data);
+		$tplt = isset($template['ARCHIVELIST_HEADER']) ? $template['ARCHIVELIST_HEADER']
+		                                               : '';
+		echo TEMPLATE::fill($tplt, $data);
 
 		$query = 'SELECT itime, SUBSTRING(itime,1,4) AS Year, SUBSTRING(itime,6,2) AS Month, SUBSTRING(itime,9,2) as Day FROM '.sql_table('item')
 		. ' WHERE iblog=' . $this->getID()
@@ -573,11 +578,12 @@
 		if ($catid)
 			$query .= ' and icat=' . intval($catid);
 
-		$query .= ' GROUP BY Year, Month';
+		$query .= ' GROUP BY Year';
+		if ($mode == 'month' || $mode == 'day')
+			$query .= ', Month';
 		if ($mode == 'day')
 			$query .= ', Day';
 
-
 		$query .= ' ORDER BY itime DESC';
 
 		if ($limit > 0)
@@ -585,18 +591,31 @@
 
 		$res = sql_query($query);
 
-		while ($current = mysql_fetch_object($res)) {
+		while ($current = sql_fetch_object($res)) {
 			$current->itime = strtotime($current->itime);	// string time -> unix timestamp
 
 			if ($mode == 'day') {
 				$archivedate = date('Y-m-d',$current->itime);
 				$archive['day'] = date('d',$current->itime);
 				$data['day'] = date('d',$current->itime);
+				$data['month'] = date('m',$current->itime);
+				$archive['month'] = $data['month'];
+			} elseif ($mode == 'year') {
+				$archivedate = date('Y',$current->itime);
+				$data['day'] = '';
+				$data['month'] = '';
+				$archive['day'] = '';
+				$archive['month'] = '';
 			} else {
 				$archivedate = date('Y-m',$current->itime);
+				$data['month'] = date('m',$current->itime);
+				$archive['month'] = $data['month'];
+				$data['day'] = '';
+				$archive['day'] = '';
 			}
-			$data['month'] = date('m',$current->itime);
+
 			$data['year'] = date('Y',$current->itime);
+			$archive['year'] = $data['year'];
 			$data['archivelink'] = createArchiveLink($this->getID(),$archivedate,$linkparams);
 
 			$manager->notify(
@@ -611,9 +630,11 @@
 
 		}
 
-		mysql_free_result($res);
+		sql_free_result($res);
 
-		echo TEMPLATE::fill($template['ARCHIVELIST_FOOTER'],$data);
+		$tplt = isset($template['ARCHIVELIST_FOOTER']) ? $template['ARCHIVELIST_FOOTER']
+		                                               : '';
+		echo TEMPLATE::fill($tplt, $data);
 	}
 
 
@@ -656,7 +677,7 @@
 		$res = sql_query($query);
 
 
-		while ($data = mysql_fetch_assoc($res)) {
+		while ($data = sql_fetch_assoc($res)) {
 			$data['blogid'] = $this->getID();
 			$data['blogurl'] = $blogurl;
 			$data['catlink'] = createLink(
@@ -668,6 +689,33 @@
 								)
 							   );
 			$data['self'] = $CONF['Self'];
+			
+			//catiscurrent
+			if ($this->getSelectedCategory()) {
+				if ($this->getSelectedCategory() == $data['catid']) {
+					$data['catiscurrent'] = 'yes';
+					$data['currentcat'] = 'yes';
+				}
+				else {
+					$data['catiscurrent'] = 'no';
+					$data['currentcat'] = 'no';
+				}
+			}
+			else {
+				global $itemid;
+				if (intval($itemid) && $manager->existsItem(intval($itemid),0,0)) {
+					$iobj =& $manager->getItem(intval($itemid),0,0);
+					$cid = $iobj['catid'];
+					if ($cid == $data['catid']) {
+						$data['catiscurrent'] = 'yes';
+						$data['currentcat'] = 'yes';
+					}
+					else {
+						$data['catiscurrent'] = 'no';
+						$data['currentcat'] = 'no';
+					}
+				}
+			}
 
 			$manager->notify(
 				'PreCategoryListItem',
@@ -682,7 +730,7 @@
 
 		}
 
-		mysql_free_result($res);
+		sql_free_result($res);
 
 		echo TEMPLATE::fill((isset($template['CATLIST_FOOTER']) ? $template['CATLIST_FOOTER'] : null),
 							array(
@@ -701,18 +749,34 @@
 		global $CONF, $manager;
 
 		switch ($orderby) {
-			case 'number': $orderby='bnumber'; break;
-			case 'name': $orderby='bname'; break;
-			case 'shortname': $orderby='bshortname'; break;
-			case 'description': $orderby='bdesc'; break;
-			default: $orderby='bnumber';	break;
+			case 'number':
+				$orderby='bnumber';
+				break;
+			case 'name':
+				$orderby='bname';
+				break;
+			case 'shortname':
+				$orderby='bshortname';
+				break;
+			case 'description':
+				$orderby='bdesc';
+				break;
+			default:
+				$orderby='bnumber';
+				break;
 		}
 
 		$direction=strtolower($direction);
 		switch ($direction) {
-			case 'asc': $direction='ASC';  break;
-			case 'desc': $direction='DESC'; break;
-			default: $direction='ASC';	break;
+			case 'asc':
+				$direction='ASC';
+				break;
+			case 'desc':
+				$direction='DESC';
+				break;
+			default:
+				$direction='ASC';
+				break;
 		}
 
 		$template =& $manager->getTemplate($template);
@@ -726,7 +790,7 @@
 		$query = 'SELECT bnumber, bname, bshortname, bdesc, burl FROM '.sql_table('blog').' ORDER BY '.$orderby.' '.$direction;
 		$res = sql_query($query);
 
-		while ($data = mysql_fetch_assoc($res)) {
+		while ($data = sql_fetch_assoc($res)) {
 
 			$list = array();
 
@@ -755,7 +819,7 @@
 
 		}
 
-		mysql_free_result($res);
+		sql_free_result($res);
 
 		echo TEMPLATE::fill((isset($template['BLOGLIST_FOOTER']) ? $template['BLOGLIST_FOOTER'] : null),
 							array(
@@ -775,11 +839,11 @@
 			   . ' WHERE bnumber=' . $this->blogid;
 		$res = sql_query($query);
 
-		$this->isValid = (mysql_num_rows($res) > 0);
+		$this->isValid = (sql_num_rows($res) > 0);
 		if (!$this->isValid)
 			return;
 
-		$this->settings = mysql_fetch_assoc($res);
+		$this->settings = sql_fetch_assoc($res);
 	}
 
 	function writeSettings() {
@@ -797,7 +861,6 @@
 			   . "     btimeoffset=" . $offset . ","
 			   . "     bpublic=" . intval($this->isPublic()) . ","
 			   . "     breqemail=" . intval($this->emailRequired()) . ","
-			   . "     bsendping=" . intval($this->sendPing()) . ","
 			   . "     bconvertbreaks=" . intval($this->convertBreaks()) . ","
 			   . "     ballowpast=" . intval($this->allowPastPosting()) . ","
 			   . "     bnotify='" . addslashes($this->getNotifyAddress()) . "',"
@@ -828,39 +891,31 @@
 	function isValidCategory($catid) {
 		$query = 'SELECT * FROM '.sql_table('category').' WHERE cblog=' . $this->getID() . ' and catid=' . intval($catid);
 		$res = sql_query($query);
-		return (mysql_num_rows($res) != 0);
+		return (sql_num_rows($res) != 0);
 	}
 
 	function getCategoryName($catid) {
 		$res = sql_query('SELECT cname FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and catid=' . intval($catid));
-		$o = mysql_fetch_object($res);
+		$o = sql_fetch_object($res);
 		return $o->cname;
 	}
 
 	function getCategoryDesc($catid) {
 		$res = sql_query('SELECT cdesc FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and catid=' . intval($catid));
-		$o = mysql_fetch_object($res);
+		$o = sql_fetch_object($res);
 		return $o->cdesc;
 	}
 
 	function getCategoryIdFromName($name) {
 		$res = sql_query('SELECT catid FROM '.sql_table('category').' WHERE cblog='.$this->getID().' and cname="' . addslashes($name) . '"');
-		if (mysql_num_rows($res) > 0) {
-			$o = mysql_fetch_object($res);
+		if (sql_num_rows($res) > 0) {
+			$o = sql_fetch_object($res);
 			return $o->catid;
 		} else {
 			return $this->getDefaultCategory();
 		}
 	}
 
-	function sendPing() {
-		return $this->getSetting('bsendping');
-	}
-
-	function setPingUserland($val) {
-		$this->setSetting('bsendping',$val);
-	}
-
 	function convertBreaks() {
 		return $this->getSetting('bconvertbreaks');
 	}
@@ -1099,13 +1154,13 @@
 	// returns true if there is a blog with the given shortname (static)
 	function exists($name) {
 		$r = sql_query('select * FROM '.sql_table('blog').' WHERE bshortname="'.addslashes($name).'"');
-		return (mysql_num_rows($r) != 0);
+		return (sql_num_rows($r) != 0);
 	}
 
 	// returns true if there is a blog with the given ID (static)
 	function existsID($id) {
 		$r = sql_query('select * FROM '.sql_table('blog').' WHERE bnumber='.intval($id));
-		return (mysql_num_rows($r) != 0);
+		return (sql_num_rows($r) != 0);
 	}
 
         // flag there is a future post pending
@@ -1130,7 +1185,7 @@
 			$blogid = $this->getID();
 			$result = sql_query("SELECT * FROM " . sql_table('item')
 			          . " WHERE iposted=0 AND iblog=" . $blogid . " AND itime<NOW()");
-			if (mysql_num_rows($result) > 0) {
+			if (sql_num_rows($result) > 0) {
 				// This $pinged is allow a plugin to tell other hook to the event that a ping is sent already
 				// Note that the plugins's calling order is subject to thri order in the plugin list
 				$pinged = false;
@@ -1147,7 +1202,7 @@
 				// check to see any pending future post, clear the flag is none
 				$result = sql_query("SELECT * FROM " . sql_table('item')
 				          . " WHERE iposted=0 AND iblog=" . $blogid);
-				if (mysql_num_rows($result) == 0) {
+				if (sql_num_rows($result) == 0) {
 					$this->clearFuturePost();
 				}
 			}
@@ -1199,10 +1254,28 @@
 		$i = count($items);
 		$query = '';
 		foreach ($items as $value) {
-			$query .= '(SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author, m.mrealname as authorname, i.itime, i.imore as more, m.mnumber as authorid, m.memail as authormail, m.murl as authorurl, c.cname as category, i.icat as catid, i.iclosed as closed';
-
-			$query .= ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c'
-				   . ' WHERE i.iblog='.$this->blogid
+			$query .= '('
+					.	'SELECT'
+					.	' i.inumber as itemid,'
+					.	' i.ititle as title,'
+					.	' i.ibody as body,'
+					.	' m.mname as author,'
+					.	' m.mrealname as authorname,'
+					.	' i.itime,'
+					.	' i.imore as more,'
+					.	' m.mnumber as authorid,'
+					.	' m.memail as authormail,'
+					.	' m.murl as authorurl,'
+					.	' c.cname as category,'
+					.	' i.icat as catid,'
+					.	' i.iclosed as closed';
+
+			$query .= ' FROM '
+					. sql_table('item') . ' as i, '
+					. sql_table('member') . ' as m, '
+					. sql_table('category') . ' as c'
+					. ' WHERE'
+				    .    ' i.iblog='.$this->blogid
 				   . ' and i.iauthor=m.mnumber'
 				   . ' and i.icat=c.catid'
 				   . ' and i.idraft=0'	// exclude drafts
diff -x .svn -aruN 3.41.src/nucleus/libs/BODYACTIONS.php 3.51.src/nucleus/libs/BODYACTIONS.php
--- 3.41.src/nucleus/libs/BODYACTIONS.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/libs/BODYACTIONS.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * A class to parses plugin calls inside items
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: BODYACTIONS.php 1273 2008-10-15 21:34:56Z kaigreve $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: BODYACTIONS.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 class BODYACTIONS extends BaseActions {
diff -x .svn -aruN 3.41.src/nucleus/libs/COMMENTACTIONS.php 3.51.src/nucleus/libs/COMMENTACTIONS.php
--- 3.41.src/nucleus/libs/COMMENTACTIONS.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/libs/COMMENTACTIONS.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,8 +13,8 @@
  * This class is used when parsing comment templates
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: COMMENTACTIONS.php 1254 2008-03-08 17:17:52Z kaigreve $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: COMMENTACTIONS.php 1405 2009-08-14 15:56:06Z ftruscot $
  */
 
 class COMMENTACTIONS extends BaseActions {
@@ -62,6 +62,7 @@
 			'userlink',
 			'useremail',
 			'userwebsite',
+			'userwebsitelink',
 			'excerpt',
 			'short',
 			'skinfile',
@@ -388,6 +389,17 @@
 		if (!(strpos($this->currentComment['userlinkraw'], 'http://') === false))
 			echo $this->currentComment['userlinkraw'];
 	}
+	
+	/**
+	 * Parse templatevar userwebsitelink
+	 */
+	function parse_userwebsitelink() {
+		if (!(strpos($this->currentComment['userlinkraw'], 'http://') === false)) {
+			echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>';
+		} else {
+			echo $this->currentComment['user'];
+		}
+	}
 
 }
 ?>
diff -x .svn -aruN 3.41.src/nucleus/libs/COMMENT.php 3.51.src/nucleus/libs/COMMENT.php
--- 3.41.src/nucleus/libs/COMMENT.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/COMMENT.php	2009-11-01 14:53:58.000000000 -0600
@@ -15,7 +15,7 @@
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
  * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: COMMENT.php 1252 2008-03-06 18:39:02Z kaigreve $
+ * @version $Id: COMMENT.php 1370 2009-06-22 22:00:32Z ftruscot $
  */
 class COMMENT {
 
@@ -30,7 +30,7 @@
 			   . ' WHERE cnumber=' . intval($commentid);
 		$comments = sql_query($query);
 
-		$aCommentInfo = mysql_fetch_assoc($comments);
+		$aCommentInfo = sql_fetch_assoc($comments);
 		if ($aCommentInfo)
 		{
 			$aCommentInfo['timestamp'] = strtotime($aCommentInfo['ctime']);
diff -x .svn -aruN 3.41.src/nucleus/libs/COMMENTS.php 3.51.src/nucleus/libs/COMMENTS.php
--- 3.41.src/nucleus/libs/COMMENTS.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/libs/COMMENTS.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * A class representing the comments (all of them) for a certain post on a ceratin blog
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: COMMENTS.php 1281 2008-10-24 06:01:23Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: COMMENTS.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 if ( !function_exists('requestVar') ) exit;
@@ -84,7 +84,7 @@
 				   . ' ORDER BY c.ctime';
 
 			$comments = sql_query($query);
-			$this->commentcount = mysql_num_rows($comments);
+			$this->commentcount = sql_num_rows($comments);
 		}
 
 		// if no result was found
@@ -102,7 +102,7 @@
 
 		$parser->parse($template['COMMENTS_HEADER']);
 
-		while ( $comment = mysql_fetch_assoc($comments) ) {
+		while ( $comment = sql_fetch_assoc($comments) ) {
 			$comment['timestamp'] = strtotime($comment['ctime']);
 			$actions->setCurrentComment($comment);
 			$actions->setHighlight($highlight);
@@ -113,7 +113,7 @@
 
 		$parser->parse($template['COMMENTS_FOOTER']);
 
-		mysql_free_result($comments);
+		sql_free_result($comments);
 
 		return $this->commentcount;
 	}
@@ -126,7 +126,7 @@
 			   . ' FROM '.sql_table('comment').' as c'
 			   . ' WHERE c.citem='. $this->itemid;
 		$res = sql_query($query);
-		$arr = mysql_fetch_row($res);
+		$arr = sql_fetch_row($res);
 
 		return $arr[0];
 	}
@@ -287,7 +287,7 @@
 		sql_query($query);
 
 		// post add comment
-		$commentid = mysql_insert_id();
+		$commentid = sql_insert_id();
 		$manager->notify('PostAddComment',array('comment' => &$comment, 'commentid' => &$commentid, 'spamcheck' => &$spamcheck));
 
 		// succeeded !
diff -x .svn -aruN 3.41.src/nucleus/libs/ENCAPSULATE.php 3.51.src/nucleus/libs/ENCAPSULATE.php
--- 3.41.src/nucleus/libs/ENCAPSULATE.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/ENCAPSULATE.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * Part of the code for the Nucleus admin area
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: ENCAPSULATE.php 1279 2008-10-23 08:18:26Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: ENCAPSULATE.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 class ENCAPSULATE {
diff -x .svn -aruN 3.41.src/nucleus/libs/globalfunctions.php 3.51.src/nucleus/libs/globalfunctions.php
--- 3.41.src/nucleus/libs/globalfunctions.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/globalfunctions.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -12,73 +12,74 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: globalfunctions.php 1355 2009-03-15 21:14:41Z kaigreve $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: globalfunctions.php 1421 2009-11-01 13:45:44Z kaigreve $
 
  */
 
 // needed if we include globalfunctions from install.php
 global $nucleus, $CONF, $DIR_LIBS, $DIR_LANG, $manager, $member;
 
-$nucleus['version'] = 'v3.41';
+$nucleus['version'] = 'v3.51';
 $nucleus['codename'] = '';
 
 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'));
 
 $CONF['debug'] = 0;
 if ($CONF['debug']) {
-	error_reporting(E_ALL);	// report all errors!
+    error_reporting(E_ALL); // report all errors!
 } else {
-	error_reporting(E_ERROR | E_WARNING | E_PARSE);
+    ini_set('display_errors','0');
+    error_reporting(E_ERROR | E_WARNING | E_PARSE);
 }
 
 /*
-	Indicates when Nucleus should display startup errors. Set to 1 if you want
-	the error enabled (default), false otherwise
+    Indicates when Nucleus should display startup errors. Set to 1 if you want
+    the error enabled (default), false otherwise
 
-	alertOnHeadersSent
-		Displays an error when visiting a public Nucleus page and headers have
-		been sent out to early. This usually indicates an error in either a
-		configuration file or a language file, and could cause Nucleus to
-		malfunction
-	alertOnSecurityRisk
-		Displays an error only when visiting the admin area, and when one or
-		more of the installation files (install.php, install.sql, upgrades/
-		directory) are still on the server.
+    alertOnHeadersSent
+        Displays an error when visiting a public Nucleus page and headers have
+        been sent out to early. This usually indicates an error in either a
+        configuration file or a language file, and could cause Nucleus to
+        malfunction
+    alertOnSecurityRisk
+        Displays an error only when visiting the admin area, and when one or
+        more of the installation files (install.php, install.sql, upgrades/
+        directory) are still on the server.
 */
 
-$CONF['alertOnHeadersSent'] = 1;
+$CONF['alertOnHeadersSent']  = 1;
 $CONF['alertOnSecurityRisk'] = 1;
-/*$CONF['ItemURL'] = $CONF['Self'];
-$CONF['ArchiveURL'] = $CONF['Self'];
-$CONF['ArchiveListURL'] = $CONF['Self'];
-$CONF['MemberURL'] = $CONF['Self'];
-$CONF['SearchURL'] = $CONF['Self'];
-$CONF['BlogURL'] = $CONF['Self'];
-$CONF['CategoryURL'] = $CONF['Self'];
+/*$CONF['ItemURL']           = $CONF['Self'];
+$CONF['ArchiveURL']          = $CONF['Self'];
+$CONF['ArchiveListURL']      = $CONF['Self'];
+$CONF['MemberURL']           = $CONF['Self'];
+$CONF['SearchURL']           = $CONF['Self'];
+$CONF['BlogURL']             = $CONF['Self'];
+$CONF['CategoryURL']         = $CONF['Self'];
 
 // switch URLMode back to normal when $CONF['Self'] ends in .php
 // this avoids urls like index.php/item/13/index.php/item/15
 if (!isset($CONF['URLMode']) || (($CONF['URLMode'] == 'pathinfo') && (substr($CONF['Self'], strlen($CONF['Self']) - 4) == '.php'))) {
-	$CONF['URLMode'] = 'normal';
+    $CONF['URLMode'] = 'normal';
 }*/
 
 if (getNucleusPatchLevel() > 0) {
-	$nucleus['version'] .= '/' . getNucleusPatchLevel();
+    $nucleus['version'] .= '/' . getNucleusPatchLevel();
 }
 
 // Avoid notices
 if (!isset($CONF['installscript'])) {
-	$CONF['installscript'] = 0;
+    $CONF['installscript'] = 0;
 }
 
 // we will use postVar, getVar, ... methods instead of HTTP_GET_VARS or _GET
 if ($CONF['installscript'] != 1) { // vars were already included in install.php
-	if (phpversion() >= '4.1.0') {
-		include_once($DIR_LIBS . 'vars4.1.0.php');
-	} else {
-		include_once($DIR_LIBS . 'vars4.0.6.php');
-	}
+    if (phpversion() >= '4.1.0') {
+        include_once($DIR_LIBS . 'vars4.1.0.php');
+    } else {
+        include_once($DIR_LIBS . 'vars4.0.6.php');
+    }
 }
 
 // sanitize option
@@ -89,31 +90,40 @@
 sanitizeParams();
 
 // get all variables that can come from the request and put them in the global scope
-$blogid	= requestVar('blogid');
-$itemid	= intRequestVar('itemid');
-$catid = intRequestVar('catid');
-$skinid	= requestVar('skinid');
-$memberid = requestVar('memberid');
-$archivelist = requestVar('archivelist');
-$imagepopup = requestVar('imagepopup');
-$archive = requestVar('archive');
-$query = requestVar('query');
-$highlight = requestVar('highlight');
-$amount = requestVar('amount');
-$action = requestVar('action');
-$nextaction = requestVar('nextaction');
-$maxresults = requestVar('maxresults');
-$startpos = intRequestVar('startpos');
+$blogid       = requestVar('blogid');
+$itemid       = intRequestVar('itemid');
+$catid        = intRequestVar('catid');
+$skinid       = requestVar('skinid');
+$memberid     = requestVar('memberid');
+$archivelist  = requestVar('archivelist');
+$imagepopup   = requestVar('imagepopup');
+$archive      = requestVar('archive');
+$query        = requestVar('query');
+$highlight    = requestVar('highlight');
+$amount       = requestVar('amount');
+$action       = requestVar('action');
+$nextaction   = requestVar('nextaction');
+$maxresults   = requestVar('maxresults');
+$startpos     = intRequestVar('startpos');
 $errormessage = '';
-$error = '';
-$virtualpath = ((getVar('virtualpath') != null) ? getVar('virtualpath') : serverVar('PATH_INFO'));
+$error        = '';
+$special      = requestVar('special');
+$virtualpath  = ((getVar('virtualpath') != null) ? getVar('virtualpath') : serverVar('PATH_INFO'));
 
 if (!headers_sent() ) {
-	header('Generator: Nucleus CMS ' . $nucleus['version']);
+    header('Generator: Nucleus CMS ' . $nucleus['version']);
 }
 
 // include core classes that are needed for login & plugin handling
-include($DIR_LIBS . 'mysql.php');
+// added for 3.5 sql_* wrapper
+global $MYSQL_HANDLER;
+if (!isset($MYSQL_HANDLER))
+    $MYSQL_HANDLER = array('mysql','');
+if ($MYSQL_HANDLER[0] == '')
+    $MYSQL_HANDLER[0] = 'mysql';
+include_once($DIR_LIBS . 'sql/'.$MYSQL_HANDLER[0].'.php');
+// end new for 3.5 sql_* wrapper
+include_once($DIR_LIBS . 'mysql.php');
 include($DIR_LIBS . 'MEMBER.php');
 include($DIR_LIBS . 'ACTIONLOG.php');
 include($DIR_LIBS . 'MANAGER.php');
@@ -122,17 +132,20 @@
 $manager =& MANAGER::instance();
 
 // make sure there's no unnecessary escaping:
-set_magic_quotes_runtime(0);
+//set_magic_quotes_runtime(0);
+if (version_compare(PHP_VERSION, '5.3.0', '<')) {
+    ini_set('magic_quotes_runtime', '0');
+}
 
 // Avoid notices
 if (!isset($CONF['UsingAdminArea'])) {
-	$CONF['UsingAdminArea'] = 0;
+    $CONF['UsingAdminArea'] = 0;
 }
 
 // only needed when updating logs
 if ($CONF['UsingAdminArea']) {
-	include($DIR_LIBS . 'xmlrpc.inc.php');	// XML-RPC client classes
-	include_once($DIR_LIBS . 'ADMIN.php');
+    include($DIR_LIBS . 'xmlrpc.inc.php');  // XML-RPC client classes
+    include_once($DIR_LIBS . 'ADMIN.php');
 }
 
 // connect to database
@@ -141,8 +154,8 @@
 
 // logs sanitized result if need
 if ($orgRequestURI!==serverVar('REQUEST_URI')) {
-	$msg = "Sanitized [" . serverVar('REMOTE_ADDR') . "] ";
-	$msg .= $orgRequestURI . " -> " . serverVar('REQUEST_URI');
+    $msg = "Sanitized [" . serverVar('REMOTE_ADDR') . "] ";
+    $msg .= $orgRequestURI . " -> " . serverVar('REQUEST_URI');
     if ($bLoggingSanitizedResult) {
         addToLog(WARNING, $msg);
     }
@@ -159,19 +172,19 @@
 
 // Properly set $CONF['Self'] and others if it's not set... usually when we are access from admin menu
 if (!isset($CONF['Self'])) {
-	$CONF['Self'] = $CONF['IndexURL'];
-	// strip trailing /
-	if ($CONF['Self'][strlen($CONF['Self']) -1] == "/") {
-		$CONF['Self'] = substr($CONF['Self'], 0, strlen($CONF['Self']) -1);
-	}
-
-/*	$CONF['ItemURL'] = $CONF['Self'];
-	$CONF['ArchiveURL'] = $CONF['Self'];
-	$CONF['ArchiveListURL'] = $CONF['Self'];
-	$CONF['MemberURL'] = $CONF['Self'];
-	$CONF['SearchURL'] = $CONF['Self'];
-	$CONF['BlogURL'] = $CONF['Self'];
-	$CONF['CategoryURL'] = $CONF['Self']; */
+    $CONF['Self'] = $CONF['IndexURL'];
+    // strip trailing /
+    if ($CONF['Self'][strlen($CONF['Self']) -1] == "/") {
+        $CONF['Self'] = substr($CONF['Self'], 0, strlen($CONF['Self']) -1);
+    }
+
+/*	$CONF['ItemURL']        = $CONF['Self'];
+    $CONF['ArchiveURL']     = $CONF['Self'];
+    $CONF['ArchiveListURL'] = $CONF['Self'];
+    $CONF['MemberURL']      = $CONF['Self'];
+    $CONF['SearchURL']      = $CONF['Self'];
+    $CONF['BlogURL']        = $CONF['Self'];
+    $CONF['CategoryURL']    = $CONF['Self'];*/
 }
 
 $CONF['ItemURL'] = $CONF['Self'];
@@ -185,12 +198,12 @@
 // switch URLMode back to normal when $CONF['Self'] ends in .php
 // this avoids urls like index.php/item/13/index.php/item/15
 if (!isset($CONF['URLMode']) || (($CONF['URLMode'] == 'pathinfo') && (substr($CONF['Self'], strlen($CONF['Self']) - 4) == '.php'))) {
-	$CONF['URLMode'] = 'normal';
+    $CONF['URLMode'] = 'normal';
 }
 
 // automatically use simpler toolbar for mozilla
 if (($CONF['DisableJsTools'] == 0) && strstr(serverVar('HTTP_USER_AGENT'), 'Mozilla/5.0') && strstr(serverVar('HTTP_USER_AGENT'), 'Gecko') ) {
-	$CONF['DisableJsTools'] = 2;
+    $CONF['DisableJsTools'] = 2;
 }
 
 // login if cookies set
@@ -200,99 +213,99 @@
 if (!isset($CONF['secureCookieKey'])) $CONF['secureCookieKey']=24;
 switch($CONF['secureCookieKey']){
 case 8:
-	$CONF['secureCookieKeyIP']=preg_replace('/\.[0-9]+\.[0-9]+\.[0-9]+$/','',serverVar('REMOTE_ADDR'));
-	break;
+    $CONF['secureCookieKeyIP']=preg_replace('/\.[0-9]+\.[0-9]+\.[0-9]+$/','',serverVar('REMOTE_ADDR'));
+    break;
 case 16:
-	$CONF['secureCookieKeyIP']=preg_replace('/\.[0-9]+\.[0-9]+$/','',serverVar('REMOTE_ADDR'));
-	break;
+    $CONF['secureCookieKeyIP']=preg_replace('/\.[0-9]+\.[0-9]+$/','',serverVar('REMOTE_ADDR'));
+    break;
 case 24:
-	$CONF['secureCookieKeyIP']=preg_replace('/\.[0-9]+$/','',serverVar('REMOTE_ADDR'));
-	break;
+    $CONF['secureCookieKeyIP']=preg_replace('/\.[0-9]+$/','',serverVar('REMOTE_ADDR'));
+    break;
 case 32:
-	$CONF['secureCookieKeyIP']=serverVar('REMOTE_ADDR');
-	break;
+    $CONF['secureCookieKeyIP']=serverVar('REMOTE_ADDR');
+    break;
 default:
-	$CONF['secureCookieKeyIP']='';
+    $CONF['secureCookieKeyIP']='';
 }
 
 // login/logout when required or renew cookies
 if ($action == 'login') {
-	// Form Authentication
-	$login = postVar('login');
-	$pw = postVar('password');
-	$shared	= intPostVar('shared');	// shared computer or not
-
-	$pw=substr($pw,0,40); // avoid md5 collision by using a long key
-
-	if ($member->login($login, $pw) ) {
-
-		$member->newCookieKey();
-		$member->setCookies($shared);
-
-		if ($CONF['secureCookieKey']!=='none') {
-			// secure cookie key
-			$member->setCookieKey(md5($member->getCookieKey().$CONF['secureCookieKeyIP']));
-			$member->write();
-		}
-
-		// allows direct access to parts of the admin area after logging in
-		if ($nextaction) {
-			$action = $nextaction;
-		}
-
-		$manager->notify('LoginSuccess', array('member' => &$member) );
-		$errormessage = '';
-		ACTIONLOG::add(INFO, "Login successful for $login (sharedpc=$shared)");
-	} else {
-		// errormessage for [%errordiv%]
-		$errormessage = 'Login failed for ' . $login;
-
-		$manager->notify('LoginFailed', array('username' => $login) );
-		ACTIONLOG::add(INFO, $errormessage);
-	}
+    // Form Authentication
+    $login = postVar('login');
+    $pw = postVar('password');
+    $shared = intPostVar('shared'); // shared computer or not
+
+    $pw=substr($pw,0,40); // avoid md5 collision by using a long key
+
+    if ($member->login($login, $pw) ) {
+
+        $member->newCookieKey();
+        $member->setCookies($shared);
+
+        if ($CONF['secureCookieKey']!=='none') {
+            // secure cookie key
+            $member->setCookieKey(md5($member->getCookieKey().$CONF['secureCookieKeyIP']));
+            $member->write();
+        }
+
+        // allows direct access to parts of the admin area after logging in
+        if ($nextaction) {
+            $action = $nextaction;
+        }
+
+        $manager->notify('LoginSuccess', array('member' => &$member, 'username' => $login) );
+        $errormessage = '';
+        ACTIONLOG::add(INFO, "Login successful for $login (sharedpc=$shared)");
+    } else {
+        // errormessage for [%errordiv%]
+        $errormessage = 'Login failed for ' . $login;
+
+        $manager->notify('LoginFailed', array('username' => $login) );
+        ACTIONLOG::add(INFO, $errormessage);
+    }
 /*
 
 Backed out for now: See http://forum.nucleuscms.org/viewtopic.php?t=3684 for details
 
 } elseif (serverVar('PHP_AUTH_USER') && serverVar('PHP_AUTH_PW')) {
-	// HTTP Authentication
-	$login  = serverVar('PHP_AUTH_USER');
-	$pw     = serverVar('PHP_AUTH_PW');
-
-	if ($member->login($login, $pw) ) {
-		$manager->notify('LoginSuccess',array('member' => &$member));
-		ACTIONLOG::add(INFO, "HTTP authentication successful for $login");
-	} else {
-		$manager->notify('LoginFailed',array('username' => $login));
-		ACTIONLOG::add(INFO, 'HTTP authentication failed for ' . $login);
-
-		//Since bad credentials, generate an apropriate error page
-		header("WWW-Authenticate: Basic realm=\"Nucleus CMS {$nucleus['version']}\"");
-		header('HTTP/1.0 401 Unauthorized');
-		echo 'Invalid username or password';
-		exit;
-	}
+    // HTTP Authentication
+    $login  = serverVar('PHP_AUTH_USER');
+    $pw     = serverVar('PHP_AUTH_PW');
+
+    if ($member->login($login, $pw) ) {
+        $manager->notify('LoginSuccess',array('member' => &$member));
+        ACTIONLOG::add(INFO, "HTTP authentication successful for $login");
+    } else {
+        $manager->notify('LoginFailed',array('username' => $login));
+        ACTIONLOG::add(INFO, 'HTTP authentication failed for ' . $login);
+
+        //Since bad credentials, generate an apropriate error page
+        header("WWW-Authenticate: Basic realm=\"Nucleus CMS {$nucleus['version']}\"");
+        header('HTTP/1.0 401 Unauthorized');
+        echo 'Invalid username or password';
+        exit;
+    }
 */
 
 } elseif (($action == 'logout') && (!headers_sent() ) && cookieVar($CONF['CookiePrefix'] . 'user') ) {
-	// remove cookies on logout
-	setcookie($CONF['CookiePrefix'] . 'user', '', (time() - 2592000), $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
-	setcookie($CONF['CookiePrefix'] . 'loginkey', '', (time() - 2592000), $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
-	$manager->notify('Logout', array('username' => cookieVar($CONF['CookiePrefix'] . 'user') ) );
+    // remove cookies on logout
+    setcookie($CONF['CookiePrefix'] . 'user', '', (time() - 2592000), $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
+    setcookie($CONF['CookiePrefix'] . 'loginkey', '', (time() - 2592000), $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
+    $manager->notify('Logout', array('username' => cookieVar($CONF['CookiePrefix'] . 'user') ) );
 } elseif (cookieVar($CONF['CookiePrefix'] . 'user') ) {
-	// Cookie Authentication
-	$ck=cookieVar($CONF['CookiePrefix'] . 'loginkey');
-	// secure cookie key
-	$ck=substr($ck,0,32); // avoid md5 collision by using a long key
-	if ($CONF['secureCookieKey']!=='none') $ck=md5($ck.$CONF['secureCookieKeyIP']);
-	$res = $member->cookielogin(cookieVar($CONF['CookiePrefix'] . 'user'), $ck );
-	unset($ck);
-
-	// renew cookies when not on a shared computer
-	if ($res && (cookieVar($CONF['CookiePrefix'] . 'sharedpc') != 1) && (!headers_sent() ) ) {
-		$member->setCookieKey(cookieVar($CONF['CookiePrefix'] . 'loginkey'));
-		$member->setCookies();
-	}
+    // Cookie Authentication
+    $ck=cookieVar($CONF['CookiePrefix'] . 'loginkey');
+    // secure cookie key
+    $ck=substr($ck,0,32); // avoid md5 collision by using a long key
+    if ($CONF['secureCookieKey']!=='none') $ck=md5($ck.$CONF['secureCookieKeyIP']);
+    $res = $member->cookielogin(cookieVar($CONF['CookiePrefix'] . 'user'), $ck );
+    unset($ck);
+
+    // renew cookies when not on a shared computer
+    if ($res && (cookieVar($CONF['CookiePrefix'] . 'sharedpc') != 1) && (!headers_sent() ) ) {
+        $member->setCookieKey(cookieVar($CONF['CookiePrefix'] . 'loginkey'));
+        $member->setCookies();
+    }
 }
 
 // login completed
@@ -301,8 +314,8 @@
 
 // first, let's see if the site is disabled or not. always allow admin area access.
 if ($CONF['DisableSite'] && !$member->isAdmin() && !$CONF['UsingAdminArea']) {
-	redirect($CONF['DisableSiteURL']);
-	exit;
+    redirect($CONF['DisableSiteURL']);
+    exit;
 }
 
 // load other classes
@@ -323,174 +336,176 @@
 
 // set lastVisit cookie (if allowed)
 if (!headers_sent() ) {
-	if ($CONF['LastVisit']) {
-		setcookie($CONF['CookiePrefix'] . 'lastVisit', time(), time() + 2592000, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
-	} else {
-		setcookie($CONF['CookiePrefix'] . 'lastVisit', '', (time() - 2592000), $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
-	}
+    if ($CONF['LastVisit']) {
+        setcookie($CONF['CookiePrefix'] . 'lastVisit', time(), time() + 2592000, $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
+    } else {
+        setcookie($CONF['CookiePrefix'] . 'lastVisit', '', (time() - 2592000), $CONF['CookiePath'], $CONF['CookieDomain'], $CONF['CookieSecure']);
+    }
 }
 
 // read language file, only after user has been initialized
 $language = getLanguageName();
-include($DIR_LANG . ereg_replace( '[\\|/]', '', $language) . '.php');
+//include($DIR_LANG . ereg_replace( '[\\|/]', '', $language) . '.php');
+include($DIR_LANG . preg_replace( '@\\|/@', '', $language) . '.php');
 
 /*
-	Backed out for now: See http://forum.nucleuscms.org/viewtopic.php?t=3684 for details
+    Backed out for now: See http://forum.nucleuscms.org/viewtopic.php?t=3684 for details
 
 // To remove after v2.5 is released and language files have been updated.
 // Including this makes sure that language files for v2.5beta can still be used for v2.5final
 // without having weird _SETTINGS_EXTAUTH string showing up in the admin area.
 if (!defined('_MEMBERS_BYPASS'))
 {
-	define('_SETTINGS_EXTAUTH',			'Enable External Authentication');
-	define('_WARNING_EXTAUTH',			'Warning: Enable only if needed.');
-	define('_MEMBERS_BYPASS',			'Use External Authentication');
+    define('_SETTINGS_EXTAUTH',         'Enable External Authentication');
+    define('_WARNING_EXTAUTH',          'Warning: Enable only if needed.');
+    define('_MEMBERS_BYPASS',           'Use External Authentication');
 }
 
 */
 
 // make sure the archivetype skinvar keeps working when _ARCHIVETYPE_XXX not defined
 if (!defined('_ARCHIVETYPE_MONTH') ) {
-	define('_ARCHIVETYPE_DAY', 'day');
-	define('_ARCHIVETYPE_MONTH', 'month');
+    define('_ARCHIVETYPE_DAY', 'day');
+    define('_ARCHIVETYPE_MONTH', 'month');
+    define('_ARCHIVETYPE_YEAR', 'year');
 }
 
 // decode path_info
 if ($CONF['URLMode'] == 'pathinfo') {
-	// initialize keywords if this hasn't been done before
-	if (!isset($CONF['ItemKey']) || $CONF['ItemKey'] == '') {
-		$CONF['ItemKey'] = 'item';
-	}
-
-	if (!isset($CONF['ArchiveKey']) || $CONF['ArchiveKey'] == '') {
-		$CONF['ArchiveKey'] = 'archive';
-	}
-
-	if (!isset($CONF['ArchivesKey']) || $CONF['ArchivesKey'] == '') {
-		$CONF['ArchivesKey'] = 'archives';
-	}
-
-	if (!isset($CONF['MemberKey']) || $CONF['MemberKey'] == '') {
-		$CONF['MemberKey'] = 'member';
-	}
-
-	if (!isset($CONF['BlogKey']) || $CONF['BlogKey'] == '') {
-		$CONF['BlogKey'] = 'blog';
-	}
-
-	if (!isset($CONF['CategoryKey']) || $CONF['CategoryKey'] == '') {
-		$CONF['CategoryKey'] = 'category';
-	}
-
-	if (!isset($CONF['SpecialskinKey']) || $CONF['SpecialskinKey'] == '') {
-		$CONF['SpecialskinKey'] = 'special';
-	}
-
-	$parsed = false;
-	$manager->notify(
-		'ParseURL',
-		array(
-			'type' => basename(serverVar('SCRIPT_NAME') ), // e.g. item, blog, ...
-			'info' => $virtualpath,
-			'complete' => &$parsed
-		)
-	);
-
-	if (!$parsed) {
-		// default implementation
-		$data = explode("/", $virtualpath );
-		for ($i = 0; $i < sizeof($data); $i++) {
-			switch ($data[$i]) {
-				case $CONF['ItemKey']: // item/1 (blogid)
-					$i++;
-
-					if ($i < sizeof($data) ) {
-						$itemid = intval($data[$i]);
-					}
-					break;
-
-				case $CONF['ArchivesKey']: // archives/1 (blogid)
-					$i++;
-
-					if ($i < sizeof($data) ) {
-						$archivelist = intval($data[$i]);
-					}
-					break;
-
-				case $CONF['ArchiveKey']: // two possibilities: archive/yyyy-mm or archive/1/yyyy-mm (with blogid)
-					if ((($i + 1) < sizeof($data) ) && (!strstr($data[$i + 1], '-') ) ) {
-						$blogid = intval($data[++$i]);
-					}
-
-					$i++;
-
-					if ($i < sizeof($data) ) {
-						$archive = $data[$i];
-					}
-					break;
-
-				case 'blogid': // blogid/1
-				case $CONF['BlogKey']: // blog/1
-					$i++;
-
-					if ($i < sizeof($data) ) {
-						$blogid = intval($data[$i]);
-					}
-					break;
-
-				case $CONF['CategoryKey']: // category/1 (catid)
-				case 'catid':
-					$i++;
-
-					if ($i < sizeof($data) ) {
-						$catid = intval($data[$i]);
-					}
-					break;
-
-				case $CONF['MemberKey']:
-					$i++;
-
-					if ($i < sizeof($data) ) {
-						$memberid = intval($data[$i]);
-					}
-					break;
+    // initialize keywords if this hasn't been done before
+    if (!isset($CONF['ItemKey']) || $CONF['ItemKey'] == '') {
+        $CONF['ItemKey'] = 'item';
+    }
+
+    if (!isset($CONF['ArchiveKey']) || $CONF['ArchiveKey'] == '') {
+        $CONF['ArchiveKey'] = 'archive';
+    }
+
+    if (!isset($CONF['ArchivesKey']) || $CONF['ArchivesKey'] == '') {
+        $CONF['ArchivesKey'] = 'archives';
+    }
+
+    if (!isset($CONF['MemberKey']) || $CONF['MemberKey'] == '') {
+        $CONF['MemberKey'] = 'member';
+    }
+
+    if (!isset($CONF['BlogKey']) || $CONF['BlogKey'] == '') {
+        $CONF['BlogKey'] = 'blog';
+    }
+
+    if (!isset($CONF['CategoryKey']) || $CONF['CategoryKey'] == '') {
+        $CONF['CategoryKey'] = 'category';
+    }
+
+    if (!isset($CONF['SpecialskinKey']) || $CONF['SpecialskinKey'] == '') {
+        $CONF['SpecialskinKey'] = 'special';
+    }
+
+    $parsed = false;
+    $manager->notify(
+        'ParseURL',
+        array(
+            'type' => basename(serverVar('SCRIPT_NAME') ), // e.g. item, blog, ...
+            'info' => $virtualpath,
+            'complete' => &$parsed
+        )
+    );
+
+    if (!$parsed) {
+        // default implementation
+        $data = explode("/", $virtualpath );
+        for ($i = 0; $i < sizeof($data); $i++) {
+            switch ($data[$i]) {
+                case $CONF['ItemKey']: // item/1 (blogid)
+                    $i++;
+
+                    if ($i < sizeof($data) ) {
+                        $itemid = intval($data[$i]);
+                    }
+                    break;
+
+                case $CONF['ArchivesKey']: // archives/1 (blogid)
+                    $i++;
+
+                    if ($i < sizeof($data) ) {
+                        $archivelist = intval($data[$i]);
+                    }
+                    break;
+
+                case $CONF['ArchiveKey']: // two possibilities: archive/yyyy-mm or archive/1/yyyy-mm (with blogid)
+                    if ((($i + 1) < sizeof($data) ) && (!strstr($data[$i + 1], '-') ) ) {
+                        $blogid = intval($data[++$i]);
+                    }
+
+                    $i++;
+
+                    if ($i < sizeof($data) ) {
+                        $archive = $data[$i];
+                    }
+                    break;
+
+                case 'blogid': // blogid/1
+                case $CONF['BlogKey']: // blog/1
+                    $i++;
+
+                    if ($i < sizeof($data) ) {
+                        $blogid = intval($data[$i]);
+                    }
+                    break;
+
+                case $CONF['CategoryKey']: // category/1 (catid)
+                case 'catid':
+                    $i++;
+
+                    if ($i < sizeof($data) ) {
+                        $catid = intval($data[$i]);
+                    }
+                    break;
+
+                case $CONF['MemberKey']:
+                    $i++;
+
+                    if ($i < sizeof($data) ) {
+                        $memberid = intval($data[$i]);
+                    }
+                    break;
 
                 case $CONF['SpecialskinKey']:
                     $i++;
 
-					if ($i < sizeof($data) ) {
-                    	$_REQUEST['special'] = $data[$i];
+                    if ($i < sizeof($data) ) {
+                        $_REQUEST['special'] = $data[$i];
                     }
                     break;
 
-				default:
-					// skip...
-			}
-		}
-	}
+                default:
+                    // skip...
+            }
+        }
+    }
 }
 
 function intPostVar($name) {
-	return intval(postVar($name) );
+    return intval(postVar($name) );
 }
 
 function intGetVar($name) {
-	return intval(getVar($name) );
+    return intval(getVar($name) );
 }
 
 function intRequestVar($name) {
-	return intval(requestVar($name) );
+    return intval(requestVar($name) );
 }
 
 function intCookieVar($name) {
-	return intval(cookieVar($name) );
+    return intval(cookieVar($name) );
 }
 
 /**
   * returns the currently used version (100 = 1.00, 101 = 1.01, etc...)
   */
 function getNucleusVersion() {
-	return 341;
+    return 351;
 }
 
 /**
@@ -499,105 +514,129 @@
  * be tested without having to install CVS.
  */
 function getNucleusPatchLevel() {
-	return 0;
+    return 0;
+}
+
+/**
+ * returns the latest version available for download from nucleuscms.org 
+ * or false if unable to attain data
+ * format will be major.minor/patachlevel
+ * e.g. 3.41 or 3.41/02
+ */
+function getLatestVersion() {
+    if (!function_exists('curl_init')) return false;
+    $crl = curl_init();
+    $timeout = 5;
+    curl_setopt ($crl, CURLOPT_URL,'http://nucleuscms.org/version_check.php');
+    curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
+    $ret = curl_exec($crl);
+    curl_close($crl);
+    return $ret;
+
 }
 
 /**
   * Connects to mysql server
   */
+/* moved to $DIR_LIBS/sql/*.php handler files
 function sql_connect() {
-	global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_CONN;
+    global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_CONN;
 
-	$MYSQL_CONN = @mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD) or startUpError('<p>Could not connect to MySQL database.</p>', 'Connect Error');
-	mysql_select_db($MYSQL_DATABASE) or startUpError('<p>Could not select database: ' . mysql_error() . '</p>', 'Connect Error');
+    $MYSQL_CONN = @mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD) or startUpError('<p>Could not connect to MySQL database.</p>', 'Connect Error');
+    mysql_select_db($MYSQL_DATABASE) or startUpError('<p>Could not select database: ' . mysql_error() . '</p>', 'Connect Error');
 
-	return $MYSQL_CONN;
-}
+    return $MYSQL_CONN;
+}*/
 
 /**
  * returns a prefixed nucleus table name
  */
 function sql_table($name) {
-	global $MYSQL_PREFIX;
+    global $MYSQL_PREFIX;
 
-	if ($MYSQL_PREFIX) {
-		return $MYSQL_PREFIX . 'nucleus_' . $name;
-	} else {
-		return 'nucleus_' . $name;
-	}
+    if ($MYSQL_PREFIX) {
+        return $MYSQL_PREFIX . 'nucleus_' . $name;
+    } else {
+        return 'nucleus_' . $name;
+    }
 }
 
 function sendContentType($contenttype, $pagetype = '', $charset = _CHARSET) {
-	global $manager, $CONF;
+    global $manager, $CONF;
 
-	if (!headers_sent() ) {
-		// if content type is application/xhtml+xml, only send it to browsers
-		// that can handle it (IE6 cannot). Otherwise, send text/html
-
-		// v2.5: For admin area pages, keep sending text/html (unless it's a debug version)
-		//       application/xhtml+xml still causes too much problems with the javascript implementations
-
-		// v3.3: ($CONF['UsingAdminArea'] && !$CONF['debug']) gets removed,
-		//       application/xhtml+xml seems to be working, so we're going to use it if we can.
-		if (
-				($contenttype == 'application/xhtml+xml')
-			&&	(!stristr(serverVar('HTTP_ACCEPT'), 'application/xhtml+xml') )
-			) {
-			$contenttype = 'text/html';
-		}
-
-		$manager->notify(
-			'PreSendContentType',
-			array(
-				'contentType' => &$contenttype,
-				'charset' => &$charset,
-				'pageType' => $pagetype
-			)
-		);
-
-		// strip strange characters
-		$contenttype = preg_replace('|[^a-z0-9-+./]|i', '', $contenttype);
-		$charset = preg_replace('|[^a-z0-9-_]|i', '', $charset);
-
-		if ($charset != '') {
-			header('Content-Type: ' . $contenttype . '; charset=' . $charset);
-		} else {
-			header('Content-Type: ' . $contenttype);
-		}
-	}
+    if (!headers_sent() ) {
+        // if content type is application/xhtml+xml, only send it to browsers
+        // that can handle it (IE6 cannot). Otherwise, send text/html
+
+        // v2.5: For admin area pages, keep sending text/html (unless it's a debug version)
+        //       application/xhtml+xml still causes too much problems with the javascript implementations
+
+        // v3.3: ($CONF['UsingAdminArea'] && !$CONF['debug']) gets removed,
+        //       application/xhtml+xml seems to be working, so we're going to use it if we can.
+        if (
+                ($contenttype == 'application/xhtml+xml')
+            &&  (!stristr(serverVar('HTTP_ACCEPT'), 'application/xhtml+xml') )
+            ) {
+            $contenttype = 'text/html';
+        }
+        $manager->notify(
+            'PreSendContentType',
+            array(
+                'contentType' => &$contenttype,
+                'charset' => &$charset,
+                'pageType' => $pagetype
+            )
+        );
+        // strip strange characters
+        $contenttype = preg_replace('|[^a-z0-9-+./]|i', '', $contenttype);
+        $charset = preg_replace('|[^a-z0-9-_]|i', '', $charset);
+
+        if ($charset != '') {
+            header('Content-Type: ' . $contenttype . '; charset=' . $charset);
+        } else {
+            header('Content-Type: ' . $contenttype);
+        }
+    }
 }
 
 /**
- * Errors before the database connection has been made
+ * Errors before the database connection has been made - moved to 
  */
+/* moved to $DIR_LIBS/sql/*.php handler files
 function startUpError($msg, $title) {
-	?>
-	<html xmlns="http://www.w3.org/1999/xhtml">
-		<head><title><?php echo htmlspecialchars($title)?></title></head>
-		<body>
-			<h1><?php echo htmlspecialchars($title)?></h1>
-			<?php echo $msg?>
-		</body>
-	</html>
-	<?php	exit;
-}
+
+
+    ?>
+    <html xmlns="http://www.w3.org/1999/xhtml">
+        <head><title><?php echo htmlspecialchars($title)?></title></head>
+
+        <body>
+            <h1><?php echo htmlspecialchars($title)?></h1>
+            <?php echo $msg?>
+        </body>
+    </html>
+    <?php   exit;
+}*/
 
 /**
   * disconnects from SQL server
   */
+/* moved to $DIR_LIBS/sql/*.php handler files
 function sql_disconnect() {
-	@mysql_close();
-}
+    @mysql_close();
+}*/
 
 /**
   * executes an SQL query
   */
+/* moved to $DIR_LIBS/sql/*.php handler files
 function sql_query($query) {
-	global $SQLCount;
-	$SQLCount++;
-	$res = mysql_query($query) or print("mySQL error with query $query: " . mysql_error() . '<p />');
-	return $res;
-}
+    global $SQLCount;
+    $SQLCount++;
+    $res = mysql_query($query) or print("mySQL error with query $query: " . mysql_error() . '<p />');
+    return $res;
+}*/
 
 
 /**
@@ -612,467 +651,537 @@
  *
  */
 function highlight($text, $expression, $highlight) {
-	if (!$highlight || !$expression) {
-		return $text;
-	}
-
-	if (is_array($expression) && (count($expression) == 0) ) {
-		return $text;
-	}
-
-	// add a tag in front (is needed for preg_match_all to work correct)
-	$text = '<!--h-->' . $text;
-
-	// split the HTML up so we have HTML tags
-	// $matches[0][i] = HTML + text
-	// $matches[1][i] = HTML
-	// $matches[2][i] = text
-	preg_match_all('/(<[^>]+>)([^<>]*)/', $text, $matches);
-
-	// throw it all together again while applying the highlight to the text pieces
-	$result = '';
-	for ($i = 0; $i < sizeof($matches[2]); $i++) {
-		if ($i != 0) {
-			$result .= $matches[1][$i];
-		}
-
-		if (is_array($expression) ) {
-			foreach ($expression as $regex) {
-				if ($regex) {
-					$matches[2][$i] = @eregi_replace($regex, $highlight, $matches[2][$i]);
-				}
-			}
-
-			$result .= $matches[2][$i];
-		} else {
-			$result .= @eregi_replace($expression, $highlight, $matches[2][$i]);
-		}
-	}
+    if (!$highlight || !$expression) {
+        return $text;
+    }
 
-	return $result;
+    if (is_array($expression) && (count($expression) == 0) ) {
+        return $text;
+    }
+
+    // add a tag in front (is needed for preg_match_all to work correct)
+    $text = '<!--h-->' . $text;
+
+    // split the HTML up so we have HTML tags
+    // $matches[0][i] = HTML + text
+    // $matches[1][i] = HTML
+    // $matches[2][i] = text
+    preg_match_all('/(<[^>]+>)([^<>]*)/', $text, $matches);
+
+    // throw it all together again while applying the highlight to the text pieces
+    $result = '';
+    for ($i = 0; $i < sizeof($matches[2]); $i++) {
+        if ($i != 0) {
+            $result .= $matches[1][$i];
+        }
+
+        if (is_array($expression) ) {
+            foreach ($expression as $regex) {
+                if ($regex) {
+                    $matches[2][$i] = @eregi_replace($regex, $highlight, $matches[2][$i]);
+                }
+            }
+
+            $result .= $matches[2][$i];
+        } else {
+            $result .= @eregi_replace($expression, $highlight, $matches[2][$i]);
+        }
+    }
+
+    return $result;
 }
 
 /**
  * Parses a query into an array of expressions that can be passed on to the highlight method
  */
 function parseHighlight($query) {
-	// TODO: add more intelligent splitting logic
+    // TODO: add more intelligent splitting logic
 
-	// get rid of quotes
-	$query = preg_replace('/\'|"/', '', $query);
+    // get rid of quotes
+    $query = preg_replace('/\'|"/', '', $query);
 
-	if (!query) {
-		return array();
-	}
-
-	$aHighlight = explode(' ', $query);
-
-	for ($i = 0; $i < count($aHighlight); $i++) {
-		$aHighlight[$i] = trim($aHighlight[$i]);
-
-		if (strlen($aHighlight[$i]) < 3) {
-			unset($aHighlight[$i]);
-		}
-	}
-
-	if (count($aHighlight) == 1) {
-		return $aHighlight[0];
-	} else {
-		return $aHighlight;
-	}
+    if (!$query) {
+        return array();
+    }
+
+    $aHighlight = explode(' ', $query);
+
+    for ($i = 0; $i < count($aHighlight); $i++) {
+        $aHighlight[$i] = trim($aHighlight[$i]);
+
+        if (strlen($aHighlight[$i]) < 3) {
+            unset($aHighlight[$i]);
+        }
+    }
+
+    if (count($aHighlight) == 1) {
+        return $aHighlight[0];
+    } else {
+        return $aHighlight;
+    }
 }
 
 /**
   * Checks if email address is valid
   */
 function isValidMailAddress($address) {
-	if (preg_match('/^[a-zA-Z+0-9\._-]+@[a-zA-Z0-9\._-]+\.[A-Za-z]{2,5}$/', $address)) {
-		return 1;
-	} else {
-		return 0;
-	}
+    if (preg_match('/^[a-zA-Z+0-9\._-]+@[a-zA-Z0-9\._-]+\.[A-Za-z]{2,5}$/', $address)) {
+        return 1;
+    } else {
+        return 0;
+    }
 }
 
 
 // some helper functions
 function getBlogIDFromName($name) {
-	return quickQuery('SELECT bnumber as result FROM ' . sql_table('blog') . ' WHERE bshortname="' . addslashes($name) . '"');
+    return quickQuery('SELECT bnumber as result FROM ' . sql_table('blog') . ' WHERE bshortname="' . addslashes($name) . '"');
 }
 
 function getBlogNameFromID($id) {
-	return quickQuery('SELECT bname as result FROM ' . sql_table('blog') . ' WHERE bnumber=' . intval($id) );
+    return quickQuery('SELECT bname as result FROM ' . sql_table('blog') . ' WHERE bnumber=' . intval($id) );
 }
 
 function getBlogIDFromItemID($itemid) {
-	return quickQuery('SELECT iblog as result FROM ' . sql_table('item') . ' WHERE inumber=' . intval($itemid) );
+    return quickQuery('SELECT iblog as result FROM ' . sql_table('item') . ' WHERE inumber=' . intval($itemid) );
 }
 
 function getBlogIDFromCommentID($commentid) {
-	return quickQuery('SELECT cblog as result FROM ' . sql_table('comment') . ' WHERE cnumber=' . intval($commentid) );
+    return quickQuery('SELECT cblog as result FROM ' . sql_table('comment') . ' WHERE cnumber=' . intval($commentid) );
 }
 
 function getBlogIDFromCatID($catid) {
-	return quickQuery('SELECT cblog as result FROM ' . sql_table('category') . ' WHERE catid=' . intval($catid) );
+    return quickQuery('SELECT cblog as result FROM ' . sql_table('category') . ' WHERE catid=' . intval($catid) );
 }
 
 function getCatIDFromName($name) {
-	return quickQuery('SELECT catid as result FROM ' . sql_table('category') . ' WHERE cname="' . addslashes($name) . '"');
+    return quickQuery('SELECT catid as result FROM ' . sql_table('category') . ' WHERE cname="' . addslashes($name) . '"');
 }
 
 function quickQuery($q) {
-	$res = sql_query($q);
-	$obj = mysql_fetch_object($res);
+    $res = sql_query($q);
+    $obj = sql_fetch_object($res);
 	return $obj->result;
 }
 
 function getPluginNameFromPid($pid) {
-	$res = sql_query('SELECT pfile FROM ' . sql_table('plugin') . ' WHERE pid=' . intval($pid) );
-	$obj = mysql_fetch_object($res);
-	return $obj->pfile;
+    $res = sql_query('SELECT pfile FROM ' . sql_table('plugin') . ' WHERE pid=' . intval($pid) );
+    $obj = sql_fetch_object($res);
+    return $obj->pfile;
+//    return isset($obj->pfile) ? $obj->pfile : false;
 }
 
 function selector() {
-	global $itemid, $blogid, $memberid, $query, $amount, $archivelist, $maxresults;
-	global $archive, $skinid, $blog, $memberinfo, $CONF, $member;
-	global $imagepopup, $catid;
-	global $manager;
-
-	$actionNames = array('addcomment', 'sendmessage', 'createaccount', 'forgotpassword', 'votepositive', 'votenegative', 'plugin');
-	$action = requestVar('action');
-
-	if (in_array($action, $actionNames) ) {
-		global $DIR_LIBS, $errormessage;
-		include_once($DIR_LIBS . 'ACTION.php');
-		$a = new ACTION();
-		$errorInfo = $a->doAction($action);
-
-		if ($errorInfo) {
-			$errormessage = $errorInfo['message'];
-		}
-	}
-
-	// show error when headers already sent out
-	if (headers_sent() && $CONF['alertOnHeadersSent']) {
-
-		// try to get line number/filename (extra headers_sent params only exists in PHP 4.3+)
-		if (function_exists('version_compare') && version_compare('4.3.0', phpversion(), '<=') ) {
-			headers_sent($hsFile, $hsLine);
-			$extraInfo = ' in <code>' . $hsFile . '</code> line <code>' . $hsLine . '</code>';
-		} else {
-			$extraInfo = '';
-		}
-
-		startUpError(
-			'<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>',
-			'Page headers already sent'
-		);
-		exit;
-	}
-
-	// make is so ?archivelist without blogname or blogid shows the archivelist
-	// for the default weblog
-	if (serverVar('QUERY_STRING') == 'archivelist') {
-		$archivelist = $CONF['DefaultBlog'];
-	}
-
-	// now decide which type of skin we need
-	if ($itemid) {
-		// itemid given -> only show that item
-		$type = 'item';
-
-		if (!$manager->existsItem($itemid,0,0) ) {
-			doError(_ERROR_NOSUCHITEM);
-		}
-
-		global $itemidprev, $itemidnext, $catid, $itemtitlenext, $itemtitleprev;
-
-		// 1. get timestamp, blogid and catid for item
-		$query = 'SELECT itime, iblog, icat FROM ' . sql_table('item') . ' WHERE inumber=' . intval($itemid);
-		$res = sql_query($query);
-		$obj = mysql_fetch_object($res);
-
-		// if a different blog id has been set through the request or selectBlog(),
-		// deny access
-		if ($blogid && (intval($blogid) != $obj->iblog) ) {
-			doError(_ERROR_NOSUCHITEM);
-		}
-
-		// if a category has been selected which doesn't match the item, ignore the
-		// category. #85
-		if (($catid != 0) && ($catid != $obj->icat) ) {
-			$catid = 0;
-		}
-
-		$blogid = $obj->iblog;
-		$timestamp = strtotime($obj->itime);
-
-		$b =& $manager->getBlog($blogid);
-
-		if ($b->isValidCategory($catid) ) {
-			$catextra = ' and icat=' . $catid;
-		} else {
-			$catextra = '';
-		}
-
-		// get previous itemid and title
-		$query = 'SELECT inumber, ititle FROM ' . sql_table('item') . ' WHERE itime<' . mysqldate($timestamp) . ' and idraft=0 and iblog=' . $blogid . $catextra . ' ORDER BY itime DESC LIMIT 1';
-		$res = sql_query($query);
-
-		$obj = mysql_fetch_object($res);
-
-		if ($obj) {
-			$itemidprev = $obj->inumber;
-			$itemtitleprev = $obj->ititle;
-		}
-
-		// get next itemid and title
-		$query = 'SELECT inumber, ititle FROM ' . sql_table('item') . ' WHERE itime>' . mysqldate($timestamp) . ' and itime <= ' . mysqldate($b->getCorrectTime()) . ' and idraft=0 and iblog=' . $blogid . $catextra . ' ORDER BY itime ASC LIMIT 1';
-		$res = sql_query($query);
-
-		$obj = mysql_fetch_object($res);
-
-		if ($obj) {
-			$itemidnext = $obj->inumber;
-			$itemtitlenext = $obj->ititle;
-		}
-
-	} elseif ($archive) {
-		// show archive
-		$type = 'archive';
-
-		// get next and prev month links ...
-		global $archivenext, $archiveprev, $archivetype, $archivenextexists, $archiveprevexists;
-
-		// sql queries for the timestamp of the first and the last published item
-		$query = "SELECT UNIX_TIMESTAMP(itime) as result FROM ".sql_table('item')." WHERE idraft=0 ORDER BY itime ASC";
-		$first_timestamp=quickQuery ($query);
-		$query = "SELECT UNIX_TIMESTAMP(itime) as result FROM ".sql_table('item')." WHERE idraft=0 ORDER BY itime DESC";
-		$last_timestamp=quickQuery ($query);
-
-		sscanf($archive, '%d-%d-%d', $y, $m, $d);
-
-		if ($d != 0) {
-			$archivetype = _ARCHIVETYPE_DAY;
-			$t = mktime(0, 0, 0, $m, $d, $y);
-			// one day has 24 * 60 * 60 = 86400 seconds
-			$archiveprev = strftime('%Y-%m-%d', $t - 86400 );
-			// check for published items
-			if ($t > $first_timestamp) {
-				$archiveprevexists = true;
-			}
-			else {
-				$archiveprevexists = false;
-			}
-
-			// one day later
-			$t += 86400;
-			$archivenext = strftime('%Y-%m-%d', $t);
-			if ($t < $last_timestamp) {
-				$archivenextexists = true;
-			}
-			else {
-				$archivenextexists = false;
-			}
-
-		} else {
-			$archivetype = _ARCHIVETYPE_MONTH;
-			$t = mktime(0, 0, 0, $m, 1, $y);
-			// one day before is in the previous month
-			$archiveprev = strftime('%Y-%m', $t - 86400);
-			if ($t > $first_timestamp) {
-				$archiveprevexists = true;
-			}
-			else {
-				$archiveprevexists = false;
-			}
-
-			// timestamp for the next month
-			$t = mktime(0, 0, 0, $m+1, 1, $y);
-			$archivenext = strftime('%Y-%m', $t);
-			if ($t < $last_timestamp) {
-				$archivenextexists = true;
-			}
-			else {
-				$archivenextexists = false;
-			}
-		}
-
-	} elseif ($archivelist) {
-		$type = 'archivelist';
-
-		if (is_numeric($archivelist)) {
-			$blogid = intVal($archivelist);
-		} else {
-			$blogid = getBlogIDFromName($archivelist);
-		}
-
-		if (!$blogid) {
-			doError(_ERROR_NOSUCHBLOG);
-		}
-
-	} elseif ($query) {
-		global $startpos;
-		$type = 'search';
-		$query = stripslashes($query);
-
-		if (is_numeric($blogid)) {
-			$blogid = intVal($blogid);
-		} else {
-			$blogid = getBlogIDFromName($blogid);
-		}
-
-		if (!$blogid) {
-			doError(_ERROR_NOSUCHBLOG);
-		}
-
-	} elseif ($memberid) {
-		$type = 'member';
-
-		if (!MEMBER::existsID($memberid) ) {
-			doError(_ERROR_NOSUCHMEMBER);
-		}
-
-		$memberinfo = $manager->getMember($memberid);
-
-	} elseif ($imagepopup) {
-		// media object (images etc.)
-		$type = 'imagepopup';
-
-		// TODO: check if media-object exists
-		// TODO: set some vars?
-	} else {
-		// show regular index page
-		global $startpos;
-		$type = 'index';
-	}
-
-	// decide which blog should be displayed
-	if (!$blogid) {
-		$blogid = $CONF['DefaultBlog'];
-	}
-
-	$b =& $manager->getBlog($blogid);
-	$blog = $b;	// references can't be placed in global variables?
-
-	if (!$blog->isValid) {
-		doError(_ERROR_NOSUCHBLOG);
-	}
-
-	// set catid if necessary
-	if ($catid) {
-		$blog->setSelectedCategory($catid);
-	}
-
-	// decide which skin should be used
-	if ($skinid != '' && ($skinid == 0) ) {
-		selectSkin($skinid);
-	}
-
-	if (!$skinid) {
-		$skinid = $blog->getDefaultSkin();
-	}
-
-	$special = requestVar('special');
-	if (!empty($special) && isValidShortName($special)) {
-		$type = strtolower($special);
-	}
-
-	$skin = new SKIN($skinid);
-
-	if (!$skin->isValid) {
-		doError(_ERROR_NOSUCHSKIN);
-	}
+    global $itemid, $blogid, $memberid, $query, $amount, $archivelist, $maxresults;
+    global $archive, $skinid, $blog, $memberinfo, $CONF, $member;
+    global $imagepopup, $catid, $special;
+    global $manager;
+
+    $actionNames = array('addcomment', 'sendmessage', 'createaccount', 'forgotpassword', 'votepositive', 'votenegative', 'plugin');
+    $action = requestVar('action');
+
+    if (in_array($action, $actionNames) ) {
+        global $DIR_LIBS, $errormessage;
+        include_once($DIR_LIBS . 'ACTION.php');
+        $a = new ACTION();
+        $errorInfo = $a->doAction($action);
+
+        if ($errorInfo) {
+            $errormessage = $errorInfo['message'];
+        }
+    }
+
+    // show error when headers already sent out
+    if (headers_sent() && $CONF['alertOnHeadersSent']) {
+
+        // try to get line number/filename (extra headers_sent params only exists in PHP 4.3+)
+        if (function_exists('version_compare') && version_compare('4.3.0', phpversion(), '<=') ) {
+            headers_sent($hsFile, $hsLine);
+            $extraInfo = ' in <code>' . $hsFile . '</code> line <code>' . $hsLine . '</code>';
+        } else {
+            $extraInfo = '';
+        }
+
+        startUpError(
+            '<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>',
+            'Page headers already sent'
+        );
+        exit;
+    }
+
+    // make is so ?archivelist without blogname or blogid shows the archivelist
+    // for the default weblog
+    if (serverVar('QUERY_STRING') == 'archivelist') {
+        $archivelist = $CONF['DefaultBlog'];
+    }
+
+    // now decide which type of skin we need
+    if ($itemid) {
+        // itemid given -> only show that item
+        $type = 'item';
+
+        if (!$manager->existsItem($itemid,0,0) ) {
+            doError(_ERROR_NOSUCHITEM);
+        }
+
+        global $itemidprev, $itemidnext, $catid, $itemtitlenext, $itemtitleprev;
+
+        // 1. get timestamp, blogid and catid for item
+        $query = 'SELECT itime, iblog, icat FROM ' . sql_table('item') . ' WHERE inumber=' . intval($itemid);
+        $res = sql_query($query);
+        $obj = sql_fetch_object($res);
+
+        // if a different blog id has been set through the request or selectBlog(),
+        // deny access
+
+
+
+        if ($blogid && (intval($blogid) != $obj->iblog) ) {
+
+
+
+
+
+
+
+
+
+            doError(_ERROR_NOSUCHITEM);
+
+        }
+
+        // if a category has been selected which doesn't match the item, ignore the
+        // category. #85
+        if (($catid != 0) && ($catid != $obj->icat) ) {
+            $catid = 0;
+        }
+
+        $blogid = $obj->iblog;
+        $timestamp = strtotime($obj->itime);
+
+        $b =& $manager->getBlog($blogid);
+
+        if ($b->isValidCategory($catid) ) {
+            $catextra = ' and icat=' . $catid;
+        } else {
+            $catextra = '';
+        }
+
+        // get previous itemid and title
+        $query = 'SELECT inumber, ititle FROM ' . sql_table('item') . ' WHERE itime<' . mysqldate($timestamp) . ' and idraft=0 and iblog=' . $blogid . $catextra . ' ORDER BY itime DESC LIMIT 1';
+        $res = sql_query($query);
+
+        $obj = sql_fetch_object($res);
+
+        if ($obj) {
+            $itemidprev = $obj->inumber;
+            $itemtitleprev = $obj->ititle;
+        }
+
+        // get next itemid and title
+        $query = 'SELECT inumber, ititle FROM ' . sql_table('item') . ' WHERE itime>' . mysqldate($timestamp) . ' and itime <= ' . mysqldate($b->getCorrectTime()) . ' and idraft=0 and iblog=' . $blogid . $catextra . ' ORDER BY itime ASC LIMIT 1';
+        $res = sql_query($query);
+
+        $obj = sql_fetch_object($res);
+
+        if ($obj) {
+            $itemidnext = $obj->inumber;
+            $itemtitlenext = $obj->ititle;
+        }
+
+    } elseif ($archive) {
+        // show archive
+        $type = 'archive';
+
+        // get next and prev month links ...
+        global $archivenext, $archiveprev, $archivetype, $archivenextexists, $archiveprevexists;
+
+        // sql queries for the timestamp of the first and the last published item
+        $query = "SELECT UNIX_TIMESTAMP(itime) as result FROM ".sql_table('item')." WHERE idraft=0 ORDER BY itime ASC";
+        $first_timestamp=quickQuery ($query);
+        $query = "SELECT UNIX_TIMESTAMP(itime) as result FROM ".sql_table('item')." WHERE idraft=0 ORDER BY itime DESC";
+        $last_timestamp=quickQuery ($query);
+
+        sscanf($archive, '%d-%d-%d', $y, $m, $d);
+
+        if ($d != 0) {
+            $archivetype = _ARCHIVETYPE_DAY;
+            $t = mktime(0, 0, 0, $m, $d, $y);
+            // one day has 24 * 60 * 60 = 86400 seconds
+            $archiveprev = strftime('%Y-%m-%d', $t - 86400 );
+            // check for published items
+            if ($t > $first_timestamp) {
+                $archiveprevexists = true;
+            }
+            else {
+                $archiveprevexists = false;
+            }
+
+            // one day later
+            $t += 86400;
+            $archivenext = strftime('%Y-%m-%d', $t);
+            if ($t < $last_timestamp) {
+                $archivenextexists = true;
+            }
+            else {
+                $archivenextexists = false;
+            }
+
+        } elseif ($m == 0) {
+            $archivetype = _ARCHIVETYPE_YEAR;
+            $t = mktime(0, 0, 0, 12, 31, $y - 1);
+            // one day before is in the previous year
+            $archiveprev = strftime('%Y', $t);
+            if ($t > $first_timestamp) {
+                $archiveprevexists = true;
+            }
+            else {
+                $archiveprevexists = false;
+            }
+
+            // timestamp for the next year
+            $t = mktime(0, 0, 0, 1, 1, $y + 1);
+            $archivenext = strftime('%Y', $t);
+            if ($t < $last_timestamp) {
+                $archivenextexists = true;
+            }
+            else {
+                $archivenextexists = false;
+            }
+        } else {
+            $archivetype = _ARCHIVETYPE_MONTH;
+            $t = mktime(0, 0, 0, $m, 1, $y);
+            // one day before is in the previous month
+            $archiveprev = strftime('%Y-%m', $t - 86400);
+            if ($t > $first_timestamp) {
+                $archiveprevexists = true;
+            }
+            else {
+                $archiveprevexists = false;
+            }
+
+            // timestamp for the next month
+            $t = mktime(0, 0, 0, $m+1, 1, $y);
+            $archivenext = strftime('%Y-%m', $t);
+            if ($t < $last_timestamp) {
+                $archivenextexists = true;
+            }
+            else {
+                $archivenextexists = false;
+            }
+        }
+
+    } elseif ($archivelist) {
+        $type = 'archivelist';
+
+        if (is_numeric($archivelist)) {
+            $blogid = intVal($archivelist);
+        } else {
+            $blogid = getBlogIDFromName($archivelist);
+        }
+
+        if (!$blogid) {
+            doError(_ERROR_NOSUCHBLOG);
+        }
 
-	// parse the skin
-	$skin->parse($type);
+    } elseif ($query) {
+        global $startpos;
+        $type = 'search';
+        $query = stripslashes($query);
 
-	// check to see we should throw JustPosted event
-	$blog->checkJustPosted();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+        if (is_numeric($blogid)) {
+            $blogid = intVal($blogid);
+        } else {
+            $blogid = getBlogIDFromName($blogid);
+        }
+
+        if (!$blogid) {
+            doError(_ERROR_NOSUCHBLOG);
+        }
+
+    } elseif ($memberid) {
+        $type = 'member';
+
+        if (!MEMBER::existsID($memberid) ) {
+            doError(_ERROR_NOSUCHMEMBER);
+        }
+
+        $memberinfo = $manager->getMember($memberid);
+
+    } elseif ($imagepopup) {
+        // media object (images etc.)
+        $type = 'imagepopup';
+
+        // TODO: check if media-object exists
+        // TODO: set some vars?
+    } else {
+        // show regular index page
+        global $startpos;
+        $type = 'index';
+    }
+
+    // any type of skin with catid
+    if ($catid && !$blogid) {
+        $blogid = getBlogIDFromCatID($catid);
+    }
+
+    // decide which blog should be displayed
+    if (!$blogid) {
+        $blogid = $CONF['DefaultBlog'];
+    }
+
+    $b =& $manager->getBlog($blogid);
+    $blog = $b; // references can't be placed in global variables?
+
+    if (!$blog->isValid) {
+        doError(_ERROR_NOSUCHBLOG);
+    }
+
+    // set catid if necessary
+    if ($catid) {
+        // check if the category is valid
+        if (!$blog->isValidCategory($catid)) {
+            doError(_ERROR_NOSUCHCATEGORY);
+        } else {
+            $blog->setSelectedCategory($catid);
+        }
+    }
+
+    // decide which skin should be used
+    if ($skinid != '' && ($skinid == 0) ) {
+        selectSkin($skinid);
+    }
+
+    if (!$skinid) {
+        $skinid = $blog->getDefaultSkin();
+    }
+
+    //$special = requestVar('special'); //get at top of file as global
+    if (!empty($special) && isValidShortName($special)) {
+        $type = strtolower($special);
+    }
+
+    $skin = new SKIN($skinid);
+
+    if (!$skin->isValid) {
+        doError(_ERROR_NOSUCHSKIN);
+    }
+
+    // parse the skin
+    $skin->parse($type);
+
+    // check to see we should throw JustPosted event
+    $blog->checkJustPosted();
 }
 
 /**
   * Show error skin with given message. An optional skin-object to use can be given
   */
 function doError($msg, $skin = '') {
-	global $errormessage, $CONF, $skinid, $blogid, $manager;
+    global $errormessage, $CONF, $skinid, $blogid, $manager;
 
-	if ($skin == '') {
+    if ($skin == '') {
 
-		if (SKIN::existsID($skinid) ) {
-			$skin = new SKIN($skinid);
-		} elseif ($manager->existsBlogID($blogid) ) {
-			$blog =& $manager->getBlog($blogid);
-			$skin = new SKIN($blog->getDefaultSkin() );
-		} elseif ($CONF['DefaultBlog']) {
-			$blog =& $manager->getBlog($CONF['DefaultBlog']);
-			$skin = new SKIN($blog->getDefaultSkin() );
-		} else {
-			// this statement should actually never be executed
-			$skin = new SKIN($CONF['BaseSkin']);
-		}
-
-	}
-
-	$errormessage = $msg;
-	$skin->parse('error');
-	exit;
+        if (SKIN::existsID($skinid) ) {
+            $skin = new SKIN($skinid);
+        } elseif ($manager->existsBlogID($blogid) ) {
+            $blog =& $manager->getBlog($blogid);
+            $skin = new SKIN($blog->getDefaultSkin() );
+        } elseif ($CONF['DefaultBlog']) {
+            $blog =& $manager->getBlog($CONF['DefaultBlog']);
+            $skin = new SKIN($blog->getDefaultSkin() );
+        } else {
+            // this statement should actually never be executed
+            $skin = new SKIN($CONF['BaseSkin']);
+        }
+
+    }
+
+    $skinid = $skin->id;
+    $errormessage = $msg;
+    $skin->parse('error');
+    exit;
 }
 
 function getConfig() {
-	global $CONF;
+    global $CONF;
 
-	$query = 'SELECT * FROM ' . sql_table('config');
-	$res = sql_query($query);
+    $query = 'SELECT * FROM ' . sql_table('config');
+    $res = sql_query($query);
 
-	while ($obj = mysql_fetch_object($res) ) {
-		$CONF[$obj->name] = $obj->value;
-	}
+    while ($obj = sql_fetch_object($res) ) {
+        $CONF[$obj->name] = $obj->value;
+    }
 }
 
 // some checks for names of blogs, categories, templates, members, ...
 function isValidShortName($name) {
-	return eregi('^[a-z0-9]+$', $name);
+    return eregi('^[a-z0-9]+$', $name);
 }
 
 function isValidDisplayName($name) {
-	return eregi('^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$', $name);
+    return eregi('^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$', $name);
 }
 
 function isValidCategoryName($name) {
-	return 1;
+    return 1;
 }
 
 function isValidTemplateName($name) {
-	return eregi('^[a-z0-9/]+$', $name);
+    return eregi('^[a-z0-9/]+$', $name);
 }
 
 function isValidSkinName($name) {
-	return eregi('^[a-z0-9/]+$', $name);
+    return eregi('^[a-z0-9/]+$', $name);
 }
 
 // add and remove linebreaks
 function addBreaks($var) {
-	return nl2br($var);
+    return nl2br($var);
 }
 
 function removeBreaks($var) {
-	return preg_replace("/<br \/>([\r\n])/", "$1", $var);
+    return preg_replace("/<br \/>([\r\n])/", "$1", $var);
 }
 
 // shortens a text string to maxlength ($toadd) is what needs to be added
 // at the end (end length is <= $maxlength)
 function shorten($text, $maxlength, $toadd) {
-	// 1. remove entities...
-	$trans = get_html_translation_table(HTML_ENTITIES);
-	$trans = array_flip($trans);
-	$text = strtr($text, $trans);
-
-	// 2. the actual shortening
-	if (strlen($text) > $maxlength) {
-		$text = substr($text, 0, $maxlength - strlen($toadd) ) . $toadd;
-	}
+    // 1. remove entities...
+    $trans = get_html_translation_table(HTML_ENTITIES);
+
+    $trans = array_flip($trans);
+    $text = strtr($text, $trans);
+
+    // 2. the actual shortening
+    if (strlen($text) > $maxlength) {
+        $text = substr($text, 0, $maxlength - strlen($toadd) ) . $toadd;
+
+    }
 
-	return $text;
+    return $text;
 }
 
 /**
@@ -1080,25 +1189,25 @@
   * quotes around it.
   */
 function mysqldate($timestamp) {
-	return '"' . date('Y-m-d H:i:s', $timestamp) . '"';
+    return '"' . date('Y-m-d H:i:s', $timestamp) . '"';
 }
 
 /**
   * functions for use in index.php
   */
 function selectBlog($shortname) {
-	global $blogid, $archivelist;
-	$blogid = getBlogIDFromName($shortname);
+    global $blogid, $archivelist;
+    $blogid = getBlogIDFromName($shortname);
 
-	// also force archivelist variable, if it is set
-	if ($archivelist) {
-		$archivelist = $blogid;
-	}
+    // also force archivelist variable, if it is set
+    if ($archivelist) {
+        $archivelist = $blogid;
+    }
 }
 
 function selectSkin($skinname) {
-	global $skinid;
-	$skinid = SKIN::getIdFromName($skinname);
+    global $skinid;
+    $skinid = SKIN::getIdFromName($skinname);
 }
 
 /**
@@ -1106,85 +1215,86 @@
  * multiple categories can have the same name)
  */
 function selectCategory($cat) {
-	global $catid;
-	if (is_numeric($cat) ) {
-		$catid = intval($cat);
-	} else {
-		$catid = getCatIDFromName($cat);
-	}
+    global $catid;
+    if (is_numeric($cat) ) {
+        $catid = intval($cat);
+    } else {
+        $catid = getCatIDFromName($cat);
+    }
 }
 
 function selectItem($id) {
-	global $itemid;
-	$itemid = intval($id);
+    global $itemid;
+    $itemid = intval($id);
 }
 
 // force the use of a language file (warning: can cause warnings)
 function selectLanguage($language) {
-	global $DIR_LANG;
-	include($DIR_LANG . ereg_replace( '[\\|/]', '', $language) . '.php');
+    global $DIR_LANG;
+//    include($DIR_LANG . ereg_replace( '[\\|/]', '', $language) . '.php');
+    include($DIR_LANG . preg_replace( '@\\|/@', '', $language) . '.php');
 }
 
 function parseFile($filename, $includeMode = 'normal', $includePrefix = '') {
-	$handler = new ACTIONS('fileparser');
-	$parser = new PARSER(SKIN::getAllowedActionsForType('fileparser'), $handler);
-	$handler->parser =& $parser;
-
-	// set IncludeMode properties of parser
-	PARSER::setProperty('IncludeMode', $includeMode);
-	PARSER::setProperty('IncludePrefix', $includePrefix);
-
-	if (!file_exists($filename) ) {
-		doError('A file is missing');
-	}
-
-	$fsize = filesize($filename);
-
-	if ($fsize <= 0) {
-		return;
-	}
-
-	// read file
-	$fd = fopen ($filename, 'r');
-	$contents = fread ($fd, $fsize);
-	fclose ($fd);
+    $handler = new ACTIONS('fileparser');
+    $parser = new PARSER(SKIN::getAllowedActionsForType('fileparser'), $handler);
+    $handler->parser =& $parser;
+
+    // set IncludeMode properties of parser
+    PARSER::setProperty('IncludeMode', $includeMode);
+    PARSER::setProperty('IncludePrefix', $includePrefix);
+
+    if (!file_exists($filename) ) {
+        doError('A file is missing');
+    }
 
-	// parse file contents
-	$parser->parse($contents);
+    $fsize = filesize($filename);
+
+    if ($fsize <= 0) {
+        return;
+    }
+
+    // read file
+    $fd = fopen ($filename, 'r');
+    $contents = fread ($fd, $fsize);
+    fclose ($fd);
+
+    // parse file contents
+    $parser->parse($contents);
 }
 
 /**
   * Outputs a debug message
   */
 function debug($msg) {
-	echo '<p><b>' . $msg . "</b></p>\n";
+    echo '<p><b>' . $msg . "</b></p>\n";
 }
 
 // shortcut
 function addToLog($level, $msg) {
-	ACTIONLOG::add($level, $msg);
+    ACTIONLOG::add($level, $msg);
 }
 
 // shows a link to help file
 function help($id) {
-	echo helpHtml($id);
+    echo helpHtml($id);
 }
 
 function helpHtml($id) {
-	global $CONF;
-	return helplink($id) . '<img src="' . $CONF['AdminURL'] . 'documentation/icon-help.gif" width="15" height="15" alt="' . _HELP_TT . '" title="' . _HELP_TT . '" /></a>';
+    global $CONF;
+    return helplink($id) . '<img src="' . $CONF['AdminURL'] . 'documentation/icon-help.gif" width="15" height="15" alt="' . _HELP_TT . '" title="' . _HELP_TT . '" /></a>';
 }
 
 function helplink($id) {
-	global $CONF;
-	return '<a href="' . $CONF['AdminURL'] . 'documentation/help.html#'. $id . '" onclick="if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);">';
+    global $CONF;
+    return '<a href="' . $CONF['AdminURL'] . 'documentation/help.html#'. $id . '" onclick="if (event &amp;&amp; event.preventDefault) event.preventDefault(); return help(this.href);">';
 }
 
 function getMailFooter() {
-	$message = "\n\n-----------------------------";
-	$message .=  "\n   Powered by Nucleus CMS";
-	$message .=  "\n(http://www.nucleuscms.org/)";
-	return $message;
+    $message = "\n\n-----------------------------";
+    $message .=  "\n   Powered by Nucleus CMS";
+    $message .=  "\n(http://www.nucleuscms.org/)";
+    return $message;
 }
 
 /**
@@ -1195,174 +1305,176 @@
   * checks if file exists, etc...
   */
 function getLanguageName() {
-	global $CONF, $member;
+    global $CONF, $member;
+
+    if ($member && $member->isLoggedIn() ) {
+        // try to use members language
+        $memlang = $member->getLanguage();
 
-	if ($member && $member->isLoggedIn() ) {
-		// try to use members language
-		$memlang = $member->getLanguage();
-
-		if (($memlang != '') && (checkLanguage($memlang) ) ) {
-			return $memlang;
-		}
-	}
-
-	// use default language
-	if (checkLanguage($CONF['Language']) ) {
-		return $CONF['Language'];
-	} else {
-		return 'english';
-	}
+        if (($memlang != '') && (checkLanguage($memlang) ) ) {
+            return $memlang;
+        }
+    }
+
+    // use default language
+    if (checkLanguage($CONF['Language']) ) {
+        return $CONF['Language'];
+    } else {
+        return 'english';
+    }
 }
 
 /**
   * Includes a PHP file. This method can be called while parsing templates and skins
   */
 function includephp($filename) {
-	// make predefined variables global, so most simple scripts can be used here
+    // make predefined variables global, so most simple scripts can be used here
+
+    // apache (names taken from PHP doc)
+    global $GATEWAY_INTERFACE, $SERVER_NAME, $SERVER_SOFTWARE, $SERVER_PROTOCOL;
+    global $REQUEST_METHOD, $QUERY_STRING, $DOCUMENT_ROOT, $HTTP_ACCEPT;
+    global $HTTP_ACCEPT_CHARSET, $HTTP_ACCEPT_ENCODING, $HTTP_ACCEPT_LANGUAGE;
+    global $HTTP_CONNECTION, $HTTP_HOST, $HTTP_REFERER, $HTTP_USER_AGENT;
+    global $REMOTE_ADDR, $REMOTE_PORT, $SCRIPT_FILENAME, $SERVER_ADMIN;
+    global $SERVER_PORT, $SERVER_SIGNATURE, $PATH_TRANSLATED, $SCRIPT_NAME;
+    global $REQUEST_URI;
+
+    // php (taken from PHP doc)
+    global $argv, $argc, $PHP_SELF, $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS;
+    global $HTTP_POST_FILES, $HTTP_ENV_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS;
 
-	// apache (names taken from PHP doc)
-	global $GATEWAY_INTERFACE, $SERVER_NAME, $SERVER_SOFTWARE, $SERVER_PROTOCOL;
-	global $REQUEST_METHOD, $QUERY_STRING, $DOCUMENT_ROOT, $HTTP_ACCEPT;
-	global $HTTP_ACCEPT_CHARSET, $HTTP_ACCEPT_ENCODING, $HTTP_ACCEPT_LANGUAGE;
-	global $HTTP_CONNECTION, $HTTP_HOST, $HTTP_REFERER, $HTTP_USER_AGENT;
-	global $REMOTE_ADDR, $REMOTE_PORT, $SCRIPT_FILENAME, $SERVER_ADMIN;
-	global $SERVER_PORT, $SERVER_SIGNATURE, $PATH_TRANSLATED, $SCRIPT_NAME;
-	global $REQUEST_URI;
-
-	// php (taken from PHP doc)
-	global $argv, $argc, $PHP_SELF, $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS;
-	global $HTTP_POST_FILES, $HTTP_ENV_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS;
-
-	// other
-	global $PATH_INFO, $HTTPS, $HTTP_RAW_POST_DATA, $HTTP_X_FORWARDED_FOR;
-
-	if (@file_exists($filename) ) {
-		include($filename);
-	}
+    // other
+    global $PATH_INFO, $HTTPS, $HTTP_RAW_POST_DATA, $HTTP_X_FORWARDED_FOR;
+
+    if (@file_exists($filename) ) {
+        include($filename);
+    }
 }
 
 /**
   * Checks if a certain language/plugin exists
   */
 function checkLanguage($lang) {
-	global $DIR_LANG ;
-	return file_exists($DIR_LANG . ereg_replace( '[\\|/]', '', $lang) . '.php');
+    global $DIR_LANG ;
+//    return file_exists($DIR_LANG . ereg_replace( '[\\|/]', '', $lang) . '.php');
+    return file_exists($DIR_LANG . preg_replace( '@\\|/@', '', $lang) . '.php');
 }
 
 function checkPlugin($plug) {
-	global $DIR_PLUGINS;
-	return file_exists($DIR_PLUGINS . ereg_replace( '[\\|/]', '', $plug) . '.php');
+    global $DIR_PLUGINS;
+    return file_exists($DIR_PLUGINS . ereg_replace( '[\\|/]', '', $plug) . '.php');
+//    return file_exists($DIR_PLUGINS . preg_replace( '@\\|/@', '', $plug) . '.php');
 }
 
 /**
   * Centralisation of the functions that generate links
   */
 function createItemLink($itemid, $extra = '') {
-	return createLink('item', array('itemid' => $itemid, 'extra' => $extra) );
+    return createLink('item', array('itemid' => $itemid, 'extra' => $extra) );
 }
 
 function createMemberLink($memberid, $extra = '') {
-	return createLink('member', array('memberid' => $memberid, 'extra' => $extra) );
+    return createLink('member', array('memberid' => $memberid, 'extra' => $extra) );
 }
 
 function createCategoryLink($catid, $extra = '') {
-	return createLink('category', array('catid' => $catid, 'extra' => $extra) );
+    return createLink('category', array('catid' => $catid, 'extra' => $extra) );
 }
 
 function createArchiveListLink($blogid = '', $extra = '') {
-	return createLink('archivelist', array('blogid' => $blogid, 'extra' => $extra) );
+    return createLink('archivelist', array('blogid' => $blogid, 'extra' => $extra) );
 }
 
 function createArchiveLink($blogid, $archive, $extra = '') {
-	return createLink('archive', array('blogid' => $blogid, 'archive' => $archive, 'extra' => $extra) );
+    return createLink('archive', array('blogid' => $blogid, 'archive' => $archive, 'extra' => $extra) );
 }
 
 function createBlogidLink($blogid, $params = '') {
-	return createLink('blog', array('blogid' => $blogid, 'extra' => $params) );
+    return createLink('blog', array('blogid' => $blogid, 'extra' => $params) );
 }
 
 function createLink($type, $params) {
-	global $manager, $CONF;
+    global $manager, $CONF;
 
-	$generatedURL = '';
-	$usePathInfo = ($CONF['URLMode'] == 'pathinfo');
+    $generatedURL = '';
+    $usePathInfo = ($CONF['URLMode'] == 'pathinfo');
 
-	// ask plugins first
-	$created = false;
+    // ask plugins first
+    $created = false;
 
-	if ($usePathInfo) {
-		$manager->notify(
-			'GenerateURL',
-			array(
-				'type' => $type,
-				'params' => $params,
-				'completed' => &$created,
-				'url' => &$url
-			)
-		);
-	}
-
-	// if a plugin created the URL, return it
-	if ($created) {
-		return $url;
-	}
-
-	// default implementation
-	switch ($type) {
-		case 'item':
-			if ($usePathInfo) {
-				$url = $CONF['ItemURL'] . '/' . $CONF['ItemKey'] . '/' . $params['itemid'];
-			} else {
-				$url = $CONF['ItemURL'] . '?itemid=' . $params['itemid'];
-			}
-			break;
-
-		case 'member':
-			if ($usePathInfo) {
-				$url = $CONF['MemberURL'] . '/' . $CONF['MemberKey'] . '/' . $params['memberid'];
-			} else {
-				$url = $CONF['MemberURL'] . '?memberid=' . $params['memberid'];
-			}
-			break;
-
-		case 'category':
-			if ($usePathInfo) {
-				$url = $CONF['CategoryURL'] . '/' . $CONF['CategoryKey'] . '/' . $params['catid'];
-			} else {
-				$url = $CONF['CategoryURL'] . '?catid=' . $params['catid'];
-			}
-			break;
-
-		case 'archivelist':
-			if (!$params['blogid']) {
-				$params['blogid'] = $CONF['DefaultBlog'];
-			}
-
-			if ($usePathInfo) {
-				$url = $CONF['ArchiveListURL'] . '/' . $CONF['ArchivesKey'] . '/' . $params['blogid'];
-			} else {
-				$url = $CONF['ArchiveListURL'] . '?archivelist=' . $params['blogid'];
-			}
-			break;
-
-		case 'archive':
-			if ($usePathInfo) {
-				$url = $CONF['ArchiveURL'] . '/' . $CONF['ArchiveKey'] . '/'.$params['blogid'].'/' . $params['archive'];
-			} else {
-				$url = $CONF['ArchiveURL'] . '?blogid='.$params['blogid'].'&amp;archive=' . $params['archive'];
-			}
-			break;
-
-		case 'blog':
-			if ($usePathInfo) {
-				$url = $CONF['BlogURL'] . '/' . $CONF['BlogKey'] . '/' . $params['blogid'];
-			} else {
-				$url = $CONF['BlogURL'] . '?blogid=' . $params['blogid'];
-			}
-			break;
-	}
+    if ($usePathInfo) {
+        $manager->notify(
+            'GenerateURL',
+            array(
+                'type' => $type,
+                'params' => $params,
+                'completed' => &$created,
+                'url' => &$url
+            )
+        );
+    }
+
+    // if a plugin created the URL, return it
+    if ($created) {
+        return $url;
+    }
+
+    // default implementation
+    switch ($type) {
+        case 'item':
+            if ($usePathInfo) {
+                $url = $CONF['ItemURL'] . '/' . $CONF['ItemKey'] . '/' . $params['itemid'];
+            } else {
+                $url = $CONF['ItemURL'] . '?itemid=' . $params['itemid'];
+            }
+            break;
+
+        case 'member':
+            if ($usePathInfo) {
+                $url = $CONF['MemberURL'] . '/' . $CONF['MemberKey'] . '/' . $params['memberid'];
+            } else {
+                $url = $CONF['MemberURL'] . '?memberid=' . $params['memberid'];
+            }
+            break;
+
+        case 'category':
+            if ($usePathInfo) {
+                $url = $CONF['CategoryURL'] . '/' . $CONF['CategoryKey'] . '/' . $params['catid'];
+            } else {
+                $url = $CONF['CategoryURL'] . '?catid=' . $params['catid'];
+            }
+            break;
+
+        case 'archivelist':
+            if (!$params['blogid']) {
+                $params['blogid'] = $CONF['DefaultBlog'];
+            }
+
+            if ($usePathInfo) {
+                $url = $CONF['ArchiveListURL'] . '/' . $CONF['ArchivesKey'] . '/' . $params['blogid'];
+            } else {
+                $url = $CONF['ArchiveListURL'] . '?archivelist=' . $params['blogid'];
+            }
+            break;
+
+        case 'archive':
+            if ($usePathInfo) {
+                $url = $CONF['ArchiveURL'] . '/' . $CONF['ArchiveKey'] . '/'.$params['blogid'].'/' . $params['archive'];
+            } else {
+                $url = $CONF['ArchiveURL'] . '?blogid='.$params['blogid'].'&amp;archive=' . $params['archive'];
+            }
+            break;
+
+        case 'blog':
+            if ($usePathInfo) {
+                $url = $CONF['BlogURL'] . '/' . $CONF['BlogKey'] . '/' . $params['blogid'];
+            } else {
+                $url = $CONF['BlogURL'] . '?blogid=' . $params['blogid'];
+            }
+            break;
+    }
 
-	return addLinkParams($url, (isset($params['extra'])? $params['extra'] : null));
+    return addLinkParams($url, (isset($params['extra'])? $params['extra'] : null));
 }
 
 function createBlogLink($url, $params) {
@@ -1377,30 +1489,30 @@
     } elseif ($CONF['URLMode'] == 'pathinfo' && substr($url, -1) == '/') {
         $url = substr($url, 0, -1);
     }
-	return addLinkParams($url, $params);
+    return addLinkParams($url, $params);
 }
 
 function addLinkParams($link, $params) {
-	global $CONF;
+    global $CONF;
 
-	if (is_array($params) ) {
+    if (is_array($params) ) {
 
-		if ($CONF['URLMode'] == 'pathinfo')	{
+        if ($CONF['URLMode'] == 'pathinfo') {
 
-			foreach ($params as $param => $value) {
-				$link .= '/' . $param . '/' . urlencode($value);
-			}
+            foreach ($params as $param => $value) {
+                $link .= '/' . $param . '/' . urlencode($value);
+            }
 
-		} else {
+        } else {
 
-			foreach ($params as $param => $value) {
-				$link .= '&amp;' . $param . '=' . urlencode($value);
-			}
+            foreach ($params as $param => $value) {
+                $link .= '&amp;' . $param . '=' . urlencode($value);
+            }
 
-		}
-	}
+        }
+    }
 
-	return $link;
+    return $link;
 }
 
 /**
@@ -1414,118 +1526,117 @@
  *		altered query string (for the examples above: foo=3&bar=2&x=y)
  */
 function alterQueryStr($querystr, $param, $value) {
-	$vars = explode('&', $querystr);
-	$set  = false;
+    $vars = explode('&', $querystr);
+    $set  = false;
 
-	for ($i = 0; $i < count($vars); $i++) {
-		$v = explode('=', $vars[$i]);
+    for ($i = 0; $i < count($vars); $i++) {
+        $v = explode('=', $vars[$i]);
 
-		if ($v[0] == $param) {
-			$v[1] = $value;
-			$vars[$i] = implode('=', $v);
-			$set = true;
-			break;
-		}
-	}
-
-	if (!$set) {
-		$vars[] = $param . '=' . $value;
-	}
+        if ($v[0] == $param) {
+            $v[1] = $value;
+            $vars[$i] = implode('=', $v);
+            $set = true;
+            break;
+        }
+    }
 
-	return ltrim(implode('&', $vars), '&');
+    if (!$set) {
+        $vars[] = $param . '=' . $value;
+    }
+
+    return ltrim(implode('&', $vars), '&');
 }
 
 // passes one variable as hidden input field (multiple fields for arrays)
 // @see passRequestVars in varsx.x.x.php
 function passVar($key, $value) {
-	// array ?
-	if (is_array($value) ) {
-		for ($i = 0; $i < sizeof($value); $i++) {
-			passVar($key . '[' . $i . ']', $value[$i]);
-		}
+    // array ?
+    if (is_array($value) ) {
+        for ($i = 0; $i < sizeof($value); $i++) {
+            passVar($key . '[' . $i . ']', $value[$i]);
+        }
 
-		return;
-	}
+        return;
+    }
 
-	// other values: do stripslashes if needed
-	?><input type="hidden" name="<?php echo htmlspecialchars($key)?>" value="<?php echo htmlspecialchars(undoMagic($value) )?>" /><?php
+    // other values: do stripslashes if needed
+    ?><input type="hidden" name="<?php echo htmlspecialchars($key)?>" value="<?php echo htmlspecialchars(undoMagic($value) )?>" /><?php
 }
 
 /*
-	Date format functions (to be used from [%date(..)%] skinvars
+    Date format functions (to be used from [%date(..)%] skinvars
 */
 function formatDate($format, $timestamp, $defaultFormat, &$blog) {
-	// apply blog offset (#42)
-	$boffset = $blog ? $blog->getTimeOffset() * 3600 : 0;
-	$offset = date('Z', $timestamp) + $boffset;
-
-	switch ($format) {
-		case 'rfc822':
-			if ($offset >= 0) {
-				$tz = '+';
-			} else {
-				$tz = '-';
-				$offset = -$offset;
-			}
-
-			$tz .= sprintf("%02d%02d", floor($offset / 3600), round(($offset % 3600) / 60) );
-			return date('D, j M Y H:i:s ', $timestamp) . $tz;
-
-		case 'rfc822GMT':
-			$timestamp -= $offset;
-			return date('D, j M Y H:i:s ', $timestamp) . 'GMT';
-
-		case 'utc':
-			$timestamp -= $offset;
-			return date('Y-m-d\TH:i:s\Z', $timestamp);
-
-		case 'iso8601':
-			if ($offset >= 0) {
-				$tz = '+';
-			} else {
-				$tz = '-';
-				$offset = -$offset;
-			}
-
-			$tz .= sprintf("%02d:%02d", floor($offset / 3600), round(($offset % 3600) / 60) );
-			return date('Y-m-d\TH:i:s', $timestamp) . $tz;
-
-		default :
-			return strftime($format ? $format : $defaultFormat, $timestamp);
-	}
+    // apply blog offset (#42)
+    $boffset = $blog ? $blog->getTimeOffset() * 3600 : 0;
+    $offset = date('Z', $timestamp) + $boffset;
+
+    switch ($format) {
+        case 'rfc822':
+            if ($offset >= 0) {
+                $tz = '+';
+            } else {
+                $tz = '-';
+                $offset = -$offset;
+            }
+
+            $tz .= sprintf("%02d%02d", floor($offset / 3600), round(($offset % 3600) / 60) );
+            return date('D, j M Y H:i:s ', $timestamp) . $tz;
+
+        case 'rfc822GMT':
+            $timestamp -= $offset;
+            return date('D, j M Y H:i:s ', $timestamp) . 'GMT';
+
+        case 'utc':
+            $timestamp -= $offset;
+            return date('Y-m-d\TH:i:s\Z', $timestamp);
+
+        case 'iso8601':
+            if ($offset >= 0) {
+                $tz = '+';
+            } else {
+                $tz = '-';
+                $offset = -$offset;
+            }
+            $tz .= sprintf("%02d:%02d", floor($offset / 3600), round(($offset % 3600) / 60) );
+            return date('Y-m-d\TH:i:s', $timestamp) . $tz;
+
+        default :
+            return strftime($format ? $format : $defaultFormat, $timestamp);
+    }
 }
 
 function checkVars($aVars) {
-	global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES, $HTTP_SESSION_VARS;
+    global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES, $HTTP_SESSION_VARS;
 
-	foreach ($aVars as $varName) {
+    foreach ($aVars as $varName) {
 
-		if (phpversion() >= '4.1.0') {
+        if (phpversion() >= '4.1.0') {
 
-			if (   isset($_GET[$varName])
-				|| isset($_POST[$varName])
-				|| isset($_COOKIE[$varName])
-				|| isset($_ENV[$varName])
-				|| isset($_SESSION[$varName])
-				|| isset($_FILES[$varName])
-			) {
-				die('Sorry. An error occurred.');
-			}
-
-		} else {
-
-			if (   isset($HTTP_GET_VARS[$varName])
-				|| isset($HTTP_POST_VARS[$varName])
-				|| isset($HTTP_COOKIE_VARS[$varName])
-				|| isset($HTTP_ENV_VARS[$varName])
-				|| isset($HTTP_SESSION_VARS[$varName])
-				|| isset($HTTP_POST_FILES[$varName])
-			) {
-				die('Sorry. An error occurred.');
-			}
+            if (   isset($_GET[$varName])
+                || isset($_POST[$varName])
+                || isset($_COOKIE[$varName])
+                || isset($_ENV[$varName])
+                || isset($_SESSION[$varName])
+                || isset($_FILES[$varName])
+            ) {
+                die('Sorry. An error occurred.');
+            }
+
+        } else {
+
+            if (   isset($HTTP_GET_VARS[$varName])
+                || isset($HTTP_POST_VARS[$varName])
+                || isset($HTTP_COOKIE_VARS[$varName])
+                || isset($HTTP_ENV_VARS[$varName])
+                || isset($HTTP_SESSION_VARS[$varName])
+                || isset($HTTP_POST_FILES[$varName])
+            ) {
+                die('Sorry. An error occurred.');
+            }
 
-		}
-	}
+        }
+    }
 }
 
 
@@ -1535,47 +1646,47 @@
  */
 function sanitizeParams()
 {
-	global $HTTP_SERVER_VARS;
+    global $HTTP_SERVER_VARS;
 
-	$array = array();
-	$str = '';
-	$frontParam = '';
-
-	// REQUEST_URI of $HTTP_SERVER_VARS
-	$str =& $HTTP_SERVER_VARS["REQUEST_URI"];
-	serverStringToArray($str, $array, $frontParam);
-	sanitizeArray($array);
-	arrayToServerString($array, $frontParam, $str);
-
-	// QUERY_STRING of $HTTP_SERVER_VARS
-	$str =& $HTTP_SERVER_VARS["QUERY_STRING"];
-	serverStringToArray($str, $array, $frontParam);
-	sanitizeArray($array);
-	arrayToServerString($array, $frontParam, $str);
-
-	if (phpversion() >= '4.1.0') {
-		// REQUEST_URI of $_SERVER
-		$str =& $_SERVER["REQUEST_URI"];
-		serverStringToArray($str, $array, $frontParam);
-		sanitizeArray($array);
-		arrayToServerString($array, $frontParam, $str);
-
-		// QUERY_STRING of $_SERVER
-		$str =& $_SERVER["QUERY_STRING"];
-		serverStringToArray($str, $array, $frontParam);
-		sanitizeArray($array);
-		arrayToServerString($array, $frontParam, $str);
-	}
-
-	// $_GET
-	convArrayForSanitizing($_GET, $array);
-	sanitizeArray($array);
-	revertArrayForSanitizing($array, $_GET);
-
-	// $_REQUEST (only GET param)
-	convArrayForSanitizing($_REQUEST, $array);
-	sanitizeArray($array);
-	revertArrayForSanitizing($array, $_REQUEST);
+    $array = array();
+    $str = '';
+    $frontParam = '';
+
+    // REQUEST_URI of $HTTP_SERVER_VARS
+    $str =& $HTTP_SERVER_VARS["REQUEST_URI"];
+    serverStringToArray($str, $array, $frontParam);
+    sanitizeArray($array);
+    arrayToServerString($array, $frontParam, $str);
+
+    // QUERY_STRING of $HTTP_SERVER_VARS
+    $str =& $HTTP_SERVER_VARS["QUERY_STRING"];
+    serverStringToArray($str, $array, $frontParam);
+    sanitizeArray($array);
+    arrayToServerString($array, $frontParam, $str);
+
+    if (phpversion() >= '4.1.0') {
+        // REQUEST_URI of $_SERVER
+        $str =& $_SERVER["REQUEST_URI"];
+        serverStringToArray($str, $array, $frontParam);
+        sanitizeArray($array);
+        arrayToServerString($array, $frontParam, $str);
+
+        // QUERY_STRING of $_SERVER
+        $str =& $_SERVER["QUERY_STRING"];
+        serverStringToArray($str, $array, $frontParam);
+        sanitizeArray($array);
+        arrayToServerString($array, $frontParam, $str);
+    }
+
+    // $_GET
+    convArrayForSanitizing($_GET, $array);
+    sanitizeArray($array);
+    revertArrayForSanitizing($array, $_GET);
+
+    // $_REQUEST (only GET param)
+    convArrayForSanitizing($_REQUEST, $array);
+    sanitizeArray($array);
+    revertArrayForSanitizing($array, $_REQUEST);
 }
 
 /**
@@ -1584,138 +1695,139 @@
  * Also avoid the access to plugin/index.php by guest user.
  */
 function ticketForPlugin(){
-	global $CONF,$DIR_PLUGINS,$member,$ticketforplugin;
+    global $CONF,$DIR_PLUGINS,$member,$ticketforplugin;
+
+    /* initialize */
+    $ticketforplugin=array();
+    $ticketforplugin['ticket']=false;
+
+    /* Check if using plugin's php file. */
+    if ($p_translated=serverVar('PATH_TRANSLATED')) {
+        if (!file_exists($p_translated)) $p_translated='';
+    }
+    if (!$p_translated) {
+        $p_translated=serverVar('SCRIPT_FILENAME');
+        if (!file_exists($p_translated)) {
+            header("HTTP/1.0 404 Not Found");
+            exit('');
+        }
+    }
+    $p_translated=str_replace('\\','/',$p_translated);
+    $d_plugins=str_replace('\\','/',$DIR_PLUGINS);
+    if (strpos($p_translated,$d_plugins)!==0) return;// This isn't plugin php file.
+
+    /* Solve the plugin php file or admin directory */
+    $phppath=substr($p_translated,strlen($d_plugins));
+    $phppath=preg_replace('!^/!','',$phppath);// Remove the first "/" if exists.
+    $path=preg_replace('/^NP_(.*)\.php$/','$1',$phppath); // Remove the first "NP_" and the last ".php" if exists.
+    $path=preg_replace('!^([^/]*)/(.*)$!','$1',$path); // Remove the "/" and beyond.
+
+    /* Solve the plugin name. */
+    $plugins=array();
+    $query='SELECT pfile FROM '.sql_table('plugin');
+    $res=sql_query($query);
+    while($row=sql_fetch_row($res)) {
+        $name=substr($row[0],3);
+        $plugins[strtolower($name)]=$name;
+    }
+    sql_free_result($res);
+    if ($plugins[$path]) $plugin_name=$plugins[$path];
+    else if (in_array($path,$plugins)) $plugin_name=$path;
+    else {
+        header("HTTP/1.0 404 Not Found");
+        exit('');
+    }
+
+    /* Return if not index.php */
+    if ( $phppath!=strtolower($plugin_name).'/'
+        && $phppath!=strtolower($plugin_name).'/index.php' ) return;
+
+    /* Exit if not logged in. */
+    if ( !$member->isLoggedIn() ) exit("You aren't logged in.");
+
+    global $manager,$DIR_LIBS,$DIR_LANG,$HTTP_GET_VARS,$HTTP_POST_VARS;
+
+    /* Check if this feature is needed (ie, if "$manager->checkTicket()" is not included in the script). */
+    if (!($p_translated=serverVar('PATH_TRANSLATED'))) $p_translated=serverVar('SCRIPT_FILENAME');
+    if ($file=@file($p_translated)) {
+        $prevline='';
+        foreach($file as $line) {
+            if (preg_match('/[\$]manager([\s]*)[\-]>([\s]*)checkTicket([\s]*)[\(]/i',$prevline.$line)) return;
+            $prevline=$line;
+        }
+    }
+
+    /* Show a form if not valid ticket */
+    if ( ( strstr(serverVar('REQUEST_URI'),'?') || serverVar('QUERY_STRING')
+            || strtoupper(serverVar('REQUEST_METHOD'))=='POST' )
+                && (!$manager->checkTicket()) ){
+
+        if (!class_exists('PluginAdmin')) {
+            $language = getLanguageName();
+//            include($DIR_LANG . ereg_replace( '[\\|/]', '', $language) . '.php');
+            include($DIR_LANG . preg_replace( '@\\|/@', '', $language) . '.php');
+            include($DIR_LIBS . 'PLUGINADMIN.php');
+        }
+        if (!(function_exists('mb_strimwidth') || extension_loaded('mbstring'))) {
+            if (file_exists($DIR_LIBS.'mb_emulator/mb-emulator.php')) {
+                global $mbemu_internals;
+                include_once($DIR_LIBS.'mb_emulator/mb-emulator.php');
+            }
+        }
+        $oPluginAdmin = new PluginAdmin($plugin_name);
+        $oPluginAdmin->start();
+        echo '<p>' . _ERROR_BADTICKET . "</p>\n";
+
+        /* Show the form to confirm action */
+        // PHP 4.0.x support
+        $get=  (isset($_GET))  ? $_GET  : $HTTP_GET_VARS;
+        $post= (isset($_POST)) ? $_POST : $HTTP_POST_VARS;
+        // Resolve URI and QUERY_STRING
+        if ($uri=serverVar('REQUEST_URI')) {
+            list($uri,$qstring)=explode('?',$uri);
+        } else {
+            if ( !($uri=serverVar('PHP_SELF')) ) $uri=serverVar('SCRIPT_NAME');
+            $qstring=serverVar('QUERY_STRING');
+        }
+        if ($qstring) $qstring='?'.$qstring;
+        echo '<p>'._SETTINGS_UPDATE.' : '._QMENU_PLUGINS.' <span style="color:red;">'.
+            htmlspecialchars($plugin_name)."</span> ?</p>\n";
+        switch(strtoupper(serverVar('REQUEST_METHOD'))){
+        case 'POST':
+            echo '<form method="POST" action="'.htmlspecialchars($uri.$qstring).'">';
+            $manager->addTicketHidden();
+            _addInputTags($post);
+            break;
+        case 'GET':
+            echo '<form method="GET" action="'.htmlspecialchars($uri).'">';
+            $manager->addTicketHidden();
+            _addInputTags($get);
+        default:
+            break;
+        }
+        echo '<input type="submit" value="'._YES.'" />&nbsp;&nbsp;&nbsp;&nbsp;';
+        echo '<input type="button" value="'._NO.'" onclick="history.back(); return false;" />';
+        echo "</form>\n";
 
-	/* initialize */
-	$ticketforplugin=array();
-	$ticketforplugin['ticket']=false;
-
-	/* Check if using plugin's php file. */
-	if ($p_translated=serverVar('PATH_TRANSLATED')) {
-		if (!file_exists($p_translated)) $p_translated='';
-	}
-	if (!$p_translated) {
-		$p_translated=serverVar('SCRIPT_FILENAME');
-		if (!file_exists($p_translated)) {
-			header("HTTP/1.0 404 Not Found");
-			exit('');
-		}
-	}
-	$p_translated=str_replace('\\','/',$p_translated);
-	$d_plugins=str_replace('\\','/',$DIR_PLUGINS);
-	if (strpos($p_translated,$d_plugins)!==0) return;// This isn't plugin php file.
-
-	/* Solve the plugin php file or admin directory */
-	$phppath=substr($p_translated,strlen($d_plugins));
-	$phppath=preg_replace('!^/!','',$phppath);// Remove the first "/" if exists.
-	$path=preg_replace('/^NP_(.*)\.php$/','$1',$phppath); // Remove the first "NP_" and the last ".php" if exists.
-	$path=preg_replace('!^([^/]*)/(.*)$!','$1',$path); // Remove the "/" and beyond.
-
-	/* Solve the plugin name. */
-	$plugins=array();
-	$query='SELECT pfile FROM '.sql_table('plugin');
-	$res=sql_query($query);
-	while($row=mysql_fetch_row($res)) {
-		$name=substr($row[0],3);
-		$plugins[strtolower($name)]=$name;
-	}
-	mysql_free_result($res);
-	if ($plugins[$path]) $plugin_name=$plugins[$path];
-	else if (in_array($path,$plugins)) $plugin_name=$path;
-	else {
-		header("HTTP/1.0 404 Not Found");
-		exit('');
-	}
-
-	/* Return if not index.php */
-	if ( $phppath!=strtolower($plugin_name).'/'
-		&& $phppath!=strtolower($plugin_name).'/index.php' ) return;
-
-	/* Exit if not logged in. */
-	if ( !$member->isLoggedIn() ) exit("You aren't logged in.");
-
-	global $manager,$DIR_LIBS,$DIR_LANG,$HTTP_GET_VARS,$HTTP_POST_VARS;
-
-	/* Check if this feature is needed (ie, if "$manager->checkTicket()" is not included in the script). */
-	if (!($p_translated=serverVar('PATH_TRANSLATED'))) $p_translated=serverVar('SCRIPT_FILENAME');
-	if ($file=@file($p_translated)) {
-		$prevline='';
-		foreach($file as $line) {
-			if (preg_match('/[\$]manager([\s]*)[\-]>([\s]*)checkTicket([\s]*)[\(]/i',$prevline.$line)) return;
-			$prevline=$line;
-		}
-	}
-
-	/* Show a form if not valid ticket */
-	if ( ( strstr(serverVar('REQUEST_URI'),'?') || serverVar('QUERY_STRING')
-			|| strtoupper(serverVar('REQUEST_METHOD'))=='POST' )
-				&& (!$manager->checkTicket()) ){
-
-		if (!class_exists('PluginAdmin')) {
-			$language = getLanguageName();
-			include($DIR_LANG . ereg_replace( '[\\|/]', '', $language) . '.php');
-			include($DIR_LIBS . 'PLUGINADMIN.php');
-		}
-		if (!(function_exists('mb_strimwidth') || extension_loaded('mbstring'))) {
-			if (file_exists($DIR_LIBS.'mb_emulator/mb-emulator.php')) {
-				global $mbemu_internals;
-				include_once($DIR_LIBS.'mb_emulator/mb-emulator.php');
-			}
-		}
-		$oPluginAdmin = new PluginAdmin($plugin_name);
-		$oPluginAdmin->start();
-		echo '<p>' . _ERROR_BADTICKET . "</p>\n";
-
-		/* Show the form to confirm action */
-		// PHP 4.0.x support
-		$get=  (isset($_GET))  ? $_GET  : $HTTP_GET_VARS;
-		$post= (isset($_POST)) ? $_POST : $HTTP_POST_VARS;
-		// Resolve URI and QUERY_STRING
-		if ($uri=serverVar('REQUEST_URI')) {
-			list($uri,$qstring)=explode('?',$uri);
-		} else {
-			if ( !($uri=serverVar('PHP_SELF')) ) $uri=serverVar('SCRIPT_NAME');
-			$qstring=serverVar('QUERY_STRING');
-		}
-		if ($qstring) $qstring='?'.$qstring;
-		echo '<p>'._SETTINGS_UPDATE.' : '._QMENU_PLUGINS.' <span style="color:red;">'.
-			htmlspecialchars($plugin_name)."</span> ?</p>\n";
-		switch(strtoupper(serverVar('REQUEST_METHOD'))){
-		case 'POST':
-			echo '<form method="POST" action="'.htmlspecialchars($uri.$qstring).'">';
-			$manager->addTicketHidden();
-			_addInputTags($post);
-			break;
-		case 'GET':
-			echo '<form method="GET" action="'.htmlspecialchars($uri).'">';
-			$manager->addTicketHidden();
-			_addInputTags($get);
-		default:
-			break;
-		}
-		echo '<input type="submit" value="'._YES.'" />&nbsp;&nbsp;&nbsp;&nbsp;';
-		echo '<input type="button" value="'._NO.'" onclick="history.back(); return false;" />';
-		echo "</form>\n";
-
-		$oPluginAdmin->end();
-		exit;
-	}
-
-	/* Create new ticket */
-	$ticket=$manager->addTicketToUrl('');
-	$ticketforplugin['ticket']=substr($ticket,strpos($ticket,'ticket=')+7);
+        $oPluginAdmin->end();
+        exit;
+    }
+
+    /* Create new ticket */
+    $ticket=$manager->addTicketToUrl('');
+    $ticketforplugin['ticket']=substr($ticket,strpos($ticket,'ticket=')+7);
 }
 function _addInputTags(&$keys,$prefix=''){
-	foreach($keys as $key=>$value){
-		if ($prefix) $key=$prefix.'['.$key.']';
-		if (is_array($value)) _addInputTags($value,$key);
-		else {
-			if (get_magic_quotes_gpc()) $value=stripslashes($value);
-			if ($key=='ticket') continue;
-			echo '<input type="hidden" name="'.htmlspecialchars($key).
-				'" value="'.htmlspecialchars($value).'" />'."\n";
-		}
-	}
+    foreach($keys as $key=>$value){
+        if ($prefix) $key=$prefix.'['.$key.']';
+        if (is_array($value)) _addInputTags($value,$key);
+        else {
+            if (get_magic_quotes_gpc()) $value=stripslashes($value);
+            if ($key=='ticket') continue;
+            echo '<input type="hidden" name="'.htmlspecialchars($key).
+                '" value="'.htmlspecialchars($value).'" />'."\n";
+        }
+    }
 }
 
 /**
@@ -1724,26 +1836,26 @@
  */
 function serverStringToArray($str, &$array, &$frontParam)
 {
-	// init param
-	$array = array();
-	$fronParam = "";
-
-	// split front param, e.g. /index.php, and others, e.g. blogid=1&page=2
-	if (strstr($str, "?")){
-		list($frontParam, $args) = preg_split("/\?/", $str, 2);
-	}
-	else {
-		$args = $str;
-		$frontParam = "";
-	}
-
-	// If there is no args like blogid=1&page=2, return
-	if (!strstr($str, "=") && !strlen($frontParam)) {
-		$frontParam = $str;
-		return;
-	}
+    // init param
+    $array = array();
+    $fronParam = "";
+
+    // split front param, e.g. /index.php, and others, e.g. blogid=1&page=2
+    if (strstr($str, "?")){
+        list($frontParam, $args) = preg_split("/\?/", $str, 2);
+    }
+    else {
+        $args = $str;
+        $frontParam = "";
+    }
+
+    // If there is no args like blogid=1&page=2, return
+    if (!strstr($str, "=") && !strlen($frontParam)) {
+        $frontParam = $str;
+        return;
+    }
 
-	$array = explode("&", $args);
+    $array = explode("&", $args);
 }
 
 /**
@@ -1752,14 +1864,14 @@
  */
 function arrayToServerString($array, $frontParam, &$str)
 {
-	if (strstr($str, "?")) {
-		$str = $frontParam . "?";
-	} else {
-		$str = $frontParam;
-	}
-	if (count($array)) {
-		$str .= implode("&", $array);
-	}
+    if (strstr($str, "?")) {
+        $str = $frontParam . "?";
+    } else {
+        $str = $frontParam;
+    }
+    if (count($array)) {
+        $str .= implode("&", $array);
+    }
 }
 
 /**
@@ -1770,45 +1882,45 @@
  */
 function sanitizeArray(&$array)
 {
-	$excludeListForSanitization = array('query');
+    $excludeListForSanitization = array('query');
 //	$excludeListForSanitization = array();
 
-	foreach ($array as $k => $v) {
+    foreach ($array as $k => $v) {
 
-		// split to key and value
-		list($key, $val) = preg_split("/=/", $v, 2);
-		if (!isset($val)) {
-			continue;
-		}
-
-		// when magic quotes is on, need to use stripslashes,
-		// and then addslashes
-		if (get_magic_quotes_gpc()) {
-			$val = stripslashes($val);
-		}
-		$val = addslashes($val);
-
-		// if $key is included in exclude list, skip this param
-		if (!in_array($key, $excludeListForSanitization)) {
-
-			// check value
-			if (strpos($val, '\\')) {
-				list($val, $tmp) = explode('\\', $val);
-			}
-			
-			// remove control code etc.
-			$val = strtr($val, "\0\r\n<>'\"", "       ");
-
-			// check key
-			if (preg_match('/\"/i', $key)) {
-				unset($array[$k]);
-				continue;
-			}
-
-			// set sanitized info
-			$array[$k] = sprintf("%s=%s", $key, $val);
-		}
-	}
+        // split to key and value
+        list($key, $val) = preg_split("/=/", $v, 2);
+        if (!isset($val)) {
+            continue;
+        }
+
+        // when magic quotes is on, need to use stripslashes,
+        // and then addslashes
+        if (get_magic_quotes_gpc()) {
+            $val = stripslashes($val);
+        }
+        $val = addslashes($val);
+
+        // if $key is included in exclude list, skip this param
+        if (!in_array($key, $excludeListForSanitization)) {
+
+            // check value
+            if (strpos($val, '\\')) {
+                list($val, $tmp) = explode('\\', $val);
+            }
+            
+            // remove control code etc.
+            $val = strtr($val, "\0\r\n<>'\"", "       ");
+
+            // check key
+            if (preg_match('/\"/i', $key)) {
+                unset($array[$k]);
+                continue;
+            }
+
+            // set sanitized info
+            $array[$k] = sprintf("%s=%s", $key, $val);
+        }
+    }
 }
 
 /**
@@ -1816,12 +1928,12 @@
  */
 function convArrayForSanitizing($src, &$array)
 {
-	$array = array();
-	foreach ($src as $key => $val) {
-		if (key_exists($key, $_GET)) {
-			array_push($array, sprintf("%s=%s", $key, $val));
-		}
-	}
+    $array = array();
+    foreach ($src as $key => $val) {
+        if (key_exists($key, $_GET)) {
+            array_push($array, sprintf("%s=%s", $key, $val));
+        }
+    }
 }
 
 /**
@@ -1829,10 +1941,10 @@
  */
 function revertArrayForSanitizing($array, &$dst)
 {
-	foreach ($array as $v) {
-		list($key, $val) = preg_split("/=/", $v, 2);
-		$dst[$key] = $val;
-	}
+    foreach ($array as $v) {
+        list($key, $val) = preg_split("/=/", $v, 2);
+        $dst[$key] = $val;
+    }
 }
 
 /**
@@ -1841,9 +1953,9 @@
  * - the URL will be stripped of illegal or dangerous characters
  */
 function redirect($url) {
-	$url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:@%*]|i', '', $url);
-	header('Location: ' . $url);
-	exit;
+    $url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:@%*]|i', '', $url);
+    header('Location: ' . $url);
+    exit;
 }
 
 /**
@@ -1853,15 +1965,15 @@
  * unneeded whitespace.
  */
 function stringStripTags ($string) {
-	$string = preg_replace("/<del[^>]*>.+<\/del[^>]*>/isU", '', $string);
-	$string = preg_replace("/<script[^>]*>.+<\/script[^>]*>/isU", '', $string);
-	$string = preg_replace("/<style[^>]*>.+<\/style[^>]*>/isU", '', $string);
-	$string = str_replace('>', '> ', $string);
-	$string = str_replace('<', ' <', $string);
-	$string = strip_tags($string);
-	$string = preg_replace("/\s+/", " ", $string);
-	$string = trim($string);
-	return $string;
+    $string = preg_replace("/<del[^>]*>.+<\/del[^>]*>/isU", '', $string);
+    $string = preg_replace("/<script[^>]*>.+<\/script[^>]*>/isU", '', $string);
+    $string = preg_replace("/<style[^>]*>.+<\/style[^>]*>/isU", '', $string);
+    $string = str_replace('>', '> ', $string);
+    $string = str_replace('<', ' <', $string);
+    $string = strip_tags($string);
+    $string = preg_replace("/\s+/", " ", $string);
+    $string = trim($string);
+    return $string;
 }
 
 /**
@@ -1869,17 +1981,17 @@
  * Tags are stripped and entities are normalized
  */
 function stringToAttribute ($string) {
-	$string = stringStripTags($string);
-	$string = entity::named_to_numeric($string);
-	$string = entity::normalize_numeric($string);
-
-	if (_CHARSET == 'UTF-8') {
-		$string = entity::numeric_to_utf8($string);
-	}
-
-	$string = entity::specialchars($string, 'html');
-	$string = entity::numeric_to_named($string);
-	return $string;
+    $string = stringStripTags($string);
+    $string = entity::named_to_numeric($string);
+    $string = entity::normalize_numeric($string);
+
+    if (strtoupper(_CHARSET) == 'UTF-8') {
+        $string = entity::numeric_to_utf8($string);
+    }
+
+    $string = entity::specialchars($string, 'html');
+    $string = entity::numeric_to_named($string);
+    return $string;
 }
 
 /**
@@ -1888,28 +2000,28 @@
  * converted to numeric entities.
  */
 function stringToXML ($string) {
-	$string = stringStripTags($string);
-	$string = entity::named_to_numeric($string);
-	$string = entity::normalize_numeric($string);
-
-	if (_CHARSET == 'UTF-8') {
-		$string = entity::numeric_to_utf8($string);
-	}
+    $string = stringStripTags($string);
+    $string = entity::named_to_numeric($string);
+    $string = entity::normalize_numeric($string);
+
+    if (strtoupper(_CHARSET) == 'UTF-8') {
+        $string = entity::numeric_to_utf8($string);
+    }
 
-	$string = entity::specialchars($string, 'xml');
-	return $string;
+    $string = entity::specialchars($string, 'xml');
+    return $string;
 }
 
 // START: functions from the end of file BLOG.php
 // used for mail notification (html -> text)
 function toAscii($html) {
-	// strip off most tags
-	$html = strip_tags($html,'<a>');
-	$to_replace = "/<a[^>]*href=[\"\']([^\"^']*)[\"\'][^>]*>([^<]*)<\/a>/i";
-	_links_init();
-	$ascii = preg_replace_callback ($to_replace, '_links_add', $html);
-	$ascii .= "\n\n" . _links_list();
-	return strip_tags($ascii);
+    // strip off most tags
+    $html = strip_tags($html,'<a>');
+    $to_replace = "/<a[^>]*href=[\"\']([^\"^']*)[\"\'][^>]*>([^<]*)<\/a>/i";
+    _links_init();
+    $ascii = preg_replace_callback ($to_replace, '_links_add', $html);
+    $ascii .= "\n\n" . _links_list();
+    return strip_tags($ascii);
 }
 
 function _links_init() {
@@ -1928,8 +2040,8 @@
    $output = '';
    $i = 1;
    foreach ($tmp_links as $current) {
-	  $output .= "[$i] $current\n";
-	  $i++;
+      $output .= "[$i] $current\n";
+      $i++;
    }
    return $output;
 }
@@ -1939,13 +2051,17 @@
 /**
  * @todo document this
  */
-function encode_desc($data)
-	{   $to_entities = get_html_translation_table(HTML_ENTITIES);
-		$from_entities = array_flip($to_entities);
-		$data = strtr($data,$from_entities);
-		$data = strtr($data,$to_entities);
-		return $data;
-	}
+function encode_desc(&$data)
+{
+    $to_entities = get_html_translation_table(HTML_ENTITIES);
+
+    $from_entities = array_flip($to_entities);
+
+    $data = strtr($data,$from_entities);
+    $data = strtr($data,$to_entities);
+
+    return $data;
+}
 
 /**
  * Returns the Javascript code for a bookmarklet that works on most modern browsers
@@ -1953,15 +2069,15 @@
  * @param blogid
  */
 function getBookmarklet($blogid) {
-	global $CONF;
+    global $CONF;
 
-	// normal
-	$document = 'document';
-	$bookmarkletline = "javascript:Q='';x=".$document.";y=window;if(x.selection){Q=x.selection.createRange().text;}else if(y.getSelection){Q=y.getSelection();}else if(x.getSelection){Q=x.getSelection();}wingm=window.open('";
-	$bookmarkletline .= $CONF['AdminURL'] . "bookmarklet.php?blogid=$blogid";
-	$bookmarkletline .="&logtext='+escape(Q)+'&loglink='+escape(x.location.href)+'&loglinktitle='+escape(x.title),'nucleusbm','scrollbars=yes,width=600,height=550,left=10,top=10,status=yes,resizable=yes');wingm.focus();";
+    // normal
+    $document = 'document';
+    $bookmarkletline = "javascript:Q='';x=".$document.";y=window;if(x.selection){Q=x.selection.createRange().text;}else if(y.getSelection){Q=y.getSelection();}else if(x.getSelection){Q=x.getSelection();}wingm=window.open('";
+    $bookmarkletline .= $CONF['AdminURL'] . "bookmarklet.php?blogid=$blogid";
+    $bookmarkletline .="&logtext='+escape(Q)+'&loglink='+escape(x.location.href)+'&loglinktitle='+escape(x.title),'nucleusbm','scrollbars=yes,width=600,height=550,left=10,top=10,status=yes,resizable=yes');wingm.focus();";
 
-	return $bookmarkletline;
+    return $bookmarkletline;
 }
 // END: functions from the end of file ADMIN.php
 
@@ -1972,11 +2088,11 @@
  * @return mixed Variable
  */
 function ifset(&$var) {
-	if (isset($var)) {
-		return $var;
-	}
+    if (isset($var)) {
+        return $var;
+    }
 
-	return null;
+    return null;
 }
 
 /**
@@ -1986,10 +2102,15 @@
  * @return number of subscriber(s)
  */
 function numberOfEventSubscriber($event) {
-	$query = 'SELECT COUNT(*) as count FROM ' . sql_table('plugin_event') . ' WHERE event=\'' . $event . '\'';
-	$res = sql_query($query);
-	$obj = mysql_fetch_object($res);
-	return $obj->count;
+    $query = 'SELECT COUNT(*) as count FROM ' . sql_table('plugin_event') . ' WHERE event=\'' . $event . '\'';
+    $res = sql_query($query);
+    $obj = sql_fetch_object($res);
+    return $obj->count;
+}
+
+function selectSpecialSkinType($id) {
+    global $special;
+    $special = strtolower($id);
 }
 
-?>
+?>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/libs/include/admin-add.template 3.51.src/nucleus/libs/include/admin-add.template
--- 3.41.src/nucleus/libs/include/admin-add.template	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/include/admin-add.template	2009-11-01 14:53:52.000000000 -0600
@@ -89,8 +89,6 @@
 				<%endif%>
 			</div>
 			<input name="actiontype" tabindex="61" value="adddraft" type="radio" id="act_draft" /><label for="act_draft"><%text(_ADD_ADDDRAFT)%></label> <%helplink(draft)%>
-			<br />
-			<input id="dosendping" name="dosendping" value="1" type="checkbox" checked="checked"><label for="dosendping"><%text(_UPDATEDPING_GOSENDPING)%></label>
 		</td>
 	</tr><tr>
 		<td><%text(_ADD_PLUGIN_EXTRAS)%></td>
diff -x .svn -aruN 3.41.src/nucleus/libs/include/admin-edit.template 3.51.src/nucleus/libs/include/admin-edit.template
--- 3.41.src/nucleus/libs/include/admin-edit.template	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/include/admin-edit.template	2009-11-01 14:53:52.000000000 -0600
@@ -116,9 +116,6 @@
 	<br />
 	<input name="actiontype" value="delete" type="radio" id="act_delete" tabindex="72" /><label for="act_delete"><%text(_BMLET_DELETE)%></label>
 <%endif%>
-	<br />
-	<input id="dosendping" name="dosendping" value="1" type="checkbox"><label for="dosendping"><%text(_UPDATEDPING_GOSENDPING)%></label>
-
 	</td>
 </tr><tr>
 	<td><%text(_ADD_PLUGIN_EXTRAS)%></td>
diff -x .svn -aruN 3.41.src/nucleus/libs/include/bookmarklet-add.template 3.51.src/nucleus/libs/include/bookmarklet-add.template
--- 3.41.src/nucleus/libs/include/bookmarklet-add.template	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/include/bookmarklet-add.template	2009-11-01 14:53:52.000000000 -0600
@@ -1,6 +1,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 	<html xmlns="http://www.w3.org/1999/xhtml">
 	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=<%text(_CHARSET)%>" />
 		<title><%text(_ADD_ADDTO)%> '<%blogname%>'</title>
 		<link rel="stylesheet" type="text/css" href="styles/bookmarklet.css" /> 
 		<link rel="stylesheet" type="text/css" href="styles/addedit.css" />		
@@ -127,8 +128,6 @@
 						<%endif%>
 					</div>
 					<input name="actiontype" value="adddraft" type="radio" id="act_draft" /><label for="act_draft"><%text(_ADD_ADDDRAFT)%></label> <%helplink(draft)%>
-					<br />
-					<input id="dosendping" name="dosendping" value="1" type="checkbox" checked="checked"><label for="dosendping"><%text(_UPDATEDPING_GOSENDPING)%></label>
 				</td>
 				</tr>
 				<tr>
diff -x .svn -aruN 3.41.src/nucleus/libs/include/bookmarklet-edit.template 3.51.src/nucleus/libs/include/bookmarklet-edit.template
--- 3.41.src/nucleus/libs/include/bookmarklet-edit.template	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/include/bookmarklet-edit.template	2009-11-01 14:53:52.000000000 -0600
@@ -1,6 +1,7 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 	<html xmlns="http://www.w3.org/1999/xhtml">
 	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=<%text(_CHARSET)%>" />
 		<title><%text(_EDIT_ITEM)%></title>
 		<link rel="stylesheet" type="text/css" href="styles/bookmarklet.css" />
 		<link rel="stylesheet" type="text/css" href="styles/addedit.css" />				
@@ -126,9 +127,7 @@
 							<li>
 								<input name="actiontype" value="backtodrafts" type="radio" id="act_backtodrafts" tabindex="71" /><label for="act_backtodrafts"><%text(_BMLET_BACKTODRAFTS)%></label> <%helplink(draft)%>
 							</li>
-					<%endif%>						
-				</ul>
-				<input id="dosendping" name="dosendping" value="1" type="checkbox"><label for="dosendping"><%text(_UPDATEDPING_GOSENDPING)%></label>
+					<%endif%>
 				</td></tr>
 				
 				<tr>
diff -x .svn -aruN 3.41.src/nucleus/libs/ITEMACTIONS.php 3.51.src/nucleus/libs/ITEMACTIONS.php
--- 3.41.src/nucleus/libs/ITEMACTIONS.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/ITEMACTIONS.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,8 +13,8 @@
  * This class is used to parse item templates
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: ITEMACTIONS.php 1338 2009-02-28 15:09:19Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: ITEMACTIONS.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 class ITEMACTIONS extends BaseActions {
 
@@ -542,6 +542,4 @@
 
 }
 
-
-
 ?>
diff -x .svn -aruN 3.41.src/nucleus/libs/ITEM.php 3.51.src/nucleus/libs/ITEM.php
--- 3.41.src/nucleus/libs/ITEM.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/ITEM.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * A class representing an item
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: ITEM.php 1286 2008-12-01 09:01:37Z ehui $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: ITEM.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 class ITEM {
 
@@ -64,9 +64,9 @@
 
 		$res = sql_query($query);
 
-		if (mysql_num_rows($res) == 1)
+		if (sql_num_rows($res) == 1)
 		{
-			$aItemInfo = mysql_fetch_assoc($res);
+			$aItemInfo = sql_fetch_assoc($res);
 			$aItemInfo['timestamp'] = strtotime($aItemInfo['itime']);
 			return $aItemInfo;
 		} else {
@@ -372,7 +372,7 @@
 		}
 		$r = sql_query($r);
 
-		return (mysql_num_rows($r) != 0);
+		return (sql_num_rows($r) != 0);
 	}
 
 	/**
diff -x .svn -aruN 3.41.src/nucleus/libs/KARMA.php 3.51.src/nucleus/libs/KARMA.php
--- 3.41.src/nucleus/libs/KARMA.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/KARMA.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,8 +13,8 @@
  * Class representing the karma votes for a certain item
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: KARMA.php 1116 2007-02-03 08:24:29Z kimitake $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: KARMA.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 class KARMA {
 
@@ -87,7 +87,7 @@
 	function readFromDatabase() {
 		$query = 'SELECT ikarmapos, ikarmaneg FROM '.sql_table('item').' WHERE inumber=' . $this->itemid;
 		$res = sql_query($query);
-		$obj = mysql_fetch_object($res);
+		$obj = sql_fetch_object($res);
 
 		$this->karmapos = $obj->ikarmapos;
 		$this->karmaneg = $obj->ikarmaneg;
@@ -104,7 +104,7 @@
 	function isVoteAllowed($ip) {
 		$query = 'SELECT * FROM '.sql_table('karma')." WHERE itemid=$this->itemid and ip='".addslashes($ip)."'";
 		$res = sql_query($query);
-		return (mysql_num_rows($res) == 0);
+		return (sql_num_rows($res) == 0);
 	}
 
 	// save IP in database so no multiple votes are possible
diff -x .svn -aruN 3.41.src/nucleus/libs/MANAGER.php 3.51.src/nucleus/libs/MANAGER.php
--- 3.41.src/nucleus/libs/MANAGER.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/MANAGER.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -19,8 +19,8 @@
  * active at all times. The object can be requested using MANAGER::instance()
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: MANAGER.php 1279 2008-10-23 08:18:26Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: MANAGER.php 1411 2009-09-14 19:49:05Z ftruscot $
  */
 class MANAGER {
 
@@ -247,7 +247,10 @@
 
 				if (!file_exists($fileName))
 				{
-					ACTIONLOG::add(WARNING, sprintf(_MANAGER_PLUGINFILE_NOTFOUND, $name));
+					if (!defined('_MANAGER_PLUGINFILE_NOTFOUND')) {
+                        define('_MANAGER_PLUGINFILE_NOTFOUND', 'Plugin %s was not loaded (File not found)');
+                    }
+                    ACTIONLOG::add(WARNING, sprintf(_MANAGER_PLUGINFILE_NOTFOUND, $name)); 
 					return 0;
 				}
 
@@ -275,6 +278,15 @@
 					ACTIONLOG::add(WARNING, sprintf(_MANAGER_PLUGINTABLEPREFIX_NOTSUPPORT, $name));
 					return 0;
 				}
+				
+				// unload plugin if using non-mysql handler and plugin does not support it 
+				global $MYSQL_HANDLER;
+				if ((!in_array('mysql',$MYSQL_HANDLER)) && !$this->plugins[$name]->supportsFeature('SqlApi'))
+				{
+					unset($this->plugins[$name]);
+					ACTIONLOG::add(WARNING, sprintf(_MANAGER_PLUGINSQLAPI_NOTSUPPORT, $name));
+					return 0;
+				}
 
 				// call init method
 				$this->plugins[$name]->init();
@@ -371,7 +383,7 @@
 			case 'installedPlugins':
 				$this->cachedInfo['installedPlugins'] = array();
 				$res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin'));
-				while ($o = mysql_fetch_object($res))
+				while ($o = sql_fetch_object($res))
 				{
 					$this->cachedInfo['installedPlugins'][$o->pid] = $o->pfile;
 				}
@@ -409,8 +421,8 @@
 				// load class if needed
 				$this->_loadPlugin($listener);
 				// do notify (if method exists)
-				if (method_exists($this->plugins[$listener], 'event_' . $eventName))
-					call_user_func(array(&$this->plugins[$listener],'event_' . $eventName), $data);
+                if (isset($this->plugins[$listener]) && method_exists($this->plugins[$listener], 'event_' . $eventName))
+					call_user_func(array(&$this->plugins[$listener],'event_' . $eventName), &$data);
 			}
 		}
 
@@ -424,7 +436,7 @@
 		$this->subscriptions = array();
 
 		$res = sql_query('SELECT p.pfile as pfile, e.event as event FROM '.sql_table('plugin_event').' as e, '.sql_table('plugin').' as p WHERE e.pid=p.pid ORDER BY p.porder ASC');
-		while ($o = mysql_fetch_object($res)) {
+		while ($o = sql_fetch_object($res)) {
 			$pluginName = $o->pfile;
 			$eventName = $o->event;
 			$this->subscriptions[$eventName][] = $pluginName;
diff -x .svn -aruN 3.41.src/nucleus/libs/MEDIA.php 3.51.src/nucleus/libs/MEDIA.php
--- 3.41.src/nucleus/libs/MEDIA.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/MEDIA.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,10 +13,12 @@
  * Media classes for nucleus
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: MEDIA.php 1288 2008-12-16 20:20:22Z ftruscot $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: MEDIA.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
+define('PRIVATE_COLLECTION', 'Private Collection');
+define('READ_ONLY_MEDIA_FOLDER', '(Read Only)');
 
 /**
   * Represents the media objects for a certain member
@@ -29,13 +31,13 @@
 	  *
 	  * @returns array of dirname => display name
 	  */
-	function getCollectionList() {
+	function getCollectionList($exceptReadOnly = false) {
 		global $member, $DIR_MEDIA;
 
 		$collections = array();
 
 		// add private directory for member
-		$collections[$member->getID()] = 'Private Collection';
+		$collections[$member->getID()] = PRIVATE_COLLECTION;
 
 		// add global collections
 		if (!is_dir($DIR_MEDIA)) return $collections;
@@ -43,8 +45,15 @@
 		$dirhandle = opendir($DIR_MEDIA);
 		while ($dirname = readdir($dirhandle)) {
 			// only add non-numeric (numeric=private) dirs
-			if (@is_dir($DIR_MEDIA . $dirname) && ($dirname != '.') && ($dirname != '..') && ($dirname != 'CVS') && (!is_numeric($dirname)))  {
-				$collections[$dirname] = $dirname;
+			if (@is_dir($DIR_MEDIA . $dirname) &&
+				($dirname != '.') &&
+				($dirname != '..') &&
+				($dirname != 'CVS') &&
+				(!is_numeric($dirname)))  {
+				if (@is_writable($DIR_MEDIA . $dirname))
+					$collections[$dirname] = $dirname;
+				else if ($exceptReadOnly == false)
+					$collections[$dirname] = $dirname . ' ' . READ_ONLY_MEDIA_FOLDER;
 			}
 		}
 		closedir($dirhandle);
@@ -98,29 +107,25 @@
 	  * checks if a collection exists with the given name, and if it's
 	  * allowed for the currently logged in member to upload files to it
 	  */
-	function isValidCollection($collectionName) {
+	function isValidCollection($collectionName, $exceptReadOnly = false) {
 		global $member, $DIR_MEDIA;
-	  	 
+
 		// allow creating new private directory
-		if (preg_match('#^[0-9]+[/\\\\]?$#',$collectionName))
-			return ((int)$member->getID() == (int)$collectionName);
-	  	 
-		// avoid directory traversal
-		// note that preg_replace() is requred to remove the last "/" or "\" if exists
-		$media = realpath($DIR_MEDIA);
-		$media = preg_replace('#[/\\\\]+$#','',$media);
-		$collectionDir = realpath( $DIR_MEDIA . $collectionName );
-		$collectionDir = preg_replace('#[/\\\\]+$#','',$collectionDir);
-		if (strpos($collectionDir,$media)!==0 || $collectionDir == $media) return false;
-	  	 
-		// private collections only accept uploads from their owners
-		// The "+1" of "strlen($media)+1" corresponds to "/" or "\".
-		$collectionName=substr($collectionDir,strlen($media)+1);
-		if (preg_match('/^[0-9]+$/',$collectionName))
-		return ((int)$member->getID() == (int)$collectionName);
+		if ($collectionName === (string)$member->getID())
+			return true;
+			
+		$collections = MEDIA::getCollectionList($exceptReadOnly);
+		$dirname = $collections[$collectionName];
+		if ($dirname == NULL || $dirname === PRIVATE_COLLECTION)
+			return false;  
+
+		// other collections should exist and be writable
+		$collectionDir = $DIR_MEDIA . $collectionName;
+		if ($exceptReadOnly)
+			return (@is_dir($collectionDir) && @is_writable($collectionDir));
 
-		// other collections should exists and be writable
-		return (@is_dir($collectionDir) && @is_writable($collectionDir));
+		// other collections should exist
+		return @is_dir($collectionDir);
        }
 
 	/**
@@ -140,7 +145,8 @@
 		$manager->notify('PreMediaUpload',array('collection' => &$collection, 'uploadfile' => $uploadfile, 'filename' => &$filename));
 
 		// don't allow uploads to unknown or forbidden collections
-		if (!MEDIA::isValidCollection($collection))
+		$exceptReadOnly = true;
+		if (!MEDIA::isValidCollection($collection,$exceptReadOnly))
 			return _ERROR_DISALLOWED;
 
 		// check dir permissions (try to create dir if it does not exist)
diff -x .svn -aruN 3.41.src/nucleus/libs/MEMBER.php 3.51.src/nucleus/libs/MEMBER.php
--- 3.41.src/nucleus/libs/MEMBER.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/MEMBER.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * A class representing site members
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: MEMBER.php 1347 2009-03-06 14:58:20Z ftruscot $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: MEMBER.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 class MEMBER {
 
@@ -88,17 +88,16 @@
 		if ($success && $this->readFromName($login)) {
 			$this->loggedin = 1;
 			return $this->isLoggedIn();
-		}
-		elseif (!$success && $allowlocal) {
+		} elseif (!$success && $allowlocal) {
 			if (!$this->readFromName($login))
 				return 0;
 			if (!$this->checkPassword($password))
 				return 0;
 			$this->loggedin = 1;
 			return $this->isLoggedIn();
-		}
-		else 
+		} else {
 			return 0;
+		}
 	}
 
 	/**
@@ -130,7 +129,7 @@
 		$query =  'SELECT * FROM '.sql_table('member') . ' WHERE ' . $where;
 
 		$res = sql_query($query);
-		$obj = mysql_fetch_object($res);
+		$obj = sql_fetch_object($res);
 
 		$this->setRealName($obj->mrealname);
 		$this->setEmail($obj->memail);
@@ -145,7 +144,7 @@
 		$this->setLanguage($obj->deflang);
 		$this->setAutosave($obj->mautosave);
 
-		return mysql_num_rows($res);
+		return sql_num_rows($res);
 	}
 
 
@@ -158,10 +157,10 @@
 			   . ' tblog=' . intval($blogid)
 			   . ' and tmember='. $this->getID();
 		$res = sql_query($query);
-		if (mysql_num_rows($res) == 0)
+		if (sql_num_rows($res) == 0)
 			return 0;
 		else
-			return (mysql_result($res,0,0) == 1) ;
+			return (sql_result($res,0,0) == 1) ;
 	}
 
 	function blogAdminRights($blogid) {
@@ -181,7 +180,7 @@
 			   . ' tblog=' . intval($blogid)
 			   . ' and tmember='. $this->getID();
 		$res = sql_query($query);
-		return (mysql_num_rows($res) != 0);
+		return (sql_num_rows($res) != 0);
 	}
 
 	function canAddItem($catid) {
@@ -223,7 +222,7 @@
 			   . ' FROM '.sql_table('comment') .', '.sql_table('item').', '.sql_table('blog')
 			   . ' WHERE citem=inumber and iblog=bnumber and cnumber=' . intval($commentid);
 		$res = sql_query($query);
-		$obj = mysql_fetch_object($res);
+		$obj = sql_fetch_object($res);
 
 		return ($obj->cauthor == $this->getID()) or $this->isBlogAdmin($obj->blogid) or ($obj->iauthor == $this->getID());
 	}
@@ -239,7 +238,7 @@
 
 		$query =  'SELECT iblog, iauthor FROM '.sql_table('item').' WHERE inumber=' . intval($itemid);
 		$res = sql_query($query);
-		$obj = mysql_fetch_object($res);
+		$obj = sql_fetch_object($res);
 		return ($obj->iauthor == $this->getID()) or $this->isBlogAdmin($obj->iblog);
 	}
 
@@ -249,7 +248,7 @@
 	  */
 	function canBeDeleted() {
 		$res = sql_query('SELECT * FROM '.sql_table('item').' WHERE iauthor=' . $this->getID());
-		return (mysql_num_rows($res) == 0);
+		return (sql_num_rows($res) == 0);
 	}
 
 	/**
@@ -391,8 +390,8 @@
 			$query = 'SELECT tblog as blogid from '.sql_table('team').' where tadmin=1 and tmember=' . $this->getID();
 
 		$res = sql_query($query);
-		if (mysql_num_rows($res) > 0) {
-			while ($obj = mysql_fetch_object($res)) {
+		if (sql_num_rows($res) > 0) {
+			while ($obj = sql_fetch_object($res)) {
 				array_push($blogs, $obj->blogid);
 			}
 		}
@@ -413,8 +412,8 @@
 			$query = 'SELECT tblog as blogid from '.sql_table('team').' where tmember=' . $this->getID();
 
 		$res = sql_query($query);
-		if (mysql_num_rows($res) > 0) {
-			while ($obj = mysql_fetch_object($res)) {
+		if (sql_num_rows($res) > 0) {
+			while ($obj = sql_fetch_object($res)) {
 				array_push($blogs, $obj->blogid);
 			}
 		}
@@ -575,7 +574,7 @@
 	 */	 	
 	function exists($name) {
 		$r = sql_query('select * FROM '.sql_table('member')." WHERE mname='".addslashes($name)."'");
-		return (mysql_num_rows($r) != 0);
+		return (sql_num_rows($r) != 0);
 	}
 
 	/**
@@ -585,7 +584,7 @@
 	 */	 	 	
 	function existsID($id) {
 		$r = sql_query('select * FROM '.sql_table('member')." WHERE mnumber='".intval($id)."'");
-		return (mysql_num_rows($r) != 0);
+		return (sql_num_rows($r) != 0);
 	}
 
 	/**
@@ -605,7 +604,7 @@
 	 * Adds a new member
 	 * 
 	 * @static
-	 */	 	 	
+	 */
 	function create($name, $realname, $password, $email, $url, $admin, $canlogin, $notes) {
 		if (!isValidMailAddress($email))
 			return _ERROR_BADMAILADDRESS;
@@ -655,10 +654,10 @@
 		$query = 'SELECT * FROM ' . sql_table('activation') . ' WHERE vkey=\'' . addslashes($key). '\'';
 		$res = sql_query($query);
 
-		if (!$res || (mysql_num_rows($res) == 0))
+		if (!$res || (sql_num_rows($res) == 0))
 			return 0;
 		else
-			return mysql_fetch_object($res);
+			return sql_fetch_object($res);
 	}
 
 	/**
@@ -766,12 +765,16 @@
 	 */
 	function cleanupActivationTable()
 	{
-		$boundary = time() - (60 * 60 * 24 * 2);
+		$actdays = 2;
+		if (isset($CONF['ActivationDays']) && intval($CONF['ActivationDays']) > 0) {
+		    $actdays = intval($CONF['ActivationDays']);
+		}
+		$boundary = time() - (60 * 60 * 24 * $actdays);
 
 		// 1. walk over all entries, and see if special actions need to be performed
 		$res = sql_query('SELECT * FROM ' . sql_table('activation') . ' WHERE vtime < \'' . date('Y-m-d H:i:s',$boundary) . '\'');
 
-		while ($o = mysql_fetch_object($res))
+		while ($o = sql_fetch_object($res))
 		{
 			switch ($o->vtype)
 			{
diff -x .svn -aruN 3.41.src/nucleus/libs/NOTIFICATION.php 3.51.src/nucleus/libs/NOTIFICATION.php
--- 3.41.src/nucleus/libs/NOTIFICATION.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/libs/NOTIFICATION.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * message can be sent (e.g. comment or karma vote notification).
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: NOTIFICATION.php 1116 2007-02-03 08:24:29Z kimitake $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: NOTIFICATION.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 class NOTIFICATION {
 
diff -x .svn -aruN 3.41.src/nucleus/libs/PAGEFACTORY.php 3.51.src/nucleus/libs/PAGEFACTORY.php
--- 3.41.src/nucleus/libs/PAGEFACTORY.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/PAGEFACTORY.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -11,8 +11,8 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: PAGEFACTORY.php 1339 2009-02-28 15:20:08Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: PAGEFACTORY.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 /**
@@ -79,7 +79,7 @@
 			'ticket',
 			'autosave',
 			'autosaveinfo',
-			'ifautosave'
+			'ifautosave',
 		);
 
 		// TODO: maybe add 'skin' later on?
diff -x .svn -aruN 3.41.src/nucleus/libs/PARSER.php 3.51.src/nucleus/libs/PARSER.php
--- 3.41.src/nucleus/libs/PARSER.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/PARSER.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -11,8 +11,8 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: PARSER.php 1224 2007-12-06 23:42:22Z kaigreve $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: PARSER.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 if ( !function_exists('requestVar') ) exit;
@@ -115,8 +115,7 @@
 			// redirect to plugin action if possible
 			if (in_array('plugin', $this->actions) && $manager->pluginInstalled('NP_'.$action)) {
 				$this->doAction('plugin('.$action.$this->pdelim.implode($this->pdelim,$params).')');
-			}
-			else {
+			} else {
 				if ($CONF['DebugVars']==true) {
 				echo '&lt;%' , $action , '(', implode($this->pdelim, $params), ')%&gt;';
 		}
diff -x .svn -aruN 3.41.src/nucleus/libs/PLUGINADMIN.php 3.51.src/nucleus/libs/PLUGINADMIN.php
--- 3.41.src/nucleus/libs/PLUGINADMIN.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/PLUGINADMIN.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * code to make it easier to create plugin admin areas
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: PLUGINADMIN.php 1279 2008-10-23 08:18:26Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: PLUGINADMIN.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES, $HTTP_SESSION_VARS;
diff -x .svn -aruN 3.41.src/nucleus/libs/PLUGIN.php 3.51.src/nucleus/libs/PLUGIN.php
--- 3.41.src/nucleus/libs/PLUGIN.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/PLUGIN.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 	/*
 	 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
-	 * Copyright (C) 2002-2007 The Nucleus Group
+	 * Copyright (C) 2002-2009 The Nucleus Group
 	 *
 	 * This program is free software; you can redistribute it and/or
 	 * modify it under the terms of the GNU General Public License
@@ -16,8 +16,8 @@
 	 * plugins.html file that is included with the Nucleus documenation
 	 *
 	 * @license http://nucleuscms.org/license.txt GNU General Public License
-	 * @copyright Copyright (C) 2002-2007 The Nucleus Group
-	 * @version $Id: PLUGIN.php 1279 2008-10-23 08:18:26Z shizuki $
+	 * @copyright Copyright (C) 2002-2009 The Nucleus Group
+	 * @version $Id: PLUGIN.php 1393 2009-07-24 21:06:40Z ftruscot $
 	 */
 	class NucleusPlugin {
 
@@ -58,7 +58,7 @@
 		}
 		function doAction($type) { return _ERROR_PLUGIN_NOSUCHACTION; }
 		function doIf($key,$value) { return false; }
-		function doItemVar () {}
+		function doItemVar (&$item) {}
 
 		/**
 		 * Checks if a plugin supports a certain feature.
@@ -68,6 +68,7 @@
 		 *		Name of the feature. See plugin documentation for more info
 		 *			'SqlTablePrefix' -> if the plugin uses the sql_table() method to get table names
 		 *			'HelpPage' -> if the plugin provides a helppage
+		 *                              'SqlApi' -> if the plugin uses the complete sql_* api (must also require nucleuscms 3.5)
 		 */
 		function supportsFeature($feature) {
 			return 0;
@@ -168,7 +169,7 @@
 					 sql_table('plugin_option_desc').' d '.
 					 'WHERE d.opid='. intval($this->getID()).' AND d.oid=o.oid'
 				);
-				while ($row = mysql_fetch_object($query))
+				while ($row = sql_fetch_object($query))
 					$this->plugin_options[strtolower($row->name)] = $row->value;
 		  }
 		  if (isset($this->plugin_options[strtolower($name)]))
@@ -316,7 +317,7 @@
 			$q = 'SELECT otype, oextra FROM '.sql_table('plugin_option_desc').' WHERE oid = '.$oid;
 			$query = sql_query($q);
 
-			$o = mysql_fetch_array($query);
+			$o = sql_fetch_array($query);
 
 			if (($this->optionCanBeNumeric($o['otype'])) && ($o['oextra'] == 'number' )) {
 				$orderby = 'CAST(ovalue AS SIGNED)';
@@ -329,7 +330,7 @@
 			// create the array
 			$i = 0;
 			$top = array();
-			while($row = mysql_fetch_array($query)) {
+			while($row = sql_fetch_array($query)) {
 				$top[$i++] = $row;
 			}
 
@@ -354,7 +355,7 @@
 							 .', \''.addslashes($defValue).'\''
 							 .', \''.addslashes($typeExtras).'\')';
 			sql_query($query);
-			$oid = mysql_insert_id();
+			$oid = sql_insert_id();
 
 			$key = $context . '_' . $name;
 			$this->_aOptionToInfo[$key] = array('oid' => $oid, 'default' => $defValue);
@@ -446,7 +447,7 @@
 			// get from DB
 			$res = sql_query('SELECT ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid='.intval($oid).' and ocontextid=' . intval($contextid));
 
-			if (!$res || (mysql_num_rows($res) == 0)) {
+			if (!$res || (sql_num_rows($res) == 0)) {
 				$defVal = $this->_getDefVal($context, $name);
 				$this->_aOptionValues[$key] = $defVal;
 
@@ -456,7 +457,7 @@
 				sql_query($query);
 			}
 			else {
-				$o = mysql_fetch_object($res);
+				$o = sql_fetch_object($res);
 				$this->_aOptionValues[$key] = $o->ovalue;
 			}
 
@@ -490,12 +491,12 @@
 					break;
 			}
 			if ($r) {
-				while ($o = mysql_fetch_object($r))
+				while ($o = sql_fetch_object($r))
 					$aOptions[$o->contextid] = $defVal;
 			}
 
 			$res = sql_query('SELECT ocontextid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid=' . $oid);
-			while ($o = mysql_fetch_object($res))
+			while ($o = sql_fetch_object($res))
 				$aOptions[$o->ocontextid] = $o->ovalue;
 
 			return $aOptions;
@@ -515,11 +516,11 @@
 			$this->_aOptionToInfo = array();
 			$query = 'SELECT oid, oname, ocontext, odef FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . intval($this->plugid);
 			$res = sql_query($query);
-			while ($o = mysql_fetch_object($res)) {
+			while ($o = sql_fetch_object($res)) {
 				$k = $o->ocontext . '_' . $o->oname;
 				$this->_aOptionToInfo[$k] = array('oid' => $o->oid, 'default' => $o->odef);
 			}
-			mysql_free_result($res);
+			sql_free_result($res);
 
 			return $this->_aOptionToInfo[$key]['oid'];
 		}
@@ -542,9 +543,9 @@
 				// find ids
 			$query = 'SELECT oid FROM '.sql_table('plugin_option_desc') . ' WHERE ocontext=\''.addslashes($context).'\'';
 			$res = sql_query($query);
-			while ($o = mysql_fetch_object($res))
+			while ($o = sql_fetch_object($res))
 				array_push($aOIDs, $o->oid);
-			mysql_free_result($res);
+			sql_free_result($res);
 				// delete those options. go go go
 			if (count($aOIDs) > 0) {
 				$query = 'DELETE FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).') and ocontextid=' . intval($contextid);
@@ -594,7 +595,7 @@
 		function subscribtionListIsUptodate() {
 			$res = sql_query('SELECT event FROM '.sql_table('plugin_event').' WHERE pid = '.$this->getID());
 			$ev = array();
-			while($a = mysql_fetch_array($res)) {
+			while($a = sql_fetch_array($res)) {
 				array_push($ev, $a['event']);
 			}
 			if (count($ev) != count($this->getEventList())) {
@@ -625,7 +626,7 @@
 				// get option type info
 				$query = 'SELECT opid, oname, ocontext, otype, oextra, odef FROM ' . sql_table('plugin_option_desc') . ' WHERE oid=' . intval($oid);
 				$res = sql_query($query);
-				if ($o = mysql_fetch_object($res))
+				if ($o = sql_fetch_object($res))
 				{
 					foreach ($values as $key => $value) {
 						// avoid overriding the key used by foreach statement
diff -x .svn -aruN 3.41.src/nucleus/libs/SEARCH.php 3.51.src/nucleus/libs/SEARCH.php
--- 3.41.src/nucleus/libs/SEARCH.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/SEARCH.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2003-2007 The Nucleus Group
+ * Copyright (C) 2003-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -19,8 +19,8 @@
  * http://davidaltherr.net/web/php_functions/boolean/funcs.mysql.boolean.txt
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: SEARCH.php 1266 2008-08-31 10:20:51Z dekarma $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: SEARCH.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 
@@ -43,7 +43,7 @@
 
 		// get all public searchable blogs, no matter what, include the current blog allways.
 		$res = sql_query('SELECT bnumber FROM '.sql_table('blog').' WHERE bincludesearch=1 ');
-		while ($obj = mysql_fetch_object($res))
+		while ($obj = sql_fetch_object($res))
 			$this->blogs[] = intval($obj->bnumber);
 	}
 
diff -x .svn -aruN 3.41.src/nucleus/libs/showlist.php 3.51.src/nucleus/libs/showlist.php
--- 3.41.src/nucleus/libs/showlist.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/showlist.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,8 +13,8 @@
  * Functions to create lists of things inside the admin are
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: showlist.php 1348 2009-03-12 15:14:45Z ftruscot $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: showlist.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 
@@ -40,18 +40,18 @@
 		$res = sql_query($query);
 
 		// don't do anything if there are no results
-		$numrows = mysql_num_rows($res);
+		$numrows = sql_num_rows($res);
 		if ($numrows == 0)
 			return 0;
 
 		call_user_func('listplug_' . $type, $template, 'HEAD');
 
-		while($template['current'] = mysql_fetch_object($res))
+		while($template['current'] = sql_fetch_object($res))
 			call_user_func('listplug_' . $type, $template, 'BODY');
 
 		call_user_func('listplug_' . $type, $template, 'FOOT');
 
-		mysql_free_result($res);
+		sql_free_result($res);
 
 		// return amount of results
 		return $numrows;
@@ -202,7 +202,7 @@
 				// check dependency require
 				$req = array();
 				$res = sql_query('SELECT pfile FROM ' . sql_table('plugin'));
-				while($o = mysql_fetch_object($res)) {
+				while($o = sql_fetch_object($res)) {
 					$preq =& $manager->getPlugin($o->pfile);
 					if ($preq) {
 						$depList = $preq->getPluginDep();
@@ -590,7 +590,7 @@
 				// show list of defined parts
 				$r = sql_query('SELECT stype FROM '.sql_table('skin').' WHERE sdesc='.$current->sdnumber . ' ORDER BY stype');
 				$types = array();
-				while ($o = mysql_fetch_object($r))
+				while ($o = sql_fetch_object($r))
 					array_push($types,$o->stype);
 				if (sizeof($types) > 0) {
 					$friendlyNames = SKIN::getFriendlyNames();
diff -x .svn -aruN 3.41.src/nucleus/libs/skinie.php 3.51.src/nucleus/libs/skinie.php
--- 3.41.src/nucleus/libs/skinie.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/skinie.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  *	exporting Nucleus skins: SKINIMPORT and SKINEXPORT
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: skinie.php 1279 2008-10-23 08:18:26Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: skinie.php 1389 2009-07-18 08:50:07Z shizuki $
  */
 
 class SKINIMPORT {
@@ -113,7 +113,9 @@
 	function readFile($filename, $metaOnly = 0) {
 		// open file
 		$this->fp = @fopen($filename, 'r');
-		if (!$this->fp) return _SKINIE_ERROR_FAILEDOPEN_FILEURL;
+		if (!$this->fp) {
+		    return _SKINIE_ERROR_FAILEDOPEN_FILEURL;
+		}
 
 		// here we go!
 		$this->inXml = 1;
@@ -148,8 +150,9 @@
 
 		while ( ($buffer = fread($temp, 4096) ) && (!$metaOnly || ($metaOnly && !$this->metaDataRead))) {
 			$err = xml_parse( $this->parser, $buffer, feof($temp) );
-			if (!$err && $this->debug)
+			if (!$err && $this->debug) {
 				echo 'ERROR: ', xml_error_string(xml_get_error_code($this->parser)), '<br />';
+			}
 		}
 
 		// all done
@@ -191,8 +194,9 @@
 
 		// if not allowed to overwrite, check if any nameclashes exists
 		if (!$allowOverwrite) {
-			if ((sizeof($existingSkins) > 0) || (sizeof($existingTemplates) > 0))
+			if ((sizeof($existingSkins) > 0) || (sizeof($existingTemplates) > 0)) {
 				return _SKINIE_NAME_CLASHES_DETECTED;
+			}
 		}
 
 		foreach ($this->skins as $skinName => $data) {
@@ -205,9 +209,21 @@
 				$skinObj->deleteAllParts();
 
 				// update general info
-				$skinObj->updateGeneralInfo($skinName, $data['description'], $data['type'], $data['includeMode'], $data['includePrefix']);
+				$skinObj->updateGeneralInfo(
+				    $skinName,
+				    $data['description'],
+				    $data['type'],
+				    $data['includeMode'],
+				    $data['includePrefix']
+				);
 			} else {
-				$skinid = SKIN::createNew($skinName, $data['description'], $data['type'], $data['includeMode'], $data['includePrefix']);
+				$skinid = SKIN::createNew(
+				    $skinName,
+				    $data['description'],
+				    $data['type'],
+				    $data['includeMode'],
+				    $data['includePrefix']
+				);
 				$skinObj = new SKIN($skinid);
 			}
 
@@ -249,8 +265,9 @@
 		$clashes = array();
 
 		foreach ($this->skins as $skinName => $data) {
-			if (SKIN::exists($skinName))
+			if (SKIN::exists($skinName)) {
 				array_push($clashes, $skinName);
+			}
 		}
 
 		return $clashes;
@@ -264,8 +281,9 @@
 		$clashes = array();
 
 		foreach ($this->templates as $templateName => $data) {
-			if (TEMPLATE::exists($templateName))
+			if (TEMPLATE::exists($templateName)) {
 				array_push($clashes, $templateName);
+			}
 		}
 
 		return $clashes;
@@ -275,9 +293,13 @@
 	 * Called by XML parser for each new start element encountered
 	 */
 	function startElement($parser, $name, $attrs) {
-		foreach($attrs as $key=>$value) $attrs[$key]=htmlspecialchars($value,ENT_QUOTES);
+		foreach($attrs as $key=>$value) {
+		    $attrs[$key]=htmlspecialchars($value,ENT_QUOTES);
+		}
 
-		if ($this->debug) echo 'START: ', htmlspecialchars($name), '<br />';
+		if ($this->debug) {
+		    echo 'START: ', htmlspecialchars($name), '<br />';
+		}
 
 		switch ($name) {
 			case 'nucleusskin':
@@ -319,7 +341,7 @@
 				$this->currentPartName = $attrs['name'];
 				break;
 			default:
-				echo _SKINIE_SEELEMENT_UNEXPECTEDTAG . htmlspecialchars($name) , '<br />';
+				echo _SKINIE_SEELEMENT_UNEXPECTEDTAG . htmlspecialchars($name, ENT_QUOTES) , '<br />';
 				break;
 		}
 
@@ -332,7 +354,9 @@
 	  * Called by the XML parser for each closing tag encountered
 	  */
 	function endElement($parser, $name) {
-		if ($this->debug) echo 'END: ', htmlspecialchars($name), '<br />';
+		if ($this->debug) {
+			echo 'END: ' . htmlspecialchars($name, ENT_QUOTES) . '<br />';
+		}
 
 		switch ($name) {
 			case 'nucleusskin':
@@ -346,10 +370,14 @@
 			case 'info':
 				$this->info = $this->getCharacterData();
 			case 'skin':
-				if (!$this->inMeta) $this->inSkin = 0;
+				if (!$this->inMeta) {
+				    $this->inSkin = 0;
+				}
 				break;
 			case 'template':
-				if (!$this->inMeta) $this->inTemplate = 0;
+				if (!$this->inMeta) {
+				    $this->inTemplate = 0;
+				}
 				break;
 			case 'description':
 				if ($this->inSkin) {
@@ -366,7 +394,7 @@
 				}
 				break;
 			default:
-				echo _SKINIE_SEELEMENT_UNEXPECTEDTAG . htmlspecialchars($name), '<br />';
+				echo _SKINIE_SEELEMENT_UNEXPECTEDTAG . htmlspecialchars($name, ENT_QUOTES) . '<br />';
 				break;
 		}
 		$this->clearCharacterData();
@@ -377,7 +405,9 @@
 	 * Called by XML parser for data inside elements
 	 */
 	function characterData ($parser, $data) {
-		if ($this->debug) echo 'NEW DATA: ', htmlspecialchars($data), '<br />';
+		if ($this->debug) {
+			echo 'NEW DATA: ' . htmlspecialchars($data, ENT_QUOTES) . '<br />';
+		}
 		$this->cdata .= $data;
 	}
 
@@ -454,7 +484,10 @@
 	 * @result false when no such ID exists
 	 */
 	function addTemplate($id) {
-		if (!TEMPLATE::existsID($id)) return 0;
+		if (!TEMPLATE::existsID($id)) {
+		    return 0;
+		}
+
 
 		$this->templates[$id] = TEMPLATE::getNameFromId($id);
 
@@ -469,7 +502,9 @@
 	 * @result false when no such ID exists
 	 */
 	function addSkin($id) {
-		if (!SKIN::existsID($id)) return 0;
+		if (!SKIN::existsID($id)) {
+		    return 0;
+		}
 
 		$this->skins[$id] = SKIN::getNameFromId($id);
 
@@ -507,11 +542,11 @@
 		echo "\t<meta>\n";
 			// skins
 			foreach ($this->skins as $skinId => $skinName) {
-				echo "\t\t", '<skin name="',htmlspecialchars($skinName),'" />',"\n";
+				echo "\t\t", '<skin name="',htmlspecialchars($skinName, ENT_QUOTES),'" />',"\n";
 			}
 			// templates
 			foreach ($this->templates as $templateId => $templateName) {
-				echo "\t\t", '<template name="',htmlspecialchars($templateName),'" />',"\n";
+				echo "\t\t", '<template name="',htmlspecialchars($templateName, ENT_QUOTES),'" />',"\n";
 			}
 			// extra info
 			if ($this->info)
@@ -528,7 +563,7 @@
 			echo "\t\t", '<description>',htmlspecialchars($skinObj->getDescription()),'</description>',"\n";
 
 			$res = sql_query('SELECT stype, scontent FROM '.sql_table('skin').' WHERE sdesc='.$skinId);
-			while ($partObj = mysql_fetch_object($res)) {
+			while ($partObj = sql_fetch_object($res)) {
 				echo "\t\t",'<part name="',htmlspecialchars($partObj->stype),'">';
 				echo '<![CDATA[', $this->escapeCDATA($partObj->scontent),']]>';
 				echo "</part>\n\n";
@@ -546,7 +581,7 @@
 			echo "\t\t",'<description>',htmlspecialchars(TEMPLATE::getDesc($templateId)),'</description>',"\n";
 
 			$res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc='.$templateId);
-			while ($partObj = mysql_fetch_object($res)) {
+			while ($partObj = sql_fetch_object($res)) {
 				echo "\t\t",'<part name="',htmlspecialchars($partObj->tpartname),'">';
 				echo '<![CDATA[', $this->escapeCDATA($partObj->tcontent) ,']]>';
 				echo '</part>',"\n\n";
diff -x .svn -aruN 3.41.src/nucleus/libs/SKIN.php 3.51.src/nucleus/libs/SKIN.php
--- 3.41.src/nucleus/libs/SKIN.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/SKIN.php	2009-11-01 14:53:58.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -13,8 +13,8 @@
  * Class representing a skin
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: SKIN.php 1247 2008-02-11 14:28:05Z kaigreve $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: SKIN.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 if ( !function_exists('requestVar') ) exit;
@@ -38,8 +38,8 @@
 
 		// read skin name/description/content type
 		$res = sql_query('SELECT * FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $this->id);
-		$obj = mysql_fetch_object($res);
-		$this->isValid = (mysql_num_rows($res) > 0);
+		$obj = sql_fetch_object($res);
+		$this->isValid = (sql_num_rows($res) > 0);
 		if (!$this->isValid)
 			return;
 
@@ -99,7 +99,7 @@
 			   . ' FROM '.sql_table('skin_desc')
 			   . ' WHERE sdname="'.addslashes($name).'"';
 		$res = sql_query($query);
-		$obj = mysql_fetch_object($res);
+		$obj = sql_fetch_object($res);
 		return $obj->sdnumber;
 	}
 
@@ -133,7 +133,7 @@
 		);
 
 		sql_query('INSERT INTO '.sql_table('skin_desc')." (sdname, sddesc, sdtype, sdincmode, sdincpref) VALUES ('" . addslashes($name) . "','" . addslashes($desc) . "','".addslashes($type)."','".addslashes($includeMode)."','".addslashes($includePrefix)."')");
-		$newid = mysql_insert_id();
+		$newid = sql_insert_id();
 
 		$manager->notify(
 			'PostAddSkin',
@@ -197,10 +197,10 @@
 		$query = 'SELECT scontent FROM '.sql_table('skin')." WHERE sdesc=$this->id and stype='". addslashes($type) ."'";
 		$res = sql_query($query);
 
-		if (mysql_num_rows($res) == 0)
+		if (sql_num_rows($res) == 0)
 			return '';
 		else
-			return mysql_result($res, 0, 0);
+			return sql_result($res, 0, 0);
 	}
 
 	/**
@@ -256,7 +256,7 @@
 
 		$query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member')";
 		$res = sql_query($query);
-		while ($row = mysql_fetch_array($res)) {
+		while ($row = sql_fetch_array($res)) {
 			$skintypes[strtolower($row['stype'])] = ucfirst($row['stype']);
 		}
 
@@ -278,6 +278,7 @@
 								'sitevar',
 								'otherarchivelist',
 								'otherarchivedaylist',
+								'otherarchiveyearlist',
 								'self',
 								'adminurl',
 								'todaylink',
@@ -299,7 +300,8 @@
 								'charset',
 								'bloglist',
 								'addlink',
-								'addpopupcode'
+								'addpopupcode',
+								'sticky'
 								);
 
 		// extra actions specific for a certain skin type
@@ -314,6 +316,7 @@
 								'categorylist',
 								'archivelist',
 								'archivedaylist',
+								'archiveyearlist',
 								'nextlink',
 								'prevlink'
 								);
@@ -325,6 +328,7 @@
 								'categorylist',
 								'archivelist',
 								'archivedaylist',
+								'archiveyearlist',
 								'blogsetting',
 								'archivedate',
 								'nextarchive',
@@ -338,6 +342,7 @@
 				$extraActions = array('blog',
 								'archivelist',
 								'archivedaylist',
+								'archiveyearlist',
 								'categorylist',
 								'blogsetting',
 							   );
@@ -346,6 +351,7 @@
 				$extraActions = array('blog',
 								'archivelist',
 								'archivedaylist',
+								'archiveyearlist',
 								'categorylist',
 								'searchresults',
 								'othersearchresults',
@@ -383,6 +389,7 @@
 								'categorylist',
 								'archivelist',
 								'archivedaylist',
+								'archiveyearlist',
 								'itemtitle',
 								'itemid',
 								'itemlink',
@@ -403,9 +410,8 @@
 						'categorylist',
 						'archivelist',
 						'archivedaylist',
+						'archiveyearlist',
 						'nextlink',
-						'archivelist',
-						'archivedaylist',
 						'prevlink',
 						'membermailform',
 						'nucleusbutton'
diff -x .svn -aruN 3.41.src/nucleus/libs/sql/mysql.php 3.51.src/nucleus/libs/sql/mysql.php
--- 3.41.src/nucleus/libs/sql/mysql.php	1969-12-31 18:00:00.000000000 -0600
+++ 3.51.src/nucleus/libs/sql/mysql.php	2009-11-01 14:53:52.000000000 -0600
@@ -0,0 +1,326 @@
+<?php
+
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2009 The Nucleus Group
+ *
+ * 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.
+ * (see nucleus/documentation/index.html#license for more info)
+ */
+/**
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id$
+ */
+ 
+/*
+ * complete sql_* wrappers for mysql functions
+ *
+ * functions moved from globalfunctions.php: sql_connect, sql_disconnect, sql_query
+ */
+
+
+$MYSQL_CONN = 0;
+
+if (function_exists('mysql_query') && !function_exists('sql_fetch_assoc'))
+{
+	/**
+	 * Errors before the database connection has been made
+	 */
+	function startUpError($msg, $title) {
+		?>
+		<html xmlns="http://www.w3.org/1999/xhtml">
+			<head><title><?php echo htmlspecialchars($title)?></title></head>
+			<body>
+				<h1><?php echo htmlspecialchars($title)?></h1>
+				<?php echo $msg?>
+			</body>
+		</html>
+<?php
+		exit;
+	}
+	
+	/**
+	  * Connects to mysql server with arguments
+	  */
+	function sql_connect_args($mysql_host = 'localhost', $mysql_user = '', $mysql_password = '', $mysql_database = '') {
+		
+		$CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password); 
+		if ($mysql_database) mysql_select_db($mysql_database,$CONN);
+
+		return $CONN;
+	}
+	
+	/**
+	  * Connects to mysql server
+	  */
+	function sql_connect() {
+		global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_CONN;
+
+		$MYSQL_CONN = @mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD) or startUpError('<p>Could not connect to MySQL database.</p>', 'Connect Error');
+		mysql_select_db($MYSQL_DATABASE) or startUpError('<p>Could not select database: ' . mysql_error() . '</p>', 'Connect Error');
+
+		return $MYSQL_CONN;
+	}
+
+	/**
+	  * disconnects from SQL server
+	  */
+	function sql_disconnect($conn = false) {
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		@mysql_close($conn);
+	}
+	
+	function sql_close($conn = false) {
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		@mysql_close($conn);
+	}
+	
+	/**
+	  * executes an SQL query
+	  */
+	function sql_query($query,$conn = false) {
+		global $SQLCount,$MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		$SQLCount++;
+		$res = mysql_query($query,$conn) or print("mySQL error with query $query: " . mysql_error($conn) . '<p />');
+		return $res;
+	}
+	
+	/**
+	  * executes an SQL error
+	  */
+	function sql_error($conn = false)
+	{
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		return mysql_error($conn);
+	}
+	
+	/**
+	  * executes an SQL db select
+	  */
+	function sql_select_db($db,$conn = false)
+	{
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		return mysql_select_db($db,$conn);
+	}
+	
+	/**
+	  * executes an SQL real escape 
+	  */
+	function sql_real_escape_string($val,$conn = false)
+	{
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		return mysql_real_escape_string($val,$conn);
+	}
+	
+	/**
+	  * executes an PDO::quote() like escape, ie adds quotes arround the string and escapes chars as needed 
+	  */
+	function sql_quote_string($val,$conn = false) {
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		return "'".mysql_real_escape_string($val,$conn)."'";
+	}
+	
+	/**
+	  * executes an SQL insert id
+	  */
+	function sql_insert_id($conn = false)
+	{
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		return mysql_insert_id($conn);
+	}
+	
+	/**
+	  * executes an SQL result request
+	  */
+	function sql_result($res, $row, $col)
+	{
+		return mysql_result($res,$row,$col);
+	}
+	
+	/**
+	  * frees sql result resources
+	  */
+	function sql_free_result($res)
+	{
+		return mysql_free_result($res);
+	}
+	
+	/**
+	  * returns number of rows in SQL result
+	  */
+	function sql_num_rows($res)
+	{
+		return mysql_num_rows($res);
+	}
+	
+	/**
+	  * returns number of rows affected by SQL query
+	  */
+	function sql_affected_rows($res)
+	{
+		return mysql_affected_rows($res);
+	}
+	
+	/**
+	  * Get number of fields in result
+	  */
+	function sql_num_fields($res)
+	{
+		return mysql_num_fields($res);
+	}
+	
+	/**
+	  * fetches next row of SQL result as an associative array
+	  */
+	function sql_fetch_assoc($res)
+	{
+		return mysql_fetch_assoc($res);
+	}
+	
+	/**
+	  * Fetch a result row as an associative array, a numeric array, or both
+	  */
+	function sql_fetch_array($res)
+	{
+		return mysql_fetch_array($res);
+	}
+	
+	/**
+	  * fetches next row of SQL result as an object
+	  */
+	function sql_fetch_object($res)
+	{
+		return mysql_fetch_object($res);
+	}
+	
+	/**
+	  * Get a result row as an enumerated array
+	  */
+	function sql_fetch_row($res)
+	{
+		return mysql_fetch_row($res);
+	}
+	
+	/**
+	  * Get column information from a result and return as an object
+	  */
+	function sql_fetch_field($res,$offset = 0)
+	{
+		return mysql_fetch_field($res,$offset);
+	}
+	
+	/**
+	  * Get current system status (returns string)
+	  */
+	function sql_stat($conn=false)
+	{
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		return mysql_stat($conn);
+	}
+	
+	/**
+	  * Returns the name of the character set
+	  */
+	function sql_client_encoding($conn=false)
+	{
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		return mysql_client_encoding($conn);
+	}
+	
+	/**
+	  * Get SQL client version
+	  */
+	function sql_get_client_info()
+	{
+		return mysql_get_client_info();
+	}
+	
+	/**
+	  * Get SQL server version
+	  */
+	function sql_get_server_info($conn=false)
+	{
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		return mysql_get_server_info($conn);
+	}
+	
+	/**
+	  * Returns a string describing the type of SQL connection in use for the connection or FALSE on failure
+	  */
+	function sql_get_host_info($conn=false)
+	{
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		return mysql_get_host_info($conn);
+	}
+	
+	/**
+	  * Returns the SQL protocol on success, or FALSE on failure. 
+	  */
+	function sql_get_proto_info($conn=false)
+	{
+		global $MYSQL_CONN;
+		if (!$conn) $conn = $MYSQL_CONN;
+		return mysql_get_proto_info($conn);
+	}
+
+    /**
+     * Get the name of the specified field in a result
+     */
+    function sql_field_name($res, $offset = 0)
+    {
+        return mysql_field_name($res, $offset);
+    }
+	
+/**************************************************************************
+Unimplemented mysql_* functions
+
+# mysql_ data_ seek (maybe useful)
+# mysql_ errno (maybe useful)
+# mysql_ fetch_ lengths (maybe useful)
+# mysql_ field_ flags (maybe useful)
+# mysql_ field_ len (maybe useful)
+# mysql_ field_ seek (maybe useful)
+# mysql_ field_ table (maybe useful)
+# mysql_ field_ type (maybe useful)
+# mysql_ info (maybe useful)
+# mysql_ list_ processes (maybe useful)
+# mysql_ ping (maybe useful)
+# mysql_ set_ charset (maybe useful, requires php >=5.2.3 and mysql >=5.0.7)
+# mysql_ thread_ id (maybe useful)
+
+# mysql_ db_ name (useful only if working on multiple dbs which we do not do)
+# mysql_ list_ dbs (useful only if working on multiple dbs which we do not do)
+
+# mysql_ pconnect (probably not useful and could cause some unintended performance issues)
+# mysql_ unbuffered_ query (possibly useful, but complicated and not supported by all database drivers (pdo))
+
+# mysql_ change_ user (deprecated)
+# mysql_ create_ db (deprecated)
+# mysql_ db_ query (deprecated)
+# mysql_ drop_ db (deprecated)
+# mysql_ escape_ string (deprecated)
+# mysql_ list_ fields (deprecated)
+# mysql_ list_ tables (deprecated)
+# mysql_ tablename (deprecated)
+
+*******************************************************************/
+
+
+}
+?>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/libs/sql/pdo.php 3.51.src/nucleus/libs/sql/pdo.php
--- 3.41.src/nucleus/libs/sql/pdo.php	1969-12-31 18:00:00.000000000 -0600
+++ 3.51.src/nucleus/libs/sql/pdo.php	2009-11-01 14:53:52.000000000 -0600
@@ -0,0 +1,577 @@
+<?php
+
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2009 The Nucleus Group
+ *
+ * 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.
+ * (see nucleus/documentation/index.html#license for more info)
+ */
+/**
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id$
+ */
+ 
+/*
+ * complete sql_* wrappers for mysql functions
+ *
+ * functions moved from globalfunctions.php: sql_connect, sql_disconnect, sql_query
+ */
+ 
+
+$MYSQL_CONN = 0;
+global $SQL_DBH;
+$SQL_DBH = NULL;
+
+if (!function_exists('sql_fetch_assoc'))
+{
+	/**
+	 * Errors before the database connection has been made
+	 */
+	function startUpError($msg, $title) {
+		?>
+		<html xmlns="http://www.w3.org/1999/xhtml">
+			<head><title><?php echo htmlspecialchars($title)?></title></head>
+			<body>
+				<h1><?php echo htmlspecialchars($title)?></h1>
+				<?php echo $msg?>
+			</body>
+		</html>
+		<?php	exit;
+	}
+	
+	/**
+	  * Connects to mysql server
+	  */
+	function sql_connect_args($mysql_host = 'localhost', $mysql_user = '', $mysql_password = '', $mysql_database = '') {
+		global $MYSQL_HANDLER;
+		
+		try {
+			if (strpos($mysql_host,':') === false) {
+				$host = $mysql_host;
+				$port = '';
+				$portnum = '';
+			}
+			else {
+				list($host,$port) = explode(":",$mysql_host);
+				if (isset($port)) {
+					$portnum = $port;
+					$port = ';port='.trim($port);
+				}
+				else {
+					$port = '';
+					$portnum = '';
+				}
+			}
+			
+			switch ($MYSQL_HANDLER[1]) {
+				case 'sybase':
+				case 'dblib':
+					if (is_numeric($portnum)) $port = ':'.intval($portnum);
+					else $port = '';
+					$DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$mysql_database, $mysql_user, $mysql_password);
+				break;
+				case 'mssql':
+					if (is_numeric($portnum)) $port = ','.intval($portnum);
+					else $port = '';
+					$DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$mysql_database, $mysql_user, $mysql_password);
+				break;
+				case 'oci':
+					if (is_numeric($portnum)) $port = ':'.intval($portnum);
+					else $port = '';
+					$DBH = new PDO($MYSQL_HANDLER[1].':dbname=//'.$host.$port.'/'.$mysql_database, $mysql_user, $mysql_password);
+				break;
+				case 'odbc':
+					if (is_numeric($portnum)) $port = ';PORT='.intval($portnum);
+					else $port = '';
+					$DBH = new PDO($MYSQL_HANDLER[1].':DRIVER={IBM DB2 ODBC DRIVER};HOSTNAME='.$host.$port.';DATABASE='.$mysql_database.';PROTOCOL=TCPIP;UID='.$mysql_user.';PWD='.$mysql_password);
+
+				break;
+				case 'pgsql':
+					if (is_numeric($portnum)) $port = ';port='.intval($portnum);
+					else $port = '';
+					$DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$mysql_database, $mysql_user, $mysql_password);
+				break;
+				case 'sqlite':
+				case 'sqlite2':
+					if (is_numeric($portnum)) $port = ':'.intval($portnum);
+					else $port = '';
+					$DBH = new PDO($MYSQL_HANDLER[1].':'.$mysql_database, $mysql_user, $mysql_password);
+				break;
+				default:
+					//mysql
+					$DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$mysql_database, $mysql_user, $mysql_password);
+				break;
+			}
+	
+			
+						
+		} catch (PDOException $e) {
+			$DBH =NULL;
+			startUpError('<p>a1 Error!: ' . $e->getMessage() . '</p>', 'Connect Error');
+		}
+//echo '<hr />DBH: '.print_r($DBH,true).'<hr />';		
+		return $DBH;
+	}
+	
+	/**
+	  * Connects to mysql server
+	  */
+	function sql_connect() {
+		global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_CONN, $MYSQL_HANDLER, $SQL_DBH;
+		$SQL_DBH = NULL;
+		try {
+			if (strpos($MYSQL_HOST,':') === false) {
+				$host = $MYSQL_HOST;
+				$port = '';
+			}
+			else {
+				list($host,$port) = explode(":",$MYSQL_HOST);
+				if (isset($port)) {
+					$portnum = $port;
+					$port = ';port='.trim($port);
+				}
+				else {
+					$port = '';
+					$portnum = '';
+				}
+			}
+			
+			switch ($MYSQL_HANDLER[1]) {
+				case 'sybase':
+				case 'dblib':
+					if (is_numeric($portnum)) $port = ':'.intval($portnum);
+					else $port = '';
+					$SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$MYSQL_DATABASE, $MYSQL_USER, $MYSQL_PASSWORD);
+				break;
+				case 'mssql':
+					if (is_numeric($portnum)) $port = ','.intval($portnum);
+					else $port = '';
+					$SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$MYSQL_DATABASE, $MYSQL_USER, $MYSQL_PASSWORD);
+				break;
+				case 'oci':
+					if (is_numeric($portnum)) $port = ':'.intval($portnum);
+					else $port = '';
+					$SQL_DBH = new PDO($MYSQL_HANDLER[1].':dbname=//'.$host.$port.'/'.$MYSQL_DATABASE, $MYSQL_USER, $MYSQL_PASSWORD);
+				break;
+				case 'odbc':
+					if (is_numeric($portnum)) $port = ';PORT='.intval($portnum);
+					else $port = '';
+					$SQL_DBH = new PDO($MYSQL_HANDLER[1].':DRIVER={IBM DB2 ODBC DRIVER};HOSTNAME='.$host.$port.';DATABASE='.$MYSQL_DATABASE.';PROTOCOL=TCPIP;UID='.$MYSQL_USER.';PWD='.$MYSQL_PASSWORD);
+
+				break;
+				case 'pgsql':
+					if (is_numeric($portnum)) $port = ';port='.intval($portnum);
+					else $port = '';
+					$SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$MYSQL_DATABASE, $MYSQL_USER, $MYSQL_PASSWORD);
+				break;
+				case 'sqlite':
+				case 'sqlite2':
+					if (is_numeric($portnum)) $port = ':'.intval($portnum);
+					else $port = '';
+					$SQL_DBH = new PDO($MYSQL_HANDLER[1].':'.$MYSQL_DATABASE, $MYSQL_USER, $MYSQL_PASSWORD);
+				break;
+				default:
+					//mysql
+					$SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$MYSQL_DATABASE, $MYSQL_USER, $MYSQL_PASSWORD);
+				break;
+			}
+			
+			//$SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$MYSQL_DATABASE, $MYSQL_USER, $MYSQL_PASSWORD);
+						
+		} catch (PDOException $e) {
+			$SQL_DBH = NULL;
+			startUpError('<p>a2 Error!: ' . $e->getMessage() . '</p>', 'Connect Error');
+		}
+//		echo '<hr />DBH: '.print_r($SQL_DBH,true).'<hr />';		
+		$MYSQL_CONN &= $SQL_DBH;
+		return $SQL_DBH;
+
+	}
+
+	/**
+	  * disconnects from SQL server
+	  */
+	function sql_disconnect(&$dbh=NULL) {
+		global $SQL_DBH;
+		if (is_null($dbh)) $SQL_DBH = NULL;
+		else $dbh = NULL;
+	}
+	
+	function sql_close(&$dbh=NULL) {
+		global $SQL_DBH;
+		if (is_null($dbh)) $SQL_DBH = NULL;
+		else $dbh = NULL;
+	}
+	
+	/**
+	  * executes an SQL query
+	  */
+	function sql_query($query,$dbh=NULL) {
+		global $SQLCount,$SQL_DBH;
+		$SQLCount++;
+//echo '<hr />SQL_DBH: ';
+//print_r($SQL_DBH);
+//echo '<hr />DBH: ';
+//print_r($dbh);
+//echo '<hr />';
+//echo $query.'<hr />';
+		if (is_null($dbh)) $res = $SQL_DBH->query($query);
+		else $res = $dbh->query($query);
+		if ($res->errorCode() != '00000') {
+			$errors = $res->errorInfo();
+			print("SQL error with query $query: " . $errors[0].'-'.$errors[1].' '.$errors[2] . '<p />');
+		}
+		
+		return $res;
+	}
+	
+	/**
+	  * executes an SQL error
+	  */
+	function sql_error($dbh=NULL)
+	{
+		global $SQL_DBH;
+		if (is_null($dbh)) $error = $SQL_DBH->errorInfo();
+		else $error = $dbh->errorInfo();
+		if ($error[0] != '00000') {
+			return $error[0].'-'.$error[1].' '.$error[2];
+		}
+		else return '';
+	}
+	
+	/**
+	  * executes an SQL db select
+	  */
+	function sql_select_db($db,&$dbh=NULL)
+	{
+		global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_CONN, $MYSQL_HANDLER, $SQL_DBH;
+//echo '<hr />'.print_r($dbh,true).'<hr />';
+//exit;
+		if (is_null($dbh)) { 
+			try {
+				$SQL_DBH = NULL;
+				list($host,$port) = explode(":",$MYSQL_HOST);
+				if (isset($port)) {
+					$portnum = $port;
+					$port = ';port='.trim($port);
+				}
+				else {
+					$port = '';
+					$portnum = '';
+				}
+				//$SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.trim($host).$port.';dbname='.$db, $MYSQL_USER, $MYSQL_PASSWORD);
+				//$SQL_DBH = sql_connect();
+				switch ($MYSQL_HANDLER[1]) {
+					case 'sybase':
+					case 'dblib':
+						if (is_numeric($portnum)) $port = ':'.intval($portnum);
+						else $port = '';
+						$SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$db, $MYSQL_USER, $MYSQL_PASSWORD);
+					break;
+					case 'mssql':
+						if (is_numeric($portnum)) $port = ','.intval($portnum);
+						else $port = '';
+						$SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$db, $MYSQL_USER, $MYSQL_PASSWORD);
+					break;
+					case 'oci':
+						if (is_numeric($portnum)) $port = ':'.intval($portnum);
+						else $port = '';
+						$SQL_DBH = new PDO($MYSQL_HANDLER[1].':dbname=//'.$host.$port.'/'.$db, $MYSQL_USER, $MYSQL_PASSWORD);
+					break;
+					case 'odbc':
+						if (is_numeric($portnum)) $port = ';PORT='.intval($portnum);
+						else $port = '';
+						$SQL_DBH = new PDO($MYSQL_HANDLER[1].':DRIVER={IBM DB2 ODBC DRIVER};HOSTNAME='.$host.$port.';DATABASE='.$db.';PROTOCOL=TCPIP;UID='.$MYSQL_USER.';PWD='.$MYSQL_PASSWORD);
+
+					break;
+					case 'pgsql':
+						if (is_numeric($portnum)) $port = ';port='.intval($portnum);
+						else $port = '';
+						$SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$db, $MYSQL_USER, $MYSQL_PASSWORD);
+					break;
+					case 'sqlite':
+					case 'sqlite2':
+						if (is_numeric($portnum)) $port = ':'.intval($portnum);
+						else $port = '';
+						$SQL_DBH = new PDO($MYSQL_HANDLER[1].':'.$db, $MYSQL_USER, $MYSQL_PASSWORD);
+					break;
+					default:
+						//mysql
+						$SQL_DBH = new PDO($MYSQL_HANDLER[1].':host='.$host.$port.';dbname='.$db, $MYSQL_USER, $MYSQL_PASSWORD);
+					break;
+				}
+				return 1;
+			} catch (PDOException $e) {
+				startUpError('<p>a3 Error!: ' . $e->getMessage() . '</p>', 'Connect Error');
+				return 0;
+			}
+		}
+		else {
+			if ($dbh->exec("USE $db") !== false) return 1;
+			else return 0;
+		}
+	}
+	
+	/**
+	  * executes an SQL real escape 
+	  */
+	function sql_real_escape_string($val,$dbh=NULL)
+	{
+		return addslashes($val);
+	}
+	
+	/**
+	  * executes an PDO::quote() like escape, ie adds quotes arround the string and escapes chars as needed 
+	  */
+	function sql_quote_string($val,$dbh=NULL) {
+		global $SQL_DBH;
+		if (is_null($dbh))
+			return $SQL_DBH->quote($val);
+		else
+			return $dbh->quote($val);
+	}
+	
+	/**
+	  * executes an SQL insert id
+	  */
+	function sql_insert_id($dbh=NULL)
+	{	
+		global $SQL_DBH;
+		if (is_null($dbh))
+			return $SQL_DBH->lastInsertId();
+		else
+			return $dbh->lastInsertId();
+	}
+	
+	/**
+	  * executes an SQL result request
+	  */
+	function sql_result($res, $row = 0, $col = 0)
+	{
+		$results = array();
+		if (intval($row) < 1) {
+			$results = $res->fetch(PDO::FETCH_BOTH);
+			return $results[$col];
+		}
+		else {
+			for ($i = 0; $i < intval($row); $i++) {
+				$results = $res->fetch(PDO::FETCH_BOTH);
+			}
+			$results = $res->fetch(PDO::FETCH_BOTH);
+			return $results[$col];
+		}
+	}
+	
+	/**
+	  * frees sql result resources
+	  */
+	function sql_free_result($res)
+	{
+		$res = NULL;
+		return true;
+	}
+	
+	/**
+	  * returns number of rows in SQL result
+	  */
+	function sql_num_rows($res)
+	{
+		return $res->rowCount();
+	}
+	
+	/**
+	  * returns number of rows affected by SQL query
+	  */
+	function sql_affected_rows($res)
+	{
+		return $res->rowCount();
+	}
+	
+	/**
+	  * Get number of fields in result
+	  */
+	function sql_num_fields($res)
+	{
+		return $res->columnCount();
+	}
+	
+	/**
+	  * fetches next row of SQL result as an associative array
+	  */
+	function sql_fetch_assoc($res)
+	{
+		$results = array();
+		$results = $res->fetch(PDO::FETCH_ASSOC);	
+		return $results;
+	}
+	
+	/**
+	  * Fetch a result row as an associative array, a numeric array, or both
+	  */
+	function sql_fetch_array($res)
+	{
+		$results = array();
+		$results = $res->fetch(PDO::FETCH_BOTH);
+		return $results;
+	}
+	
+	/**
+	  * fetches next row of SQL result as an object
+	  */
+	function sql_fetch_object($res)
+	{
+		$results = NULL;
+		$results = $res->fetchObject();	
+		return $results;
+	}
+	
+	/**
+	  * Get a result row as an enumerated array
+	  */
+	function sql_fetch_row($res)
+	{
+		$results = array();
+		$results = $res->fetch(PDO::FETCH_NUM);	
+		return $results;
+	}
+	
+	/**
+	  * Get column information from a result and return as an object
+	  */
+	function sql_fetch_field($res,$offset = 0)
+	{
+		$results = array();
+		$obj = NULL;
+		$results = $res->getColumnMeta($offset);
+		foreach($results as $key=>$value) {
+			$obj->$key = $value;
+		}
+		return $obj;
+	}
+	
+	/**
+	  * Get current system status (returns string)
+	  */
+	function sql_stat($dbh=NULL)
+	{
+		//not implemented
+		global $SQL_DBH;
+		if (is_null($dbh))
+			return '';
+		else
+			return '';
+	}
+	
+	/**
+	  * Returns the name of the character set
+	  */
+	function sql_client_encoding($dbh=NULL)
+	{
+		//not implemented
+		global $SQL_DBH;
+		if (is_null($dbh))
+			return '';
+		else
+			return '';
+	}
+	
+	/**
+	  * Get SQL client version
+	  */
+	function sql_get_client_info()
+	{
+		global $SQL_DBH;
+		return $SQL_DBH->getAttribute(constant("PDO::ATTR_CLIENT_VERSION"));
+	}
+	
+	/**
+	  * Get SQL server version
+	  */
+	function sql_get_server_info($dbh=NULL)
+	{
+		global $SQL_DBH;
+		if (is_null($dbh))
+			return $SQL_DBH->getAttribute(constant("PDO::ATTR_SERVER_VERSION"));
+		else
+			return $dbh->getAttribute(constant("PDO::ATTR_SERVER_VERSION"));
+	}
+	
+	/**
+	  * Returns a string describing the type of SQL connection in use for the connection or FALSE on failure
+	  */
+	function sql_get_host_info($dbh=NULL)
+	{
+		global $SQL_DBH;
+		if (is_null($dbh))
+			return $SQL_DBH->getAttribute(constant("PDO::ATTR_SERVER_INFO"));
+		else
+			return $dbh->getAttribute(constant("PDO::ATTR_SERVER_INFO"));
+	}
+	
+	/**
+	  * Returns the SQL protocol on success, or FALSE on failure. 
+	  */
+	function sql_get_proto_info($dbh=NULL)
+	{
+		//not implemented
+		global $SQL_DBH;
+		if (is_null($dbh))
+			return false;
+		else
+			return false;
+	}
+
+    /**
+     * Get the name of the specified field in a result
+     */
+    function sql_field_name($res, $offset = 0)
+    {
+        $column = $res->getColumnMeta($offset);
+        if ($column) {
+            return $column['name'];
+        }
+        return false;
+    }
+
+/**************************************************************************
+Unimplemented mysql_* functions
+
+# mysql_ data_ seek (maybe useful)
+# mysql_ errno (maybe useful)
+# mysql_ fetch_ lengths (maybe useful)
+# mysql_ field_ flags (maybe useful)
+# mysql_ field_ len (maybe useful)
+# mysql_ field_ seek (maybe useful)
+# mysql_ field_ table (maybe useful)
+# mysql_ field_ type (maybe useful)
+# mysql_ info (maybe useful)
+# mysql_ list_ processes (maybe useful)
+# mysql_ ping (maybe useful)
+# mysql_ set_ charset (maybe useful, requires php >=5.2.3 and mysql >=5.0.7)
+# mysql_ thread_ id (maybe useful)
+
+# mysql_ db_ name (useful only if working on multiple dbs which we do not do)
+# mysql_ list_ dbs (useful only if working on multiple dbs which we do not do)
+
+# mysql_ pconnect (probably not useful and could cause some unintended performance issues)
+# mysql_ unbuffered_ query (possibly useful, but complicated and not supported by all database drivers (pdo))
+
+# mysql_ change_ user (deprecated)
+# mysql_ create_ db (deprecated)
+# mysql_ db_ query (deprecated)
+# mysql_ drop_ db (deprecated)
+# mysql_ escape_ string (deprecated)
+# mysql_ list_ fields (deprecated)
+# mysql_ list_ tables (deprecated)
+# mysql_ tablename (deprecated)
+
+*******************************************************************/
+
+}
+
+?>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/libs/TEMPLATE.php 3.51.src/nucleus/libs/TEMPLATE.php
--- 3.41.src/nucleus/libs/TEMPLATE.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/TEMPLATE.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * A class representing a template
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: TEMPLATE.php 1338 2009-02-28 15:09:19Z shizuki $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: TEMPLATE.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 class TEMPLATE {
 
@@ -40,7 +40,7 @@
 			   . ' FROM '.sql_table('template_desc')
 			   . ' WHERE tdname="'.addslashes($name).'"';
 		$res = sql_query($query);
-		$obj = mysql_fetch_object($res);
+		$obj = sql_fetch_object($res);
 		return $obj->tdnumber;
 	}
 
@@ -95,7 +95,7 @@
 		);
 
 		sql_query('INSERT INTO '.sql_table('template_desc')." (tdname, tddesc) VALUES ('" . addslashes($name) . "','" . addslashes($desc) . "')");
-		$newId = mysql_insert_id();
+		$newId = sql_insert_id();
 
 		$manager->notify(
 			'PostAddTemplate',
@@ -130,7 +130,7 @@
 			   . ' FROM '.sql_table('template_desc').', '.sql_table('template')
 			   . ' WHERE tdesc=tdnumber and tdname="' . addslashes($name) . '"';
 		$res = sql_query($query);
-		while ($obj = mysql_fetch_object($res))
+		while ($obj = sql_fetch_object($res))
 			$template[$obj->tpartname] = $obj->tcontent;
 
 		// set locale according to template:
@@ -168,14 +168,14 @@
 	// (static)
 	function exists($name) {
 		$r = sql_query('select * FROM '.sql_table('template_desc').' WHERE tdname="'.addslashes($name).'"');
-		return (mysql_num_rows($r) != 0);
+		return (sql_num_rows($r) != 0);
 	}
 
 	// returns true if there is a template with the given ID
 	// (static)
 	function existsID($id) {
 		$r = sql_query('select * FROM '.sql_table('template_desc').' WHERE tdnumber='.intval($id));
-		return (mysql_num_rows($r) != 0);
+		return (sql_num_rows($r) != 0);
 	}
 
 	// (static)
@@ -187,7 +187,7 @@
 	function getDesc($id) {
 		$query = 'SELECT tddesc FROM '.sql_table('template_desc').' WHERE tdnumber='. intval($id);
 		$res = sql_query($query);
-		$obj = mysql_fetch_object($res);
+		$obj = sql_fetch_object($res);
 		return $obj->tddesc;
 	}
 
diff -x .svn -aruN 3.41.src/nucleus/libs/vars4.0.6.php 3.51.src/nucleus/libs/vars4.0.6.php
--- 3.41.src/nucleus/libs/vars4.0.6.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/vars4.0.6.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -12,8 +12,8 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: vars4.0.6.php 1153 2007-05-20 23:18:22Z kaigreve $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: vars4.0.6.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 /**
diff -x .svn -aruN 3.41.src/nucleus/libs/vars4.1.0.php 3.51.src/nucleus/libs/vars4.1.0.php
--- 3.41.src/nucleus/libs/vars4.1.0.php	2009-03-15 22:31:32.000000000 -0500
+++ 3.51.src/nucleus/libs/vars4.1.0.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -12,8 +12,8 @@
  */
 /**
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: vars4.1.0.php 1153 2007-05-20 23:18:22Z kaigreve $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: vars4.1.0.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 function getVar($name) {
diff -x .svn -aruN 3.41.src/nucleus/libs/xmlrpc.inc.php 3.51.src/nucleus/libs/xmlrpc.inc.php
--- 3.41.src/nucleus/libs/xmlrpc.inc.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/libs/xmlrpc.inc.php	2009-11-01 14:53:58.000000000 -0600
@@ -2,7 +2,7 @@
 // by Edd Dumbill (C) 1999-2002
 // <edd@usefulinc.com>
 // $Original: xmlrpc.inc,v 1.158 2007/03/01 21:21:02 ggiunta Exp $
-// $Id: xmlrpc.inc.php 1199 2007-09-07 07:03:41Z kimitake $
+// $Id: xmlrpc.inc.php 1396 2009-07-28 20:19:52Z ftruscot $
 
 
 // Copyright (c) 1999,2000,2002 Edd Dumbill.
@@ -41,7 +41,9 @@
 	{
 		// For PHP 4 onward, XML functionality is always compiled-in on windows:
 		// no more need to dl-open it. It might have been compiled out on *nix...
-		if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN'))
+		//if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN'))
+		$phpver = phpversion();
+		if (!extension_loaded('xml') && version_compare($phpver,'5.3.0','<'))
 		{
 			dl('xml.so');
 		}
@@ -2271,7 +2273,8 @@
 					}
 				}
 				// be tolerant to line endings, and extra empty lines
-				$ar = split("\r?\n", trim(substr($data, 0, $pos)));
+				//$ar = split("\r?\n", trim(substr($data, 0, $pos))); //split() is deprecated
+				$ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos)));
 				while(list(,$line) = @each($ar))
 				{
 					// take care of multi-line headers and cookies
diff -x .svn -aruN 3.41.src/nucleus/media.php 3.51.src/nucleus/media.php
--- 3.41.src/nucleus/media.php	2009-03-15 22:31:36.000000000 -0500
+++ 3.51.src/nucleus/media.php	2009-11-01 14:54:08.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -20,8 +20,8 @@
  *     passed through to the add-item form (linkto, popupimg or inline img)
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: media.php 1287 2008-12-12 18:50:10Z ftruscot $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: media.php 1390 2009-07-19 02:41:50Z ftruscot $
  *
  */
 
@@ -46,8 +46,8 @@
 
 // check if member is on at least one teamlist
 $query = 'SELECT * FROM ' . sql_table('team'). ' WHERE tmember=' . $member->getID();
-$teams = mysql_query($query);
-if (mysql_num_rows($teams) == 0)
+$teams = sql_query($query);
+if (sql_num_rows($teams) == 0 && !$member->isAdmin())
 	media_doError(_ERROR_DISALLOWEDUPLOAD);
 
 // get action
diff -x .svn -aruN 3.41.src/nucleus/plugins/NP_Ping.php 3.51.src/nucleus/plugins/NP_Ping.php
--- 3.41.src/nucleus/plugins/NP_Ping.php	2009-03-15 22:31:22.000000000 -0500
+++ 3.51.src/nucleus/plugins/NP_Ping.php	2009-11-01 14:53:30.000000000 -0600
@@ -1,275 +1,383 @@
-<?
-/*
-  Note: based on NP_PingPong, adapt for the new ping mechanism
-
-  History
-    v1.0 - Initial version
-    v1.1 - Add JustPosted event support
-    v1.2 - JustPosted event handling in background
-    v1.3 - pinged variable support
-    v1.4 - language file support
-    v1.5 - remove arg1 in exec() call
+<?php
+/**
+ *
+ * Send weblog updates ping
+ *     plugin for NucleusCMS(version 3.30 or lator)
+ *     Note: based on NP_PingPong, adapt for the new ping mechanism
+ * PHP versions 4 and 5
+ *
+ * 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.
+ * (see nucleus/documentation/index.html#license for more info)
+ *
+ * @author    admun (Edmond Hui)
+ * @license   http://www.gnu.org/licenses/gpl.txt  GNU GENERAL PUBLIC LICENSE Version 2, June 1991
+ * @version   1.8
+ * @link      http://edmondhui.homeip.net/nudn
+ * $id$
+ * History
+ *   v1.0 - Initial version
+ *   v1.1 - Add JustPosted event support
+ *   v1.2 - JustPosted event handling in background
+ *   v1.3 - pinged variable support
+ *   v1.4 - language file support
+ *   v1.5 - remove arg1 in exec() call
+ *   v1.6 - move send update ping override option to plugin
+ *   v1.7 - move send ping option from blog to plugin/blog level
+ *        - remove ping override option
+ *   v1.8 - remove sendPing event handle, switch to use PostAddItem and PostUpdateItem event for new item ping
  */
 
-class NP_Ping extends NucleusPlugin {
+class NP_Ping extends NucleusPlugin
+{
 
-	function getName() { return 'Ping'; }
+    function getName()
+    {
+        return 'Ping';
+    }
+
+    function getAuthor()
+    {
+        return 'admun (Edmond Hui)';
+    }
+
+    function getURL()
+    {
+        return 'http://edmondhui.homeip.net/nudn';
+    }
+
+    function getVersion()
+    {
+        return '1.8';
+    }
+
+    function getMinNucleusVersion()
+    {
+        return '330';
+    }
+
+    function getDescription()
+    {
+        return _PING_DESC;
+    }
+
+    function supportsFeature($what)
+    {
+        switch($what) {
+            case 'SqlTablePrefix':
+                return 1;
+            default:
+                return 0;
+        }
+    }
+
+    function init()
+    {
+//        $language = ereg_replace( '[\\|/]', '', getLanguageName());
+        $language = preg_replace( '@\\|/@', '', getLanguageName());
+        if (file_exists($this->getDirectory()  . $language . '.php')) {
+            include_once($this->getDirectory() . $language . '.php');
+        } else {
+            include_once($this->getDirectory() . 'english.php');
+        }
+    }
+
+    function install()
+    {
+        // Default, http://pingomatic.com
+        $this->createOption('pingpong_pingomatic',  _PING_PINGOM,    'yesno', 'yes');
+        // http://weblogs.com
+        $this->createOption('pingpong_weblogs',     _PING_WEBLOGS,   'yesno', 'no');
+        // http://www.technorati.com
+        $this->createOption('pingpong_technorati',  _PING_TECHNOR,   'yesno', 'no');
+        // http://www.blogrolling.com
+        $this->createOption('pingpong_blogrolling', _PING_BLOGR,     'yesno', 'no');
+        // http://blo.gs
+        $this->createOption('pingpong_blogs',       _PING_BLOGS,     'yesno', 'no');
+        // http://weblogues.com/
+        $this->createOption('pingpong_weblogues',   _PING_WEBLOGUES, 'yesno', 'no');
+        // http://blogg.de
+        $this->createOption('pingpong_bloggde',     _PING_BLOGGDE,   'yesno', 'no');
+
+        // Pinging on background
+        $this->createOption('ping_background',      _PING_BG,        'yesno', 'no');
+
+        $this->createBlogOption('ping_sendping',    _PING_SENDPING,  'yesno', 'yes');
+    }
+
+    function getEventList()
+    {
+        return array(
+            'JustPosted',
+            'PostAddItem',
+            'PostUpdateItem'
+        );
+    }
+
+    function event_JustPosted($data)
+    {
+        global $DIR_PLUGINS, $DIR_NUCLEUS;
+
+        // exit is another plugin already send ping
+        if ($data['pinged'] == true) {
+            return;
+        }
+
+        $bid = intval($data['blogid']);
+        if ($this->getBlogOption($bid, 'ping_sendping') == "yes") {
+            if ($this->getOption('ping_background') == "yes") {
+                exec("php $DIR_PLUGINS/ping/ping.php " . $data['blogid'] . " &");
+            } else {
+                $this->sendPings($data['blogid']);
+            }
+        }
+        // mark the ping has been sent
+        $data['pinged'] = true;
+    }
+
+    function event_PostAddItem($data)
+    {
+//        global $manager;
+//        $blogId =  getBlogIDFromItemID($data['itemid']);
+//        $item   =& ITEM::getitem($data['itemid'], 0, 0); // draft or future post return 0
+//        if ($item != 0) {
+//            if ($this->getBlogOption($blogId, 'ping_sendping') == "yes") {
+//                $this->sendPings(array('blogid' => $blogId));
+//            }
+//        }
+        $this->_sendPingCheck($data['itemid']);
+    }
+
+    function event_PostUpdateItem($data)
+    {
+//        global $manager;
+//        $blogId =  getBlogIDFromItemID($data['itemid']);
+//        $blog   =& $manager->getBlog($blogId);    // <- why?
+//        $item   =& ITEM::getitem($data['itemid'], 0, 0); // draft or future post return 0
+//        if ($item != 0) {
+//            if ($this->getBlogOption($blogId,'ping_sendping') == "yes" ) {
+//                $this->sendPings(array('blogid' => $blogId));
+//            }
+//        }
+        $this->_sendPingCheck($data['itemid']);
+    }
+
+    function _sendPingCheck($itemid)
+    {
+        $iid  = intval($itemid);
+        $item = ITEM::getitem($iid, 0, 0); // draft or future post return 0
+        if ($item) {
+            $bid = intval(getBlogIDFromItemID($iid));
+            if ($this->getBlogOption($bid, 'ping_sendping') == "yes" ) {
+                $this->sendPings(array('blogid' => $bid));
+            }
+        }
+    }
+
+    function sendPings($data) {
+
+        if (!class_exists('xmlrpcmsg')) {
+            global $DIR_LIBS;
+            include($DIR_LIBS . 'xmlrpc.inc.php');
+        }
+        $this->myBlogId = $data['blogid'];
+
+        $ping_result = '';
+
+        if ($this->getOption('pingpong_pingomatic') == 'yes') {
+            $ping_result .= _PINGING . "Ping-o-matic:\n";
+            $ping_result .= $this->pingPingomatic();
+            $ping_result .= " | ";
+        }
 
-	function getAuthor() { return 'admun (Edmond Hui)'; }
-	function getURL()    { return 'http://edmondhui.homeip.net/nudn'; }
-	function getVersion() { return '1.5'; }
-
-	function getMinNucleusVersion() { return '330'; }
-
-	function getDescription() {
-		return _PING_DESC;
-	}
-
-	function supportsFeature($what) {
-		switch($what) {
-			case 'SqlTablePrefix':
-				return 1;
-			default:
-				return 0;
-		}
-	}
-
-	function init()
-	{
-		$language = ereg_replace( '[\\|/]', '', getLanguageName());
-		if (file_exists($this->getDirectory()  . $language . '.php')) {
-			include_once($this->getDirectory() . $language . '.php');
-		}else {
-			include_once($this->getDirectory() . 'english.php');
-		}
-	}
-
-	function install() {
-		$this->createOption('pingpong_pingomatic',_PING_PINGOM,'yesno','yes');  // Default, http://pingomatic.com
-		$this->createOption('pingpong_weblogs',_PING_WEBLOGS,'yesno','no'); // http://weblogs.com
-		$this->createOption('pingpong_technorati',_PING_TECHNOR,'yesno','no'); // http://www.technorati.com
-		$this->createOption('pingpong_blogrolling',_PING_BLOGR,'yesno','no'); // http://www.blogrolling.com
-		$this->createOption('pingpong_blogs',_PING_BLOGS,'yesno','no'); // http://blo.gs
-		$this->createOption('pingpong_weblogues',_PING_WEBLOGUES,'yesno','no'); // http://weblogues.com/
-		$this->createOption('pingpong_bloggde',_PING_BLOGGDE,'yesno','no'); // http://blogg.de
-		$this->createOption('ping_background',_PING_BG,'yesno','yes');
-	}
-
-	function getEventList() {
-		return array('SendPing', 'JustPosted');
-	}
-
-	function event_JustPosted($data) {
-		global $DIR_PLUGINS, $DIR_NUCLEUS;
-
-		// exit is another plugin already send ping
-		if ($data['pinged'] == true) {
-			return;
-		}
-
-		if ($this->getOption('ping_background') == "yes") {
-			exec("php $DIR_PLUGINS/ping/ping.php " . $data['blogid'] . " &");
-		} else {
-			$this->sendPings($data['blogid']);
-
-        		ACTIONLOG::add(INFO, 'NP_Ping: Sending ping (from foreground)');
-		}
-
-		// mark the ping has been sent
-		$data['pinged'] = true;
-        }
-
-	function event_SendPing($data) {
-                $this->sendPings($data);
-	}
-
-        function sendPings($data) {
-		if (!class_exists('xmlrpcmsg')) {
-			global $DIR_LIBS;
-			include($DIR_LIBS . 'xmlrpc.inc.php');
-		}
-
-                $this->myBlogId = $data['blogid'];
-
-		if ($this->getOption('pingpong_pingomatic')=='yes') {
-			echo _PINGING . "Ping-o-matic:<br/>";
-			echo $this->pingPingomatic();
-			echo "<br/>";
-		}
-
-		if ($this->getOption('pingpong_weblogs')=='yes') { 
-			echo _PINGING . "Weblogs.com:<br/>";
-			echo $this->pingWeblogs();
-			echo "<br/>";
-		}
-
-		if ($this->getOption('pingpong_technorati')=='yes') {
-			echo _PINGING . "Technorati:<br/>";
-			echo $this->pingTechnorati();
-			echo "<br/>";
-		}
-
-		if ($this->getOption('pingpong_blogrolling')=='yes') {
-			echo _PINGING . "Blogrolling.com:<br/>";
-			echo $this->pingBlogRollingDotCom();
-			echo "<br/>";
-		}
-
-		if ($this->getOption('pingpong_blogs')=='yes') {
-			echo _PINGING . "Blog.gs:<br/>";
-			echo $this->pingBloGs();
-			echo "<br/>";
-		}
-
-		if ($this->getOption('pingpong_weblogues')=='yes') {
-			echo _PINGING . "Weblogues.com:<br/>";
-			echo $this->pingWebloguesDotCom();
-			echo "<br/>";
-		}
-
-		if ($this->getOption('pingpong_bloggde')=='yes') {
-			echo _PINGING . "Blog.de:<br/>";
-			echo $this->pingBloggDe();
-			echo "<br/>";
-		}
-        }
-
-	function pingPingomatic() {
-		$b = new BLOG($this->myBlogId);
-		$message = new xmlrpcmsg(
-					'weblogUpdates.ping', array(
-					new xmlrpcval($b->getName(),'string'),
-					new xmlrpcval($b->getURL(),'string')
-					));
-
-		$c = new xmlrpc_client('/', 'rpc.pingomatic.com', 80);
-		//$c->setDebug(1);
-
-		$r = $c->send($message,30); // 30 seconds timeout...
-		return $this->processPingResult($r);
-	}
-
-	function pingWeblogs() {
-		$b = new BLOG($this->myBlogId);
-		$message = new xmlrpcmsg(
-					'weblogupdates.ping',array(
-					new xmlrpcval($b->getName(),'string'),
-					new xmlrpcval($b->getUrl(),'string')
-					));
-
-		$c = new xmlrpc_client('/rpc2', 'rpc.weblogs.com', 80);
-		//$c->setdebug(1);
-
-		$r = $c->send($message,30); // 30 seconds timeout...
-		return $this->processPingResult($r);
-	} 
-
-	function pingTechnorati() {
-		$b = new BLOG($this->myBlogId);
-		$message = new xmlrpcmsg(
-					'weblogUpdates.ping', array(
-					new xmlrpcval($b->getName(),'string'),
-					new xmlrpcval($b->getURL(),'string')
-					));
-
-		$c = new xmlrpc_client('/rpc/ping/', 'rpc.technorati.com', 80);
-		//$c->setDebug(1);
-
-		$r = $c->send($message,30); // 30 seconds timeout...
-		return $this->processPingResult($r);
-	}
-
-	function pingBlogRollingDotCom() {
-		$b = new BLOG($this->myBlogId);         
-		$message = new xmlrpcmsg(
-					'weblogUpdates.ping',
-					array(
-					new xmlrpcval($b->getName(),'string'), // your blog title
-					new xmlrpcval($b->getURL(),'string')  // your blog url
-					));
-
-		$c = new xmlrpc_client('/pinger/', 'rpc.blogrolling.com', 80);
-		//$c->setDebug(1);
-
-		$r = $c->send($message,30); // 30 seconds timeout...     
-		return $this->processPingResult($r);
-	} 
-
-	function pingBloGs() {
-		$b = new BLOG($this->myBlogId);
-		$message = new xmlrpcmsg(
-					'weblogUpdates.extendedPing', array(
-					new xmlrpcval($b->getName(),'string'),
-					new xmlrpcval($b->getURL(),'string')
-					));
-
-		$c = new xmlrpc_client('/', 'ping.blo.gs', 80);
-		//$c->setDebug(1);
-
-		$r = $c->send($message,30); // 30 seconds timeout...    
-		return $this->processPingResult($r);
-	} 
-
-	function pingWebloguesDotCom() {
-		$b = new BLOG($this->myBlogId);
-		$message = new xmlrpcmsg(
-					'weblogUpdates.extendedPing',
-					array(
-					new xmlrpcval($b->getName(),'string'), // your blog title
-					new xmlrpcval($b->getURL(),'string')  // your blog url
-					));
-
-		$c = new xmlrpc_client('/RPC/', 'www.weblogues.com', 80);
-		//$c->setDebug(1);
-
-		$r = $c->send($message,30); // 30 seconds timeout...     
-		return $this->processPingResult($r);
-	}
-
-	function pingBloggDe() {
-		$b = new BLOG($this->myBlogId);
-		$message = new xmlrpcmsg(
-					'bloggUpdates.ping', array(
-					new xmlrpcval($b->getName(),'string'),
-					new xmlrpcval($b->getURL(),'string')
-					));
-
-		$c = new xmlrpc_client('/', 'xmlrpc.blogg.de', 80);
-		//$c->setDebug(1);
-
-		$r = $c->send($message,30); // 30 seconds timeout...   
-		return $this->processPingResult($r);
-	} 
-
-	function processPingResult($r) {
-		global $php_errormsg;
-
-		if (($r == 0) && ($r->errno || $r->errstring)) {
-			return _PING_ERROR . " " . $r->errno . ' : ' . $r->errstring;
-		} elseif (($r == 0) && ($php_errormsg)) {
-			return _PING_PHP_ERROR . $php_errormsg;
-		} elseif ($r == 0) {
-			return _PING_PHP_PING_ERROR;
-		} elseif ($r->faultCode() != 0) {
-			return _PING_ERROR . ': ' . $r->faultString();
-		} else {
-			$r = $r->value();	// get response struct
-
-			// get values
-			$flerror = $r->structmem('flerror');
-			$flerror = $flerror->scalarval();
-
-			$message = $r->structmem('message');
-			$message = $message->scalarval();
-
-			if ($flerror != 0) {
-      				return _PING_ERROR . ' (flerror=1): ' . $message;
-			}
-			else {
-				return _PING_SUCCESS . ': ' . $message;
-			}
-		}
-	}
+        if ($this->getOption('pingpong_weblogs') == 'yes') { 
+            $ping_result .= _PINGING . "Weblogs.com:\n";
+            $ping_result .= $this->pingWeblogs();
+            $ping_result .= " | ";
+        }
+
+        if ($this->getOption('pingpong_technorati') == 'yes') {
+            $ping_result .= _PINGING . "Technorati:\n";
+            $ping_result .= $this->pingTechnorati();
+            $ping_result .= " | ";
+        }
+
+        if ($this->getOption('pingpong_blogrolling') == 'yes') {
+            $ping_result .= _PINGING . "Blogrolling.com:\n";
+            $ping_result .= $this->pingBlogRollingDotCom();
+            $ping_result .= " | ";
+        }
+
+        if ($this->getOption('pingpong_blogs') == 'yes') {
+            $ping_result .= _PINGING . "Blog.gs:\n";
+            $ping_result .= $this->pingBloGs();
+            $ping_result .= " | ";
+        }
+
+        if ($this->getOption('pingpong_weblogues') == 'yes') {
+            $ping_result .= _PINGING . "Weblogues.com:\n";
+            $ping_result .= $this->pingWebloguesDotCom();
+            $ping_result .= " | ";
+        }
+
+        if ($this->getOption('pingpong_bloggde') == 'yes') {
+            $ping_result .= _PINGING . "Blog.de:\n";
+            $ping_result .= $this->pingBloggDe();
+            $ping_result .= " | ";
+        }
+
+        ACTIONLOG::add(INFO, $ping_result);
+    }
+
+    function pingPingomatic() {
+        $b = new BLOG($this->myBlogId);
+        $message = new xmlrpcmsg(
+                            'weblogUpdates.ping',
+                            array(
+                                new xmlrpcval($b->getName(), 'string'),
+                                new xmlrpcval($b->getURL(), 'string')
+                            )
+                   );
+
+        $c = new xmlrpc_client('/', 'rpc.pingomatic.com', 80);
+        //$c->setDebug(1);
+
+        $r = $c->send($message,30); // 30 seconds timeout...
+        return $this->processPingResult($r);
+    }
+
+    function pingWeblogs() {
+        $b = new BLOG($this->myBlogId);
+        $message = new xmlrpcmsg(
+                            'weblogupdates.ping',
+                            array(
+                                new xmlrpcval($b->getName(), 'string'),
+                                new xmlrpcval($b->getURL(), 'string')
+                            )
+                   );
+
+        $c = new xmlrpc_client('/rpc2', 'rpc.weblogs.com', 80);
+        //$c->setdebug(1);
+
+        $r = $c->send($message,30); // 30 seconds timeout...
+        return $this->processPingResult($r);
+    } 
+
+    function pingTechnorati() {
+        $b = new BLOG($this->myBlogId);
+        $message = new xmlrpcmsg(
+                            'weblogUpdates.ping',
+                            array(
+                                new xmlrpcval($b->getName(),'string'),
+                                new xmlrpcval($b->getURL(),'string')
+                            )
+                   );
+
+        $c = new xmlrpc_client('/rpc/ping/', 'rpc.technorati.com', 80);
+        //$c->setDebug(1);
+
+        $r = $c->send($message,30); // 30 seconds timeout...
+        return $this->processPingResult($r);
+    }
+
+    function pingBlogRollingDotCom() {
+        $b = new BLOG($this->myBlogId);
+        $message = new xmlrpcmsg(
+                            'weblogUpdates.ping',
+                            array(
+                                new xmlrpcval($b->getName(),'string'),
+                                new xmlrpcval($b->getURL(),'string')
+                            )
+                   );
+
+        $c = new xmlrpc_client('/pinger/', 'rpc.blogrolling.com', 80);
+        //$c->setDebug(1);
+
+        $r = $c->send($message,30); // 30 seconds timeout...     
+        return $this->processPingResult($r);
+    } 
+
+    function pingBloGs() {
+        $b = new BLOG($this->myBlogId);
+        $message = new xmlrpcmsg(
+                            'weblogUpdates.extendedPing',
+                            array(
+                                new xmlrpcval($b->getName(),'string'),
+                                new xmlrpcval($b->getURL(),'string')
+                            )
+                   );
+
+        $c = new xmlrpc_client('/', 'ping.blo.gs', 80);
+        //$c->setDebug(1);
+
+        $r = $c->send($message,30); // 30 seconds timeout...    
+        return $this->processPingResult($r);
+    } 
+
+    function pingWebloguesDotCom() {
+        $b = new BLOG($this->myBlogId);
+        $message = new xmlrpcmsg(
+                            'weblogUpdates.extendedPing',
+                            array(
+                                new xmlrpcval($b->getName(),'string'),
+                                new xmlrpcval($b->getURL(),'string')
+                            )
+                   );
+
+        $c = new xmlrpc_client('/RPC/', 'www.weblogues.com', 80);
+        //$c->setDebug(1);
+
+        $r = $c->send($message,30); // 30 seconds timeout...     
+        return $this->processPingResult($r);
+    }
+
+    function pingBloggDe() {
+        $b = new BLOG($this->myBlogId);
+        $message = new xmlrpcmsg(
+                            'bloggUpdates.ping',
+                            array(
+                                new xmlrpcval($b->getName(),'string'),
+                                new xmlrpcval($b->getURL(),'string')
+                            )
+                   );
+
+        $c = new xmlrpc_client('/', 'xmlrpc.blogg.de', 80);
+        //$c->setDebug(1);
+
+        $r = $c->send($message,30); // 30 seconds timeout...   
+        return $this->processPingResult($r);
+    } 
+
+    function processPingResult($r) {
+        global $php_errormsg;
+
+        if (($r == 0) && ($r->errno || $r->errstring)) {
+            return _PING_ERROR . " " . $r->errno . ' : ' . $r->errstring;
+        } elseif (($r == 0) && ($php_errormsg)) {
+            return _PING_PHP_ERROR . $php_errormsg;
+        } elseif ($r == 0) {
+            return _PING_PHP_PING_ERROR;
+        } elseif ($r->faultCode() != 0) {
+            return _PING_ERROR . ': ' . $r->faultString();
+        } else {
+            $r = $r->value();   // get response struct
+
+            // get values
+            $flerror = $r->structmem('flerror');
+            $flerror = $flerror->scalarval();
+
+            $message = $r->structmem('message');
+            $message = $message->scalarval();
+
+            if ($flerror != 0) {
+                return _PING_ERROR . ' (flerror=1): ' . $message;
+            } else {
+                return _PING_SUCCESS . ': ' . $message;
+            }
+        }
+    }
 }
 
-?>
+?>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/plugins/NP_SecurityEnforcer.php 3.51.src/nucleus/plugins/NP_SecurityEnforcer.php
--- 3.41.src/nucleus/plugins/NP_SecurityEnforcer.php	1969-12-31 18:00:00.000000000 -0600
+++ 3.51.src/nucleus/plugins/NP_SecurityEnforcer.php	2009-11-01 14:53:30.000000000 -0600
@@ -0,0 +1,211 @@
+<?php
+/*
+License:
+This software is published under the same license as NucleusCMS, namely
+the GNU General Public License. See http://www.gnu.org/licenses/gpl.html for
+details about the conditions of this license.
+
+In general, 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.
+*/
+class NP_SecurityEnforcer extends NucleusPlugin {
+
+	function getName() { return 'SecurityEnforcer'; }
+
+	function getAuthor()  {	return 'Frank Truscott';	}
+
+	function getURL()   { return 'http://revcetera.com/ftruscot';	}
+
+	function getVersion() {	return '1.01'; }
+
+	function getDescription() {
+		return _SECURITYENFORCER_DESCRIPTION;
+	}
+	
+	function getMinNucleusVersion() { return 350; }
+
+	function supportsFeature($what)	{
+		switch($what) {
+		case 'SqlTablePrefix':
+			return 1;
+		/*case 'HelpPage':
+			return 1;*/
+		default:
+			return 0;
+		}
+	}
+
+	function getTableList() { return array(sql_table('plug_securityenforcer')); }
+	function getEventList() { return array('QuickMenu','PrePasswordSet','CustomLogin','LoginSuccess','LoginFailed'); }
+	
+	function install() {
+		global $CONF;
+
+// Need to make some options
+		$this->createOption('quickmenu', _SECURITYENFORCER_OPT_QUICKMENU, 'yesno', 'yes');
+		$this->createOption('del_uninstall_data', _SECURITYENFORCER_OPT_DEL_UNINSTALL_DATA, 'yesno','no');
+		$this->createOption('enable_security', _SECURITYENFORCER_OPT_ENABLE, 'yesno','yes');
+		$this->createOption('pwd_min_length', _SECURITYENFORCER_OPT_PWD_MIN_LENGTH, 'text','8');
+		$this->createOption('pwd_complexity', _SECURITYENFORCER_OPT_PWD_COMPLEXITY, 'select','0',_SECURITYENFORCER_OPT_SELECT_OFF_COMP.'|0|'._SECURITYENFORCER_OPT_SELECT_ONE_COMP.'|1|'._SECURITYENFORCER_OPT_SELECT_TWO_COMP.'|2|'._SECURITYENFORCER_OPT_SELECT_THREE_COMP.'|3|'._SECURITYENFORCER_OPT_SELECT_FOUR_COMP.'|4');
+		$this->createOption('max_failed_login', _SECURITYENFORCER_OPT_MAX_FAILED_LOGIN, 'text', '5');
+		$this->createOption('login_lockout', _SECURITYENFORCER_OPT_LOGIN_LOCKOUT, 'text', '15');
+		
+// create needed tables
+		sql_query("CREATE TABLE IF NOT EXISTS ". sql_table('plug_securityenforcer').
+					" ( 
+					  `login` varchar(255),
+					  `fails` int(11) NOT NULL default '0',					  
+					  `lastfail` bigint NOT NULL default '0',
+					  KEY `login` (`login`)) TYPE=MyISAM");
+
+	}
+	
+	function unInstall() {
+		// if requested, delete the data table
+		if ($this->getOption('del_uninstall_data') == 'yes')	{
+			sql_query('DROP TABLE '.sql_table('plug_securityenforcer'));
+		}
+	}
+	
+	function init() {
+		// include language file for this plugin
+//        $language = ereg_replace( '[\\|/]', '', getLanguageName());
+        $language = preg_replace( '@\\|/@', '', getLanguageName());
+        if (file_exists($this->getDirectory().$language.'.php'))
+            include_once($this->getDirectory().$language.'.php');
+        else
+            include_once($this->getDirectory().'english.php');
+			
+		$this->enable_security = $this->getOption('enable_security');
+		$this->pwd_min_length = intval($this->getOption('pwd_min_length'));
+		$this->pwd_complexity = intval($this->getOption('pwd_complexity'));
+		$this->max_failed_login = intval($this->getOption('max_failed_login'));
+		$this->login_lockout = intval($this->getOption('login_lockout'));
+	}
+	function hasAdminArea() { return 1; }
+
+	function event_QuickMenu(&$data) {
+    	// only show when option enabled
+		global $member;
+    	if ($this->getOption('quickmenu') != 'yes' || !$member->isAdmin()) return;
+    	global $member;
+    	if (!($member->isLoggedIn())) return;
+    	array_push($data['options'],
+      		array('title' => 'Security Enforcer',
+        	'url' => $this->getAdminURL(),
+        	'tooltip' => _SECURITYENFORCER_ADMIN_TOOLTIP));
+  	}
+	
+	function event_PrePasswordSet(&$data) {
+		//password, errormessage, valid
+		if ($this->enable_security == 'yes') {
+			if (!$this->_validate_passwd($data['password'],$this->pwd_min_length, $this->pwd_complexity)) {
+				$data['errormessage'] = _SECURITYENFORCER_INSUFFICIENT_COMPLEXITY;
+				$data['errormessage'] .= _SECURITYENFORCER_MIN_PWD_LENGTH . $this->pwd_min_length; 
+				$data['errormessage'] .= _SECURITYENFORCER_PWD_COMPLEXITY . $this->pwd_complexity . "<br /><br />\n"; 
+				$data['valid'] = false;
+			}
+		}
+	}
+	
+	function event_CustomLogin(&$data) {
+		//login,password,success,allowlocal
+		if ($this->enable_security == 'yes' && $this->max_failed_login > 0) {
+			global $_SERVER;
+			$login = $data['login'];
+			$ip = $_SERVER['REMOTE_ADDR'];
+			sql_query("DELETE FROM ".sql_table('plug_securityenforcer')." WHERE lastfail < ".(time() - ($this->login_lockout * 60)));
+			$query = "SELECT fails as result FROM ".sql_table('plug_securityenforcer')." ";
+			//$query .= "WHERE login='".addslashes($login)."'";
+			$query .= "WHERE login='".sql_real_escape_string($login)."'";
+			$flogin = quickQuery($query); 
+			$query = "SELECT fails as result FROM ".sql_table('plug_securityenforcer')." ";
+			//$query .= "WHERE login='".addslashes($ip)."'";
+			$query .= "WHERE login='".sql_real_escape_string($ip)."'";
+			$fip = quickQuery($query); 
+			if ($flogin >= $this->max_failed_login || $fip >= $this->max_failed_login) {
+				$data['success'] = 0;
+				$data['allowlocal'] = 0;
+				//ACTIONLOG::add(INFO, 'login disallowed by NP_SecurityEnforcer. login: '.htmlentities($login).', ip: '.htmlentities($ip) );
+				$info = sprintf(_SECURITYENFORCER_LOGIN_DISALLOWED, htmlspecialchars($login), htmlspecialchars($ip));
+                ACTIONLOG::add(INFO, $info);
+			}
+		}
+	}
+	
+	function event_LoginSuccess(&$data) {
+		//member(obj),username
+		if ($this->enable_security == 'yes' && $this->max_failed_login > 0) {
+			global $_SERVER;
+			$login = $data['username'];
+			$ip = $_SERVER['REMOTE_ADDR'];
+			//sql_query("DELETE FROM ".sql_table('plug_securityenforcer')." WHERE login='".addslashes($login)."'");
+			sql_query("DELETE FROM ".sql_table('plug_securityenforcer')." WHERE login='".sql_real_escape_string($login)."'");
+			//sql_query("DELETE FROM ".sql_table('plug_securityenforcer')." WHERE login='".addslashes($ip)."'");			
+			sql_query("DELETE FROM ".sql_table('plug_securityenforcer')." WHERE login='".sql_real_escape_string($ip)."'");
+		}
+	}
+	
+	function event_LoginFailed(&$data) {
+		//username
+		if ($this->enable_security == 'yes' && $this->max_failed_login > 0) {
+			global $_SERVER;
+			$login = $data['username'];
+			$ip = $_SERVER['REMOTE_ADDR'];
+			//sql_table('plug_securityenforcer')
+			//$lres = sql_query("SELECT * FROM ".sql_table('plug_securityenforcer')." WHERE login='".addslashes($login)."'");
+			$lres = sql_query("SELECT * FROM ".sql_table('plug_securityenforcer')." WHERE login='".sql_real_escape_string($login)."'");
+			if (sql_num_rows($lres)) {
+				//sql_query("UPDATE ".sql_table('plug_securityenforcer')." SET fails=fails+1, lastfail=".time()." WHERE login='".addslashes($login)."'");
+				sql_query("UPDATE ".sql_table('plug_securityenforcer')." SET fails=fails+1, lastfail=".time()." WHERE login='".sql_real_escape_string($login)."'");
+			}
+			else {
+				//sql_query("INSERT INTO ".sql_table('plug_securityenforcer')." (login,fails,lastfail) VALUES ('".addslashes($login)."',1,".time().")");
+				sql_query("INSERT INTO ".sql_table('plug_securityenforcer')." (login,fails,lastfail) VALUES ('".sql_real_escape_string($login)."',1,".time().")");
+			}
+			//$lres = sql_query("SELECT * FROM ".sql_table('plug_securityenforcer')." WHERE login='".addslashes($ip)."'");
+			$lres = sql_query("SELECT * FROM ".sql_table('plug_securityenforcer')." WHERE login='".sql_real_escape_string($ip)."'");
+			if (sql_num_rows($lres)) {
+				//sql_query("UPDATE ".sql_table('plug_securityenforcer')." SET fails=fails+1, lastfail=".time()." WHERE login='".addslashes($ip)."'");
+				sql_query("UPDATE ".sql_table('plug_securityenforcer')." SET fails=fails+1, lastfail=".time()." WHERE login='".sql_real_escape_string($ip)."'");
+			}
+			else {
+				//sql_query("INSERT INTO ".sql_table('plug_securityenforcer')." (login,fails,lastfail) VALUES ('".addslashes($ip)."',1,".time().")");
+				sql_query("INSERT INTO ".sql_table('plug_securityenforcer')." (login,fails,lastfail) VALUES ('".sql_real_escape_string($ip)."',1,".time().")");
+			}
+		}		
+	}
+	
+	/* Helper Functions */
+	
+	function _validate_passwd($passwd,$minlength = 6,$complexity = 0) {
+		$minlength = intval($minlength);
+		$complexity = intval($complexity);
+		
+		if ($minlength < 6 ) $minlength = 6;
+		if (strlen($passwd) < $minlength) return false;
+
+		if ($complexity > 4) $complexity = 4;
+		$ucchars = "[A-Z]";
+		$lcchars = "[a-z]";
+		$numchars = "[0-9]";
+		$ochars = "[-~!@#$%^&*()_+=,.<>?:;|]";
+		$chartypes = array($ucchars, $lcchars, $numchars, $ochars);
+		$tot = array(0,0,0,0);
+		$i = 0;
+		foreach ($chartypes as $value) {
+			$tot[$i] = preg_match("/".$value."/", $passwd);
+			$i = $i + 1;
+		}
+
+		if (array_sum($tot) >= $complexity) return true;
+		else return false;
+	}
+}
+?>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/plugins/NP_Text.php 3.51.src/nucleus/plugins/NP_Text.php
--- 3.41.src/nucleus/plugins/NP_Text.php	1969-12-31 18:00:00.000000000 -0600
+++ 3.51.src/nucleus/plugins/NP_Text.php	2009-11-01 14:53:30.000000000 -0600
@@ -0,0 +1,132 @@
+<?php
+ 
+class NP_Text extends NucleusPlugin {
+	
+	var $incModePref = array();
+	var $errorLogged = false;
+	var $constantPrefix = "SL_";
+ 
+	function getEventList() { return array('PreSkinParse'); }
+	function getName() { return 'Text'; }
+	function getAuthor() { return 'Armon Toubman'; }
+	function getURL() { return 'http://forum.nucleuscms.org/viewtopic.php?t=14904'; }
+	function getVersion() { return '0.53'; }
+	function getDescription() {
+		return 'Display constants from language files: <%Text(CONSTANT)%>';
+	}
+	function supportsFeature($feature) {
+        switch($feature) {
+            case 'SqlTablePrefix': return 1;
+            default: return 0;
+        }
+	} 
+	function install() {}
+	function uninstall() {}
+	function init() {
+		$this->incModePref = $this->skin_incmodepref();
+	}
+	
+	function event_PreSkinParse() {
+		global $member;
+		if( !$member->isLoggedIn() and isset($_GET['lang']) ) {
+			setcookie('NP_Text', getVar('lang'), time()+60*60*24*90); // 3 months
+		}
+	}
+	 
+	function doSkinVar($skinType, $constant) {
+		global $member, $CONF;
+		
+		$language = getLanguageName();
+		$getLanguage = isset($_GET['lang']) ? getVar('lang') : false;
+		$cookieLanguage = isset($_COOKIE['NP_Text']) ? cookieVar('NP_Text') : false;
+		
+//		if( !$member->isLoggedIn() ) {
+			if( $getLanguage ) {
+				$this->use_lang($getLanguage, $constant);
+			}
+			elseif( $cookieLanguage ) {
+				$this->use_lang($cookieLanguage, $constant);
+			}
+			else {
+				$this->use_lang($language, $constant);
+			}
+//		}
+//		else {
+//			$this->use_lang($language, $constant);
+//		}
+		
+	}
+	
+	function doTemplateVar(&$item, $constant) {
+		global $member, $CONF;
+		
+		$language = getLanguageName();
+		$getLanguage = isset($_GET['lang']) ? getVar('lang') : false;
+		$cookieLanguage = isset($_COOKIE['NP_Text']) ? cookieVar('NP_Text') : false;
+		
+//		if( !$member->isLoggedIn() ) {
+			if( $getLanguage ) {
+				$this->use_lang($getLanguage, $constant);
+			}
+			elseif( $cookieLanguage ) {
+				$this->use_lang($cookieLanguage, $constant);
+			}
+			else {
+				$this->use_lang($language, $constant);
+			}
+//		}
+//		else {
+//			$this->use_lang($language, $constant);
+//		}
+		
+	}
+	
+	function use_lang($language, $constant) {
+		global $DIR_SKINS;
+		
+		$filename = '';
+		
+		if( $this->incModePref[0] == "normal" ) {
+			$filename = $filename.$this->incModePref[1];
+			$filename = $filename."language/";
+			$filename = $filename.$language;
+			$filename = $filename.".php";
+		}
+		elseif( $this->incModePref[0] == "skindir" ) {
+			$filename = $filename.$DIR_SKINS;
+			$filename = $filename.$this->incModePref[1];
+			$filename = $filename."language/";
+			$filename = $filename.$language;
+			$filename = $filename.".php";
+		}
+		
+		if( is_file($filename) ) {
+			include($filename);
+		}
+		else {
+			addToLog(1, "NP_Text cannot find ".$filename);
+		}
+		
+		if( defined($this->constantPrefix.$constant) ) {
+			echo constant($this->constantPrefix.$constant);
+		}
+		else {
+			echo $this->constantPrefix.$constant;
+			if( is_file($filename) ) {
+				addToLog(1, "NP_Text cannot find definition for ".$this->constantPrefix.$constant." in ".$filename);
+			}
+		}			
+		
+	}
+	
+	function skin_incmodepref() {
+		global $currentSkinName;
+		$sql = "SELECT * FROM ".sql_table("skin_desc")." WHERE sdname = '".$currentSkinName."'";
+		$result = sql_query($sql);
+		$row = sql_fetch_array($result, MYSQL_ASSOC);
+		return array($row['sdincmode'], $row['sdincpref']);
+	}
+	
+}
+ 
+?>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/plugins/ping/english.php 3.51.src/nucleus/plugins/ping/english.php
--- 3.41.src/nucleus/plugins/ping/english.php	2009-03-15 22:31:22.000000000 -0500
+++ 3.51.src/nucleus/plugins/ping/english.php	2009-11-01 14:53:30.000000000 -0600
@@ -13,4 +13,7 @@
 	define('_PING_PHP_ERROR', 'PHP Error: ');
 	define('_PING_PHP_PING_ERROR', 'Error while trying to send ping. Sorry about that.');
 	define('_PING_SUCCESS', 'Success');
+	define('_UPDATEDPING_GOSENDPING', 'Send Update ping'); 
+	define('_PING_EXTRA_PLUGIN_OPTION', 'Blog Tracking Ping Service');
+	define('_PING_SENDPING', 'Notify ping service when new post is added?');
 ?>
diff -x .svn -aruN 3.41.src/nucleus/plugins/securityenforcer/english.php 3.51.src/nucleus/plugins/securityenforcer/english.php
--- 3.41.src/nucleus/plugins/securityenforcer/english.php	1969-12-31 18:00:00.000000000 -0600
+++ 3.51.src/nucleus/plugins/securityenforcer/english.php	2009-11-01 14:53:30.000000000 -0600
@@ -0,0 +1,43 @@
+<?php
+/** English language file for NP_SECURITYENFORCER Plugin
+*/
+
+// Plugin Options
+define('_SECURITYENFORCER_OPT_QUICKMENU',		   'Show Admin Area in quick menu?');
+define('_SECURITYENFORCER_OPT_DEL_UNINSTALL_DATA',	   'Delete NP_SecurityEnforcer data table on uninstall?');
+define('_SECURITYENFORCER_OPT_ENABLE',		   'Enable NP_SecurityEnforcer password and login checks?');
+define('_SECURITYENFORCER_OPT_PWD_MIN_LENGTH',		'Minimum Length in characters of a user password. Integer. 8 is the default and 6 the minimum value: ');
+define('_SECURITYENFORCER_OPT_PWD_COMPLEXITY',		'Password Complexity Check. (How many character types should be present out of a-z, A-Z, 0-9, punctuation marks?):');
+define('_SECURITYENFORCER_OPT_SELECT_OFF_COMP',		'Off');
+define('_SECURITYENFORCER_OPT_SELECT_ONE_COMP',		'One character type');
+define('_SECURITYENFORCER_OPT_SELECT_TWO_COMP',		'Two character types');
+define('_SECURITYENFORCER_OPT_SELECT_THREE_COMP',		'Three character types');
+define('_SECURITYENFORCER_OPT_SELECT_FOUR_COMP',		'Four character types');
+define('_SECURITYENFORCER_OPT_MAX_FAILED_LOGIN',		'How many failed login attempts before locking the user account?');
+define('_SECURITYENFORCER_OPT_LOGIN_LOCKOUT',		'After how many minutes should a locked account be released?');
+
+
+//QuickMenu
+define('_SECURITYENFORCER_ADMIN_TOOLTIP',		   'Manage NP_SecurityEnforcer Plugin');
+define('_SECURITYENFORCER_ADMIN_UNLOCKED',		   ' has been unlocked. Remember to unlock the corresponding IP or Login Name.');
+define('_SECURITYENFORCER_ADMIN_NONE_LOCKED',		   'No Records Found.');
+
+// ERRORS
+define('_SECURITYENFORCER_INSUFFICIENT_COMPLEXITY',		   'This password does not meet site requirements for length or complexity. <br />');
+define('_SECURITYENFORCER_MIN_PWD_LENGTH',		   '<br />Minimum password length: ');
+define('_SECURITYENFORCER_PWD_COMPLEXITY',		   '<br />Minimum number of character types ([a-z], [A-Z], [0-9], [-~!@#$%^&*()_+=,.<>?:;|]): ');
+
+//random words
+define('_SECURITYENFORCER_UNLOCK',		   'Unlock');
+define('_SECURITYENFORCER_ENTITY',		   'Entity');
+define('_SECURITYENFORCER_LOCKED_ENTITIES',		   'Currently Locked Entities');
+
+// Plugin desc
+define('_SECURITYENFORCER_DESCRIPTION',				'Enforces some password complexity rules and sets a maximum number of failed logins.');
+// Log info
+define('_SECURITYENFORCER_LOGIN_DISALLOWED',		'login disallowed by NP_SecurityEnforcer. login: %1$s, ip: %2$s');
+// QuickMenu title
+define('_SECURITYENFORCER_ADMIN_TITLE',				'Security Enforcer Administration');
+
+
+?>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/plugins/securityenforcer/index.php 3.51.src/nucleus/plugins/securityenforcer/index.php
--- 3.41.src/nucleus/plugins/securityenforcer/index.php	1969-12-31 18:00:00.000000000 -0600
+++ 3.51.src/nucleus/plugins/securityenforcer/index.php	2009-11-01 14:53:30.000000000 -0600
@@ -0,0 +1,84 @@
+<?php
+
+/*
+
+Admin area for NP_SecurityEnforcer
+
+*/
+
+	// if your 'plugin' directory is not in the default location,
+	// edit this variable to point to your site directory
+	// (where config.php is)
+	$strRel = '../../../';
+
+	include($strRel . 'config.php');
+	if (!$member->isAdmin())
+		doError('Insufficient Permissions.');
+		
+
+	include($DIR_LIBS . 'PLUGINADMIN.php');
+	// some functions
+	
+	function SE_unlockLogin($login) {
+		sql_query("DELETE FROM ".sql_table('plug_securityenforcer')." WHERE login='".addslashes($login)."'");
+	}
+	
+		
+	// checks
+	
+
+	
+	// create the admin area page
+	$oPluginAdmin = new PluginAdmin('SecurityEnforcer');
+	// add styles to the <HEAD>
+	$oPluginAdmin->start('');
+	
+	// if form to unlock is posted
+	if(postVar('action') == 'unlock') {
+		if (!$manager->checkTicket()) 
+			doError('Invalid Ticket');
+		$logins = postVar('unlock');
+		$message = '';
+		if(is_array($logins)) {
+			foreach ($logins as $entity) {
+				SE_unlockLogin($entity);
+				$message .= '<br />' . $entity . _SECURITYENFORCER_ADMIN_UNLOCKED;
+			}
+		}
+	}		
+	$plug =& $oPluginAdmin->plugin;
+
+	// page title
+	echo '<h2>'._SECURITYENFORCER_ADMIN_TITLE.'</h2>';
+	
+	// error output
+	if($message) { echo "<p><strong>"; echo $message; echo "</strong></p>"; }
+		
+	// generate table from all entries in the database
+	echo '<h3>'._SECURITYENFORCER_LOCKED_ENTITIES.'</h3>';
+	echo '<form action="' . $oPluginAdmin->plugin->getAdminURL() . '" method="POST">';
+	echo '<input type="hidden" name="action" value="unlock" />';
+	$manager->addTicketHidden();
+	echo '<table>';
+	echo '<tr><th>'._SECURITYENFORCER_ENTITY.'</th><th>'._SECURITYENFORCER_UNLOCK.'?</th></tr>';
+	echo '<tr><td colspan="2" class="submit"><input type="submit" value="'._SECURITYENFORCER_UNLOCK.'" /></td></tr>';
+	// do query to get all entries, loop
+	$result = sql_query("SELECT * FROM ".sql_table("plug_securityenforcer")." WHERE fails >= ".$plug->max_failed_login);
+	if(sql_num_rows($result)) {
+		while($row = sql_fetch_assoc($result)) {
+			echo '<tr>';
+  				echo '<td>'.htmlspecialchars($row['login']).'</td>';
+  				echo '<td><input type="checkbox" name="unlock[]" value="'.htmlspecialchars($row['login']).'" />'._SECURITYENFORCER_UNLOCK.'</td>';
+			echo '</tr>';
+		}
+	}
+	else {
+		echo '<tr><td colspan="2"><strong>'._SECURITYENFORCER_ADMIN_NONE_LOCKED.'</strong></td></tr>';
+	}
+	echo '<tr><td colspan="2" class="submit"><input type="submit" value="'._SECURITYENFORCER_UNLOCK.'" /></td></tr>';
+	echo '</table>';
+	echo '</form>';
+	
+	$oPluginAdmin->end();
+
+?>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/plugins/securityenforcer/japanese-euc.php 3.51.src/nucleus/plugins/securityenforcer/japanese-euc.php
--- 3.41.src/nucleus/plugins/securityenforcer/japanese-euc.php	1969-12-31 18:00:00.000000000 -0600
+++ 3.51.src/nucleus/plugins/securityenforcer/japanese-euc.php	2009-11-01 14:53:30.000000000 -0600
@@ -0,0 +1,44 @@
+<?php
+/** English language file for NP_SECURITYENFORCER Plugin
+*/
+
+// Plugin Options
+define('_SECURITYENFORCER_OPT_QUICKMENU',			'å˥塼ɽޤ');
+define('_SECURITYENFORCER_OPT_DEL_UNINSTALL_DATA',	'󥤥󥹥ȡ˥ǡ١Υơ֥ޤ');
+define('_SECURITYENFORCER_OPT_ENABLE',				'ѥɤΥåȥåΤȤSecurityEnforcerͭˤޤ');
+define('_SECURITYENFORCER_OPT_PWD_MIN_LENGTH',		'ѥɤκǾʸ(ǥեȤ8ʸ6ʸ̤ˤϻǤޤ');
+define('_SECURITYENFORCER_OPT_PWD_COMPLEXITY',		'ѥɶ٤Υå(a-z, A-Z, 0-9, 鲿ʸפ¸ߤ٤Ǥ?):');
+define('_SECURITYENFORCER_OPT_SELECT_OFF_COMP',		'Off');
+define('_SECURITYENFORCER_OPT_SELECT_ONE_COMP',		'ʸ');
+define('_SECURITYENFORCER_OPT_SELECT_TWO_COMP',		'ʸ');
+define('_SECURITYENFORCER_OPT_SELECT_THREE_COMP',	'ʸ');
+define('_SECURITYENFORCER_OPT_SELECT_FOUR_COMP',	'ͼʸ');
+define('_SECURITYENFORCER_OPT_MAX_FAILED_LOGIN',	'ܤΥԤǥȤåޤ');
+define('_SECURITYENFORCER_OPT_LOGIN_LOCKOUT',		'ȤåƤ鲿ʬǥåޤ');
+
+
+// QuickMenu
+define('_SECURITYENFORCER_ADMIN_TOOLTIP',			'SecurityEnforcerץ饰δ');
+define('_SECURITYENFORCER_ADMIN_UNLOCKED',			'åޤбɣХɥ쥹ޤϥ̾ΥåΤ˺ʤǤ');
+define('_SECURITYENFORCER_ADMIN_NONE_LOCKED',		'ʤ');
+
+// ERRORS
+define('_SECURITYENFORCER_INSUFFICIENT_COMPLEXITY',	'Ϥ줿ѥɤϡΥȤ׵ᤵʸޤ϶٤Ƥޤ<br />');
+define('_SECURITYENFORCER_MIN_PWD_LENGTH',			'<br />ѥɤûޤ');
+define('_SECURITYENFORCER_PWD_COMPLEXITY',			'<br />ʸפʤޤ([a-z], [A-Z], [0-9], [-~!@#$%^&*()_+=,.<>?:;|]): ');
+
+// random words
+define('_SECURITYENFORCER_UNLOCK',					'å');
+define('_SECURITYENFORCER_ENTITY',					'ƥƥ');
+define('_SECURITYENFORCER_LOCKED_ENTITIES',			'ߥåΥƥƥ');
+
+// Plugin desc
+define('_SECURITYENFORCER_DESCRIPTION',				'ѥɤκǾʸ䶯٤¡Բǽʤɤꤷޤ');
+
+// Log info
+define('_SECURITYENFORCER_LOGIN_DISALLOWED',		'⡼ȥۥȡ%2$sפΥ̾%1$sפΥSecurityEnforcerץ饰ˤäƵ䤵ޤ');
+
+// QuickMenu title
+define('_SECURITYENFORCER_ADMIN_TITLE',				'SecurityEnforcerץ饰δ');
+
+?>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/plugins/securityenforcer/japanese-utf8.php 3.51.src/nucleus/plugins/securityenforcer/japanese-utf8.php
--- 3.41.src/nucleus/plugins/securityenforcer/japanese-utf8.php	1969-12-31 18:00:00.000000000 -0600
+++ 3.51.src/nucleus/plugins/securityenforcer/japanese-utf8.php	2009-11-01 14:53:30.000000000 -0600
@@ -0,0 +1,44 @@
+<?php
+/** English language file for NP_SECURITYENFORCER Plugin
+*/
+
+// Plugin Options
+define('_SECURITYENFORCER_OPT_QUICKMENU',			'クイックメニューに表示しますか？');
+define('_SECURITYENFORCER_OPT_DEL_UNINSTALL_DATA',	'アンインストール時にデータベースのテーブルを削除しますか？');
+define('_SECURITYENFORCER_OPT_ENABLE',				'パスワードのチェックとログインチェックのときにSecurityEnforcerを有効にしますか？');
+define('_SECURITYENFORCER_OPT_PWD_MIN_LENGTH',		'パスワードの最小文字数(デフォルトは8文字。6文字未満には指定できません：');
+define('_SECURITYENFORCER_OPT_PWD_COMPLEXITY',		'パスワード強度のチェック(a-z, A-Z, 0-9, 句読点から何種類の文字タイプが存在するべきですか?):');
+define('_SECURITYENFORCER_OPT_SELECT_OFF_COMP',		'Off');
+define('_SECURITYENFORCER_OPT_SELECT_ONE_COMP',		'一種類の文字タイプ');
+define('_SECURITYENFORCER_OPT_SELECT_TWO_COMP',		'二種類の文字タイプ');
+define('_SECURITYENFORCER_OPT_SELECT_THREE_COMP',	'三種類の文字タイプ');
+define('_SECURITYENFORCER_OPT_SELECT_FOUR_COMP',	'四種類の文字タイプ');
+define('_SECURITYENFORCER_OPT_MAX_FAILED_LOGIN',	'何度目のログイン失敗でアカウントをロックしますか？');
+define('_SECURITYENFORCER_OPT_LOGIN_LOCKOUT',		'アカウントをロックしてから何分でロック解除しますか？');
+
+
+// QuickMenu
+define('_SECURITYENFORCER_ADMIN_TOOLTIP',			'SecurityEnforcerプラグインの管理');
+define('_SECURITYENFORCER_ADMIN_UNLOCKED',			'ロック解除されました。対応するＩＰアドレス、またはログイン名のロックを解除するのを忘れないでください。');
+define('_SECURITYENFORCER_ADMIN_NONE_LOCKED',		'該当なし');
+
+// ERRORS
+define('_SECURITYENFORCER_INSUFFICIENT_COMPLEXITY',	'入力されたパスワードは、このサイトで要求される文字数、または強度を満たしていません。<br />');
+define('_SECURITYENFORCER_MIN_PWD_LENGTH',			'<br />パスワードが短すぎます：');
+define('_SECURITYENFORCER_PWD_COMPLEXITY',			'<br />文字タイプが少なすぎます([a-z], [A-Z], [0-9], [-~!@#$%^&*()_+=,.<>?:;|]): ');
+
+// random words
+define('_SECURITYENFORCER_UNLOCK',					'アンロック');
+define('_SECURITYENFORCER_ENTITY',					'エンティティ');
+define('_SECURITYENFORCER_LOCKED_ENTITIES',			'現在ロック中のエンティティ');
+
+// Plugin desc
+define('_SECURITYENFORCER_DESCRIPTION',				'パスワードの最小文字数や強度の制限、ログイン失敗可能回数などを設定します');
+
+// Log info
+define('_SECURITYENFORCER_LOGIN_DISALLOWED',		'リモートホスト「%2$s」からのログイン名「%1$s」のログインはSecurityEnforcerプラグインによって拒絶されました');
+
+// QuickMenu title
+define('_SECURITYENFORCER_ADMIN_TITLE',				'SecurityEnforcerプラグインの管理');
+
+?>
\ No newline at end of file
diff -x .svn -aruN 3.41.src/nucleus/xmlrpc/api_blogger.inc.php 3.51.src/nucleus/xmlrpc/api_blogger.inc.php
--- 3.41.src/nucleus/xmlrpc/api_blogger.inc.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/xmlrpc/api_blogger.inc.php	2009-11-01 14:54:00.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
  * This file contains definitions for the methods in the Blogger API
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: api_blogger.inc.php 1119 2007-02-04 06:24:28Z kimitake $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: api_blogger.inc.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 
@@ -299,7 +299,7 @@
 			   ." LIMIT $amount";
 		$r = sql_query($query);
 
-		while ($row = mysql_fetch_assoc($r)) {
+		while ($row = sql_fetch_assoc($r)) {
 
 			// remove linebreaks if needed
 			if ($blog->convertBreaks())
diff -x .svn -aruN 3.41.src/nucleus/xmlrpc/api_metaweblog.inc.php 3.51.src/nucleus/xmlrpc/api_metaweblog.inc.php
--- 3.41.src/nucleus/xmlrpc/api_metaweblog.inc.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/xmlrpc/api_metaweblog.inc.php	2009-11-01 14:54:00.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -15,8 +15,8 @@
  *	This file contains definitions for the methods of the metaWeblog API
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: api_metaweblog.inc.php 1116 2007-02-03 08:24:29Z kimitake $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: api_metaweblog.inc.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 
@@ -287,7 +287,7 @@
 			   ." LIMIT $amount";
 		$r = sql_query($query);
 
-		while ($row = mysql_fetch_assoc($r)) {
+		while ($row = sql_fetch_assoc($r)) {
 
 			// remove linebreaks if needed
 			if ($blog->convertBreaks()) {
@@ -402,7 +402,7 @@
 				. " ORDER BY cname";
 		$r = sql_query($query);
 
-		while ($obj = mysql_fetch_object($r)) {
+		while ($obj = sql_fetch_object($r)) {
 
 			$categorystruct[$obj->cname] = new xmlrpcval(
 				array(
diff -x .svn -aruN 3.41.src/nucleus/xmlrpc/api_mt.inc.php 3.51.src/nucleus/xmlrpc/api_mt.inc.php
--- 3.41.src/nucleus/xmlrpc/api_mt.inc.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/xmlrpc/api_mt.inc.php	2009-11-01 14:54:00.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,7 +16,8 @@
  * Wouter Demuynck 2003-08-31
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: api_mt.inc.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 	// mt.supportedMethods
@@ -352,7 +353,7 @@
 				. " ORDER BY cname";
 		$r = sql_query($query);
 
-		while ($obj = mysql_fetch_object($r)) {
+		while ($obj = sql_fetch_object($r)) {
 
 			$categorystruct[] = new xmlrpcval(
 				array(
@@ -401,7 +402,7 @@
 			   ." LIMIT $iAmount";
 		$r = sql_query($query);
 
-		while ($row = mysql_fetch_assoc($r)) {
+		while ($row = sql_fetch_assoc($r)) {
 
 			$newstruct = new xmlrpcval(array(
 				"dateCreated" => new xmlrpcval(iso8601_encode(strtotime($row['itime'])),"dateTime.iso8601"),
diff -x .svn -aruN 3.41.src/nucleus/xmlrpc/api_nucleus.inc.php 3.51.src/nucleus/xmlrpc/api_nucleus.inc.php
--- 3.41.src/nucleus/xmlrpc/api_nucleus.inc.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/xmlrpc/api_nucleus.inc.php	2009-11-01 14:54:00.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,8 +16,8 @@
  * NOTE: These functions are deprecated and will most likely be removed!
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: api_nucleus.inc.php 1116 2007-02-03 08:24:29Z kimitake $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: api_nucleus.inc.php 1418 2009-10-30 06:25:28Z ehui $
  */
 
 	// nucleus.addItem
@@ -232,7 +232,7 @@
 			   ." ORDER BY itime DESC"
 			   ." LIMIT $amount";
 		$r = sql_query($query);
-		while ($obj = mysql_fetch_object($r)) {
+		while ($obj = sql_fetch_object($r)) {
 			$newstruct = new xmlrpcval(array(
 				"publishDate" => new xmlrpcval(iso8601_encode(strtotime($obj->itime)),"dateTime.iso8601"),
 				"userid" => new xmlrpcval($obj->iauthor,"string"),
@@ -288,7 +288,7 @@
 			"body" => new xmlrpcval($item['body'],"string"),
 			"more" => new xmlrpcval($item['more'],"string"),
 			"draft" => new xmlrpcval($item['draft'],"boolean"),
-			"closed" => new xmlrpcval($ite['closed'],"boolean"),
+			"closed" => new xmlrpcval($item['closed'],"boolean"),
 		),'struct');
 
 		return new xmlrpcresp($newstruct);
diff -x .svn -aruN 3.41.src/nucleus/xmlrpc/server.php 3.51.src/nucleus/xmlrpc/server.php
--- 3.41.src/nucleus/xmlrpc/server.php	2009-03-15 22:31:34.000000000 -0500
+++ 3.51.src/nucleus/xmlrpc/server.php	2009-11-01 14:54:00.000000000 -0600
@@ -1,7 +1,7 @@
 <?php
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -61,8 +61,8 @@
  * mt.supportedMethods
  *
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: server.php 1201 2007-09-07 07:12:21Z kimitake $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: server.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 $CONF = array();
 require("../../config.php");	// include Nucleus libs and code
@@ -179,7 +179,7 @@
 			. " ORDER BY bname";
 	$r = sql_query($query);
 
-	while ($obj = mysql_fetch_object($r)) {
+	while ($obj = sql_fetch_object($r)) {
 		if ($obj->burl)
 			$blogurl = $obj->burl;
 		else
diff -x .svn -aruN 3.41.src/xml-rss2.php 3.51.src/xml-rss2.php
--- 3.41.src/xml-rss2.php	2009-03-15 22:31:38.000000000 -0500
+++ 3.51.src/xml-rss2.php	2009-11-01 14:54:08.000000000 -0600
@@ -2,7 +2,7 @@
 
 /*
  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2009 The Nucleus Group
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
 /**
  * Nucleus RSS syndication channel skin
  * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id: xml-rss2.php 1116 2007-02-03 08:24:29Z kimitake $
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: xml-rss2.php 1388 2009-07-18 06:31:28Z shizuki $
  */
 
 header('Pragma: no-cache');
