OSDN Git Service

Add some codes from 3.61. Currently files under /nucleus/libs and /nucleus/libs/sql...
[nucleus-jp/nucleus-jp-ancient.git] / utf8 / nucleus / libs / ADMIN.php
index 8963d8b..6b6e536 100755 (executable)
-<?php
-/*
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 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)
- */
-/**
- * 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,v 1.14 2007-02-04 06:28:46 kimitake Exp $
- * @version $NucleusJP: ADMIN.php,v 1.13 2007/02/03 06:00:04 kimitake Exp $
- */
-
-require_once "showlist.php";
-
-/**
- * Builds the admin area and executes admin actions
- */
-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');
-/*
-               // 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');
-*/
-               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 . " ($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">Show all blogs</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.'">'.$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;
-
-               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 = 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 . $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 . $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 . $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 . $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 . $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 = 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;
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-               echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
-
-               // start index
-               if (postVar('start'))
-                       $start = postVar('start');
-               else
-                       $start = 0;
-
-               // amount of items to show
-               if (postVar('amount'))
-                       $amount = postVar('amount');
-               else
-                       $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;
-
-               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 = postVar('start');
-               else
-                       $start = 0;
-
-               // amount of items to show
-               if (postVar('amount'))
-                       $amount = postVar('amount');
-               else
-                       $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, 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;
-
-               // start index
-               if (postVar('start'))
-                       $start = postVar('start');
-               else
-                       $start = 0;
-
-               // amount of items to show
-               if (postVar('amount'))
-                       $amount = postVar('amount');
-               else
-                       $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;
-
-               if ($blogid == '')
-                       $blogid = intRequestVar('blogid');
-               else
-                       $blogid = intval($blogid);
-
-               $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
-
-               // start index
-               if (postVar('start'))
-                       $start = postVar('start');
-               else
-                       $start = 0;
-
-               // amount of items to show
-               if (postVar('amount'))
-                       $amount = postVar('amount');
-               else
-                       $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
-               */
-               switch ($actiontype) {
-                       case 'adddraft':
-                               $publish = 0;
-                               $wasdraft = 1;
-                               $timestamp = 0;
-                               break;
-                       case 'addfuture':
-                               $wasdraft = 1;
-                               $publish = 1;
-                               $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year'));
-                               break;
-                       case 'addnow':
-                               $wasdraft = 1;
-                               $publish = 1;
-                               $timestamp = 0;
-                               break;
-                       case 'changedate':
-                               $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year'));
-                               $publish = 1;
-                               $wasdraft = 0;
-                               break;
-                       case 'edit':
-                       default:
-                               $publish = 1;
-                               $wasdraft = 0;
-                               $timestamp = 0;
-               }
-
-               // edit the item for real
-               ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
-
-               if ($draftid > 0) {
-                       ITEM::delete($draftid);
-               }
-
-               $blogid = getBlogIDFromItemID($itemid);
-               $blog =& $manager->getBlog($blogid);
-               if (!$closed && $publish && $wasdraft && $blog->pingUserland()) {
-                       $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;
-
-               $manager->loadClass('ITEM');
-               ITEM::delete($itemid);
-       }
-
-       /**
-        * @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();
-
-               ITEM::move($itemid, $catid);
-
-               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);
-
-               $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid));
-
-               if ($result['status'] == 'newcategory')
-                       $this->action_categoryedit(
-                               $result['catid'],
-                               $blogid,
-                               $blog->pingUserland() ? $pingUrl : ''
-                       );
-               elseif ((postVar('actiontype') == 'addnow') && $blog->pingUserland())
-                       $this->action_sendping($blogid);
-               else
-                       $this->action_itemlist($blogid);
-       }
-
-       /**
-        * Shows a window that says we're about to ping weblogs.com.
-        * 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).'" />');
-               ?>
-               <h2>Site Updated, Now pinging weblogs.com</h2>
-
-               <p>
-                       Pinging weblogs.com! This can a while...
-                       <br />
-                       When the ping is complete (and successfull), your weblog will show up in the weblogs.com updates list.
-               </p>
-
-               <p>
-                       If you aren't automatically passed through, <a href="index.php?action=rawping&amp;blogid=<?php echo $blogid?>">try again</a>
-               </p>
-               <?php           $this->pagefoot();
-       }
-
-       /**
-        * Ping to Weblogs.com
-        * Sends the real ping (can take up to 10 seconds!)
-        */
-       function action_rawping() {
-               global $manager;
-               // TODO: checks?
-
-               $blogid = intRequestVar('blogid');
-               $blog =& $manager->getBlog($blogid);
-
-               $result = $blog->sendUserlandPing();
-
-               $this->pagehead();
-
-               ?>
-
-               <h2>Ping Results</h2>
-
-               <p>The following message was returned by weblogs.com:</p>
-
-               <div class='note'><?php echo  $result ?></div>
-
-               <ul>
-                       <li><a href="index.php?action=itemlist&amp;blogid=<?php echo $blog->getID()?>">View list of recent items for <?php echo htmlspecialchars($blog->getName())?></a></li>
-                       <li><a href="<?php echo $blog->getURL()?>">Visit your own site</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_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();
-
-               $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 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"><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>(This is the name used to logon)</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"><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); ?></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>
-               <?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);
-               }
-
-
-               $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>';
-                       }
-
-                       if ($bNeedsPasswordChange)
-                       {
-                               ?>
-                                       <div><form action="index.php" method="post">
-
-                                               <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>
-
-
-                                       </form></div>
-
-                               <?php
-
-                       }
-
-               $this->pagefoot();
-
-       }
-
-       /**
-        * Account activation - set password part
-        *
-        * @author dekarma
-        */
-       function action_activatesetpwd() {
-
-               $key = postVar('key');
-
-               // clean up old activation keys
-               MEMBER::cleanupActivationTable();
-
-               // get activation info
-               $info = MEMBER::getActivationInfo($key);
-
-               if (!$info || ($info->type == 'addresschange'))
-                       return $this->_showActivationPage($key, _ERROR_ACTIVATE);
-
-               $mem = MEMBER::createFromId($info->vmember);
-
-               if (!$mem)
-                       return $this->_showActivationPage($key, _ERROR_ACTIVATE);
-
-               $password               = postVar('password');
-               $repeatpassword = postVar('repeatpassword');
-
-               if ($password != $repeatpassword)
-                       return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
-
-               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  $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' => &$mem, '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' => &$mem, '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>Members currently on your team:
-               <?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>
-                       <td><?php echo _EBLOG_PING?> <?php help('pinguserland'); ?></td>
-                       <td><?php $this->input_yesno('pinguserland',$blog->pingUserland(),85); ?></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 (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  $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('pinguserland'));
-               $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  $mem->getDisplayName() ?></b>
-                       </p>
-
-                       <p>
-                       Please note that media files will <b>NOT</b> be deleted. (At least not in this Nucleus version)
-                       </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 */
-               $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>注意事項</h3>
-
-               <p>作成にあたって、下記の<strong>注意事項</strong> をまずお読み下さい</p>
-
-               <p>新しいweblogを作成した後に、このblogにアクセスするための方法を紹介しておきます。方法は2つあります:</p>
-
-               <ol>
-                       <li><strong>簡単な方法:</strong> <code>index.php</code>の複製を作り、新しいblogを表示するように変更を加えます。 この変更の詳細は、作成後に表示されます。</li>
-                       <li><strong>高度な方法:</strong> 現在のblogで使用しているスキンに<code>otherblog</code>というコードを使った記述を加えます。この方法では、同じページ内で複数のblogを展開することが可能となります。</li>
-               </ol>
-
-               <h3>Weblogの作成</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('blogadmin'); ?>
-                       </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' => &$bdescription,
-                               '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
-               sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, 'General','Items that do not fit in other categories')");
-               $catid = mysql_insert_id();
-
-               // 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);
-
-
-               $blog->additem($blog->getDefaultCategory(),'First Item','これはあなたのweblogにおける最初のアイテムです。自由に削除していただいてかまいません。','',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
-
-               $manager->notify(
-                       'PostAddBlog',
-                       array(
-                               'blog' => &$blog
-                       )
-               );
-
-               $manager->notify(
-                       'PostAddCategory',
-                       array(
-                               'blog' => &$blog,
-                               'name' => 'General',
-                               'description' => 'Items that do not fit in other categories',
-                               'catid' => $catid
-                       )
-               );
-
-               $this->pagehead();
-               ?>
-               <h2>新しいweblogが作成されました</h2>
-
-               <p>新しいweblog 「<?php echo htmlspecialchars($bname)?>」が作成されました。続けて、これにアクセスするために以下のどちらかの手順に進んでください。</p>
-
-               <ol>
-                       <li><a href="#index_php">簡単な方法: 下のコードを貼付けた <code><?php echo htmlspecialchars($bshortname)?>.php</code> というファイルを作成する</a></li>
-                       <li><a href="#skins">高度な方法: 現在使用しているスキンに新しいweblogを展開させるための記述を加える</a></li>
-               </ol>
-
-               <h3><a id="index_php">方法 1: <code><?php echo htmlspecialchars($bshortname)?>.php</code> というファイルを作成</a></h3>
-
-               <p><code><?php echo htmlspecialchars($bshortname)?>.php</code> というファイルを作成して、中身に以下のコードを貼り付ける:</p>
-<pre><code>&lt;?php
-
-$CONF['Self'] = '<b><?php echo htmlspecialchars($bshortname)?>.php</b>';
-
-include('<i>./config.php</i>');
-
-selectBlog('<b><?php echo htmlspecialchars($bshortname)?></b>');
-selector();
-
-?&gt;</code></pre>
-
-               <p>すでにある<code>index.php</code>と同じディレクトリにアップロードします。</p>
-
-               <p>新しいweblogの作成を完了するためには、下にこのファイルのURLを入力してください。 (すでに用意した値で合っているとは思いますが保証はしません):</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">方法 2: 現在使用しているスキンに新しいweblogを展開する記述を加える</a></h3>
-
-               <p>新しいweblogの作成を完了するためには、下にURLを入力してください。 (大抵は既存blogと同じURL)</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  $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);
-?>
-               </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);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
-<?php
-       $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
-?>
-               </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>
-<?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);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 160);
-       $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 170);
-       $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 180);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 190);
-       $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 200);
-       $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 210);
-       $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 220);
-       $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 230);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 240);
-       $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 250);
-       $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 260);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',270);
-       $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',280);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
-               </tr><tr>
-                       <td><?php echo _TEMPLATE_UPDATE?></td>
-                       <td>
-                               <input type="submit" tabindex="290" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
-                               <input type="reset" tabindex="300" 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;
-       ?>
-               </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;
-
-               $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, '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'));
-
-
-               // 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 die("Query error: " . 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 $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=' . strtolower($row['stype']) . '">' . ucfirst($row['stype']) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&amp;skinid=' . $skinid . '&amp;type=' . 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  $skin->getName() ?>': <?php echo (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 (isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
-               <?php help('skinpart' . $type);?>
-               <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 (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 ", ";
-                       }
-               ?>
-               <br /><br />
-               Short blog names:
-               <?php                   $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
-                       showlist($query,'table',array('content'=>'shortblognames'));
-               ?>
-
-               <br />
-               Template names:
-               <?php                   $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
-                       showlist($query,'table',array('content'=>'shortnames'));
-               ?>
-
-
-               </div>
-               </form>
-
-
-               <?php           $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 . $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  $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 $skintype; ?> (<?php echo $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 $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 />
-                               URL: <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>
-                       <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'));
-
-               // 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;
-
-       }
-
-       /**
-        * @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 xmlns="http://www.w3.org/1999/xhtml">
-               <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 />(';
-
-                       // Note(JP): disabled code name description
-/*
-                       if ($member->isLoggedIn() && $member->isAdmin())
-                               echo '<a href="http://nucleuscms.org/version.php?v=',getNucleusVersion(),'&amp;pl=',getNucleusPatchLevel(),'" title="Check for upgrade">Nucleus CMS ', $nucleus['version'], ' &quot;', $nucleus['codename'], '&quot;</a>';
-                       else
-                               echo 'Nucleus CMS ', $nucleus['version'], ' &quot;', $nucleus['codename'], '&quot;';
-*/
-                       if ($member->isLoggedIn() && $member->isAdmin())
-                               echo '<a href="http://nucleuscms.org/version.php?v=',getNucleusVersion(),'&amp;pl=',getNucleusPatchLevel(),'" title="Check for upgrade">Nucleus CMS ', $nucleus['version'], ' </a>';
-                       else
-                               echo 'Nucleus CMS ', $nucleus['version'];
-                       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="http://nucleuscms.org/">Nucleus CMS</a> &copy; 2002-<?php echo date('Y'); ?> The Nucleus Group
-                               -
-                               <a href="http://nucleuscms.org/donate.php">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=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 = getBlogNameFromID($blogid);
-               $sjisBlogName = mb_convert_encoding($sjisBlogName, "SJIS", "auto");
-
-               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\\Post To &Nucleus (".$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>Bookmarklet<!-- and Right Click Menu --></h2>
-
-               <p>
-               Bookmarklet とは、クリック1回で記事の投稿ができるシステムです。 この Bookmarklet をインストールすると、ブラウザのツールバーの'add to weblog'ボタンが利用可能となり、Nucleusの新規アイテムの追加ウィンドウがポップアップします。任意のWebページを開いた状態でこのボタンを押せば、そのWebページのタイトルと、そのページへのリンクタグがすでに埋め込まれた状態でアイテム追加ウィンドウが開き、さらに、そのページ内に引用したい文を選択した状態であればその引用文も自動的に引用します。
-               </p>
-
-               <h3>Bookmarklet</h3>
-               <p>
-                       下のリンク部分を「お気に入り」もしくはツールバーにドラッグできます。<small>(その前にテストしてみたい場合は単純に下のリンクをクリックしてみてください)</small>
-                       <br />
-                       <br />
-                       <a href="<?php echo htmlspecialchars($bm)?>">Add to <?php echo $blog->getShortName()?></a> (ほとんどのブラウザで動作します)
-               </p>
-
-               <h3>右クリックメニューにインストール (WindowsでIE使用時)</h3>
-               <p>
-                       <?php
-                               $url = 'index.php?action=regfile&blogid=' . intval($blogid);
-                               $url = $manager->addTicketToUrl($url);
-                       ?>
-                       あるいは<a href="<?php echo htmlspecialchars($url) ?>">右クリックメニュー</a>にインストールすることもできます (「開く」を選択すれば直接レジストリに登録します)
-               </p>
-
-               <p>
-                       このインストールした右クリックメニューを表示するためにはIEの再起動が必要です。
-               </p>
-
-               <h3>アンインストール</h3>
-               <p>
-                       「お気に入り」もしくはツールバーから消すには、単に削除するだけです。
-               </p>
-               
-               <p>
-                       右クリックメニューから消したい時は、以下の手順を踏んでください:
-               </p>
-
-               <ol>
-                       <li>スタートメニューから「ファイルを指定して実行...」を選択</li>
-                       <li>"regedit" と入力</li>
-                       <li>"OK" ボタンを押す</li>
-                       <li>"\HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt" をツリーの中から検索</li>
-                       <li>"add to weblog" エントリを削除</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);
-
-               $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">Only blog '<?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_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">
-               <b>An example</b>: "134.58.253.193" will only block one computer, while "134.58.253" will block 256 IP addresses, including the one from the first example.
-               </div>
-
-               <div>
-               <?php                   if ($ip) {
-               ?>
-                       <input name="iprange" type="radio" value="<?php echo htmlspecialchars($ip)?>" checked="checked" id="ip_fixed" /><label for="ip_fixed"><?php echo htmlspecialchars($ip)?></label>
-                       <br />
-                       <input name="iprange" type="radio" value="custom" id="ip_custom" /><label for="ip_custom">Custom: </label><input name='customiprange' value='<?php echo htmlspecialchars($ip)?>' 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);
-
-               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);
-
-               $message = 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 . ' (' . $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 . $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 . $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(_ERROR_INSREQPLUGIN . $pluginName);
-                       }
-               }
-
-               // 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).'\')');
-                       }
-               }
-
-               $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;
-
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-
-               $pid = intPostVar('plugid');
-
-               $error = $this->deleteOnePlugin($pid, 1);
-               if ($error) {
-                       $this->error($error);
-               }
-
-               $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 = mysql_fetch_object($res)) {
-                       $plug =& $manager->getPlugin($o->pfile);
-                       if ($plug)
-                       {
-                               $depList = $plug->getPluginDep();
-                               foreach ($depList as $depName)
-                               {
-                                       if ($name == $depName)
-                                       {
-                                               return _ERROR_DELREQPLUGIN . $o->pfile;
-                                       }
-                               }
-                       }
-               }
-
-               $manager->notify('PreDeletePlugin', array('plugid' => $pid));
-
-               // 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();
-       }
-
-       /**
-        * @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();
-       }
-
-       /**
-        * @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>';
-               $this->pagehead($extrahead);
-
-               ?>
-                       <p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>
-
-                       <h2>Options for <?php echo htmlspecialchars(getPluginNameFromPid($pid))?></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' => ''
-                       ));
-               }
-
-               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'];
-
-                               echo '<tr><th colspan="2">Options for ', htmlspecialchars($aOption['pfile']),'</th></tr>';
-                       }
-
-                       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) {
-               $id = htmlspecialchars($name);
-               $id = str_replace('[','-',$id);
-               $id = str_replace(']','-',$id);
-               $id1 = $id . htmlspecialchars($value1);
-               $id2 = $id . htmlspecialchars($value2);
-
-               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 ' ';
-               echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
-                       if ($checkedval != $value1)
-                               echo "tabindex='$tabindex' checked='checked'";
-                       echo ' id="'.$id2.'" /><label for="'.$id2.'">' . $noval . '</label>';
-       }
-
-} // class ADMIN
-
-?>
+<?php\r
+/*\r
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
+ * Copyright (C) 2002-2010 The Nucleus Group\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ * (see nucleus/documentation/index.html#license for more info)\r
+ */\r
+/**\r
+ * The code for the Nucleus admin area\r
+ *\r
+ * @license http://nucleuscms.org/license.txt GNU General Public License\r
+ * @copyright Copyright (C) 2002-2010 The Nucleus Group\r
+ * @version $Id$\r
+ * @version $NucleusJP: ADMIN.php,v 1.21.2.4 2007/10/30 19:04:24 kmorimatsu Exp $\r
+ */\r
+\r
+if ( !function_exists('requestVar') ) exit;\r
+require_once dirname(__FILE__) . '/showlist.php';\r
+\r
+/**\r
+ * Builds the admin area and executes admin actions\r
+ */\r
+class ADMIN {\r
+\r
+       /**\r
+        * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)\r
+        */\r
+       var $action;\r
+\r
+       /**\r
+        * Class constructor\r
+        */\r
+       function ADMIN() {\r
+\r
+       }\r
+\r
+       /**\r
+        * Executes an action\r
+        *\r
+        * @param string $action action to be performed\r
+        */\r
+       function action($action) {\r
+               global $CONF, $manager;\r
+\r
+               // list of action aliases\r
+               $alias = array(\r
+                       'login' => 'overview',\r
+                       '' => 'overview'\r
+               );\r
+\r
+               if (isset($alias[$action]))\r
+                       $action = $alias[$action];\r
+\r
+               $methodName = 'action_' . $action;\r
+\r
+               $this->action = strtolower($action);\r
+\r
+               // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action\r
+               // is an action that requires user interaction before something is actually done)\r
+               // all safe actions are in this array:\r
+               $aActionsNotToCheck = array(\r
+                       'showlogin',\r
+                       'login',\r
+                       'overview',\r
+                       'itemlist',\r
+                       'blogcommentlist',\r
+                       'bookmarklet',\r
+                       'blogsettings',\r
+                       'banlist',\r
+                       'deleteblog',\r
+                       'editmembersettings',\r
+                       'browseownitems',\r
+                       'browseowncomments',\r
+                       'createitem',\r
+                       'itemedit',\r
+                       'itemmove',\r
+                       'categoryedit',\r
+                       'categorydelete',\r
+                       'manage',\r
+                       'actionlog',\r
+                       'settingsedit',\r
+                       'backupoverview',\r
+                       'pluginlist',\r
+                       'createnewlog',\r
+                       'usermanagement',\r
+                       'skinoverview',\r
+                       'templateoverview',\r
+                       'skinieoverview',\r
+                       'itemcommentlist',\r
+                       'commentedit',\r
+                       'commentdelete',\r
+                       'banlistnewfromitem',\r
+                       'banlistdelete',\r
+                       'itemdelete',\r
+                       'manageteam',\r
+                       'teamdelete',\r
+                       'banlistnew',\r
+                       'memberedit',\r
+                       'memberdelete',\r
+                       'pluginhelp',\r
+                       'pluginoptions',\r
+                       'plugindelete',\r
+                       'skinedittype',\r
+                       'skinremovetype',\r
+                       'skindelete',\r
+                       'skinedit',\r
+                       'templateedit',\r
+                       'templatedelete',\r
+                       'activate',\r
+                       'systemoverview'\r
+               );\r
+/*\r
+               // the rest of the actions needs to be checked\r
+               $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');\r
+*/\r
+               if (!in_array($this->action, $aActionsNotToCheck))\r
+               {\r
+                       if (!$manager->checkTicket())\r
+                               $this->error(_ERROR_BADTICKET);\r
+               }\r
+\r
+               if (method_exists($this, $methodName))\r
+                       call_user_func(array(&$this, $methodName));\r
+               else\r
+                       $this->error(_BADACTION . htmlspecialchars(" ($action)"));\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_showlogin() {\r
+               global $error;\r
+               $this->action_login($error);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_login($msg = '', $passvars = 1) {\r
+               global $member;\r
+\r
+               // skip to overview when allowed\r
+               if ($member->isLoggedIn() && $member->canLogin()) {\r
+                       $this->action_overview();\r
+                       exit;\r
+               }\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<h2>', _LOGIN ,'</h2>';\r
+               if ($msg) echo _MESSAGE , ': ', htmlspecialchars($msg);\r
+               ?>\r
+\r
+               <form action="index.php" method="post"><p>\r
+               <?php echo _LOGIN_NAME; ?> <br /><input name="login"  tabindex="10" />\r
+               <br />\r
+               <?php echo _LOGIN_PASSWORD; ?> <br /><input name="password"  tabindex="20" type="password" />\r
+               <br />\r
+               <input name="action" value="login" type="hidden" />\r
+               <br />\r
+               <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />\r
+               <br />\r
+               <small>\r
+                       <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>\r
+                       <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>\r
+               </small>\r
+               <?php              // pass through vars\r
+\r
+                       $oldaction = postVar('oldaction');\r
+                       if (  ($oldaction != 'logout')  && ($oldaction != 'login')  && $passvars ) {\r
+                               passRequestVars();\r
+                       }\r
+\r
+\r
+               ?>\r
+               </p></form>\r
+               <?php      $this->pagefoot();\r
+       }\r
+\r
+\r
+       /**\r
+        * provides a screen with the overview of the actions available\r
+        * @todo document parameter\r
+        */\r
+       function action_overview($msg = '') {\r
+               global $member;\r
+\r
+               $this->pagehead();\r
+\r
+               if ($msg)\r
+                       echo _MESSAGE , ': ', $msg;\r
+\r
+               /* ---- add items ---- */\r
+               echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';\r
+\r
+               $showAll = requestVar('showall');\r
+\r
+               if (($member->isAdmin()) && ($showAll == 'yes')) {\r
+                       // Super-Admins have access to all blogs! (no add item support though)\r
+                       $query =  'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'\r
+                                  . ' FROM ' . sql_table('blog')\r
+                                  . ' ORDER BY bname';\r
+               } else {\r
+                       $query =  'SELECT bnumber, bname, tadmin, burl, bshortname'\r
+                                  . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')\r
+                                  . ' WHERE tblog=bnumber and tmember=' . $member->getID()\r
+                                  . ' ORDER BY bname';\r
+               }\r
+               $template['content'] = 'bloglist';\r
+               $template['superadmin'] = $member->isAdmin();\r
+               $amount = showlist($query,'table',$template);\r
+\r
+               if (($showAll != 'yes') && ($member->isAdmin())) {\r
+                       $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));\r
+                       if ($total > $amount)\r
+                               echo '<p><a href="index.php?action=overview&amp;showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';\r
+               }\r
+\r
+               if ($amount == 0)\r
+                       echo _OVERVIEW_NOBLOGS;\r
+\r
+               if ($amount != 0) {\r
+                       echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';\r
+                       $query =  'SELECT ititle, inumber, bshortname'\r
+                                  . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')\r
+                                  . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';\r
+                       $template['content'] = 'draftlist';\r
+                       $amountdrafts = showlist($query, 'table', $template);\r
+                       if ($amountdrafts == 0)\r
+                               echo _OVERVIEW_NODRAFTS;\r
+               }\r
+\r
+               /* ---- user settings ---- */\r
+               echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';\r
+               echo '<ul>';\r
+               echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';\r
+               echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';\r
+               echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';\r
+               echo '</ul>';\r
+\r
+               /* ---- general settings ---- */\r
+               if ($member->isAdmin()) {\r
+                       echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';\r
+                       echo '<ul>';\r
+                       echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';\r
+                       echo '</ul>';\r
+               }\r
+\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Returns a link to a weblog\r
+        * @param object BLOG\r
+        */\r
+       function bloglink(&$blog) {\r
+               return '<a href="'.htmlspecialchars($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. htmlspecialchars( $blog->getName() ) .'</a>';\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_manage($msg = '') {\r
+               global $member;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';\r
+\r
+               if ($msg)\r
+                       echo '<p>' , _MESSAGE , ': ', $msg , '</p>';\r
+\r
+\r
+               echo '<h2>' . _MANAGE_GENERAL. '</h2>';\r
+\r
+               echo '<ul>';\r
+               echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';\r
+               echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';\r
+               echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';\r
+               echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';\r
+               echo '</ul>';\r
+\r
+               echo '<h2>' . _MANAGE_SKINS . '</h2>';\r
+               echo '<ul>';\r
+               echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';\r
+               echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';\r
+               echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';\r
+               echo '</ul>';\r
+\r
+               echo '<h2>' . _MANAGE_EXTRA . '</h2>';\r
+               echo '<ul>';\r
+               echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';\r
+               echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';\r
+               echo '</ul>';\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemlist($blogid = '') {\r
+               global $member, $manager, $CONF;\r
+\r
+               if ($blogid == '')\r
+                       $blogid = intRequestVar('blogid');\r
+\r
+               $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';\r
+               echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';\r
+\r
+               // start index\r
+               if (postVar('start'))\r
+                       $start = intPostVar('start');\r
+               else\r
+                       $start = 0;\r
+\r
+               if ($start == 0)\r
+                       echo '<p><a href="index.php?action=createitem&amp;blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';\r
+\r
+               // amount of items to show\r
+               if (postVar('amount'))\r
+                       $amount = intPostVar('amount');\r
+               else {\r
+                       $amount = intval($CONF['DefaultListSize']);\r
+                       if ($amount < 1)\r
+                               $amount = 10;\r
+               }\r
+\r
+               $search = postVar('search');    // search through items\r
+\r
+               $query =  'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime, bnumber, catid'\r
+                          . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')\r
+                          . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;\r
+\r
+               if ($search)\r
+                       $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';\r
+\r
+               // non-blog-admins can only edit/delete their own items\r
+               if (!$member->blogAdminRights($blogid))\r
+                       $query .= ' and iauthor=' . $member->getID();\r
+\r
+\r
+               $query .= ' ORDER BY itime DESC'\r
+                               . " LIMIT $start,$amount";\r
+\r
+               $template['content'] = 'itemlist';\r
+               $template['now'] = $blog->getCorrectTime(time());\r
+\r
+               $manager->loadClass("ENCAPSULATE");\r
+               $navList =& new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);\r
+               $navList->showBatchList('item',$query,'table',$template);\r
+\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_batchitem() {\r
+               global $member, $manager;\r
+\r
+               // check if logged in\r
+               $member->isLoggedIn() or $this->disallow();\r
+\r
+               // more precise check will be done for each performed operation\r
+\r
+               // get array of itemids from request\r
+               $selected = requestIntArray('batch');\r
+               $action = requestVar('batchaction');\r
+\r
+               // Show error when no items were selected\r
+               if (!is_array($selected) || sizeof($selected) == 0)\r
+                       $this->error(_BATCH_NOSELECTION);\r
+\r
+               // On move: when no destination blog/category chosen, show choice now\r
+               $destCatid = intRequestVar('destcatid');\r
+               if (($action == 'move') && (!$manager->existsCategory($destCatid)))\r
+                       $this->batchMoveSelectDestination('item',$selected);\r
+\r
+               // On delete: check if confirmation has been given\r
+               if (($action == 'delete') && (requestVar('confirmation') != 'yes'))\r
+                       $this->batchAskDeleteConfirmation('item',$selected);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';\r
+               echo '<h2>',_BATCH_ITEMS,'</h2>';\r
+               echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';\r
+               echo '<ul>';\r
+\r
+\r
+               // walk over all itemids and perform action\r
+               foreach ($selected as $itemid) {\r
+                       $itemid = intval($itemid);\r
+                       echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';\r
+\r
+                       // perform action, display errors if needed\r
+                       switch($action) {\r
+                               case 'delete':\r
+                                       $error = $this->deleteOneItem($itemid);\r
+                                       break;\r
+                               case 'move':\r
+                                       $error = $this->moveOneItem($itemid, $destCatid);\r
+                                       break;\r
+                               default:\r
+                                       $error = _BATCH_UNKNOWN . htmlspecialchars($action);\r
+                       }\r
+\r
+                       echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';\r
+                       echo '</li>';\r
+               }\r
+\r
+               echo '</ul>';\r
+               echo '<b>',_BATCH_DONE,'</b>';\r
+\r
+               $this->pagefoot();\r
+\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_batchcomment() {\r
+               global $member;\r
+\r
+               // check if logged in\r
+               $member->isLoggedIn() or $this->disallow();\r
+\r
+               // more precise check will be done for each performed operation\r
+\r
+               // get array of itemids from request\r
+               $selected = requestIntArray('batch');\r
+               $action = requestVar('batchaction');\r
+\r
+               // Show error when no items were selected\r
+               if (!is_array($selected) || sizeof($selected) == 0)\r
+                       $this->error(_BATCH_NOSELECTION);\r
+\r
+               // On delete: check if confirmation has been given\r
+               if (($action == 'delete') && (requestVar('confirmation') != 'yes'))\r
+                       $this->batchAskDeleteConfirmation('comment',$selected);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';\r
+               echo '<h2>',_BATCH_COMMENTS,'</h2>';\r
+               echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';\r
+               echo '<ul>';\r
+\r
+               // walk over all itemids and perform action\r
+               foreach ($selected as $commentid) {\r
+                       $commentid = intval($commentid);\r
+                       echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';\r
+\r
+                       // perform action, display errors if needed\r
+                       switch($action) {\r
+                               case 'delete':\r
+                                       $error = $this->deleteOneComment($commentid);\r
+                                       break;\r
+                               default:\r
+                                       $error = _BATCH_UNKNOWN . htmlspecialchars($action);\r
+                       }\r
+\r
+                       echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';\r
+                       echo '</li>';\r
+               }\r
+\r
+               echo '</ul>';\r
+               echo '<b>',_BATCH_DONE,'</b>';\r
+\r
+               $this->pagefoot();\r
+\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_batchmember() {\r
+               global $member;\r
+\r
+               // check if logged in and admin\r
+               ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();\r
+\r
+               // get array of itemids from request\r
+               $selected = requestIntArray('batch');\r
+               $action = requestVar('batchaction');\r
+\r
+               // Show error when no members selected\r
+               if (!is_array($selected) || sizeof($selected) == 0)\r
+                       $this->error(_BATCH_NOSELECTION);\r
+\r
+               // On delete: check if confirmation has been given\r
+               if (($action == 'delete') && (requestVar('confirmation') != 'yes'))\r
+                       $this->batchAskDeleteConfirmation('member',$selected);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';\r
+               echo '<h2>',_BATCH_MEMBERS,'</h2>';\r
+               echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';\r
+               echo '<ul>';\r
+\r
+               // walk over all itemids and perform action\r
+               foreach ($selected as $memberid) {\r
+                       $memberid = intval($memberid);\r
+                       echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';\r
+\r
+                       // perform action, display errors if needed\r
+                       switch($action) {\r
+                               case 'delete':\r
+                                       $error = $this->deleteOneMember($memberid);\r
+                                       break;\r
+                               case 'setadmin':\r
+                                       // always succeeds\r
+                                       sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);\r
+                                       $error = '';\r
+                                       break;\r
+                               case 'unsetadmin':\r
+                                       // there should always remain at least one super-admin\r
+                                       $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');\r
+                                       if (sql_num_rows($r) < 2)\r
+                                               $error = _ERROR_ATLEASTONEADMIN;\r
+                                       else\r
+                                               sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);\r
+                                       break;\r
+                               default:\r
+                                       $error = _BATCH_UNKNOWN . htmlspecialchars($action);\r
+                       }\r
+\r
+                       echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';\r
+                       echo '</li>';\r
+               }\r
+\r
+               echo '</ul>';\r
+               echo '<b>',_BATCH_DONE,'</b>';\r
+\r
+               $this->pagefoot();\r
+\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_batchteam() {\r
+               global $member;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               // check if logged in and admin\r
+               ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();\r
+\r
+               // get array of itemids from request\r
+               $selected = requestIntArray('batch');\r
+               $action = requestVar('batchaction');\r
+\r
+               // Show error when no members selected\r
+               if (!is_array($selected) || sizeof($selected) == 0)\r
+                       $this->error(_BATCH_NOSELECTION);\r
+\r
+               // On delete: check if confirmation has been given\r
+               if (($action == 'delete') && (requestVar('confirmation') != 'yes'))\r
+                       $this->batchAskDeleteConfirmation('team',$selected);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manageteam&amp;blogid=',$blogid,'">(',_BACK,')</a></p>';\r
+\r
+               echo '<h2>',_BATCH_TEAM,'</h2>';\r
+               echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';\r
+               echo '<ul>';\r
+\r
+               // walk over all itemids and perform action\r
+               foreach ($selected as $memberid) {\r
+                       $memberid = intval($memberid);\r
+                       echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';\r
+\r
+                       // perform action, display errors if needed\r
+                       switch($action) {\r
+                               case 'delete':\r
+                                       $error = $this->deleteOneTeamMember($blogid, $memberid);\r
+                                       break;\r
+                               case 'setadmin':\r
+                                       // always succeeds\r
+                                       sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);\r
+                                       $error = '';\r
+                                       break;\r
+                               case 'unsetadmin':\r
+                                       // there should always remain at least one admin\r
+                                       $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);\r
+                                       if (sql_num_rows($r) < 2)\r
+                                               $error = _ERROR_ATLEASTONEBLOGADMIN;\r
+                                       else\r
+                                               sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);\r
+                                       break;\r
+                               default:\r
+                                       $error = _BATCH_UNKNOWN . htmlspecialchars($action);\r
+                       }\r
+\r
+                       echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';\r
+                       echo '</li>';\r
+               }\r
+\r
+               echo '</ul>';\r
+               echo '<b>',_BATCH_DONE,'</b>';\r
+\r
+               $this->pagefoot();\r
+\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_batchcategory() {\r
+               global $member, $manager;\r
+\r
+               // check if logged in\r
+               $member->isLoggedIn() or $this->disallow();\r
+\r
+               // more precise check will be done for each performed operation\r
+\r
+               // get array of itemids from request\r
+               $selected = requestIntArray('batch');\r
+               $action = requestVar('batchaction');\r
+\r
+               // Show error when no items were selected\r
+               if (!is_array($selected) || sizeof($selected) == 0)\r
+                       $this->error(_BATCH_NOSELECTION);\r
+\r
+               // On move: when no destination blog chosen, show choice now\r
+               $destBlogId = intRequestVar('destblogid');\r
+               if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))\r
+                       $this->batchMoveCategorySelectDestination('category',$selected);\r
+\r
+               // On delete: check if confirmation has been given\r
+               if (($action == 'delete') && (requestVar('confirmation') != 'yes'))\r
+                       $this->batchAskDeleteConfirmation('category',$selected);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';\r
+               echo '<h2>',BATCH_CATEGORIES,'</h2>';\r
+               echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';\r
+               echo '<ul>';\r
+\r
+               // walk over all itemids and perform action\r
+               foreach ($selected as $catid) {\r
+                       $catid = intval($catid);\r
+                       echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';\r
+\r
+                       // perform action, display errors if needed\r
+                       switch($action) {\r
+                               case 'delete':\r
+                                       $error = $this->deleteOneCategory($catid);\r
+                                       break;\r
+                               case 'move':\r
+                                       $error = $this->moveOneCategory($catid, $destBlogId);\r
+                                       break;\r
+                               default:\r
+                                       $error = _BATCH_UNKNOWN . htmlspecialchars($action);\r
+                       }\r
+\r
+                       echo '<b>',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),'</b>';\r
+                       echo '</li>';\r
+               }\r
+\r
+               echo '</ul>';\r
+               echo '<b>',_BATCH_DONE,'</b>';\r
+\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function batchMoveSelectDestination($type, $ids) {\r
+               global $manager;\r
+               $this->pagehead();\r
+               ?>\r
+               <h2><?php echo _MOVE_TITLE?></h2>\r
+               <form method="post" action="index.php"><div>\r
+\r
+                       <input type="hidden" name="action" value="batch<?php echo $type?>" />\r
+                       <input type="hidden" name="batchaction" value="move" />\r
+                       <?php\r
+                               $manager->addTicketHidden();\r
+\r
+                               // insert selected item numbers\r
+                               $idx = 0;\r
+                               foreach ($ids as $id)\r
+                                       echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';\r
+\r
+                               // show blog/category selection list\r
+                               $this->selectBlogCategory('destcatid');\r
+\r
+                       ?>\r
+\r
+\r
+                       <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />\r
+\r
+               </div></form>\r
+               <?php      $this->pagefoot();\r
+               exit;\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function batchMoveCategorySelectDestination($type, $ids) {\r
+               global $manager;\r
+               $this->pagehead();\r
+               ?>\r
+               <h2><?php echo _MOVECAT_TITLE?></h2>\r
+               <form method="post" action="index.php"><div>\r
+\r
+                       <input type="hidden" name="action" value="batch<?php echo $type?>" />\r
+                       <input type="hidden" name="batchaction" value="move" />\r
+                       <?php\r
+                               $manager->addTicketHidden();\r
+\r
+                               // insert selected item numbers\r
+                               $idx = 0;\r
+                               foreach ($ids as $id)\r
+                                       echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';\r
+\r
+                               // show blog/category selection list\r
+                               $this->selectBlog('destblogid');\r
+\r
+                       ?>\r
+\r
+\r
+                       <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />\r
+\r
+               </div></form>\r
+               <?php      $this->pagefoot();\r
+               exit;\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function batchAskDeleteConfirmation($type, $ids) {\r
+               global $manager;\r
+\r
+               $this->pagehead();\r
+               ?>\r
+               <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>\r
+               <form method="post" action="index.php"><div>\r
+\r
+                       <input type="hidden" name="action" value="batch<?php echo $type?>" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input type="hidden" name="batchaction" value="delete" />\r
+                       <input type="hidden" name="confirmation" value="yes" />\r
+                       <?php                      // insert selected item numbers\r
+                               $idx = 0;\r
+                               foreach ($ids as $id)\r
+                                       echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';\r
+\r
+                               // add hidden vars for team & comment\r
+                               if ($type == 'team')\r
+                               {\r
+                                       echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';\r
+                               }\r
+                               if ($type == 'comment')\r
+                               {\r
+                                       echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';\r
+                               }\r
+\r
+                       ?>\r
+\r
+                       <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />\r
+\r
+               </div></form>\r
+               <?php      $this->pagefoot();\r
+               exit;\r
+       }\r
+\r
+\r
+       /**\r
+        * Inserts a HTML select element with choices for all categories to which the current\r
+        * member has access\r
+        * @see function selectBlog\r
+        */\r
+       function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {\r
+               ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);\r
+       }\r
+\r
+       /**\r
+        * Inserts a HTML select element with choices for all blogs to which the user has access\r
+        *        mode = 'blog' => shows blognames and values are blogids\r
+        *        mode = 'category' => show category names and values are catids\r
+        *\r
+        * @param $iForcedBlogInclude\r
+        *        ID of a blog that always needs to be included, without checking if the\r
+        *        member is on the blog team (-1 = none)\r
+        * @todo document parameters\r
+        */\r
+       function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {\r
+               global $member, $CONF;\r
+\r
+               // 0. get IDs of blogs to which member can post items (+ forced blog)\r
+               $aBlogIds = array();\r
+               if ($iForcedBlogInclude != -1)\r
+                       $aBlogIds[] = intval($iForcedBlogInclude);\r
+\r
+               if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))\r
+                       $queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';\r
+               else\r
+                       $queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();\r
+               $rblogids = sql_query($queryBlogs);\r
+               while ($o = sql_fetch_object($rblogids))\r
+                       if ($o->bnumber != $iForcedBlogInclude)\r
+                               $aBlogIds[] = intval($o->bnumber);\r
+\r
+               if (count($aBlogIds) == 0)\r
+                       return;\r
+\r
+               echo '<select name="',$name,'" tabindex="',$tabindex,'">';\r
+\r
+               // 1. select blogs (we'll create optiongroups)\r
+               // (only select those blogs that have the user on the team)\r
+               $queryBlogs =  'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';\r
+               $blogs = sql_query($queryBlogs);\r
+               if ($mode == 'category') {\r
+                       if (sql_num_rows($blogs) > 1)\r
+                               $multipleBlogs = 1;\r
+\r
+                       while ($oBlog = sql_fetch_object($blogs)) {\r
+                               if ($multipleBlogs)\r
+                                       echo '<optgroup label="',htmlspecialchars($oBlog->bname),'">';\r
+\r
+                               // show selection to create new category when allowed/wanted\r
+                               if ($showNewCat) {\r
+                                       // check if allowed to do so\r
+                                       if ($member->blogAdminRights($oBlog->bnumber))\r
+                                               echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';\r
+                               }\r
+\r
+                               // 2. for each category in that blog\r
+                               $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');\r
+                               while ($oCat = sql_fetch_object($categories)) {\r
+                                       if ($oCat->catid == $selected)\r
+                                               $selectText = ' selected="selected" ';\r
+                                       else\r
+                                               $selectText = '';\r
+                                       echo '<option value="',$oCat->catid,'" ', $selectText,'>',htmlspecialchars($oCat->cname),'</option>';\r
+                               }\r
+\r
+                               if ($multipleBlogs)\r
+                                       echo '</optgroup>';\r
+                       }\r
+               } else {\r
+                       // blog mode\r
+                       while ($oBlog = sql_fetch_object($blogs)) {\r
+                               echo '<option value="',$oBlog->bnumber,'"';\r
+                               if ($oBlog->bnumber == $selected)\r
+                                       echo ' selected="selected"';\r
+                               echo'>',htmlspecialchars($oBlog->bname),'</option>';\r
+                       }\r
+               }\r
+               echo '</select>';\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_browseownitems() {\r
+               global $member, $manager, $CONF;\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';\r
+               echo '<h2>' . _ITEMLIST_YOUR. '</h2>';\r
+\r
+               // start index\r
+               if (postVar('start'))\r
+                       $start = intPostVar('start');\r
+               else\r
+                       $start = 0;\r
+\r
+               // amount of items to show\r
+               if (postVar('amount'))\r
+                       $amount = intPostVar('amount');\r
+               else {\r
+                       $amount = intval($CONF['DefaultListSize']);\r
+                       if ($amount < 1)\r
+                               $amount = 10;\r
+               }\r
+\r
+               $search = postVar('search');    // search through items\r
+\r
+               $query =  'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'\r
+                          . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')\r
+                          . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';\r
+\r
+               if ($search)\r
+                       $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';\r
+\r
+               $query .= ' ORDER BY itime DESC'\r
+                               . " LIMIT $start,$amount";\r
+\r
+               $template['content'] = 'itemlist';\r
+               $template['now'] = time();\r
+\r
+               $manager->loadClass("ENCAPSULATE");\r
+               $navList =& new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);\r
+               $navList->showBatchList('item',$query,'table',$template);\r
+\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * Show all the comments for a given item\r
+        * @param int $itemid\r
+        */\r
+       function action_itemcommentlist($itemid = '') {\r
+               global $member, $manager, $CONF;\r
+\r
+               if ($itemid == '')\r
+                       $itemid = intRequestVar('itemid');\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canAlterItem($itemid) or $this->disallow();\r
+\r
+               $blogid = getBlogIdFromItemId($itemid);\r
+\r
+               $this->pagehead();\r
+\r
+               // start index\r
+               if (postVar('start'))\r
+                       $start = intPostVar('start');\r
+               else\r
+                       $start = 0;\r
+\r
+               // amount of items to show\r
+               if (postVar('amount'))\r
+                       $amount = intPostVar('amount');\r
+               else {\r
+                       $amount = intval($CONF['DefaultListSize']);\r
+                       if ($amount < 1)\r
+                               $amount = 10;\r
+               }\r
+\r
+               $search = postVar('search');\r
+\r
+               echo '<p>(<a href="index.php?action=itemlist&amp;blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';\r
+               echo '<h2>',_COMMENTS,'</h2>';\r
+\r
+               $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;\r
+\r
+               if ($search)\r
+                       $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';\r
+\r
+               $query .= ' ORDER BY ctime ASC'\r
+                               . " LIMIT $start,$amount";\r
+\r
+               $template['content'] = 'commentlist';\r
+               $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));\r
+\r
+               $manager->loadClass("ENCAPSULATE");\r
+               $navList =& new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);\r
+               $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Browse own comments\r
+        */\r
+       function action_browseowncomments() {\r
+               global $member, $manager, $CONF;\r
+\r
+               // start index\r
+               if (postVar('start'))\r
+                       $start = intPostVar('start');\r
+               else\r
+                       $start = 0;\r
+\r
+               // amount of items to show\r
+               if (postVar('amount'))\r
+                       $amount = intPostVar('amount');\r
+               else {\r
+                       $amount = intval($CONF['DefaultListSize']);\r
+                       if ($amount < 1)\r
+                               $amount = 10;\r
+               }\r
+\r
+               $search = postVar('search');\r
+\r
+\r
+               $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();\r
+\r
+               if ($search)\r
+                       $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';\r
+\r
+               $query .= ' ORDER BY ctime DESC'\r
+                               . " LIMIT $start,$amount";\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';\r
+               echo '<h2>', _COMMENTS_YOUR ,'</h2>';\r
+\r
+               $template['content'] = 'commentlist';\r
+               $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself\r
+\r
+               $manager->loadClass("ENCAPSULATE");\r
+               $navList =& new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);\r
+               $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Browse all comments for a weblog\r
+        * @param int $blogid\r
+        */\r
+       function action_blogcommentlist($blogid = '')\r
+       {\r
+               global $member, $manager, $CONF;\r
+\r
+               if ($blogid == '')\r
+                       $blogid = intRequestVar('blogid');\r
+               else\r
+                       $blogid = intval($blogid);\r
+\r
+               $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();\r
+\r
+               // start index\r
+               if (postVar('start'))\r
+                       $start = intPostVar('start');\r
+               else\r
+                       $start = 0;\r
+\r
+               // amount of items to show\r
+               if (postVar('amount'))\r
+                       $amount = intPostVar('amount');\r
+               else {\r
+                       $amount = intval($CONF['DefaultListSize']);\r
+                       if ($amount < 1)\r
+                               $amount = 10;\r
+               }\r
+\r
+               $search = postVar('search');            // search through comments\r
+\r
+\r
+               $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);\r
+\r
+               if ($search != '')\r
+                       $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';\r
+\r
+\r
+               $query .= ' ORDER BY ctime DESC'\r
+                               . " LIMIT $start,$amount";\r
+\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';\r
+               echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';\r
+\r
+               $template['content'] = 'commentlist';\r
+               $template['canAddBan'] = $member->blogAdminRights($blogid);\r
+\r
+               $manager->loadClass("ENCAPSULATE");\r
+               $navList =& new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);\r
+               $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Provide a page to item a new item to the given blog\r
+        */\r
+       function action_createitem() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               // check if allowed\r
+               $member->teamRights($blogid) or $this->disallow();\r
+\r
+               $memberid = $member->getID();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $this->pagehead();\r
+\r
+               // generate the add-item form\r
+               $formfactory =& new PAGEFACTORY($blogid);\r
+               $formfactory->createAddForm('admin');\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemedit() {\r
+               global $member, $manager;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canAlterItem($itemid) or $this->disallow();\r
+\r
+               $item =& $manager->getItem($itemid,1,1);\r
+               $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));\r
+\r
+               $manager->notify('PrepareItemForEdit', array('item' => &$item));\r
+\r
+               if ($blog->convertBreaks()) {\r
+                       $item['body'] = removeBreaks($item['body']);\r
+                       $item['more'] = removeBreaks($item['more']);\r
+               }\r
+\r
+               // form to edit blog items\r
+               $this->pagehead();\r
+               $formfactory =& new PAGEFACTORY($blog->getID());\r
+               $formfactory->createEditForm('admin',$item);\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemupdate() {\r
+               global $member, $manager, $CONF;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+               $catid = postVar('catid');\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canUpdateItem($itemid, $catid) or $this->disallow();\r
+\r
+               $actiontype = postVar('actiontype');\r
+\r
+               // delete actions are handled by itemdelete (which has confirmation)\r
+               if ($actiontype == 'delete') {\r
+                       $this->action_itemdelete();\r
+                       return;\r
+               }\r
+\r
+               $body   = postVar('body');\r
+               $title  = postVar('title');\r
+               $more   = postVar('more');\r
+               $closed = intPostVar('closed');\r
+               $draftid = intPostVar('draftid');\r
+\r
+               // default action = add now\r
+               if (!$actiontype)\r
+                       $actiontype='addnow';\r
+\r
+               // create new category if needed\r
+               if (strstr($catid,'newcat')) {\r
+                       // get blogid\r
+                       list($blogid) = sscanf($catid,"newcat-%d");\r
+\r
+                       // create\r
+                       $blog =& $manager->getBlog($blogid);\r
+                       $catid = $blog->createNewCategory();\r
+\r
+                       // show error when sth goes wrong\r
+                       if (!$catid)\r
+                               $this->doError(_ERROR_CATCREATEFAIL);\r
+               }\r
+\r
+               /*\r
+                       set some variables based on actiontype\r
+\r
+                       actiontypes:\r
+                               draft items -> addnow, addfuture, adddraft, delete\r
+                               non-draft items -> edit, changedate, delete\r
+\r
+                       variables set:\r
+                               $timestamp: set to a nonzero value for future dates or date changes\r
+                               $wasdraft: set to 1 when the item used to be a draft item\r
+                               $publish: set to 1 when the edited item is not a draft\r
+               */\r
+               $blogid =  getBlogIDFromItemID($itemid);\r
+               $blog   =& $manager->getBlog($blogid);\r
+\r
+               $wasdrafts = array('adddraft', 'addfuture', 'addnow');\r
+               $wasdraft  = in_array($actiontype, $wasdrafts) ? 1 : 0;\r
+               $publish   = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;\r
+               if ($actiontype == 'addfuture' || $actiontype == 'changedate') {\r
+                       $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));\r
+               } else {\r
+                       $timestamp =0;\r
+               }\r
+\r
+               // edit the item for real\r
+               ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);\r
+\r
+               $this->updateFuturePosted($blogid);\r
+\r
+               if ($draftid > 0) {\r
+                       // delete permission is checked inside ITEM::delete()\r
+                       ITEM::delete($draftid);\r
+               }\r
+\r
+               // show category edit window when we created a new category\r
+               // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')\r
+               if ($catid != intPostVar('catid')) {\r
+                       $this->action_categoryedit(\r
+                               $catid,\r
+                               $blog->getID(),\r
+                               $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)\r
+                       );\r
+               } else {\r
+                       // TODO: set start item correctly for itemlist\r
+                       $this->action_itemlist(getBlogIDFromItemID($itemid));\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemdelete() {\r
+               global $member, $manager;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canAlterItem($itemid) or $this->disallow();\r
+\r
+               if (!$manager->existsItem($itemid,1,1))\r
+                       $this->error(_ERROR_NOSUCHITEM);\r
+\r
+               $item =& $manager->getItem($itemid,1,1);\r
+               $title = htmlspecialchars(strip_tags($item['title']));\r
+               $body = strip_tags($item['body']);\r
+               $body = htmlspecialchars(shorten($body,300,'...'));\r
+\r
+               $this->pagehead();\r
+               ?>\r
+                       <h2><?php echo _DELETE_CONFIRM?></h2>\r
+\r
+                       <p><?php echo _CONFIRMTXT_ITEM?></p>\r
+\r
+                       <div class="note">\r
+                               <b>"<?php echo  $title ?>"</b>\r
+                               <br />\r
+                               <?php echo $body?>\r
+                       </div>\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                               <input type="hidden" name="action" value="itemdeleteconfirm" />\r
+                               <?php $manager->addTicketHidden() ?>\r
+                               <input type="hidden" name="itemid" value="<?php echo  $itemid; ?>" />\r
+                               <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>"  tabindex="10" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemdeleteconfirm() {\r
+               global $member;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canAlterItem($itemid) or $this->disallow();\r
+\r
+               // get blogid first\r
+               $blogid = getBlogIdFromItemId($itemid);\r
+\r
+               // delete item (note: some checks will be performed twice)\r
+               $this->deleteOneItem($itemid);\r
+\r
+               $this->action_itemlist($blogid);\r
+       }\r
+\r
+       /**\r
+        * Deletes one item and returns error if something goes wrong\r
+        * @param int $itemid\r
+        */\r
+       function deleteOneItem($itemid) {\r
+               global $member, $manager;\r
+\r
+               // only allow if user is allowed to alter item (also checks if itemid exists)\r
+               if (!$member->canAlterItem($itemid))\r
+                       return _ERROR_DISALLOWED;\r
+\r
+               // need to get blogid before the item is deleted\r
+               $blogid = getBlogIDFromItemId($itemid);\r
+\r
+               $manager->loadClass('ITEM');\r
+               ITEM::delete($itemid);\r
+\r
+               // update blog's futureposted\r
+               $this->updateFuturePosted($blogid);\r
+       }\r
+\r
+       /**\r
+        * Update a blog's future posted flag\r
+        * @param int $blogid\r
+        */\r
+       function updateFuturePosted($blogid) {\r
+               global $manager;\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+               $currenttime = $blog->getCorrectTime(time());\r
+               $result = sql_query("SELECT * FROM ".sql_table('item').\r
+                       " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));\r
+               if (sql_num_rows($result) > 0) {\r
+                               $blog->setFuturePost();\r
+               }\r
+               else {\r
+                               $blog->clearFuturePost();\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemmove() {\r
+               global $member, $manager;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canAlterItem($itemid) or $this->disallow();\r
+\r
+               $item =& $manager->getItem($itemid,1,1);\r
+\r
+               $this->pagehead();\r
+               ?>\r
+                       <h2><?php echo _MOVE_TITLE?></h2>\r
+                       <form method="post" action="index.php"><div>\r
+                               <input type="hidden" name="action" value="itemmoveto" />\r
+                               <input type="hidden" name="itemid" value="<?php echo  $itemid; ?>" />\r
+\r
+                               <?php\r
+\r
+                                       $manager->addTicketHidden();\r
+                                       $this->selectBlogCategory('catid',$item['catid'],10,1);\r
+                               ?>\r
+\r
+                               <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemmoveto() {\r
+               global $member, $manager;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+               $catid = requestVar('catid');\r
+\r
+               // create new category if needed\r
+               if (strstr($catid,'newcat')) {\r
+                       // get blogid\r
+                       list($blogid) = sscanf($catid,'newcat-%d');\r
+\r
+                       // create\r
+                       $blog =& $manager->getBlog($blogid);\r
+                       $catid = $blog->createNewCategory();\r
+\r
+                       // show error when sth goes wrong\r
+                       if (!$catid)\r
+                               $this->doError(_ERROR_CATCREATEFAIL);\r
+               }\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canUpdateItem($itemid, $catid) or $this->disallow();\r
+\r
+               $old_blogid = getBlogIDFromItemId($itemid);\r
+\r
+               ITEM::move($itemid, $catid);\r
+\r
+               // set the futurePosted flag on the blog\r
+               $this->updateFuturePosted(getBlogIDFromItemId($itemid));\r
+\r
+               // reset the futurePosted in case the item is moved from one blog to another\r
+               $this->updateFuturePosted($old_blogid);\r
+\r
+               if ($catid != intRequestVar('catid'))\r
+                       $this->action_categoryedit($catid, $blog->getID());\r
+               else\r
+                       $this->action_itemlist(getBlogIDFromCatID($catid));\r
+       }\r
+\r
+       /**\r
+        * Moves one item to a given category (category existance should be checked by caller)\r
+        * errors are returned\r
+        * @param int $itemid\r
+        * @param int $destCatid category ID to which the item will be moved\r
+        */\r
+       function moveOneItem($itemid, $destCatid) {\r
+               global $member;\r
+\r
+               // only allow if user is allowed to move item\r
+               if (!$member->canUpdateItem($itemid, $destCatid))\r
+                       return _ERROR_DISALLOWED;\r
+\r
+               ITEM::move($itemid, $destCatid);\r
+       }\r
+\r
+       /**\r
+        * Adds a item to the chosen blog\r
+        */\r
+       function action_additem() {\r
+               global $manager, $CONF;\r
+\r
+               $manager->loadClass('ITEM');\r
+\r
+               $result = ITEM::createFromRequest();\r
+\r
+               if ($result['status'] == 'error')\r
+                       $this->error($result['message']);\r
+\r
+               $blogid = getBlogIDFromItemID($result['itemid']);\r
+               $blog =& $manager->getBlog($blogid);\r
+               $btimestamp = $blog->getCorrectTime();\r
+               $item      = $manager->getItem(intval($result['itemid']), 1, 1);\r
+\r
+               if ($result['status'] == 'newcategory') {\r
+                       $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));\r
+                       $this->action_categoryedit($result['catid'], $blogid, $distURI);\r
+               } else {\r
+                       $methodName = 'action_itemList';\r
+                       call_user_func(array(&$this, $methodName), $blogid);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Allows to edit previously made comments\r
+        */\r
+       function action_commentedit() {\r
+               global $member, $manager;\r
+\r
+               $commentid = intRequestVar('commentid');\r
+\r
+               $member->canAlterComment($commentid) or $this->disallow();\r
+\r
+               $comment = COMMENT::getComment($commentid);\r
+\r
+               $manager->notify('PrepareCommentForEdit',array('comment' => &$comment));\r
+\r
+               // change <br /> to \n\r
+               $comment['body'] = str_replace('<br />','',$comment['body']);\r
+               \r
+               // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0\r
+               /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>", "\\1", $comment['body']) */\r
+               $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#I", "\\1", $comment['body']);\r
+               \r
+               $this->pagehead();\r
+\r
+               ?>\r
+               <h2><?php echo _EDITC_TITLE?></h2>\r
+\r
+               <form action="index.php" method="post"><div>\r
+\r
+               <input type="hidden" name="action" value="commentupdate" />\r
+               <?php $manager->addTicketHidden(); ?>\r
+               <input type="hidden" name="commentid" value="<?php echo  $commentid; ?>" />\r
+               <table><tr>\r
+                       <th colspan="2"><?php echo _EDITC_TITLE?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _EDITC_WHO?></td>\r
+                       <td>\r
+                       <?php                      if ($comment['member'])\r
+                                       echo $comment['member'] . " (" . _EDITC_MEMBER . ")";\r
+                               else\r
+                                       echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";\r
+                       ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _EDITC_WHEN?></td>\r
+                       <td><?php echo  date("Y-m-d @ H:i",$comment['timestamp']); ?></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EDITC_HOST?></td>\r
+                       <td><?php echo  $comment['host']; ?></td>\r
+               </tr>\r
+               <tr>\r
+                       <td><?php echo _EDITC_URL; ?></td>\r
+                       <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>\r
+               </tr>\r
+               <tr>\r
+                       <td><?php echo _EDITC_EMAIL; ?></td>\r
+                       <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>\r
+               </tr>\r
+               <tr>\r
+                       <td><?php echo _EDITC_TEXT?></td>\r
+                       <td>\r
+                               <textarea name="body" tabindex="10" rows="10" cols="50"><?php                              // htmlspecialchars not needed (things should be escaped already)\r
+                                       echo $comment['body'];\r
+                               ?></textarea>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _EDITC_EDIT?></td>\r
+                       <td><input type="submit"  tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>\r
+               </tr></table>\r
+\r
+               </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_commentupdate() {\r
+               global $member, $manager;\r
+\r
+               $commentid = intRequestVar('commentid');\r
+\r
+               $member->canAlterComment($commentid) or $this->disallow();\r
+\r
+               $url = postVar('url');\r
+               $email = postVar('email');\r
+               $body = postVar('body');\r
+               \r
+               # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0\r
+               # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE\r
+               # important note that '\' must be matched with '\\\\' in preg* expressions\r
+               // intercept words that are too long\r
+               if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)\r
+               {\r
+                       $this->error(_ERROR_COMMENT_LONGWORD);\r
+               }\r
+               \r
+               // check length\r
+               if (strlen($body) < 3) {\r
+                       $this->error(_ERROR_COMMENT_NOCOMMENT);\r
+               }\r
+               if (strlen($body)>5000)\r
+               {\r
+                       $this->error(_ERROR_COMMENT_TOOLONG);\r
+               }\r
+               \r
+               // prepare body\r
+               $body = COMMENT::prepareBody($body);\r
+\r
+               // call plugins\r
+               $manager->notify('PreUpdateComment',array('body' => &$body));\r
+\r
+               $query =  'UPDATE '.sql_table('comment')\r
+                          . " SET cmail = '" . sql_real_escape_string($url) . "', cemail = '" . sql_real_escape_string($email) . "', cbody = '" . sql_real_escape_string($body) . "'"\r
+                          . " WHERE cnumber=" . $commentid;\r
+               sql_query($query);\r
+\r
+               // get itemid\r
+               $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);\r
+               $o = sql_fetch_object($res);\r
+               $itemid = $o->citem;\r
+\r
+               if ($member->canAlterItem($itemid))\r
+                       $this->action_itemcommentlist($itemid);\r
+               else\r
+                       $this->action_browseowncomments();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_commentdelete() {\r
+               global $member, $manager;\r
+\r
+               $commentid = intRequestVar('commentid');\r
+\r
+               $member->canAlterComment($commentid) or $this->disallow();\r
+\r
+               $comment = COMMENT::getComment($commentid);\r
+\r
+               $body = strip_tags($comment['body']);\r
+               $body = htmlspecialchars(shorten($body, 300, '...'));\r
+\r
+               if ($comment['member'])\r
+                       $author = $comment['member'];\r
+               else\r
+                       $author = $comment['user'];\r
+\r
+               $this->pagehead();\r
+               ?>\r
+\r
+                       <h2><?php echo _DELETE_CONFIRM?></h2>\r
+\r
+                       <p><?php echo _CONFIRMTXT_COMMENT?></p>\r
+\r
+                       <div class="note">\r
+                       <b><?php echo _EDITC_WHO?>:</b> <?php echo  $author ?>\r
+                       <br />\r
+                       <b><?php echo _EDITC_TEXT?>:</b> <?php echo  $body ?>\r
+                       </div>\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                               <input type="hidden" name="action" value="commentdeleteconfirm" />\r
+                               <?php $manager->addTicketHidden() ?>\r
+                               <input type="hidden" name="commentid" value="<?php echo  $commentid; ?>" />\r
+                               <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_commentdeleteconfirm() {\r
+               global $member;\r
+\r
+               $commentid = intRequestVar('commentid');\r
+\r
+               // get item id first\r
+               $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);\r
+               $o = sql_fetch_object($res);\r
+               $itemid = $o->citem;\r
+\r
+               $error = $this->deleteOneComment($commentid);\r
+               if ($error)\r
+                       $this->doError($error);\r
+\r
+               if ($member->canAlterItem($itemid))\r
+                       $this->action_itemcommentlist($itemid);\r
+               else\r
+                       $this->action_browseowncomments();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function deleteOneComment($commentid) {\r
+               global $member, $manager;\r
+\r
+               $commentid = intval($commentid);\r
+\r
+               if (!$member->canAlterComment($commentid))\r
+                       return _ERROR_DISALLOWED;\r
+\r
+               $manager->notify('PreDeleteComment', array('commentid' => $commentid));\r
+\r
+               // delete the comments associated with the item\r
+               $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;\r
+               sql_query($query);\r
+\r
+               $manager->notify('PostDeleteComment', array('commentid' => $commentid));\r
+\r
+               return '';\r
+       }\r
+\r
+       /**\r
+        * Usermanagement main\r
+        */\r
+       function action_usermanagement() {\r
+               global $member, $manager;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';\r
+\r
+               echo '<h2>' . _MEMBERS_TITLE .'</h2>';\r
+\r
+               echo '<h3>' . _MEMBERS_CURRENT .'</h3>';\r
+\r
+               // show list of members with actions\r
+               $query =  'SELECT *'\r
+                          . ' FROM '.sql_table('member');\r
+               $template['content'] = 'memberlist';\r
+               $template['tabindex'] = 10;\r
+\r
+               $manager->loadClass("ENCAPSULATE");\r
+               $batch =& new BATCH('member');\r
+               $batch->showlist($query,'table',$template);\r
+\r
+               echo '<h3>' . _MEMBERS_NEW .'</h3>';\r
+               ?>\r
+                       <form method="post" action="index.php" name="memberedit"><div>\r
+\r
+                       <input type="hidden" name="action" value="memberadd" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+\r
+                       <table>\r
+                       <tr>\r
+                               <th colspan="2"><?php echo _MEMBERS_NEW?></th>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>\r
+                               <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>\r
+                               </td>\r
+                               <td><input tabindex="10010" name="name" size="32" maxlength="32" /></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_REALNAME?></td>\r
+                               <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_PWD?></td>\r
+                               <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_REPPWD?></td>\r
+                               <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_EMAIL?></td>\r
+                               <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_URL?></td>\r
+                               <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>\r
+                               <td><?php $this->input_yesno('admin',0,10060); ?> </td>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>\r
+                               <td><?php $this->input_yesno('canlogin',1,10070); ?></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_NOTES?></td>\r
+                               <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_NEW?></td>\r
+                               <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>\r
+                       </tr></table>\r
+\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Edit member settings\r
+        */\r
+       function action_memberedit() {\r
+               $this->action_editmembersettings(intRequestVar('memberid'));\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_editmembersettings($memberid = '') {\r
+               global $member, $manager, $CONF;\r
+\r
+               if ($memberid == '')\r
+                       $memberid = $member->getID();\r
+\r
+               // check if allowed\r
+               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();\r
+\r
+               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';\r
+               $this->pagehead($extrahead);\r
+\r
+               // show message to go back to member overview (only for admins)\r
+               if ($member->isAdmin())\r
+                       echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';\r
+               else\r
+                       echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';\r
+\r
+               echo '<h2>' . _MEMBERS_EDIT . '</h2>';\r
+\r
+               $mem = MEMBER::createFromID($memberid);\r
+\r
+               ?>\r
+               <form method="post" action="index.php" name="memberedit"><div>\r
+\r
+               <input type="hidden" name="action" value="changemembersettings" />\r
+               <input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />\r
+               <?php $manager->addTicketHidden() ?>\r
+\r
+               <table><tr>\r
+                       <th colspan="2"><?php echo _MEMBERS_EDIT?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>\r
+                               <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>\r
+                       </td>\r
+                       <td>\r
+                       <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>\r
+                               <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo  htmlspecialchars($mem->getDisplayName()); ?>" />\r
+                       <?php } else {\r
+                               echo htmlspecialchars($member->getDisplayName());\r
+                          }\r
+                       ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _MEMBERS_REALNAME?></td>\r
+                       <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo  htmlspecialchars($mem->getRealName()); ?>" /></td>\r
+               </tr><tr>\r
+               <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>\r
+                       <td><?php echo _MEMBERS_PWD?></td>\r
+                       <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _MEMBERS_REPPWD?></td>\r
+                       <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>\r
+               <?php } ?>\r
+               </tr><tr>\r
+                       <td><?php echo _MEMBERS_EMAIL?>\r
+                               <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>\r
+                       </td>\r
+                       <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo  htmlspecialchars($mem->getEmail()); ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _MEMBERS_URL?></td>\r
+                       <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo  htmlspecialchars($mem->getURL()); ?>" /></td>\r
+               <?php // only allow to change this by super-admins\r
+                  // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)\r
+                  if ($member->isAdmin()) {\r
+               ?>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>\r
+                               <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>\r
+                               <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>\r
+               <?php } ?>\r
+               </tr><tr>\r
+                       <td><?php echo _MEMBERS_NOTES?></td>\r
+                       <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo  htmlspecialchars($mem->getNotes()); ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>\r
+                       </td>\r
+                       <td>\r
+\r
+                               <select name="deflang" tabindex="85">\r
+                                       <option value=""><?php echo _MEMBERS_USESITELANG?></option>\r
+                               <?php                      // show a dropdown list of all available languages\r
+                               global $DIR_LANG;\r
+                               $dirhandle = opendir($DIR_LANG);\r
+                               while ($filename = readdir($dirhandle))\r
+                               {\r
+                                       # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0\r
+                                       # original ereg: ereg("^(.*)\.php$", $filename, $matches)\r
+                                       if (preg_match('#^(.*)\.php$#', $filename, $matches) )\r
+                                       {\r
+                                               $name = $matches[1];\r
+                                               echo "<option value=\"$name\"";\r
+                                               if ($name == $mem->getLanguage() )\r
+                                               {\r
+                                                       echo " selected=\"selected\"";\r
+                                               }\r
+                                               echo ">$name</option>";\r
+                                       }\r
+                               }\r
+                               closedir($dirhandle);\r
+                               \r
+                               ?>\r
+                               </select>\r
+\r
+                       </td>\r
+               </tr>\r
+               <tr>\r
+                       <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>\r
+                       <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>\r
+               </tr>\r
+               <?php\r
+                       // plugin options\r
+                       $this->_insertPluginOptions('member',$memberid);\r
+               ?>\r
+               <tr>\r
+                       <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _MEMBERS_EDIT?></td>\r
+                       <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>\r
+               </tr></table>\r
+\r
+               </div></form>\r
+\r
+               <?php\r
+                       echo '<h3>',_PLUGINS_EXTRA,'</h3>';\r
+\r
+                       $manager->notify(\r
+                               'MemberSettingsFormExtras',\r
+                               array(\r
+                                       'member' => &$mem\r
+                               )\r
+                       );\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_changemembersettings() {\r
+               global $member, $CONF, $manager;\r
+\r
+               $memberid = intRequestVar('memberid');\r
+\r
+               // check if allowed\r
+               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();\r
+\r
+               $name              = trim(strip_tags(postVar('name')));\r
+               $realname          = trim(strip_tags(postVar('realname')));\r
+               $password          = postVar('password');\r
+               $repeatpassword = postVar('repeatpassword');\r
+               $email            = strip_tags(postVar('email'));\r
+               $url                    = strip_tags(postVar('url'));\r
+\r
+               # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0\r
+               # original eregi: !eregi("^https?://", $url)\r
+               // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.\r
+               if (!preg_match('#^https?://#', $url) )\r
+               {\r
+                       $url = "http://" . $url;\r
+               }\r
+               $admin            = postVar('admin');\r
+               $canlogin          = postVar('canlogin');\r
+               $notes            = strip_tags(postVar('notes'));\r
+               $deflang                = postVar('deflang');\r
+\r
+               $mem = MEMBER::createFromID($memberid);\r
+\r
+               if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {\r
+\r
+                       if (!isValidDisplayName($name))\r
+                               $this->error(_ERROR_BADNAME);\r
+\r
+                       if (($name != $mem->getDisplayName()) && MEMBER::exists($name))\r
+                               $this->error(_ERROR_NICKNAMEINUSE);\r
+\r
+                       if ($password != $repeatpassword)\r
+                               $this->error(_ERROR_PASSWORDMISMATCH);\r
+\r
+                       if ($password && (strlen($password) < 6))\r
+                               $this->error(_ERROR_PASSWORDTOOSHORT);\r
+\r
+                       if ($password) {\r
+                               $pwdvalid = true;\r
+                               $pwderror = '';\r
+                               $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));\r
+                               if (!$pwdvalid) {\r
+                                       $this->error($pwderror);\r
+                               }\r
+                       }\r
+               }\r
+\r
+               if (!isValidMailAddress($email))\r
+                       $this->error(_ERROR_BADMAILADDRESS);\r
+\r
+\r
+               if (!$realname)\r
+                       $this->error(_ERROR_REALNAMEMISSING);\r
+\r
+               if (($deflang != '') && (!checkLanguage($deflang)))\r
+                       $this->error(_ERROR_NOSUCHLANGUAGE);\r
+\r
+               // check if there will remain at least one site member with both the logon and admin rights\r
+               // (check occurs when taking away one of these rights from such a member)\r
+               if (    (!$admin && $mem->isAdmin() && $mem->canLogin())\r
+                        || (!$canlogin && $mem->isAdmin() && $mem->canLogin())\r
+                  )\r
+               {\r
+                       $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');\r
+                       if (sql_num_rows($r) < 2)\r
+                               $this->error(_ERROR_ATLEASTONEADMIN);\r
+               }\r
+\r
+               if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {\r
+                       $mem->setDisplayName($name);\r
+                       if ($password)\r
+                               $mem->setPassword($password);\r
+               }\r
+\r
+               $oldEmail = $mem->getEmail();\r
+\r
+               $mem->setRealName($realname);\r
+               $mem->setEmail($email);\r
+               $mem->setURL($url);\r
+               $mem->setNotes($notes);\r
+               $mem->setLanguage($deflang);\r
+\r
+\r
+               // only allow super-admins to make changes to the admin status\r
+               if ($member->isAdmin()) {\r
+                       $mem->setAdmin($admin);\r
+                       $mem->setCanLogin($canlogin);\r
+               }\r
+\r
+               $autosave = postVar ('autosave');\r
+               $mem->setAutosave($autosave);\r
+\r
+               $mem->write();\r
+\r
+               // store plugin options\r
+               $aOptions = requestArray('plugoption');\r
+               NucleusPlugin::_applyPluginOptions($aOptions);\r
+               $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));\r
+\r
+               // if email changed, generate new password\r
+               if ($oldEmail != $mem->getEmail())\r
+               {\r
+                       $mem->sendActivationLink('addresschange', $oldEmail);\r
+                       // logout member\r
+                       $mem->newCookieKey();\r
+\r
+                       // only log out if the member being edited is the current member.\r
+                       if ($member->getID() == $memberid)\r
+                               $member->logout();\r
+                       $this->action_login(_MSG_ACTIVATION_SENT, 0);\r
+                       return;\r
+               }\r
+\r
+\r
+               if (  ( $mem->getID() == $member->getID() )\r
+                  && ( $mem->getDisplayName() != $member->getDisplayName() )\r
+                  ) {\r
+                       $mem->newCookieKey();\r
+                       $member->logout();\r
+                       $this->action_login(_MSG_LOGINAGAIN, 0);\r
+               } else {\r
+                       $this->action_overview(_MSG_SETTINGSCHANGED);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_memberadd() {\r
+               global $member, $manager;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               if (postVar('password') != postVar('repeatpassword'))\r
+                       $this->error(_ERROR_PASSWORDMISMATCH);\r
+               if (strlen(postVar('password')) < 6)\r
+                       $this->error(_ERROR_PASSWORDTOOSHORT);\r
+\r
+               $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));\r
+               if ($res != 1)\r
+                       $this->error($res);\r
+\r
+               // fire PostRegister event\r
+               $newmem = new MEMBER();\r
+               $newmem->readFromName(postVar('name'));\r
+               $manager->notify('PostRegister',array('member' => &$newmem));\r
+\r
+               $this->action_usermanagement();\r
+       }\r
+\r
+       /**\r
+        * Account activation\r
+        *\r
+        * @author dekarma\r
+        */\r
+       function action_activate() {\r
+\r
+               $key = getVar('key');\r
+               $this->_showActivationPage($key);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function _showActivationPage($key, $message = '')\r
+       {\r
+               global $manager;\r
+\r
+               // clean up old activation keys\r
+               MEMBER::cleanupActivationTable();\r
+\r
+               // get activation info\r
+               $info = MEMBER::getActivationInfo($key);\r
+\r
+               if (!$info)\r
+                       $this->error(_ERROR_ACTIVATE);\r
+\r
+               $mem = MEMBER::createFromId($info->vmember);\r
+\r
+               if (!$mem)\r
+                       $this->error(_ERROR_ACTIVATE);\r
+\r
+               $text = '';\r
+               $title = '';\r
+               $bNeedsPasswordChange = true;\r
+\r
+               switch ($info->vtype)\r
+               {\r
+                       case 'forgot':\r
+                               $title = _ACTIVATE_FORGOT_TITLE;\r
+                               $text = _ACTIVATE_FORGOT_TEXT;\r
+                               break;\r
+                       case 'register':\r
+                               $title = _ACTIVATE_REGISTER_TITLE;\r
+                               $text = _ACTIVATE_REGISTER_TEXT;\r
+                               break;\r
+                       case 'addresschange':\r
+                               $title = _ACTIVATE_CHANGE_TITLE;\r
+                               $text = _ACTIVATE_CHANGE_TEXT;\r
+                               $bNeedsPasswordChange = false;\r
+                               MEMBER::activate($key);\r
+                               break;\r
+               }\r
+\r
+               $aVars = array(\r
+                       'memberName' => htmlspecialchars($mem->getDisplayName())\r
+               );\r
+               $title = TEMPLATE::fill($title, $aVars);\r
+               $text = TEMPLATE::fill($text, $aVars);\r
+\r
+               $this->pagehead();\r
+\r
+                       echo '<h2>' , $title, '</h2>';\r
+                       echo '<p>' , $text, '</p>';\r
+\r
+                       if ($message != '')\r
+                       {\r
+                               echo '<p class="error">',$message,'</p>';\r
+                       }\r
+\r
+                       if ($bNeedsPasswordChange)\r
+                       {\r
+                               ?>\r
+                                       <div><form action="index.php" method="post">\r
+\r
+                                               <input type="hidden" name="action" value="activatesetpwd" />\r
+                                               <?php $manager->addTicketHidden() ?>\r
+                                               <input type="hidden" name="key" value="<?php echo htmlspecialchars($key) ?>" />\r
+\r
+                                               <table><tr>\r
+                                                       <td><?php echo _MEMBERS_PWD?></td>\r
+                                                       <td><input type="password" maxlength="40" size="16" name="password" /></td>\r
+                                               </tr><tr>\r
+                                                       <td><?php echo _MEMBERS_REPPWD?></td>\r
+                                                       <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>\r
+                                               <?php\r
+\r
+                                                       global $manager;\r
+                                                       $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));\r
+\r
+                                               ?>\r
+                                               </tr><tr>\r
+                                                       <td><?php echo _MEMBERS_SETPWD ?></td>\r
+                                                       <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>\r
+                                               </tr></table>\r
+\r
+\r
+                                       </form></div>\r
+\r
+                               <?php\r
+\r
+                       }\r
+\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * Account activation - set password part\r
+        *\r
+        * @author dekarma\r
+        */\r
+       function action_activatesetpwd() {\r
+               \r
+               $key = postVar('key');\r
+\r
+               // clean up old activation keys\r
+               MEMBER::cleanupActivationTable();\r
+\r
+               // get activation info\r
+               $info = MEMBER::getActivationInfo($key);\r
+\r
+               if (!$info || ($info->type == 'addresschange'))\r
+                       return $this->_showActivationPage($key, _ERROR_ACTIVATE);\r
+\r
+               $mem = MEMBER::createFromId($info->vmember);\r
+\r
+               if (!$mem)\r
+                       return $this->_showActivationPage($key, _ERROR_ACTIVATE);\r
+\r
+               $password          = postVar('password');\r
+               $repeatpassword = postVar('repeatpassword');\r
+\r
+               if ($password != $repeatpassword)\r
+                       return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);\r
+\r
+               if ($password && (strlen($password) < 6))\r
+                       return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);\r
+               \r
+               if ($password) {\r
+                       $pwdvalid = true;\r
+                       $pwderror = '';\r
+                       global $manager;\r
+                       $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));\r
+                       if (!$pwdvalid) {\r
+                               return $this->_showActivationPage($key,$pwderror);\r
+                       }\r
+               }\r
+               $error = '';\r
+               $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));\r
+               if ($error != '')\r
+                       return $this->_showActivationPage($key, $error);\r
+\r
+\r
+               // set password\r
+               $mem->setPassword($password);\r
+               $mem->write();\r
+\r
+               // do the activation\r
+               MEMBER::activate($key);\r
+\r
+               $this->pagehead();\r
+                       echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';\r
+                       echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Manage team\r
+        */\r
+       function action_manageteam() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               // check if allowed\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $this->pagehead();\r
+\r
+               echo "<p><a href='index.php?action=blogsettings&amp;blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";\r
+\r
+               echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';\r
+\r
+               echo '<h3>' . _TEAM_CURRENT . '</h3>';\r
+\r
+\r
+\r
+               $query =  'SELECT tblog, tmember, mname, mrealname, memail, tadmin'\r
+                          . ' FROM '.sql_table('member').', '.sql_table('team')\r
+                          . ' WHERE tmember=mnumber and tblog=' . $blogid;\r
+\r
+               $template['content'] = 'teamlist';\r
+               $template['tabindex'] = 10;\r
+\r
+               $manager->loadClass("ENCAPSULATE");\r
+               $batch =& new BATCH('team');\r
+               $batch->showlist($query, 'table', $template);\r
+\r
+               ?>\r
+                       <h3><?php echo _TEAM_ADDNEW?></h3>\r
+\r
+                       <form method='post' action='index.php'><div>\r
+\r
+                       <input type='hidden' name='action' value='teamaddmember' />\r
+                       <input type='hidden' name='blogid' value='<?php echo  $blogid; ?>' />\r
+                       <?php $manager->addTicketHidden() ?>\r
+\r
+                       <table><tr>\r
+                               <td><?php echo _TEAM_CHOOSEMEMBER?></td>\r
+                               <td><?php                                  // TODO: try to make it so only non-team-members are listed\r
+                                       $query =  'SELECT mname as text, mnumber as value'\r
+                                                  . ' FROM '.sql_table('member');\r
+\r
+                                       $template['name'] = 'memberid';\r
+                                       $template['tabindex'] = 10000;\r
+                                       showlist($query,'select',$template);\r
+                               ?></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>\r
+                               <td><?php $this->input_yesno('admin',0,10020); ?></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _TEAM_ADD?></td>\r
+                               <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>\r
+                       </tr></table>\r
+\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Add member to team\r
+        */\r
+       function action_teamaddmember() {\r
+               global $member, $manager;\r
+\r
+               $memberid = intPostVar('memberid');\r
+               $blogid = intPostVar('blogid');\r
+               $admin = intPostVar('admin');\r
+\r
+               // check if allowed\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+               if (!$blog->addTeamMember($memberid, $admin))\r
+                       $this->error(_ERROR_ALREADYONTEAM);\r
+\r
+               $this->action_manageteam();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_teamdelete() {\r
+               global $member, $manager;\r
+\r
+               $memberid = intRequestVar('memberid');\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               // check if allowed\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $teammem = MEMBER::createFromID($memberid);\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $this->pagehead();\r
+               ?>\r
+                       <h2><?php echo _DELETE_CONFIRM?></h2>\r
+\r
+                       <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>\r
+                       </p>\r
+\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                       <input type="hidden" name="action" value="teamdeleteconfirm" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />\r
+                       <input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />\r
+                       <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_teamdeleteconfirm() {\r
+               global $member;\r
+\r
+               $memberid = intRequestVar('memberid');\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $error = $this->deleteOneTeamMember($blogid, $memberid);\r
+               if ($error)\r
+                       $this->error($error);\r
+\r
+\r
+               $this->action_manageteam();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function deleteOneTeamMember($blogid, $memberid) {\r
+               global $member, $manager;\r
+\r
+               $blogid = intval($blogid);\r
+               $memberid = intval($memberid);\r
+\r
+               // check if allowed\r
+               if (!$member->blogAdminRights($blogid))\r
+                       return _ERROR_DISALLOWED;\r
+\r
+               // check if: - there remains at least one blog admin\r
+               //                 - (there remains at least one team member)\r
+               $tmem = MEMBER::createFromID($memberid);\r
+\r
+               $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));\r
+\r
+               if ($tmem->isBlogAdmin($blogid)) {\r
+                       // check if there are more blog members left and at least one admin\r
+                       // (check for at least two admins before deletion)\r
+                       $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';\r
+                       $r = sql_query($query);\r
+                       if (sql_num_rows($r) < 2)\r
+                               return _ERROR_ATLEASTONEBLOGADMIN;\r
+               }\r
+\r
+               $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";\r
+               sql_query($query);\r
+\r
+               $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));\r
+\r
+               return '';\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_teamchangeadmin() {\r
+               global $member;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+               $memberid = intRequestVar('memberid');\r
+\r
+               // check if allowed\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $mem = MEMBER::createFromID($memberid);\r
+\r
+               // don't allow when there is only one admin at this moment\r
+               if ($mem->isBlogAdmin($blogid)) {\r
+                       $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");\r
+                       if (sql_num_rows($r) == 1)\r
+                               $this->error(_ERROR_ATLEASTONEBLOGADMIN);\r
+               }\r
+\r
+               if ($mem->isBlogAdmin($blogid))\r
+                       $newval = 0;\r
+               else\r
+                       $newval = 1;\r
+\r
+               $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";\r
+               sql_query($query);\r
+\r
+               // only show manageteam if member did not change its own admin privileges\r
+               if ($member->isBlogAdmin($blogid))\r
+                       $this->action_manageteam();\r
+               else\r
+                       $this->action_overview(_MSG_ADMINCHANGED);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_blogsettings() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               // check if allowed\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';\r
+               $this->pagehead($extrahead);\r
+\r
+               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';\r
+               ?>\r
+               <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>\r
+\r
+               <h3><?php echo _EBLOG_TEAM_TITLE?></h3>\r
+\r
+               <p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>\r
+               <?php\r
+                       $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));\r
+                       $aMemberNames = array();\r
+                       while ($o = sql_fetch_object($res))\r
+                               array_push($aMemberNames, htmlspecialchars($o->mname) . ' (' . htmlspecialchars($o->mrealname). ')');\r
+                       echo implode(',', $aMemberNames);\r
+               ?>\r
+               </p>\r
+\r
+\r
+\r
+               <p>\r
+               <a href="index.php?action=manageteam&amp;blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>\r
+               </p>\r
+\r
+               <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>\r
+\r
+               <form method="post" action="index.php"><div>\r
+\r
+               <input type="hidden" name="action" value="blogsettingsupdate" />\r
+               <?php $manager->addTicketHidden() ?>\r
+               <input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />\r
+               <table><tr>\r
+                       <td><?php echo _EBLOG_NAME?></td>\r
+                       <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo  htmlspecialchars($blog->getName()) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>\r
+                               <?php echo _EBLOG_SHORTNAME_EXTRA?>\r
+                       </td>\r
+                       <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo  htmlspecialchars($blog->getShortName()) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_DESC?></td>\r
+                       <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo  htmlspecialchars($blog->getDescription()) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_URL?></td>\r
+                       <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo  htmlspecialchars($blog->getURL()) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_DEFSKIN?>\r
+                               <?php help('blogdefaultskin'); ?>\r
+                       </td>\r
+                       <td>\r
+                               <?php\r
+                                       $query =  'SELECT sdname as text, sdnumber as value'\r
+                                                  . ' FROM '.sql_table('skin_desc');\r
+                                       $template['name'] = 'defskin';\r
+                                       $template['selected'] = $blog->getDefaultSkin();\r
+                                       $template['tabindex'] = 50;\r
+                                       showlist($query,'select',$template);\r
+                               ?>\r
+\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>\r
+                       </td>\r
+                       <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>\r
+                       </td>\r
+                       <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_DISABLECOMMENTS?>\r
+                       </td>\r
+                       <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_ANONYMOUS?>\r
+                       </td>\r
+                       <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>\r
+               </tr><tr>\r
+       <td><?php echo _EBLOG_REQUIREDEMAIL?>\r
+                </td>\r
+                <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>\r
+         </tr><tr>\r
+                       <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>\r
+                       <td><input name="notify" tabindex="80" maxlength="128" size="40" value="<?php echo  htmlspecialchars($blog->getNotifyAddress()); ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_NOTIFY_ON?></td>\r
+                       <td>\r
+                               <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"\r
+                                       <?php if  ($blog->notifyOnComment()) echo "checked='checked'" ?>\r
+                               /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>\r
+                               <br />\r
+                               <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"\r
+                                       <?php if  ($blog->notifyOnVote()) echo "checked='checked'" ?>\r
+                               /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>\r
+                               <br />\r
+                               <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"\r
+                                       <?php if  ($blog->notifyOnNewItem()) echo "checked='checked'" ?>\r
+                               /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>\r
+                       <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo  htmlspecialchars($blog->getMaxComments()); ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>\r
+                       <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo  htmlspecialchars($blog->getUpdateFile()) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_DEFCAT?></td>\r
+                       <td>\r
+                               <?php\r
+                                       $query =  'SELECT cname as text, catid as value'\r
+                                                  . ' FROM '.sql_table('category')\r
+                                                  . ' WHERE cblog=' . $blog->getID();\r
+                                       $template['name'] = 'defcat';\r
+                                       $template['selected'] = $blog->getDefaultCategory();\r
+                                       $template['tabindex'] = 110;\r
+                                       showlist($query,'select',$template);\r
+                               ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>\r
+                               <br /><?php echo _EBLOG_STIME?> <b><?php echo  strftime("%H:%M",time()); ?></b>\r
+                               <br /><?php echo _EBLOG_BTIME?> <b><?php echo  strftime("%H:%M",$blog->getCorrectTime()); ?></b>\r
+                               </td>\r
+                       <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo  htmlspecialchars($blog->getTimeOffset()); ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>\r
+                       <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>\r
+               </tr>\r
+               <?php\r
+                       // plugin options\r
+                       $this->_insertPluginOptions('blog',$blogid);\r
+               ?>\r
+               <tr>\r
+                       <th colspan="2"><?php echo _EBLOG_CHANGE?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_CHANGE?></td>\r
+                       <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>\r
+               </tr></table>\r
+\r
+               </div></form>\r
+\r
+               <h3><?php echo _EBLOG_CAT_TITLE?></h3>\r
+\r
+\r
+               <?php\r
+               $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';\r
+               $template['content'] = 'categorylist';\r
+               $template['tabindex'] = 200;\r
+\r
+               $manager->loadClass("ENCAPSULATE");\r
+               $batch =& new BATCH('category');\r
+               $batch->showlist($query,'table',$template);\r
+\r
+               ?>\r
+\r
+\r
+               <form action="index.php" method="post"><div>\r
+               <input name="action" value="categorynew" type="hidden" />\r
+               <?php $manager->addTicketHidden() ?>\r
+               <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />\r
+\r
+               <table><tr>\r
+                       <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_CAT_NAME?></td>\r
+                       <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_CAT_DESC?></td>\r
+                       <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_CAT_CREATE?></td>\r
+                       <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>\r
+               </tr></table>\r
+\r
+               </div></form>\r
+\r
+               <?php\r
+\r
+                       echo '<h3>',_PLUGINS_EXTRA,'</h3>';\r
+\r
+                       $manager->notify(\r
+                               'BlogSettingsFormExtras',\r
+                               array(\r
+                                       'blog' => &$blog\r
+                               )\r
+                       );\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_categorynew() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $cname = postVar('cname');\r
+               $cdesc = postVar('cdesc');\r
+\r
+               if (!isValidCategoryName($cname))\r
+                       $this->error(_ERROR_BADCATEGORYNAME);\r
+\r
+               $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid);\r
+               $res = sql_query($query);\r
+               if (sql_num_rows($res) > 0)\r
+                       $this->error(_ERROR_DUPCATEGORYNAME);\r
+\r
+               $blog      =& $manager->getBlog($blogid);\r
+               $newCatID   =  $blog->createNewCategory($cname, $cdesc);\r
+\r
+               $this->action_blogsettings();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_categoryedit($catid = '', $blogid = '', $desturl = '') {\r
+               global $member, $manager;\r
+\r
+               if ($blogid == '')\r
+                       $blogid = intGetVar('blogid');\r
+               else\r
+                       $blogid = intval($blogid);\r
+               if ($catid == '')\r
+                       $catid = intGetVar('catid');\r
+               else\r
+                       $catid = intval($catid);\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");\r
+               $obj = sql_fetch_object($res);\r
+\r
+               $cname = $obj->cname;\r
+               $cdesc = $obj->cdesc;\r
+\r
+               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';\r
+               $this->pagehead($extrahead);\r
+\r
+               echo "<p><a href='index.php?action=blogsettings&amp;blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";\r
+\r
+               ?>\r
+               <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo htmlspecialchars($cname)?>'</h2>\r
+               <form method='post' action='index.php'><div>\r
+               <input name="blogid" type="hidden" value="<?php echo $blogid?>" />\r
+               <input name="catid" type="hidden" value="<?php echo $catid?>" />\r
+               <input name="desturl" type="hidden" value="<?php echo htmlspecialchars($desturl) ?>" />\r
+               <input name="action" type="hidden" value="categoryupdate" />\r
+               <?php $manager->addTicketHidden(); ?>\r
+\r
+               <table><tr>\r
+                       <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_CAT_NAME?></td>\r
+                       <td><input type="text" name="cname" value="<?php echo htmlspecialchars($cname)?>" size="40" maxlength="40" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_CAT_DESC?></td>\r
+                       <td><input type="text" name="cdesc" value="<?php echo htmlspecialchars($cdesc)?>" size="40" maxlength="200" /></td>\r
+               </tr>\r
+               <?php\r
+                       // insert plugin options\r
+                       $this->_insertPluginOptions('category',$catid);\r
+               ?>\r
+               <tr>\r
+                       <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_CAT_UPDATE?></td>\r
+                       <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>\r
+               </tr></table>\r
+\r
+               </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_categoryupdate() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intPostVar('blogid');\r
+               $catid = intPostVar('catid');\r
+               $cname = postVar('cname');\r
+               $cdesc = postVar('cdesc');\r
+               $desturl = postVar('desturl');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               if (!isValidCategoryName($cname))\r
+                       $this->error(_ERROR_BADCATEGORYNAME);\r
+\r
+               $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";\r
+               $res = sql_query($query);\r
+               if (sql_num_rows($res) > 0)\r
+                       $this->error(_ERROR_DUPCATEGORYNAME);\r
+\r
+               $query =  'UPDATE '.sql_table('category').' SET'\r
+                          . " cname='" . sql_real_escape_string($cname) . "',"\r
+                          . " cdesc='" . sql_real_escape_string($cdesc) . "'"\r
+                          . " WHERE catid=" . $catid;\r
+\r
+               sql_query($query);\r
+\r
+               // store plugin options\r
+               $aOptions = requestArray('plugoption');\r
+               NucleusPlugin::_applyPluginOptions($aOptions);\r
+               $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));\r
+\r
+\r
+               if ($desturl) {\r
+                       redirect($desturl);\r
+                       exit;\r
+               } else {\r
+                       $this->action_blogsettings();\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_categorydelete() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+               $catid = intRequestVar('catid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               // check if the category is valid\r
+               if (!$blog->isValidCategory($catid))\r
+                       $this->error(_ERROR_NOSUCHCATEGORY);\r
+\r
+               // don't allow deletion of default category\r
+               if ($blog->getDefaultCategory() == $catid)\r
+                       $this->error(_ERROR_DELETEDEFCATEGORY);\r
+\r
+               // check if catid is the only category left for blogid\r
+               $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;\r
+               $res = sql_query($query);\r
+               if (sql_num_rows($res) == 1)\r
+                       $this->error(_ERROR_DELETELASTCATEGORY);\r
+\r
+\r
+               $this->pagehead();\r
+               ?>\r
+                       <h2><?php echo _DELETE_CONFIRM?></h2>\r
+\r
+                       <div>\r
+                       <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo  htmlspecialchars($blog->getCategoryName($catid))?></b>\r
+                       </div>\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                       <input type="hidden" name="action" value="categorydeleteconfirm" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input type="hidden" name="blogid" value="<?php echo $blogid?>" />\r
+                       <input type="hidden" name="catid" value="<?php echo $catid?>" />\r
+                       <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_categorydeleteconfirm() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+               $catid = intRequestVar('catid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $error = $this->deleteOneCategory($catid);\r
+               if ($error)\r
+                       $this->error($error);\r
+\r
+               $this->action_blogsettings();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function deleteOneCategory($catid) {\r
+               global $manager, $member;\r
+\r
+               $catid = intval($catid);\r
+\r
+               $blogid = getBlogIDFromCatID($catid);\r
+\r
+               if (!$member->blogAdminRights($blogid))\r
+                       return ERROR_DISALLOWED;\r
+\r
+               // get blog\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               // check if the category is valid\r
+               if (!$blog || !$blog->isValidCategory($catid))\r
+                       return _ERROR_NOSUCHCATEGORY;\r
+\r
+               $destcatid = $blog->getDefaultCategory();\r
+\r
+               // don't allow deletion of default category\r
+               if ($blog->getDefaultCategory() == $catid)\r
+                       return _ERROR_DELETEDEFCATEGORY;\r
+\r
+               // check if catid is the only category left for blogid\r
+               $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;\r
+               $res = sql_query($query);\r
+               if (sql_num_rows($res) == 1)\r
+                       return _ERROR_DELETELASTCATEGORY;\r
+\r
+               $manager->notify('PreDeleteCategory', array('catid' => $catid));\r
+\r
+               // change category for all items to the default category\r
+               $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";\r
+               sql_query($query);\r
+\r
+               // delete all associated plugin options\r
+               NucleusPlugin::_deleteOptionValues('category', $catid);\r
+\r
+               // delete category\r
+               $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;\r
+               sql_query($query);\r
+\r
+               $manager->notify('PostDeleteCategory', array('catid' => $catid));\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function moveOneCategory($catid, $destblogid) {\r
+               global $manager, $member;\r
+\r
+               $catid = intval($catid);\r
+               $destblogid = intval($destblogid);\r
+\r
+               $blogid = getBlogIDFromCatID($catid);\r
+\r
+               // mover should have admin rights on both blogs\r
+               if (!$member->blogAdminRights($blogid))\r
+                       return _ERROR_DISALLOWED;\r
+               if (!$member->blogAdminRights($destblogid))\r
+                       return _ERROR_DISALLOWED;\r
+\r
+               // cannot move to self\r
+               if ($blogid == $destblogid)\r
+                       return _ERROR_MOVETOSELF;\r
+\r
+               // get blogs\r
+               $blog =& $manager->getBlog($blogid);\r
+               $destblog =& $manager->getBlog($destblogid);\r
+\r
+               // check if the category is valid\r
+               if (!$blog || !$blog->isValidCategory($catid))\r
+                       return _ERROR_NOSUCHCATEGORY;\r
+\r
+               // don't allow default category to be moved\r
+               if ($blog->getDefaultCategory() == $catid)\r
+                       return _ERROR_MOVEDEFCATEGORY;\r
+\r
+               $manager->notify(\r
+                       'PreMoveCategory',\r
+                       array(\r
+                               'catid' => &$catid,\r
+                               'sourceblog' => &$blog,\r
+                               'destblog' => &$destblog\r
+                       )\r
+               );\r
+\r
+               // update comments table (cblog)\r
+               $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;\r
+               $items = sql_query($query);\r
+               while ($oItem = sql_fetch_object($items)) {\r
+                       sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);\r
+               }\r
+\r
+               // update items (iblog)\r
+               $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;\r
+               sql_query($query);\r
+\r
+               // move category\r
+               $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;\r
+               sql_query($query);\r
+\r
+               $manager->notify(\r
+                       'PostMoveCategory',\r
+                       array(\r
+                               'catid' => &$catid,\r
+                               'sourceblog' => &$blog,\r
+                               'destblog' => $destblog\r
+                       )\r
+               );\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_blogsettingsupdate() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $notify          = trim(postVar('notify'));\r
+               $shortname        = trim(postVar('shortname'));\r
+               $updatefile      = trim(postVar('update'));\r
+\r
+               $notifyComment  = intPostVar('notifyComment');\r
+               $notifyVote      = intPostVar('notifyVote');\r
+               $notifyNewItem  = intPostVar('notifyNewItem');\r
+\r
+               if ($notifyComment == 0)        $notifyComment = 1;\r
+               if ($notifyVote == 0)      $notifyVote = 1;\r
+               if ($notifyNewItem == 0)        $notifyNewItem = 1;\r
+\r
+               $notifyType = $notifyComment * $notifyVote * $notifyNewItem;\r
+\r
+\r
+               if ($notify) {\r
+                       $not =& new NOTIFICATION($notify);\r
+                       if (!$not->validAddresses())\r
+                               $this->error(_ERROR_BADNOTIFY);\r
+\r
+               }\r
+\r
+               if (!isValidShortName($shortname))\r
+                       $this->error(_ERROR_BADSHORTBLOGNAME);\r
+\r
+               if (($blog->getShortName() != $shortname) && $manager->existsBlog($shortname))\r
+                       $this->error(_ERROR_DUPSHORTBLOGNAME);\r
+\r
+               // check if update file is writable\r
+               if ($updatefile && !is_writeable($updatefile))\r
+                       $this->error(_ERROR_UPDATEFILE);\r
+\r
+               $blog->setName(trim(postVar('name')));\r
+               $blog->setShortName($shortname);\r
+               $blog->setNotifyAddress($notify);\r
+               $blog->setNotifyType($notifyType);\r
+               $blog->setMaxComments(postVar('maxcomments'));\r
+               $blog->setCommentsEnabled(postVar('comments'));\r
+               $blog->setTimeOffset(postVar('timeoffset'));\r
+               $blog->setUpdateFile($updatefile);\r
+               $blog->setURL(trim(postVar('url')));\r
+               $blog->setDefaultSkin(intPostVar('defskin'));\r
+               $blog->setDescription(trim(postVar('desc')));\r
+               $blog->setPublic(postVar('public'));\r
+               $blog->setConvertBreaks(intPostVar('convertbreaks'));\r
+               $blog->setAllowPastPosting(intPostVar('allowpastposting'));\r
+               $blog->setDefaultCategory(intPostVar('defcat'));\r
+               $blog->setSearchable(intPostVar('searchable'));\r
+               $blog->setEmailRequired(intPostVar('reqemail'));\r
+\r
+               $blog->writeSettings();\r
+\r
+               // store plugin options\r
+               $aOptions = requestArray('plugoption');\r
+               NucleusPlugin::_applyPluginOptions($aOptions);\r
+               $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));\r
+\r
+\r
+               $this->action_overview(_MSG_SETTINGSCHANGED);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_deleteblog() {\r
+               global $member, $CONF, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               // check if blog is default blog\r
+               if ($CONF['DefaultBlog'] == $blogid)\r
+                       $this->error(_ERROR_DELDEFBLOG);\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $this->pagehead();\r
+               ?>\r
+                       <h2><?php echo _DELETE_CONFIRM?></h2>\r
+\r
+                       <p><?php echo _WARNINGTXT_BLOGDEL?>\r
+                       </p>\r
+\r
+                       <div>\r
+                       <?php echo _CONFIRMTXT_BLOG?><b><?php echo  htmlspecialchars($blog->getName())?></b>\r
+                       </div>\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                       <input type="hidden" name="action" value="deleteblogconfirm" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input type="hidden" name="blogid" value="<?php echo  $blogid; ?>" />\r
+                       <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_deleteblogconfirm() {\r
+               global $member, $CONF, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $manager->notify('PreDeleteBlog', array('blogid' => $blogid));\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               // check if blog is default blog\r
+               if ($CONF['DefaultBlog'] == $blogid)\r
+                       $this->error(_ERROR_DELDEFBLOG);\r
+\r
+               // delete all comments\r
+               $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;\r
+               sql_query($query);\r
+\r
+               // delete all items\r
+               $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;\r
+               sql_query($query);\r
+\r
+               // delete all team members\r
+               $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;\r
+               sql_query($query);\r
+\r
+               // delete all bans\r
+               $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;\r
+               sql_query($query);\r
+\r
+               // delete all categories\r
+               $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;\r
+               sql_query($query);\r
+\r
+               // delete all associated plugin options\r
+               NucleusPlugin::_deleteOptionValues('blog', $blogid);\r
+\r
+               // delete the blog itself\r
+               $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;\r
+               sql_query($query);\r
+\r
+               $manager->notify('PostDeleteBlog', array('blogid' => $blogid));\r
+\r
+               $this->action_overview(_DELETED_BLOG);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_memberdelete() {\r
+               global $member, $manager;\r
+\r
+               $memberid = intRequestVar('memberid');\r
+\r
+               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();\r
+\r
+               $mem = MEMBER::createFromID($memberid);\r
+\r
+               $this->pagehead();\r
+               ?>\r
+                       <h2><?php echo _DELETE_CONFIRM?></h2>\r
+\r
+                       <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo htmlspecialchars($mem->getDisplayName()) ?></b>\r
+                       </p>\r
+\r
+                       <p>\r
+                       <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>\r
+                       </p>\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                       <input type="hidden" name="action" value="memberdeleteconfirm" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input type="hidden" name="memberid" value="<?php echo  $memberid; ?>" />\r
+                       <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_memberdeleteconfirm() {\r
+               global $member;\r
+\r
+               $memberid = intRequestVar('memberid');\r
+\r
+               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();\r
+\r
+               $error = $this->deleteOneMember($memberid);\r
+               if ($error)\r
+                       $this->error($error);\r
+\r
+               if ($member->isAdmin())\r
+                       $this->action_usermanagement();\r
+               else\r
+                       $this->action_overview(_DELETED_MEMBER);\r
+       }\r
+\r
+       /**\r
+        * @static\r
+        * @todo document this\r
+        */\r
+       function deleteOneMember($memberid) {\r
+               global $manager;\r
+\r
+               $memberid = intval($memberid);\r
+               $mem = MEMBER::createFromID($memberid);\r
+\r
+               if (!$mem->canBeDeleted())\r
+                       return _ERROR_DELETEMEMBER;\r
+\r
+               $manager->notify('PreDeleteMember', array('member' => &$mem));\r
+\r
+               /* unlink comments from memberid */\r
+               if ($memberid) {\r
+                       $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. sql_real_escape_string($mem->getDisplayName())\r
+                                  .'" WHERE cmember='.$memberid;\r
+                       sql_query($query);\r
+               }\r
+\r
+               $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;\r
+               sql_query($query);\r
+\r
+               $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;\r
+               sql_query($query);\r
+\r
+               $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;\r
+               sql_query($query);\r
+\r
+               // delete all associated plugin options\r
+               NucleusPlugin::_deleteOptionValues('member', $memberid);\r
+\r
+               $manager->notify('PostDeleteMember', array('member' => &$mem));\r
+\r
+               return '';\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_createnewlog() {\r
+               global $member, $CONF, $manager;\r
+\r
+               // Only Super-Admins can do this\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';\r
+               ?>\r
+               <h2><?php echo _EBLOG_CREATE_TITLE?></h2>\r
+\r
+               <h3><?php echo _ADMIN_NOTABILIA ?></h3>\r
+\r
+               <p><?php echo _ADMIN_PLEASE_READ ?></p>\r
+\r
+               <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>\r
+\r
+               <ol>\r
+                       <li><?php echo _ADMIN_SIMPLE_WAY ?></li>\r
+                       <li><?php echo _ADMIN_ADVANCED_WAY ?></li>\r
+               </ol>\r
+\r
+               <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>\r
+\r
+               <p>\r
+               <?php echo _EBLOG_CREATE_TEXT?>\r
+               </p>\r
+\r
+               <form method="post" action="index.php"><div>\r
+\r
+               <input type="hidden" name="action" value="addnewlog" />\r
+               <?php $manager->addTicketHidden() ?>\r
+\r
+\r
+               <table><tr>\r
+                       <td><?php echo _EBLOG_NAME?></td>\r
+                       <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_SHORTNAME?>\r
+                               <?php help('shortblogname'); ?>\r
+                       </td>\r
+                       <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_DESC?></td>\r
+                       <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_DEFSKIN?>\r
+                               <?php help('blogdefaultskin'); ?>\r
+                       </td>\r
+                       <td>\r
+                               <?php\r
+                                       $query =  'SELECT sdname as text, sdnumber as value'\r
+                                                  . ' FROM '.sql_table('skin_desc');\r
+                                       $template['name'] = 'defskin';\r
+                                       $template['tabindex'] = 50;\r
+                                       $template['selected'] = $CONF['BaseSkin'];  // set default selected skin to be globally defined base skin\r
+                                       showlist($query,'select',$template);\r
+                               ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_OFFSET?>\r
+                               <?php help('blogtimeoffset'); ?>\r
+                               <br /><?php echo _EBLOG_STIME?> <b><?php echo  strftime("%H:%M",time()); ?></b>\r
+                       </td>\r
+                       <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_ADMIN?>\r
+                               <?php help('teamadmin'); ?>\r
+                       </td>\r
+                       <td><?php echo _EBLOG_ADMIN_MSG?></td>\r
+               </tr><tr>\r
+                       <td><?php echo _EBLOG_CREATE?></td>\r
+                       <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>\r
+               </tr></table>\r
+\r
+               </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_addnewlog() {\r
+               global $member, $manager, $CONF;\r
+\r
+               // Only Super-Admins can do this\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $bname            = trim(postVar('name'));\r
+               $bshortname      = trim(postVar('shortname'));\r
+               $btimeoffset    = postVar('timeoffset');\r
+               $bdesc            = trim(postVar('desc'));\r
+               $bdefskin          = postVar('defskin');\r
+\r
+               if (!isValidShortName($bshortname))\r
+                       $this->error(_ERROR_BADSHORTBLOGNAME);\r
+\r
+               if ($manager->existsBlog($bshortname))\r
+                       $this->error(_ERROR_DUPSHORTBLOGNAME);\r
+\r
+               $manager->notify(\r
+                       'PreAddBlog',\r
+                       array(\r
+                               'name'          => &$bname,\r
+                               'shortname'   => &$bshortname,\r
+                               'timeoffset'  => &$btimeoffset,\r
+                               'description' => &$bdesc,\r
+                               'defaultskin' => &$bdefskin\r
+                       )\r
+               );\r
+\r
+\r
+               // add slashes for sql queries\r
+               $bname     = sql_real_escape_string($bname);\r
+               $bshortname  = sql_real_escape_string($bshortname);\r
+               $btimeoffset = sql_real_escape_string($btimeoffset);\r
+               $bdesc     = sql_real_escape_string($bdesc);\r
+               $bdefskin       = sql_real_escape_string($bdefskin);\r
+\r
+               // create blog\r
+               $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";\r
+               sql_query($query);\r
+               $blogid = sql_insert_id();\r
+               $blog   =& $manager->getBlog($blogid);\r
+\r
+               // create new category\r
+               $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');\r
+               $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');\r
+               $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';\r
+               sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));\r
+//             sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");\r
+               $catid = sql_insert_id();\r
+\r
+               // set as default category\r
+               $blog->setDefaultCategory($catid);\r
+               $blog->writeSettings();\r
+\r
+               // create team member\r
+               $memberid = $member->getID();\r
+               $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";\r
+               sql_query($query);\r
+               \r
+               $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');\r
+               $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');\r
+               \r
+               $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);\r
+               //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);\r
+               \r
+               \r
+               \r
+               $manager->notify(\r
+                       'PostAddBlog',\r
+                       array(\r
+                               'blog' => &$blog\r
+                       )\r
+               );\r
+\r
+               $manager->notify(\r
+                       'PostAddCategory',\r
+                       array(\r
+                               'blog'          => &$blog,\r
+                               'name'          => _EBLOGDEFAULTCATEGORY_NAME,\r
+                               'description' => _EBLOGDEFAULTCATEGORY_DESC,\r
+                               'catid'    => $catid\r
+                       )\r
+               );\r
+\r
+               $this->pagehead();\r
+               ?>\r
+               <h2><?php echo _BLOGCREATED_TITLE ?></h2>\r
+\r
+               <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, htmlspecialchars($bname)) ?></p>\r
+\r
+               <ol>\r
+                       <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, htmlspecialchars($bshortname)) ?></a></li>\r
+                       <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>\r
+               </ol>\r
+\r
+               <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, htmlspecialchars($bshortname)) ?></a></h3>\r
+\r
+               <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, htmlspecialchars($bshortname)) ?></p>\r
+<pre><code>&lt;?php\r
+\r
+$CONF['Self'] = '<b><?php echo htmlspecialchars($bshortname)?>.php</b>';\r
+\r
+include('<i>./config.php</i>');\r
+\r
+selectBlog('<b><?php echo htmlspecialchars($bshortname)?></b>');\r
+selector();\r
+\r
+?&gt;</code></pre>\r
+\r
+               <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>\r
+\r
+               <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>\r
+\r
+               <form action="index.php" method="post"><div>\r
+                       <input type="hidden" name="action" value="addnewlog2" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />\r
+                       <table><tr>\r
+                               <td><?php echo _EBLOG_URL?></td>\r
+                               <td><input name="url" maxlength="100" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL'].$bshortname.'.php')?>" /></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _EBLOG_CREATE?></td>\r
+                               <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>\r
+                       </tr></table>\r
+               </div></form>\r
+\r
+               <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>\r
+\r
+               <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>\r
+\r
+               <form action="index.php" method="post"><div>\r
+                       <input type="hidden" name="action" value="addnewlog2" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />\r
+                       <table><tr>\r
+                               <td><?php echo _EBLOG_URL?></td>\r
+                               <td><input name="url" maxlength="100" size="40" /></td>\r
+                       </tr><tr>\r
+                               <td><?php echo _EBLOG_CREATE?></td>\r
+                               <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>\r
+                       </tr></table>\r
+               </div></form>\r
+\r
+               <?php      $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_addnewlog2() {\r
+               global $member, $manager;\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $burl   = requestVar('url');\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+               $blog->setURL(trim($burl));\r
+               $blog->writeSettings();\r
+\r
+               $this->action_overview(_MSG_NEWBLOG);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinieoverview() {\r
+               global $member, $DIR_LIBS, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinie.php');\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';\r
+\r
+       ?>\r
+               <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>\r
+\r
+                               <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>\r
+                               <?php                              global $DIR_SKINS;\r
+\r
+                                       $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);\r
+\r
+                                       if (sizeof($candidates) > 0) {\r
+                                               ?>\r
+                                                       <form method="post" action="index.php"><div>\r
+                                                               <input type="hidden" name="action" value="skinieimport" />\r
+                                                               <?php $manager->addTicketHidden() ?>\r
+                                                               <input type="hidden" name="mode" value="file" />\r
+                                                               <select name="skinfile" id="skinie_import_local">\r
+                                                               <?php                                                              foreach ($candidates as $skinname => $skinfile) {\r
+                                                                               $html = htmlspecialchars($skinfile);\r
+                                                                               echo '<option value="',$html,'">',$skinname,'</option>';\r
+                                                                       }\r
+                                                               ?>\r
+                                                               </select>\r
+                                                               <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />\r
+                                                       </div></form>\r
+                                               <?php                              } else {\r
+                                               echo _SKINIE_NOCANDIDATES;\r
+                                       }\r
+                               ?>\r
+                               </p>\r
+\r
+                               <p><em><?php echo _OR?></em></p>\r
+\r
+                               <form method="post" action="index.php"><p>\r
+                                       <?php $manager->addTicketHidden() ?>\r
+                                       <input type="hidden" name="action" value="skinieimport" />\r
+                                       <input type="hidden" name="mode" value="url" />\r
+                                       <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>\r
+                                       <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />\r
+                                       <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />\r
+                               </p></form>\r
+\r
+\r
+               <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>\r
+               <form method="post" action="index.php"><div>\r
+                       <input type="hidden" name="action" value="skinieexport" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+\r
+                       <p><?php echo _SKINIE_EXPORT_INTRO?></p>\r
+\r
+                       <table><tr>\r
+                               <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>\r
+                       </tr><tr>\r
+       <?php      // show list of skins\r
+               $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));\r
+               while ($skinObj = sql_fetch_object($res)) {\r
+                       $id = 'skinexp' . $skinObj->sdnumber;\r
+                       echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']"  id="',$id,'" />';\r
+                       echo '<label for="',$id,'">',htmlspecialchars($skinObj->sdname),'</label></td>';\r
+                       echo '<td>',htmlspecialchars($skinObj->sddesc),'</td>';\r
+                       echo '</tr><tr>';\r
+               }\r
+\r
+               echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';\r
+\r
+               // show list of templates\r
+               $res = sql_query('SELECT * FROM '.sql_table('template_desc'));\r
+               while ($templateObj = sql_fetch_object($res)) {\r
+                       $id = 'templateexp' . $templateObj->tdnumber;\r
+                       echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';\r
+                       echo '<label for="',$id,'">',htmlspecialchars($templateObj->tdname),'</label></td>';\r
+                       echo '<td>',htmlspecialchars($templateObj->tddesc),'</td>';\r
+                       echo '</tr><tr>';\r
+               }\r
+\r
+       ?>\r
+                               <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>\r
+                       </tr><tr>\r
+                               <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>\r
+                       </tr><tr>\r
+                               <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>\r
+                       </tr><tr>\r
+                               <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>\r
+                       </tr></table>\r
+               </div></form>\r
+\r
+       <?php\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinieimport() {\r
+               global $member, $DIR_LIBS, $DIR_SKINS, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinie.php');\r
+\r
+               $skinFileRaw= postVar('skinfile');\r
+               $mode      = postVar('mode');\r
+\r
+               $importer =& new SKINIMPORT();\r
+\r
+               // get full filename\r
+               if ($mode == 'file')\r
+               {\r
+                       $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';\r
+\r
+                       // backwards compatibilty (in v2.0, exports were saved as skindata.xml)\r
+                       if (!file_exists($skinFile))\r
+                               $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';\r
+               } else {\r
+                       $skinFile = $skinFileRaw;\r
+               }\r
+\r
+               // read only metadata\r
+               $error = $importer->readFile($skinFile, 1);\r
+\r
+               // clashes\r
+               $skinNameClashes = $importer->checkSkinNameClashes();\r
+               $templateNameClashes = $importer->checkTemplateNameClashes();\r
+               $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);\r
+\r
+               if ($error) $this->error($error);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';\r
+               ?>\r
+               <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>\r
+\r
+               <ul>\r
+                       <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>\r
+                       <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>\r
+                       <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>\r
+                       <?php\r
+                               if ($hasNameClashes)\r
+                               {\r
+                       ?>\r
+                       <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>\r
+                       <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>\r
+                       <?php\r
+                               } // if (hasNameClashes)\r
+                       ?>\r
+               </ul>\r
+\r
+               <form method="post" action="index.php"><div>\r
+                       <input type="hidden" name="action" value="skiniedoimport" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input type="hidden" name="skinfile" value="<?php echo htmlspecialchars(postVar('skinfile'))?>" />\r
+                       <input type="hidden" name="mode" value="<?php echo htmlspecialchars($mode)?>" />\r
+                       <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />\r
+                       <?php\r
+                               if ($hasNameClashes)\r
+                               {\r
+                       ?>\r
+                       <br />\r
+                       <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>\r
+                       <?php\r
+                               } // if (hasNameClashes)\r
+                       ?>\r
+               </div></form>\r
+\r
+\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skiniedoimport() {\r
+               global $member, $DIR_LIBS, $DIR_SKINS;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinie.php');\r
+\r
+               $skinFileRaw= postVar('skinfile');\r
+               $mode      = postVar('mode');\r
+\r
+               $allowOverwrite = intPostVar('overwrite');\r
+\r
+               // get full filename\r
+               if ($mode == 'file')\r
+               {\r
+                       $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';\r
+\r
+                       // backwards compatibilty (in v2.0, exports were saved as skindata.xml)\r
+                       if (!file_exists($skinFile))\r
+                               $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';\r
+\r
+               } else {\r
+                       $skinFile = $skinFileRaw;\r
+               }\r
+\r
+               $importer =& new SKINIMPORT();\r
+\r
+               $error = $importer->readFile($skinFile);\r
+\r
+               if ($error)\r
+                       $this->error($error);\r
+\r
+               $error = $importer->writeToDatabase($allowOverwrite);\r
+\r
+               if ($error)\r
+                       $this->error($error);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';\r
+       ?>\r
+               <h2><?php echo _SKINIE_DONE?></h2>\r
+\r
+               <ul>\r
+                       <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>\r
+                       <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>\r
+                       <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>\r
+               </ul>\r
+\r
+       <?php      $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinieexport() {\r
+               global $member, $DIR_LIBS;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinie.php');\r
+\r
+               $aSkins = requestIntArray('skin');\r
+               $aTemplates = requestIntArray('template');\r
+\r
+               if (!is_array($aTemplates)) $aTemplates = array();\r
+               if (!is_array($aSkins)) $aSkins = array();\r
+\r
+               $skinList = array_keys($aSkins);\r
+               $templateList = array_keys($aTemplates);\r
+\r
+               $info = postVar('info');\r
+\r
+               $exporter =& new SKINEXPORT();\r
+               foreach ($skinList as $skinId) {\r
+                       $exporter->addSkin($skinId);\r
+               }\r
+               foreach ($templateList as $templateId) {\r
+                       $exporter->addTemplate($templateId);\r
+               }\r
+               $exporter->setInfo($info);\r
+\r
+               $exporter->export();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templateoverview() {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';\r
+\r
+               echo '<h2>' . _TEMPLATE_TITLE . '</h2>';\r
+               echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';\r
+\r
+               $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';\r
+               $template['content'] = 'templatelist';\r
+               $template['tabindex'] = 10;\r
+               showlist($query,'table',$template);\r
+\r
+               echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';\r
+\r
+               ?>\r
+               <form method="post" action="index.php"><div>\r
+\r
+               <input name="action" value="templatenew" type="hidden" />\r
+               <?php $manager->addTicketHidden() ?>\r
+               <table><tr>\r
+                       <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>\r
+                       <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _TEMPLATE_DESC?></td>\r
+                       <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _TEMPLATE_CREATE?></td>\r
+                       <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>\r
+               </tr></table>\r
+\r
+               </div></form>\r
+\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templateedit($msg = '') {\r
+               global $member, $manager;\r
+\r
+               $templateid = intRequestVar('templateid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';\r
+               $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';\r
+\r
+               $this->pagehead($extrahead);\r
+\r
+               $templatename = TEMPLATE::getNameFromId($templateid);\r
+               $templatedescription = TEMPLATE::getDesc($templateid);\r
+               $template =& $manager->getTemplate($templatename);\r
+\r
+               ?>\r
+               <p>\r
+               <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>\r
+               </p>\r
+\r
+               <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo  htmlspecialchars($templatename); ?>'</h2>\r
+\r
+               <?php                              if ($msg) echo "<p>"._MESSAGE.": $msg</p>";\r
+               ?>\r
+\r
+               <p><?php echo _TEMPLATE_EDIT_MSG?></p>\r
+\r
+               <form method="post" action="index.php">\r
+               <div>\r
+\r
+               <input type="hidden" name="action" value="templateupdate" />\r
+               <?php $manager->addTicketHidden() ?>\r
+               <input type="hidden" name="templateid" value="<?php echo  $templateid; ?>" />\r
+\r
+               <table><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>\r
+                       <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo  htmlspecialchars($templatename) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _TEMPLATE_DESC?></td>\r
+                       <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo  htmlspecialchars($templatedescription) ?>" /></td>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _TEMPLATE_UPDATE?></td>\r
+                       <td>\r
+                               <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />\r
+                               <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />\r
+                       </td>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>\r
+<?php  $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);\r
+       $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);\r
+       $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);\r
+       $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);\r
+       $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);\r
+       $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>\r
+<?php  $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);\r
+       $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);\r
+       $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);\r
+       $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);\r
+       $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);\r
+       $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);\r
+       $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>\r
+<?php\r
+       $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>\r
+<?php  $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>\r
+<?php  $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);\r
+       $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);\r
+       $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>\r
+<?php  $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);\r
+       $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);\r
+       $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>\r
+<?php  $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);\r
+       $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);\r
+       $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>\r
+<?php  $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);\r
+       $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);\r
+       $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);\r
+       $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);\r
+       $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>\r
+<?php  $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);\r
+       $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);\r
+       $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>\r
+<?php  $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);\r
+       $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>\r
+<?php\r
+               $tab = 600;\r
+               $pluginfields = array();\r
+               $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));\r
+\r
+               foreach ($pluginfields as $pfkey=>$pfvalue) {\r
+                       echo "</tr><tr>\n";\r
+                       echo '<th colspan="2">'.htmlentities($pfkey)."</th>\n";\r
+                       foreach ($pfvalue as $pffield=>$pfdesc) {\r
+                               $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);\r
+                       }\r
+               }\r
+?>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _TEMPLATE_UPDATE?></td>\r
+                       <td>\r
+                               <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />\r
+                               <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />\r
+                       </td>\r
+               </tr></table>\r
+\r
+               </div>\r
+               </form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {\r
+               static $count = 1;\r
+               if (!isset($template[$name])) $template[$name] = '';\r
+       ?>\r
+               </tr><tr>\r
+                       <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>\r
+                       <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>\r
+       <?php      $count++;\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templateupdate() {\r
+               global $member, $manager;\r
+\r
+               $templateid = intRequestVar('templateid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $name = postVar('tname');\r
+               $desc = postVar('tdesc');\r
+\r
+               if (!isValidTemplateName($name))\r
+                       $this->error(_ERROR_BADTEMPLATENAME);\r
+\r
+               if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))\r
+                       $this->error(_ERROR_DUPTEMPLATENAME);\r
+\r
+\r
+               $name = sql_real_escape_string($name);\r
+               $desc = sql_real_escape_string($desc);\r
+\r
+               // 1. Remove all template parts\r
+               $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;\r
+               sql_query($query);\r
+\r
+               // 2. Update description\r
+               $query =  'UPDATE '.sql_table('template_desc').' SET'\r
+                          . " tdname='" . $name . "',"\r
+                          . " tddesc='" . $desc . "'"\r
+                          . " WHERE tdnumber=" . $templateid;\r
+               sql_query($query);\r
+\r
+               // 3. Add non-empty template parts\r
+               $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));\r
+               $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));\r
+               $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));\r
+               $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));\r
+               $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));\r
+               $this->addToTemplate($templateid, 'NEW', postVar('NEW'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));\r
+               $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));\r
+               $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));\r
+               $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));\r
+               $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));\r
+               $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));\r
+               $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));\r
+               $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));\r
+               $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));\r
+               $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));\r
+               $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));\r
+               $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));\r
+               $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));\r
+               $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));\r
+               $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));\r
+               $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));\r
+               $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));\r
+               $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));\r
+               $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));\r
+               $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));\r
+\r
+               $pluginfields = array();\r
+               $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));\r
+               foreach ($pluginfields as $pfkey=>$pfvalue) {\r
+                       foreach ($pfvalue as $pffield=>$pfdesc) {\r
+                               $this->addToTemplate($templateid, $pffield, postVar($pffield));\r
+                       }\r
+               }\r
+\r
+               // jump back to template edit\r
+               $this->action_templateedit(_TEMPLATE_UPDATED);\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function addToTemplate($id, $partname, $content) {\r
+               $partname = sql_real_escape_string($partname);\r
+               $content = sql_real_escape_string($content);\r
+\r
+               $id = intval($id);\r
+\r
+               // don't add empty parts:\r
+               if (!trim($content)) return -1;\r
+\r
+               $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "\r
+                          . "VALUES ($id, '$partname', '$content')";\r
+               sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());\r
+               return sql_insert_id();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templatedelete() {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $templateid = intRequestVar('templateid');\r
+               // TODO: check if template can be deleted\r
+\r
+               $this->pagehead();\r
+\r
+               $name = TEMPLATE::getNameFromId($templateid);\r
+               $desc = TEMPLATE::getDesc($templateid);\r
+\r
+               ?>\r
+                       <h2><?php echo _DELETE_CONFIRM?></h2>\r
+\r
+                       <p>\r
+                       <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo htmlspecialchars($name)?></b> (<?php echo  htmlspecialchars($desc) ?>)\r
+                       </p>\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                               <input type="hidden" name="action" value="templatedeleteconfirm" />\r
+                               <?php $manager->addTicketHidden() ?>\r
+                               <input type="hidden" name="templateid" value="<?php echo  $templateid ?>" />\r
+                               <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templatedeleteconfirm() {\r
+               global $member, $manager;\r
+\r
+               $templateid = intRequestVar('templateid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));\r
+\r
+               // 1. delete description\r
+               sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);\r
+\r
+               // 2. delete parts\r
+               sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);\r
+\r
+               $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));\r
+\r
+               $this->action_templateoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templatenew() {\r
+               global $member;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $name = postVar('name');\r
+               $desc = postVar('desc');\r
+\r
+               if (!isValidTemplateName($name))\r
+                       $this->error(_ERROR_BADTEMPLATENAME);\r
+\r
+               if (TEMPLATE::exists($name))\r
+                       $this->error(_ERROR_DUPTEMPLATENAME);\r
+\r
+               $newTemplateId = TEMPLATE::createNew($name, $desc);\r
+\r
+               $this->action_templateoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templateclone() {\r
+               global $member;\r
+\r
+               $templateid = intRequestVar('templateid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // 1. read old template\r
+               $name = TEMPLATE::getNameFromId($templateid);\r
+               $desc = TEMPLATE::getDesc($templateid);\r
+\r
+               // 2. create desc thing\r
+               $name = "cloned" . $name;\r
+\r
+               // if a template with that name already exists:\r
+               if (TEMPLATE::exists($name)) {\r
+                       $i = 1;\r
+                       while (TEMPLATE::exists($name . $i))\r
+                               $i++;\r
+                       $name .= $i;\r
+               }\r
+\r
+               $newid = TEMPLATE::createNew($name, $desc);\r
+\r
+               // 3. create clone\r
+               // go through parts of old template and add them to the new one\r
+               $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);\r
+               while ($o = sql_fetch_object($res)) {\r
+                       $this->addToTemplate($newid, $o->tpartname, $o->tcontent);\r
+               }\r
+\r
+               $this->action_templateoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinoverview() {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';\r
+\r
+               echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';\r
+\r
+               echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';\r
+\r
+               $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';\r
+               $template['content'] = 'skinlist';\r
+               $template['tabindex'] = 10;\r
+               showlist($query,'table',$template);\r
+\r
+               echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';\r
+\r
+               ?>\r
+               <form method="post" action="index.php">\r
+               <div>\r
+\r
+               <input name="action" value="skinnew" type="hidden" />\r
+               <?php $manager->addTicketHidden() ?>\r
+               <table><tr>\r
+                       <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>\r
+                       <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SKIN_DESC?></td>\r
+                       <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SKIN_CREATE?></td>\r
+                       <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>\r
+               </tr></table>\r
+\r
+               </div>\r
+               </form>\r
+\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinnew() {\r
+               global $member;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $name = trim(postVar('name'));\r
+               $desc = trim(postVar('desc'));\r
+\r
+               if (!isValidSkinName($name))\r
+                       $this->error(_ERROR_BADSKINNAME);\r
+\r
+               if (SKIN::exists($name))\r
+                       $this->error(_ERROR_DUPSKINNAME);\r
+\r
+               $newId = SKIN::createNew($name, $desc);\r
+\r
+               $this->action_skinoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinedit() {\r
+               global $member, $manager;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $skin =& new SKIN($skinid);\r
+\r
+               $this->pagehead();\r
+               ?>\r
+               <p>\r
+                       <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>\r
+               </p>\r
+               <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo  $skin->getName() ?>'</h2>\r
+\r
+               <h3><?php echo _SKIN_PARTS_TITLE?></h3>\r
+               <?php echo _SKIN_PARTS_MSG?>\r
+               <ul>\r
+                       <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>\r
+                       <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>\r
+                       <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>\r
+                       <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>\r
+                       <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>\r
+                       <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>\r
+                       <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>\r
+                       <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>\r
+               </ul>\r
+\r
+               <?php\r
+\r
+               $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;\r
+               $res = sql_query($query);\r
+\r
+               echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';\r
+               echo '<form method="get" action="index.php">' . "\r\n";\r
+               echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";\r
+               echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";\r
+               echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";\r
+               echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";\r
+               echo '</form>' . "\r\n";\r
+\r
+               if ($res && sql_num_rows($res) > 0) {\r
+                       echo '<ul>';\r
+                       $tabstart = 75;\r
+\r
+                       while ($row = sql_fetch_assoc($res)) {\r
+                               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'])) . '">'._LISTS_DELETE.'</a>)</li>';\r
+                       }\r
+\r
+                       echo '</ul>';\r
+               }\r
+\r
+               ?>\r
+\r
+               <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>\r
+               <form method="post" action="index.php">\r
+               <div>\r
+\r
+               <input type="hidden" name="action" value="skineditgeneral" />\r
+               <?php $manager->addTicketHidden() ?>\r
+               <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />\r
+               <table><tr>\r
+                       <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>\r
+                       <td><input name="name" tabindex="90" value="<?php echo  htmlspecialchars($skin->getName()) ?>" maxlength="20" size="20" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SKIN_DESC?></td>\r
+                       <td><input name="desc" tabindex="100" value="<?php echo  htmlspecialchars($skin->getDescription()) ?>" maxlength="200" size="50" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SKIN_TYPE?></td>\r
+                       <td><input name="type" tabindex="110" value="<?php echo  htmlspecialchars($skin->getContentType()) ?>" maxlength="40" size="20" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>\r
+                       <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>\r
+                       <td><input name="inc_prefix" tabindex="130" value="<?php echo  htmlspecialchars($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SKIN_CHANGE?></td>\r
+                       <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>\r
+               </tr></table>\r
+\r
+               </div>\r
+               </form>\r
+\r
+\r
+               <?php      $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skineditgeneral() {\r
+               global $member;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $name = postVar('name');\r
+               $desc = postVar('desc');\r
+               $type = postVar('type');\r
+               $inc_mode = postVar('inc_mode');\r
+               $inc_prefix = postVar('inc_prefix');\r
+\r
+               $skin =& new SKIN($skinid);\r
+\r
+               // 1. Some checks\r
+               if (!isValidSkinName($name))\r
+                       $this->error(_ERROR_BADSKINNAME);\r
+\r
+               if (($skin->getName() != $name) && SKIN::exists($name))\r
+                       $this->error(_ERROR_DUPSKINNAME);\r
+\r
+               if (!$type) $type = 'text/html';\r
+               if (!$inc_mode) $inc_mode = 'normal';\r
+\r
+               // 2. Update description\r
+               $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);\r
+\r
+               $this->action_skinedit();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinedittype($msg = '') {\r
+               global $member, $manager;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+               $type = requestVar('type');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $type = trim($type);\r
+               $type = strtolower($type);\r
+\r
+               if (!isValidShortName($type)) {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);\r
+               }\r
+\r
+               $skin =& new SKIN($skinid);\r
+\r
+               $friendlyNames = SKIN::getFriendlyNames();\r
+\r
+               $this->pagehead();\r
+               ?>\r
+               <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>\r
+\r
+               <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo htmlspecialchars($skin->getName()) ?>': <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>\r
+\r
+               <?php              if ($msg) echo "<p>"._MESSAGE.": $msg</p>";\r
+               ?>\r
+\r
+\r
+               <form method="post" action="index.php">\r
+               <div>\r
+\r
+               <input type="hidden" name="action" value="skinupdate" />\r
+               <?php $manager->addTicketHidden() ?>\r
+               <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />\r
+               <input type="hidden" name="type" value="<?php echo  $type ?>" />\r
+\r
+               <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />\r
+               <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />\r
+               (skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)\r
+               <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {\r
+                       help('skinpart' . $type);\r
+               } else {\r
+                       help('skinpartspecial');\r
+               }?>\r
+               <br />\r
+\r
+               <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo  htmlspecialchars($skin->getContent($type)) ?></textarea>\r
+\r
+               <br />\r
+               <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />\r
+               <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />\r
+               (skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)\r
+\r
+               <br /><br />\r
+               <?php echo _SKIN_ALLOWEDVARS?>\r
+               <?php              $actions = SKIN::getAllowedActionsForType($type);\r
+\r
+                       sort($actions);\r
+\r
+                       while ($current = array_shift($actions)) {\r
+                               // skip deprecated vars\r
+                               if ($current == 'ifcat') continue;\r
+                               if ($current == 'imagetext') continue;\r
+                               if ($current == 'vars') continue;\r
+\r
+                               echo helplink('skinvar-' . $current) . "$current</a>";\r
+                               if (count($actions) != 0) echo ", ";\r
+                       }\r
+               echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;\r
+               $query = 'SELECT bshortname, bname FROM '.sql_table('blog');\r
+                       showlist($query,'table',array('content'=>'shortblognames'));\r
+               echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;\r
+               $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');\r
+                       showlist($query,'table',array('content'=>'shortnames'));\r
+               echo '</div></form>';\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinupdate() {\r
+               global $member;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+               $content = trim(postVar('content'));\r
+               $type = postVar('type');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $skin =& new SKIN($skinid);\r
+               $skin->update($type, $content);\r
+\r
+               $this->action_skinedittype(_SKIN_UPDATED);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skindelete() {\r
+               global $member, $manager, $CONF;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // don't allow default skin to be deleted\r
+               if ($skinid == $CONF['BaseSkin'])\r
+                       $this->error(_ERROR_DEFAULTSKIN);\r
+\r
+               // don't allow deletion of default skins for blogs\r
+               $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;\r
+               $r = sql_query($query);\r
+               if ($o = sql_fetch_object($r))\r
+                       $this->error(_ERROR_SKINDEFDELETE . htmlspecialchars($o->bname));\r
+\r
+               $this->pagehead();\r
+\r
+               $skin =& new SKIN($skinid);\r
+               $name = $skin->getName();\r
+               $desc = $skin->getDescription();\r
+\r
+               ?>\r
+                       <h2><?php echo _DELETE_CONFIRM?></h2>\r
+\r
+                       <p>\r
+                               <?php echo _CONFIRMTXT_SKIN?><b><?php echo htmlspecialchars($name) ?></b> (<?php echo  htmlspecialchars($desc)?>)\r
+                       </p>\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                               <input type="hidden" name="action" value="skindeleteconfirm" />\r
+                               <?php $manager->addTicketHidden() ?>\r
+                               <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />\r
+                               <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skindeleteconfirm() {\r
+               global $member, $CONF, $manager;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // don't allow default skin to be deleted\r
+               if ($skinid == $CONF['BaseSkin'])\r
+                       $this->error(_ERROR_DEFAULTSKIN);\r
+\r
+               // don't allow deletion of default skins for blogs\r
+               $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;\r
+               $r = sql_query($query);\r
+               if ($o = sql_fetch_object($r))\r
+                       $this->error(_ERROR_SKINDEFDELETE .$o->bname);\r
+\r
+               $manager->notify('PreDeleteSkin', array('skinid' => $skinid));\r
+\r
+               // 1. delete description\r
+               sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);\r
+\r
+               // 2. delete parts\r
+               sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);\r
+\r
+               $manager->notify('PostDeleteSkin', array('skinid' => $skinid));\r
+\r
+               $this->action_skinoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinremovetype() {\r
+               global $member, $manager, $CONF;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+               $skintype = requestVar('type');\r
+\r
+               if (!isValidShortName($skintype)) {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);\r
+               }\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // don't allow default skinparts to be deleted\r
+               if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);\r
+               }\r
+\r
+               $this->pagehead();\r
+\r
+               $skin =& new SKIN($skinid);\r
+               $name = $skin->getName();\r
+               $desc = $skin->getDescription();\r
+\r
+               ?>\r
+                       <h2><?php echo _DELETE_CONFIRM?></h2>\r
+\r
+                       <p>\r
+                               <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo htmlspecialchars($skintype); ?> (<?php echo htmlspecialchars($name); ?>)</b> (<?php echo  htmlspecialchars($desc)?>)\r
+                       </p>\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                               <input type="hidden" name="action" value="skinremovetypeconfirm" />\r
+                               <?php $manager->addTicketHidden() ?>\r
+                               <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />\r
+                               <input type="hidden" name="type" value="<?php echo htmlspecialchars($skintype); ?>" />\r
+                               <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinremovetypeconfirm() {\r
+               global $member, $CONF, $manager;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+               $skintype = requestVar('type');\r
+\r
+               if (!isValidShortName($skintype)) {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);\r
+               }\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // don't allow default skinparts to be deleted\r
+               if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);\r
+               }\r
+\r
+               $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));\r
+\r
+               // delete part\r
+               sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');\r
+\r
+               $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));\r
+\r
+               $this->action_skinedit();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinclone() {\r
+               global $member;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // 1. read skin to clone\r
+               $skin =& new SKIN($skinid);\r
+\r
+               $name = "clone_" . $skin->getName();\r
+\r
+               // if a skin with that name already exists:\r
+               if (SKIN::exists($name)) {\r
+                       $i = 1;\r
+                       while (SKIN::exists($name . $i))\r
+                               $i++;\r
+                       $name .= $i;\r
+               }\r
+\r
+               // 2. create skin desc\r
+               $newid = SKIN::createNew(\r
+                       $name,\r
+                       $skin->getDescription(),\r
+                       $skin->getContentType(),\r
+                       $skin->getIncludeMode(),\r
+                       $skin->getIncludePrefix()\r
+               );\r
+\r
+\r
+               // 3. clone\r
+               /*\r
+               $this->skinclonetype($skin, $newid, 'index');\r
+               $this->skinclonetype($skin, $newid, 'item');\r
+               $this->skinclonetype($skin, $newid, 'archivelist');\r
+               $this->skinclonetype($skin, $newid, 'archive');\r
+               $this->skinclonetype($skin, $newid, 'search');\r
+               $this->skinclonetype($skin, $newid, 'error');\r
+               $this->skinclonetype($skin, $newid, 'member');\r
+               $this->skinclonetype($skin, $newid, 'imagepopup');\r
+               */\r
+\r
+               $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;\r
+               $res = sql_query($query);\r
+               while ($row = sql_fetch_assoc($res)) {\r
+                       $this->skinclonetype($skin, $newid, $row['stype']);\r
+               }\r
+\r
+               $this->action_skinoverview();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function skinclonetype($skin, $newid, $type) {\r
+               $newid = intval($newid);\r
+               $content = $skin->getContent($type);\r
+               if ($content) {\r
+                       $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". sql_real_escape_string($content)."', '". sql_real_escape_string($type)."')";\r
+                       sql_query($query);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_settingsedit() {\r
+               global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';\r
+               ?>\r
+\r
+               <h2><?php echo _SETTINGS_TITLE?></h2>\r
+\r
+               <form action="index.php" method="post">\r
+               <div>\r
+\r
+               <input type="hidden" name="action" value="settingsupdate" />\r
+               <?php $manager->addTicketHidden() ?>\r
+\r
+               <table><tr>\r
+                       <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>\r
+                       <td>\r
+                               <?php\r
+                                       $query =  'SELECT bname as text, bnumber as value'\r
+                                                  . ' FROM '.sql_table('blog');\r
+                                       $template['name'] = 'DefaultBlog';\r
+                                       $template['selected'] = $CONF['DefaultBlog'];\r
+                                       $template['tabindex'] = 10;\r
+                                       showlist($query,'select',$template);\r
+                               ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>\r
+                       <td>\r
+                               <?php\r
+                                       $query =  'SELECT sdname as text, sdnumber as value'\r
+                                                  . ' FROM '.sql_table('skin_desc');\r
+                                       $template['name'] = 'BaseSkin';\r
+                                       $template['selected'] = $CONF['BaseSkin'];\r
+                                       $template['tabindex'] = 1;\r
+                                       showlist($query,'select',$template);\r
+                               ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_ADMINMAIL?></td>\r
+                       <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo  htmlspecialchars($CONF['AdminEmail']) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_SITENAME?></td>\r
+                       <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo  htmlspecialchars($CONF['SiteName']) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_SITEURL?></td>\r
+                       <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo  htmlspecialchars($CONF['IndexURL']) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_ADMINURL?></td>\r
+                       <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo  htmlspecialchars($CONF['AdminURL']) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>\r
+                       <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo  htmlspecialchars($CONF['PluginURL']) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>\r
+                       <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo  htmlspecialchars($CONF['SkinsURL']) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>\r
+                       <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo  htmlspecialchars($CONF['ActionURL']) ?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>\r
+                       </td>\r
+                       <td>\r
+\r
+                               <select name="Language" tabindex="10050">\r
+                               <?php                      // show a dropdown list of all available languages\r
+                               global $DIR_LANG;\r
+                               $dirhandle = opendir($DIR_LANG);\r
+                               while ($filename = readdir($dirhandle) )\r
+                               {\r
+                                       # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0\r
+                                       # original ereg: ereg("^(.*)\.php$",$filename,$matches)\r
+                                       if (preg_match('#^(.*)\.php$#', $filename, $matches) )\r
+                                       {\r
+                                               $name = $matches[1];\r
+                                               echo "<option value=\"$name\"";\r
+                                               if ($name == $CONF['Language'])\r
+                                               {\r
+                                                       echo " selected=\"selected\"";\r
+                                               }\r
+                                               echo ">$name</option>";\r
+                                       }\r
+                               }\r
+                               closedir($dirhandle);\r
+\r
+                               ?>\r
+                               </select>\r
+\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>\r
+                       </td>\r
+                       <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>\r
+                                       <br />\r
+                               <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo  htmlspecialchars($CONF['DisableSiteURL'])?>" />\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_DIRS?></td>\r
+                       <td><?php echo  htmlspecialchars($DIR_NUCLEUS) ?>\r
+                               <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_DBLOGIN?></td>\r
+                       <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>\r
+               </tr><tr>\r
+                       <td>\r
+                       <?php\r
+                               echo _SETTINGS_JSTOOLBAR\r
+                               /* =_SETTINGS_DISABLEJS\r
+\r
+                                       I temporary changed the meaning of DisableJsTools, until I can find a good\r
+                                       way to select the javascript version to use\r
+\r
+                                       now, its:\r
+                                               0 : IE\r
+                                               1 : all javascript disabled\r
+                                               2 : 'simpler' javascript (for mozilla/opera/mac)\r
+                               */\r
+                          ?>\r
+                       </td>\r
+                       <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>\r
+                               <select name="DisableJsTools" tabindex="10075">\r
+                       <?php                              $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';\r
+                                       echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";\r
+                                       $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';\r
+                                       echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";\r
+                                       $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';\r
+                                       echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";\r
+                       ?>\r
+                               </select>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>\r
+                                          <td><?php\r
+\r
+                                          $this->input_yesno('URLMode',$CONF['URLMode'],10077,\r
+                                                         'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);\r
+\r
+                                          echo ' ', _SETTINGS_URLMODE_HELP;\r
+\r
+                                                        ?>\r
+\r
+                                          </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>\r
+                                          <td><?php\r
+\r
+                                               $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);\r
+\r
+                                                        ?>\r
+\r
+                                          </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>\r
+                       <td>\r
+                       <?php\r
+                               if (!array_key_exists('DefaultListSize',$CONF)) {\r
+                                       sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");\r
+                                       $CONF['DefaultListSize'] = 10;\r
+                               }\r
+                       ?>\r
+                               <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo  htmlspecialchars((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />\r
+                       </td>\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_MEDIADIR?></td>\r
+                       <td><?php echo  htmlspecialchars($DIR_MEDIA) ?>\r
+                               <i><?php echo _SETTINGS_SEECONFIGPHP?></i>\r
+                               <?php                              if (!is_dir($DIR_MEDIA))\r
+                                               echo "<br /><b>" . _WARNING_NOTADIR . "</b>";\r
+                                       if (!is_readable($DIR_MEDIA))\r
+                                               echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";\r
+                                       if (!is_writeable($DIR_MEDIA))\r
+                                               echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";\r
+                               ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_MEDIAURL?></td>\r
+                       <td>\r
+                               <input name="MediaURL" tabindex="10080" size="40" value="<?php echo  htmlspecialchars($CONF['MediaURL']) ?>" />\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>\r
+                       <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>\r
+                       <td>\r
+                               <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo  htmlspecialchars($CONF['AllowedTypes']) ?>" />\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>\r
+                       <td>\r
+                               <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo  htmlspecialchars($CONF['MaxUploadSize']) ?>" />\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_MEDIAPREFIX?></td>\r
+                       <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>\r
+\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_CHANGELOGIN?></td>\r
+                       <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_ALLOWCREATE?>\r
+                               <?php help('allowaccountcreation'); ?>\r
+                       </td>\r
+                       <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>\r
+                               <br /><?php echo _SETTINGS_NEWLOGIN2?>\r
+                       </td>\r
+                       <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_MEMBERMSGS?>\r
+                               <?php help('messageservice'); ?>\r
+                       </td>\r
+                       <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_NONMEMBERMSGS?>\r
+                               <?php help('messageservice'); ?>\r
+                       </td>\r
+                       <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_PROTECTMEMNAMES?>\r
+                               <?php help('protectmemnames'); ?>\r
+                       </td>\r
+                       <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>\r
+                       </td>\r
+\r
+\r
+\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_COOKIEPREFIX?></td>\r
+                       <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo  htmlspecialchars($CONF['CookiePrefix'])?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>\r
+                       <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo  htmlspecialchars($CONF['CookieDomain'])?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_COOKIEPATH?></td>\r
+                       <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo  htmlspecialchars($CONF['CookiePath'])?>" /></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_COOKIESECURE?></td>\r
+                       <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_COOKIELIFE?></td>\r
+                       <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,\r
+                                                         1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>\r
+                       </td>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_LASTVISIT?></td>\r
+                       <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>\r
+\r
+\r
+\r
+               </tr><tr>\r
+                       <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>\r
+               </tr><tr>\r
+                       <td><?php echo _SETTINGS_UPDATE?></td>\r
+                       <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>\r
+               </tr></table>\r
+\r
+               </div>\r
+               </form>\r
+\r
+               <?php\r
+                       echo '<h2>',_PLUGINS_EXTRA,'</h2>';\r
+\r
+                       $manager->notify(\r
+                               'GeneralSettingsFormExtras',\r
+                               array()\r
+                       );\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_settingsupdate() {\r
+               global $member, $CONF;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // check if email address for admin is valid\r
+               if (!isValidMailAddress(postVar('AdminEmail')))\r
+                       $this->error(_ERROR_BADMAILADDRESS);\r
+\r
+\r
+               // save settings\r
+               $this->updateConfig('DefaultBlog',        postVar('DefaultBlog'));\r
+               $this->updateConfig('BaseSkin',          postVar('BaseSkin'));\r
+               $this->updateConfig('IndexURL',          postVar('IndexURL'));\r
+               $this->updateConfig('AdminURL',          postVar('AdminURL'));\r
+               $this->updateConfig('PluginURL',                postVar('PluginURL'));\r
+               $this->updateConfig('SkinsURL',          postVar('SkinsURL'));\r
+               $this->updateConfig('ActionURL',                postVar('ActionURL'));\r
+               $this->updateConfig('Language',          postVar('Language'));\r
+               $this->updateConfig('AdminEmail',          postVar('AdminEmail'));\r
+               $this->updateConfig('SessionCookie',    postVar('SessionCookie'));\r
+               $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));\r
+               $this->updateConfig('AllowMemberMail',  postVar('AllowMemberMail'));\r
+               $this->updateConfig('NonmemberMail',    postVar('NonmemberMail'));\r
+               $this->updateConfig('ProtectMemNames',  postVar('ProtectMemNames'));\r
+               $this->updateConfig('SiteName',          postVar('SiteName'));\r
+               $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));\r
+               $this->updateConfig('DisableSite',        postVar('DisableSite'));\r
+               $this->updateConfig('DisableSiteURL',   postVar('DisableSiteURL'));\r
+               $this->updateConfig('LastVisit',                postVar('LastVisit'));\r
+               $this->updateConfig('MediaURL',          postVar('MediaURL'));\r
+               $this->updateConfig('AllowedTypes',      postVar('AllowedTypes'));\r
+               $this->updateConfig('AllowUpload',        postVar('AllowUpload'));\r
+               $this->updateConfig('MaxUploadSize',    postVar('MaxUploadSize'));\r
+               $this->updateConfig('MediaPrefix',        postVar('MediaPrefix'));\r
+               $this->updateConfig('AllowLoginEdit',   postVar('AllowLoginEdit'));\r
+               $this->updateConfig('DisableJsTools',   postVar('DisableJsTools'));\r
+               $this->updateConfig('CookieDomain',      postVar('CookieDomain'));\r
+               $this->updateConfig('CookiePath',          postVar('CookiePath'));\r
+               $this->updateConfig('CookieSecure',      postVar('CookieSecure'));\r
+               $this->updateConfig('URLMode',            postVar('URLMode'));\r
+               $this->updateConfig('CookiePrefix',      postVar('CookiePrefix'));\r
+               $this->updateConfig('DebugVars',                postVar('DebugVars'));\r
+               $this->updateConfig('DefaultListSize',  postVar('DefaultListSize'));\r
+\r
+               // load new config and redirect (this way, the new language will be used is necessary)\r
+               // note that when changing cookie settings, this redirect might cause the user\r
+               // to have to log in again.\r
+               getConfig();\r
+               redirect($CONF['AdminURL'] . '?action=manage');\r
+               exit;\r
+\r
+       }\r
+\r
+       /**\r
+        *  Give an overview over the used system\r
+        */\r
+       function action_systemoverview() {\r
+               global $member, $nucleus, $CONF;\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";\r
+\r
+               if ($member->isLoggedIn() && $member->isAdmin()) {\r
+\r
+                       // Information about the used PHP and MySQL installation\r
+                       echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n";\r
+\r
+                       // Version of PHP MySQL\r
+                       echo "<table>\n";\r
+                       echo "\t<tr>\n";\r
+                       echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";\r
+                       echo "\t\t" . '<td>' . phpversion() . "</td>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";\r
+                       echo "\t\t" . '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";\r
+                       echo "\t</tr>";\r
+                       echo "</table>\n";\r
+\r
+                       // Important PHP settings\r
+                       echo "<table>\n";\r
+                       echo "\t<tr>\n";\r
+                       echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td width="50%">magic_quotes_gpc' . "</td>\n";\r
+                       $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';\r
+                       echo "\t\t" . '<td>' . $mqg . "</td>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td>magic_quotes_runtime' . "</td>\n";\r
+                       $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';\r
+                       echo "\t\t" . '<td>' . $mqr . "</td>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td>register_globals' . "</td>\n";\r
+                       $rg = ini_get('register_globals') ? 'On' : 'Off';\r
+                       echo "\t\t" . '<td>' . $rg . "</td>\n";\r
+                       echo "\t</tr>";\r
+                       echo "</table>\n";\r
+\r
+                       // Information about GD library\r
+                       $gdinfo = gd_info();\r
+                       echo "<table>\n";\r
+                       echo "\t<tr>";\r
+                       echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";\r
+                       echo "\t</tr>\n";\r
+                       foreach ($gdinfo as $key=>$value) {\r
+                               if (is_bool($value)) {\r
+                                       $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;\r
+                               } else {\r
+                                       $value = htmlspecialchars($value, ENT_QUOTES);\r
+                               }\r
+                               echo "\t<tr>";\r
+                               echo "\t\t" . '<td width="50%">' . $key . "</td>\n";\r
+                               echo "\t\t" . '<td>' . $value . "</td>\n";\r
+                               echo "\t</tr>\n";\r
+                       }\r
+                       echo "</table>\n";\r
+\r
+                       // Check if special modules are loaded\r
+                       ob_start();\r
+                       phpinfo(INFO_MODULES);\r
+                       $im = ob_get_contents();\r
+                       ob_clean();\r
+                       echo "<table>\n";\r
+                       echo "\t<tr>";\r
+                       echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td width="50%">mod_rewrite' . "</td>\n";\r
+                       $modrewrite = (strstr($im, 'mod_rewrite') != '') ?\r
+                                               _ADMIN_SYSTEMOVERVIEW_ENABLE :\r
+                                               _ADMIN_SYSTEMOVERVIEW_DISABLE;\r
+                       echo "\t\t" . '<td>' . $modrewrite . "</td>\n";\r
+                       echo "\t</tr>\n";\r
+                       echo "</table>\n";\r
+\r
+                       // Information about the used Nucleus CMS\r
+                       echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";\r
+                       global $nucleus;\r
+                       $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';\r
+                       $np = getNucleusPatchLevel();\r
+                       echo "<table>\n";\r
+                       echo "\t<tr>";\r
+                       echo "\t\t" . '<th colspan="2">Nucleus CMS' . "</th>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";\r
+                       echo "\t\t" . '<td>' . $nv . "</td>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td width="50%">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";\r
+                       echo "\t\t" . '<td>' . $np . "</td>\n";\r
+                       echo "\t</tr>\n";\r
+                       echo "</table>\n";\r
+\r
+                       // Important settings of the installation\r
+                       echo "<table>\n";\r
+                       echo "\t<tr>";\r
+                       echo "\t\t" . '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td width="50%">' . '$CONF[' . "'Self']</td>\n";\r
+                       echo "\t\t" . '<td>' . $CONF['Self'] . "</td>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td width="50%">' . '$CONF[' . "'ItemURL']</td>\n";\r
+                       echo "\t\t" . '<td>' . $CONF['ItemURL'] . "</td>\n";\r
+                       echo "\t</tr><tr>\n";\r
+                       echo "\t\t" . '<td width="50%">' . '$CONF[' . "'alertOnHeadersSent']</td>\n";\r
+                       $ohs = $CONF['alertOnHeadersSent'] ?\r
+                                               _ADMIN_SYSTEMOVERVIEW_ENABLE :\r
+                                               _ADMIN_SYSTEMOVERVIEW_DISABLE;\r
+                       echo "\t\t" . '<td>' . $ohs . "</td>\n";\r
+                       echo "\t</tr>\n";\r
+                       echo "</table>\n";\r
+\r
+                       // Link to the online version test at the Nucleus CMS website\r
+                       echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";\r
+                       if ($nucleus['codename'] != '') {\r
+                               $codenamestring = ' &quot;' . $nucleus['codename'] . '&quot;';\r
+                       } else {\r
+                               $codenamestring = '';\r
+                       }\r
+                       echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;\r
+                       $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());\r
+                       echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';\r
+                       echo 'Nucleus CMS ' . $nv . $codenamestring;\r
+                       echo '</a>';\r
+               //echo '<br />';\r
+               }\r
+               else {\r
+                       echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;\r
+               }\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function updateConfig($name, $val) {\r
+               $name = sql_real_escape_string($name);\r
+               $val = trim(sql_real_escape_string($val));\r
+\r
+               $query = 'UPDATE '.sql_table('config')\r
+                          . " SET value='$val'"\r
+                          . " WHERE name='$name'";\r
+\r
+               sql_query($query) or die(_ADMIN_SQLDIE_QUERYERROR . sql_error());\r
+               return sql_insert_id();\r
+       }\r
+\r
+       /**\r
+        * Error message\r
+        * @param string $msg message that will be shown\r
+        */\r
+       function error($msg) {\r
+               $this->pagehead();\r
+               ?>\r
+               <h2>Error!</h2>\r
+               <?php      echo $msg;\r
+               echo "<br />";\r
+               echo "<a href='index.php' onclick='history.back()'>"._BACK."</a>";\r
+               $this->pagefoot();\r
+               exit;\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function disallow() {\r
+               ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));\r
+\r
+               $this->error(_ERROR_DISALLOWED);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function pagehead($extrahead = '') {\r
+               global $member, $nucleus, $CONF, $manager;\r
+\r
+               $manager->notify(\r
+                       'AdminPrePageHead',\r
+                       array(\r
+                               'extrahead' => &$extrahead,\r
+                               'action' => $this->action\r
+                       )\r
+               );\r
+\r
+               $baseUrl = htmlspecialchars($CONF['AdminURL']);\r
+\r
+               ?>\r
+               <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+               <html <?php echo _HTML_XML_NAME_SPACE_AND_LANG_CODE; ?>>\r
+               <head>\r
+                       <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />\r
+                       <title><?php echo htmlspecialchars($CONF['SiteName'])?> - Admin</title>\r
+                       <link rel="stylesheet" title="Nucleus Admin Default" type="text/css" href="<?php echo $baseUrl?>styles/admin.css" />\r
+                       <link rel="stylesheet" title="Nucleus Admin Default" type="text/css"\r
+                       href="<?php echo $baseUrl?>styles/addedit.css" />\r
+\r
+                       <script type="text/javascript" src="<?php echo $baseUrl?>javascript/edit.js"></script>\r
+                       <script type="text/javascript" src="<?php echo $baseUrl?>javascript/admin.js"></script>\r
+                       <script type="text/javascript" src="<?php echo $baseUrl?>javascript/compatibility.js"></script>\r
+\r
+         <meta http-equiv='Pragma' content='no-cache' />\r
+         <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />\r
+         <meta http-equiv='Expires' content='-1' />\r
+\r
+                       <?php echo $extrahead?>\r
+               </head>\r
+               <body>\r
+               <div id="adminwrapper">\r
+               <div class="header">\r
+               <h1><?php echo htmlspecialchars($CONF['SiteName'])?></h1>\r
+               </div>\r
+               <div id="container">\r
+               <div id="content">\r
+               <div class="loginname">\r
+               <?php              if ($member->isLoggedIn())\r
+                               echo _LOGGEDINAS . ' ' . $member->getDisplayName()\r
+                                       ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a>"\r
+                                       . "<br /><a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";\r
+                       else\r
+                               echo '<a href="index.php?action=showlogin" title="Log in">' , _NOTLOGGEDIN , '</a> <br />';\r
+\r
+                       echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a>";\r
+\r
+                       echo '<br />(';\r
+\r
+                       $codenamestring = ($nucleus['codename']!='')? ' &quot;'.$nucleus['codename'].'&quot;':'';\r
+\r
+                       if ($member->isLoggedIn() && $member->isAdmin()) {\r
+                               $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());\r
+                               echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';\r
+                               $newestVersion = getLatestVersion();\r
+                               $newestCompare = str_replace('/','.',$newestVersion);\r
+                               $newestCompare = intval($newestCompare);\r
+                               $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);\r
+                               if ($newestVersion && version_compare($newestCompare,$currentVersion) > 0) {\r
+                                       echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE.'">'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT.$newestVersion.'</a>';\r
+                               }\r
+                       } else {\r
+                               echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;\r
+                       }\r
+                       echo ')';\r
+               echo '</div>';\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function pagefoot() {\r
+               global $action, $member, $manager;\r
+\r
+               $manager->notify(\r
+                       'AdminPrePageFoot',\r
+                       array(\r
+                               'action' => $this->action\r
+                       )\r
+               );\r
+\r
+               if ($member->isLoggedIn() && ($action != 'showlogin')) {\r
+                       ?>\r
+                       <h2><?php echo  _LOGOUT ?></h2>\r
+                       <ul>\r
+                               <li><a href="index.php?action=overview"><?php echo  _BACKHOME?></a></li>\r
+                               <li><a href='index.php?action=logout'><?php echo  _LOGOUT?></a></li>\r
+                       </ul>\r
+                       <?php      }\r
+               ?>\r
+                       <div class="foot">\r
+                               <a href="<?php echo _ADMINPAGEFOOT_OFFICIALURL ?>">Nucleus CMS</a> &copy; 2002-<?php echo date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT; ?>\r
+                               -\r
+                               <a href="<?php echo _ADMINPAGEFOOT_DONATEURL ?>"><?php echo _ADMINPAGEFOOT_DONATE ?></a>\r
+                       </div>\r
+\r
+                       </div><!-- content -->\r
+\r
+                       <div id="quickmenu">\r
+\r
+                               <?php                      // ---- user settings ----\r
+                               if (($action != 'showlogin') && ($member->isLoggedIn())) {\r
+                                       echo '<ul>';\r
+                                       echo '<li><a href="index.php?action=overview">',_QMENU_HOME,'</a></li>';\r
+                                       echo '</ul>';\r
+\r
+                                       echo '<h2>',_QMENU_ADD,'</h2>';\r
+                                       echo '<form method="get" action="index.php"><div>';\r
+                                       echo '<input type="hidden" name="action" value="createitem" />';\r
+\r
+                                               $showAll = requestVar('showall');\r
+                                               if (($member->isAdmin()) && ($showAll == 'yes')) {\r
+                                                       // Super-Admins have access to all blogs! (no add item support though)\r
+                                                       $query =  'SELECT bnumber as value, bname as text'\r
+                                                                  . ' FROM ' . sql_table('blog')\r
+                                                                  . ' ORDER BY bname';\r
+                                               } else {\r
+                                                       $query =  'SELECT bnumber as value, bname as text'\r
+                                                                  . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')\r
+                                                                  . ' WHERE tblog=bnumber and tmember=' . $member->getID()\r
+                                                                  . ' ORDER BY bname';\r
+                                               }\r
+                                               $template['name'] = 'blogid';\r
+                                               $template['tabindex'] = 15000;\r
+                                               $template['extra'] = _QMENU_ADD_SELECT;\r
+                                               $template['selected'] = -1;\r
+                                               $template['shorten'] = 10;\r
+                                               $template['shortenel'] = '';\r
+                                               $template['javascript'] = 'onchange="return form.submit()"';\r
+                                               showlist($query,'select',$template);\r
+\r
+                                       echo '</div></form>';\r
+\r
+                                       echo '<h2>' . $member->getDisplayName(). '</h2>';\r
+                                       echo '<ul>';\r
+                                       echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . '</a></li>';\r
+                                       echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . '</a></li>';\r
+                                       echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . '</a></li>';\r
+                                       echo '</ul>';\r
+\r
+\r
+\r
+\r
+                                       // ---- general settings ----\r
+                                       if ($member->isAdmin()) {\r
+\r
+                                               echo '<h2>',_QMENU_MANAGE,'</h2>';\r
+\r
+                                               echo '<ul>';\r
+                                               echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . '</a></li>';\r
+                                               echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . '</a></li>';\r
+                                               echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . '</a></li>';\r
+                                               echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . '</a></li>';\r
+                                               echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . '</a></li>';\r
+                                               echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . '</a></li>';\r
+                                               echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . '</a></li>';\r
+                                               echo '</ul>';\r
+\r
+                                               echo '<h2>',_QMENU_LAYOUT,'</h2>';\r
+                                               echo '<ul>';\r
+                                               echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . '</a></li>';\r
+                                               echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . '</a></li>';\r
+                                               echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . '</a></li>';\r
+                                               echo '</ul>';\r
+\r
+                                       }\r
+\r
+                                       $aPluginExtras = array();\r
+                                       $manager->notify(\r
+                                               'QuickMenu',\r
+                                               array(\r
+                                                       'options' => &$aPluginExtras\r
+                                               )\r
+                                       );\r
+                                       if (count($aPluginExtras) > 0)\r
+                                       {\r
+                                               echo '<h2>', _QMENU_PLUGINS, '</h2>';\r
+                                               echo '<ul>';\r
+                                               foreach ($aPluginExtras as $aInfo)\r
+                                               {\r
+                                                       echo '<li><a href="'.htmlspecialchars($aInfo['url']).'" title="'.htmlspecialchars($aInfo['tooltip']).'">'.htmlspecialchars($aInfo['title']).'</a></li>';\r
+                                               }\r
+                                               echo '</ul>';\r
+                                       }\r
+\r
+                               } else if (($action == 'activate') || ($action == 'activatesetpwd')) {\r
+\r
+                                       echo '<h2>', _QMENU_ACTIVATE, '</h2>', _QMENU_ACTIVATE_TEXT;\r
+                               } else {\r
+                                       // introduction text on login screen\r
+                                       echo '<h2>', _QMENU_INTRO, '</h2>', _QMENU_INTRO_TEXT;\r
+                               }\r
+                               ?>\r
+                       </div>\r
+\r
+                       <!-- content / quickmenu container -->\r
+                       <div class="clear"></div>       <!-- new -->\r
+                       </div>\r
+\r
+                       <!-- adminwrapper -->   <!-- new -->\r
+                       </div>   <!-- new -->\r
+                       </body>\r
+                       </html>\r
+               <?php   }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_regfile() {\r
+               global $member, $CONF;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $member->teamRights($blogid) or $this->disallow();\r
+\r
+               // header-code stolen from phpMyAdmin\r
+               // REGEDIT and bookmarklet code stolen from GreyMatter\r
+\r
+               $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));\r
+               $sjisBlogName = mb_convert_encoding($sjisBlogName, "SJIS", "auto");\r
+\r
+               header('Content-Type: application/octetstream');\r
+               header('Content-Disposition: filename="nucleus.reg"');\r
+               header('Pragma: no-cache');\r
+               header('Expires: 0');\r
+\r
+               echo "REGEDIT4\n";\r
+               echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";\r
+               echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";\r
+               echo '"contexts"=hex:31';\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_bookmarklet() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $member->teamRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+               $bm = getBookmarklet($blogid);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';\r
+\r
+               ?>\r
+\r
+               <h2><?php echo _BOOKMARKLET_TITLE ?></h2>\r
+\r
+               <p>\r
+               <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>\r
+               </p>\r
+\r
+               <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>\r
+               <p>\r
+                       <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>\r
+                       <br />\r
+                       <br />\r
+                       <?php echo '<a href="' . htmlspecialchars($bm, ENT_QUOTES) . '">' . sprintf(_BOOKMARKLET_ANCHOR, htmlspecialchars($blog->getName(), ENT_QUOTES)) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>\r
+               </p>\r
+\r
+               <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>\r
+               <p>\r
+                       <?php\r
+                               $url = 'index.php?action=regfile&blogid=' . intval($blogid);\r
+                               $url = $manager->addTicketToUrl($url);\r
+                       ?>\r
+                       <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . htmlspecialchars($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>\r
+               </p>\r
+\r
+               <p>\r
+                       <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>\r
+               </p>\r
+\r
+               <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>\r
+               <p>\r
+                       <?php echo _BOOKMARKLET_DELETEBAR ?>\r
+               </p>\r
+\r
+               <p>\r
+                       <?php echo _BOOKMARKLET_DELETERIGHTT ?>\r
+               </p>\r
+\r
+               <ol>\r
+                       <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>\r
+                       <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>\r
+                       <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>\r
+                       <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>\r
+                       <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>\r
+               </ol>\r
+\r
+               <?php\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_actionlog() {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';\r
+\r
+               $url = $manager->addTicketToUrl('index.php?action=clearactionlog');\r
+\r
+               ?>\r
+                       <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>\r
+                       <p><a href="<?php echo htmlspecialchars($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>\r
+               <?php\r
+               echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';\r
+\r
+               $query =  'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';\r
+               $template['content'] = 'actionlist';\r
+               $amount = showlist($query,'table',$template);\r
+\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlist() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';\r
+\r
+               echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";\r
+\r
+               $query =  'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';\r
+               $template['content'] = 'banlist';\r
+               $amount = showlist($query,'table',$template);\r
+\r
+               if ($amount == 0)\r
+                       echo _BAN_NONE;\r
+\r
+               echo '<h2>'._BAN_NEW_TITLE.'</h2>';\r
+               echo "<p><a href='index.php?action=banlistnew&amp;blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";\r
+\r
+\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlistdelete() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+               $iprange = requestVar('iprange');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+               $banBlogName =  htmlspecialchars($blog->getName(), ENT_QUOTES);\r
+\r
+               $this->pagehead();\r
+               ?>\r
+                       <h2><?php echo _BAN_REMOVE_TITLE?></h2>\r
+\r
+                       <form method="post" action="index.php">\r
+\r
+                       <h3><?php echo _BAN_IPRANGE?></h3>\r
+\r
+                       <p>\r
+                               <?php echo _CONFIRMTXT_BAN?> <?php echo htmlspecialchars($iprange) ?>\r
+                               <input name="iprange" type="hidden" value="<?php echo htmlspecialchars($iprange)?>" />\r
+                       </p>\r
+\r
+                       <h3><?php echo _BAN_BLOGS?></h3>\r
+\r
+                       <div>\r
+                               <input type="hidden" name="blogid" value="<?php echo $blogid?>" />\r
+                               <input name="allblogs" type="radio" value="0" id="allblogs_one" />\r
+                               <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>\r
+                               <br />\r
+                               <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>\r
+                       </div>\r
+\r
+                       <h3><?php echo _BAN_DELETE_TITLE?></h3>\r
+\r
+                       <div>\r
+                               <?php $manager->addTicketHidden() ?>\r
+                               <input type="hidden" name="action" value="banlistdeleteconfirm" />\r
+                               <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />\r
+                       </div>\r
+\r
+                       </form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlistdeleteconfirm() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intPostVar('blogid');\r
+               $allblogs = postVar('allblogs');\r
+               $iprange = postVar('iprange');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $deleted = array();\r
+\r
+               if (!$allblogs) {\r
+                       if (BAN::removeBan($blogid, $iprange))\r
+                               array_push($deleted, $blogid);\r
+               } else {\r
+                       // get blogs fot which member has admin rights\r
+                       $adminblogs = $member->getAdminBlogs();\r
+                       foreach ($adminblogs as $blogje) {\r
+                               if (BAN::removeBan($blogje, $iprange))\r
+                                       array_push($deleted, $blogje);\r
+                       }\r
+               }\r
+\r
+               if (sizeof($deleted) == 0)\r
+                       $this->error(_ERROR_DELETEBAN);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<a href="index.php?action=banlist&amp;blogid=',$blogid,'">(',_BACK,')</a>';\r
+               echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';\r
+               echo "<p>"._BAN_REMOVED_TEXT."</p>";\r
+\r
+               echo "<ul>";\r
+               foreach ($deleted as $delblog) {\r
+                       $b =& $manager->getBlog($delblog);\r
+                       echo "<li>" . htmlspecialchars($b->getName()). "</li>";\r
+               }\r
+               echo "</ul>";\r
+\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlistnewfromitem() {\r
+               $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlistnew($blogid = '') {\r
+               global $member, $manager;\r
+\r
+               if ($blogid == '')\r
+                       $blogid = intRequestVar('blogid');\r
+\r
+               $ip = requestVar('ip');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $this->pagehead();\r
+               ?>\r
+               <h2><?php echo _BAN_ADD_TITLE?></h2>\r
+\r
+\r
+               <form method="post" action="index.php">\r
+\r
+               <h3><?php echo _BAN_IPRANGE?></h3>\r
+\r
+               <p><?php echo _BAN_IPRANGE_TEXT?></p>\r
+\r
+               <div class="note">\r
+                       <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>\r
+                       <?php echo _BAN_EXAMPLE_TEXT ?>\r
+               </div>\r
+\r
+               <div>\r
+               <?php\r
+               if ($ip) {\r
+                       $iprangeVal = htmlspecialchars($ip, ENT_QUOTES);\r
+               ?>\r
+                       <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />\r
+                       <label for="ip_fixed"><?php echo $iprangeVal ?></label>\r
+                       <br />\r
+                       <input name="iprange" type="radio" value="custom" id="ip_custom" />\r
+                       <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>\r
+                       <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />\r
+               <?php\r
+               } else {\r
+                               echo "<input name='iprange' value='custom' type='hidden' />";\r
+                               echo "<input name='customiprange' value='' maxlength='15' size='15' />";\r
+                       }\r
+               ?>\r
+               </div>\r
+\r
+               <h3><?php echo _BAN_BLOGS?></h3>\r
+\r
+               <p><?php echo _BAN_BLOGS_TEXT?></p>\r
+\r
+               <div>\r
+                       <input type="hidden" name="blogid" value="<?php echo $blogid?>" />\r
+                       <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo htmlspecialchars($blog->getName())?>'</label>\r
+                       <br />\r
+                       <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>\r
+               </div>\r
+\r
+               <h3><?php echo _BAN_REASON_TITLE?></h3>\r
+\r
+               <p><?php echo _BAN_REASON_TEXT?></p>\r
+\r
+               <div><textarea name="reason" cols="40" rows="5"></textarea></div>\r
+\r
+               <h3><?php echo _BAN_ADD_TITLE?></h3>\r
+\r
+               <div>\r
+                       <input name="action" type="hidden" value="banlistadd" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />\r
+               </div>\r
+\r
+               </form>\r
+\r
+               <?php      $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlistadd() {\r
+               global $member;\r
+\r
+               $blogid =          intPostVar('blogid');\r
+               $allblogs =      postVar('allblogs');\r
+               $iprange =        postVar('iprange');\r
+               if ($iprange == "custom")\r
+                       $iprange = postVar('customiprange');\r
+               $reason =          postVar('reason');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               // TODO: check IP range validity\r
+\r
+               if (!$allblogs) {\r
+                       if (!BAN::addBan($blogid, $iprange, $reason))\r
+                               $this->error(_ERROR_ADDBAN);\r
+               } else {\r
+                       // get blogs fot which member has admin rights\r
+                       $adminblogs = $member->getAdminBlogs();\r
+                       $failed = 0;\r
+                       foreach ($adminblogs as $blogje) {\r
+                               if (!BAN::addBan($blogje, $iprange, $reason))\r
+                                       $failed = 1;\r
+                       }\r
+                       if ($failed)\r
+                               $this->error(_ERROR_ADDBAN);\r
+               }\r
+\r
+               $this->action_banlist();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_clearactionlog() {\r
+               global $member;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               ACTIONLOG::clear();\r
+\r
+               $this->action_manage(_MSG_ACTIONLOGCLEARED);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_backupoverview() {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';\r
+               ?>\r
+               <h2><?php echo _BACKUPS_TITLE?></h2>\r
+\r
+               <h3><?php echo _BACKUP_TITLE?></h3>\r
+\r
+               <p><?php echo _BACKUP_INTRO?></p>\r
+\r
+               <form method="post" action="index.php"><p>\r
+               <input type="hidden" name="action" value="backupcreate" />\r
+               <?php $manager->addTicketHidden() ?>\r
+\r
+               <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>\r
+               <br />\r
+               <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>\r
+               <br /><br />\r
+               <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />\r
+\r
+               </p></form>\r
+\r
+               <div class="note"><?php echo _BACKUP_NOTE?></div>\r
+\r
+\r
+               <h3><?php echo _RESTORE_TITLE?></h3>\r
+\r
+               <div class="note"><?php echo _RESTORE_NOTE?></div>\r
+\r
+               <p><?php echo _RESTORE_INTRO?></p>\r
+\r
+               <form method="post" action="index.php" enctype="multipart/form-data"><p>\r
+                       <input type="hidden" name="action" value="backuprestore" />\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input name="backup_file" type="file" tabindex="30" />\r
+                       <br /><br />\r
+                       <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />\r
+                       <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>\r
+                       <br /><?php echo _RESTORE_WARNING?>\r
+               </p></form>\r
+\r
+               <?php      $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_backupcreate() {\r
+               global $member, $DIR_LIBS;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // use compression ?\r
+               $useGzip = intval(postVar('gzip'));\r
+\r
+               include($DIR_LIBS . 'backup.php');\r
+\r
+               // try to extend time limit\r
+               // (creating/restoring dumps might take a while)\r
+               @set_time_limit(1200);\r
+\r
+               $bu = new Backup();\r
+               $bu->do_backup($useGzip);\r
+               exit;\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_backuprestore() {\r
+               global $member, $DIR_LIBS;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               if (intPostVar('letsgo') != 1)\r
+                       $this->error(_ERROR_BACKUP_NOTSURE);\r
+\r
+               include($DIR_LIBS . 'backup.php');\r
+\r
+               // try to extend time limit\r
+               // (creating/restoring dumps might take a while)\r
+               @set_time_limit(1200);\r
+\r
+               $bu = new Backup();\r
+               $message = $bu->do_restore();\r
+               if ($message != '')\r
+                       $this->error($message);\r
+\r
+               $this->pagehead();\r
+               ?>\r
+               <h2><?php echo _RESTORE_COMPLETE?></h2>\r
+               <?php      $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_pluginlist() {\r
+               global $member, $manager;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';\r
+\r
+               echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';\r
+\r
+               echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' &nbsp;&nbsp;<span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';\r
+\r
+\r
+               $query =  'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';\r
+\r
+               $template['content'] = 'pluginlist';\r
+               $template['tabindex'] = 10;\r
+               showlist($query, 'table', $template);\r
+\r
+               ?>\r
+                       <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>\r
+\r
+                       <p><?php echo _PLUGS_TEXT_UPDATE?></p>\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                               <input type="hidden" name="action" value="pluginupdate" />\r
+                               <?php $manager->addTicketHidden() ?>\r
+                               <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />\r
+                       </div></form>\r
+\r
+                       <h3><?php echo _PLUGS_TITLE_NEW?></h3>\r
+                       \r
+                       <?php\r
+                       // find a list of possibly non-installed plugins\r
+                               $candidates = array();\r
+                               global $DIR_PLUGINS;\r
+                               $dirhandle = opendir($DIR_PLUGINS);\r
+                               while ($filename = readdir($dirhandle) )\r
+                               {\r
+                                       # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0\r
+                                       # original ereg: ereg('^NP_(.*)\.php$',$filename,$matches)\r
+                                       if (preg_match('#^NP_(.*)\.php$#', $filename, $matches) )\r
+                                       {\r
+                                               $name = $matches[1];\r
+                                               // only show in list when not yet installed\r
+                                               $res = sql_query('SELECT * FROM ' . sql_table('plugin') . ' WHERE `pfile` = "NP_' . sql_real_escape_string($name) . '"');\r
+                                               if (sql_num_rows($res) == 0)\r
+                                               {\r
+                                                       array_push($candidates, $name);\r
+                                               }\r
+                                       }\r
+                               }\r
+                               closedir($dirhandle);\r
+                               \r
+                               if (sizeof($candidates) > 0)\r
+                               {\r
+                       ?>\r
+\r
+                       <p><?php echo _PLUGS_ADD_TEXT?></p>\r
+\r
+\r
+                       <form method='post' action='index.php'><div>\r
+                               <input type='hidden' name='action' value='pluginadd' />\r
+                               <?php $manager->addTicketHidden() ?>\r
+                               <select name="filename" tabindex="30">\r
+                               <?php   \r
+                               foreach($candidates as $name)\r
+                               {\r
+                                       echo '<option value="NP_',$name,'">',htmlspecialchars($name),'</option>';\r
+                               }\r
+                               ?>\r
+                               </select>\r
+                               <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />\r
+                       </div></form>\r
+\r
+               <?php\r
+                               }\r
+                               else\r
+                               {\r
+                               echo '<p>',_PLUGS_NOCANDIDATES,'</p>';\r
+                       }\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_pluginhelp() {\r
+               global $member, $manager, $DIR_PLUGINS, $CONF;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $plugid = intGetVar('plugid');\r
+\r
+               if (!$manager->pidInstalled($plugid))\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+\r
+               $plugName = getPluginNameFromPid($plugid);\r
+\r
+               $this->pagehead();\r
+\r
+               echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';\r
+\r
+               echo '<h2>',_PLUGS_HELP_TITLE,': ',htmlspecialchars($plugName),'</h2>';\r
+\r
+               $plug =& $manager->getPlugin($plugName);\r
+               $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';\r
+\r
+               if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {\r
+                       @readfile($helpFile);\r
+               } else {\r
+                       echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';\r
+                       echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';\r
+               }\r
+\r
+\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_pluginadd() {\r
+               global $member, $manager, $DIR_PLUGINS;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $name = postVar('filename');\r
+\r
+               if ($manager->pluginInstalled($name))\r
+                       $this->error(_ERROR_DUPPLUGIN);\r
+               if (!checkPlugin($name))\r
+                       $this->error(_ERROR_PLUGFILEERROR . ' (' . htmlspecialchars($name) . ')');\r
+\r
+               // get number of currently installed plugins\r
+               $res = sql_query('SELECT * FROM '.sql_table('plugin'));\r
+               $numCurrent = sql_num_rows($res);\r
+\r
+               // plugin will be added as last one in the list\r
+               $newOrder = $numCurrent + 1;\r
+\r
+               $manager->notify(\r
+                       'PreAddPlugin',\r
+                       array(\r
+                               'file' => &$name\r
+                       )\r
+               );\r
+\r
+               // do this before calling getPlugin (in case the plugin id is used there)\r
+               $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';\r
+               sql_query($query);\r
+               $iPid = sql_insert_id();\r
+\r
+               $manager->clearCachedInfo('installedPlugins');\r
+\r
+               // Load the plugin for condition checking and instalation\r
+               $plugin =& $manager->getPlugin($name);\r
+\r
+               // check if it got loaded (could have failed)\r
+               if (!$plugin)\r
+               {\r
+                       sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));\r
+                       $manager->clearCachedInfo('installedPlugins');\r
+                       $this->error(_ERROR_PLUGIN_LOAD);\r
+               }\r
+\r
+               // check if plugin needs a newer Nucleus version\r
+               if (getNucleusVersion() < $plugin->getMinNucleusVersion())\r
+               {\r
+                       // uninstall plugin again...\r
+                       $this->deleteOnePlugin($plugin->getID());\r
+\r
+                       // ...and show error\r
+                       $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars($plugin->getMinNucleusVersion()));\r
+               }\r
+\r
+               // check if plugin needs a newer Nucleus version\r
+               if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))\r
+               {\r
+                       // uninstall plugin again...\r
+                       $this->deleteOnePlugin($plugin->getID());\r
+\r
+                       // ...and show error\r
+                       $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );\r
+               }\r
+\r
+               $pluginList = $plugin->getPluginDep();\r
+               foreach ($pluginList as $pluginName)\r
+               {\r
+\r
+                       $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');\r
+                       if (sql_num_rows($res) == 0)\r
+                       {\r
+                               // uninstall plugin again...\r
+                               $this->deleteOnePlugin($plugin->getID());\r
+\r
+                               $this->error(sprintf(_ERROR_INSREQPLUGIN, htmlspecialchars($pluginName, ENT_QUOTES)));\r
+                       }\r
+               }\r
+\r
+               // call the install method of the plugin\r
+               $plugin->install();\r
+\r
+               $manager->notify(\r
+                       'PostAddPlugin',\r
+                       array(\r
+                               'plugin' => &$plugin\r
+                       )\r
+               );\r
+\r
+               // update all events\r
+               $this->action_pluginupdate();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_pluginupdate() {\r
+               global $member, $manager, $CONF;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // delete everything from plugin_events\r
+               sql_query('DELETE FROM '.sql_table('plugin_event'));\r
+\r
+               // loop over all installed plugins\r
+               $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));\r
+               while($o = sql_fetch_object($res)) {\r
+                       $pid = $o->pid;\r
+                       $plug =& $manager->getPlugin($o->pfile);\r
+                       if ($plug)\r
+                       {\r
+                               $eventList = $plug->getEventList();\r
+                               foreach ($eventList as $eventName)\r
+                                       sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.sql_real_escape_string($eventName).'\')');\r
+                       }\r
+               }\r
+\r
+               redirect($CONF['AdminURL'] . '?action=pluginlist');\r
+//             $this->action_pluginlist();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_plugindelete() {\r
+               global $member, $manager;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $pid = intGetVar('plugid');\r
+\r
+               if (!$manager->pidInstalled($pid))\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+\r
+               $this->pagehead();\r
+               ?>\r
+                       <h2><?php echo _DELETE_CONFIRM?></h2>\r
+\r
+                       <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>\r
+\r
+                       <form method="post" action="index.php"><div>\r
+                       <?php $manager->addTicketHidden() ?>\r
+                       <input type="hidden" name="action" value="plugindeleteconfirm" />\r
+                       <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />\r
+                       <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />\r
+                       </div></form>\r
+               <?php\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_plugindeleteconfirm() {\r
+               global $member, $manager, $CONF;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $pid = intPostVar('plugid');\r
+\r
+               $error = $this->deleteOnePlugin($pid, 1);\r
+               if ($error) {\r
+                       $this->error($error);\r
+               }\r
+\r
+               redirect($CONF['AdminURL'] . '?action=pluginlist');\r
+//             $this->action_pluginlist();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function deleteOnePlugin($pid, $callUninstall = 0) {\r
+               global $manager;\r
+\r
+               $pid = intval($pid);\r
+\r
+               if (!$manager->pidInstalled($pid))\r
+                       return _ERROR_NOSUCHPLUGIN;\r
+\r
+               $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);\r
+\r
+/*             // call the unInstall method of the plugin\r
+               if ($callUninstall) {\r
+                       $plugin =& $manager->getPlugin($name);\r
+                       if ($plugin) $plugin->unInstall();\r
+               }*/\r
+\r
+               // check dependency before delete\r
+               $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));\r
+               while($o = sql_fetch_object($res)) {\r
+                       $plug =& $manager->getPlugin($o->pfile);\r
+                       if ($plug)\r
+                       {\r
+                               $depList = $plug->getPluginDep();\r
+                               foreach ($depList as $depName)\r
+                               {\r
+                                       if ($name == $depName)\r
+                                       {\r
+                                               return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+\r
+               $manager->notify('PreDeletePlugin', array('plugid' => $pid));\r
+\r
+               // call the unInstall method of the plugin\r
+               if ($callUninstall) {\r
+                       $plugin =& $manager->getPlugin($name);\r
+                       if ($plugin) $plugin->unInstall();\r
+               }\r
+\r
+               // delete all subscriptions\r
+               sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);\r
+\r
+               // delete all options\r
+               // get OIDs from plugin_option_desc\r
+               $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);\r
+               $aOIDs = array();\r
+               while ($o = sql_fetch_object($res)) {\r
+                       array_push($aOIDs, $o->oid);\r
+               }\r
+\r
+               // delete from plugin_option and plugin_option_desc\r
+               sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);\r
+               if (count($aOIDs) > 0)\r
+                       sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');\r
+\r
+               // update order numbers\r
+               $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);\r
+               $o = sql_fetch_object($res);\r
+               sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);\r
+\r
+               // delete row\r
+               sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);\r
+\r
+               $manager->clearCachedInfo('installedPlugins');\r
+               $manager->notify('PostDeletePlugin', array('plugid' => $pid));\r
+\r
+               return '';\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_pluginup() {\r
+               global $member, $manager, $CONF;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $plugid = intGetVar('plugid');\r
+\r
+               if (!$manager->pidInstalled($plugid))\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+\r
+               // 1. get old order number\r
+               $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);\r
+               $o = sql_fetch_object($res);\r
+               $oldOrder = $o->porder;\r
+\r
+               // 2. calculate new order number\r
+               $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;\r
+\r
+               // 3. update plug numbers\r
+               sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);\r
+               sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);\r
+\r
+               //$this->action_pluginlist();\r
+               // To avoid showing ticket in the URL, redirect to pluginlist, instead.\r
+               redirect($CONF['AdminURL'] . '?action=pluginlist');\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_plugindown() {\r
+               global $member, $manager, $CONF;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $plugid = intGetVar('plugid');\r
+               if (!$manager->pidInstalled($plugid))\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+\r
+               // 1. get old order number\r
+               $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);\r
+               $o = sql_fetch_object($res);\r
+               $oldOrder = $o->porder;\r
+\r
+               $res = sql_query('SELECT * FROM '.sql_table('plugin'));\r
+               $maxOrder = sql_num_rows($res);\r
+\r
+               // 2. calculate new order number\r
+               $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;\r
+\r
+               // 3. update plug numbers\r
+               sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);\r
+               sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);\r
+\r
+               //$this->action_pluginlist();\r
+               // To avoid showing ticket in the URL, redirect to pluginlist, instead.\r
+               redirect($CONF['AdminURL'] . '?action=pluginlist');\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_pluginoptions($message = '') {\r
+               global $member, $manager;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $pid = intRequestVar('plugid');\r
+               if (!$manager->pidInstalled($pid))\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+\r
+               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';\r
+               $pluginName = htmlspecialchars(getPluginNameFromPid($pid), ENT_QUOTES);\r
+               $this->pagehead($extrahead);\r
+\r
+               ?>\r
+                       <p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>\r
+\r
+                       <h2><?php echo sprintf(_PLUGIN_OPTIONS_TITLE, $pluginName) ?></h2>\r
+\r
+                       <?php if  ($message) echo $message?>\r
+\r
+                       <form action="index.php" method="post">\r
+                       <div>\r
+                               <input type="hidden" name="action" value="pluginoptionsupdate" />\r
+                               <input type="hidden" name="plugid" value="<?php echo $pid?>" />\r
+\r
+               <?php\r
+\r
+               $manager->addTicketHidden();\r
+\r
+               $aOptions = array();\r
+               $aOIDs = array();\r
+               $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';\r
+               $r = sql_query($query);\r
+               while ($o = sql_fetch_object($r)) {\r
+                       array_push($aOIDs, $o->oid);\r
+                       $aOptions[$o->oid] = array(\r
+                                               'oid' => $o->oid,\r
+                                               'value' => $o->odef,\r
+                                               'name' => $o->oname,\r
+                                               'description' => $o->odesc,\r
+                                               'type' => $o->otype,\r
+                                               'typeinfo' => $o->oextra,\r
+                                               'contextid' => 0\r
+                       );\r
+               }\r
+               // fill out actual values\r
+               if (count($aOIDs) > 0) {\r
+                       $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');\r
+                       while ($o = sql_fetch_object($r))\r
+                               $aOptions[$o->oid]['value'] = $o->ovalue;\r
+               }\r
+\r
+               // call plugins\r
+               $manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));\r
+\r
+               $template['content'] = 'plugoptionlist';\r
+               $amount = showlist($aOptions,'table',$template);\r
+               if ($amount == 0)\r
+                       echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';\r
+\r
+               ?>\r
+                       </div>\r
+                       </form>\r
+               <?php      $this->pagefoot();\r
+\r
+\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_pluginoptionsupdate() {\r
+               global $member, $manager;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $pid = intRequestVar('plugid');\r
+               if (!$manager->pidInstalled($pid))\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+\r
+               $aOptions = requestArray('plugoption');\r
+               NucleusPlugin::_applyPluginOptions($aOptions);\r
+\r
+               $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));\r
+\r
+               $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);\r
+       }\r
+\r
+       /**\r
+        * @static\r
+        * @todo document this\r
+        */\r
+       function _insertPluginOptions($context, $contextid = 0) {\r
+               // get all current values for this contextid\r
+               // (note: this might contain doubles for overlapping contextids)\r
+               $aIdToValue = array();\r
+               $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));\r
+               while ($o = sql_fetch_object($res)) {\r
+                       $aIdToValue[$o->oid] = $o->ovalue;\r
+               }\r
+\r
+               // get list of oids per pid\r
+               $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')\r
+                          . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';\r
+               $res = sql_query($query);\r
+               $aOptions = array();\r
+               while ($o = sql_fetch_object($res)) {\r
+                       if (in_array($o->oid, array_keys($aIdToValue)))\r
+                               $value = $aIdToValue[$o->oid];\r
+                       else\r
+                               $value = $o->odef;\r
+\r
+                       array_push($aOptions, array(\r
+                               'pid' => $o->pid,\r
+                               'pfile' => $o->pfile,\r
+                               'oid' => $o->oid,\r
+                               'value' => $value,\r
+                               'name' => $o->oname,\r
+                               'description' => $o->odesc,\r
+                               'type' => $o->otype,\r
+                               'typeinfo' => $o->oextra,\r
+                               'contextid' => $contextid,\r
+                               'extra' => ''\r
+                       ));\r
+               }\r
+\r
+               global $manager;\r
+               $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));\r
+\r
+\r
+               $iPrevPid = -1;\r
+               foreach ($aOptions as $aOption) {\r
+\r
+                       // new plugin?\r
+                       if ($iPrevPid != $aOption['pid']) {\r
+                               $iPrevPid = $aOption['pid'];\r
+                               if (!defined('_PLUGIN_OPTIONS_TITLE')) {\r
+                                       define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');\r
+                               }\r
+                               echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, htmlspecialchars($aOption['pfile'], ENT_QUOTES)).'</th></tr>';\r
+                       }\r
+                       \r
+                       $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);\r
+                       if (@$meta['access'] != 'hidden') {\r
+                               echo '<tr>';\r
+                               listplug_plugOptionRow($aOption);\r
+                               echo '</tr>';\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Helper functions to create option forms etc.\r
+        * @todo document parameters\r
+        */\r
+       function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {\r
+               $id = htmlspecialchars($name);\r
+               $id = str_replace('[','-',$id);\r
+               $id = str_replace(']','-',$id);\r
+               $id1 = $id . htmlspecialchars($value1);\r
+               $id2 = $id . htmlspecialchars($value2);\r
+\r
+               if ($name=="admin") {\r
+                       echo '<input onclick="selectCanLogin(true);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';\r
+               } else {\r
+                       echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';\r
+               }\r
+\r
+                       if ($checkedval == $value1)\r
+                               echo "tabindex='$tabindex' checked='checked'";\r
+                       echo ' id="'.$id1.'" /><label for="'.$id1.'">' . $yesval . '</label>';\r
+               echo ' ';\r
+               if ($name=="admin") {\r
+                       echo '<input onclick="selectCanLogin(false);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';\r
+               } else {\r
+                       echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';\r
+               }\r
+                       if ($checkedval != $value1)\r
+                               echo "tabindex='$tabindex' checked='checked'";\r
+                       if ($isAdmin && $name=="canlogin")\r
+                               echo ' disabled="disabled"';\r
+                       echo ' id="'.$id2.'" /><label for="'.$id2.'">' . $noval . '</label>';\r
+       }\r
+\r
+} // class ADMIN\r
+\r
+?>
\ No newline at end of file