X-Git-Url: http://git.sourceforge.jp/view?p=nucleus-jp%2Fnucleus-jp-ancient.git;a=blobdiff_plain;f=utf8%2Fnucleus%2Flibs%2FADMIN.php;h=6b6e5361e69ecbe97e396b2060a191ac3216d490;hp=657362f320f108a9f868f2a41a5a4c77e4ef2e33;hb=7a9ab741d74fc3e819af9b1e23a2bb6a28e00297;hpb=02ef663776459a9704a30f1a15a21f814f7d6239 diff --git a/utf8/nucleus/libs/ADMIN.php b/utf8/nucleus/libs/ADMIN.php index 657362f..6b6e536 100755 --- a/utf8/nucleus/libs/ADMIN.php +++ b/utf8/nucleus/libs/ADMIN.php @@ -1,35 +1,48 @@ action_xxxx method) + /** + * @var string $action action currently being executed ($action=xxxx -> action_xxxx method) + */ var $action; + /** + * Class constructor + */ function ADMIN() { } /** - * Executes an action - * - * @param $action - * action to be performed - */ + * Executes an action + * + * @param string $action action to be performed + */ function action($action) { global $CONF, $manager; @@ -39,7 +52,7 @@ class ADMIN { '' => 'overview' ); - if ($alias[$action]) + if (isset($alias[$action])) $action = $alias[$action]; $methodName = 'action_' . $action; @@ -49,10 +62,60 @@ class ADMIN { // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action // is an action that requires user interaction before something is actually done) // all safe actions are in this array: - $aActionsNotToCheck = array('showlogin', 'login', 'overview', 'itemlist', 'blogcommentlist', 'bookmarklet', 'blogsettings', 'banlist', 'deleteblog', 'editmembersettings', 'browseownitems', 'browseowncomments', 'createitem', 'itemedit', 'itemmove', 'categoryedit', 'categorydelete', 'manage', 'actionlog', 'settingsedit', 'backupoverview', 'pluginlist', 'createnewlog', 'usermanagement', 'skinoverview', 'templateoverview', 'skinieoverview', 'itemcommentlist', 'commentedit', 'commentdelete', 'banlistnewfromitem', 'banlistdelete', 'itemdelete', 'manageteam', 'teamdelete', 'banlistnew', 'memberedit', 'memberdelete', 'pluginhelp', 'pluginoptions', 'plugindelete', 'skinedittype', 'skindelete', 'skinedit', 'templateedit', 'templatedelete', 'activate'); + $aActionsNotToCheck = array( + 'showlogin', + 'login', + 'overview', + 'itemlist', + 'blogcommentlist', + 'bookmarklet', + 'blogsettings', + 'banlist', + 'deleteblog', + 'editmembersettings', + 'browseownitems', + 'browseowncomments', + 'createitem', + 'itemedit', + 'itemmove', + 'categoryedit', + 'categorydelete', + 'manage', + 'actionlog', + 'settingsedit', + 'backupoverview', + 'pluginlist', + 'createnewlog', + 'usermanagement', + 'skinoverview', + 'templateoverview', + 'skinieoverview', + 'itemcommentlist', + 'commentedit', + 'commentdelete', + 'banlistnewfromitem', + 'banlistdelete', + 'itemdelete', + 'manageteam', + 'teamdelete', + 'banlistnew', + 'memberedit', + 'memberdelete', + 'pluginhelp', + 'pluginoptions', + 'plugindelete', + 'skinedittype', + 'skinremovetype', + 'skindelete', + 'skinedit', + 'templateedit', + 'templatedelete', + 'activate', + 'systemoverview' + ); /* // the rest of the actions needs to be checked - $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'sendping', 'rawping', 'activatesetpwd'); + $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd'); */ if (!in_array($this->action, $aActionsNotToCheck)) { @@ -63,16 +126,21 @@ class ADMIN { if (method_exists($this, $methodName)) call_user_func(array(&$this, $methodName)); else - $this->error(_BADACTION . " ($action)"); + $this->error(_BADACTION . htmlspecialchars(" ($action)")); } - + /** + * @todo document this + */ function action_showlogin() { global $error; $this->action_login($error); } + /** + * @todo document this + */ function action_login($msg = '', $passvars = 1) { global $member; @@ -89,9 +157,9 @@ class ADMIN { ?>

- :
+

- :
+


@@ -101,7 +169,7 @@ class ADMIN {
-

- pagefoot(); + pagefoot(); } /** - * provides a screen with the overview of the actions available - */ + * provides a screen with the overview of the actions available + * @todo document parameter + */ function action_overview($msg = '') { global $member; @@ -149,7 +218,7 @@ class ADMIN { if (($showAll != 'yes') && ($member->isAdmin())) { $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog')); if ($total > $amount) - echo '

Show all blogs

'; + echo '

' . _OVERVIEW_SHOWALL . '

'; } if ($amount == 0) @@ -186,11 +255,17 @@ class ADMIN { $this->pagefoot(); } - // returns a link to a weblog (takes BLOG object as parameter) + /** + * Returns a link to a weblog + * @param object BLOG + */ function bloglink(&$blog) { - return ''.$blog->getName() .''; + return ''. htmlspecialchars( $blog->getName() ) .''; } + /** + * @todo document this + */ function action_manage($msg = '') { global $member; @@ -229,8 +304,11 @@ class ADMIN { $this->pagefoot(); } + /** + * @todo document this + */ function action_itemlist($blogid = '') { - global $member, $manager; + global $member, $manager, $CONF; if ($blogid == '') $blogid = intRequestVar('blogid'); @@ -255,17 +333,20 @@ class ADMIN { // amount of items to show if (postVar('amount')) $amount = intPostVar('amount'); - else - $amount = 10; + else { + $amount = intval($CONF['DefaultListSize']); + if ($amount < 1) + $amount = 10; + } $search = postVar('search'); // search through items - $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime' + $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime, bnumber, catid' . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category') . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid; if ($search) - $query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))'; + $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))'; // non-blog-admins can only edit/delete their own items if (!$member->blogAdminRights($blogid)) @@ -278,7 +359,7 @@ class ADMIN { $template['content'] = 'itemlist'; $template['now'] = $blog->getCorrectTime(time()); - + $manager->loadClass("ENCAPSULATE"); $navList =& new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0); $navList->showBatchList('item',$query,'table',$template); @@ -286,7 +367,9 @@ class ADMIN { $this->pagefoot(); } - + /** + * @todo document this + */ function action_batchitem() { global $member, $manager; @@ -334,7 +417,7 @@ class ADMIN { $error = $this->moveOneItem($itemid, $destCatid); break; default: - $error = _BATCH_UNKNOWN . $action; + $error = _BATCH_UNKNOWN . htmlspecialchars($action); } echo '',($error ? $error : _BATCH_SUCCESS),''; @@ -349,6 +432,9 @@ class ADMIN { } + /** + * @todo document this + */ function action_batchcomment() { global $member; @@ -387,7 +473,7 @@ class ADMIN { $error = $this->deleteOneComment($commentid); break; default: - $error = _BATCH_UNKNOWN . $action; + $error = _BATCH_UNKNOWN . htmlspecialchars($action); } echo '',($error ? $error : _BATCH_SUCCESS),''; @@ -402,6 +488,9 @@ class ADMIN { } + /** + * @todo document this + */ function action_batchmember() { global $member; @@ -445,13 +534,13 @@ class ADMIN { case 'unsetadmin': // there should always remain at least one super-admin $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1'); - if (mysql_num_rows($r) < 2) + if (sql_num_rows($r) < 2) $error = _ERROR_ATLEASTONEADMIN; else sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid); break; default: - $error = _BATCH_UNKNOWN . $action; + $error = _BATCH_UNKNOWN . htmlspecialchars($action); } echo '',($error ? $error : _BATCH_SUCCESS),''; @@ -466,7 +555,9 @@ class ADMIN { } - + /** + * @todo document this + */ function action_batchteam() { global $member; @@ -513,13 +604,13 @@ class ADMIN { case 'unsetadmin': // there should always remain at least one admin $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid); - if (mysql_num_rows($r) < 2) + if (sql_num_rows($r) < 2) $error = _ERROR_ATLEASTONEBLOGADMIN; else sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid); break; default: - $error = _BATCH_UNKNOWN . $action; + $error = _BATCH_UNKNOWN . htmlspecialchars($action); } echo '',($error ? $error : _BATCH_SUCCESS),''; @@ -534,8 +625,9 @@ class ADMIN { } - - + /** + * @todo document this + */ function action_batchcategory() { global $member, $manager; @@ -582,10 +674,10 @@ class ADMIN { $error = $this->moveOneCategory($catid, $destBlogId); break; default: - $error = _BATCH_UNKNOWN . $action; + $error = _BATCH_UNKNOWN . htmlspecialchars($action); } - echo '',($error ? 'Error: '.$error : _BATCH_SUCCESS),''; + echo '',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),''; echo ''; } @@ -596,6 +688,9 @@ class ADMIN { } + /** + * @todo document this + */ function batchMoveSelectDestination($type, $ids) { global $manager; $this->pagehead(); @@ -622,10 +717,13 @@ class ADMIN { - pagefoot(); + pagefoot(); exit; } + /** + * @todo document this + */ function batchMoveCategorySelectDestination($type, $ids) { global $manager; $this->pagehead(); @@ -652,10 +750,13 @@ class ADMIN { - pagefoot(); + pagefoot(); exit; } + /** + * @todo document this + */ function batchAskDeleteConfirmation($type, $ids) { global $manager; @@ -668,7 +769,7 @@ class ADMIN { addTicketHidden() ?> - '; @@ -688,27 +789,30 @@ class ADMIN { - pagefoot(); + pagefoot(); exit; } /** - * Inserts a HTML select element with choices for all categories to which the current - * member has access - */ + * Inserts a HTML select element with choices for all categories to which the current + * member has access + * @see function selectBlog + */ function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) { ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude); } /** - * Inserts a HTML select element with choices for all blogs to which the user has access - * mode = 'blog' => shows blognames and values are blogids - * mode = 'category' => show category names and values are catids - * - * @param $iForcedBlogInclude - * ID of a blog that always needs to be included, without checking if the member is on the blog team (-1 = none) - */ + * Inserts a HTML select element with choices for all blogs to which the user has access + * mode = 'blog' => shows blognames and values are blogids + * mode = 'category' => show category names and values are catids + * + * @param $iForcedBlogInclude + * ID of a blog that always needs to be included, without checking if the + * member is on the blog team (-1 = none) + * @todo document parameters + */ function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) { global $member, $CONF; @@ -722,7 +826,7 @@ class ADMIN { else $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID(); $rblogids = sql_query($queryBlogs); - while ($o = mysql_fetch_object($rblogids)) + while ($o = sql_fetch_object($rblogids)) if ($o->bnumber != $iForcedBlogInclude) $aBlogIds[] = intval($o->bnumber); @@ -736,10 +840,10 @@ class ADMIN { $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname'; $blogs = sql_query($queryBlogs); if ($mode == 'category') { - if (mysql_num_rows($blogs) > 1) + if (sql_num_rows($blogs) > 1) $multipleBlogs = 1; - while ($oBlog = mysql_fetch_object($blogs)) { + while ($oBlog = sql_fetch_object($blogs)) { if ($multipleBlogs) echo ''; @@ -752,7 +856,7 @@ class ADMIN { // 2. for each category in that blog $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC'); - while ($oCat = mysql_fetch_object($categories)) { + while ($oCat = sql_fetch_object($categories)) { if ($oCat->catid == $selected) $selectText = ' selected="selected" '; else @@ -765,7 +869,7 @@ class ADMIN { } } else { // blog mode - while ($oBlog = mysql_fetch_object($blogs)) { + while ($oBlog = sql_fetch_object($blogs)) { echo '