3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2007 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * The code for the Nucleus admin area
15 * @license http://nucleuscms.org/license.txt GNU General Public License
16 * @copyright Copyright (C) 2002-2007 The Nucleus Group
17 * @version $Id: ADMIN.php,v 1.22 2007-05-10 08:38:33 kimitake Exp $
18 * @version $NucleusJP: ADMIN.php,v 1.21 2007/04/27 19:05:53 kimitake Exp $
21 if ( !function_exists('requestVar') ) exit;
22 require_once dirname(__FILE__) . '/showlist.php';
25 * Builds the admin area and executes admin actions
30 * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
44 * @param string $action action to be performed
46 function action($action) {
47 global $CONF, $manager;
49 // list of action aliases
51 'login' => 'overview',
55 if (isset($alias[$action]))
56 $action = $alias[$action];
58 $methodName = 'action_' . $action;
60 $this->action = strtolower($action);
62 // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
63 // is an action that requires user interaction before something is actually done)
64 // all safe actions are in this array:
65 $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');
67 // the rest of the actions needs to be checked
68 $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');
70 if (!in_array($this->action, $aActionsNotToCheck))
72 if (!$manager->checkTicket())
73 $this->error(_ERROR_BADTICKET);
76 if (method_exists($this, $methodName))
77 call_user_func(array(&$this, $methodName));
79 $this->error(_BADACTION . htmlspecialchars(" ($action)"));
86 function action_showlogin() {
88 $this->action_login($error);
94 function action_login($msg = '', $passvars = 1) {
97 // skip to overview when allowed
98 if ($member->isLoggedIn() && $member->canLogin()) {
99 $this->action_overview();
105 echo '<h2>', _LOGIN ,'</h2>';
106 if ($msg) echo _MESSAGE , ': ', htmlspecialchars($msg);
109 <form action="index.php" method="post"><p>
110 <?php echo _LOGIN_NAME?>: <br /><input name="login" tabindex="10" />
112 <?php echo _LOGIN_PASSWORD?>: <br /><input name="password" tabindex="20" type="password" />
114 <input name="action" value="login" type="hidden" />
116 <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
119 <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
120 <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
122 <?php // pass through vars
124 $oldaction = postVar('oldaction');
125 if ( ($oldaction != 'logout') && ($oldaction != 'login') && $passvars ) {
132 <?php $this->pagefoot();
137 * provides a screen with the overview of the actions available
138 * @todo document parameter
140 function action_overview($msg = '') {
146 echo _MESSAGE , ': ', $msg;
148 /* ---- add items ---- */
149 echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
151 $showAll = requestVar('showall');
153 if (($member->isAdmin()) && ($showAll == 'yes')) {
154 // Super-Admins have access to all blogs! (no add item support though)
155 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
156 . ' FROM ' . sql_table('blog')
159 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
160 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
161 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
164 $template['content'] = 'bloglist';
165 $template['superadmin'] = $member->isAdmin();
166 $amount = showlist($query,'table',$template);
168 if (($showAll != 'yes') && ($member->isAdmin())) {
169 $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
170 if ($total > $amount)
171 echo '<p><a href="index.php?action=overview&showall=yes">Show all blogs</a></p>';
175 echo _OVERVIEW_NOBLOGS;
178 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
179 $query = 'SELECT ititle, inumber, bshortname'
180 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
181 . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
182 $template['content'] = 'draftlist';
183 $amountdrafts = showlist($query, 'table', $template);
184 if ($amountdrafts == 0)
185 echo _OVERVIEW_NODRAFTS;
188 /* ---- user settings ---- */
189 echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
191 echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
192 echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
193 echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
196 /* ---- general settings ---- */
197 if ($member->isAdmin()) {
198 echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
200 echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
209 * Returns a link to a weblog
212 function bloglink(&$blog) {
213 return '<a href="'.htmlspecialchars($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. htmlspecialchars( $blog->getName() ) .'</a>';
217 * @todo document this
219 function action_manage($msg = '') {
222 $member->isAdmin() or $this->disallow();
226 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
229 echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
232 echo '<h2>' . _MANAGE_GENERAL. '</h2>';
235 echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
236 echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
237 echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
238 echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
241 echo '<h2>' . _MANAGE_SKINS . '</h2>';
243 echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
244 echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
245 echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
248 echo '<h2>' . _MANAGE_EXTRA . '</h2>';
250 echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
251 echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
258 * @todo document this
260 function action_itemlist($blogid = '') {
261 global $member, $manager;
264 $blogid = intRequestVar('blogid');
266 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
269 $blog =& $manager->getBlog($blogid);
271 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
272 echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
275 if (postVar('start'))
276 $start = intPostVar('start');
281 echo '<p><a href="index.php?action=createitem&blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
283 // amount of items to show
284 if (postVar('amount'))
285 $amount = intPostVar('amount');
289 $search = postVar('search'); // search through items
291 $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
292 . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
293 . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
296 $query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))';
298 // non-blog-admins can only edit/delete their own items
299 if (!$member->blogAdminRights($blogid))
300 $query .= ' and iauthor=' . $member->getID();
303 $query .= ' ORDER BY itime DESC'
304 . " LIMIT $start,$amount";
306 $template['content'] = 'itemlist';
307 $template['now'] = $blog->getCorrectTime(time());
309 $manager->loadClass("ENCAPSULATE");
310 $navList =& new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
311 $navList->showBatchList('item',$query,'table',$template);
318 * @todo document this
320 function action_batchitem() {
321 global $member, $manager;
323 // check if logged in
324 $member->isLoggedIn() or $this->disallow();
326 // more precise check will be done for each performed operation
328 // get array of itemids from request
329 $selected = requestIntArray('batch');
330 $action = requestVar('batchaction');
332 // Show error when no items were selected
333 if (!is_array($selected) || sizeof($selected) == 0)
334 $this->error(_BATCH_NOSELECTION);
336 // On move: when no destination blog/category chosen, show choice now
337 $destCatid = intRequestVar('destcatid');
338 if (($action == 'move') && (!$manager->existsCategory($destCatid)))
339 $this->batchMoveSelectDestination('item',$selected);
341 // On delete: check if confirmation has been given
342 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
343 $this->batchAskDeleteConfirmation('item',$selected);
347 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
348 echo '<h2>',_BATCH_ITEMS,'</h2>';
349 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
353 // walk over all itemids and perform action
354 foreach ($selected as $itemid) {
355 $itemid = intval($itemid);
356 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
358 // perform action, display errors if needed
361 $error = $this->deleteOneItem($itemid);
364 $error = $this->moveOneItem($itemid, $destCatid);
367 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
370 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
375 echo '<b>',_BATCH_DONE,'</b>';
383 * @todo document this
385 function action_batchcomment() {
388 // check if logged in
389 $member->isLoggedIn() or $this->disallow();
391 // more precise check will be done for each performed operation
393 // get array of itemids from request
394 $selected = requestIntArray('batch');
395 $action = requestVar('batchaction');
397 // Show error when no items were selected
398 if (!is_array($selected) || sizeof($selected) == 0)
399 $this->error(_BATCH_NOSELECTION);
401 // On delete: check if confirmation has been given
402 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
403 $this->batchAskDeleteConfirmation('comment',$selected);
407 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
408 echo '<h2>',_BATCH_COMMENTS,'</h2>';
409 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
412 // walk over all itemids and perform action
413 foreach ($selected as $commentid) {
414 $commentid = intval($commentid);
415 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
417 // perform action, display errors if needed
420 $error = $this->deleteOneComment($commentid);
423 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
426 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
431 echo '<b>',_BATCH_DONE,'</b>';
439 * @todo document this
441 function action_batchmember() {
444 // check if logged in and admin
445 ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
447 // get array of itemids from request
448 $selected = requestIntArray('batch');
449 $action = requestVar('batchaction');
451 // Show error when no members selected
452 if (!is_array($selected) || sizeof($selected) == 0)
453 $this->error(_BATCH_NOSELECTION);
455 // On delete: check if confirmation has been given
456 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
457 $this->batchAskDeleteConfirmation('member',$selected);
461 echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
462 echo '<h2>',_BATCH_MEMBERS,'</h2>';
463 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
466 // walk over all itemids and perform action
467 foreach ($selected as $memberid) {
468 $memberid = intval($memberid);
469 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
471 // perform action, display errors if needed
474 $error = $this->deleteOneMember($memberid);
478 sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
482 // there should always remain at least one super-admin
483 $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
484 if (mysql_num_rows($r) < 2)
485 $error = _ERROR_ATLEASTONEADMIN;
487 sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
490 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
493 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
498 echo '<b>',_BATCH_DONE,'</b>';
506 * @todo document this
508 function action_batchteam() {
511 $blogid = intRequestVar('blogid');
513 // check if logged in and admin
514 ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
516 // get array of itemids from request
517 $selected = requestIntArray('batch');
518 $action = requestVar('batchaction');
520 // Show error when no members selected
521 if (!is_array($selected) || sizeof($selected) == 0)
522 $this->error(_BATCH_NOSELECTION);
524 // On delete: check if confirmation has been given
525 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
526 $this->batchAskDeleteConfirmation('team',$selected);
530 echo '<p><a href="index.php?action=manageteam&blogid=',$blogid,'">(',_BACK,')</a></p>';
532 echo '<h2>',_BATCH_TEAM,'</h2>';
533 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
536 // walk over all itemids and perform action
537 foreach ($selected as $memberid) {
538 $memberid = intval($memberid);
539 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
541 // perform action, display errors if needed
544 $error = $this->deleteOneTeamMember($blogid, $memberid);
548 sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
552 // there should always remain at least one admin
553 $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
554 if (mysql_num_rows($r) < 2)
555 $error = _ERROR_ATLEASTONEBLOGADMIN;
557 sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
560 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
563 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
568 echo '<b>',_BATCH_DONE,'</b>';
576 * @todo document this
578 function action_batchcategory() {
579 global $member, $manager;
581 // check if logged in
582 $member->isLoggedIn() or $this->disallow();
584 // more precise check will be done for each performed operation
586 // get array of itemids from request
587 $selected = requestIntArray('batch');
588 $action = requestVar('batchaction');
590 // Show error when no items were selected
591 if (!is_array($selected) || sizeof($selected) == 0)
592 $this->error(_BATCH_NOSELECTION);
594 // On move: when no destination blog chosen, show choice now
595 $destBlogId = intRequestVar('destblogid');
596 if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
597 $this->batchMoveCategorySelectDestination('category',$selected);
599 // On delete: check if confirmation has been given
600 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
601 $this->batchAskDeleteConfirmation('category',$selected);
605 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
606 echo '<h2>',BATCH_CATEGORIES,'</h2>';
607 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
610 // walk over all itemids and perform action
611 foreach ($selected as $catid) {
612 $catid = intval($catid);
613 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
615 // perform action, display errors if needed
618 $error = $this->deleteOneCategory($catid);
621 $error = $this->moveOneCategory($catid, $destBlogId);
624 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
627 echo '<b>',($error ? 'Error: '.$error : _BATCH_SUCCESS),'</b>';
632 echo '<b>',_BATCH_DONE,'</b>';
639 * @todo document this
641 function batchMoveSelectDestination($type, $ids) {
645 <h2><?php echo _MOVE_TITLE?></h2>
646 <form method="post" action="index.php"><div>
648 <input type="hidden" name="action" value="batch<?php echo $type?>" />
649 <input type="hidden" name="batchaction" value="move" />
651 $manager->addTicketHidden();
653 // insert selected item numbers
655 foreach ($ids as $id)
656 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
658 // show blog/category selection list
659 $this->selectBlogCategory('destcatid');
664 <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
667 <?php $this->pagefoot();
672 * @todo document this
674 function batchMoveCategorySelectDestination($type, $ids) {
678 <h2><?php echo _MOVECAT_TITLE?></h2>
679 <form method="post" action="index.php"><div>
681 <input type="hidden" name="action" value="batch<?php echo $type?>" />
682 <input type="hidden" name="batchaction" value="move" />
684 $manager->addTicketHidden();
686 // insert selected item numbers
688 foreach ($ids as $id)
689 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
691 // show blog/category selection list
692 $this->selectBlog('destblogid');
697 <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
700 <?php $this->pagefoot();
705 * @todo document this
707 function batchAskDeleteConfirmation($type, $ids) {
712 <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
713 <form method="post" action="index.php"><div>
715 <input type="hidden" name="action" value="batch<?php echo $type?>" />
716 <?php $manager->addTicketHidden() ?>
717 <input type="hidden" name="batchaction" value="delete" />
718 <input type="hidden" name="confirmation" value="yes" />
719 <?php // insert selected item numbers
721 foreach ($ids as $id)
722 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
724 // add hidden vars for team & comment
727 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
729 if ($type == 'comment')
731 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
736 <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
739 <?php $this->pagefoot();
745 * Inserts a HTML select element with choices for all categories to which the current
747 * @see function selectBlog
749 function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
750 ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
754 * Inserts a HTML select element with choices for all blogs to which the user has access
755 * mode = 'blog' => shows blognames and values are blogids
756 * mode = 'category' => show category names and values are catids
758 * @param $iForcedBlogInclude
759 * ID of a blog that always needs to be included, without checking if the
760 * member is on the blog team (-1 = none)
761 * @todo document parameters
763 function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
764 global $member, $CONF;
766 // 0. get IDs of blogs to which member can post items (+ forced blog)
768 if ($iForcedBlogInclude != -1)
769 $aBlogIds[] = intval($iForcedBlogInclude);
771 if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))
772 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
774 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
775 $rblogids = sql_query($queryBlogs);
776 while ($o = mysql_fetch_object($rblogids))
777 if ($o->bnumber != $iForcedBlogInclude)
778 $aBlogIds[] = intval($o->bnumber);
780 if (count($aBlogIds) == 0)
783 echo '<select name="',$name,'" tabindex="',$tabindex,'">';
785 // 1. select blogs (we'll create optiongroups)
786 // (only select those blogs that have the user on the team)
787 $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
788 $blogs = sql_query($queryBlogs);
789 if ($mode == 'category') {
790 if (mysql_num_rows($blogs) > 1)
793 while ($oBlog = mysql_fetch_object($blogs)) {
795 echo '<optgroup label="',htmlspecialchars($oBlog->bname),'">';
797 // show selection to create new category when allowed/wanted
799 // check if allowed to do so
800 if ($member->blogAdminRights($oBlog->bnumber))
801 echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
804 // 2. for each category in that blog
805 $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
806 while ($oCat = mysql_fetch_object($categories)) {
807 if ($oCat->catid == $selected)
808 $selectText = ' selected="selected" ';
811 echo '<option value="',$oCat->catid,'" ', $selectText,'>',htmlspecialchars($oCat->cname),'</option>';
819 while ($oBlog = mysql_fetch_object($blogs)) {
820 echo '<option value="',$oBlog->bnumber,'"';
821 if ($oBlog->bnumber == $selected)
822 echo ' selected="selected"';
823 echo'>',htmlspecialchars($oBlog->bname),'</option>';
831 * @todo document this
833 function action_browseownitems() {
834 global $member, $manager;
838 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
839 echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
842 if (postVar('start'))
843 $start = intPostVar('start');
847 // amount of items to show
848 if (postVar('amount'))
849 $amount = intPostVar('amount');
853 $search = postVar('search'); // search through items
855 $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
856 . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
857 . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
860 $query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))';
862 $query .= ' ORDER BY itime DESC'
863 . " LIMIT $start,$amount";
865 $template['content'] = 'itemlist';
866 $template['now'] = time();
868 $manager->loadClass("ENCAPSULATE");
869 $navList =& new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
870 $navList->showBatchList('item',$query,'table',$template);
877 * Show all the comments for a given item
880 function action_itemcommentlist($itemid = '') {
881 global $member, $manager;
884 $itemid = intRequestVar('itemid');
886 // only allow if user is allowed to alter item
887 $member->canAlterItem($itemid) or $this->disallow();
889 // ED$ what is this??? getBlogIDFromItemId()??
890 $blogid = getBlogIdFromItemId($itemid);
895 if (postVar('start'))
896 $start = intPostVar('start');
900 // amount of items to show
901 if (postVar('amount'))
902 $amount = intPostVar('amount');
906 $search = postVar('search');
908 echo '<p>(<a href="index.php?action=itemlist&blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
909 echo '<h2>',_COMMENTS,'</h2>';
911 $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;
914 $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
916 $query .= ' ORDER BY ctime ASC'
917 . " LIMIT $start,$amount";
919 $template['content'] = 'commentlist';
920 $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
922 $manager->loadClass("ENCAPSULATE");
923 $navList =& new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
924 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
930 * Browse own comments
932 function action_browseowncomments() {
933 global $member, $manager;
936 if (postVar('start'))
937 $start = intPostVar('start');
941 // amount of items to show
942 if (postVar('amount'))
943 $amount = intPostVar('amount');
947 $search = postVar('search');
950 $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();
953 $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
955 $query .= ' ORDER BY ctime DESC'
956 . " LIMIT $start,$amount";
960 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
961 echo '<h2>', _COMMENTS_YOUR ,'</h2>';
963 $template['content'] = 'commentlist';
964 $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
966 $manager->loadClass("ENCAPSULATE");
967 $navList =& new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
968 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
974 * Browse all comments for a weblog
977 function action_blogcommentlist($blogid = '')
979 global $member, $manager;
982 $blogid = intRequestVar('blogid');
984 $blogid = intval($blogid);
986 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
989 if (postVar('start'))
990 $start = intPostVar('start');
994 // amount of items to show
995 if (postVar('amount'))
996 $amount = intPostVar('amount');
1000 $search = postVar('search'); // search through comments
1003 $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);
1006 $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
1009 $query .= ' ORDER BY ctime DESC'
1010 . " LIMIT $start,$amount";
1013 $blog =& $manager->getBlog($blogid);
1017 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1018 echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
1020 $template['content'] = 'commentlist';
1021 $template['canAddBan'] = $member->blogAdminRights($blogid);
1023 $manager->loadClass("ENCAPSULATE");
1024 $navList =& new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
1025 $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
1031 * Provide a page to item a new item to the given blog
1033 function action_createitem() {
1034 global $member, $manager;
1036 $blogid = intRequestVar('blogid');
1039 $member->teamRights($blogid) or $this->disallow();
1041 $memberid = $member->getID();
1043 $blog =& $manager->getBlog($blogid);
1047 // generate the add-item form
1048 $formfactory =& new PAGEFACTORY($blogid);
1049 $formfactory->createAddForm('admin');
1055 * @todo document this
1057 function action_itemedit() {
1058 global $member, $manager;
1060 $itemid = intRequestVar('itemid');
1062 // only allow if user is allowed to alter item
1063 $member->canAlterItem($itemid) or $this->disallow();
1065 $item =& $manager->getItem($itemid,1,1);
1066 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1068 $manager->notify('PrepareItemForEdit', array('item' => &$item));
1070 if ($blog->convertBreaks()) {
1071 $item['body'] = removeBreaks($item['body']);
1072 $item['more'] = removeBreaks($item['more']);
1075 // form to edit blog items
1077 $formfactory =& new PAGEFACTORY($blog->getID());
1078 $formfactory->createEditForm('admin',$item);
1083 * @todo document this
1085 function action_itemupdate() {
1086 global $member, $manager, $CONF;
1088 $itemid = intRequestVar('itemid');
1089 $catid = postVar('catid');
1091 // only allow if user is allowed to alter item
1092 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1094 $actiontype = postVar('actiontype');
1096 // delete actions are handled by itemdelete (which has confirmation)
1097 if ($actiontype == 'delete') {
1098 $this->action_itemdelete();
1102 $body = postVar('body');
1103 $title = postVar('title');
1104 $more = postVar('more');
1105 $closed = intPostVar('closed');
1106 $draftid = intPostVar('draftid');
1108 // default action = add now
1110 $actiontype='addnow';
1112 // create new category if needed
1113 if (strstr($catid,'newcat')) {
1115 list($blogid) = sscanf($catid,"newcat-%d");
1118 $blog =& $manager->getBlog($blogid);
1119 $catid = $blog->createNewCategory();
1121 // show error when sth goes wrong
1123 $this->doError(_ERROR_CATCREATEFAIL);
1127 set some variables based on actiontype
1130 draft items -> addnow, addfuture, adddraft, delete
1131 non-draft items -> edit, changedate, delete
1134 $timestamp: set to a nonzero value for future dates or date changes
1135 $wasdraft: set to 1 when the item used to be a draft item
1136 $publish: set to 1 when the edited item is not a draft
1138 switch ($actiontype) {
1147 $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year'));
1155 $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year'));
1166 // edit the item for real
1167 ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
1169 $blogid = getBlogIDFromItemID($itemid);
1170 $blog =& $manager->getBlog($blogid);
1173 if ($timestamp > $blog->getCorrectTime(time())) {
1177 $this->updateFuturePosted($blogid);
1180 ITEM::delete($draftid);
1183 if (!$closed && $publish && $wasdraft && $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0 && !$isFuture) {
1184 $this->action_sendping($blogid);
1188 // show category edit window when we created a new category
1189 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1190 if ($catid != intPostVar('catid')) {
1191 $this->action_categoryedit(
1194 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1197 // TODO: set start item correctly for itemlist
1198 $this->action_itemlist(getBlogIDFromItemID($itemid));
1203 * @todo document this
1205 function action_itemdelete() {
1206 global $member, $manager;
1208 $itemid = intRequestVar('itemid');
1210 // only allow if user is allowed to alter item
1211 $member->canAlterItem($itemid) or $this->disallow();
1213 if (!$manager->existsItem($itemid,1,1))
1214 $this->error(_ERROR_NOSUCHITEM);
1216 $item =& $manager->getItem($itemid,1,1);
1217 $title = htmlspecialchars(strip_tags($item['title']));
1218 $body = strip_tags($item['body']);
1219 $body = htmlspecialchars(shorten($body,300,'...'));
1223 <h2><?php echo _DELETE_CONFIRM?></h2>
1225 <p><?php echo _CONFIRMTXT_ITEM?></p>
1228 <b>"<?php echo $title ?>"</b>
1233 <form method="post" action="index.php"><div>
1234 <input type="hidden" name="action" value="itemdeleteconfirm" />
1235 <?php $manager->addTicketHidden() ?>
1236 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1237 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" tabindex="10" />
1244 * @todo document this
1246 function action_itemdeleteconfirm() {
1249 $itemid = intRequestVar('itemid');
1251 // only allow if user is allowed to alter item
1252 $member->canAlterItem($itemid) or $this->disallow();
1254 // get blogid first ED$ What is this? getBlogIDFromItemId()???
1255 $blogid = getBlogIdFromItemId($itemid);
1257 // delete item (note: some checks will be performed twice)
1258 $this->deleteOneItem($itemid);
1260 $this->action_itemlist($blogid);
1264 * Deletes one item and returns error if something goes wrong
1265 * @param int $itemid
1267 function deleteOneItem($itemid) {
1268 global $member, $manager;
1270 // only allow if user is allowed to alter item (also checks if itemid exists)
1271 if (!$member->canAlterItem($itemid))
1272 return _ERROR_DISALLOWED;
1274 // need to get blogid before the item is deleted
1275 $blogid = getBlogIDFromItemId($itemid);
1277 $manager->loadClass('ITEM');
1278 ITEM::delete($itemid);
1280 // update blog's futureposted
1281 $this->updateFuturePosted($blogid);
1285 * Update a blog's future posted flag
1286 * @param int $blogid
1288 function updateFuturePosted($blogid) {
1291 $blog =& $manager->getBlog($blogid);
1292 $currenttime = $blog->getCorrectTime(time());
1293 $result = sql_query("SELECT * FROM ".sql_table('item').
1294 " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
1295 if (mysql_num_rows($result) > 0) {
1296 $blog->setFuturePost();
1299 $blog->clearFuturePost();
1304 * @todo document this
1306 function action_itemmove() {
1307 global $member, $manager;
1309 $itemid = intRequestVar('itemid');
1311 // only allow if user is allowed to alter item
1312 $member->canAlterItem($itemid) or $this->disallow();
1314 $item =& $manager->getItem($itemid,1,1);
1318 <h2><?php echo _MOVE_TITLE?></h2>
1319 <form method="post" action="index.php"><div>
1320 <input type="hidden" name="action" value="itemmoveto" />
1321 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1325 $manager->addTicketHidden();
1326 $this->selectBlogCategory('catid',$item['catid'],10,1);
1329 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
1336 * @todo document this
1338 function action_itemmoveto() {
1339 global $member, $manager;
1341 $itemid = intRequestVar('itemid');
1342 $catid = requestVar('catid');
1344 // create new category if needed
1345 if (strstr($catid,'newcat')) {
1347 list($blogid) = sscanf($catid,'newcat-%d');
1350 $blog =& $manager->getBlog($blogid);
1351 $catid = $blog->createNewCategory();
1353 // show error when sth goes wrong
1355 $this->doError(_ERROR_CATCREATEFAIL);
1358 // only allow if user is allowed to alter item
1359 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1361 $old_blogid = getBlogIDFromItemId($itemid);
1363 ITEM::move($itemid, $catid);
1365 // set the futurePosted flag on the blog
1366 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
1368 // reset the futurePosted in case the item is moved from one blog to another
1369 $this->updateFuturePosted($old_blogid);
1371 if ($catid != intRequestVar('catid'))
1372 $this->action_categoryedit($catid, $blog->getID());
1374 $this->action_itemlist(getBlogIDFromCatID($catid));
1378 * Moves one item to a given category (category existance should be checked by caller)
1379 * errors are returned
1380 * @param int $itemid
1381 * @param int $destCatid category ID to which the item will be moved
1383 function moveOneItem($itemid, $destCatid) {
1386 // only allow if user is allowed to move item
1387 if (!$member->canUpdateItem($itemid, $destCatid))
1388 return _ERROR_DISALLOWED;
1390 ITEM::move($itemid, $destCatid);
1394 * Adds a item to the chosen blog
1396 function action_additem() {
1397 global $member, $manager, $CONF;
1399 $manager->loadClass('ITEM');
1401 $result = ITEM::createFromRequest();
1403 if ($result['status'] == 'error')
1404 $this->error($result['message']);
1406 $blogid = getBlogIDFromItemID($result['itemid']);
1407 $blog =& $manager->getBlog($blogid);
1409 $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid));
1411 if ($result['status'] == 'newcategory')
1412 $this->action_categoryedit(
1415 $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0 ? $pingUrl : ''
1417 elseif ((postVar('actiontype') == 'addnow') && $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0)
1418 $this->action_sendping($blogid);
1420 $this->action_itemlist($blogid);
1424 * Shows a window that says we're about to ping.
1425 * immediately refresh to the real pinging page, which will
1426 * show an error, or redirect to the blog.
1428 * @param int $blogid ID of blog for which ping needs to be sent out
1430 function action_sendping($blogid = -1) {
1431 global $member, $manager;
1434 $blogid = intRequestVar('blogid');
1436 $member->isLoggedIn() or $this->disallow();
1438 $rawPingUrl = $manager->addTicketToUrl('index.php?action=rawping&blogid=' . intval($blogid));
1440 $this->pagehead('<meta http-equiv="refresh" content="1; url='.htmlspecialchars($rawPingUrl).'" />');
1442 <h2>Site Updated, Now pinging various weblog listing services...</h2>
1445 This can take a while...
1449 If you aren't automatically passed through, <a href="index.php?action=rawping&blogid=<?php echo $blogid?>">try again</a>
1451 <?php $this->pagefoot();
1455 * Sends the real ping (can take up to 10 seconds!)
1457 function action_rawping() {
1461 $blogid = intRequestVar('blogid');
1462 $blog =& $manager->getBlog($blogid);
1468 <h2>Pinging services, please wait...</h2>
1472 // send sendPing event
1473 $manager->notify('SendPing', array('blogid' => $blogid));
1479 <li><a href="index.php?action=itemlist&blogid=<?php echo $blog->getID()?>">View list of recent items for <?php echo htmlspecialchars($blog->getName())?></a></li>
1480 <li><a href="<?php echo $blog->getURL()?>">Visit your own site</a></li>
1483 <?php $this->pagefoot();
1487 * Allows to edit previously made comments
1489 function action_commentedit() {
1490 global $member, $manager;
1492 $commentid = intRequestVar('commentid');
1494 $member->canAlterComment($commentid) or $this->disallow();
1496 $comment = COMMENT::getComment($commentid);
1498 $manager->notify('PrepareCommentForEdit',array('comment' => &$comment));
1500 // change <br /> to \n
1501 $comment['body'] = str_replace('<br />','',$comment['body']);
1503 $comment['body'] = eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>","\\1",$comment['body']);
1508 <h2><?php echo _EDITC_TITLE?></h2>
1510 <form action="index.php" method="post"><div>
1512 <input type="hidden" name="action" value="commentupdate" />
1513 <?php $manager->addTicketHidden(); ?>
1514 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1516 <th colspan="2"><?php echo _EDITC_TITLE?></th>
1518 <td><?php echo _EDITC_WHO?></td>
1520 <?php if ($comment['member'])
1521 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1523 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1527 <td><?php echo _EDITC_WHEN?></td>
1528 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1530 <td><?php echo _EDITC_HOST?></td>
1531 <td><?php echo $comment['host']; ?></td>
1533 <td><?php echo _EDITC_TEXT?></td>
1535 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1536 echo $comment['body'];
1540 <td><?php echo _EDITC_EDIT?></td>
1541 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
1550 * @todo document this
1552 function action_commentupdate() {
1553 global $member, $manager;
1555 $commentid = intRequestVar('commentid');
1557 $member->canAlterComment($commentid) or $this->disallow();
1559 $body = postVar('body');
1561 // intercept words that are too long
1562 if (eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}",$body) != false)
1563 $this->error(_ERROR_COMMENT_LONGWORD);
1566 if (strlen($body)<3)
1567 $this->error(_ERROR_COMMENT_NOCOMMENT);
1568 if (strlen($body)>5000)
1569 $this->error(_ERROR_COMMENT_TOOLONG);
1573 $body = COMMENT::prepareBody($body);
1576 $manager->notify('PreUpdateComment',array('body' => &$body));
1578 $query = 'UPDATE '.sql_table('comment')
1579 . " SET cbody='" .addslashes($body). "'"
1580 . " WHERE cnumber=" . $commentid;
1584 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1585 $o = mysql_fetch_object($res);
1586 $itemid = $o->citem;
1588 if ($member->canAlterItem($itemid))
1589 $this->action_itemcommentlist($itemid);
1591 $this->action_browseowncomments();
1596 * @todo document this
1598 function action_commentdelete() {
1599 global $member, $manager;
1601 $commentid = intRequestVar('commentid');
1603 $member->canAlterComment($commentid) or $this->disallow();
1605 $comment = COMMENT::getComment($commentid);
1607 $body = strip_tags($comment['body']);
1608 $body = htmlspecialchars(shorten($body, 300, '...'));
1610 if ($comment['member'])
1611 $author = $comment['member'];
1613 $author = $comment['user'];
1618 <h2><?php echo _DELETE_CONFIRM?></h2>
1620 <p><?php echo _CONFIRMTXT_COMMENT?></p>
1623 <b><?php echo _EDITC_WHO?>:</b> <?php echo $author ?>
1625 <b><?php echo _EDITC_TEXT?>:</b> <?php echo $body ?>
1628 <form method="post" action="index.php"><div>
1629 <input type="hidden" name="action" value="commentdeleteconfirm" />
1630 <?php $manager->addTicketHidden() ?>
1631 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1632 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
1639 * @todo document this
1641 function action_commentdeleteconfirm() {
1644 $commentid = intRequestVar('commentid');
1646 // get item id first
1647 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1648 $o = mysql_fetch_object($res);
1649 $itemid = $o->citem;
1651 $error = $this->deleteOneComment($commentid);
1653 $this->doError($error);
1655 if ($member->canAlterItem($itemid))
1656 $this->action_itemcommentlist($itemid);
1658 $this->action_browseowncomments();
1662 * @todo document this
1664 function deleteOneComment($commentid) {
1665 global $member, $manager;
1667 $commentid = intval($commentid);
1669 if (!$member->canAlterComment($commentid))
1670 return _ERROR_DISALLOWED;
1672 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1674 // delete the comments associated with the item
1675 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1678 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1684 * Usermanagement main
1686 function action_usermanagement() {
1687 global $member, $manager;
1690 $member->isAdmin() or $this->disallow();
1694 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
1696 echo '<h2>' . _MEMBERS_TITLE .'</h2>';
1698 echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
1700 // show list of members with actions
1702 . ' FROM '.sql_table('member');
1703 $template['content'] = 'memberlist';
1704 $template['tabindex'] = 10;
1706 $manager->loadClass("ENCAPSULATE");
1707 $batch =& new BATCH('member');
1708 $batch->showlist($query,'table',$template);
1710 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1712 <form method="post" action="index.php" name="memberedit"><div>
1714 <input type="hidden" name="action" value="memberadd" />
1715 <?php $manager->addTicketHidden() ?>
1719 <th colspan="2"><?php echo _MEMBERS_NEW?></th>
1721 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1722 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1724 <td><input tabindex="10010" name="name" size="16" maxlength="16" /></td>
1726 <td><?php echo _MEMBERS_REALNAME?></td>
1727 <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
1729 <td><?php echo _MEMBERS_PWD?></td>
1730 <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
1732 <td><?php echo _MEMBERS_REPPWD?></td>
1733 <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
1735 <td><?php echo _MEMBERS_EMAIL?></td>
1736 <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
1738 <td><?php echo _MEMBERS_URL?></td>
1739 <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
1741 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1742 <td><?php $this->input_yesno('admin',0,10060); ?> </td>
1744 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1745 <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
1747 <td><?php echo _MEMBERS_NOTES?></td>
1748 <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
1750 <td><?php echo _MEMBERS_NEW?></td>
1751 <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
1760 * Edit member settings
1762 function action_memberedit() {
1763 $this->action_editmembersettings(intRequestVar('memberid'));
1767 * @todo document this
1769 function action_editmembersettings($memberid = '') {
1770 global $member, $manager, $CONF;
1772 if ($memberid == '')
1773 $memberid = $member->getID();
1776 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1778 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
1779 $this->pagehead($extrahead);
1781 // show message to go back to member overview (only for admins)
1782 if ($member->isAdmin())
1783 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
1785 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
1787 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
1789 $mem = MEMBER::createFromID($memberid);
1792 <form method="post" action="index.php" name="memberedit"><div>
1794 <input type="hidden" name="action" value="changemembersettings" />
1795 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
1796 <?php $manager->addTicketHidden() ?>
1799 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
1801 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1802 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1805 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1806 <input name="name" tabindex="10" maxlength="16" size="16" value="<?php echo htmlspecialchars($mem->getDisplayName()); ?>" />
1808 echo htmlspecialchars($member->getDisplayName());
1813 <td><?php echo _MEMBERS_REALNAME?></td>
1814 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo htmlspecialchars($mem->getRealName()); ?>" /></td>
1816 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1817 <td><?php echo _MEMBERS_PWD?></td>
1818 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
1820 <td><?php echo _MEMBERS_REPPWD?></td>
1821 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
1824 <td><?php echo _MEMBERS_EMAIL?>
1825 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
1827 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo htmlspecialchars($mem->getEmail()); ?>" /></td>
1829 <td><?php echo _MEMBERS_URL?></td>
1830 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo htmlspecialchars($mem->getURL()); ?>" /></td>
1831 <?php // only allow to change this by super-admins
1832 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
1833 if ($member->isAdmin()) {
1836 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1837 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
1839 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1840 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
1843 <td><?php echo _MEMBERS_NOTES?></td>
1844 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo htmlspecialchars($mem->getNotes()); ?>" /></td>
1846 <td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>
1850 <select name="deflang" tabindex="85">
1851 <option value=""><?php echo _MEMBERS_USESITELANG?></option>
1852 <?php // show a dropdown list of all available languages
1854 $dirhandle = opendir($DIR_LANG);
1855 while ($filename = readdir($dirhandle)) {
1856 if (ereg("^(.*)\.php$",$filename,$matches)) {
1857 $name = $matches[1];
1858 echo "<option value='$name'";
1859 if ($name == $mem->getLanguage())
1860 echo " selected='selected'";
1861 echo ">$name</option>";
1864 closedir($dirhandle);
1873 $this->_insertPluginOptions('member',$memberid);
1876 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
1878 <td><?php echo _MEMBERS_EDIT?></td>
1879 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
1885 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
1888 'MemberSettingsFormExtras',
1898 * @todo document this
1900 function action_changemembersettings() {
1901 global $member, $CONF, $manager;
1903 $memberid = intRequestVar('memberid');
1906 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1908 $name = trim(strip_tags(postVar('name')));
1909 $realname = trim(strip_tags(postVar('realname')));
1910 $password = postVar('password');
1911 $repeatpassword = postVar('repeatpassword');
1912 $email = strip_tags(postVar('email'));
1913 $url = strip_tags(postVar('url'));
1915 // Sometimes user didn't prefix the URL with http://, this cause a malformed URL. Let's fix it.
1916 if (!eregi("^https?://", $url))
1917 $url = "http://".$url;
1919 $admin = postVar('admin');
1920 $canlogin = postVar('canlogin');
1921 $notes = strip_tags(postVar('notes'));
1922 $deflang = postVar('deflang');
1924 $mem = MEMBER::createFromID($memberid);
1926 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1928 if (!isValidDisplayName($name))
1929 $this->error(_ERROR_BADNAME);
1931 if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
1932 $this->error(_ERROR_NICKNAMEINUSE);
1934 if ($password != $repeatpassword)
1935 $this->error(_ERROR_PASSWORDMISMATCH);
1937 if ($password && (strlen($password) < 6))
1938 $this->error(_ERROR_PASSWORDTOOSHORT);
1941 if (!isValidMailAddress($email))
1942 $this->error(_ERROR_BADMAILADDRESS);
1946 $this->error(_ERROR_REALNAMEMISSING);
1948 if (($deflang != '') && (!checkLanguage($deflang)))
1949 $this->error(_ERROR_NOSUCHLANGUAGE);
1951 // check if there will remain at least one site member with both the logon and admin rights
1952 // (check occurs when taking away one of these rights from such a member)
1953 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
1954 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
1957 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
1958 if (mysql_num_rows($r) < 2)
1959 $this->error(_ERROR_ATLEASTONEADMIN);
1962 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1963 $mem->setDisplayName($name);
1965 $mem->setPassword($password);
1968 $oldEmail = $mem->getEmail();
1970 $mem->setRealName($realname);
1971 $mem->setEmail($email);
1973 $mem->setNotes($notes);
1974 $mem->setLanguage($deflang);
1977 // only allow super-admins to make changes to the admin status
1978 if ($member->isAdmin()) {
1979 $mem->setAdmin($admin);
1980 $mem->setCanLogin($canlogin);
1986 // store plugin options
1987 $aOptions = requestArray('plugoption');
1988 NucleusPlugin::_applyPluginOptions($aOptions);
1989 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
1991 // if email changed, generate new password
1992 if ($oldEmail != $mem->getEmail())
1994 $mem->sendActivationLink('addresschange', $oldEmail);
1996 $mem->newCookieKey();
1998 // only log out if the member being edited is the current member.
1999 if ($member->getID() == $memberid)
2001 $this->action_login(_MSG_ACTIVATION_SENT, 0);
2006 if ( ( $mem->getID() == $member->getID() )
2007 && ( $mem->getDisplayName() != $member->getDisplayName() )
2009 $mem->newCookieKey();
2011 $this->action_login(_MSG_LOGINAGAIN, 0);
2013 $this->action_overview(_MSG_SETTINGSCHANGED);
2018 * @todo document this
2020 function action_memberadd() {
2021 global $member, $manager;
2024 $member->isAdmin() or $this->disallow();
2026 if (postVar('password') != postVar('repeatpassword'))
2027 $this->error(_ERROR_PASSWORDMISMATCH);
2028 if (strlen(postVar('password')) < 6)
2029 $this->error(_ERROR_PASSWORDTOOSHORT);
2031 $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
2035 // fire PostRegister event
2036 $newmem = new MEMBER();
2037 $newmem->readFromName(postVar('name'));
2038 $manager->notify('PostRegister',array('member' => &$newmem));
2040 $this->action_usermanagement();
2044 * Account activation
2048 function action_activate() {
2050 $key = getVar('key');
2051 $this->_showActivationPage($key);
2055 * @todo document this
2057 function _showActivationPage($key, $message = '')
2061 // clean up old activation keys
2062 MEMBER::cleanupActivationTable();
2064 // get activation info
2065 $info = MEMBER::getActivationInfo($key);
2068 $this->error(_ERROR_ACTIVATE);
2070 $mem = MEMBER::createFromId($info->vmember);
2073 $this->error(_ERROR_ACTIVATE);
2077 $bNeedsPasswordChange = true;
2079 switch ($info->vtype)
2082 $title = _ACTIVATE_FORGOT_TITLE;
2083 $text = _ACTIVATE_FORGOT_TEXT;
2086 $title = _ACTIVATE_REGISTER_TITLE;
2087 $text = _ACTIVATE_REGISTER_TEXT;
2089 case 'addresschange':
2090 $title = _ACTIVATE_CHANGE_TITLE;
2091 $text = _ACTIVATE_CHANGE_TEXT;
2092 $bNeedsPasswordChange = false;
2093 MEMBER::activate($key);
2098 'memberName' => htmlspecialchars($mem->getDisplayName())
2100 $title = TEMPLATE::fill($title, $aVars);
2101 $text = TEMPLATE::fill($text, $aVars);
2105 echo '<h2>' , $title, '</h2>';
2106 echo '<p>' , $text, '</p>';
2110 echo '<p class="error">',$message,'</p>';
2113 if ($bNeedsPasswordChange)
2116 <div><form action="index.php" method="post">
2118 <input type="hidden" name="action" value="activatesetpwd" />
2119 <?php $manager->addTicketHidden() ?>
2120 <input type="hidden" name="key" value="<?php echo htmlspecialchars($key) ?>" />
2123 <td><?php echo _MEMBERS_PWD?></td>
2124 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2126 <td><?php echo _MEMBERS_REPPWD?></td>
2127 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2131 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2135 <td><?php echo _MEMBERS_SETPWD ?></td>
2136 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2151 * Account activation - set password part
2155 function action_activatesetpwd() {
2157 $key = postVar('key');
2159 // clean up old activation keys
2160 MEMBER::cleanupActivationTable();
2162 // get activation info
2163 $info = MEMBER::getActivationInfo($key);
2165 if (!$info || ($info->type == 'addresschange'))
2166 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2168 $mem = MEMBER::createFromId($info->vmember);
2171 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2173 $password = postVar('password');
2174 $repeatpassword = postVar('repeatpassword');
2176 if ($password != $repeatpassword)
2177 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2179 if ($password && (strlen($password) < 6))
2180 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2184 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2186 return $this->_showActivationPage($key, $error);
2190 $mem->setPassword($password);
2193 // do the activation
2194 MEMBER::activate($key);
2197 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2198 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2205 function action_manageteam() {
2206 global $member, $manager;
2208 $blogid = intRequestVar('blogid');
2211 $member->blogAdminRights($blogid) or $this->disallow();
2215 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2217 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
2219 echo '<h3>' . _TEAM_CURRENT . '</h3>';
2223 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2224 . ' FROM '.sql_table('member').', '.sql_table('team')
2225 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2227 $template['content'] = 'teamlist';
2228 $template['tabindex'] = 10;
2230 $manager->loadClass("ENCAPSULATE");
2231 $batch =& new BATCH('team');
2232 $batch->showlist($query, 'table', $template);
2235 <h3><?php echo _TEAM_ADDNEW?></h3>
2237 <form method='post' action='index.php'><div>
2239 <input type='hidden' name='action' value='teamaddmember' />
2240 <input type='hidden' name='blogid' value='<?php echo $blogid; ?>' />
2241 <?php $manager->addTicketHidden() ?>
2244 <td><?php echo _TEAM_CHOOSEMEMBER?></td>
2245 <td><?php // TODO: try to make it so only non-team-members are listed
2246 $query = 'SELECT mname as text, mnumber as value'
2247 . ' FROM '.sql_table('member');
2249 $template['name'] = 'memberid';
2250 $template['tabindex'] = 10000;
2251 showlist($query,'select',$template);
2254 <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
2255 <td><?php $this->input_yesno('admin',0,10020); ?></td>
2257 <td><?php echo _TEAM_ADD?></td>
2258 <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
2267 * Add member to team
2269 function action_teamaddmember() {
2270 global $member, $manager;
2272 $memberid = intPostVar('memberid');
2273 $blogid = intPostVar('blogid');
2274 $admin = intPostVar('admin');
2277 $member->blogAdminRights($blogid) or $this->disallow();
2279 $blog =& $manager->getBlog($blogid);
2280 if (!$blog->addTeamMember($memberid, $admin))
2281 $this->error(_ERROR_ALREADYONTEAM);
2283 $this->action_manageteam();
2288 * @todo document this
2290 function action_teamdelete() {
2291 global $member, $manager;
2293 $memberid = intRequestVar('memberid');
2294 $blogid = intRequestVar('blogid');
2297 $member->blogAdminRights($blogid) or $this->disallow();
2299 $teammem = MEMBER::createFromID($memberid);
2300 $blog =& $manager->getBlog($blogid);
2304 <h2><?php echo _DELETE_CONFIRM?></h2>
2306 <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>
2310 <form method="post" action="index.php"><div>
2311 <input type="hidden" name="action" value="teamdeleteconfirm" />
2312 <?php $manager->addTicketHidden() ?>
2313 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2314 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2315 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2322 * @todo document this
2324 function action_teamdeleteconfirm() {
2327 $memberid = intRequestVar('memberid');
2328 $blogid = intRequestVar('blogid');
2330 $error = $this->deleteOneTeamMember($blogid, $memberid);
2332 $this->error($error);
2335 $this->action_manageteam();
2339 * @todo document this
2341 function deleteOneTeamMember($blogid, $memberid) {
2342 global $member, $manager;
2344 $blogid = intval($blogid);
2345 $memberid = intval($memberid);
2348 if (!$member->blogAdminRights($blogid))
2349 return _ERROR_DISALLOWED;
2351 // check if: - there remains at least one blog admin
2352 // - (there remains at least one team member)
2353 $tmem = MEMBER::createFromID($memberid);
2355 $manager->notify('PreDeleteTeamMember', array('member' => &$mem, 'blogid' => $blogid));
2357 if ($tmem->isBlogAdmin($blogid)) {
2358 // check if there are more blog members left and at least one admin
2359 // (check for at least two admins before deletion)
2360 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2361 $r = sql_query($query);
2362 if (mysql_num_rows($r) < 2)
2363 return _ERROR_ATLEASTONEBLOGADMIN;
2366 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2369 $manager->notify('PostDeleteTeamMember', array('member' => &$mem, 'blogid' => $blogid));
2375 * @todo document this
2377 function action_teamchangeadmin() {
2380 $blogid = intRequestVar('blogid');
2381 $memberid = intRequestVar('memberid');
2384 $member->blogAdminRights($blogid) or $this->disallow();
2386 $mem = MEMBER::createFromID($memberid);
2388 // don't allow when there is only one admin at this moment
2389 if ($mem->isBlogAdmin($blogid)) {
2390 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2391 if (mysql_num_rows($r) == 1)
2392 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2395 if ($mem->isBlogAdmin($blogid))
2400 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2403 // only show manageteam if member did not change its own admin privileges
2404 if ($member->isBlogAdmin($blogid))
2405 $this->action_manageteam();
2407 $this->action_overview(_MSG_ADMINCHANGED);
2411 * @todo document this
2413 function action_blogsettings() {
2414 global $member, $manager;
2416 $blogid = intRequestVar('blogid');
2419 $member->blogAdminRights($blogid) or $this->disallow();
2421 $blog =& $manager->getBlog($blogid);
2423 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2424 $this->pagehead($extrahead);
2426 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
2428 <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
2430 <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
2432 <p>Members currently on your team:
2434 $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
2435 $aMemberNames = array();
2436 while ($o = mysql_fetch_object($res))
2437 array_push($aMemberNames, htmlspecialchars($o->mname) . ' (' . htmlspecialchars($o->mrealname). ')');
2438 echo implode(',', $aMemberNames);
2445 <a href="index.php?action=manageteam&blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
2448 <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
2450 <form method="post" action="index.php"><div>
2452 <input type="hidden" name="action" value="blogsettingsupdate" />
2453 <?php $manager->addTicketHidden() ?>
2454 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2456 <td><?php echo _EBLOG_NAME?></td>
2457 <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo htmlspecialchars($blog->getName()) ?>" /></td>
2459 <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
2460 <?php echo _EBLOG_SHORTNAME_EXTRA?>
2462 <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo htmlspecialchars($blog->getShortName()) ?>" /></td>
2464 <td><?php echo _EBLOG_DESC?></td>
2465 <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo htmlspecialchars($blog->getDescription()) ?>" /></td>
2467 <td><?php echo _EBLOG_URL?></td>
2468 <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo htmlspecialchars($blog->getURL()) ?>" /></td>
2470 <td><?php echo _EBLOG_DEFSKIN?>
2471 <?php help('blogdefaultskin'); ?>
2475 $query = 'SELECT sdname as text, sdnumber as value'
2476 . ' FROM '.sql_table('skin_desc');
2477 $template['name'] = 'defskin';
2478 $template['selected'] = $blog->getDefaultSkin();
2479 $template['tabindex'] = 50;
2480 showlist($query,'select',$template);
2485 <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
2487 <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
2489 <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
2491 <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
2493 <td><?php echo _EBLOG_DISABLECOMMENTS?>
2495 <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
2497 <td><?php echo _EBLOG_ANONYMOUS?>
2499 <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
2501 <td><?php echo _EBLOG_REQUIREDEMAIL?>
2503 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
2505 <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
2506 <td><input name="notify" tabindex="80" maxlength="60" size="40" value="<?php echo htmlspecialchars($blog->getNotifyAddress()); ?>" /></td>
2508 <td><?php echo _EBLOG_NOTIFY_ON?></td>
2510 <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
2511 <?php if ($blog->notifyOnComment()) echo "checked='checked'" ?>
2512 /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
2514 <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
2515 <?php if ($blog->notifyOnVote()) echo "checked='checked'" ?>
2516 /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
2518 <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
2519 <?php if ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
2520 /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
2524 if (numberOfEventSubscriber('SendPing') > 0) {
2526 <td><?php echo _EBLOG_PING?> <?php help('sendping'); ?></td>
2527 <td><?php $this->input_yesno('sendping',$blog->sendPing(),85); ?></td>
2532 <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
2533 <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo htmlspecialchars($blog->getMaxComments()); ?>" /></td>
2535 <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
2536 <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo htmlspecialchars($blog->getUpdateFile()) ?>" /></td>
2538 <td><?php echo _EBLOG_DEFCAT?></td>
2541 $query = 'SELECT cname as text, catid as value'
2542 . ' FROM '.sql_table('category')
2543 . ' WHERE cblog=' . $blog->getID();
2544 $template['name'] = 'defcat';
2545 $template['selected'] = $blog->getDefaultCategory();
2546 $template['tabindex'] = 110;
2547 showlist($query,'select',$template);
2551 <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
2552 <br /><?php echo _EBLOG_STIME?> <b><?php echo strftime("%H:%M",time()); ?></b>
2553 <br /><?php echo _EBLOG_BTIME?> <b><?php echo strftime("%H:%M",$blog->getCorrectTime()); ?></b>
2555 <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo htmlspecialchars($blog->getTimeOffset()); ?>" /></td>
2557 <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
2558 <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
2562 $this->_insertPluginOptions('blog',$blogid);
2565 <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
2567 <td><?php echo _EBLOG_CHANGE?></td>
2568 <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
2573 <h3><?php echo _EBLOG_CAT_TITLE?></h3>
2577 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2578 $template['content'] = 'categorylist';
2579 $template['tabindex'] = 200;
2581 $manager->loadClass("ENCAPSULATE");
2582 $batch =& new BATCH('category');
2583 $batch->showlist($query,'table',$template);
2588 <form action="index.php" method="post"><div>
2589 <input name="action" value="categorynew" type="hidden" />
2590 <?php $manager->addTicketHidden() ?>
2591 <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
2594 <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
2596 <td><?php echo _EBLOG_CAT_NAME?></td>
2597 <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
2599 <td><?php echo _EBLOG_CAT_DESC?></td>
2600 <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
2602 <td><?php echo _EBLOG_CAT_CREATE?></td>
2603 <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
2610 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2613 'BlogSettingsFormExtras',
2623 * @todo document this
2625 function action_categorynew() {
2626 global $member, $manager;
2628 $blogid = intRequestVar('blogid');
2630 $member->blogAdminRights($blogid) or $this->disallow();
2632 $cname = postVar('cname');
2633 $cdesc = postVar('cdesc');
2635 if (!isValidCategoryName($cname))
2636 $this->error(_ERROR_BADCATEGORYNAME);
2638 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . addslashes($cname).'\' and cblog=' . intval($blogid);
2639 $res = sql_query($query);
2640 if (mysql_num_rows($res) > 0)
2641 $this->error(_ERROR_DUPCATEGORYNAME);
2643 $blog =& $manager->getBlog($blogid);
2644 $newCatID = $blog->createNewCategory($cname, $cdesc);
2646 $this->action_blogsettings();
2650 * @todo document this
2652 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
2653 global $member, $manager;
2656 $blogid = intGetVar('blogid');
2658 $blogid = intval($blogid);
2660 $catid = intGetVar('catid');
2662 $catid = intval($catid);
2664 $member->blogAdminRights($blogid) or $this->disallow();
2666 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
2667 $obj = mysql_fetch_object($res);
2669 $cname = $obj->cname;
2670 $cdesc = $obj->cdesc;
2672 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2673 $this->pagehead($extrahead);
2675 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2678 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo htmlspecialchars($cname)?>'</h2>
2679 <form method='post' action='index.php'><div>
2680 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
2681 <input name="catid" type="hidden" value="<?php echo $catid?>" />
2682 <input name="desturl" type="hidden" value="<?php echo htmlspecialchars($desturl) ?>" />
2683 <input name="action" type="hidden" value="categoryupdate" />
2684 <?php $manager->addTicketHidden(); ?>
2687 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2689 <td><?php echo _EBLOG_CAT_NAME?></td>
2690 <td><input type="text" name="cname" value="<?php echo htmlspecialchars($cname)?>" size="40" maxlength="40" /></td>
2692 <td><?php echo _EBLOG_CAT_DESC?></td>
2693 <td><input type="text" name="cdesc" value="<?php echo htmlspecialchars($cdesc)?>" size="40" maxlength="200" /></td>
2696 // insert plugin options
2697 $this->_insertPluginOptions('category',$catid);
2700 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2702 <td><?php echo _EBLOG_CAT_UPDATE?></td>
2703 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
2712 * @todo document this
2714 function action_categoryupdate() {
2715 global $member, $manager;
2717 $blogid = intPostVar('blogid');
2718 $catid = intPostVar('catid');
2719 $cname = postVar('cname');
2720 $cdesc = postVar('cdesc');
2721 $desturl = postVar('desturl');
2723 $member->blogAdminRights($blogid) or $this->disallow();
2725 if (!isValidCategoryName($cname))
2726 $this->error(_ERROR_BADCATEGORYNAME);
2728 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . addslashes($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
2729 $res = sql_query($query);
2730 if (mysql_num_rows($res) > 0)
2731 $this->error(_ERROR_DUPCATEGORYNAME);
2733 $query = 'UPDATE '.sql_table('category').' SET'
2734 . " cname='" . addslashes($cname) . "',"
2735 . " cdesc='" . addslashes($cdesc) . "'"
2736 . " WHERE catid=" . $catid;
2740 // store plugin options
2741 $aOptions = requestArray('plugoption');
2742 NucleusPlugin::_applyPluginOptions($aOptions);
2743 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
2750 $this->action_blogsettings();
2755 * @todo document this
2757 function action_categorydelete() {
2758 global $member, $manager;
2760 $blogid = intRequestVar('blogid');
2761 $catid = intRequestVar('catid');
2763 $member->blogAdminRights($blogid) or $this->disallow();
2765 $blog =& $manager->getBlog($blogid);
2767 // check if the category is valid
2768 if (!$blog->isValidCategory($catid))
2769 $this->error(_ERROR_NOSUCHCATEGORY);
2771 // don't allow deletion of default category
2772 if ($blog->getDefaultCategory() == $catid)
2773 $this->error(_ERROR_DELETEDEFCATEGORY);
2775 // check if catid is the only category left for blogid
2776 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2777 $res = sql_query($query);
2778 if (mysql_num_rows($res) == 1)
2779 $this->error(_ERROR_DELETELASTCATEGORY);
2784 <h2><?php echo _DELETE_CONFIRM?></h2>
2787 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo htmlspecialchars($blog->getCategoryName($catid))?></b>
2790 <form method="post" action="index.php"><div>
2791 <input type="hidden" name="action" value="categorydeleteconfirm" />
2792 <?php $manager->addTicketHidden() ?>
2793 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
2794 <input type="hidden" name="catid" value="<?php echo $catid?>" />
2795 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2802 * @todo document this
2804 function action_categorydeleteconfirm() {
2805 global $member, $manager;
2807 $blogid = intRequestVar('blogid');
2808 $catid = intRequestVar('catid');
2810 $member->blogAdminRights($blogid) or $this->disallow();
2812 $error = $this->deleteOneCategory($catid);
2814 $this->error($error);
2816 $this->action_blogsettings();
2820 * @todo document this
2822 function deleteOneCategory($catid) {
2823 global $manager, $member;
2825 $catid = intval($catid);
2827 $manager->notify('PreDeleteCategory', array('catid' => $catid));
2829 $blogid = getBlogIDFromCatID($catid);
2831 if (!$member->blogAdminRights($blogid))
2832 return ERROR_DISALLOWED;
2835 $blog =& $manager->getBlog($blogid);
2837 // check if the category is valid
2838 if (!$blog || !$blog->isValidCategory($catid))
2839 return _ERROR_NOSUCHCATEGORY;
2841 $destcatid = $blog->getDefaultCategory();
2843 // don't allow deletion of default category
2844 if ($blog->getDefaultCategory() == $catid)
2845 return _ERROR_DELETEDEFCATEGORY;
2847 // check if catid is the only category left for blogid
2848 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2849 $res = sql_query($query);
2850 if (mysql_num_rows($res) == 1)
2851 return _ERROR_DELETELASTCATEGORY;
2853 // change category for all items to the default category
2854 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
2857 // delete all associated plugin options
2858 NucleusPlugin::_deleteOptionValues('category', $catid);
2861 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
2864 $manager->notify('PostDeleteCategory', array('catid' => $catid));
2869 * @todo document this
2871 function moveOneCategory($catid, $destblogid) {
2872 global $manager, $member;
2874 $catid = intval($catid);
2875 $destblogid = intval($destblogid);
2877 $blogid = getBlogIDFromCatID($catid);
2879 // mover should have admin rights on both blogs
2880 if (!$member->blogAdminRights($blogid))
2881 return _ERROR_DISALLOWED;
2882 if (!$member->blogAdminRights($destblogid))
2883 return _ERROR_DISALLOWED;
2885 // cannot move to self
2886 if ($blogid == $destblogid)
2887 return _ERROR_MOVETOSELF;
2890 $blog =& $manager->getBlog($blogid);
2891 $destblog =& $manager->getBlog($destblogid);
2893 // check if the category is valid
2894 if (!$blog || !$blog->isValidCategory($catid))
2895 return _ERROR_NOSUCHCATEGORY;
2897 // don't allow default category to be moved
2898 if ($blog->getDefaultCategory() == $catid)
2899 return _ERROR_MOVEDEFCATEGORY;
2905 'sourceblog' => &$blog,
2906 'destblog' => &$destblog
2910 // update comments table (cblog)
2911 $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
2912 $items = sql_query($query);
2913 while ($oItem = mysql_fetch_object($items)) {
2914 sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
2917 // update items (iblog)
2918 $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
2922 $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
2929 'sourceblog' => &$blog,
2930 'destblog' => $destblog
2937 * @todo document this
2939 function action_blogsettingsupdate() {
2940 global $member, $manager;
2942 $blogid = intRequestVar('blogid');
2944 $member->blogAdminRights($blogid) or $this->disallow();
2946 $blog =& $manager->getBlog($blogid);
2948 $notify = trim(postVar('notify'));
2949 $shortname = trim(postVar('shortname'));
2950 $updatefile = trim(postVar('update'));
2952 $notifyComment = intPostVar('notifyComment');
2953 $notifyVote = intPostVar('notifyVote');
2954 $notifyNewItem = intPostVar('notifyNewItem');
2956 if ($notifyComment == 0) $notifyComment = 1;
2957 if ($notifyVote == 0) $notifyVote = 1;
2958 if ($notifyNewItem == 0) $notifyNewItem = 1;
2960 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
2964 $not =& new NOTIFICATION($notify);
2965 if (!$not->validAddresses())
2966 $this->error(_ERROR_BADNOTIFY);
2970 if (!isValidShortName($shortname))
2971 $this->error(_ERROR_BADSHORTBLOGNAME);
2973 if (($blog->getShortName() != $shortname) && $manager->existsBlog($shortname))
2974 $this->error(_ERROR_DUPSHORTBLOGNAME);
2976 // check if update file is writable
2977 if ($updatefile && !is_writeable($updatefile))
2978 $this->error(_ERROR_UPDATEFILE);
2980 $blog->setName(trim(postVar('name')));
2981 $blog->setShortName($shortname);
2982 $blog->setNotifyAddress($notify);
2983 $blog->setNotifyType($notifyType);
2984 $blog->setMaxComments(postVar('maxcomments'));
2985 $blog->setCommentsEnabled(postVar('comments'));
2986 $blog->setTimeOffset(postVar('timeoffset'));
2987 $blog->setUpdateFile($updatefile);
2988 $blog->setURL(trim(postVar('url')));
2989 $blog->setDefaultSkin(intPostVar('defskin'));
2990 $blog->setDescription(trim(postVar('desc')));
2991 $blog->setPublic(postVar('public'));
2992 $blog->setPingUserland(postVar('sendping'));
2993 $blog->setConvertBreaks(intPostVar('convertbreaks'));
2994 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
2995 $blog->setDefaultCategory(intPostVar('defcat'));
2996 $blog->setSearchable(intPostVar('searchable'));
2997 $blog->setEmailRequired(intPostVar('reqemail'));
2999 $blog->writeSettings();
3001 // store plugin options
3002 $aOptions = requestArray('plugoption');
3003 NucleusPlugin::_applyPluginOptions($aOptions);
3004 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
3007 $this->action_overview(_MSG_SETTINGSCHANGED);
3011 * @todo document this
3013 function action_deleteblog() {
3014 global $member, $CONF, $manager;
3016 $blogid = intRequestVar('blogid');
3018 $member->blogAdminRights($blogid) or $this->disallow();
3020 // check if blog is default blog
3021 if ($CONF['DefaultBlog'] == $blogid)
3022 $this->error(_ERROR_DELDEFBLOG);
3024 $blog =& $manager->getBlog($blogid);
3028 <h2><?php echo _DELETE_CONFIRM?></h2>
3030 <p><?php echo _WARNINGTXT_BLOGDEL?>
3034 <?php echo _CONFIRMTXT_BLOG?><b><?php echo htmlspecialchars($blog->getName())?></b>
3037 <form method="post" action="index.php"><div>
3038 <input type="hidden" name="action" value="deleteblogconfirm" />
3039 <?php $manager->addTicketHidden() ?>
3040 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
3041 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3048 * @todo document this
3050 function action_deleteblogconfirm() {
3051 global $member, $CONF, $manager;
3053 $blogid = intRequestVar('blogid');
3055 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3057 $member->blogAdminRights($blogid) or $this->disallow();
3059 // check if blog is default blog
3060 if ($CONF['DefaultBlog'] == $blogid)
3061 $this->error(_ERROR_DELDEFBLOG);
3063 // delete all comments
3064 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3068 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3071 // delete all team members
3072 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3076 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3079 // delete all categories
3080 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3083 // delete all associated plugin options
3084 NucleusPlugin::_deleteOptionValues('blog', $blogid);
3086 // delete the blog itself
3087 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3090 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3092 $this->action_overview(_DELETED_BLOG);
3096 * @todo document this
3098 function action_memberdelete() {
3099 global $member, $manager;
3101 $memberid = intRequestVar('memberid');
3103 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3105 $mem = MEMBER::createFromID($memberid);
3109 <h2><?php echo _DELETE_CONFIRM?></h2>
3111 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo htmlspecialchars($mem->getDisplayName()) ?></b>
3115 Please note that media files will <b>NOT</b> be deleted. (At least not in this Nucleus version)
3118 <form method="post" action="index.php"><div>
3119 <input type="hidden" name="action" value="memberdeleteconfirm" />
3120 <?php $manager->addTicketHidden() ?>
3121 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3122 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3129 * @todo document this
3131 function action_memberdeleteconfirm() {
3134 $memberid = intRequestVar('memberid');
3136 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3138 $error = $this->deleteOneMember($memberid);
3140 $this->error($error);
3142 if ($member->isAdmin())
3143 $this->action_usermanagement();
3145 $this->action_overview(_DELETED_MEMBER);
3150 * @todo document this
3152 function deleteOneMember($memberid) {
3155 $memberid = intval($memberid);
3156 $mem = MEMBER::createFromID($memberid);
3158 if (!$mem->canBeDeleted())
3159 return _ERROR_DELETEMEMBER;
3161 $manager->notify('PreDeleteMember', array('member' => &$mem));
3163 /* unlink comments from memberid */
3164 $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. addslashes($mem->getDisplayName())
3165 .'" WHERE cmember='.$memberid;
3168 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3171 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3174 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3177 // delete all associated plugin options
3178 NucleusPlugin::_deleteOptionValues('member', $memberid);
3180 $manager->notify('PostDeleteMember', array('member' => &$mem));
3186 * @todo document this
3188 function action_createnewlog() {
3189 global $member, $CONF, $manager;
3191 // Only Super-Admins can do this
3192 $member->isAdmin() or $this->disallow();
3196 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3198 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
3200 <h3>泡¦§ï亶ç@¡¦/h3>
3202 <p>ä½Ø塦¡¦¡¦¡â¡¦Þä!£ã¡ãáà¢ä
\8e¶¶æ
\8e¦Ðä!¡¦strong>泡¦§ï亶ç@¡¦/strong> ¡¦Ää!¾ã¡ú¡¦´æ
\8e¨ã¡ð§ì²ä!Êä!¡¦/p>
3204 <p>åô°ã¡÷¡¦§Øeblog¡¦Ää
\8e»Ø塦¡¦Îä!Þå]¸ä!¡¦
\80¢ä!Æä!Álog¡¦¡¦£áá⡦£î¥â¹ã¡ù¡¦¶ä!Þä"¢ä!¡¦Ëí¡¦5¡¦ÄæS¹ä¡¦¡¦Îä!¡¦¡ê¡¦ºä!¾ã¡ù¡¦¤åÇí¡¦5¡¦°Ô¡¦¤ã¡â¡¦´ä!¾ã¡ù:</p>
3207 <li><strong>ç°¡å¹ø¡¦¡¦Ëí¡¦5:</strong> <code>index.php</code>¡¦¡¦£å製ã£òä½Øä"´ä ¢åÇèááÎä!¡¦log¡¦ÄæÝäéâ
\8e¸¡¦Òä"¶ä"°ä!¡¦!¡¦£çåù´ã£ò¡¦ ¡¦°ä!¾ã¡ù¡¦¡¦¡¦Æä!¡¦£çåù´ã¡çëåRç´°ã¡è¥à¢ä
\8e»Ø塦徸ä!¡¦¡¨ç¤ºã¡õ¡¦¸ä!¾ã¡ù¡¦¡¦/li>
3208 <li><strong>é«ÐåY¡¦¡åçö¹æ¡¦:</strong> ¡¦¾å×äááÁlog¡¦§ä½¿¡¦¡¦¡÷¡¦¡¦¡ä¡¦¶ä"¹ã£ç¥ã³ã¡æ
\8eÜcode>otherblog</code>¡¦¡¦¡ä¡¦¡¦"³ã¥îáã²ä"Ää
\8e»¿ã¡â¥áÞæ
\8e¦Ðæ
\8e½°ã£ò¡¦ ¡¦°ä!¾ã¡ù¡¦¤ä!Æä!¡¦Ëí¡¦5¡¦§ã¡è¥à¢å0¸ä!Ðä#Ôä#¼ã£ìå桦!§è£ååó°ã¡ç`log¡¦ÄåPÊç6¶ä!Òä"¶ä!Æä!¡¦¡ì¡¦¡¦¥ï¥á¡¦¡åáâ´ä!¾ã¡ù¡¦¡¦/li>
3211 <h3>Weblog¡¦¡¦¡¦å桦/h3>
3214 <?php echo _EBLOG_CREATE_TEXT?>
3217 <form method="post" action="index.php"><div>
3219 <input type="hidden" name="action" value="addnewlog" />
3220 <?php $manager->addTicketHidden() ?>
3224 <td><?php echo _EBLOG_NAME?></td>
3225 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3227 <td><?php echo _EBLOG_SHORTNAME?>
3228 <?php help('shortblogname'); ?>
3230 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3232 <td><?php echo _EBLOG_DESC?></td>
3233 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3235 <td><?php echo _EBLOG_DEFSKIN?>
3236 <?php help('blogdefaultskin'); ?>
3240 $query = 'SELECT sdname as text, sdnumber as value'
3241 . ' FROM '.sql_table('skin_desc');
3242 $template['name'] = 'defskin';
3243 $template['tabindex'] = 50;
3244 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3245 showlist($query,'select',$template);
3249 <td><?php echo _EBLOG_OFFSET?>
3250 <?php help('blogtimeoffset'); ?>
3251 <br /><?php echo _EBLOG_STIME?> <b><?php echo strftime("%H:%M",time()); ?></b>
3253 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3255 <td><?php echo _EBLOG_ADMIN?>
3256 <?php help('teamadmin'); ?>
3258 <td><?php echo _EBLOG_ADMIN_MSG?></td>
3260 <td><?php echo _EBLOG_CREATE?></td>
3261 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3270 * @todo document this
3272 function action_addnewlog() {
3273 global $member, $manager, $CONF;
3275 // Only Super-Admins can do this
3276 $member->isAdmin() or $this->disallow();
3278 $bname = trim(postVar('name'));
3279 $bshortname = trim(postVar('shortname'));
3280 $btimeoffset = postVar('timeoffset');
3281 $bdesc = trim(postVar('desc'));
3282 $bdefskin = postVar('defskin');
3284 if (!isValidShortName($bshortname))
3285 $this->error(_ERROR_BADSHORTBLOGNAME);
3287 if ($manager->existsBlog($bshortname))
3288 $this->error(_ERROR_DUPSHORTBLOGNAME);
3294 'shortname' => &$bshortname,
3295 'timeoffset' => &$btimeoffset,
3296 'description' => &$bdescription,
3297 'defaultskin' => &$bdefskin
3302 // add slashes for sql queries
3303 $bname = addslashes($bname);
3304 $bshortname = addslashes($bshortname);
3305 $btimeoffset = addslashes($btimeoffset);
3306 $bdesc = addslashes($bdesc);
3307 $bdefskin = addslashes($bdefskin);
3310 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
3312 $blogid = mysql_insert_id();
3313 $blog =& $manager->getBlog($blogid);
3315 // create new category
3316 sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, 'General','Items that do not fit in other categories')");
3317 $catid = mysql_insert_id();
3319 // set as default category
3320 $blog->setDefaultCategory($catid);
3321 $blog->writeSettings();
3323 // create team member
3324 $memberid = $member->getID();
3325 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
3329 $blog->additem($blog->getDefaultCategory(),'First Item','¡¦Æä"¸ä!¡¦¡â¡¦¡¦¢¡¡¦Öeblog¡¦¡¦¡ê¡¦Âä"¶åÓࡦÚä!¡¦£ááâ¤ã¥æ¡¦ ¡¦§ã¡ù¡¦¤æ¡¦éô±ã¡æ¡¦´ç9¤ã¡÷¡¦¡¦¡ä¡¦Þä! ¡¦¡¦!¡¦¡ë¡¦¾ã¡ä¡¦¾ã¡û¡¦Æä ¡¦,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3342 'name' => 'General',
3343 'description' => 'Items that do not fit in other categories',
3350 <h2>åô°ã¡÷¡¦§Øeblog¡¦¸ä
\8e»Ø塦¡¦Êä"¸ä!¾ã¡÷¡¦¡¦/h2>
3352 <p>åô°ã¡÷¡¦§Øeblog ¡¦¡¦?php echo htmlspecialchars($bname)?>¡¦ºä!¸ä
\8e»Ø塦¡¦Êä"¸ä!¾ã¡÷¡¦Þä ¤æUÔä!Âä!¡¦
\80¢ä!Æä"¸ä!¡¦£áá⡦£î¥â¹ã¡ù¡¦¶ä!Þä"¢ä!¡¦»¥ä¸¶ä!¡¦¡å¥á¡ã£é¡¦¶ä!¡¦±ëé¡¡¦!¡¦
\80²ã£ó¡¦§ã¡ï¡¦ ¡¦Êä!¡¦ ¡¦/p>
3355 <li><a href="#index_php">ç°¡å¹ø¡¦¡¦Ëí¡¦5: 丶ä!¡¦£ê¥ã¼ã¥é¡¦Äæ
\8e°¼ä¡¦¡¦Âä!¡¦<code><?php echo htmlspecialchars($bshortname)?>.php</code> ¡¦¡¦¡ä¡¦¡¦#Êä"¡ã£âá㡦£òä½Ø塦¡¦Òä"¡¦/a></li>
3356 <li><a href="#skins">é«ÐåY¡¦¡åçö¹æ¡¦: ¡¦¾å×äãï^¡¦¡¦¡÷¡¦¡¦¡ä¡¦¶ä"¹ã£ç¥ã³ã¡æ¡¦°ã¡÷¡¦§Øeblog¡¦ÄåPÊç6¶ä!Êä!Öä"¶ä!Þä"¢ä!¡¦¡¦è¿°ã£ò¡¦ ¡¦°ä"¡¦/a></li>
3359 <h3><a id="index_php">åô¹æ¡¦ 1: <code><?php echo htmlspecialchars($bshortname)?>.php</code> ¡¦¡¦¡ä¡¦¡¦#Êä"¡ã£âá㡦£òä½Ø塦</a></h3>
3361 <p><code><?php echo htmlspecialchars($bshortname)?>.php</code> ¡¦¡¦¡ä¡¦¡¦#Êä"¡ã£âá㡦£òä½Ø塦¡¦Îä!¡¦
\80¢ä
\8e¶èº«¡¦¡¦»¥ä¸¶ä!¡¦£ê¥ã¼ã¥é¡¦Äæ
\8e°¼ã£êä»Ðä!Âä"¡¦</p>
3364 $CONF['Self'] = '<b><?php echo htmlspecialchars($bshortname)?>.php</b>';
3366 include('<i>./config.php</i>');
3368 selectBlog('<b><?php echo htmlspecialchars($bshortname)?></b>');
3373 <p>¡¦Òä!§ã¡æ¥á¤ä"¡¦code>index.php</code>¡¦¡¦¿ì¡¦Ðä#¡¦"£ã¥æá⡦¥è¡¦¡¦¡æ¥â¢ã¥ã¡¦Îä#ã¥îáã²ä!Îä!¾ã¡ù¡¦¡¦/p>
3375 <p>åô°ã¡÷¡¦§Øeblog¡¦¡¦¡¦åæÀä"ÄåM¸ä
\8e¸¡¦!Òä"¶ä!Þä"¢ä!¡¦¡è¥à¢ä
\8e¶¶ä!¡¦¡ó¡¦¡¦¥õ¡¦¡ã£âá㡦¡çSRL¡¦Äå%¥å³û¡¦Îä!¡¦¡ï¡¦ ¡¦Êä!¡¦ ¡¦(¡¦Òä!§ã¡æô¡¦§ï¡¦Îä!Þå ¤ã¡ä¡¦°ä!£ã¡ãáᡦ"¶ä!¡¦¡è¡¦Úä!¡¦!¾ã¡ù¡¦¸ä
\8e½Úæ
\8e¦¼ã¡è¥áÎä!¾ã¡û¡¦¡¦:</p>
3377 <form action="index.php" method="post"><div>
3378 <input type="hidden" name="action" value="addnewlog2" />
3379 <?php $manager->addTicketHidden() ?>
3380 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3382 <td><?php echo _EBLOG_URL?></td>
3383 <td><input name="url" maxlength="100" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
3385 <td><?php echo _EBLOG_CREATE?></td>
3386 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3390 <h3><a id="skins">åô¹æ¡¦ 2: ¡¦¾å×äãï^¡¦¡¦¡÷¡¦¡¦¡ä¡¦¶ä"¹ã£ç¥ã³ã¡æ¡¦°ã¡÷¡¦§Øeblog¡¦ÄåPÊç6¶ä!Òä"¶æ
\8e¦Ðæ
\8e½°ã£ò¡¦ ¡¦°ä"¡¦/a></h3>
3392 <p>åô°ã¡÷¡¦§Øeblog¡¦¡¦¡¦åæÀä"ÄåM¸ä
\8e¸¡¦!Òä"¶ä!Þä"¢ä!¡¦¡è¥à¢ä
\8e¶¶ä!¡¦RL¡¦Äå%¥å³û¡¦Îä!¡¦¡ï¡¦ ¡¦Êä!¡¦ ¡¦(大æ³ë¥á¡¦Íáåç8blog¡¦¡¦¿ì¡¦Ï¶RL)</p>
3394 <form action="index.php" method="post"><div>
3395 <input type="hidden" name="action" value="addnewlog2" />
3396 <?php $manager->addTicketHidden() ?>
3397 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3399 <td><?php echo _EBLOG_URL?></td>
3400 <td><input name="url" maxlength="100" size="40" /></td>
3402 <td><?php echo _EBLOG_CREATE?></td>
3403 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3407 <?php $this->pagefoot();
3412 * @todo document this
3414 function action_addnewlog2() {
3415 global $member, $manager;
3417 $member->blogAdminRights($blogid) or $this->disallow();
3419 $burl = requestVar('url');
3420 $blogid = intRequestVar('blogid');
3422 $blog =& $manager->getBlog($blogid);
3423 $blog->setURL(trim($burl));
3424 $blog->writeSettings();
3426 $this->action_overview(_MSG_NEWBLOG);
3430 * @todo document this
3432 function action_skinieoverview() {
3433 global $member, $DIR_LIBS, $manager;
3435 $member->isAdmin() or $this->disallow();
3437 // load skinie class
3438 include_once($DIR_LIBS . 'skinie.php');
3442 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3445 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
3447 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
3448 <?php global $DIR_SKINS;
3450 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
3452 if (sizeof($candidates) > 0) {
3454 <form method="post" action="index.php"><div>
3455 <input type="hidden" name="action" value="skinieimport" />
3456 <?php $manager->addTicketHidden() ?>
3457 <input type="hidden" name="mode" value="file" />
3458 <select name="skinfile" id="skinie_import_local">
3459 <?php foreach ($candidates as $skinname => $skinfile) {
3460 $html = htmlspecialchars($skinfile);
3461 echo '<option value="',$html,'">',$skinname,'</option>';
3465 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3468 echo _SKINIE_NOCANDIDATES;
3473 <p><em><?php echo _OR?></em></p>
3475 <form method="post" action="index.php"><p>
3476 <?php $manager->addTicketHidden() ?>
3477 <input type="hidden" name="action" value="skinieimport" />
3478 <input type="hidden" name="mode" value="url" />
3479 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
3480 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3481 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3485 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
3486 <form method="post" action="index.php"><div>
3487 <input type="hidden" name="action" value="skinieexport" />
3488 <?php $manager->addTicketHidden() ?>
3490 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
3493 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
3495 <?php // show list of skins
3496 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
3497 while ($skinObj = mysql_fetch_object($res)) {
3498 $id = 'skinexp' . $skinObj->sdnumber;
3499 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
3500 echo '<label for="',$id,'">',htmlspecialchars($skinObj->sdname),'</label></td>';
3501 echo '<td>',htmlspecialchars($skinObj->sddesc),'</td>';
3505 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3507 // show list of templates
3508 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3509 while ($templateObj = mysql_fetch_object($res)) {
3510 $id = 'templateexp' . $templateObj->tdnumber;
3511 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
3512 echo '<label for="',$id,'">',htmlspecialchars($templateObj->tdname),'</label></td>';
3513 echo '<td>',htmlspecialchars($templateObj->tddesc),'</td>';
3518 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
3520 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3522 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
3524 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
3534 * @todo document this
3536 function action_skinieimport() {
3537 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3539 $member->isAdmin() or $this->disallow();
3541 // load skinie class
3542 include_once($DIR_LIBS . 'skinie.php');
3544 $skinFileRaw= postVar('skinfile');
3545 $mode = postVar('mode');
3547 $importer =& new SKINIMPORT();
3549 // get full filename
3550 if ($mode == 'file')
3552 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3554 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3555 if (!file_exists($skinFile))
3556 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3558 $skinFile = $skinFileRaw;
3561 // read only metadata
3562 $error = $importer->readFile($skinFile, 1);
3565 $skinNameClashes = $importer->checkSkinNameClashes();
3566 $templateNameClashes = $importer->checkTemplateNameClashes();
3567 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3569 if ($error) $this->error($error);
3573 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3575 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
3578 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
3579 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3580 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3582 if ($hasNameClashes)
3585 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
3586 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
3588 } // if (hasNameClashes)
3592 <form method="post" action="index.php"><div>
3593 <input type="hidden" name="action" value="skiniedoimport" />
3594 <?php $manager->addTicketHidden() ?>
3595 <input type="hidden" name="skinfile" value="<?php echo htmlspecialchars(postVar('skinfile'))?>" />
3596 <input type="hidden" name="mode" value="<?php echo htmlspecialchars($mode)?>" />
3597 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
3599 if ($hasNameClashes)
3603 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
3605 } // if (hasNameClashes)
3615 * @todo document this
3617 function action_skiniedoimport() {
3618 global $member, $DIR_LIBS, $DIR_SKINS;
3620 $member->isAdmin() or $this->disallow();
3622 // load skinie class
3623 include_once($DIR_LIBS . 'skinie.php');
3625 $skinFileRaw= postVar('skinfile');
3626 $mode = postVar('mode');
3628 $allowOverwrite = intPostVar('overwrite');
3630 // get full filename
3631 if ($mode == 'file')
3633 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3635 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3636 if (!file_exists($skinFile))
3637 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3640 $skinFile = $skinFileRaw;
3643 $importer =& new SKINIMPORT();
3645 $error = $importer->readFile($skinFile);
3648 $this->error($error);
3650 $error = $importer->writeToDatabase($allowOverwrite);
3653 $this->error($error);
3657 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3659 <h2><?php echo _SKINIE_DONE?></h2>
3662 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
3663 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3664 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3667 <?php $this->pagefoot();
3672 * @todo document this
3674 function action_skinieexport() {
3675 global $member, $DIR_LIBS;
3677 $member->isAdmin() or $this->disallow();
3679 // load skinie class
3680 include_once($DIR_LIBS . 'skinie.php');
3682 $aSkins = requestIntArray('skin');
3683 $aTemplates = requestIntArray('template');
3685 if (!is_array($aTemplates)) $aTemplates = array();
3686 if (!is_array($aSkins)) $aSkins = array();
3688 $skinList = array_keys($aSkins);
3689 $templateList = array_keys($aTemplates);
3691 $info = postVar('info');
3693 $exporter =& new SKINEXPORT();
3694 foreach ($skinList as $skinId) {
3695 $exporter->addSkin($skinId);
3697 foreach ($templateList as $templateId) {
3698 $exporter->addTemplate($templateId);
3700 $exporter->setInfo($info);
3702 $exporter->export();
3706 * @todo document this
3708 function action_templateoverview() {
3709 global $member, $manager;
3711 $member->isAdmin() or $this->disallow();
3715 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3717 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
3718 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
3720 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
3721 $template['content'] = 'templatelist';
3722 $template['tabindex'] = 10;
3723 showlist($query,'table',$template);
3725 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
3728 <form method="post" action="index.php"><div>
3730 <input name="action" value="templatenew" type="hidden" />
3731 <?php $manager->addTicketHidden() ?>
3733 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3734 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
3736 <td><?php echo _TEMPLATE_DESC?></td>
3737 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
3739 <td><?php echo _TEMPLATE_CREATE?></td>
3740 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3750 * @todo document this
3752 function action_templateedit($msg = '') {
3753 global $member, $manager;
3755 $templateid = intRequestVar('templateid');
3757 $member->isAdmin() or $this->disallow();
3759 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
3760 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.addslashes(_EDITTEMPLATE_EMPTY).'");</script>';
3762 $this->pagehead($extrahead);
3764 $templatename = TEMPLATE::getNameFromId($templateid);
3765 $templatedescription = TEMPLATE::getDesc($templateid);
3766 $template =& $manager->getTemplate($templatename);
3770 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
3773 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo htmlspecialchars($templatename); ?>'</h2>
3775 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
3778 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
3780 <form method="post" action="index.php">
3783 <input type="hidden" name="action" value="templateupdate" />
3784 <?php $manager->addTicketHidden() ?>
3785 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
3788 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
3790 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3791 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo htmlspecialchars($templatename) ?>" /></td>
3793 <td><?php echo _TEMPLATE_DESC?></td>
3794 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo htmlspecialchars($templatedescription) ?>" /></td>
3796 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3798 <td><?php echo _TEMPLATE_UPDATE?></td>
3800 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3801 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3804 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
3805 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
3806 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
3807 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
3808 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
3809 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
3810 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
3813 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
3814 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
3815 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
3816 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
3817 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
3818 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
3819 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
3820 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
3823 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
3825 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
3828 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
3829 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
3832 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
3833 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
3834 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
3835 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
3838 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
3839 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
3840 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
3841 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
3844 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
3845 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 160);
3846 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 170);
3847 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 180);
3850 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
3851 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 190);
3852 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 200);
3853 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 210);
3854 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 220);
3855 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 230);
3858 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
3859 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 240);
3860 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 250);
3861 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 260);
3864 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
3865 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',270);
3866 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',280);
3869 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3871 <td><?php echo _TEMPLATE_UPDATE?></td>
3873 <input type="submit" tabindex="290" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3874 <input type="reset" tabindex="300" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3885 * @todo document this
3887 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
3891 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
3892 <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>
3897 * @todo document this
3899 function action_templateupdate() {
3902 $templateid = intRequestVar('templateid');
3904 $member->isAdmin() or $this->disallow();
3906 $name = postVar('tname');
3907 $desc = postVar('tdesc');
3909 if (!isValidTemplateName($name))
3910 $this->error(_ERROR_BADTEMPLATENAME);
3912 if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
3913 $this->error(_ERROR_DUPTEMPLATENAME);
3916 $name = addslashes($name);
3917 $desc = addslashes($desc);
3919 // 1. Remove all template parts
3920 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
3923 // 2. Update description
3924 $query = 'UPDATE '.sql_table('template_desc').' SET'
3925 . " tdname='" . $name . "',"
3926 . " tddesc='" . $desc . "'"
3927 . " WHERE tdnumber=" . $templateid;
3930 // 3. Add non-empty template parts
3931 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
3932 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
3933 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
3934 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
3935 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
3936 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
3937 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
3938 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
3939 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
3940 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
3941 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
3942 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
3943 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
3944 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
3945 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
3946 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
3947 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
3948 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
3949 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
3950 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
3951 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
3952 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
3953 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
3954 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
3955 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
3956 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
3957 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
3958 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
3959 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
3960 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
3961 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
3962 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
3963 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
3964 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
3967 // jump back to template edit
3968 $this->action_templateedit(_TEMPLATE_UPDATED);
3973 * @todo document this
3975 function addToTemplate($id, $partname, $content) {
3976 $partname = addslashes($partname);
3977 $content = addslashes($content);
3981 // don't add empty parts:
3982 if (!trim($content)) return -1;
3984 $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
3985 . "VALUES ($id, '$partname', '$content')";
3986 sql_query($query) or die("Query error: " . mysql_error());
3987 return mysql_insert_id();
3991 * @todo document this
3993 function action_templatedelete() {
3994 global $member, $manager;
3996 $member->isAdmin() or $this->disallow();
3998 $templateid = intRequestVar('templateid');
3999 // TODO: check if template can be deleted
4003 $name = TEMPLATE::getNameFromId($templateid);
4004 $desc = TEMPLATE::getDesc($templateid);
4007 <h2><?php echo _DELETE_CONFIRM?></h2>
4010 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo htmlspecialchars($name)?></b> (<?php echo htmlspecialchars($desc) ?>)
4013 <form method="post" action="index.php"><div>
4014 <input type="hidden" name="action" value="templatedeleteconfirm" />
4015 <?php $manager->addTicketHidden() ?>
4016 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
4017 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4024 * @todo document this
4026 function action_templatedeleteconfirm() {
4027 global $member, $manager;
4029 $templateid = intRequestVar('templateid');
4031 $member->isAdmin() or $this->disallow();
4033 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
4035 // 1. delete description
4036 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
4039 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4041 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
4043 $this->action_templateoverview();
4047 * @todo document this
4049 function action_templatenew() {
4052 $member->isAdmin() or $this->disallow();
4054 $name = postVar('name');
4055 $desc = postVar('desc');
4057 if (!isValidTemplateName($name))
4058 $this->error(_ERROR_BADTEMPLATENAME);
4060 if (TEMPLATE::exists($name))
4061 $this->error(_ERROR_DUPTEMPLATENAME);
4063 $newTemplateId = TEMPLATE::createNew($name, $desc);
4065 $this->action_templateoverview();
4069 * @todo document this
4071 function action_templateclone() {
4074 $templateid = intRequestVar('templateid');
4076 $member->isAdmin() or $this->disallow();
4078 // 1. read old template
4079 $name = TEMPLATE::getNameFromId($templateid);
4080 $desc = TEMPLATE::getDesc($templateid);
4082 // 2. create desc thing
4083 $name = "cloned" . $name;
4085 // if a template with that name already exists:
4086 if (TEMPLATE::exists($name)) {
4088 while (TEMPLATE::exists($name . $i))
4093 $newid = TEMPLATE::createNew($name, $desc);
4096 // go through parts of old template and add them to the new one
4097 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4098 while ($o = mysql_fetch_object($res)) {
4099 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
4102 $this->action_templateoverview();
4106 * @todo document this
4108 function action_skinoverview() {
4109 global $member, $manager;
4111 $member->isAdmin() or $this->disallow();
4115 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4117 echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
4119 echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
4121 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
4122 $template['content'] = 'skinlist';
4123 $template['tabindex'] = 10;
4124 showlist($query,'table',$template);
4126 echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
4129 <form method="post" action="index.php">
4132 <input name="action" value="skinnew" type="hidden" />
4133 <?php $manager->addTicketHidden() ?>
4135 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4136 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4138 <td><?php echo _SKIN_DESC?></td>
4139 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4141 <td><?php echo _SKIN_CREATE?></td>
4142 <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
4153 * @todo document this
4155 function action_skinnew() {
4158 $member->isAdmin() or $this->disallow();
4160 $name = trim(postVar('name'));
4161 $desc = trim(postVar('desc'));
4163 if (!isValidSkinName($name))
4164 $this->error(_ERROR_BADSKINNAME);
4166 if (SKIN::exists($name))
4167 $this->error(_ERROR_DUPSKINNAME);
4169 $newId = SKIN::createNew($name, $desc);
4171 $this->action_skinoverview();
4175 * @todo document this
4177 function action_skinedit() {
4178 global $member, $manager;
4180 $skinid = intRequestVar('skinid');
4182 $member->isAdmin() or $this->disallow();
4184 $skin =& new SKIN($skinid);
4189 <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
4191 <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo $skin->getName() ?>'</h2>
4193 <h3><?php echo _SKIN_PARTS_TITLE?></h3>
4194 <?php echo _SKIN_PARTS_MSG?>
4196 <li><a tabindex="10" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=index"><?php echo _SKIN_PART_MAIN?></a> <?php help('skinpartindex')?></li>
4197 <li><a tabindex="20" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=item"><?php echo _SKIN_PART_ITEM?></a> <?php help('skinpartitem')?></li>
4198 <li><a tabindex="30" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=archivelist"><?php echo _SKIN_PART_ALIST?></a> <?php help('skinpartarchivelist')?></li>
4199 <li><a tabindex="40" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=archive"><?php echo _SKIN_PART_ARCHIVE?></a> <?php help('skinpartarchive')?></li>
4200 <li><a tabindex="50" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=search"><?php echo _SKIN_PART_SEARCH?></a> <?php help('skinpartsearch')?></li>
4201 <li><a tabindex="60" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=error"><?php echo _SKIN_PART_ERROR?></a> <?php help('skinparterror')?></li>
4202 <li><a tabindex="70" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=member"><?php echo _SKIN_PART_MEMBER?></a> <?php help('skinpartmember')?></li>
4203 <li><a tabindex="75" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=imagepopup"><?php echo _SKIN_PART_POPUP?></a> <?php help('skinpartimagepopup')?></li>
4208 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
4209 $res = sql_query($query);
4211 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4212 echo '<form method="get" action="index.php">' . "\r\n";
4213 echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
4214 echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
4215 echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
4216 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
4217 echo '</form>' . "\r\n";
4219 if ($res && mysql_num_rows($res) > 0) {
4223 while ($row = mysql_fetch_assoc($res)) {
4224 echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&skinid=' . $skinid . '&type=' . htmlspecialchars(strtolower($row['stype'])) . '">' . htmlspecialchars(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&skinid=' . $skinid . '&type=' . htmlspecialchars(strtolower($row['stype'])) . '">remove</a>)</li>';
4232 <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
4233 <form method="post" action="index.php">
4236 <input type="hidden" name="action" value="skineditgeneral" />
4237 <?php $manager->addTicketHidden() ?>
4238 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4240 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4241 <td><input name="name" tabindex="90" value="<?php echo htmlspecialchars($skin->getName()) ?>" maxlength="20" size="20" /></td>
4243 <td><?php echo _SKIN_DESC?></td>
4244 <td><input name="desc" tabindex="100" value="<?php echo htmlspecialchars($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
4246 <td><?php echo _SKIN_TYPE?></td>
4247 <td><input name="type" tabindex="110" value="<?php echo htmlspecialchars($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
4249 <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
4250 <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
4252 <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
4253 <td><input name="inc_prefix" tabindex="130" value="<?php echo htmlspecialchars($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
4255 <td><?php echo _SKIN_CHANGE?></td>
4256 <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
4263 <?php $this->pagefoot();
4267 * @todo document this
4269 function action_skineditgeneral() {
4272 $skinid = intRequestVar('skinid');
4274 $member->isAdmin() or $this->disallow();
4276 $name = postVar('name');
4277 $desc = postVar('desc');
4278 $type = postVar('type');
4279 $inc_mode = postVar('inc_mode');
4280 $inc_prefix = postVar('inc_prefix');
4282 $skin =& new SKIN($skinid);
4285 if (!isValidSkinName($name))
4286 $this->error(_ERROR_BADSKINNAME);
4288 if (($skin->getName() != $name) && SKIN::exists($name))
4289 $this->error(_ERROR_DUPSKINNAME);
4291 if (!$type) $type = 'text/html';
4292 if (!$inc_mode) $inc_mode = 'normal';
4294 // 2. Update description
4295 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4297 $this->action_skinedit();
4302 * @todo document this
4304 function action_skinedittype($msg = '') {
4305 global $member, $manager;
4307 $skinid = intRequestVar('skinid');
4308 $type = requestVar('type');
4310 $member->isAdmin() or $this->disallow();
4312 $type = trim($type);
4313 $type = strtolower($type);
4315 if (!isValidShortName($type)) {
4316 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4319 $skin =& new SKIN($skinid);
4321 $friendlyNames = SKIN::getFriendlyNames();
4325 <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
4327 <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo htmlspecialchars($skin->getName()) ?>': <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
4329 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4333 <form method="post" action="index.php">
4336 <input type="hidden" name="action" value="skinupdate" />
4337 <?php $manager->addTicketHidden() ?>
4338 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4339 <input type="hidden" name="type" value="<?php echo $type ?>" />
4341 <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4342 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4343 (skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4344 <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4345 help('skinpart' . $type);
4347 help('skinpartspecial');
4351 <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo htmlspecialchars($skin->getContent($type)) ?></textarea>
4354 <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4355 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4356 (skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4359 <?php echo _SKIN_ALLOWEDVARS?>
4360 <?php $actions = SKIN::getAllowedActionsForType($type);
4364 while ($current = array_shift($actions)) {
4365 // skip deprecated vars
4366 if ($current == 'ifcat') continue;
4367 if ($current == 'imagetext') continue;
4368 if ($current == 'vars') continue;
4370 echo helplink('skinvar-' . $current) . "$current</a>";
4371 if (count($actions) != 0) echo ", ";
4376 <?php $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4377 showlist($query,'table',array('content'=>'shortblognames'));
4382 <?php $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4383 showlist($query,'table',array('content'=>'shortnames'));
4391 <?php $this->pagefoot();
4395 * @todo document this
4397 function action_skinupdate() {
4400 $skinid = intRequestVar('skinid');
4401 $content = trim(postVar('content'));
4402 $type = postVar('type');
4404 $member->isAdmin() or $this->disallow();
4406 $skin =& new SKIN($skinid);
4407 $skin->update($type, $content);
4409 $this->action_skinedittype(_SKIN_UPDATED);
4413 * @todo document this
4415 function action_skindelete() {
4416 global $member, $manager, $CONF;
4418 $skinid = intRequestVar('skinid');
4420 $member->isAdmin() or $this->disallow();
4422 // don't allow default skin to be deleted
4423 if ($skinid == $CONF['BaseSkin'])
4424 $this->error(_ERROR_DEFAULTSKIN);
4426 // don't allow deletion of default skins for blogs
4427 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4428 $r = sql_query($query);
4429 if ($o = mysql_fetch_object($r))
4430 $this->error(_ERROR_SKINDEFDELETE . htmlspecialchars($o->bname));
4434 $skin =& new SKIN($skinid);
4435 $name = $skin->getName();
4436 $desc = $skin->getDescription();
4439 <h2><?php echo _DELETE_CONFIRM?></h2>
4442 <?php echo _CONFIRMTXT_SKIN?><b><?php echo htmlspecialchars($name) ?></b> (<?php echo htmlspecialchars($desc)?>)
4445 <form method="post" action="index.php"><div>
4446 <input type="hidden" name="action" value="skindeleteconfirm" />
4447 <?php $manager->addTicketHidden() ?>
4448 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4449 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4456 * @todo document this
4458 function action_skindeleteconfirm() {
4459 global $member, $CONF, $manager;
4461 $skinid = intRequestVar('skinid');
4463 $member->isAdmin() or $this->disallow();
4465 // don't allow default skin to be deleted
4466 if ($skinid == $CONF['BaseSkin'])
4467 $this->error(_ERROR_DEFAULTSKIN);
4469 // don't allow deletion of default skins for blogs
4470 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4471 $r = sql_query($query);
4472 if ($o = mysql_fetch_object($r))
4473 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
4475 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4477 // 1. delete description
4478 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4481 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4483 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4485 $this->action_skinoverview();
4489 * @todo document this
4491 function action_skinremovetype() {
4492 global $member, $manager, $CONF;
4494 $skinid = intRequestVar('skinid');
4495 $skintype = requestVar('type');
4497 if (!isValidShortName($skintype)) {
4498 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4501 $member->isAdmin() or $this->disallow();
4503 // don't allow default skinparts to be deleted
4504 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4505 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4510 $skin =& new SKIN($skinid);
4511 $name = $skin->getName();
4512 $desc = $skin->getDescription();
4515 <h2><?php echo _DELETE_CONFIRM?></h2>
4518 <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo htmlspecialchars($skintype); ?> (<?php echo htmlspecialchars($name); ?>)</b> (<?php echo htmlspecialchars($desc)?>)
4521 <form method="post" action="index.php"><div>
4522 <input type="hidden" name="action" value="skinremovetypeconfirm" />
4523 <?php $manager->addTicketHidden() ?>
4524 <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
4525 <input type="hidden" name="type" value="<?php echo htmlspecialchars($skintype); ?>" />
4526 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4533 * @todo document this
4535 function action_skinremovetypeconfirm() {
4536 global $member, $CONF, $manager;
4538 $skinid = intRequestVar('skinid');
4539 $skintype = requestVar('type');
4541 if (!isValidShortName($skintype)) {
4542 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4545 $member->isAdmin() or $this->disallow();
4547 // don't allow default skinparts to be deleted
4548 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4549 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4552 $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4555 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
4557 $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4559 $this->action_skinedit();
4563 * @todo document this
4565 function action_skinclone() {
4568 $skinid = intRequestVar('skinid');
4570 $member->isAdmin() or $this->disallow();
4572 // 1. read skin to clone
4573 $skin =& new SKIN($skinid);
4575 $name = "clone_" . $skin->getName();
4577 // if a skin with that name already exists:
4578 if (SKIN::exists($name)) {
4580 while (SKIN::exists($name . $i))
4585 // 2. create skin desc
4586 $newid = SKIN::createNew(
4588 $skin->getDescription(),
4589 $skin->getContentType(),
4590 $skin->getIncludeMode(),
4591 $skin->getIncludePrefix()
4597 $this->skinclonetype($skin, $newid, 'index');
4598 $this->skinclonetype($skin, $newid, 'item');
4599 $this->skinclonetype($skin, $newid, 'archivelist');
4600 $this->skinclonetype($skin, $newid, 'archive');
4601 $this->skinclonetype($skin, $newid, 'search');
4602 $this->skinclonetype($skin, $newid, 'error');
4603 $this->skinclonetype($skin, $newid, 'member');
4604 $this->skinclonetype($skin, $newid, 'imagepopup');
4607 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
4608 $res = sql_query($query);
4609 while ($row = mysql_fetch_assoc($res)) {
4610 $this->skinclonetype($skin, $newid, $row['stype']);
4613 $this->action_skinoverview();
4618 * @todo document this
4620 function skinclonetype($skin, $newid, $type) {
4621 $newid = intval($newid);
4622 $content = $skin->getContent($type);
4624 $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". addslashes($content)."', '". addslashes($type)."')";
4630 * @todo document this
4632 function action_settingsedit() {
4633 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
4635 $member->isAdmin() or $this->disallow();
4639 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4642 <h2><?php echo _SETTINGS_TITLE?></h2>
4644 <form action="index.php" method="post">
4647 <input type="hidden" name="action" value="settingsupdate" />
4648 <?php $manager->addTicketHidden() ?>
4651 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
4653 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
4656 $query = 'SELECT bname as text, bnumber as value'
4657 . ' FROM '.sql_table('blog');
4658 $template['name'] = 'DefaultBlog';
4659 $template['selected'] = $CONF['DefaultBlog'];
4660 $template['tabindex'] = 10;
4661 showlist($query,'select',$template);
4665 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
4668 $query = 'SELECT sdname as text, sdnumber as value'
4669 . ' FROM '.sql_table('skin_desc');
4670 $template['name'] = 'BaseSkin';
4671 $template['selected'] = $CONF['BaseSkin'];
4672 $template['tabindex'] = 1;
4673 showlist($query,'select',$template);
4677 <td><?php echo _SETTINGS_ADMINMAIL?></td>
4678 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo htmlspecialchars($CONF['AdminEmail']) ?>" /></td>
4680 <td><?php echo _SETTINGS_SITENAME?></td>
4681 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo htmlspecialchars($CONF['SiteName']) ?>" /></td>
4683 <td><?php echo _SETTINGS_SITEURL?></td>
4684 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL']) ?>" /></td>
4686 <td><?php echo _SETTINGS_ADMINURL?></td>
4687 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo htmlspecialchars($CONF['AdminURL']) ?>" /></td>
4689 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
4690 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo htmlspecialchars($CONF['PluginURL']) ?>" /></td>
4692 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
4693 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo htmlspecialchars($CONF['SkinsURL']) ?>" /></td>
4695 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
4696 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo htmlspecialchars($CONF['ActionURL']) ?>" /></td>
4698 <td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>
4702 <select name="Language" tabindex="10050">
4703 <?php // show a dropdown list of all available languages
4705 $dirhandle = opendir($DIR_LANG);
4706 while ($filename = readdir($dirhandle)) {
4707 if (ereg("^(.*)\.php$",$filename,$matches)) {
4708 $name = $matches[1];
4709 echo "<option value='$name'";
4710 if ($name == $CONF['Language'])
4711 echo " selected='selected'";
4712 echo ">$name</option>";
4715 closedir($dirhandle);
4722 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
4724 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
4726 URL: <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo htmlspecialchars($CONF['DisableSiteURL'])?>" />
4729 <td><?php echo _SETTINGS_DIRS?></td>
4730 <td><?php echo htmlspecialchars($DIR_NUCLEUS) ?>
4731 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4733 <td><?php echo _SETTINGS_DBLOGIN?></td>
4734 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4738 echo _SETTINGS_JSTOOLBAR
4739 /* =_SETTINGS_DISABLEJS
4741 I temporary changed the meaning of DisableJsTools, until I can find a good
4742 way to select the javascript version to use
4746 1 : all javascript disabled
4747 2 : 'simpler' javascript (for mozilla/opera/mac)
4751 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
4752 <select name="DisableJsTools" tabindex="10075">
4753 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
4754 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
4755 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
4756 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
4757 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
4758 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
4763 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
4766 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
4767 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
4769 echo ' ', _SETTINGS_URLMODE_HELP;
4775 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
4777 <td><?php echo _SETTINGS_MEDIADIR?></td>
4778 <td><?php echo htmlspecialchars($DIR_MEDIA) ?>
4779 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
4780 <?php if (!is_dir($DIR_MEDIA))
4781 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
4782 if (!is_readable($DIR_MEDIA))
4783 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
4784 if (!is_writeable($DIR_MEDIA))
4785 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
4789 <td><?php echo _SETTINGS_MEDIAURL?></td>
4791 <input name="MediaURL" tabindex="10080" size="40" value="<?php echo htmlspecialchars($CONF['MediaURL']) ?>" />
4794 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
4795 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
4797 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
4799 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo htmlspecialchars($CONF['AllowedTypes']) ?>" />
4802 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
4804 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo htmlspecialchars($CONF['MaxUploadSize']) ?>" />
4807 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
4808 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
4811 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
4813 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
4814 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
4816 <td><?php echo _SETTINGS_ALLOWCREATE?>
4817 <?php help('allowaccountcreation'); ?>
4819 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
4822 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
4823 <br /><?php echo _SETTINGS_NEWLOGIN2?>
4825 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
4828 <td><?php echo _SETTINGS_MEMBERMSGS?>
4829 <?php help('messageservice'); ?>
4831 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
4834 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
4835 <?php help('messageservice'); ?>
4837 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
4840 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
4841 <?php help('protectmemnames'); ?>
4843 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
4849 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
4851 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
4852 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo htmlspecialchars($CONF['CookiePrefix'])?>" /></td>
4854 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
4855 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo htmlspecialchars($CONF['CookieDomain'])?>" /></td>
4857 <td><?php echo _SETTINGS_COOKIEPATH?></td>
4858 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo htmlspecialchars($CONF['CookiePath'])?>" /></td>
4860 <td><?php echo _SETTINGS_COOKIESECURE?></td>
4861 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
4863 <td><?php echo _SETTINGS_COOKIELIFE?></td>
4864 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
4865 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
4868 <td><?php echo _SETTINGS_LASTVISIT?></td>
4869 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
4874 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
4876 <td><?php echo _SETTINGS_UPDATE?></td>
4877 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
4884 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
4887 'GeneralSettingsFormExtras',
4895 * @todo document this
4897 function action_settingsupdate() {
4898 global $member, $CONF;
4900 $member->isAdmin() or $this->disallow();
4902 // check if email address for admin is valid
4903 if (!isValidMailAddress(postVar('AdminEmail')))
4904 $this->error(_ERROR_BADMAILADDRESS);
4908 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
4909 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
4910 $this->updateConfig('IndexURL', postVar('IndexURL'));
4911 $this->updateConfig('AdminURL', postVar('AdminURL'));
4912 $this->updateConfig('PluginURL', postVar('PluginURL'));
4913 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
4914 $this->updateConfig('ActionURL', postVar('ActionURL'));
4915 $this->updateConfig('Language', postVar('Language'));
4916 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
4917 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
4918 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
4919 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
4920 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
4921 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
4922 $this->updateConfig('SiteName', postVar('SiteName'));
4923 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
4924 $this->updateConfig('DisableSite', postVar('DisableSite'));
4925 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
4926 $this->updateConfig('LastVisit', postVar('LastVisit'));
4927 $this->updateConfig('MediaURL', postVar('MediaURL'));
4928 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
4929 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
4930 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
4931 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
4932 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
4933 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
4934 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
4935 $this->updateConfig('CookiePath', postVar('CookiePath'));
4936 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
4937 $this->updateConfig('URLMode', postVar('URLMode'));
4938 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
4940 // load new config and redirect (this way, the new language will be used is necessary)
4941 // note that when changing cookie settings, this redirect might cause the user
4942 // to have to log in again.
4944 redirect($CONF['AdminURL'] . '?action=manage');
4950 * @todo document this
4952 function updateConfig($name, $val) {
4953 $name = addslashes($name);
4954 $val = trim(addslashes($val));
4956 $query = 'UPDATE '.sql_table('config')
4957 . " SET value='$val'"
4958 . " WHERE name='$name'";
4960 sql_query($query) or die("Query error: " . mysql_error());
4961 return mysql_insert_id();
4966 * @param string $msg message that will be shown
4968 function error($msg) {
4974 echo "<a href='index.php' onclick='history.back()'>"._BACK."</a>";
4980 * @todo document this
4982 function disallow() {
4983 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
4985 $this->error(_ERROR_DISALLOWED);
4989 * @todo document this
4991 function pagehead($extrahead = '') {
4992 global $member, $nucleus, $CONF, $manager;
4997 'extrahead' => &$extrahead,
4998 'action' => $this->action
5002 $baseUrl = htmlspecialchars($CONF['AdminURL']);
5005 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5006 <html xmlns="http://www.w3.org/1999/xhtml">
5008 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
5009 <title><?php echo htmlspecialchars($CONF['SiteName'])?> - Admin</title>
5010 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css" href="<?php echo $baseUrl?>styles/admin.css" />
5011 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css"
5012 href="<?php echo $baseUrl?>styles/addedit.css" />
5014 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/edit.js"></script>
5015 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/admin.js"></script>
5016 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/compatibility.js"></script>
5018 <meta http-equiv='Pragma' content='no-cache' />
5019 <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />
5020 <meta http-equiv='Expires' content='-1' />
5022 <?php echo $extrahead?>
5025 <div class="header">
5026 <h1><?php echo htmlspecialchars($CONF['SiteName'])?></h1>
5028 <div id="container">
5030 <div class="loginname">
5031 <?php if ($member->isLoggedIn())
5032 echo _LOGGEDINAS . ' ' . $member->getDisplayName()
5033 ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a>"
5034 . "<br /><a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5036 echo '<a href="index.php?action=showlogin" title="Log in">' , _NOTLOGGEDIN , '</a> <br />';
5038 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a>";
5042 // Note(JP): disabled code name description
5044 if ($member->isLoggedIn() && $member->isAdmin())
5045 echo '<a href="http://nucleuscms.org/version.php?v=',getNucleusVersion(),'&pl=',getNucleusPatchLevel(),'" title="Check for upgrade">Nucleus CMS ', $nucleus['version'], ' "', $nucleus['codename'], '"</a>';
5047 echo 'Nucleus CMS ', $nucleus['version'], ' "', $nucleus['codename'], '"';
5049 if ($member->isLoggedIn() && $member->isAdmin())
5050 echo '<a href="http://nucleuscms.org/version.php?v=',getNucleusVersion(),'&pl=',getNucleusPatchLevel(),'" title="Check for upgrade">Nucleus CMS ', $nucleus['version'], ' </a>';
5052 echo 'Nucleus CMS ', $nucleus['version'];
5058 * @todo document this
5060 function pagefoot() {
5061 global $action, $member, $manager;
5066 'action' => $this->action
5070 if ($member->isLoggedIn() && ($action != 'showlogin')) {
5072 <h2><?php echo _LOGOUT ?></h2>
5074 <li><a href="index.php?action=overview"><?php echo _BACKHOME?></a></li>
5075 <li><a href='index.php?action=logout'><?php echo _LOGOUT?></a></li>
5080 <a href="http://nucleuscms.org/">Nucleus CMS</a> © 2002-<?php echo date('Y'); ?> The Nucleus Group
5082 <a href="http://nucleuscms.org/donate.php">Donate!</a>
5085 </div><!-- content -->
5087 <div id="quickmenu">
5089 <?php // ---- user settings ----
5090 if (($action != 'showlogin') && ($member->isLoggedIn())) {
5092 echo '<li><a href="index.php?action=overview">',_QMENU_HOME,'</a></li>';
5095 echo '<h2>',_QMENU_ADD,'</h2>';
5096 echo '<form method="get" action="index.php"><div>';
5097 echo '<input type="hidden" name="action" value="createitem" />';
5099 $showAll = requestVar('showall');
5100 if (($member->isAdmin()) && ($showAll == 'yes')) {
5101 // Super-Admins have access to all blogs! (no add item support though)
5102 $query = 'SELECT bnumber as value, bname as text'
5103 . ' FROM ' . sql_table('blog')
5104 . ' ORDER BY bname';
5106 $query = 'SELECT bnumber as value, bname as text'
5107 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5108 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5109 . ' ORDER BY bname';
5111 $template['name'] = 'blogid';
5112 $template['tabindex'] = 15000;
5113 $template['extra'] = _QMENU_ADD_SELECT;
5114 $template['selected'] = -1;
5115 $template['shorten'] = 10;
5116 $template['shortenel'] = '';
5117 $template['javascript'] = 'onchange="return form.submit()"';
5118 showlist($query,'select',$template);
5120 echo '</div></form>';
5122 echo '<h2>' . $member->getDisplayName(). '</h2>';
5124 echo '<li><a href="index.php?action=editmembersettings">',_QMENU_USER_SETTINGS,'</a></li>';
5125 echo '<li><a href="index.php?action=browseownitems">',_QMENU_USER_ITEMS,'</a></li>';
5126 echo '<li><a href="index.php?action=browseowncomments">',_QMENU_USER_COMMENTS,'</a></li>';
5132 // ---- general settings ----
5133 if ($member->isAdmin()) {
5135 echo '<h2>',_QMENU_MANAGE,'</h2>';
5138 echo '<li><a href="index.php?action=actionlog">',_QMENU_MANAGE_LOG,'</a></li>';
5139 echo '<li><a href="index.php?action=settingsedit">',_QMENU_MANAGE_SETTINGS,'</a></li>';
5140 echo '<li><a href="index.php?action=usermanagement">',_QMENU_MANAGE_MEMBERS,'</a></li>';
5141 echo '<li><a href="index.php?action=createnewlog">',_QMENU_MANAGE_NEWBLOG,'</a></li>';
5142 echo '<li><a href="index.php?action=backupoverview">',_QMENU_MANAGE_BACKUPS,'</a></li>';
5143 echo '<li><a href="index.php?action=pluginlist">',_QMENU_MANAGE_PLUGINS,'</a></li>';
5146 echo '<h2>',_QMENU_LAYOUT,'</h2>';
5148 echo '<li><a href="index.php?action=skinoverview">',_QMENU_LAYOUT_SKINS,'</a></li>';
5149 echo '<li><a href="index.php?action=templateoverview">',_QMENU_LAYOUT_TEMPL,'</a></li>';
5150 echo '<li><a href="index.php?action=skinieoverview">',_QMENU_LAYOUT_IEXPORT,'</a></li>';
5155 $aPluginExtras = array();
5159 'options' => &$aPluginExtras
5162 if (count($aPluginExtras) > 0)
5164 echo '<h2>', _QMENU_PLUGINS, '</h2>';
5166 foreach ($aPluginExtras as $aInfo)
5168 echo '<li><a href="'.htmlspecialchars($aInfo['url']).'" title="'.htmlspecialchars($aInfo['tooltip']).'">'.htmlspecialchars($aInfo['title']).'</a></li>';
5173 } else if (($action == 'activate') || ($action == 'activatesetpwd')) {
5175 echo '<h2>', _QMENU_ACTIVATE, '</h2>', _QMENU_ACTIVATE_TEXT;
5177 // introduction text on login screen
5178 echo '<h2>', _QMENU_INTRO, '</h2>', _QMENU_INTRO_TEXT;
5183 <!-- content / quickmenu container -->
5192 * @todo document this
5194 function action_regfile() {
5195 global $member, $CONF;
5197 $blogid = intRequestVar('blogid');
5199 $member->teamRights($blogid) or $this->disallow();
5201 // header-code stolen from phpMyAdmin
5202 // REGEDIT and bookmarklet code stolen from GreyMatter
5204 $sjisBlogName = getBlogNameFromID($blogid);
5205 $sjisBlogName = mb_convert_encoding($sjisBlogName, "SJIS", "auto");
5207 header('Content-Type: application/octetstream');
5208 header('Content-Disposition: filename="nucleus.reg"');
5209 header('Pragma: no-cache');
5210 header('Expires: 0');
5213 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\Post To &Nucleus (".$sjisBlogName.")]\n";
5214 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
5215 echo '"contexts"=hex:31';
5219 * @todo document this
5221 function action_bookmarklet() {
5222 global $member, $manager;
5224 $blogid = intRequestVar('blogid');
5226 $member->teamRights($blogid) or $this->disallow();
5228 $blog =& $manager->getBlog($blogid);
5229 $bm = getBookmarklet($blogid);
5233 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5237 <h2>Bookmarklet<!-- and Right Click Menu --></h2>
5240 Bookmarklet ¡¦¡¦¡è¥à¢ä"¡¦¥åá㡦"°Ó¡¦Üä!§è¡¦äº¶ä!¡¦³õ稿ã¡ì¡¦§ã¡í¡¦¶ä"·ã£í¥ã¡¦# ¡¦§ã¡ù¡¦¡¦¡¦Æä!¡¦Bookmarklet ¡¦Ää"¤ã¥ê¥â¹ã¥è¡¦¼ã¥æ¥áÒä"¶ä!¡¦
\80¢ä#Ìä#¡¦£ãáâ¶ã¡çá㡦#¼ã¥æ¥ãÀä#¼ã¡ç%add to weblog'¡¦Øä"¿ã¥ê¥á¸å(¡¦Çäå¥ï¥á¡¦¡åáâ´ä ¡¯ucleus¡¦¡¦Ëèëãºä"¢ã£âá㡦# ¡¦¡¦¿½¡¦ ¡¦¡¦£â¥ã³ã¥é¡¦¡¦¡ì¡¦Úä#¡¦#Îä"¢ã¥ã¡¦Îä!Îä!¾ã¡ù¡¦¤ä
\8e¹»æ§ï¡¦¶eb¡¦Ôä#¼ã£ìáâÄç6¶ä!¡¦!Þæ*¶æ¡¦¡¦§ã¡ó¡¦¡¦¡¦¡¦¿ã¥ê¥âÄ塦ááÖä!°ã
\80¢ä!Úä!¶eb¡¦Ôä#¼ã£ìáᡦ£ð¥â¤ã¥è¡¦¡¦¡äáà¢ä!Úä!¡¦¡¦¡¦¼ã£ìáá¸ã¡çá㡦¥ê¥â¡¦£ð¥â°ã¡ì¡¦Òä!§ã¡æ¡¦¶ä"¢æ
\8e¼¼ã¡ïáâ¸ä!Þæ*¶æ¡¦¡¦§ã£ááâ¤ã¥æ¡¦ 追崢¡¦¡¦£â¥ã³ã¥é¡¦¡¦¡ì¡¦¶ä!ºä ¢ä!Êä"²ä!¡¦
\80¢ä!Úä!¡¦¡¦¡¦¼ã£ìå桦!¡¦»ó¡¦¡¦¡÷¡¦Þä!¡¦Ç硦Äç!¸æ³þ¡¦Îä!Þæ*¶æ¡¦¡¦§ã¡â¡¦¸ä!°ã¡ý¡¦¡¦»ó¡¦¡¦Ë硦¤æ¡¦åëÊæ:¡¦!¡¦»ó¡¦¡¦¡÷¡¦¾ã¡ù¡¦
5243 <h3>Bookmarklet</h3>
5245 丶ä!¡¦¥åáã³ã£è±ã¡¦¡¦¡¦Ää ¸ä!´å
\8e®Îä!¡¦¡¦¥â´ä ºä"¤ä!Îä!¾ä!¡¦¥ä¡¦¼ã¥æ¥ãÀä#¼ã¡æ¥ã²ä#¡¦¥ã¡¦°ã¡ä¥áºä!¾ã¡ù¡¦¡¦small>(¡¦Úä!¡¦±í¡¦¡¦¥æ¡¦¹ã¥è¡¦Îä!¡¦¡ð¥áÞä!¡¦@´å¿è¡¦¡¦¹øç´Èä!¡¦·é¡¦¡¦¥åáã³ã£è¥âÄä"¡¦¥åá㡦"¡¦¡÷¡¦¡¦¡ð¥á¡¦¡ï¡¦ ¡¦Êä!¡¦</small>
5248 <a href="<?php echo htmlspecialchars($bm)?>">Add to <?php echo $blog->getShortName()?></a> (¡¦»ã¡äáâÆä!¡¦¡çáãÌä#¡¦£ãáâ¶ã¡ä¡¦Êä
\8e»Øä!Îä!¾ã¡ù)
5251 <h3>¡¦³ã£è¥ã¡¦¥ã¡¦¡¦¥á¥ã¶ä#¥ã¥îáᡦ£âáã³ã£í¥ã°ä#¼ã¥æ
\8eÀ(Windows¡¦¡¦E使çÇäçù¡¦</h3>
5254 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
5255 $url = $manager->addTicketToUrl($url);
5257 ¡¦¤ä"¶ä!¡¦!°Þa href="<?php echo htmlspecialchars($url) ?>">¡¦³ã£è¥ã¡¦¥ã¡¦¡¦¥á¥ã¶ä#¥ã¥î:/a>¡¦¡¦£âáã³ã£í¥ã°ä#¼ã¥æ¥áÒä"¶ä!Æä!¡¦£â¡¦§ã¡í¡¦¾ã¡ù (¡¦¸ç6¶ä!¾ä ºä"Äç!¸æ³þ¡¦Òä"¸ä!°çÕê觡¦¡¦£ìáâ¹ã¥è¡¦¡¦¡æù»é·éááÎä!¾ã¡ù)
5261 ¡¦Æä!¡¦£âáã³ã£í¥ã°ä#¼ã¥æ¥áÎä!Þå/³ã£è¥ã¡¦¥ã¡¦¡¦¥á¥ã¶ä#¥ã¥îáâÄæÝäéâ
\8e¸¡¦Òä"¶ä!Þä"¢ä!¡¦¡èñ¦¡¦¡¦¡¦èµ·åµõ¡¦¸å^¡¦
\8e¤¢ä!§ã¡ù¡¦
5264 <h3>¡¦¢ã¥ê¥â¤ã¥ê¥â¹ã¥è¡¦¼ã¥æ
\8eÜ/h3>
5266 ¡¦¸ä!´å
\8e®Îä!¡¦¡¦¥â´ä ºä"¤ä!Îä!¾ä!¡¦¥ä¡¦¼ã¥æ¥ãÀä#¼ã¡ë¡¦²å
\8e´°ä!Òä!¡¦¡è¥à¢å-Ðä!¡¦±ê¡¦¤ã¡ù¡¦¶ä! ¡¦Âä!§ã¡ù¡¦
5270 ¡¦³ã£è¥ã¡¦¥ã¡¦¡¦¥á¥ã¶ä#¥ã¥îáá¶ä"²å
\8e´°ä!Îä!Þä!¡¦Í⡦¡¦
\80¢ä
\8e¹¥ä·é¡¦¡¦±ëé¡¡¦"Äæ
\8e¶¾ä"Æä!§ã¡ï¡¦ ¡¦Êä!¡¦
5274 <li>¡¦¹ã£ð¥ã¼ã¥è¡¦¡ã¥ë¡¦¥ã¥îáá¶ä"²ä ¸ä#Êä"¡ã£âá㡦£òåꡦMÔä!Îä!¡¦¡¦è¡¡¦..¡¦ºä"Äç!¸æ³þ</li>
5275 <li>"regedit" ¡¦¡¦¡¦¡¦¡¦/li>
5276 <li>"OK" ¡¦Øä"¿ã¥ê¥âÄ塦áᡦ/li>
5277 <li>"\HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt" ¡¦Ää#¡¦#¡¦¥îáᡦ¸¡¦¶ä"²å
\8e¢ØæS¡¦/li>
5278 <li>"add to weblog" ¡¦¡¦¥ê¥ã°ä#¡¦£ò¡¦´ç9¡¦/li>
5287 * @todo document this
5289 function action_actionlog() {
5290 global $member, $manager;
5292 $member->isAdmin() or $this->disallow();
5296 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5298 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
5301 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
5302 <p><a href="<?php echo htmlspecialchars($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
5304 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
5306 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
5307 $template['content'] = 'actionlist';
5308 $amount = showlist($query,'table',$template);
5315 * @todo document this
5317 function action_banlist() {
5318 global $member, $manager;
5320 $blogid = intRequestVar('blogid');
5322 $member->blogAdminRights($blogid) or $this->disallow();
5324 $blog =& $manager->getBlog($blogid);
5328 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5330 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
5332 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
5333 $template['content'] = 'banlist';
5334 $amount = showlist($query,'table',$template);
5339 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
5340 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
5348 * @todo document this
5350 function action_banlistdelete() {
5351 global $member, $manager;
5353 $blogid = intRequestVar('blogid');
5354 $iprange = requestVar('iprange');
5356 $member->blogAdminRights($blogid) or $this->disallow();
5358 $blog =& $manager->getBlog($blogid);
5362 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
5364 <form method="post" action="index.php">
5366 <h3><?php echo _BAN_IPRANGE?></h3>
5369 <?php echo _CONFIRMTXT_BAN?> <?php echo htmlspecialchars($iprange) ?>
5370 <input name="iprange" type="hidden" value="<?php echo htmlspecialchars($iprange)?>" />
5373 <h3><?php echo _BAN_BLOGS?></h3>
5376 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5377 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">Only blog '<?php echo htmlspecialchars($blog->getName())?>'</label>
5379 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5382 <h3><?php echo _BAN_DELETE_TITLE?></h3>
5385 <?php $manager->addTicketHidden() ?>
5386 <input type="hidden" name="action" value="banlistdeleteconfirm" />
5387 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5396 * @todo document this
5398 function action_banlistdeleteconfirm() {
5399 global $member, $manager;
5401 $blogid = intPostVar('blogid');
5402 $allblogs = postVar('allblogs');
5403 $iprange = postVar('iprange');
5405 $member->blogAdminRights($blogid) or $this->disallow();
5410 if (BAN::removeBan($blogid, $iprange))
5411 array_push($deleted, $blogid);
5413 // get blogs fot which member has admin rights
5414 $adminblogs = $member->getAdminBlogs();
5415 foreach ($adminblogs as $blogje) {
5416 if (BAN::removeBan($blogje, $iprange))
5417 array_push($deleted, $blogje);
5421 if (sizeof($deleted) == 0)
5422 $this->error(_ERROR_DELETEBAN);
5426 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
5427 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
5428 echo "<p>"._BAN_REMOVED_TEXT."</p>";
5431 foreach ($deleted as $delblog) {
5432 $b =& $manager->getBlog($delblog);
5433 echo "<li>" . htmlspecialchars($b->getName()). "</li>";
5442 * @todo document this
5444 function action_banlistnewfromitem() {
5445 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
5449 * @todo document this
5451 function action_banlistnew($blogid = '') {
5452 global $member, $manager;
5455 $blogid = intRequestVar('blogid');
5457 $ip = requestVar('ip');
5459 $member->blogAdminRights($blogid) or $this->disallow();
5461 $blog =& $manager->getBlog($blogid);
5465 <h2><?php echo _BAN_ADD_TITLE?></h2>
5468 <form method="post" action="index.php">
5470 <h3><?php echo _BAN_IPRANGE?></h3>
5472 <p><?php echo _BAN_IPRANGE_TEXT?></p>
5475 <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.
5481 <input name="iprange" type="radio" value="<?php echo htmlspecialchars($ip)?>" checked="checked" id="ip_fixed" /><label for="ip_fixed"><?php echo htmlspecialchars($ip)?></label>
5483 <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' />
5485 echo "<input name='iprange' value='custom' type='hidden' />";
5486 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
5491 <h3><?php echo _BAN_BLOGS?></h3>
5493 <p><?php echo _BAN_BLOGS_TEXT?></p>
5496 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5497 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo htmlspecialchars($blog->getName())?>'</label>
5499 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5502 <h3><?php echo _BAN_REASON_TITLE?></h3>
5504 <p><?php echo _BAN_REASON_TEXT?></p>
5506 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
5508 <h3><?php echo _BAN_ADD_TITLE?></h3>
5511 <input name="action" type="hidden" value="banlistadd" />
5512 <?php $manager->addTicketHidden() ?>
5513 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
5518 <?php $this->pagefoot();
5522 * @todo document this
5524 function action_banlistadd() {
5527 $blogid = intPostVar('blogid');
5528 $allblogs = postVar('allblogs');
5529 $iprange = postVar('iprange');
5530 if ($iprange == "custom")
5531 $iprange = postVar('customiprange');
5532 $reason = postVar('reason');
5534 $member->blogAdminRights($blogid) or $this->disallow();
5536 // TODO: check IP range validity
5539 if (!BAN::addBan($blogid, $iprange, $reason))
5540 $this->error(_ERROR_ADDBAN);
5542 // get blogs fot which member has admin rights
5543 $adminblogs = $member->getAdminBlogs();
5545 foreach ($adminblogs as $blogje) {
5546 if (!BAN::addBan($blogje, $iprange, $reason))
5550 $this->error(_ERROR_ADDBAN);
5553 $this->action_banlist();
5558 * @todo document this
5560 function action_clearactionlog() {
5563 $member->isAdmin() or $this->disallow();
5567 $this->action_manage(_MSG_ACTIONLOGCLEARED);
5571 * @todo document this
5573 function action_backupoverview() {
5574 global $member, $manager;
5576 $member->isAdmin() or $this->disallow();
5580 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5582 <h2><?php echo _BACKUPS_TITLE?></h2>
5584 <h3><?php echo _BACKUP_TITLE?></h3>
5586 <p><?php echo _BACKUP_INTRO?></p>
5588 <form method="post" action="index.php"><p>
5589 <input type="hidden" name="action" value="backupcreate" />
5590 <?php $manager->addTicketHidden() ?>
5592 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
5594 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
5596 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
5600 <div class="note"><?php echo _BACKUP_NOTE?></div>
5603 <h3><?php echo _RESTORE_TITLE?></h3>
5605 <div class="note"><?php echo _RESTORE_NOTE?></div>
5607 <p><?php echo _RESTORE_INTRO?></p>
5609 <form method="post" action="index.php" enctype="multipart/form-data"><p>
5610 <input type="hidden" name="action" value="backuprestore" />
5611 <?php $manager->addTicketHidden() ?>
5612 <input name="backup_file" type="file" tabindex="30" />
5614 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
5615 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
5616 <br /><?php echo _RESTORE_WARNING?>
5619 <?php $this->pagefoot();
5623 * @todo document this
5625 function action_backupcreate() {
5626 global $member, $DIR_LIBS;
5628 $member->isAdmin() or $this->disallow();
5630 // use compression ?
5631 $useGzip = intval(postVar('gzip'));
5633 include($DIR_LIBS . 'backup.php');
5635 // try to extend time limit
5636 // (creating/restoring dumps might take a while)
5637 @set_time_limit(1200);
5639 do_backup($useGzip);
5644 * @todo document this
5646 function action_backuprestore() {
5647 global $member, $DIR_LIBS;
5649 $member->isAdmin() or $this->disallow();
5651 if (intPostVar('letsgo') != 1)
5652 $this->error(_ERROR_BACKUP_NOTSURE);
5654 include($DIR_LIBS . 'backup.php');
5656 // try to extend time limit
5657 // (creating/restoring dumps might take a while)
5658 @set_time_limit(1200);
5660 $message = do_restore();
5662 $this->error($message);
5666 <h2><?php echo _RESTORE_COMPLETE?></h2>
5667 <?php $this->pagefoot();
5672 * @todo document this
5674 function action_pluginlist() {
5675 global $member, $manager;
5678 $member->isAdmin() or $this->disallow();
5682 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5684 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
5686 echo '<h3>' , _PLUGS_TITLE_INSTALLED , '</h3>';
5689 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
5691 $template['content'] = 'pluginlist';
5692 $template['tabindex'] = 10;
5693 showlist($query, 'table', $template);
5696 <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
5698 <p><?php echo _PLUGS_TEXT_UPDATE?></p>
5700 <form method="post" action="index.php"><div>
5701 <input type="hidden" name="action" value="pluginupdate" />
5702 <?php $manager->addTicketHidden() ?>
5703 <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
5706 <h3><?php echo _PLUGS_TITLE_NEW?></h3>
5708 <?php // find a list of possibly non-installed plugins
5709 $candidates = array();
5710 global $DIR_PLUGINS;
5711 $dirhandle = opendir($DIR_PLUGINS);
5712 while ($filename = readdir($dirhandle)) {
5713 if (ereg('^NP_(.*)\.php$',$filename,$matches)) {
5714 $name = $matches[1];
5715 // only show in list when not yet installed
5716 $res = sql_query('SELECT * FROM '.sql_table('plugin').' WHERE pfile="NP_'.addslashes($name).'"');
5717 if (mysql_num_rows($res) == 0)
5718 array_push($candidates,$name);
5721 closedir($dirhandle);
5723 if (sizeof($candidates) > 0) {
5726 <p><?php echo _PLUGS_ADD_TEXT?></p>
5729 <form method='post' action='index.php'><div>
5730 <input type='hidden' name='action' value='pluginadd' />
5731 <?php $manager->addTicketHidden() ?>
5732 <select name="filename" tabindex="30">
5733 <?php foreach($candidates as $name)
5734 echo '<option value="NP_',$name,'">',htmlspecialchars($name),'</option>';
5737 <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
5740 <?php } else { // sizeof(candidates) == 0
5741 echo '<p>',_PLUGS_NOCANDIDATES,'</p>';
5748 * @todo document this
5750 function action_pluginhelp() {
5751 global $member, $manager, $DIR_PLUGINS, $CONF;
5754 $member->isAdmin() or $this->disallow();
5756 $plugid = intGetVar('plugid');
5758 if (!$manager->pidInstalled($plugid))
5759 $this->error(_ERROR_NOSUCHPLUGIN);
5761 $plugName = getPluginNameFromPid($plugid);
5765 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
5767 echo '<h2>',_PLUGS_HELP_TITLE,': ',htmlspecialchars($plugName),'</h2>';
5769 $plug =& $manager->getPlugin($plugName);
5770 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
5772 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
5773 @readfile($helpFile);
5775 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
5776 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
5784 * @todo document this
5786 function action_pluginadd() {
5787 global $member, $manager, $DIR_PLUGINS;
5790 $member->isAdmin() or $this->disallow();
5792 $name = postVar('filename');
5794 if ($manager->pluginInstalled($name))
5795 $this->error(_ERROR_DUPPLUGIN);
5796 if (!checkPlugin($name))
5797 $this->error(_ERROR_PLUGFILEERROR . ' (' . htmlspecialchars($name) . ')');
5799 // get number of currently installed plugins
5800 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
5801 $numCurrent = mysql_num_rows($res);
5803 // plugin will be added as last one in the list
5804 $newOrder = $numCurrent + 1;
5813 // do this before calling getPlugin (in case the plugin id is used there)
5814 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.addslashes($name).'")';
5816 $iPid = mysql_insert_id();
5818 $manager->clearCachedInfo('installedPlugins');
5820 // Load the plugin for condition checking and instalation
5821 $plugin =& $manager->getPlugin($name);
5823 // check if it got loaded (could have failed)
5826 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
5827 $manager->clearCachedInfo('installedPlugins');
5828 $this->error(_ERROR_PLUGIN_LOAD);
5831 // check if plugin needs a newer Nucleus version
5832 if (getNucleusVersion() < $plugin->getMinNucleusVersion())
5834 // uninstall plugin again...
5835 $this->deleteOnePlugin($plugin->getID());
5837 // ...and show error
5838 $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars($plugin->getMinNucleusVersion()));
5841 // check if plugin needs a newer Nucleus version
5842 if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
5844 // uninstall plugin again...
5845 $this->deleteOnePlugin($plugin->getID());
5847 // ...and show error
5848 $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
5851 $pluginList = $plugin->getPluginDep();
5852 foreach ($pluginList as $pluginName)
5855 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
5856 if (mysql_num_rows($res) == 0)
5858 // uninstall plugin again...
5859 $this->deleteOnePlugin($plugin->getID());
5861 $this->error(_ERROR_INSREQPLUGIN . htmlspecialchars($pluginName));
5865 // call the install method of the plugin
5871 'plugin' => &$plugin
5875 // update all events
5876 $this->action_pluginupdate();
5880 * @todo document this
5882 function action_pluginupdate() {
5883 global $member, $manager;
5886 $member->isAdmin() or $this->disallow();
5888 // delete everything from plugin_events
5889 sql_query('DELETE FROM '.sql_table('plugin_event'));
5891 // loop over all installed plugins
5892 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
5893 while($o = mysql_fetch_object($res)) {
5895 $plug =& $manager->getPlugin($o->pfile);
5898 $eventList = $plug->getEventList();
5899 foreach ($eventList as $eventName)
5900 sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.addslashes($eventName).'\')');
5904 $this->action_pluginlist();
5908 * @todo document this
5910 function action_plugindelete() {
5911 global $member, $manager;
5914 $member->isAdmin() or $this->disallow();
5916 $pid = intGetVar('plugid');
5918 if (!$manager->pidInstalled($pid))
5919 $this->error(_ERROR_NOSUCHPLUGIN);
5923 <h2><?php echo _DELETE_CONFIRM?></h2>
5925 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
5927 <form method="post" action="index.php"><div>
5928 <?php $manager->addTicketHidden() ?>
5929 <input type="hidden" name="action" value="plugindeleteconfirm" />
5930 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
5931 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5933 <?php $this->pagefoot();
5937 * @todo document this
5939 function action_plugindeleteconfirm() {
5940 global $member, $manager;
5943 $member->isAdmin() or $this->disallow();
5945 $pid = intPostVar('plugid');
5947 $error = $this->deleteOnePlugin($pid, 1);
5949 $this->error($error);
5952 $this->action_pluginlist();
5956 * @todo document this
5958 function deleteOnePlugin($pid, $callUninstall = 0) {
5961 $pid = intval($pid);
5963 if (!$manager->pidInstalled($pid))
5964 return _ERROR_NOSUCHPLUGIN;
5966 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
5968 // call the unInstall method of the plugin
5969 if ($callUninstall) {
5970 $plugin =& $manager->getPlugin($name);
5971 if ($plugin) $plugin->unInstall();
5974 // check dependency before delete
5975 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
5976 while($o = mysql_fetch_object($res)) {
5977 $plug =& $manager->getPlugin($o->pfile);
5980 $depList = $plug->getPluginDep();
5981 foreach ($depList as $depName)
5983 if ($name == $depName)
5985 return _ERROR_DELREQPLUGIN . $o->pfile;
5991 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
5993 // delete all subscriptions
5994 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
5996 // delete all options
5997 // get OIDs from plugin_option_desc
5998 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
6000 while ($o = mysql_fetch_object($res)) {
6001 array_push($aOIDs, $o->oid);
6004 // delete from plugin_option and plugin_option_desc
6005 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
6006 if (count($aOIDs) > 0)
6007 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
6009 // update order numbers
6010 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
6011 $o = mysql_fetch_object($res);
6012 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
6015 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
6017 $manager->clearCachedInfo('installedPlugins');
6018 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
6024 * @todo document this
6026 function action_pluginup() {
6027 global $member, $manager;
6030 $member->isAdmin() or $this->disallow();
6032 $plugid = intGetVar('plugid');
6034 if (!$manager->pidInstalled($plugid))
6035 $this->error(_ERROR_NOSUCHPLUGIN);
6037 // 1. get old order number
6038 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6039 $o = mysql_fetch_object($res);
6040 $oldOrder = $o->porder;
6042 // 2. calculate new order number
6043 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
6045 // 3. update plug numbers
6046 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6047 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6049 $this->action_pluginlist();
6053 * @todo document this
6055 function action_plugindown() {
6056 global $member, $manager;
6059 $member->isAdmin() or $this->disallow();
6061 $plugid = intGetVar('plugid');
6062 if (!$manager->pidInstalled($plugid))
6063 $this->error(_ERROR_NOSUCHPLUGIN);
6065 // 1. get old order number
6066 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6067 $o = mysql_fetch_object($res);
6068 $oldOrder = $o->porder;
6070 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6071 $maxOrder = mysql_num_rows($res);
6073 // 2. calculate new order number
6074 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6076 // 3. update plug numbers
6077 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6078 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6080 $this->action_pluginlist();
6084 * @todo document this
6086 function action_pluginoptions($message = '') {
6087 global $member, $manager;
6090 $member->isAdmin() or $this->disallow();
6092 $pid = intRequestVar('plugid');
6093 if (!$manager->pidInstalled($pid))
6094 $this->error(_ERROR_NOSUCHPLUGIN);
6096 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
6097 $this->pagehead($extrahead);
6100 <p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>
6102 <h2>Options for <?php echo htmlspecialchars(getPluginNameFromPid($pid))?></h2>
6104 <?php if ($message) echo $message?>
6106 <form action="index.php" method="post">
6108 <input type="hidden" name="action" value="pluginoptionsupdate" />
6109 <input type="hidden" name="plugid" value="<?php echo $pid?>" />
6113 $manager->addTicketHidden();
6115 $aOptions = array();
6117 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
6118 $r = sql_query($query);
6119 while ($o = mysql_fetch_object($r)) {
6120 array_push($aOIDs, $o->oid);
6121 $aOptions[$o->oid] = array(
6123 'value' => $o->odef,
6124 'name' => $o->oname,
6125 'description' => $o->odesc,
6126 'type' => $o->otype,
6127 'typeinfo' => $o->oextra,
6131 // fill out actual values
6132 if (count($aOIDs) > 0) {
6133 $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
6134 while ($o = mysql_fetch_object($r))
6135 $aOptions[$o->oid]['value'] = $o->ovalue;
6139 $manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));
6141 $template['content'] = 'plugoptionlist';
6142 $amount = showlist($aOptions,'table',$template);
6144 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
6149 <?php $this->pagefoot();
6156 * @todo document this
6158 function action_pluginoptionsupdate() {
6159 global $member, $manager;
6162 $member->isAdmin() or $this->disallow();
6164 $pid = intRequestVar('plugid');
6165 if (!$manager->pidInstalled($pid))
6166 $this->error(_ERROR_NOSUCHPLUGIN);
6168 $aOptions = requestArray('plugoption');
6169 NucleusPlugin::_applyPluginOptions($aOptions);
6171 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
6173 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
6178 * @todo document this
6180 function _insertPluginOptions($context, $contextid = 0) {
6181 // get all current values for this contextid
6182 // (note: this might contain doubles for overlapping contextids)
6183 $aIdToValue = array();
6184 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
6185 while ($o = mysql_fetch_object($res)) {
6186 $aIdToValue[$o->oid] = $o->ovalue;
6189 // get list of oids per pid
6190 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
6191 . ' WHERE opid=pid and ocontext=\''.addslashes($context).'\' ORDER BY porder, oid ASC';
6192 $res = sql_query($query);
6193 $aOptions = array();
6194 while ($o = mysql_fetch_object($res)) {
6195 if (in_array($o->oid, array_keys($aIdToValue)))
6196 $value = $aIdToValue[$o->oid];
6200 array_push($aOptions, array(
6202 'pfile' => $o->pfile,
6205 'name' => $o->oname,
6206 'description' => $o->odesc,
6207 'type' => $o->otype,
6208 'typeinfo' => $o->oextra,
6209 'contextid' => $contextid,
6215 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
6219 foreach ($aOptions as $aOption) {
6222 if ($iPrevPid != $aOption['pid']) {
6223 $iPrevPid = $aOption['pid'];
6225 echo '<tr><th colspan="2">Options for ', htmlspecialchars($aOption['pfile']),'</th></tr>';
6229 listplug_plugOptionRow($aOption);
6238 * Helper functions to create option forms etc.
6239 * @todo document parameters
6241 function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {
6242 $id = htmlspecialchars($name);
6243 $id = str_replace('[','-',$id);
6244 $id = str_replace(']','-',$id);
6245 $id1 = $id . htmlspecialchars($value1);
6246 $id2 = $id . htmlspecialchars($value2);
6248 if ($name=="admin") {
6249 echo '<input onclick="selectCanLogin(true);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
6251 echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
6254 if ($checkedval == $value1)
6255 echo "tabindex='$tabindex' checked='checked'";
6256 echo ' id="'.$id1.'" /><label for="'.$id1.'">' . $yesval . '</label>';
6258 if ($name=="admin") {
6259 echo '<input onclick="selectCanLogin(false);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
6261 echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
6263 if ($checkedval != $value1)
6264 echo "tabindex='$tabindex' checked='checked'";
6265 if ($isAdmin && $name=="canlogin")
6266 echo " disabled='true'";
6267 echo ' id="'.$id2.'" /><label for="'.$id2.'">' . $noval . '</label>';