From 0f14e5d1173d861ce92f41796bdc094ca780ab0c Mon Sep 17 00:00:00 2001 From: Emily Wan <93227982+emilylwan@users.noreply.github.com> Date: Mon, 9 Oct 2023 23:39:05 -0400 Subject: [PATCH 1/8] inital changes --- htdocs/libraries/xml/rpc/bloggerapi.php | 620 +++--- htdocs/libraries/xml/rpc/metaweblogapi.php | 580 ++--- htdocs/libraries/xml/rpc/movabletypeapi.php | 190 +- htdocs/libraries/xml/rpc/xmlrpcapi.php | 352 +-- htdocs/libraries/xml/rpc/xmlrpcparser.php | 1962 ++++++++--------- htdocs/libraries/xml/rpc/xmlrpctag.php | 676 +++--- htdocs/libraries/xml/rpc/xoopsapi.php | 724 +++--- htdocs/libraries/xml/rss/xmlrss2parser.php | 1516 ++++++------- htdocs/libraries/xml/saxparser.php | 758 +++---- htdocs/libraries/xml/themesetparser.php | 858 +++---- htdocs/libraries/xml/xmltaghandler.php | 152 +- htdocs/mainfile.php | 96 +- .../system/admin/adsense/xoops_version.php | 50 +- .../system/admin/autotasks/xoops_version.php | 52 +- .../system/admin/avatars/xoops_version.php | 106 +- .../admin/blocksadmin/xoops_version.php | 106 +- .../admin/blockspadmin/class/blockspadmin.php | 210 +- .../admin/blockspadmin/xoops_version.php | 56 +- .../system/admin/comments/admin_header.php | 60 +- .../system/admin/comments/comment_delete.php | 28 +- .../system/admin/comments/comment_edit.php | 28 +- .../system/admin/comments/comment_post.php | 26 +- .../system/admin/comments/xoops_version.php | 104 +- .../system/admin/customtag/xoops_version.php | 50 +- .../system/admin/findusers/xoops_version.php | 106 +- htdocs/modules/system/admin/groupperm.php | 216 +- .../modules/system/admin/groups/groupform.php | 306 +-- .../system/admin/groups/xoops_version.php | 106 +- .../system/admin/images/js/imanager.js | 308 +-- .../system/admin/images/xoops_version.php | 108 +- .../system/admin/mailusers/xoops_version.php | 48 +- .../system/admin/mimetype/xoops_version.php | 52 +- .../admin/modulesadmin/xoops_version.php | 106 +- .../system/admin/pages/xoops_version.php | 52 +- .../admin/preferences/xoops_version.php | 106 +- .../system/admin/rating/class/rating.php | 458 ++-- .../system/admin/rating/xoops_version.php | 52 +- .../system/admin/smilies/smileform.php | 108 +- .../system/admin/smilies/xoops_version.php | 106 +- .../modules/system/admin/tplsets/tplform.php | 142 +- .../system/admin/tplsets/xoops_version.php | 106 +- .../system/admin/userrank/class/userrank.php | 332 +-- .../system/admin/userrank/xoops_version.php | 106 +- 43 files changed, 6142 insertions(+), 6142 deletions(-) diff --git a/htdocs/libraries/xml/rpc/bloggerapi.php b/htdocs/libraries/xml/rpc/bloggerapi.php index 6528d4893d3e..da2f91ad2158 100644 --- a/htdocs/libraries/xml/rpc/bloggerapi.php +++ b/htdocs/libraries/xml/rpc/bloggerapi.php @@ -1,310 +1,310 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * XML Parser, Blogger Api - * - * @copyright http://www.xoops.org/ The XOOPS Project - * @copyright XOOPS_copyrights.txt - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package XML - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: bloggerapi.php 19118 2010-03-27 17:46:23Z skenow $ - */ - -if (!defined('ICMS_ROOT_PATH')) { - die("ImpressCMS root path not defined"); -} -require_once ICMS_LIBRARIES_PATH . '/xml/rpc/xmlrpcapi.php'; - -class BloggerApi extends XoopsXmlRpcApi -{ - - function BloggerApi(&$params, &$response, &$module) - { - $this->XoopsXmlRpcApi($params, $response, $module); - $this->_setXoopsTagMap('storyid', 'postid'); - $this->_setXoopsTagMap('published', 'dateCreated'); - $this->_setXoopsTagMap('uid', 'userid'); - } - - function newPost() - { - if (!$this->_checkUser($this->params[2], $this->params[3])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - if (!$fields =& $this->_getPostFields(null, $this->params[1])) { - $this->response->add(new XoopsXmlRpcFault(106)); - } else { - $missing = array(); - $post = array(); - foreach ($fields as $tag => $detail) { - $maptag = $this->_getXoopsTagMap($tag); - $data = $this->_getTagCdata($this->params[4], $maptag, true); - if (trim($data) == ''){ - if ($detail['required']) { - $missing[] = $maptag; - } - } else { - $post[$tag] = $data; - } - } - if (count($missing) > 0) { - $msg = ''; - foreach ($missing as $m) { - $msg .= '<'.$m.'> '; - } - $this->response->add(new XoopsXmlRpcFault(109, $msg)); - } else { - $newparams = array(); - // Xoops Api ignores App key - $newparams[0] = $this->params[1]; - $newparams[1] = $this->params[2]; - $newparams[2] = $this->params[3]; - foreach ($post as $key => $value) { - $newparams[3][$key] =& $value; - unset($value); - } - $newparams[3]['xoops_text'] =& $this->params[4]; - $newparams[4] = $this->params[5]; - $xoopsapi =& $this->_getXoopsApi($newparams); - $xoopsapi->_setUser($this->user, $this->isadmin); - $xoopsapi->newPost(); - } - } - } - } - - function editPost() - { - if (!$this->_checkUser($this->params[2], $this->params[3])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - if (!$fields =& $this->_getPostFields($this->params[1])) { - } else { - $missing = array(); - $post = array(); - foreach ($fields as $tag => $detail) { - $data = $this->_getTagCdata($this->params[4], $tag, true); - if (trim($data) == ''){ - if ($detail['required']) { - $missing[] = $tag; - } - } else { - $post[$tag] = $data; - } - } - if (count($missing) > 0) { - $msg = ''; - foreach ($missing as $m) { - $msg .= '<'.$m.'> '; - } - $this->response->add(new XoopsXmlRpcFault(109, $msg)); - } else { - $newparams = array(); - // XOOPS API ignores App key (index 0 of params) - $newparams[0] = $this->params[1]; - $newparams[1] = $this->params[2]; - $newparams[2] = $this->params[3]; - foreach ($post as $key => $value) { - $newparams[3][$key] =& $value; - unset($value); - } - $newparams[3]['xoops_text'] =& $this->params[4]; - $newparams[4] = $this->params[5]; - $xoopsapi =& $this->_getXoopsApi($newparams); - $xoopsapi->_setUser($this->user, $this->isadmin); - $xoopsapi->editPost(); - } - } - } - } - - function deletePost() - { - if (!$this->_checkUser($this->params[2], $this->params[3])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - // XOOPS API ignores App key (index 0 of params) - array_shift($this->params); - $xoopsapi =& $this->_getXoopsApi($this->params); - $xoopsapi->_setUser($this->user, $this->isadmin); - $xoopsapi->deletePost(); - } - } - - function getPost() - { - if (!$this->_checkUser($this->params[2], $this->params[3])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - // XOOPS API ignores App key (index 0 of params) - array_shift($this->params); - $xoopsapi =& $this->_getXoopsApi($this->params); - $xoopsapi->_setUser($this->user, $this->isadmin); - $ret =& $xoopsapi->getPost(false); - if (is_array($ret)) { - $struct = new XoopsXmlRpcStruct(); - $content = ''; - foreach ($ret as $key => $value) { - $maptag = $this->_getXoopsTagMap($key); - switch($maptag) { - case 'userid': - $struct->add('userid', new XoopsXmlRpcString($value)); - break; - case 'dateCreated': - $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); - break; - case 'postid': - $struct->add('postid', new XoopsXmlRpcString($value)); - break; - default : - $content .= '<'.$key.'>'.trim($value).''; - break; - } - } - $struct->add('content', new XoopsXmlRpcString($content)); - $this->response->add($struct); - } else { - $this->response->add(new XoopsXmlRpcFault(106)); - } - } - } - - function getRecentPosts() - { - if (!$this->_checkUser($this->params[2], $this->params[3])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - // XOOPS API ignores App key (index 0 of params) - array_shift($this->params); - $xoopsapi =& $this->_getXoopsApi($this->params); - $xoopsapi->_setUser($this->user, $this->isadmin); - $ret =& $xoopsapi->getRecentPosts(false); - if (is_array($ret)) { - $arr = new XoopsXmlRpcArray(); - $count = count($ret); - if ($count == 0) { - $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); - } else { - for ($i = 0; $i < $count; $i++) { - $struct = new XoopsXmlRpcStruct(); - $content = ''; - foreach($ret[$i] as $key => $value) { - $maptag = $this->_getXoopsTagMap($key); - switch($maptag) { - case 'userid': - $struct->add('userid', new XoopsXmlRpcString($value)); - break; - case 'dateCreated': - $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); - break; - case 'postid': - $struct->add('postid', new XoopsXmlRpcString($value)); - break; - default : - $content .= '<'.$key.'>'.trim($value).''; - break; - } - } - $struct->add('content', new XoopsXmlRpcString($content)); - $arr->add($struct); - unset($struct); - } - $this->response->add($arr); - } - } else { - $this->response->add(new XoopsXmlRpcFault(106)); - } - } - } - - function getUsersBlogs() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - $arr = new XoopsXmlRpcArray(); - $struct = new XoopsXmlRpcStruct(); - $struct->add('url', new XoopsXmlRpcString(ICMS_URL.'/modules/'.$this->module->getVar('dirname').'/')); - $struct->add('blogid', new XoopsXmlRpcString($this->module->getVar('mid'))); - $struct->add('blogName', new XoopsXmlRpcString('XOOPS Blog')); - $arr->add($struct); - $this->response->add($arr); - } - } - - function getUserInfo() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - $struct = new XoopsXmlRpcStruct(); - $struct->add('nickname', new XoopsXmlRpcString($this->user->getVar('uname'))); - $struct->add('userid', new XoopsXmlRpcString($this->user->getVar('uid'))); - $struct->add('url', new XoopsXmlRpcString($this->user->getVar('url'))); - $struct->add('email', new XoopsXmlRpcString($this->user->getVar('email'))); - $struct->add('lastname', new XoopsXmlRpcString('')); - $struct->add('firstname', new XoopsXmlRpcString($this->user->getVar('name'))); - $this->response->add($struct); - } - } - - function getTemplate() - { - if (!$this->_checkUser($this->params[2], $this->params[3])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - switch ($this->params[5]) { - case 'main': - $this->response->add(new XoopsXmlRpcFault(107)); - break; - case 'archiveIndex': - $this->response->add(new XoopsXmlRpcFault(107)); - break; - default: - $this->response->add(new XoopsXmlRpcFault(107)); - break; - } - } - } - - function setTemplate() - { - if (!$this->_checkUser($this->params[2], $this->params[3])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - $this->response->add(new XoopsXmlRpcFault(107)); - } - } -} -?> + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * XML Parser, Blogger Api + * + * @copyright http://www.xoops.org/ The XOOPS Project + * @copyright XOOPS_copyrights.txt + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package XML + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: bloggerapi.php 19118 2010-03-27 17:46:23Z skenow $ + */ + +if (!defined('ICMS_ROOT_PATH')) { + die("ImpressCMS root path not defined"); +} +require_once ICMS_LIBRARIES_PATH . '/xml/rpc/xmlrpcapi.php'; + +class BloggerApi extends XoopsXmlRpcApi +{ + + function BloggerApi(&$params, &$response, &$module) + { + $this->XoopsXmlRpcApi($params, $response, $module); + $this->_setXoopsTagMap('storyid', 'postid'); + $this->_setXoopsTagMap('published', 'dateCreated'); + $this->_setXoopsTagMap('uid', 'userid'); + } + + function newPost() + { + if (!$this->_checkUser($this->params[2], $this->params[3])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + if (!$fields =& $this->_getPostFields(null, $this->params[1])) { + $this->response->add(new XoopsXmlRpcFault(106)); + } else { + $missing = array(); + $post = array(); + foreach ($fields as $tag => $detail) { + $maptag = $this->_getXoopsTagMap($tag); + $data = $this->_getTagCdata($this->params[4], $maptag, true); + if (trim($data) == ''){ + if ($detail['required']) { + $missing[] = $maptag; + } + } else { + $post[$tag] = $data; + } + } + if (count($missing) > 0) { + $msg = ''; + foreach ($missing as $m) { + $msg .= '<'.$m.'> '; + } + $this->response->add(new XoopsXmlRpcFault(109, $msg)); + } else { + $newparams = array(); + // Xoops Api ignores App key + $newparams[0] = $this->params[1]; + $newparams[1] = $this->params[2]; + $newparams[2] = $this->params[3]; + foreach ($post as $key => $value) { + $newparams[3][$key] =& $value; + unset($value); + } + $newparams[3]['xoops_text'] =& $this->params[4]; + $newparams[4] = $this->params[5]; + $xoopsapi =& $this->_getXoopsApi($newparams); + $xoopsapi->_setUser($this->user, $this->isadmin); + $xoopsapi->newPost(); + } + } + } + } + + function editPost() + { + if (!$this->_checkUser($this->params[2], $this->params[3])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + if (!$fields =& $this->_getPostFields($this->params[1])) { + } else { + $missing = array(); + $post = array(); + foreach ($fields as $tag => $detail) { + $data = $this->_getTagCdata($this->params[4], $tag, true); + if (trim($data) == ''){ + if ($detail['required']) { + $missing[] = $tag; + } + } else { + $post[$tag] = $data; + } + } + if (count($missing) > 0) { + $msg = ''; + foreach ($missing as $m) { + $msg .= '<'.$m.'> '; + } + $this->response->add(new XoopsXmlRpcFault(109, $msg)); + } else { + $newparams = array(); + // XOOPS API ignores App key (index 0 of params) + $newparams[0] = $this->params[1]; + $newparams[1] = $this->params[2]; + $newparams[2] = $this->params[3]; + foreach ($post as $key => $value) { + $newparams[3][$key] =& $value; + unset($value); + } + $newparams[3]['xoops_text'] =& $this->params[4]; + $newparams[4] = $this->params[5]; + $xoopsapi =& $this->_getXoopsApi($newparams); + $xoopsapi->_setUser($this->user, $this->isadmin); + $xoopsapi->editPost(); + } + } + } + } + + function deletePost() + { + if (!$this->_checkUser($this->params[2], $this->params[3])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + // XOOPS API ignores App key (index 0 of params) + array_shift($this->params); + $xoopsapi =& $this->_getXoopsApi($this->params); + $xoopsapi->_setUser($this->user, $this->isadmin); + $xoopsapi->deletePost(); + } + } + + function getPost() + { + if (!$this->_checkUser($this->params[2], $this->params[3])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + // XOOPS API ignores App key (index 0 of params) + array_shift($this->params); + $xoopsapi =& $this->_getXoopsApi($this->params); + $xoopsapi->_setUser($this->user, $this->isadmin); + $ret =& $xoopsapi->getPost(false); + if (is_array($ret)) { + $struct = new XoopsXmlRpcStruct(); + $content = ''; + foreach ($ret as $key => $value) { + $maptag = $this->_getXoopsTagMap($key); + switch($maptag) { + case 'userid': + $struct->add('userid', new XoopsXmlRpcString($value)); + break; + case 'dateCreated': + $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); + break; + case 'postid': + $struct->add('postid', new XoopsXmlRpcString($value)); + break; + default : + $content .= '<'.$key.'>'.trim($value).''; + break; + } + } + $struct->add('content', new XoopsXmlRpcString($content)); + $this->response->add($struct); + } else { + $this->response->add(new XoopsXmlRpcFault(106)); + } + } + } + + function getRecentPosts() + { + if (!$this->_checkUser($this->params[2], $this->params[3])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + // XOOPS API ignores App key (index 0 of params) + array_shift($this->params); + $xoopsapi =& $this->_getXoopsApi($this->params); + $xoopsapi->_setUser($this->user, $this->isadmin); + $ret =& $xoopsapi->getRecentPosts(false); + if (is_array($ret)) { + $arr = new XoopsXmlRpcArray(); + $count = count($ret); + if ($count == 0) { + $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); + } else { + for ($i = 0; $i < $count; $i++) { + $struct = new XoopsXmlRpcStruct(); + $content = ''; + foreach($ret[$i] as $key => $value) { + $maptag = $this->_getXoopsTagMap($key); + switch($maptag) { + case 'userid': + $struct->add('userid', new XoopsXmlRpcString($value)); + break; + case 'dateCreated': + $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); + break; + case 'postid': + $struct->add('postid', new XoopsXmlRpcString($value)); + break; + default : + $content .= '<'.$key.'>'.trim($value).''; + break; + } + } + $struct->add('content', new XoopsXmlRpcString($content)); + $arr->add($struct); + unset($struct); + } + $this->response->add($arr); + } + } else { + $this->response->add(new XoopsXmlRpcFault(106)); + } + } + } + + function getUsersBlogs() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + $arr = new XoopsXmlRpcArray(); + $struct = new XoopsXmlRpcStruct(); + $struct->add('url', new XoopsXmlRpcString(ICMS_URL.'/modules/'.$this->module->getVar('dirname').'/')); + $struct->add('blogid', new XoopsXmlRpcString($this->module->getVar('mid'))); + $struct->add('blogName', new XoopsXmlRpcString('XOOPS Blog')); + $arr->add($struct); + $this->response->add($arr); + } + } + + function getUserInfo() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + $struct = new XoopsXmlRpcStruct(); + $struct->add('nickname', new XoopsXmlRpcString($this->user->getVar('uname'))); + $struct->add('userid', new XoopsXmlRpcString($this->user->getVar('uid'))); + $struct->add('url', new XoopsXmlRpcString($this->user->getVar('url'))); + $struct->add('email', new XoopsXmlRpcString($this->user->getVar('email'))); + $struct->add('lastname', new XoopsXmlRpcString('')); + $struct->add('firstname', new XoopsXmlRpcString($this->user->getVar('name'))); + $this->response->add($struct); + } + } + + function getTemplate() + { + if (!$this->_checkUser($this->params[2], $this->params[3])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + switch ($this->params[5]) { + case 'main': + $this->response->add(new XoopsXmlRpcFault(107)); + break; + case 'archiveIndex': + $this->response->add(new XoopsXmlRpcFault(107)); + break; + default: + $this->response->add(new XoopsXmlRpcFault(107)); + break; + } + } + } + + function setTemplate() + { + if (!$this->_checkUser($this->params[2], $this->params[3])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + $this->response->add(new XoopsXmlRpcFault(107)); + } + } +} +?> \ No newline at end of file diff --git a/htdocs/libraries/xml/rpc/metaweblogapi.php b/htdocs/libraries/xml/rpc/metaweblogapi.php index f0f16f17ca57..c037558d0a73 100644 --- a/htdocs/libraries/xml/rpc/metaweblogapi.php +++ b/htdocs/libraries/xml/rpc/metaweblogapi.php @@ -1,290 +1,290 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * XML Parser Meta Weblog Api - * - * @copyright http://www.xoops.org/ The XOOPS Project - * @copyright XOOPS_copyrights.txt - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package XML - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: metaweblogapi.php 19118 2010-03-27 17:46:23Z skenow $ - */ - -if (!defined('ICMS_ROOT_PATH')) { - die("ImpressCMS root path not defined"); -} -require_once ICMS_LIBRARIES_PATH . '/xml/rpc/xmlrpcapi.php'; - -class MetaWeblogApi extends XoopsXmlRpcApi -{ - function MetaWeblogApi(&$params, &$response, &$module) - { - $this->XoopsXmlRpcApi($params, $response, $module); - $this->_setXoopsTagMap('storyid', 'postid'); - $this->_setXoopsTagMap('published', 'dateCreated'); - $this->_setXoopsTagMap('uid', 'userid'); - //$this->_setXoopsTagMap('hometext', 'description'); - } - - function newPost() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - if (!$fields =& $this->_getPostFields(null, $this->params[0])) { - $this->response->add(new XoopsXmlRpcFault(106)); - } else { - $missing = array(); - $post = array(); - foreach ($fields as $tag => $detail) { - $maptag = $this->_getXoopsTagMap($tag); - if (!isset($this->params[3][$maptag])) { - $data = $this->_getTagCdata($this->params[3]['description'], $maptag, true); - if (trim($data) == ''){ - if ($detail['required']) { - $missing[] = $maptag; - } - } else { - $post[$tag] = $data; - } - } else { - $post[$tag] = $this->params[3][$maptag]; - } - } - if (count($missing) > 0) { - $msg = ''; - foreach ($missing as $m) { - $msg .= '<'.$m.'> ';echo $m; - } - $this->response->add(new XoopsXmlRpcFault(109, $msg)); - } else { - $newparams = array(); - $newparams[0] = $this->params[0]; - $newparams[1] = $this->params[1]; - $newparams[2] = $this->params[2]; - foreach ($post as $key => $value) { - $newparams[3][$key] =& $value; - unset($value); - } - $newparams[3]['xoops_text'] = $this->params[3]['description']; - if (isset($this->params[3]['categories']) && is_array($this->params[3]['categories'])) { - foreach ($this->params[3]['categories'] as $k => $v) { - $newparams[3]['categories'][$k] = $v; - } - } - $newparams[4] = $this->params[4]; - $xoopsapi =& $this->_getXoopsApi($newparams); - $xoopsapi->_setUser($this->user, $this->isadmin); - $xoopsapi->newPost(); - } - } - } - } - - function editPost() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - if (!$fields =& $this->_getPostFields($this->params[0])) { - } else { - $missing = array(); - $post = array(); - foreach ($fields as $tag => $detail) { - $maptag = $this->_getXoopsTagMap($tag); - if (!isset($this->params[3][$maptag])) { - $data = $this->_getTagCdata($this->params[3]['description'], $maptag, true); - if (trim($data) == ''){ - if ($detail['required']) { - $missing[] = $tag; - } - } else { - $post[$tag] = $data; - } - } else { - $post[$tag] =& $this->params[3][$maptag]; - } - } - if (count($missing) > 0) { - $msg = ''; - foreach ($missing as $m) { - $msg .= '<'.$m.'> '; - } - $this->response->add(new XoopsXmlRpcFault(109, $msg)); - } else { - $newparams = array(); - $newparams[0] = $this->params[0]; - $newparams[1] = $this->params[1]; - $newparams[2] = $this->params[2]; - foreach ($post as $key => $value) { - $newparams[3][$key] =& $value; - unset($value); - } - if (isset($this->params[3]['categories']) && is_array($this->params[3]['categories'])) { - foreach ($this->params[3]['categories'] as $k => $v) { - $newparams[3]['categories'][$k] = $v; - } - } - $newparams[3]['xoops_text'] = $this->params[3]['description']; - $newparams[4] = $this->params[4]; - $xoopsapi =& $this->_getXoopsApi($newparams); - $xoopsapi->_setUser($this->user, $this->isadmin); - $xoopsapi->editPost(); - } - } - } - } - - function getPost() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - $xoopsapi =& $this->_getXoopsApi($this->params); - $xoopsapi->_setUser($this->user, $this->isadmin); - $ret =& $xoopsapi->getPost(false); - if (is_array($ret)) { - $struct = new XoopsXmlRpcStruct(); - $content = ''; - foreach ($ret as $key => $value) { - $maptag = $this->_getXoopsTagMap($key); - switch($maptag) { - case 'userid': - $struct->add('userid', new XoopsXmlRpcString($value)); - break; - case 'dateCreated': - $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); - break; - case 'postid': - $struct->add('postid', new XoopsXmlRpcString($value)); - $struct->add('link', new XoopsXmlRpcString(ICMS_URL.'/modules/xoopssections/item.php?item='.$value)); - $struct->add('permaLink', new XoopsXmlRpcString(ICMS_URL.'/modules/xoopssections/item.php?item='.$value)); - break; - case 'title': - $struct->add('title', new XoopsXmlRpcString($value)); - break; - default : - $content .= '<'.$key.'>'.trim($value).''; - break; - } - } - $struct->add('description', new XoopsXmlRpcString($content)); - $this->response->add($struct); - } else { - $this->response->add(new XoopsXmlRpcFault(106)); - } - } - } - - function getRecentPosts() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - $xoopsapi =& $this->_getXoopsApi($this->params); - $xoopsapi->_setUser($this->user, $this->isadmin); - $ret =& $xoopsapi->getRecentPosts(false); - if (is_array($ret)) { - $arr = new XoopsXmlRpcArray(); - $count = count($ret); - if ($count == 0) { - $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); - } else { - for ($i = 0; $i < $count; $i++) { - $struct = new XoopsXmlRpcStruct(); - $content = ''; - foreach($ret[$i] as $key => $value) { - $maptag = $this->_getXoopsTagMap($key); - switch($maptag) { - case 'userid': - $struct->add('userid', new XoopsXmlRpcString($value)); - break; - case 'dateCreated': - $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); - break; - case 'postid': - $struct->add('postid', new XoopsXmlRpcString($value)); - $struct->add('link', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); - $struct->add('permaLink', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); - break; - case 'title': - $struct->add('title', new XoopsXmlRpcString($value)); - break; - default : - $content .= '<'.$key.'>'.trim($value).''; - break; - } - } - $struct->add('description', new XoopsXmlRpcString($content)); - $arr->add($struct); - unset($struct); - } - $this->response->add($arr); - } - } else { - $this->response->add(new XoopsXmlRpcFault(106)); - } - } - } - - function getCategories() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - $xoopsapi =& $this->_getXoopsApi($this->params); - $xoopsapi->_setUser($this->user, $this->isadmin); - $ret =& $xoopsapi->getCategories(false); - if (is_array($ret)) { - $arr = new XoopsXmlRpcArray(); - foreach ($ret as $id => $detail) { - $struct = new XoopsXmlRpcStruct(); - $struct->add('description', new XoopsXmlRpcString($detail)); - $struct->add('htmlUrl', new XoopsXmlRpcString(ICMS_URL.'/modules/news/index.php?storytopic='.$id)); - $struct->add('rssUrl', new XoopsXmlRpcString('')); - $catstruct = new XoopsXmlRpcStruct(); - $catstruct->add($detail['title'], $struct); - $arr->add($catstruct); - unset($struct); - unset($catstruct); - } - $this->response->add($arr); - } else { - $this->response->add(new XoopsXmlRpcFault(106)); - } - } - } -} -?> + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * XML Parser Meta Weblog Api + * + * @copyright http://www.xoops.org/ The XOOPS Project + * @copyright XOOPS_copyrights.txt + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package XML + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: metaweblogapi.php 19118 2010-03-27 17:46:23Z skenow $ + */ + +if (!defined('ICMS_ROOT_PATH')) { + die("ImpressCMS root path not defined"); +} +require_once ICMS_LIBRARIES_PATH . '/xml/rpc/xmlrpcapi.php'; + +class MetaWeblogApi extends XoopsXmlRpcApi +{ + function MetaWeblogApi(&$params, &$response, &$module) + { + $this->XoopsXmlRpcApi($params, $response, $module); + $this->_setXoopsTagMap('storyid', 'postid'); + $this->_setXoopsTagMap('published', 'dateCreated'); + $this->_setXoopsTagMap('uid', 'userid'); + //$this->_setXoopsTagMap('hometext', 'description'); + } + + function newPost() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + if (!$fields =& $this->_getPostFields(null, $this->params[0])) { + $this->response->add(new XoopsXmlRpcFault(106)); + } else { + $missing = array(); + $post = array(); + foreach ($fields as $tag => $detail) { + $maptag = $this->_getXoopsTagMap($tag); + if (!isset($this->params[3][$maptag])) { + $data = $this->_getTagCdata($this->params[3]['description'], $maptag, true); + if (trim($data) == ''){ + if ($detail['required']) { + $missing[] = $maptag; + } + } else { + $post[$tag] = $data; + } + } else { + $post[$tag] = $this->params[3][$maptag]; + } + } + if (count($missing) > 0) { + $msg = ''; + foreach ($missing as $m) { + $msg .= '<'.$m.'> ';echo $m; + } + $this->response->add(new XoopsXmlRpcFault(109, $msg)); + } else { + $newparams = array(); + $newparams[0] = $this->params[0]; + $newparams[1] = $this->params[1]; + $newparams[2] = $this->params[2]; + foreach ($post as $key => $value) { + $newparams[3][$key] =& $value; + unset($value); + } + $newparams[3]['xoops_text'] = $this->params[3]['description']; + if (isset($this->params[3]['categories']) && is_array($this->params[3]['categories'])) { + foreach ($this->params[3]['categories'] as $k => $v) { + $newparams[3]['categories'][$k] = $v; + } + } + $newparams[4] = $this->params[4]; + $xoopsapi =& $this->_getXoopsApi($newparams); + $xoopsapi->_setUser($this->user, $this->isadmin); + $xoopsapi->newPost(); + } + } + } + } + + function editPost() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + if (!$fields =& $this->_getPostFields($this->params[0])) { + } else { + $missing = array(); + $post = array(); + foreach ($fields as $tag => $detail) { + $maptag = $this->_getXoopsTagMap($tag); + if (!isset($this->params[3][$maptag])) { + $data = $this->_getTagCdata($this->params[3]['description'], $maptag, true); + if (trim($data) == ''){ + if ($detail['required']) { + $missing[] = $tag; + } + } else { + $post[$tag] = $data; + } + } else { + $post[$tag] =& $this->params[3][$maptag]; + } + } + if (count($missing) > 0) { + $msg = ''; + foreach ($missing as $m) { + $msg .= '<'.$m.'> '; + } + $this->response->add(new XoopsXmlRpcFault(109, $msg)); + } else { + $newparams = array(); + $newparams[0] = $this->params[0]; + $newparams[1] = $this->params[1]; + $newparams[2] = $this->params[2]; + foreach ($post as $key => $value) { + $newparams[3][$key] =& $value; + unset($value); + } + if (isset($this->params[3]['categories']) && is_array($this->params[3]['categories'])) { + foreach ($this->params[3]['categories'] as $k => $v) { + $newparams[3]['categories'][$k] = $v; + } + } + $newparams[3]['xoops_text'] = $this->params[3]['description']; + $newparams[4] = $this->params[4]; + $xoopsapi =& $this->_getXoopsApi($newparams); + $xoopsapi->_setUser($this->user, $this->isadmin); + $xoopsapi->editPost(); + } + } + } + } + + function getPost() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + $xoopsapi =& $this->_getXoopsApi($this->params); + $xoopsapi->_setUser($this->user, $this->isadmin); + $ret =& $xoopsapi->getPost(false); + if (is_array($ret)) { + $struct = new XoopsXmlRpcStruct(); + $content = ''; + foreach ($ret as $key => $value) { + $maptag = $this->_getXoopsTagMap($key); + switch($maptag) { + case 'userid': + $struct->add('userid', new XoopsXmlRpcString($value)); + break; + case 'dateCreated': + $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); + break; + case 'postid': + $struct->add('postid', new XoopsXmlRpcString($value)); + $struct->add('link', new XoopsXmlRpcString(ICMS_URL.'/modules/xoopssections/item.php?item='.$value)); + $struct->add('permaLink', new XoopsXmlRpcString(ICMS_URL.'/modules/xoopssections/item.php?item='.$value)); + break; + case 'title': + $struct->add('title', new XoopsXmlRpcString($value)); + break; + default : + $content .= '<'.$key.'>'.trim($value).''; + break; + } + } + $struct->add('description', new XoopsXmlRpcString($content)); + $this->response->add($struct); + } else { + $this->response->add(new XoopsXmlRpcFault(106)); + } + } + } + + function getRecentPosts() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + $xoopsapi =& $this->_getXoopsApi($this->params); + $xoopsapi->_setUser($this->user, $this->isadmin); + $ret =& $xoopsapi->getRecentPosts(false); + if (is_array($ret)) { + $arr = new XoopsXmlRpcArray(); + $count = count($ret); + if ($count == 0) { + $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); + } else { + for ($i = 0; $i < $count; $i++) { + $struct = new XoopsXmlRpcStruct(); + $content = ''; + foreach($ret[$i] as $key => $value) { + $maptag = $this->_getXoopsTagMap($key); + switch($maptag) { + case 'userid': + $struct->add('userid', new XoopsXmlRpcString($value)); + break; + case 'dateCreated': + $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); + break; + case 'postid': + $struct->add('postid', new XoopsXmlRpcString($value)); + $struct->add('link', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); + $struct->add('permaLink', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); + break; + case 'title': + $struct->add('title', new XoopsXmlRpcString($value)); + break; + default : + $content .= '<'.$key.'>'.trim($value).''; + break; + } + } + $struct->add('description', new XoopsXmlRpcString($content)); + $arr->add($struct); + unset($struct); + } + $this->response->add($arr); + } + } else { + $this->response->add(new XoopsXmlRpcFault(106)); + } + } + } + + function getCategories() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + $xoopsapi =& $this->_getXoopsApi($this->params); + $xoopsapi->_setUser($this->user, $this->isadmin); + $ret =& $xoopsapi->getCategories(false); + if (is_array($ret)) { + $arr = new XoopsXmlRpcArray(); + foreach ($ret as $id => $detail) { + $struct = new XoopsXmlRpcStruct(); + $struct->add('description', new XoopsXmlRpcString($detail)); + $struct->add('htmlUrl', new XoopsXmlRpcString(ICMS_URL.'/modules/news/index.php?storytopic='.$id)); + $struct->add('rssUrl', new XoopsXmlRpcString('')); + $catstruct = new XoopsXmlRpcStruct(); + $catstruct->add($detail['title'], $struct); + $arr->add($catstruct); + unset($struct); + unset($catstruct); + } + $this->response->add($arr); + } else { + $this->response->add(new XoopsXmlRpcFault(106)); + } + } + } +} +?> diff --git a/htdocs/libraries/xml/rpc/movabletypeapi.php b/htdocs/libraries/xml/rpc/movabletypeapi.php index 3213e564644f..3c0834c4f184 100644 --- a/htdocs/libraries/xml/rpc/movabletypeapi.php +++ b/htdocs/libraries/xml/rpc/movabletypeapi.php @@ -1,95 +1,95 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * XML Parser Moveable Type Api - * - * @copyright http://www.xoops.org/ The XOOPS Project - * @copyright XOOPS_copyrights.txt - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package XML - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: movabletypeapi.php 19118 2010-03-27 17:46:23Z skenow $ - */ - -if (!defined('ICMS_ROOT_PATH')) { - die("ImpressCMS root path not defined"); -} -require_once ICMS_LIBRARIES_PATH . '/xml/rpc/xmlrpcapi.php'; - -class MovableTypeApi extends XoopsXmlRpcApi -{ - function MovableTypeApi(&$params, &$response, &$module) - { - $this->XoopsXmlRpcApi($params, $response, $module); - } - - function getCategoryList() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - $xoopsapi =& $this->_getXoopsApi($this->params); - $xoopsapi->_setUser($this->user, $this->isadmin); - $ret =& $xoopsapi->getCategories(false); - if (is_array($ret)) { - $arr = new XoopsXmlRpcArray(); - foreach ($ret as $id => $name) { - $struct = new XoopsXmlRpcStruct(); - $struct->add('categoryId', new XoopsXmlRpcString($id)); - $struct->add('categoryName', new XoopsXmlRpcString($name['title'])); - $arr->add($struct); - unset($struct); - } - $this->response->add($arr); - } else { - $this->response->add(new XoopsXmlRpcFault(106)); - } - } - } - - function getPostCategories() - { - $this->response->add(new XoopsXmlRpcFault(107)); - } - - function setPostCategories() - { - $this->response->add(new XoopsXmlRpcFault(107)); - } - - function supportedMethods() - { - $this->response->add(new XoopsXmlRpcFault(107)); - } -} -?> + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * XML Parser Moveable Type Api + * + * @copyright http://www.xoops.org/ The XOOPS Project + * @copyright XOOPS_copyrights.txt + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package XML + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: movabletypeapi.php 19118 2010-03-27 17:46:23Z skenow $ + */ + +if (!defined('ICMS_ROOT_PATH')) { + die("ImpressCMS root path not defined"); +} +require_once ICMS_LIBRARIES_PATH . '/xml/rpc/xmlrpcapi.php'; + +class MovableTypeApi extends XoopsXmlRpcApi +{ + function MovableTypeApi(&$params, &$response, &$module) + { + $this->XoopsXmlRpcApi($params, $response, $module); + } + + function getCategoryList() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + $xoopsapi =& $this->_getXoopsApi($this->params); + $xoopsapi->_setUser($this->user, $this->isadmin); + $ret =& $xoopsapi->getCategories(false); + if (is_array($ret)) { + $arr = new XoopsXmlRpcArray(); + foreach ($ret as $id => $name) { + $struct = new XoopsXmlRpcStruct(); + $struct->add('categoryId', new XoopsXmlRpcString($id)); + $struct->add('categoryName', new XoopsXmlRpcString($name['title'])); + $arr->add($struct); + unset($struct); + } + $this->response->add($arr); + } else { + $this->response->add(new XoopsXmlRpcFault(106)); + } + } + } + + function getPostCategories() + { + $this->response->add(new XoopsXmlRpcFault(107)); + } + + function setPostCategories() + { + $this->response->add(new XoopsXmlRpcFault(107)); + } + + function supportedMethods() + { + $this->response->add(new XoopsXmlRpcFault(107)); + } +} +?> diff --git a/htdocs/libraries/xml/rpc/xmlrpcapi.php b/htdocs/libraries/xml/rpc/xmlrpcapi.php index b99868dbbdd9..51e6cf7d651c 100644 --- a/htdocs/libraries/xml/rpc/xmlrpcapi.php +++ b/htdocs/libraries/xml/rpc/xmlrpcapi.php @@ -1,176 +1,176 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * XML Parser RPC Api - * - * @copyright http://www.xoops.org/ The XOOPS Project - * @copyright XOOPS_copyrights.txt - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package XML - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: xmlrpcapi.php 19612 2010-06-24 23:28:29Z malanciault $ - */ - -class XoopsXmlRpcApi -{ - - // reference to method parameters - var $params; - - // reference to xmlrpc document class object - var $response; - - // reference to module class object - var $module; - - // map between xoops tags and blogger specific tags - var $xoopsTagMap = array(); - - // user class object - var $user; - - var $isadmin = false; - - function XoopsXmlRpcApi(&$params, &$response, &$module) - { - $this->params =& $params; - $this->response =& $response; - $this->module =& $module; - } - - function _setUser(&$user, $isadmin = false) - { - if (is_object($user)) { - $this->user =& $user; - $this->isadmin = $isadmin; - } - } - - function _checkUser($username, $password) - { - if (isset($this->user)) { - return true; - } - $member_handler = icms::handler('icms_member'); - $this->user =& $member_handler->loginUser(addslashes($username), addslashes($password)); - if (!is_object($this->user)) { - unset($this->user); - return false; - } - $moduleperm_handler = icms::handler('icms_member_groupperm'); - if (!$moduleperm_handler->checkRight('module_read', $this->module->getVar('mid'), $this->user->getGroups())) { - unset($this->user); - return false; - } - return true; - } - - function _checkAdmin() - { - if ($this->isadmin) { - return true; - } - if (!isset($this->user)) { - return false; - } - if (!$this->user->isAdmin($this->module->getVar('mid'))) { - return false; - } - $this->isadmin = true; - return true; - } - - function &_getPostFields($post_id = null, $blog_id = null) - { - $ret = array(); - $ret['title'] = array('required' => true, 'form_type' => 'textbox', 'value_type' => 'text'); - $ret['hometext'] = array('required' => false, 'form_type' => 'textarea', 'data_type' => 'textarea'); - $ret['moretext'] = array('required' => false, 'form_type' => 'textarea', 'data_type' => 'textarea'); - $ret['categories'] = array('required' => false, 'form_type' => 'select_multi', 'data_type' => 'array'); - /* - if (!isset($blog_id)) { - if (!isset($post_id)) { - return false; - } - $itemman =& $this->mf->get(MANAGER_ITEM); - $item =& $itemman->get($post_id); - $blog_id = $item->getVar('sect_id'); - } - $sectman =& $this->mf->get(MANAGER_SECTION); - $this->section =& $sectman->get($blog_id); - $ret =& $this->section->getVar('sect_fields'); - */ - return $ret; - } - - function _setXoopsTagMap($xoopstag, $blogtag) - { - if (trim($blogtag) != '') { - $this->xoopsTagMap[$xoopstag] = $blogtag; - } - } - - function _getXoopsTagMap($xoopstag) - { - if (isset($this->xoopsTagMap[$xoopstag])) { - return $this->xoopsTagMap[$xoopstag]; - } - return $xoopstag; - } - - function _getTagCdata(&$text, $tag, $remove = true) - { - $ret = ''; - $match = array(); - if (preg_match("/\<".$tag."\>(.*)\<\/".$tag."\>/is", $text, $match)) { - if ($remove) { - $text = str_replace($match[0], '', $text); - } - $ret = $match[1]; - } - return $ret; - } - - // kind of dirty method to load XOOPS API and create a new object thereof - // returns itself if the calling object is XOOPS API - function &_getXoopsApi(&$params) - { - if (strtolower(get_class($this)) != 'xoopsapi') { - require_once ICMS_ROOT_PATH.'/class/xml/rpc/xoopsapi.php' ; - return new XoopsApi($params, $this->response, $this->module); - } else { - return $this; - } - } -} -?> + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * XML Parser RPC Api + * + * @copyright http://www.xoops.org/ The XOOPS Project + * @copyright XOOPS_copyrights.txt + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package XML + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: xmlrpcapi.php 19612 2010-06-24 23:28:29Z malanciault $ + */ + +class XoopsXmlRpcApi +{ + + // reference to method parameters + var $params; + + // reference to xmlrpc document class object + var $response; + + // reference to module class object + var $module; + + // map between xoops tags and blogger specific tags + var $xoopsTagMap = array(); + + // user class object + var $user; + + var $isadmin = false; + + function XoopsXmlRpcApi(&$params, &$response, &$module) + { + $this->params =& $params; + $this->response =& $response; + $this->module =& $module; + } + + function _setUser(&$user, $isadmin = false) + { + if (is_object($user)) { + $this->user =& $user; + $this->isadmin = $isadmin; + } + } + + function _checkUser($username, $password) + { + if (isset($this->user)) { + return true; + } + $member_handler = icms::handler('icms_member'); + $this->user =& $member_handler->loginUser(addslashes($username), addslashes($password)); + if (!is_object($this->user)) { + unset($this->user); + return false; + } + $moduleperm_handler = icms::handler('icms_member_groupperm'); + if (!$moduleperm_handler->checkRight('module_read', $this->module->getVar('mid'), $this->user->getGroups())) { + unset($this->user); + return false; + } + return true; + } + + function _checkAdmin() + { + if ($this->isadmin) { + return true; + } + if (!isset($this->user)) { + return false; + } + if (!$this->user->isAdmin($this->module->getVar('mid'))) { + return false; + } + $this->isadmin = true; + return true; + } + + function &_getPostFields($post_id = null, $blog_id = null) + { + $ret = array(); + $ret['title'] = array('required' => true, 'form_type' => 'textbox', 'value_type' => 'text'); + $ret['hometext'] = array('required' => false, 'form_type' => 'textarea', 'data_type' => 'textarea'); + $ret['moretext'] = array('required' => false, 'form_type' => 'textarea', 'data_type' => 'textarea'); + $ret['categories'] = array('required' => false, 'form_type' => 'select_multi', 'data_type' => 'array'); + /* + if (!isset($blog_id)) { + if (!isset($post_id)) { + return false; + } + $itemman =& $this->mf->get(MANAGER_ITEM); + $item =& $itemman->get($post_id); + $blog_id = $item->getVar('sect_id'); + } + $sectman =& $this->mf->get(MANAGER_SECTION); + $this->section =& $sectman->get($blog_id); + $ret =& $this->section->getVar('sect_fields'); + */ + return $ret; + } + + function _setXoopsTagMap($xoopstag, $blogtag) + { + if (trim($blogtag) != '') { + $this->xoopsTagMap[$xoopstag] = $blogtag; + } + } + + function _getXoopsTagMap($xoopstag) + { + if (isset($this->xoopsTagMap[$xoopstag])) { + return $this->xoopsTagMap[$xoopstag]; + } + return $xoopstag; + } + + function _getTagCdata(&$text, $tag, $remove = true) + { + $ret = ''; + $match = array(); + if (preg_match("/\<".$tag."\>(.*)\<\/".$tag."\>/is", $text, $match)) { + if ($remove) { + $text = str_replace($match[0], '', $text); + } + $ret = $match[1]; + } + return $ret; + } + + // kind of dirty method to load XOOPS API and create a new object thereof + // returns itself if the calling object is XOOPS API + function &_getXoopsApi(&$params) + { + if (strtolower(get_class($this)) != 'xoopsapi') { + require_once ICMS_ROOT_PATH.'/class/xml/rpc/xoopsapi.php' ; + return new XoopsApi($params, $this->response, $this->module); + } else { + return $this; + } + } +} +?> diff --git a/htdocs/libraries/xml/rpc/xmlrpcparser.php b/htdocs/libraries/xml/rpc/xmlrpcparser.php index 53c7657b312b..37ea32bf7808 100644 --- a/htdocs/libraries/xml/rpc/xmlrpcparser.php +++ b/htdocs/libraries/xml/rpc/xmlrpcparser.php @@ -1,981 +1,981 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * XML Parser Sax Parser - * - * Longer description about this page - * - * @copyright http://www.xoops.org/ The XOOPS Project - * @copyright XOOPS_copyrights.txt - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package XML - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: xmlrpcparser.php 19118 2010-03-27 17:46:23Z skenow $ - */ - -if (!defined('ICMS_ROOT_PATH')) { - die("ImpressCMS root path not defined"); -} -require_once ICMS_LIBRARIES_PATH . '/xml/saxparser.php'; -require_once ICMS_LIBRARIES_PATH . '/xml/xmltaghandler.php'; - -/** - * Class RSS Parser - * - * This class offers methods to parse RSS Files - * - * @link http://www.xoops.org/ Latest release of this class - * @package XOOPS - * @copyright Copyright (c) 2001 xoops.org. All rights reserved. - * @author Kazumi Ono - * @version 1.6 ($Date: 2007-11-01 12:57:08 -0400 (jeu., 01 nov. 2007) $) $Revision: 1136 $ - * @access public - */ - -class XoopsXmlRpcParser extends SaxParser -{ - - /** - * - * - * - * - * @access private - * @var array - */ - var $_param; - - /** - * - * - * - * - * @access private - * @var string - */ - var $_methodName; - - /** - * - * - * - * - * @access private - * @var array - */ - var $_tempName; - - /** - * - * - * - * - * @access private - * @var array - */ - var $_tempValue; - - /** - * - * - * - * - * @access private - * @var array - */ - var $_tempMember; - - /** - * - * - * - * - * @access private - * @var array - */ - var $_tempStruct; - - /** - * - * - * - * - * @access private - * @var array - */ - var $_tempArray; - - /** - * - * - * - * - * @access private - * @var array - */ - var $_workingLevel = array(); - - /** - * Constructor of the class - * - * - * - * - * @access - * @author - * @see - */ - function XoopsXmlRpcParser(&$input) - { - $this->SaxParser($input); - $this->addTagHandler(new RpcMethodNameHandler()); - $this->addTagHandler(new RpcIntHandler()); - $this->addTagHandler(new RpcDoubleHandler()); - $this->addTagHandler(new RpcBooleanHandler()); - $this->addTagHandler(new RpcStringHandler()); - $this->addTagHandler(new RpcDateTimeHandler()); - $this->addTagHandler(new RpcBase64Handler()); - $this->addTagHandler(new RpcNameHandler()); - $this->addTagHandler(new RpcValueHandler()); - $this->addTagHandler(new RpcMemberHandler()); - $this->addTagHandler(new RpcStructHandler()); - $this->addTagHandler(new RpcArrayHandler()); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function setTempName($name) - { - $this->_tempName[$this->getWorkingLevel()] = $name; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getTempName() - { - return $this->_tempName[$this->getWorkingLevel()]; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function setTempValue($value) - { - if (is_array($value)) { - settype($this->_tempValue, 'array'); - foreach ($value as $k => $v) { - $this->_tempValue[$k] = $v; - } - } elseif (is_string($value)) { - if (isset($this->_tempValue)) { - if (is_string($this->_tempValue)) { - $this->_tempValue .= $value; - } - } else { - $this->_tempValue = $value; - } - } else { - $this->_tempValue = $value; - } - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getTempValue() - { - return $this->_tempValue; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function resetTempValue() - { - unset($this->_tempValue); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function setTempMember($name, $value) - { - $this->_tempMember[$this->getWorkingLevel()][$name] = $value; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getTempMember() - { - return $this->_tempMember[$this->getWorkingLevel()]; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function resetTempMember() - { - $this->_tempMember[$this->getCurrentLevel()] = array(); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function setWorkingLevel() - { - array_push($this->_workingLevel, $this->getCurrentLevel()); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getWorkingLevel() - { - return $this->_workingLevel[count($this->_workingLevel) - 1]; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function releaseWorkingLevel() - { - array_pop($this->_workingLevel); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function setTempStruct($member) - { - $key = key($member); - $this->_tempStruct[$this->getWorkingLevel()][$key] = $member[$key]; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getTempStruct() - { - return $this->_tempStruct[$this->getWorkingLevel()]; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function resetTempStruct() - { - $this->_tempStruct[$this->getCurrentLevel()] = array(); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function setTempArray($value) - { - $this->_tempArray[$this->getWorkingLevel()][] = $value; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getTempArray() - { - return $this->_tempArray[$this->getWorkingLevel()]; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function resetTempArray() - { - $this->_tempArray[$this->getCurrentLevel()] = array(); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function setMethodName($methodName) - { - $this->_methodName = $methodName; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getMethodName() - { - return $this->_methodName; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function setParam($value) - { - $this->_param[] = $value; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function &getParam() - { - return $this->_param; - } -} - -class RpcMethodNameHandler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'methodName'; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleCharacterData(&$parser, &$data) - { - $parser->setMethodName($data); - } -} - -class RpcIntHandler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return array('int', 'i4'); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleCharacterData(&$parser, &$data) - { - $parser->setTempValue( (int) ($data)); - } -} - -class RpcDoubleHandler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'double'; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleCharacterData(&$parser, &$data) - { - $data = (float)$data; - $parser->setTempValue($data); - } -} - -class RpcBooleanHandler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'boolean'; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleCharacterData(&$parser, &$data) - { - $data = (boolean)$data; - $parser->setTempValue($data); - } -} - -class RpcStringHandler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'string'; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleCharacterData(&$parser, &$data) - { - $parser->setTempValue(strval($data)); - } -} - -class RpcDateTimeHandler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'dateTime.iso8601'; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleCharacterData(&$parser, &$data) - { - $matches = array(); - if (!preg_match("/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})$/", $data, $matches)) { - $parser->setTempValue(time()); - } else { - $parser->setTempValue(gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1])); - } - } -} - -class RpcBase64Handler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'base64'; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleCharacterData(&$parser, &$data) - { - $parser->setTempValue(base64_decode($data)); - } -} - -class RpcNameHandler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'name'; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'member': - $parser->setTempName($data); - break; - default: - break; - } - } -} - -class RpcValueHandler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'value'; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'member': - $parser->setTempValue($data); - break; - case 'data': - case 'array': - $parser->setTempValue($data); - break; - default: - break; - } - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleBeginElement(&$parser, &$attributes) - { - //$parser->resetTempValue(); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleEndElement(&$parser) - { - switch ($parser->getCurrentTag()) { - case 'member': - $parser->setTempMember($parser->getTempName(), $parser->getTempValue()); - break; - case 'array': - case 'data': - $parser->setTempArray($parser->getTempValue()); - break; - default: - $parser->setParam($parser->getTempValue()); - break; - } - $parser->resetTempValue(); - } -} - -class RpcMemberHandler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'member'; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleBeginElement(&$parser, &$attributes) - { - $parser->setWorkingLevel(); - $parser->resetTempMember(); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleEndElement(&$parser) - { - $member =& $parser->getTempMember(); - $parser->releaseWorkingLevel(); - $parser->setTempStruct($member); - } -} - -class RpcArrayHandler extends XmlTagHandler -{ - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'array'; - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleBeginElement(&$parser, &$attributes) - { - $parser->setWorkingLevel(); - $parser->resetTempArray(); - } - - /** - * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. - * - * @access - * @author - * @param - * @return - * @see - */ - function handleEndElement(&$parser) - { - $parser->setTempValue($parser->getTempArray()); - $parser->releaseWorkingLevel(); - } -} - -class RpcStructHandler extends XmlTagHandler -{ - - /** - * - * - * @access - * @author - * @param - * @return - * @see - */ - function getName() - { - return 'struct'; - } - - /** - * - * - * @access - * @author - * @param - * @return - * @see - */ - function handleBeginElement(&$parser, &$attributes) - { - $parser->setWorkingLevel(); - $parser->resetTempStruct(); - } - - /** - * - * - * @access - * @author - * @param - * @return - * @see - */ - function handleEndElement(&$parser) - { - $parser->setTempValue($parser->getTempStruct()); - $parser->releaseWorkingLevel(); - } -} -?> + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * XML Parser Sax Parser + * + * Longer description about this page + * + * @copyright http://www.xoops.org/ The XOOPS Project + * @copyright XOOPS_copyrights.txt + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package XML + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: xmlrpcparser.php 19118 2010-03-27 17:46:23Z skenow $ + */ + +if (!defined('ICMS_ROOT_PATH')) { + die("ImpressCMS root path not defined"); +} +require_once ICMS_LIBRARIES_PATH . '/xml/saxparser.php'; +require_once ICMS_LIBRARIES_PATH . '/xml/xmltaghandler.php'; + +/** + * Class RSS Parser + * + * This class offers methods to parse RSS Files + * + * @link http://www.xoops.org/ Latest release of this class + * @package XOOPS + * @copyright Copyright (c) 2001 xoops.org. All rights reserved. + * @author Kazumi Ono + * @version 1.6 ($Date: 2007-11-01 12:57:08 -0400 (jeu., 01 nov. 2007) $) $Revision: 1136 $ + * @access public + */ + +class XoopsXmlRpcParser extends SaxParser +{ + + /** + * + * + * + * + * @access private + * @var array + */ + var $_param; + + /** + * + * + * + * + * @access private + * @var string + */ + var $_methodName; + + /** + * + * + * + * + * @access private + * @var array + */ + var $_tempName; + + /** + * + * + * + * + * @access private + * @var array + */ + var $_tempValue; + + /** + * + * + * + * + * @access private + * @var array + */ + var $_tempMember; + + /** + * + * + * + * + * @access private + * @var array + */ + var $_tempStruct; + + /** + * + * + * + * + * @access private + * @var array + */ + var $_tempArray; + + /** + * + * + * + * + * @access private + * @var array + */ + var $_workingLevel = array(); + + /** + * Constructor of the class + * + * + * + * + * @access + * @author + * @see + */ + function XoopsXmlRpcParser(&$input) + { + $this->SaxParser($input); + $this->addTagHandler(new RpcMethodNameHandler()); + $this->addTagHandler(new RpcIntHandler()); + $this->addTagHandler(new RpcDoubleHandler()); + $this->addTagHandler(new RpcBooleanHandler()); + $this->addTagHandler(new RpcStringHandler()); + $this->addTagHandler(new RpcDateTimeHandler()); + $this->addTagHandler(new RpcBase64Handler()); + $this->addTagHandler(new RpcNameHandler()); + $this->addTagHandler(new RpcValueHandler()); + $this->addTagHandler(new RpcMemberHandler()); + $this->addTagHandler(new RpcStructHandler()); + $this->addTagHandler(new RpcArrayHandler()); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function setTempName($name) + { + $this->_tempName[$this->getWorkingLevel()] = $name; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getTempName() + { + return $this->_tempName[$this->getWorkingLevel()]; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function setTempValue($value) + { + if (is_array($value)) { + settype($this->_tempValue, 'array'); + foreach ($value as $k => $v) { + $this->_tempValue[$k] = $v; + } + } elseif (is_string($value)) { + if (isset($this->_tempValue)) { + if (is_string($this->_tempValue)) { + $this->_tempValue .= $value; + } + } else { + $this->_tempValue = $value; + } + } else { + $this->_tempValue = $value; + } + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getTempValue() + { + return $this->_tempValue; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function resetTempValue() + { + unset($this->_tempValue); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function setTempMember($name, $value) + { + $this->_tempMember[$this->getWorkingLevel()][$name] = $value; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getTempMember() + { + return $this->_tempMember[$this->getWorkingLevel()]; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function resetTempMember() + { + $this->_tempMember[$this->getCurrentLevel()] = array(); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function setWorkingLevel() + { + array_push($this->_workingLevel, $this->getCurrentLevel()); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getWorkingLevel() + { + return $this->_workingLevel[count($this->_workingLevel) - 1]; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function releaseWorkingLevel() + { + array_pop($this->_workingLevel); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function setTempStruct($member) + { + $key = key($member); + $this->_tempStruct[$this->getWorkingLevel()][$key] = $member[$key]; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getTempStruct() + { + return $this->_tempStruct[$this->getWorkingLevel()]; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function resetTempStruct() + { + $this->_tempStruct[$this->getCurrentLevel()] = array(); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function setTempArray($value) + { + $this->_tempArray[$this->getWorkingLevel()][] = $value; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getTempArray() + { + return $this->_tempArray[$this->getWorkingLevel()]; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function resetTempArray() + { + $this->_tempArray[$this->getCurrentLevel()] = array(); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function setMethodName($methodName) + { + $this->_methodName = $methodName; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getMethodName() + { + return $this->_methodName; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function setParam($value) + { + $this->_param[] = $value; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function &getParam() + { + return $this->_param; + } +} + +class RpcMethodNameHandler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'methodName'; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleCharacterData(&$parser, &$data) + { + $parser->setMethodName($data); + } +} + +class RpcIntHandler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return array('int', 'i4'); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleCharacterData(&$parser, &$data) + { + $parser->setTempValue( (int) ($data)); + } +} + +class RpcDoubleHandler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'double'; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleCharacterData(&$parser, &$data) + { + $data = (float)$data; + $parser->setTempValue($data); + } +} + +class RpcBooleanHandler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'boolean'; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleCharacterData(&$parser, &$data) + { + $data = (boolean)$data; + $parser->setTempValue($data); + } +} + +class RpcStringHandler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'string'; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleCharacterData(&$parser, &$data) + { + $parser->setTempValue(strval($data)); + } +} + +class RpcDateTimeHandler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'dateTime.iso8601'; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleCharacterData(&$parser, &$data) + { + $matches = array(); + if (!preg_match("/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})$/", $data, $matches)) { + $parser->setTempValue(time()); + } else { + $parser->setTempValue(gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1])); + } + } +} + +class RpcBase64Handler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'base64'; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleCharacterData(&$parser, &$data) + { + $parser->setTempValue(base64_decode($data)); + } +} + +class RpcNameHandler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'name'; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'member': + $parser->setTempName($data); + break; + default: + break; + } + } +} + +class RpcValueHandler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'value'; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'member': + $parser->setTempValue($data); + break; + case 'data': + case 'array': + $parser->setTempValue($data); + break; + default: + break; + } + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleBeginElement(&$parser, &$attributes) + { + //$parser->resetTempValue(); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleEndElement(&$parser) + { + switch ($parser->getCurrentTag()) { + case 'member': + $parser->setTempMember($parser->getTempName(), $parser->getTempValue()); + break; + case 'array': + case 'data': + $parser->setTempArray($parser->getTempValue()); + break; + default: + $parser->setParam($parser->getTempValue()); + break; + } + $parser->resetTempValue(); + } +} + +class RpcMemberHandler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'member'; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleBeginElement(&$parser, &$attributes) + { + $parser->setWorkingLevel(); + $parser->resetTempMember(); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleEndElement(&$parser) + { + $member =& $parser->getTempMember(); + $parser->releaseWorkingLevel(); + $parser->setTempStruct($member); + } +} + +class RpcArrayHandler extends XmlTagHandler +{ + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'array'; + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleBeginElement(&$parser, &$attributes) + { + $parser->setWorkingLevel(); + $parser->resetTempArray(); + } + + /** + * This Method starts the parsing of the specified RDF File. The File can be a local or a remote File. + * + * @access + * @author + * @param + * @return + * @see + */ + function handleEndElement(&$parser) + { + $parser->setTempValue($parser->getTempArray()); + $parser->releaseWorkingLevel(); + } +} + +class RpcStructHandler extends XmlTagHandler +{ + + /** + * + * + * @access + * @author + * @param + * @return + * @see + */ + function getName() + { + return 'struct'; + } + + /** + * + * + * @access + * @author + * @param + * @return + * @see + */ + function handleBeginElement(&$parser, &$attributes) + { + $parser->setWorkingLevel(); + $parser->resetTempStruct(); + } + + /** + * + * + * @access + * @author + * @param + * @return + * @see + */ + function handleEndElement(&$parser) + { + $parser->setTempValue($parser->getTempStruct()); + $parser->releaseWorkingLevel(); + } +} +?> diff --git a/htdocs/libraries/xml/rpc/xmlrpctag.php b/htdocs/libraries/xml/rpc/xmlrpctag.php index a1d594b25104..83d0474aacc3 100644 --- a/htdocs/libraries/xml/rpc/xmlrpctag.php +++ b/htdocs/libraries/xml/rpc/xmlrpctag.php @@ -1,338 +1,338 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * XML Parser RPC document - * - * @copyright http://www.xoops.org/ The XOOPS Project - * @copyright XOOPS_copyrights.txt - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package XML - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: xmlrpctag.php 19118 2010-03-27 17:46:23Z skenow $ - */ - -class XoopsXmlRpcDocument -{ - - var $_tags = array(); - - function XoopsXmlRpcDocument() - { - - } - - function add(&$tagobj) - { - $this->_tags[] =& $tagobj; - } - - function render() - { - } - -} - -class XoopsXmlRpcResponse extends XoopsXmlRpcDocument -{ - function render() - { - $count = count($this->_tags); - $payload = ''; - for ($i = 0; $i < $count; $i++) { - if (!$this->_tags[$i]->isFault()) { - $payload .= $this->_tags[$i]->render(); - } else { - return ''.$this->_tags[$i]->render().''; - } - } - return ''.$payload.''; - } -} - -class XoopsXmlRpcRequest extends XoopsXmlRpcDocument -{ - - var $methodName; - - function XoopsXmlRpcRequest($methodName) - { - $this->methodName = trim($methodName); - } - - function render() - { - $count = count($this->_tags); - $payload = ''; - for ($i = 0; $i < $count; $i++) { - $payload .= ''.$this->_tags[$i]->render().''; - } - return ''.$this->methodName.''.$payload.''; - } -} - -class XoopsXmlRpcTag -{ - - var $_fault = false; - - function XoopsXmlRpcTag() - { - - } - - function &encode(&$text) - { - $text = preg_replace(array("/\&([a-z\d\#]+)\;/i", "/\&/", "/\#\|\|([a-z\d\#]+)\|\|\#/i"), array("#||\\1||#", "&", "&\\1;"), str_replace(array("<", ">"), array("<", ">"), $text)); - return $text; - } - - function setFault($fault = true){ - $this->_fault = ( (int) ($fault) > 0) ? true : false; - } - - function isFault() - { - return $this->_fault; - } - - function render() - { - } -} - -class XoopsXmlRpcFault extends XoopsXmlRpcTag -{ - - var $_code; - var $_extra; - - function XoopsXmlRpcFault($code, $extra = null) - { - $this->setFault(true); - $this->_code = (int) ($code); - $this->_extra = isset($extra) ? trim($extra) : ''; - } - - function render() - { - switch ($this->_code) { - case 101: - $string = 'Invalid server URI'; - break; - case 102: - $string = 'Parser parse error'; - break; - case 103: - $string = 'Module not found'; - break; - case 104: - $string = 'User authentication failed'; - break; - case 105: - $string = 'Module API not found'; - break; - case 106: - $string = 'Method response error'; - break; - case 107: - $string = 'Method not supported'; - break; - case 108: - $string = 'Invalid parameter'; - break; - case 109: - $string = 'Missing parameters'; - break; - case 110: - $string = 'Selected blog application does not exist'; - break; - case 111: - $string = 'Method permission denied'; - break; - default: - $string = 'Method response error'; - break; - } - $string .= "\n".$this->_extra; - return 'faultCode'.$this->_code.'faultString'.$this->encode($string).''; - } -} - -class XoopsXmlRpcInt extends XoopsXmlRpcTag -{ - - var $_value; - - function XoopsXmlRpcInt($value) - { - $this->_value = (int) ($value); - } - - function render() - { - return ''.$this->_value.''; - } -} - -class XoopsXmlRpcDouble extends XoopsXmlRpcTag -{ - - var $_value; - - function XoopsXmlRpcDouble($value) - { - $this->_value = (float)$value; - } - - function render() - { - return ''.$this->_value.''; - } -} - -class XoopsXmlRpcBoolean extends XoopsXmlRpcTag -{ - - var $_value; - - function XoopsXmlRpcBoolean($value) - { - $this->_value = (!empty($value) && $value != false) ? 1 : 0; - } - - function render() - { - return ''.$this->_value.''; - } -} - -class XoopsXmlRpcString extends XoopsXmlRpcTag -{ - - var $_value; - - function XoopsXmlRpcString($value) - { - $this->_value = strval($value); - } - - function render() - { - return ''.$this->encode($this->_value).''; - } -} - -class XoopsXmlRpcDatetime extends XoopsXmlRpcTag -{ - - var $_value; - - function XoopsXmlRpcDatetime($value) - { - if (!is_numeric($value)) { - $this->_value = strtotime($value); - } else { - $this->_value = (int) ($value); - } - } - - function render() - { - return ''.gmstrftime("%Y%m%dT%H:%M:%S", $this->_value).''; - } -} - -class XoopsXmlRpcBase64 extends XoopsXmlRpcTag -{ - - var $_value; - - function XoopsXmlRpcBase64($value) - { - $this->_value = base64_encode($value); - } - - function render() - { - return ''.$this->_value.''; - } -} - -class XoopsXmlRpcArray extends XoopsXmlRpcTag -{ - - var $_tags = array(); - - function XoopsXmlRpcArray() - { - } - - function add(&$tagobj) - { - $this->_tags[] =& $tagobj; - } - - function render() - { - $count = count($this->_tags); - $ret = ''; - for ($i = 0; $i < $count; $i++) { - $ret .= $this->_tags[$i]->render(); - } - $ret .= ''; - return $ret; - } -} - -class XoopsXmlRpcStruct extends XoopsXmlRpcTag{ - - var $_tags = array(); - - function XoopsXmlRpcStruct(){ - } - - function add($name, &$tagobj){ - $this->_tags[] = array('name' => $name, 'value' => $tagobj); - } - - function render(){ - $count = count($this->_tags); - $ret = ''; - for ($i = 0; $i < $count; $i++) { - $ret .= ''.$this->encode($this->_tags[$i]['name']).''.$this->_tags[$i]['value']->render().''; - } - $ret .= ''; - return $ret; - } -} -?> + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * XML Parser RPC document + * + * @copyright http://www.xoops.org/ The XOOPS Project + * @copyright XOOPS_copyrights.txt + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package XML + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: xmlrpctag.php 19118 2010-03-27 17:46:23Z skenow $ + */ + +class XoopsXmlRpcDocument +{ + + var $_tags = array(); + + function XoopsXmlRpcDocument() + { + + } + + function add(&$tagobj) + { + $this->_tags[] =& $tagobj; + } + + function render() + { + } + +} + +class XoopsXmlRpcResponse extends XoopsXmlRpcDocument +{ + function render() + { + $count = count($this->_tags); + $payload = ''; + for ($i = 0; $i < $count; $i++) { + if (!$this->_tags[$i]->isFault()) { + $payload .= $this->_tags[$i]->render(); + } else { + return ''.$this->_tags[$i]->render().''; + } + } + return ''.$payload.''; + } +} + +class XoopsXmlRpcRequest extends XoopsXmlRpcDocument +{ + + var $methodName; + + function XoopsXmlRpcRequest($methodName) + { + $this->methodName = trim($methodName); + } + + function render() + { + $count = count($this->_tags); + $payload = ''; + for ($i = 0; $i < $count; $i++) { + $payload .= ''.$this->_tags[$i]->render().''; + } + return ''.$this->methodName.''.$payload.''; + } +} + +class XoopsXmlRpcTag +{ + + var $_fault = false; + + function XoopsXmlRpcTag() + { + + } + + function &encode(&$text) + { + $text = preg_replace(array("/\&([a-z\d\#]+)\;/i", "/\&/", "/\#\|\|([a-z\d\#]+)\|\|\#/i"), array("#||\\1||#", "&", "&\\1;"), str_replace(array("<", ">"), array("<", ">"), $text)); + return $text; + } + + function setFault($fault = true){ + $this->_fault = ( (int) ($fault) > 0) ? true : false; + } + + function isFault() + { + return $this->_fault; + } + + function render() + { + } +} + +class XoopsXmlRpcFault extends XoopsXmlRpcTag +{ + + var $_code; + var $_extra; + + function XoopsXmlRpcFault($code, $extra = null) + { + $this->setFault(true); + $this->_code = (int) ($code); + $this->_extra = isset($extra) ? trim($extra) : ''; + } + + function render() + { + switch ($this->_code) { + case 101: + $string = 'Invalid server URI'; + break; + case 102: + $string = 'Parser parse error'; + break; + case 103: + $string = 'Module not found'; + break; + case 104: + $string = 'User authentication failed'; + break; + case 105: + $string = 'Module API not found'; + break; + case 106: + $string = 'Method response error'; + break; + case 107: + $string = 'Method not supported'; + break; + case 108: + $string = 'Invalid parameter'; + break; + case 109: + $string = 'Missing parameters'; + break; + case 110: + $string = 'Selected blog application does not exist'; + break; + case 111: + $string = 'Method permission denied'; + break; + default: + $string = 'Method response error'; + break; + } + $string .= "\n".$this->_extra; + return 'faultCode'.$this->_code.'faultString'.$this->encode($string).''; + } +} + +class XoopsXmlRpcInt extends XoopsXmlRpcTag +{ + + var $_value; + + function XoopsXmlRpcInt($value) + { + $this->_value = (int) ($value); + } + + function render() + { + return ''.$this->_value.''; + } +} + +class XoopsXmlRpcDouble extends XoopsXmlRpcTag +{ + + var $_value; + + function XoopsXmlRpcDouble($value) + { + $this->_value = (float)$value; + } + + function render() + { + return ''.$this->_value.''; + } +} + +class XoopsXmlRpcBoolean extends XoopsXmlRpcTag +{ + + var $_value; + + function XoopsXmlRpcBoolean($value) + { + $this->_value = (!empty($value) && $value != false) ? 1 : 0; + } + + function render() + { + return ''.$this->_value.''; + } +} + +class XoopsXmlRpcString extends XoopsXmlRpcTag +{ + + var $_value; + + function XoopsXmlRpcString($value) + { + $this->_value = strval($value); + } + + function render() + { + return ''.$this->encode($this->_value).''; + } +} + +class XoopsXmlRpcDatetime extends XoopsXmlRpcTag +{ + + var $_value; + + function XoopsXmlRpcDatetime($value) + { + if (!is_numeric($value)) { + $this->_value = strtotime($value); + } else { + $this->_value = (int) ($value); + } + } + + function render() + { + return ''.gmstrftime("%Y%m%dT%H:%M:%S", $this->_value).''; + } +} + +class XoopsXmlRpcBase64 extends XoopsXmlRpcTag +{ + + var $_value; + + function XoopsXmlRpcBase64($value) + { + $this->_value = base64_encode($value); + } + + function render() + { + return ''.$this->_value.''; + } +} + +class XoopsXmlRpcArray extends XoopsXmlRpcTag +{ + + var $_tags = array(); + + function XoopsXmlRpcArray() + { + } + + function add(&$tagobj) + { + $this->_tags[] =& $tagobj; + } + + function render() + { + $count = count($this->_tags); + $ret = ''; + for ($i = 0; $i < $count; $i++) { + $ret .= $this->_tags[$i]->render(); + } + $ret .= ''; + return $ret; + } +} + +class XoopsXmlRpcStruct extends XoopsXmlRpcTag{ + + var $_tags = array(); + + function XoopsXmlRpcStruct(){ + } + + function add($name, &$tagobj){ + $this->_tags[] = array('name' => $name, 'value' => $tagobj); + } + + function render(){ + $count = count($this->_tags); + $ret = ''; + for ($i = 0; $i < $count; $i++) { + $ret .= ''.$this->encode($this->_tags[$i]['name']).''.$this->_tags[$i]['value']->render().''; + } + $ret .= ''; + return $ret; + } +} +?> diff --git a/htdocs/libraries/xml/rpc/xoopsapi.php b/htdocs/libraries/xml/rpc/xoopsapi.php index 0cb5adbfb48b..557b33c46499 100644 --- a/htdocs/libraries/xml/rpc/xoopsapi.php +++ b/htdocs/libraries/xml/rpc/xoopsapi.php @@ -1,362 +1,362 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * XML Parser Xoops Api - * - * @copyright http://www.xoops.org/ The XOOPS Project - * @copyright XOOPS_copyrights.txt - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package XML - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: xoopsapi.php 19118 2010-03-27 17:46:23Z skenow $ - */ - -if (!defined('ICMS_ROOT_PATH')) { - die("ImpressCMS root path not defined"); -} -require_once ICMS_LIBRARIES_PATH . '/xml/rpc/xmlrpcapi.php'; - -class XoopsApi extends XoopsXmlRpcApi -{ - - function XoopsApi(&$params, &$response, &$module) - { - $this->XoopsXmlRpcApi($params, $response, $module); - } - - function newPost() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - if (!$fields =& $this->_getPostFields(null, $this->params[0])) { - $this->response->add(new XoopsXmlRpcFault(106)); - } else { - $missing = array(); - foreach ($fields as $tag => $detail) { - if (!isset($this->params[3][$tag])) { - $data = $this->_getTagCdata($this->params[3]['xoops_text'], $tag, true); - if (trim($data) == ''){ - if ($detail['required']) { - $missing[] = $tag; - } - } else { - $post[$tag] =& $data; - } - } else { - $post[$tag] =& $this->params[3][$tag]; - } - } - if (count($missing) > 0) { - $msg = ''; - foreach ($missing as $m) { - $msg .= '<'.$m.'> '; - } - $this->response->add(new XoopsXmlRpcFault(109, $msg)); - } else { - // will be removed... don't worry if this looks bad - include_once ICMS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; - $story = new NewsStory(); - $error = false; - if ( (int) ($this->params[4]) > 0) { - if (!$this->_checkAdmin()) { - // non admin users cannot publish - $error = true; - $this->response->add(new XoopsXmlRpcFault(111)); - } else { - $story->setType('admin'); - $story->setApproved(true); - $story->setPublished(time()); - } - } else { - if (!$this->_checkAdmin()) { - $story->setType('user'); - } else { - $story->setType('admin'); - } - } - if (!$error) { - if (isset($post['categories']) && !empty($post['categories'][0])) { - $story->setTopicId( (int) ($post['categories'][0]['categoryId'])); - } else { - $story->setTopicId(1); - } - $story->setTitle(addslashes(trim($post['title']))); - if (isset($post['moretext'])) { - $story->setBodytext(addslashes(trim($post['moretext']))); - } - if (!isset($post['hometext'])) { - $story->setHometext(addslashes(trim($this->params[3]['xoops_text']))); - } else { - $story->setHometext(addslashes(trim($post['hometext']))); - } - $story->setUid($this->user->getVar('uid')); - $story->setHostname($_SERVER['REMOTE_ADDR']); - if (!$this->_checkAdmin()) { - $story->setNohtml(1); - } else { - $story->setNohtml(0); - } - $story->setNosmiley(0); - $story->setNotifyPub(1); - $story->setTopicalign('R'); - $ret = $story->store(); - if (!$ret) { - $this->response->add(new XoopsXmlRpcFault(106)); - } else { - $this->response->add(new XoopsXmlRpcString($ret)); - } - } - } - } - } - } - - function editPost() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - if (!$fields =& $this->_getPostFields($this->params[0])) { - } else { - $missing = array(); - foreach ($fields as $tag => $detail) { - if (!isset($this->params[3][$tag])) { - $data = $this->_getTagCdata($this->params[3]['xoops_text'], $tag, true); - if (trim($data) == ''){ - if ($detail['required']) { - $missing[] = $tag; - } - } else { - $post[$tag] = $data; - } - } else { - $post[$tag] = $this->params[3][$tag]; - } - } - if (count($missing) > 0) { - $msg = ''; - foreach ($missing as $m) { - $msg .= '<'.$m.'> '; - } - $this->response->add(new XoopsXmlRpcFault(109, $msg)); - } else { - // will be removed... don't worry if this looks bad - include_once ICMS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; - $story = new NewsStory($this->params[0]); - $storyid = $story->storyid(); - if (empty($storyid)) { - $this->response->add(new XoopsXmlRpcFault(106)); - } elseif (!$this->_checkAdmin()) { - $this->response->add(new XoopsXmlRpcFault(111)); - } else { - $story->setTitle(addslashes(trim($post['title']))); - if (isset($post['moretext'])) { - $story->setBodytext(addslashes(trim($post['moretext']))); - } - if (!isset($post['hometext'])) { - $story->setHometext(addslashes(trim($this->params[3]['xoops_text']))); - } else { - $story->setHometext(addslashes(trim($post['hometext']))); - } - if ($this->params[4]) { - $story->setApproved(true); - $story->setPublished(time()); - } - $story->setTopicalign('R'); - if (!$story->store()) { - $this->response->add(new XoopsXmlRpcFault(106)); - } else { - $this->response->add(new XoopsXmlRpcBoolean(true)); - } - } - } - } - } - } - - function deletePost() - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - if (!$this->_checkAdmin()) { - $this->response->add(new XoopsXmlRpcFault(111)); - } else { - // will be removed... don't worry if this looks bad - include_once ICMS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; - $story = new NewsStory($this->params[0]); - if (!$story->delete()) { - $this->response->add(new XoopsXmlRpcFault(106)); - } else { - $this->response->add(new XoopsXmlRpcBoolean(true)); - } - } - } - } - - // currently returns the same struct as in metaWeblogApi - function &getPost($respond=true) - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - // will be removed... don't worry if this looks bad - include_once ICMS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; - $story = new NewsStory($this->params[0]); - $ret = array('uid' => $story->uid(), 'published' => $story->published(), 'storyid' => $story->storyId(), 'title' => $story->title('Edit'), 'hometext' => $story->hometext('Edit'), 'moretext' => $story->bodytext('Edit')); - if (!$respond) { - return $ret; - } else { - if (!$ret) { - $this->response->add(new XoopsXmlRpcFault(106)); - } else { - $struct = new XoopsXmlRpcStruct(); - $content = ''; - foreach ($ret as $key => $value) { - switch($key) { - case 'uid': - $struct->add('userid', new XoopsXmlRpcString($value)); - break; - case 'published': - $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); - break; - case 'storyid': - $struct->add('postid', new XoopsXmlRpcString($value)); - $struct->add('link', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); - $struct->add('permaLink', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); - break; - case 'title': - $struct->add('title', new XoopsXmlRpcString($value)); - break; - default : - $content .= '<'.$key.'>'.trim($value).''; - break; - } - } - $struct->add('description', new XoopsXmlRpcString($content)); - $this->response->add($struct); - } - } - } - } - - function &getRecentPosts($respond=true) - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - include_once ICMS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; - if (isset($this->params[4]) && (int) ($this->params[4]) > 0) { - $stories =& NewsStory::getAllPublished( (int) ($this->params[3]), 0, $this->params[4]); - } else { - $stories =& NewsStory::getAllPublished( (int) ($this->params[3])); - } - $scount = count($stories); - $ret = array(); - for ($i = 0; $i < $scount; $i++) { - $ret[] = array('uid' => $stories[$i]->uid(), 'published' => $stories[$i]->published(), 'storyid' => $stories[$i]->storyId(), 'title' => $stories[$i]->title('Edit'), 'hometext' => $stories[$i]->hometext('Edit'), 'moretext' => $stories[$i]->bodytext('Edit')); - } - if (!$respond) { - return $ret; - } else { - if (count($ret) == 0) { - $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); - } else { - $arr = new XoopsXmlRpcArray(); - $count = count($ret); - for ($i = 0; $i < $count; $i++) { - $struct = new XoopsXmlRpcStruct(); - $content = ''; - foreach($ret[$i] as $key => $value) { - switch($key) { - case 'uid': - $struct->add('userid', new XoopsXmlRpcString($value)); - break; - case 'published': - $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); - break; - case 'storyid': - $struct->add('postid', new XoopsXmlRpcString($value)); - $struct->add('link', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); - $struct->add('permaLink', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); - break; - case 'title': - $struct->add('title', new XoopsXmlRpcString($value)); - break; - default : - $content .= '<'.$key.'>'.trim($value).''; - break; - } - } - $struct->add('description', new XoopsXmlRpcString($content)); - $arr->add($struct); - unset($struct); - } - $this->response->add($arr); - } - } - } - } - - function &getCategories($respond=true) - { - if (!$this->_checkUser($this->params[1], $this->params[2])) { - $this->response->add(new XoopsXmlRpcFault(104)); - } else { - include_once ICMS_ROOT_PATH.'/class/xoopstopic.php'; - $db =& icms_db_Factory::instance(); - $xt = new XoopsTopic($db->prefix('topics')); - $ret = $xt->getTopicsList(); - if (!$respond) { - return $ret; - } else { - if (count($ret) == 0) { - $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); - } else { - $arr = new XoopsXmlRpcArray(); - foreach ($ret as $topic_id => $topic_vars) { - $struct = new XoopsXmlRpcStruct(); - $struct->add('categoryId', new XoopsXmlRpcString($topic_id)); - $struct->add('categoryName', new XoopsXmlRpcString($topic_vars['title'])); - $struct->add('categoryPid', new XoopsXmlRpcString($topic_vars['pid'])); - $arr->add($struct); - unset($struct); - } - $this->response->add($arr); - } - } - } - } -} -?> + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * XML Parser Xoops Api + * + * @copyright http://www.xoops.org/ The XOOPS Project + * @copyright XOOPS_copyrights.txt + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package XML + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: xoopsapi.php 19118 2010-03-27 17:46:23Z skenow $ + */ + +if (!defined('ICMS_ROOT_PATH')) { + die("ImpressCMS root path not defined"); +} +require_once ICMS_LIBRARIES_PATH . '/xml/rpc/xmlrpcapi.php'; + +class XoopsApi extends XoopsXmlRpcApi +{ + + function XoopsApi(&$params, &$response, &$module) + { + $this->XoopsXmlRpcApi($params, $response, $module); + } + + function newPost() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + if (!$fields =& $this->_getPostFields(null, $this->params[0])) { + $this->response->add(new XoopsXmlRpcFault(106)); + } else { + $missing = array(); + foreach ($fields as $tag => $detail) { + if (!isset($this->params[3][$tag])) { + $data = $this->_getTagCdata($this->params[3]['xoops_text'], $tag, true); + if (trim($data) == ''){ + if ($detail['required']) { + $missing[] = $tag; + } + } else { + $post[$tag] =& $data; + } + } else { + $post[$tag] =& $this->params[3][$tag]; + } + } + if (count($missing) > 0) { + $msg = ''; + foreach ($missing as $m) { + $msg .= '<'.$m.'> '; + } + $this->response->add(new XoopsXmlRpcFault(109, $msg)); + } else { + // will be removed... don't worry if this looks bad + include_once ICMS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; + $story = new NewsStory(); + $error = false; + if ( (int) ($this->params[4]) > 0) { + if (!$this->_checkAdmin()) { + // non admin users cannot publish + $error = true; + $this->response->add(new XoopsXmlRpcFault(111)); + } else { + $story->setType('admin'); + $story->setApproved(true); + $story->setPublished(time()); + } + } else { + if (!$this->_checkAdmin()) { + $story->setType('user'); + } else { + $story->setType('admin'); + } + } + if (!$error) { + if (isset($post['categories']) && !empty($post['categories'][0])) { + $story->setTopicId( (int) ($post['categories'][0]['categoryId'])); + } else { + $story->setTopicId(1); + } + $story->setTitle(addslashes(trim($post['title']))); + if (isset($post['moretext'])) { + $story->setBodytext(addslashes(trim($post['moretext']))); + } + if (!isset($post['hometext'])) { + $story->setHometext(addslashes(trim($this->params[3]['xoops_text']))); + } else { + $story->setHometext(addslashes(trim($post['hometext']))); + } + $story->setUid($this->user->getVar('uid')); + $story->setHostname($_SERVER['REMOTE_ADDR']); + if (!$this->_checkAdmin()) { + $story->setNohtml(1); + } else { + $story->setNohtml(0); + } + $story->setNosmiley(0); + $story->setNotifyPub(1); + $story->setTopicalign('R'); + $ret = $story->store(); + if (!$ret) { + $this->response->add(new XoopsXmlRpcFault(106)); + } else { + $this->response->add(new XoopsXmlRpcString($ret)); + } + } + } + } + } + } + + function editPost() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + if (!$fields =& $this->_getPostFields($this->params[0])) { + } else { + $missing = array(); + foreach ($fields as $tag => $detail) { + if (!isset($this->params[3][$tag])) { + $data = $this->_getTagCdata($this->params[3]['xoops_text'], $tag, true); + if (trim($data) == ''){ + if ($detail['required']) { + $missing[] = $tag; + } + } else { + $post[$tag] = $data; + } + } else { + $post[$tag] = $this->params[3][$tag]; + } + } + if (count($missing) > 0) { + $msg = ''; + foreach ($missing as $m) { + $msg .= '<'.$m.'> '; + } + $this->response->add(new XoopsXmlRpcFault(109, $msg)); + } else { + // will be removed... don't worry if this looks bad + include_once ICMS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; + $story = new NewsStory($this->params[0]); + $storyid = $story->storyid(); + if (empty($storyid)) { + $this->response->add(new XoopsXmlRpcFault(106)); + } elseif (!$this->_checkAdmin()) { + $this->response->add(new XoopsXmlRpcFault(111)); + } else { + $story->setTitle(addslashes(trim($post['title']))); + if (isset($post['moretext'])) { + $story->setBodytext(addslashes(trim($post['moretext']))); + } + if (!isset($post['hometext'])) { + $story->setHometext(addslashes(trim($this->params[3]['xoops_text']))); + } else { + $story->setHometext(addslashes(trim($post['hometext']))); + } + if ($this->params[4]) { + $story->setApproved(true); + $story->setPublished(time()); + } + $story->setTopicalign('R'); + if (!$story->store()) { + $this->response->add(new XoopsXmlRpcFault(106)); + } else { + $this->response->add(new XoopsXmlRpcBoolean(true)); + } + } + } + } + } + } + + function deletePost() + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + if (!$this->_checkAdmin()) { + $this->response->add(new XoopsXmlRpcFault(111)); + } else { + // will be removed... don't worry if this looks bad + include_once ICMS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; + $story = new NewsStory($this->params[0]); + if (!$story->delete()) { + $this->response->add(new XoopsXmlRpcFault(106)); + } else { + $this->response->add(new XoopsXmlRpcBoolean(true)); + } + } + } + } + + // currently returns the same struct as in metaWeblogApi + function &getPost($respond=true) + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + // will be removed... don't worry if this looks bad + include_once ICMS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; + $story = new NewsStory($this->params[0]); + $ret = array('uid' => $story->uid(), 'published' => $story->published(), 'storyid' => $story->storyId(), 'title' => $story->title('Edit'), 'hometext' => $story->hometext('Edit'), 'moretext' => $story->bodytext('Edit')); + if (!$respond) { + return $ret; + } else { + if (!$ret) { + $this->response->add(new XoopsXmlRpcFault(106)); + } else { + $struct = new XoopsXmlRpcStruct(); + $content = ''; + foreach ($ret as $key => $value) { + switch($key) { + case 'uid': + $struct->add('userid', new XoopsXmlRpcString($value)); + break; + case 'published': + $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); + break; + case 'storyid': + $struct->add('postid', new XoopsXmlRpcString($value)); + $struct->add('link', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); + $struct->add('permaLink', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); + break; + case 'title': + $struct->add('title', new XoopsXmlRpcString($value)); + break; + default : + $content .= '<'.$key.'>'.trim($value).''; + break; + } + } + $struct->add('description', new XoopsXmlRpcString($content)); + $this->response->add($struct); + } + } + } + } + + function &getRecentPosts($respond=true) + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + include_once ICMS_ROOT_PATH.'/modules/news/class/class.newsstory.php'; + if (isset($this->params[4]) && (int) ($this->params[4]) > 0) { + $stories =& NewsStory::getAllPublished( (int) ($this->params[3]), 0, $this->params[4]); + } else { + $stories =& NewsStory::getAllPublished( (int) ($this->params[3])); + } + $scount = count($stories); + $ret = array(); + for ($i = 0; $i < $scount; $i++) { + $ret[] = array('uid' => $stories[$i]->uid(), 'published' => $stories[$i]->published(), 'storyid' => $stories[$i]->storyId(), 'title' => $stories[$i]->title('Edit'), 'hometext' => $stories[$i]->hometext('Edit'), 'moretext' => $stories[$i]->bodytext('Edit')); + } + if (!$respond) { + return $ret; + } else { + if (count($ret) == 0) { + $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); + } else { + $arr = new XoopsXmlRpcArray(); + $count = count($ret); + for ($i = 0; $i < $count; $i++) { + $struct = new XoopsXmlRpcStruct(); + $content = ''; + foreach($ret[$i] as $key => $value) { + switch($key) { + case 'uid': + $struct->add('userid', new XoopsXmlRpcString($value)); + break; + case 'published': + $struct->add('dateCreated', new XoopsXmlRpcDatetime($value)); + break; + case 'storyid': + $struct->add('postid', new XoopsXmlRpcString($value)); + $struct->add('link', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); + $struct->add('permaLink', new XoopsXmlRpcString(ICMS_URL.'/modules/news/article.php?item_id='.$value)); + break; + case 'title': + $struct->add('title', new XoopsXmlRpcString($value)); + break; + default : + $content .= '<'.$key.'>'.trim($value).''; + break; + } + } + $struct->add('description', new XoopsXmlRpcString($content)); + $arr->add($struct); + unset($struct); + } + $this->response->add($arr); + } + } + } + } + + function &getCategories($respond=true) + { + if (!$this->_checkUser($this->params[1], $this->params[2])) { + $this->response->add(new XoopsXmlRpcFault(104)); + } else { + include_once ICMS_ROOT_PATH.'/class/xoopstopic.php'; + $db =& icms_db_Factory::instance(); + $xt = new XoopsTopic($db->prefix('topics')); + $ret = $xt->getTopicsList(); + if (!$respond) { + return $ret; + } else { + if (count($ret) == 0) { + $this->response->add(new XoopsXmlRpcFault(106, 'Found 0 Entries')); + } else { + $arr = new XoopsXmlRpcArray(); + foreach ($ret as $topic_id => $topic_vars) { + $struct = new XoopsXmlRpcStruct(); + $struct->add('categoryId', new XoopsXmlRpcString($topic_id)); + $struct->add('categoryName', new XoopsXmlRpcString($topic_vars['title'])); + $struct->add('categoryPid', new XoopsXmlRpcString($topic_vars['pid'])); + $arr->add($struct); + unset($struct); + } + $this->response->add($arr); + } + } + } + } +} +?> diff --git a/htdocs/libraries/xml/rss/xmlrss2parser.php b/htdocs/libraries/xml/rss/xmlrss2parser.php index 730a090e661d..9bd3d37649ed 100644 --- a/htdocs/libraries/xml/rss/xmlrss2parser.php +++ b/htdocs/libraries/xml/rss/xmlrss2parser.php @@ -1,758 +1,758 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * XML to RSS parser - * - * @copyright http://www.xoops.org/ The XOOPS Project - * @copyright XOOPS_copyrights.txt - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package XML - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: xmlrss2parser.php 19118 2010-03-27 17:46:23Z skenow $ - */ - -if (!defined('ICMS_ROOT_PATH')) { - die("ImpressCMS root path not defined"); -} -require_once ICMS_LIBRARIES_PATH . '/xml/saxparser.php' ; -require_once ICMS_LIBRARIES_PATH . '/xml/xmltaghandler.php' ; - -class XoopsXmlRss2Parser extends SaxParser -{ - var $_tempArr = array(); - var $_channelData = array(); - var $_imageData = array(); - var $_items = array(); - - function XoopsXmlRss2Parser(&$input) - { - $this->SaxParser($input); - $this->useUtfEncoding(); - $this->addTagHandler(new RssChannelHandler()); - $this->addTagHandler(new RssTitleHandler()); - $this->addTagHandler(new RssLinkHandler()); - $this->addTagHandler(new RssGeneratorHandler()); - $this->addTagHandler(new RssDescriptionHandler()); - $this->addTagHandler(new RssCopyrightHandler()); - $this->addTagHandler(new RssNameHandler()); - $this->addTagHandler(new RssManagingEditorHandler()); - $this->addTagHandler(new RssLanguageHandler()); - $this->addTagHandler(new RssLastBuildDateHandler()); - $this->addTagHandler(new RssWebMasterHandler()); - $this->addTagHandler(new RssImageHandler()); - $this->addTagHandler(new RssUrlHandler()); - $this->addTagHandler(new RssWidthHandler()); - $this->addTagHandler(new RssHeightHandler()); - $this->addTagHandler(new RssItemHandler()); - $this->addTagHandler(new RssCategoryHandler()); - $this->addTagHandler(new RssPubDateHandler()); - $this->addTagHandler(new RssCommentsHandler()); - $this->addTagHandler(new RssSourceHandler()); - $this->addTagHandler(new RssAuthorHandler()); - $this->addTagHandler(new RssGuidHandler()); - $this->addTagHandler(new RssTextInputHandler()); - } - - function setChannelData($name, &$value) - { - if (!isset($this->_channelData[$name])) { - $this->_channelData[$name] =& $value; - } else { - $this->_channelData[$name] .= $value; - } - } - - function &getChannelData($name = null) - { - if (isset($name)) { - if (isset($this->_channelData[$name])) { - return $this->_channelData[$name]; - } - return false; - } - return $this->_channelData; - } - - function setImageData($name, &$value) - { - $this->_imageData[$name] =& $value; - } - - function &getImageData($name = null) - { - if (isset($name)) { - if (isset($this->_imageData[$name])) { - return $this->_imageData[$name]; - } - $return = false; - return $return; - } - return $this->_imageData; - } - - function setItems(&$itemarr) - { - $this->_items[] =& $itemarr; - } - - function &getItems() - { - return $this->_items; - } - - function setTempArr($name, &$value, $delim = '') - { - if (!isset($this->_tempArr[$name])) { - $this->_tempArr[$name] =& $value; - } else { - $this->_tempArr[$name] .= $delim.$value; - } - } - - function getTempArr() - { - return $this->_tempArr; - } - - function resetTempArr() - { - unset($this->_tempArr); - $this->_tempArr = array(); - } -} - -class RssChannelHandler extends XmlTagHandler -{ - - function RssChannelHandler() - { - - } - - function getName() - { - return 'channel'; - } -} - -class RssTitleHandler extends XmlTagHandler -{ - - function RssTitleHandler() - { - - } - - function getName() - { - return 'title'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('title', $data); - break; - case 'image': - $parser->setImageData('title', $data); - break; - case 'item': - case 'textInput': - $parser->setTempArr('title', $data); - break; - default: - break; - } - } -} - -class RssLinkHandler extends XmlTagHandler -{ - - function RssLinkHandler() - { - - } - - function getName() - { - return 'link'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('link', $data); - break; - case 'image': - $parser->setImageData('link', $data); - break; - case 'item': - case 'textInput': - $parser->setTempArr('link', $data); - break; - default: - break; - } - } -} - -class RssDescriptionHandler extends XmlTagHandler -{ - - function RssDescriptionHandler() - { - - } - - function getName() - { - return 'description'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('description', $data); - break; - case 'image': - $parser->setImageData('description', $data); - break; - case 'item': - case 'textInput': - $parser->setTempArr('description', $data); - break; - default: - break; - } - } -} - -class RssGeneratorHandler extends XmlTagHandler -{ - - function RssGeneratorHandler() - { - - } - - function getName() - { - return 'generator'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('generator', $data); - break; - default: - break; - } - } -} - -class RssCopyrightHandler extends XmlTagHandler -{ - - function RssCopyrightHandler() - { - - } - - function getName() - { - return 'copyright'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('copyright', $data); - break; - default: - break; - } - } -} - -class RssNameHandler extends XmlTagHandler -{ - - function RssNameHandler() - { - - } - - function getName() - { - return 'name'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'textInput': - $parser->setTempArr('name', $data); - break; - default: - break; - } - } -} - -class RssManagingEditorHandler extends XmlTagHandler -{ - - function RssManagingEditorHandler() - { - - } - - function getName() - { - return 'managingEditor'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('editor', $data); - break; - default: - break; - } - } -} - -class RssLanguageHandler extends XmlTagHandler -{ - - function RssLanguageHandler() - { - - } - - function getName() - { - return 'language'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('language', $data); - break; - default: - break; - } - } -} - -class RssWebMasterHandler extends XmlTagHandler -{ - - function RssWebMasterHandler() - { - - } - - function getName() - { - return 'webMaster'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('webmaster', $data); - break; - default: - break; - } - } -} - -class RssDocsHandler extends XmlTagHandler -{ - - function RssDocsHandler() - { - - } - - function getName() - { - return 'docs'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('docs', $data); - break; - default: - break; - } - } -} - -class RssTtlHandler extends XmlTagHandler -{ - - function RssTtlHandler() - { - - } - - function getName() - { - return 'ttl'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('ttl', $data); - break; - default: - break; - } - } -} - -class RssTextInputHandler extends XmlTagHandler -{ - - function RssWebMasterHandler() - { - - } - - function getName() - { - return 'textInput'; - } - - function handleBeginElement(&$parser, &$attributes) - { - $parser->resetTempArr(); - } - - function handleEndElement(&$parser) - { - $parser->setChannelData('textinput', $parser->getTempArr()); - } -} - -class RssLastBuildDateHandler extends XmlTagHandler -{ - - function RssLastBuildDateHandler() - { - - } - - function getName() - { - return 'lastBuildDate'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('lastbuilddate', $data); - break; - default: - break; - } - } -} - -class RssImageHandler extends XmlTagHandler -{ - - function RssImageHandler() - { - } - - function getName() - { - return 'image'; - } -} - -class RssUrlHandler extends XmlTagHandler -{ - - function RssUrlHandler() - { - - } - - function getName() - { - return 'url'; - } - - function handleCharacterData(&$parser, &$data) - { - if ($parser->getParentTag() == 'image') { - $parser->setImageData('url', $data); - } - } -} - -class RssWidthHandler extends XmlTagHandler -{ - - function RssWidthHandler() - { - - } - - function getName() - { - return 'width'; - } - - function handleCharacterData(&$parser, &$data) - { - if ($parser->getParentTag() == 'image') { - $parser->setImageData('width', $data); - } - } -} - -class RssHeightHandler extends XmlTagHandler -{ - - function RssHeightHandler() - { - } - - function getName() - { - return 'height'; - } - - function handleCharacterData(&$parser, &$data) - { - if ($parser->getParentTag() == 'image') { - $parser->setImageData('height', $data); - } - } -} - -class RssItemHandler extends XmlTagHandler -{ - - function RssItemHandler() - { - - } - - function getName() - { - return 'item'; - } - - function handleBeginElement(&$parser, &$attributes) - { - $parser->resetTempArr(); - } - - function handleEndElement(&$parser) - { - $items =& $parser->getTempArr(); - $parser->setItems( $items ); - } -} - -class RssCategoryHandler extends XmlTagHandler -{ - - function RssCategoryHandler() - { - - } - - function getName() - { - return 'category'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('category', $data); - break; - case 'item': - $parser->setTempArr('category', $data, ', '); - default: - break; - } - } -} - -class RssCommentsHandler extends XmlTagHandler -{ - - function RssCommentsHandler() - { - - } - - function getName() - { - return 'comments'; - } - - function handleCharacterData(&$parser, &$data) - { - if ($parser->getParentTag() == 'item') { - $parser->setTempArr('comments', $data); - } - } -} - -class RssPubDateHandler extends XmlTagHandler -{ - - function RssPubDateHandler() - { - - } - - function getName() - { - return 'pubDate'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'channel': - $parser->setChannelData('pubdate', $data); - break; - case 'item': - $parser->setTempArr('pubdate', $data); - break; - default: - break; - } - } -} - -class RssGuidHandler extends XmlTagHandler -{ - - function RssGuidHandler() - { - - } - - function getName() - { - return 'guid'; - } - - function handleCharacterData(&$parser, &$data) - { - if ($parser->getParentTag() == 'item') { - $parser->setTempArr('guid', $data); - } - } -} - -class RssAuthorHandler extends XmlTagHandler -{ - - function RssGuidHandler() - { - - } - - function getName() - { - return 'author'; - } - - function handleCharacterData(&$parser, &$data) - { - if ($parser->getParentTag() == 'item') { - $parser->setTempArr('author', $data); - } - } -} - -class RssSourceHandler extends XmlTagHandler -{ - - function RssSourceHandler() - { - - } - - function getName() - { - return 'source'; - } - - function handleBeginElement(&$parser, &$attributes) - { - if ($parser->getParentTag() == 'item') { - $parser->setTempArr('source_url', $attributes['url']); - } - } - - function handleCharacterData(&$parser, &$data) - { - if ($parser->getParentTag() == 'item') { - $parser->setTempArr('source', $data); - } - } -} -?> + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * XML to RSS parser + * + * @copyright http://www.xoops.org/ The XOOPS Project + * @copyright XOOPS_copyrights.txt + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package XML + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: xmlrss2parser.php 19118 2010-03-27 17:46:23Z skenow $ + */ + +if (!defined('ICMS_ROOT_PATH')) { + die("ImpressCMS root path not defined"); +} +require_once ICMS_LIBRARIES_PATH . '/xml/saxparser.php' ; +require_once ICMS_LIBRARIES_PATH . '/xml/xmltaghandler.php' ; + +class XoopsXmlRss2Parser extends SaxParser +{ + var $_tempArr = array(); + var $_channelData = array(); + var $_imageData = array(); + var $_items = array(); + + function XoopsXmlRss2Parser(&$input) + { + $this->SaxParser($input); + $this->useUtfEncoding(); + $this->addTagHandler(new RssChannelHandler()); + $this->addTagHandler(new RssTitleHandler()); + $this->addTagHandler(new RssLinkHandler()); + $this->addTagHandler(new RssGeneratorHandler()); + $this->addTagHandler(new RssDescriptionHandler()); + $this->addTagHandler(new RssCopyrightHandler()); + $this->addTagHandler(new RssNameHandler()); + $this->addTagHandler(new RssManagingEditorHandler()); + $this->addTagHandler(new RssLanguageHandler()); + $this->addTagHandler(new RssLastBuildDateHandler()); + $this->addTagHandler(new RssWebMasterHandler()); + $this->addTagHandler(new RssImageHandler()); + $this->addTagHandler(new RssUrlHandler()); + $this->addTagHandler(new RssWidthHandler()); + $this->addTagHandler(new RssHeightHandler()); + $this->addTagHandler(new RssItemHandler()); + $this->addTagHandler(new RssCategoryHandler()); + $this->addTagHandler(new RssPubDateHandler()); + $this->addTagHandler(new RssCommentsHandler()); + $this->addTagHandler(new RssSourceHandler()); + $this->addTagHandler(new RssAuthorHandler()); + $this->addTagHandler(new RssGuidHandler()); + $this->addTagHandler(new RssTextInputHandler()); + } + + function setChannelData($name, &$value) + { + if (!isset($this->_channelData[$name])) { + $this->_channelData[$name] =& $value; + } else { + $this->_channelData[$name] .= $value; + } + } + + function &getChannelData($name = null) + { + if (isset($name)) { + if (isset($this->_channelData[$name])) { + return $this->_channelData[$name]; + } + return false; + } + return $this->_channelData; + } + + function setImageData($name, &$value) + { + $this->_imageData[$name] =& $value; + } + + function &getImageData($name = null) + { + if (isset($name)) { + if (isset($this->_imageData[$name])) { + return $this->_imageData[$name]; + } + $return = false; + return $return; + } + return $this->_imageData; + } + + function setItems(&$itemarr) + { + $this->_items[] =& $itemarr; + } + + function &getItems() + { + return $this->_items; + } + + function setTempArr($name, &$value, $delim = '') + { + if (!isset($this->_tempArr[$name])) { + $this->_tempArr[$name] =& $value; + } else { + $this->_tempArr[$name] .= $delim.$value; + } + } + + function getTempArr() + { + return $this->_tempArr; + } + + function resetTempArr() + { + unset($this->_tempArr); + $this->_tempArr = array(); + } +} + +class RssChannelHandler extends XmlTagHandler +{ + + function RssChannelHandler() + { + + } + + function getName() + { + return 'channel'; + } +} + +class RssTitleHandler extends XmlTagHandler +{ + + function RssTitleHandler() + { + + } + + function getName() + { + return 'title'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('title', $data); + break; + case 'image': + $parser->setImageData('title', $data); + break; + case 'item': + case 'textInput': + $parser->setTempArr('title', $data); + break; + default: + break; + } + } +} + +class RssLinkHandler extends XmlTagHandler +{ + + function RssLinkHandler() + { + + } + + function getName() + { + return 'link'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('link', $data); + break; + case 'image': + $parser->setImageData('link', $data); + break; + case 'item': + case 'textInput': + $parser->setTempArr('link', $data); + break; + default: + break; + } + } +} + +class RssDescriptionHandler extends XmlTagHandler +{ + + function RssDescriptionHandler() + { + + } + + function getName() + { + return 'description'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('description', $data); + break; + case 'image': + $parser->setImageData('description', $data); + break; + case 'item': + case 'textInput': + $parser->setTempArr('description', $data); + break; + default: + break; + } + } +} + +class RssGeneratorHandler extends XmlTagHandler +{ + + function RssGeneratorHandler() + { + + } + + function getName() + { + return 'generator'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('generator', $data); + break; + default: + break; + } + } +} + +class RssCopyrightHandler extends XmlTagHandler +{ + + function RssCopyrightHandler() + { + + } + + function getName() + { + return 'copyright'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('copyright', $data); + break; + default: + break; + } + } +} + +class RssNameHandler extends XmlTagHandler +{ + + function RssNameHandler() + { + + } + + function getName() + { + return 'name'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'textInput': + $parser->setTempArr('name', $data); + break; + default: + break; + } + } +} + +class RssManagingEditorHandler extends XmlTagHandler +{ + + function RssManagingEditorHandler() + { + + } + + function getName() + { + return 'managingEditor'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('editor', $data); + break; + default: + break; + } + } +} + +class RssLanguageHandler extends XmlTagHandler +{ + + function RssLanguageHandler() + { + + } + + function getName() + { + return 'language'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('language', $data); + break; + default: + break; + } + } +} + +class RssWebMasterHandler extends XmlTagHandler +{ + + function RssWebMasterHandler() + { + + } + + function getName() + { + return 'webMaster'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('webmaster', $data); + break; + default: + break; + } + } +} + +class RssDocsHandler extends XmlTagHandler +{ + + function RssDocsHandler() + { + + } + + function getName() + { + return 'docs'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('docs', $data); + break; + default: + break; + } + } +} + +class RssTtlHandler extends XmlTagHandler +{ + + function RssTtlHandler() + { + + } + + function getName() + { + return 'ttl'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('ttl', $data); + break; + default: + break; + } + } +} + +class RssTextInputHandler extends XmlTagHandler +{ + + function RssWebMasterHandler() + { + + } + + function getName() + { + return 'textInput'; + } + + function handleBeginElement(&$parser, &$attributes) + { + $parser->resetTempArr(); + } + + function handleEndElement(&$parser) + { + $parser->setChannelData('textinput', $parser->getTempArr()); + } +} + +class RssLastBuildDateHandler extends XmlTagHandler +{ + + function RssLastBuildDateHandler() + { + + } + + function getName() + { + return 'lastBuildDate'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('lastbuilddate', $data); + break; + default: + break; + } + } +} + +class RssImageHandler extends XmlTagHandler +{ + + function RssImageHandler() + { + } + + function getName() + { + return 'image'; + } +} + +class RssUrlHandler extends XmlTagHandler +{ + + function RssUrlHandler() + { + + } + + function getName() + { + return 'url'; + } + + function handleCharacterData(&$parser, &$data) + { + if ($parser->getParentTag() == 'image') { + $parser->setImageData('url', $data); + } + } +} + +class RssWidthHandler extends XmlTagHandler +{ + + function RssWidthHandler() + { + + } + + function getName() + { + return 'width'; + } + + function handleCharacterData(&$parser, &$data) + { + if ($parser->getParentTag() == 'image') { + $parser->setImageData('width', $data); + } + } +} + +class RssHeightHandler extends XmlTagHandler +{ + + function RssHeightHandler() + { + } + + function getName() + { + return 'height'; + } + + function handleCharacterData(&$parser, &$data) + { + if ($parser->getParentTag() == 'image') { + $parser->setImageData('height', $data); + } + } +} + +class RssItemHandler extends XmlTagHandler +{ + + function RssItemHandler() + { + + } + + function getName() + { + return 'item'; + } + + function handleBeginElement(&$parser, &$attributes) + { + $parser->resetTempArr(); + } + + function handleEndElement(&$parser) + { + $items =& $parser->getTempArr(); + $parser->setItems( $items ); + } +} + +class RssCategoryHandler extends XmlTagHandler +{ + + function RssCategoryHandler() + { + + } + + function getName() + { + return 'category'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('category', $data); + break; + case 'item': + $parser->setTempArr('category', $data, ', '); + default: + break; + } + } +} + +class RssCommentsHandler extends XmlTagHandler +{ + + function RssCommentsHandler() + { + + } + + function getName() + { + return 'comments'; + } + + function handleCharacterData(&$parser, &$data) + { + if ($parser->getParentTag() == 'item') { + $parser->setTempArr('comments', $data); + } + } +} + +class RssPubDateHandler extends XmlTagHandler +{ + + function RssPubDateHandler() + { + + } + + function getName() + { + return 'pubDate'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'channel': + $parser->setChannelData('pubdate', $data); + break; + case 'item': + $parser->setTempArr('pubdate', $data); + break; + default: + break; + } + } +} + +class RssGuidHandler extends XmlTagHandler +{ + + function RssGuidHandler() + { + + } + + function getName() + { + return 'guid'; + } + + function handleCharacterData(&$parser, &$data) + { + if ($parser->getParentTag() == 'item') { + $parser->setTempArr('guid', $data); + } + } +} + +class RssAuthorHandler extends XmlTagHandler +{ + + function RssGuidHandler() + { + + } + + function getName() + { + return 'author'; + } + + function handleCharacterData(&$parser, &$data) + { + if ($parser->getParentTag() == 'item') { + $parser->setTempArr('author', $data); + } + } +} + +class RssSourceHandler extends XmlTagHandler +{ + + function RssSourceHandler() + { + + } + + function getName() + { + return 'source'; + } + + function handleBeginElement(&$parser, &$attributes) + { + if ($parser->getParentTag() == 'item') { + $parser->setTempArr('source_url', $attributes['url']); + } + } + + function handleCharacterData(&$parser, &$data) + { + if ($parser->getParentTag() == 'item') { + $parser->setTempArr('source', $data); + } + } +} +?> diff --git a/htdocs/libraries/xml/saxparser.php b/htdocs/libraries/xml/saxparser.php index 91f64c92e3a0..f2610ffb43b6 100644 --- a/htdocs/libraries/xml/saxparser.php +++ b/htdocs/libraries/xml/saxparser.php @@ -1,379 +1,379 @@ -xml/SaxParser.class - * Provides basic functionality to read and parse XML documents. Subclasses - * must implement all the their custom handlers by using add* function methods. - * They may also use the handle*() methods to parse a specific XML begin and end - * tags, but this is not recommended as it is more difficult. - - * @Copyright © 2001 eXtremePHP. All rights reserved. - - * @author Ken Egervari
- ******************************************************************************* - * @package XML - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: saxparser.php 19118 2010-03-27 17:46:23Z skenow $ - */ - -class SaxParser -{ - var $level; - var $parser; - - var $isCaseFolding; - var $targetEncoding; - - /* Custom Handler Variables */ - var $tagHandlers = array(); - - /* Tag stack */ - var $tags = array(); - - /* Xml Source Input */ - var $xmlInput; - - var $errors = array(); - - /**************************************************************************** - Creates a SaxParser object using a FileInput to represent the stream - of XML data to parse. Use the static methods createFileInput or - createStringInput to construct xml input source objects to supply - to the constructor, or the implementor can construct them individually. - ****************************************************************************/ - function SaxParser(&$input) - { - $this->level = 0; - $this->parser = xml_parser_create('UTF-8'); - xml_set_object($this->parser, $this); - $this->input =& $input; - $this->setCaseFolding(false); - $this->useUtfEncoding(); - xml_set_element_handler($this->parser, 'handleBeginElement','handleEndElement'); - xml_set_character_data_handler($this->parser, 'handleCharacterData'); - xml_set_processing_instruction_handler($this->parser, 'handleProcessingInstruction'); - xml_set_default_handler($this->parser, 'handleDefault'); - xml_set_unparsed_entity_decl_handler($this->parser, 'handleUnparsedEntityDecl'); - xml_set_notation_decl_handler($this->parser, 'handleNotationDecl'); - xml_set_external_entity_ref_handler($this->parser, 'handleExternalEntityRef'); - } - - /*--------------------------------------------------------------------------- - Property Methods - ---------------------------------------------------------------------------*/ - - function getCurrentLevel() - { - return $this->level; - } - - /**************************************************************************** - * @param $isCaseFolding - * @returns void - ****************************************************************************/ - function setCaseFolding($isCaseFolding) - { - assert(is_bool($isCaseFolding)); - - $this->isCaseFolding = $isCaseFolding; - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, $this->isCaseFolding); - } - - /**************************************************************************** - * @returns void - ****************************************************************************/ - function useIsoEncoding() - { - $this->targetEncoding = 'ISO-8859-1'; - xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->targetEncoding); - } - - /**************************************************************************** - * @returns void - ****************************************************************************/ - function useAsciiEncoding() - { - $this->targetEncoding = 'US-ASCII'; - xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->targetEncoding); - } - - /**************************************************************************** - * @returns void - ****************************************************************************/ - function useUtfEncoding() - { - $this->targetEncoding = 'UTF-8'; - xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->targetEncoding); - } - - /**************************************************************************** - Returns the name of the xml tag being parsed - * @returns string - ****************************************************************************/ - function getCurrentTag() - { - return $this->tags[count($this->tags) - 1]; - } - - function getParentTag() - { - if (isset($this->tags[count($this->tags) - 2])) { - return $this->tags[count($this->tags) - 2]; - } - return false; - } - - /*--------------------------------------------------------------------------- - Parser methods - ---------------------------------------------------------------------------*/ - - /**************************************************************************** - * @returns void - ****************************************************************************/ - function parse() - { - if (!is_resource($this->input)) { - if (!xml_parse($this->parser, $this->input)) { - $this->setErrors($this->getXmlError()); - return false; - } - //if (!$fp = fopen($this->input, 'r')) { - // $this->setErrors('Could not open file: '.$this->input); - // return false; - //} - } else { - while ($data = fread($this->input, 4096)) { - if (!xml_parse($this->parser, str_replace("'", "'", $data), feof($this->input))) { - $this->setErrors($this->getXmlError()); - fclose($this->input); - return false; - } - } - fclose($this->input); - } - return true; - } - - /**************************************************************************** - * @returns void - ****************************************************************************/ - function free() - { - xml_parser_free($this->parser); - - if (!method_exists($this, '__destruct')) { - unset($this); - } - else { - $this->__destruct(); - } - } - - /**************************************************************************** - * @private - * @returns string - ****************************************************************************/ - function getXmlError() - { - return sprintf("XmlParse error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser)); - } - - /*--------------------------------------------------------------------------- - Custom Handler Methods - ---------------------------------------------------------------------------*/ - - /**************************************************************************** - Adds a callback function to be called when a tag is encountered. - Functions that are added must be of the form: - functionName( $attributes ) - * @param $tagName string. The name of the tag currently being parsed. - * @param $functionName string. The name of the function in XmlDocument's - subclass. - * @returns void - ****************************************************************************/ - function addTagHandler(&$tagHandler) - { - $name = $tagHandler->getName(); - if (is_array($name)) { - foreach ($name as $n) { - $this->tagHandlers[$n] =& $tagHandler; - } - } else { - $this->tagHandlers[$name] =& $tagHandler; - } - } - - /*--------------------------------------------------------------------------- - Private Handler Methods - ---------------------------------------------------------------------------*/ - - /**************************************************************************** - Callback function that executes whenever a the start of a tag - occurs when being parsed. - * @param $parser int. The handle to the parser. - * @param $tagName string. The name of the tag currently being parsed. - * @param $attributesArray attay. The list of attributes associated with - the tag. - * @private - * @returns void - ****************************************************************************/ - function handleBeginElement($parser, $tagName, $attributesArray) - { - array_push($this->tags, $tagName); - $this->level++; - if (isset($this->tagHandlers[$tagName]) && is_subclass_of($this->tagHandlers[$tagName], 'xmltaghandler')) { - $this->tagHandlers[$tagName]->handleBeginElement($this, $attributesArray); - } else { - $this->handleBeginElementDefault($parser, $tagName, $attributesArray); - } - } - - /**************************************************************************** - Callback function that executes whenever the end of a tag - occurs when being parsed. - * @param $parser int. The handle to the parser. - * @param $tagName string. The name of the tag currently being parsed. - * @private - * @returns void - ****************************************************************************/ - function handleEndElement($parser, $tagName) - { - array_pop($this->tags); - if (isset($this->tagHandlers[$tagName]) && is_subclass_of($this->tagHandlers[$tagName], 'xmltaghandler')) { - $this->tagHandlers[$tagName]->handleEndElement($this); - } else { - $this->handleEndElementDefault($parser, $tagName); - } - $this->level--; - } - - /**************************************************************************** - Callback function that executes whenever character data is encountered - while being parsed. - * @param $parser int. The handle to the parser. - * @param $data string. Character data inside the tag - * @returns void - ****************************************************************************/ - function handleCharacterData($parser, $data) - { - $tagHandler =& $this->tagHandlers[$this->getCurrentTag()]; - if (isset($tagHandler) && is_subclass_of($tagHandler, 'xmltaghandler')) { - $tagHandler->handleCharacterData($this, $data); - } else { - $this->handleCharacterDataDefault($parser, $data); - } - } - - /**************************************************************************** - * @param $parser int. The handle to the parser. - * @returns void - ****************************************************************************/ - function handleProcessingInstruction($parser, &$target, &$data) - { - // if($target == 'php') { - // eval($data); - // } - } - - /**************************************************************************** - * @param $parser int. The handle to the parser. - * @returns void - ****************************************************************************/ - function handleDefault($parser, $data) - { - - } - - /**************************************************************************** - * @param $parser int. The handle to the parser. - * @returns void - ****************************************************************************/ - function handleUnparsedEntityDecl($parser, $entityName, $base, $systemId, $publicId, $notationName) - { - - } - - /**************************************************************************** - * @param $parser int. The handle to the parser. - * @returns void - ****************************************************************************/ - function handleNotationDecl($parser, $notationName, $base, $systemId, $publicId) - { - - } - - /**************************************************************************** - * @param $parser int. The handle to the parser. - * @returns void - ****************************************************************************/ - function handleExternalEntityRef($parser, $openEntityNames, $base, $systemId, $publicId) - { - - } - - /** - * The default tag handler method for a tag with no handler - * - * @abstract - */ - function handleBeginElementDefault($parser, $tagName, $attributesArray) - { - } - - /** - * The default tag handler method for a tag with no handler - * - * @abstract - */ - function handleEndElementDefault($parser, $tagName) - { - } - - /** - * The default tag handler method for a tag with no handler - * - * @abstract - */ - function handleCharacterDataDefault($parser, $data) - { - } - - /** - * Sets error messages - * - * @param $error string an error message - */ - function setErrors($error) - { - $this->errors[] = trim($error); - } - - /** - * Gets all the error messages - * - * @param $ashtml bool return as html? - * @return mixed - */ - function &getErrors($ashtml = true) - { - if (!$ashtml) { - return $this->errors; - } else { - $ret = ''; - if (count($this->errors) > 0) { - foreach ($this->errors as $error) { - $ret .= $error.'
'; - } - } - return $ret; - } - } -} - -?> +xml/SaxParser.class + * Provides basic functionality to read and parse XML documents. Subclasses + * must implement all the their custom handlers by using add* function methods. + * They may also use the handle*() methods to parse a specific XML begin and end + * tags, but this is not recommended as it is more difficult. + + * @Copyright © 2001 eXtremePHP. All rights reserved. + + * @author Ken Egervari
+ ******************************************************************************* + * @package XML + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: saxparser.php 19118 2010-03-27 17:46:23Z skenow $ + */ + +class SaxParser +{ + var $level; + var $parser; + + var $isCaseFolding; + var $targetEncoding; + + /* Custom Handler Variables */ + var $tagHandlers = array(); + + /* Tag stack */ + var $tags = array(); + + /* Xml Source Input */ + var $xmlInput; + + var $errors = array(); + + /**************************************************************************** + Creates a SaxParser object using a FileInput to represent the stream + of XML data to parse. Use the static methods createFileInput or + createStringInput to construct xml input source objects to supply + to the constructor, or the implementor can construct them individually. + ****************************************************************************/ + function SaxParser(&$input) + { + $this->level = 0; + $this->parser = xml_parser_create('UTF-8'); + xml_set_object($this->parser, $this); + $this->input =& $input; + $this->setCaseFolding(false); + $this->useUtfEncoding(); + xml_set_element_handler($this->parser, 'handleBeginElement','handleEndElement'); + xml_set_character_data_handler($this->parser, 'handleCharacterData'); + xml_set_processing_instruction_handler($this->parser, 'handleProcessingInstruction'); + xml_set_default_handler($this->parser, 'handleDefault'); + xml_set_unparsed_entity_decl_handler($this->parser, 'handleUnparsedEntityDecl'); + xml_set_notation_decl_handler($this->parser, 'handleNotationDecl'); + xml_set_external_entity_ref_handler($this->parser, 'handleExternalEntityRef'); + } + + /*--------------------------------------------------------------------------- + Property Methods + ---------------------------------------------------------------------------*/ + + function getCurrentLevel() + { + return $this->level; + } + + /**************************************************************************** + * @param $isCaseFolding + * @returns void + ****************************************************************************/ + function setCaseFolding($isCaseFolding) + { + assert(is_bool($isCaseFolding)); + + $this->isCaseFolding = $isCaseFolding; + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, $this->isCaseFolding); + } + + /**************************************************************************** + * @returns void + ****************************************************************************/ + function useIsoEncoding() + { + $this->targetEncoding = 'ISO-8859-1'; + xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->targetEncoding); + } + + /**************************************************************************** + * @returns void + ****************************************************************************/ + function useAsciiEncoding() + { + $this->targetEncoding = 'US-ASCII'; + xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->targetEncoding); + } + + /**************************************************************************** + * @returns void + ****************************************************************************/ + function useUtfEncoding() + { + $this->targetEncoding = 'UTF-8'; + xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->targetEncoding); + } + + /**************************************************************************** + Returns the name of the xml tag being parsed + * @returns string + ****************************************************************************/ + function getCurrentTag() + { + return $this->tags[count($this->tags) - 1]; + } + + function getParentTag() + { + if (isset($this->tags[count($this->tags) - 2])) { + return $this->tags[count($this->tags) - 2]; + } + return false; + } + + /*--------------------------------------------------------------------------- + Parser methods + ---------------------------------------------------------------------------*/ + + /**************************************************************************** + * @returns void + ****************************************************************************/ + function parse() + { + if (!is_resource($this->input)) { + if (!xml_parse($this->parser, $this->input)) { + $this->setErrors($this->getXmlError()); + return false; + } + //if (!$fp = fopen($this->input, 'r')) { + // $this->setErrors('Could not open file: '.$this->input); + // return false; + //} + } else { + while ($data = fread($this->input, 4096)) { + if (!xml_parse($this->parser, str_replace("'", "'", $data), feof($this->input))) { + $this->setErrors($this->getXmlError()); + fclose($this->input); + return false; + } + } + fclose($this->input); + } + return true; + } + + /**************************************************************************** + * @returns void + ****************************************************************************/ + function free() + { + xml_parser_free($this->parser); + + if (!method_exists($this, '__destruct')) { + unset($this); + } + else { + $this->__destruct(); + } + } + + /**************************************************************************** + * @private + * @returns string + ****************************************************************************/ + function getXmlError() + { + return sprintf("XmlParse error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser)); + } + + /*--------------------------------------------------------------------------- + Custom Handler Methods + ---------------------------------------------------------------------------*/ + + /**************************************************************************** + Adds a callback function to be called when a tag is encountered. + Functions that are added must be of the form: + functionName( $attributes ) + * @param $tagName string. The name of the tag currently being parsed. + * @param $functionName string. The name of the function in XmlDocument's + subclass. + * @returns void + ****************************************************************************/ + function addTagHandler(&$tagHandler) + { + $name = $tagHandler->getName(); + if (is_array($name)) { + foreach ($name as $n) { + $this->tagHandlers[$n] =& $tagHandler; + } + } else { + $this->tagHandlers[$name] =& $tagHandler; + } + } + + /*--------------------------------------------------------------------------- + Private Handler Methods + ---------------------------------------------------------------------------*/ + + /**************************************************************************** + Callback function that executes whenever a the start of a tag + occurs when being parsed. + * @param $parser int. The handle to the parser. + * @param $tagName string. The name of the tag currently being parsed. + * @param $attributesArray attay. The list of attributes associated with + the tag. + * @private + * @returns void + ****************************************************************************/ + function handleBeginElement($parser, $tagName, $attributesArray) + { + array_push($this->tags, $tagName); + $this->level++; + if (isset($this->tagHandlers[$tagName]) && is_subclass_of($this->tagHandlers[$tagName], 'xmltaghandler')) { + $this->tagHandlers[$tagName]->handleBeginElement($this, $attributesArray); + } else { + $this->handleBeginElementDefault($parser, $tagName, $attributesArray); + } + } + + /**************************************************************************** + Callback function that executes whenever the end of a tag + occurs when being parsed. + * @param $parser int. The handle to the parser. + * @param $tagName string. The name of the tag currently being parsed. + * @private + * @returns void + ****************************************************************************/ + function handleEndElement($parser, $tagName) + { + array_pop($this->tags); + if (isset($this->tagHandlers[$tagName]) && is_subclass_of($this->tagHandlers[$tagName], 'xmltaghandler')) { + $this->tagHandlers[$tagName]->handleEndElement($this); + } else { + $this->handleEndElementDefault($parser, $tagName); + } + $this->level--; + } + + /**************************************************************************** + Callback function that executes whenever character data is encountered + while being parsed. + * @param $parser int. The handle to the parser. + * @param $data string. Character data inside the tag + * @returns void + ****************************************************************************/ + function handleCharacterData($parser, $data) + { + $tagHandler =& $this->tagHandlers[$this->getCurrentTag()]; + if (isset($tagHandler) && is_subclass_of($tagHandler, 'xmltaghandler')) { + $tagHandler->handleCharacterData($this, $data); + } else { + $this->handleCharacterDataDefault($parser, $data); + } + } + + /**************************************************************************** + * @param $parser int. The handle to the parser. + * @returns void + ****************************************************************************/ + function handleProcessingInstruction($parser, &$target, &$data) + { + // if($target == 'php') { + // eval($data); + // } + } + + /**************************************************************************** + * @param $parser int. The handle to the parser. + * @returns void + ****************************************************************************/ + function handleDefault($parser, $data) + { + + } + + /**************************************************************************** + * @param $parser int. The handle to the parser. + * @returns void + ****************************************************************************/ + function handleUnparsedEntityDecl($parser, $entityName, $base, $systemId, $publicId, $notationName) + { + + } + + /**************************************************************************** + * @param $parser int. The handle to the parser. + * @returns void + ****************************************************************************/ + function handleNotationDecl($parser, $notationName, $base, $systemId, $publicId) + { + + } + + /**************************************************************************** + * @param $parser int. The handle to the parser. + * @returns void + ****************************************************************************/ + function handleExternalEntityRef($parser, $openEntityNames, $base, $systemId, $publicId) + { + + } + + /** + * The default tag handler method for a tag with no handler + * + * @abstract + */ + function handleBeginElementDefault($parser, $tagName, $attributesArray) + { + } + + /** + * The default tag handler method for a tag with no handler + * + * @abstract + */ + function handleEndElementDefault($parser, $tagName) + { + } + + /** + * The default tag handler method for a tag with no handler + * + * @abstract + */ + function handleCharacterDataDefault($parser, $data) + { + } + + /** + * Sets error messages + * + * @param $error string an error message + */ + function setErrors($error) + { + $this->errors[] = trim($error); + } + + /** + * Gets all the error messages + * + * @param $ashtml bool return as html? + * @return mixed + */ + function &getErrors($ashtml = true) + { + if (!$ashtml) { + return $this->errors; + } else { + $ret = ''; + if (count($this->errors) > 0) { + foreach ($this->errors as $error) { + $ret .= $error.'
'; + } + } + return $ret; + } + } +} + +?> diff --git a/htdocs/libraries/xml/themesetparser.php b/htdocs/libraries/xml/themesetparser.php index cb071d3cc16c..b62fc3303215 100644 --- a/htdocs/libraries/xml/themesetparser.php +++ b/htdocs/libraries/xml/themesetparser.php @@ -1,429 +1,429 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Tag Handler for the themeset parser - * - * @copyright http://www.xoops.org/ The XOOPS Project - * @copyright XOOPS_copyrights.txt - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package XML - * @subpackage ThemeSet Parser - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: themesetparser.php 19118 2010-03-27 17:46:23Z skenow $ - */ - -if (!defined('ICMS_ROOT_PATH')) { - die("ImpressCMS root path not defined"); -} -include_once ICMS_LIBRARIES_PATH . '/xml/saxparser.php'; -include_once ICMS_LIBRARIES_PATH . '/xml/xmltaghandler.php'; - -class XoopsThemeSetParser extends SaxParser -{ - var $tempArr = array(); - var $themeSetData = array(); - var $imagesData = array(); - var $templatesData = array(); - - function XoopsThemeSetParser(&$input) - { - $this->SaxParser($input); - $this->addTagHandler(new ThemeSetThemeNameHandler()); - $this->addTagHandler(new ThemeSetDateCreatedHandler()); - $this->addTagHandler(new ThemeSetAuthorHandler()); - $this->addTagHandler(new ThemeSetDescriptionHandler()); - $this->addTagHandler(new ThemeSetGeneratorHandler()); - $this->addTagHandler(new ThemeSetNameHandler()); - $this->addTagHandler(new ThemeSetEmailHandler()); - $this->addTagHandler(new ThemeSetLinkHandler()); - $this->addTagHandler(new ThemeSetTemplateHandler()); - $this->addTagHandler(new ThemeSetImageHandler()); - $this->addTagHandler(new ThemeSetModuleHandler()); - $this->addTagHandler(new ThemeSetFileTypeHandler()); - $this->addTagHandler(new ThemeSetTagHandler()); - } - - function setThemeSetData($name, &$value) - { - $this->themeSetData[$name] =& $value; - } - - function &getThemeSetData($name=null) - { - if (isset($name)) { - if (isset($this->themeSetData[$name])) { - return $this->themeSetData[$name]; - } - return false; - } - return $this->themeSetData; - } - - function setImagesData(&$imagearr) - { - $this->imagesData[] =& $imagearr; - } - - function &getImagesData() - { - return $this->imagesData; - } - - function setTemplatesData(&$tplarr) - { - $this->templatesData[] =& $tplarr; - } - - function &getTemplatesData() - { - return $this->templatesData; - } - - function setTempArr($name, &$value, $delim='') - { - if (!isset($this->tempArr[$name])) { - $this->tempArr[$name] =& $value; - } else { - $this->tempArr[$name] .= $delim.$value; - } - } - - function getTempArr() - { - return $this->tempArr; - } - - function resetTempArr() - { - unset($this->tempArr); - $this->tempArr = array(); - } -} - -class ThemeSetDateCreatedHandler extends XmlTagHandler -{ - - function ThemeSetDateCreatedHandler() - { - - } - - function getName() - { - return 'dateCreated'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'themeset': - $parser->setThemeSetData('date', $data); - break; - default: - break; - } - } -} - -class ThemeSetAuthorHandler extends XmlTagHandler -{ - function ThemeSetAuthorHandler() - { - - } - - function getName() - { - return 'author'; - } - - function handleBeginElement(&$parser, &$attributes) - { - $parser->resetTempArr(); - } - - function handleEndElement(&$parser) - { - $parser->setCreditsData($parser->getTempArr()); - } -} - -class ThemeSetDescriptionHandler extends XmlTagHandler -{ - function ThemeSetDescriptionHandler() - { - - } - - function getName() - { - return 'description'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'template': - $parser->setTempArr('description', $data); - break; - case 'image': - $parser->setTempArr('description', $data); - break; - default: - break; - } - } -} - -class ThemeSetGeneratorHandler extends XmlTagHandler -{ - function ThemeSetGeneratorHandler() - { - - } - - function getName() - { - return 'generator'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'themeset': - $parser->setThemeSetData('generator', $data); - break; - default: - break; - } - } -} - -class ThemeSetNameHandler extends XmlTagHandler -{ - function ThemeSetNameHandler() - { - - } - - function getName() - { - return 'name'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'themeset': - $parser->setThemeSetData('name', $data); - break; - case 'author': - $parser->setTempArr('name', $data); - break; - default: - break; - } - } -} - -class ThemeSetEmailHandler extends XmlTagHandler -{ - function ThemeSetEmailHandler() - { - - } - - function getName() - { - return 'email'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'author': - $parser->setTempArr('email', $data); - break; - default: - break; - } - } -} - -class ThemeSetLinkHandler extends XmlTagHandler -{ - function ThemeSetLinkHandler() - { - - } - - function getName() - { - return 'link'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'author': - $parser->setTempArr('link', $data); - break; - default: - break; - } - } -} - -class ThemeSetTemplateHandler extends XmlTagHandler -{ - function ThemeSetTemplateHandler() - { - - } - - function getName() - { - return 'template'; - } - - function handleBeginElement(&$parser, &$attributes) - { - $parser->resetTempArr(); - $parser->setTempArr('name', $attributes['name']); - } - - function handleEndElement(&$parser) - { - $parser->setTemplatesData($parser->getTempArr()); - } -} - -class ThemeSetImageHandler extends XmlTagHandler -{ - function ThemeSetImageHandler() - { - - } - - function getName() - { - return 'image'; - } - - function handleBeginElement(&$parser, &$attributes) - { - $parser->resetTempArr(); - $parser->setTempArr('name', $attributes[0]); - } - - function handleEndElement(&$parser) - { - $parser->setImagesData($parser->getTempArr()); - } -} - -class ThemeSetModuleHandler extends XmlTagHandler -{ - function ThemeSetModuleHandler() - { - - } - - function getName() - { - return 'module'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'template': - case 'image': - $parser->setTempArr('module', $data); - break; - default: - break; - } - } -} - -class ThemeSetFileTypeHandler extends XmlTagHandler -{ - function ThemeSetFileTypeHandler() - { - - } - - function getName() - { - return 'fileType'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'template': - $parser->setTempArr('type', $data); - break; - default: - break; - } - } -} - -class ThemeSetTagHandler extends XmlTagHandler -{ - function ThemeSetTagHandler() - { - - } - - function getName() - { - return 'tag'; - } - - function handleCharacterData(&$parser, &$data) - { - switch ($parser->getParentTag()) { - case 'image': - $parser->setTempArr('tag', $data); - break; - default: - break; - } - } -} -?> + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Tag Handler for the themeset parser + * + * @copyright http://www.xoops.org/ The XOOPS Project + * @copyright XOOPS_copyrights.txt + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package XML + * @subpackage ThemeSet Parser + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: themesetparser.php 19118 2010-03-27 17:46:23Z skenow $ + */ + +if (!defined('ICMS_ROOT_PATH')) { + die("ImpressCMS root path not defined"); +} +include_once ICMS_LIBRARIES_PATH . '/xml/saxparser.php'; +include_once ICMS_LIBRARIES_PATH . '/xml/xmltaghandler.php'; + +class XoopsThemeSetParser extends SaxParser +{ + var $tempArr = array(); + var $themeSetData = array(); + var $imagesData = array(); + var $templatesData = array(); + + function XoopsThemeSetParser(&$input) + { + $this->SaxParser($input); + $this->addTagHandler(new ThemeSetThemeNameHandler()); + $this->addTagHandler(new ThemeSetDateCreatedHandler()); + $this->addTagHandler(new ThemeSetAuthorHandler()); + $this->addTagHandler(new ThemeSetDescriptionHandler()); + $this->addTagHandler(new ThemeSetGeneratorHandler()); + $this->addTagHandler(new ThemeSetNameHandler()); + $this->addTagHandler(new ThemeSetEmailHandler()); + $this->addTagHandler(new ThemeSetLinkHandler()); + $this->addTagHandler(new ThemeSetTemplateHandler()); + $this->addTagHandler(new ThemeSetImageHandler()); + $this->addTagHandler(new ThemeSetModuleHandler()); + $this->addTagHandler(new ThemeSetFileTypeHandler()); + $this->addTagHandler(new ThemeSetTagHandler()); + } + + function setThemeSetData($name, &$value) + { + $this->themeSetData[$name] =& $value; + } + + function &getThemeSetData($name=null) + { + if (isset($name)) { + if (isset($this->themeSetData[$name])) { + return $this->themeSetData[$name]; + } + return false; + } + return $this->themeSetData; + } + + function setImagesData(&$imagearr) + { + $this->imagesData[] =& $imagearr; + } + + function &getImagesData() + { + return $this->imagesData; + } + + function setTemplatesData(&$tplarr) + { + $this->templatesData[] =& $tplarr; + } + + function &getTemplatesData() + { + return $this->templatesData; + } + + function setTempArr($name, &$value, $delim='') + { + if (!isset($this->tempArr[$name])) { + $this->tempArr[$name] =& $value; + } else { + $this->tempArr[$name] .= $delim.$value; + } + } + + function getTempArr() + { + return $this->tempArr; + } + + function resetTempArr() + { + unset($this->tempArr); + $this->tempArr = array(); + } +} + +class ThemeSetDateCreatedHandler extends XmlTagHandler +{ + + function ThemeSetDateCreatedHandler() + { + + } + + function getName() + { + return 'dateCreated'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'themeset': + $parser->setThemeSetData('date', $data); + break; + default: + break; + } + } +} + +class ThemeSetAuthorHandler extends XmlTagHandler +{ + function ThemeSetAuthorHandler() + { + + } + + function getName() + { + return 'author'; + } + + function handleBeginElement(&$parser, &$attributes) + { + $parser->resetTempArr(); + } + + function handleEndElement(&$parser) + { + $parser->setCreditsData($parser->getTempArr()); + } +} + +class ThemeSetDescriptionHandler extends XmlTagHandler +{ + function ThemeSetDescriptionHandler() + { + + } + + function getName() + { + return 'description'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'template': + $parser->setTempArr('description', $data); + break; + case 'image': + $parser->setTempArr('description', $data); + break; + default: + break; + } + } +} + +class ThemeSetGeneratorHandler extends XmlTagHandler +{ + function ThemeSetGeneratorHandler() + { + + } + + function getName() + { + return 'generator'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'themeset': + $parser->setThemeSetData('generator', $data); + break; + default: + break; + } + } +} + +class ThemeSetNameHandler extends XmlTagHandler +{ + function ThemeSetNameHandler() + { + + } + + function getName() + { + return 'name'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'themeset': + $parser->setThemeSetData('name', $data); + break; + case 'author': + $parser->setTempArr('name', $data); + break; + default: + break; + } + } +} + +class ThemeSetEmailHandler extends XmlTagHandler +{ + function ThemeSetEmailHandler() + { + + } + + function getName() + { + return 'email'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'author': + $parser->setTempArr('email', $data); + break; + default: + break; + } + } +} + +class ThemeSetLinkHandler extends XmlTagHandler +{ + function ThemeSetLinkHandler() + { + + } + + function getName() + { + return 'link'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'author': + $parser->setTempArr('link', $data); + break; + default: + break; + } + } +} + +class ThemeSetTemplateHandler extends XmlTagHandler +{ + function ThemeSetTemplateHandler() + { + + } + + function getName() + { + return 'template'; + } + + function handleBeginElement(&$parser, &$attributes) + { + $parser->resetTempArr(); + $parser->setTempArr('name', $attributes['name']); + } + + function handleEndElement(&$parser) + { + $parser->setTemplatesData($parser->getTempArr()); + } +} + +class ThemeSetImageHandler extends XmlTagHandler +{ + function ThemeSetImageHandler() + { + + } + + function getName() + { + return 'image'; + } + + function handleBeginElement(&$parser, &$attributes) + { + $parser->resetTempArr(); + $parser->setTempArr('name', $attributes[0]); + } + + function handleEndElement(&$parser) + { + $parser->setImagesData($parser->getTempArr()); + } +} + +class ThemeSetModuleHandler extends XmlTagHandler +{ + function ThemeSetModuleHandler() + { + + } + + function getName() + { + return 'module'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'template': + case 'image': + $parser->setTempArr('module', $data); + break; + default: + break; + } + } +} + +class ThemeSetFileTypeHandler extends XmlTagHandler +{ + function ThemeSetFileTypeHandler() + { + + } + + function getName() + { + return 'fileType'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'template': + $parser->setTempArr('type', $data); + break; + default: + break; + } + } +} + +class ThemeSetTagHandler extends XmlTagHandler +{ + function ThemeSetTagHandler() + { + + } + + function getName() + { + return 'tag'; + } + + function handleCharacterData(&$parser, &$data) + { + switch ($parser->getParentTag()) { + case 'image': + $parser->setTempArr('tag', $data); + break; + default: + break; + } + } +} +?> diff --git a/htdocs/libraries/xml/xmltaghandler.php b/htdocs/libraries/xml/xmltaghandler.php index 794828d7f57b..3b5524dacec4 100644 --- a/htdocs/libraries/xml/xmltaghandler.php +++ b/htdocs/libraries/xml/xmltaghandler.php @@ -1,76 +1,76 @@ -xml/XmlTagHandler
-
- XmlTagHandler
-
- Copyright © 2001 eXtremePHP. All rights reserved.
-
- @author Ken Egervari, Remi Michalski
-*******************************************************************************/ -/** - * XML Parser Tag Handler - * - * - /******************************************************************************* - * Location: xml/XmlTagHandler - * - * XmlTagHandler - - * @Copyright © 2001 eXtremePHP. All rights reserved. - - * @author Ken Egervari, Remi Michalski - ******************************************************************************* - * - * @package Administration - * @since XOOPS - * @author http://www.xoops.org The XOOPS Project - * @author modified by UnderDog - * @version $Id: xmltaghandler.php 19118 2010-03-27 17:46:23Z skenow $ - */ - -class XmlTagHandler -{ - - /**************************************************************************** - - ****************************************************************************/ - function XmlTagHandler() - { - } - - /**************************************************************************** - - ****************************************************************************/ - function getName() - { - return ''; - } - - /**************************************************************************** - - ****************************************************************************/ - function handleBeginElement(&$parser, &$attributes) - { - - } - - /**************************************************************************** - - ****************************************************************************/ - function handleEndElement(&$parser) - { - - } - - /**************************************************************************** - - ****************************************************************************/ - function handleCharacterData(&$parser, &$data) - { - - } -} - -?> +xml/XmlTagHandler
+
+ XmlTagHandler
+
+ Copyright © 2001 eXtremePHP. All rights reserved.
+
+ @author Ken Egervari, Remi Michalski
+*******************************************************************************/ +/** + * XML Parser Tag Handler + * + * + /******************************************************************************* + * Location: xml/XmlTagHandler + * + * XmlTagHandler + + * @Copyright © 2001 eXtremePHP. All rights reserved. + + * @author Ken Egervari, Remi Michalski + ******************************************************************************* + * + * @package Administration + * @since XOOPS + * @author http://www.xoops.org The XOOPS Project + * @author modified by UnderDog + * @version $Id: xmltaghandler.php 19118 2010-03-27 17:46:23Z skenow $ + */ + +class XmlTagHandler +{ + + /**************************************************************************** + + ****************************************************************************/ + function XmlTagHandler() + { + } + + /**************************************************************************** + + ****************************************************************************/ + function getName() + { + return ''; + } + + /**************************************************************************** + + ****************************************************************************/ + function handleBeginElement(&$parser, &$attributes) + { + + } + + /**************************************************************************** + + ****************************************************************************/ + function handleEndElement(&$parser) + { + + } + + /**************************************************************************** + + ****************************************************************************/ + function handleCharacterData(&$parser, &$data) + { + + } +} + +?> diff --git a/htdocs/mainfile.php b/htdocs/mainfile.php index 73b981c2f35d..30bc6507506b 100644 --- a/htdocs/mainfile.php +++ b/htdocs/mainfile.php @@ -1,48 +1,48 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // - -/** -* All information in order to connect to database are going through here. -* -* Be careful if you are changing data's in this file. -* -* @copyright http://www.xoops.org/ The XOOPS Project -* @copyright http://www.impresscms.org/ The ImpressCMS Project -* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL) -* @since XOOPS -* @package Core -* @version $Id: mainfile.php 12313 2013-09-15 21:14:35Z skenow $ -*/ - -/** - * - */ -// ImpressCMS is not installed yet. -if(! defined('XOOPS_INSTALL')){ - header('Location: install/index.php'); - exit(); -} + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // + +/** +* All information in order to connect to database are going through here. +* +* Be careful if you are changing data's in this file. +* +* @copyright http://www.xoops.org/ The XOOPS Project +* @copyright http://www.impresscms.org/ The ImpressCMS Project +* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL) +* @since XOOPS +* @package Core +* @version $Id: mainfile.php 12313 2013-09-15 21:14:35Z skenow $ +*/ + +/** + * + */ +// ImpressCMS is not installed yet. +if(! defined('XOOPS_INSTALL')){ + header('Location: install/index.php'); + exit(); +} diff --git a/htdocs/modules/system/admin/adsense/xoops_version.php b/htdocs/modules/system/admin/adsense/xoops_version.php index 0e3e7fe85f5c..9c36b357e990 100644 --- a/htdocs/modules/system/admin/adsense/xoops_version.php +++ b/htdocs/modules/system/admin/adsense/xoops_version.php @@ -1,26 +1,26 @@ - - * @version $Id: xoops_version.php 10999 2011-02-03 02:22:45Z skenow $ - */ - -$modversion = array( - 'name' => _MD_AM_ADSENSES, - 'version' => "1.0", - 'description' => _MD_AM_ADSENSES_DSC, - 'author' => "Sina Asghari (aka stranger) ", - 'credits' => "The ImpressCMS Projects", - 'help' => "", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "adsense.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=adsense", - 'category' => XOOPS_SYSTEM_ADSENSES, + + * @version $Id: xoops_version.php 10999 2011-02-03 02:22:45Z skenow $ + */ + +$modversion = array( + 'name' => _MD_AM_ADSENSES, + 'version' => "1.0", + 'description' => _MD_AM_ADSENSES_DSC, + 'author' => "Sina Asghari (aka stranger) ", + 'credits' => "The ImpressCMS Projects", + 'help' => "", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "adsense.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=adsense", + 'category' => XOOPS_SYSTEM_ADSENSES, 'group' => _MD_AM_GROUPS_ADVERTISING); \ No newline at end of file diff --git a/htdocs/modules/system/admin/autotasks/xoops_version.php b/htdocs/modules/system/admin/autotasks/xoops_version.php index 9d80ddf625d4..7e0fa404697f 100644 --- a/htdocs/modules/system/admin/autotasks/xoops_version.php +++ b/htdocs/modules/system/admin/autotasks/xoops_version.php @@ -1,27 +1,27 @@ - - * @version SVN: $Id: xoops_version.php 11000 2011-02-03 04:02:50Z skenow $ - */ - -$modversion = array( - 'name' => _MD_AM_AUTOTASKS, - 'version' => "1.0", - 'description' => "_MD_AM_AUTOTASKS_DSC", - 'author' => "mekdrop ", - 'credits' => "The ImpressCMS Project
Crystal Icons", - 'help' => "", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "images/autotasks.png", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=autotasks", - 'category' => XOOPS_SYSTEM_AUTOTASKS, + + * @version SVN: $Id: xoops_version.php 11000 2011-02-03 04:02:50Z skenow $ + */ + +$modversion = array( + 'name' => _MD_AM_AUTOTASKS, + 'version' => "1.0", + 'description' => "_MD_AM_AUTOTASKS_DSC", + 'author' => "mekdrop ", + 'credits' => "The ImpressCMS Project
Crystal Icons", + 'help' => "", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "images/autotasks.png", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=autotasks", + 'category' => XOOPS_SYSTEM_AUTOTASKS, 'group' => _MD_AM_GROUPS_SYSTEMTOOLS); \ No newline at end of file diff --git a/htdocs/modules/system/admin/avatars/xoops_version.php b/htdocs/modules/system/admin/avatars/xoops_version.php index 4ec8ce885fd4..57e2f3f7fcc9 100644 --- a/htdocs/modules/system/admin/avatars/xoops_version.php +++ b/htdocs/modules/system/admin/avatars/xoops_version.php @@ -1,53 +1,53 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of avatars, versionfile - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package Administration - * @subpackage Avatars - * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ - */ -$modversion = array( - 'name' => _MD_AM_AVATARS, - 'version' => "", - 'description' => "_MD_AM_AVATARS_DSC", - 'author' => "", - 'credits' => "The ImpressCMS Project", - 'help' => "images.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "avatars.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=avatars", - 'category' => XOOPS_SYSTEM_AVATAR, - 'group' => _MD_AM_GROUPS_USERSANDGROUPS); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of avatars, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @subpackage Avatars + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ +$modversion = array( + 'name' => _MD_AM_AVATARS, + 'version' => "", + 'description' => "_MD_AM_AVATARS_DSC", + 'author' => "", + 'credits' => "The ImpressCMS Project", + 'help' => "images.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "avatars.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=avatars", + 'category' => XOOPS_SYSTEM_AVATAR, + 'group' => _MD_AM_GROUPS_USERSANDGROUPS); diff --git a/htdocs/modules/system/admin/blocksadmin/xoops_version.php b/htdocs/modules/system/admin/blocksadmin/xoops_version.php index 419e12470c78..85928ee84fb6 100644 --- a/htdocs/modules/system/admin/blocksadmin/xoops_version.php +++ b/htdocs/modules/system/admin/blocksadmin/xoops_version.php @@ -1,53 +1,53 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of blocksadmin, versionfile - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package Administration - * @subpackage Blocks - * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ - */ -$modversion = array( - 'name' => _MD_AM_BKAD, - 'version' => 2.0, - 'description' => _MD_AM_BKAD_DSC, - 'author' => "Gustavo Pilla (aka nekro) ", - 'credits' => "The MPN SE Project", - 'help' => "blocks.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "blocksadmin.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=blocksadmin", - 'category' => XOOPS_SYSTEM_BLOCK, - 'group' => _MD_AM_GROUPS_LAYOUT); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of blocksadmin, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @subpackage Blocks + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ +$modversion = array( + 'name' => _MD_AM_BKAD, + 'version' => 2.0, + 'description' => _MD_AM_BKAD_DSC, + 'author' => "Gustavo Pilla (aka nekro) ", + 'credits' => "The MPN SE Project", + 'help' => "blocks.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "blocksadmin.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=blocksadmin", + 'category' => XOOPS_SYSTEM_BLOCK, + 'group' => _MD_AM_GROUPS_LAYOUT); diff --git a/htdocs/modules/system/admin/blockspadmin/class/blockspadmin.php b/htdocs/modules/system/admin/blockspadmin/class/blockspadmin.php index 3b3fcf845ad9..d3dae4f0f164 100644 --- a/htdocs/modules/system/admin/blockspadmin/class/blockspadmin.php +++ b/htdocs/modules/system/admin/blockspadmin/class/blockspadmin.php @@ -1,105 +1,105 @@ - - * @license LICENSE.txt - * @package Administration - * @subpackage Block Positions - * @since ImpressCMS 1.2 - * @author Rodrigo Pereira Lima (AKA TheRplima) - * @author Gustavo Pilla (aka nekro) - * @author modified by UnderDog - * @version SVN: $Id: blockspadmin.php 11009 2011-02-05 21:17:31Z skenow $ - */ - -/** - * System Blockspadmin Class - * - * @copyright The ImpressCMS Project - * @license LICENSE.txt - * @package Administration - * @subpackage Block Positions - * @since ImpressCMS 1.2 - * @author Gustavo Pilla (aka nekro) - */ -class SystemBlockspadmin extends icms_view_block_position_Object { - - /** - * Constructor - * - * @param icms_view_block_position_Handler $handler - */ - public function __construct(& $handler) { - parent::__construct( $handler ); - - $this->hideFieldFromForm('id'); - $this->hideFieldFromForm('block_default'); - $this->hideFieldFromForm('block_type'); - } - - /** - * Get Custom Title - * - * @return string - */ - public function getCustomTitle() { - $rtn = defined($this->getVar('title')) ? constant($this->getVar('title')) : $this->getVar('title'); - return $rtn; - } - - /** - * getDeleteItemLink - * - * Overwrited Method - * - * @param string $onlyUrl - * @param boolean $withimage - * @param boolean $userSide - * @return string - */ - public function getEditItemLink($onlyUrl=false, $withimage=true, $userSide=false) { - if ($this->getVar('block_default') == 1) return ""; - return parent::getEditItemLink($onlyUrl, $withimage, $userSide); - } - - /** - * getDeleteItemLink - * - * Overwrited Method - * - * @param string $onlyUrl - * @param boolean $withimage - * @param boolean $userSide - * @return string - */ - public function getDeleteItemLink($onlyUrl=false, $withimage=true, $userSide=false) { - if ($this->getVar('block_default') == 1) return ""; - return parent::getDeleteItemLink($onlyUrl, $withimage, $userSide); - } - -} - -/** - * System Blockspadmin Class - * - * @copyright The ImpressCMS Project - * @license LICENSE.txt - * @package Administration - * @subpackage Block Positions - * @since ImpressCMS 1.2 - * @author Gustavo Pilla (aka nekro) - */ -class SystemBlockspadminHandler extends icms_view_block_position_Handler { - - /** - * Constructor - * - * @param IcmsDatabase $db - */ - public function __construct(& $db) { - icms_ipf_Handler::__construct($db, 'blockspadmin', 'id', 'title', 'description', 'system'); - $this->table = $this->db->prefix('block_positions'); - } -} - + + * @license LICENSE.txt + * @package Administration + * @subpackage Block Positions + * @since ImpressCMS 1.2 + * @author Rodrigo Pereira Lima (AKA TheRplima) + * @author Gustavo Pilla (aka nekro) + * @author modified by UnderDog + * @version SVN: $Id: blockspadmin.php 11009 2011-02-05 21:17:31Z skenow $ + */ + +/** + * System Blockspadmin Class + * + * @copyright The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @subpackage Block Positions + * @since ImpressCMS 1.2 + * @author Gustavo Pilla (aka nekro) + */ +class SystemBlockspadmin extends icms_view_block_position_Object { + + /** + * Constructor + * + * @param icms_view_block_position_Handler $handler + */ + public function __construct(& $handler) { + parent::__construct( $handler ); + + $this->hideFieldFromForm('id'); + $this->hideFieldFromForm('block_default'); + $this->hideFieldFromForm('block_type'); + } + + /** + * Get Custom Title + * + * @return string + */ + public function getCustomTitle() { + $rtn = defined($this->getVar('title')) ? constant($this->getVar('title')) : $this->getVar('title'); + return $rtn; + } + + /** + * getDeleteItemLink + * + * Overwrited Method + * + * @param string $onlyUrl + * @param boolean $withimage + * @param boolean $userSide + * @return string + */ + public function getEditItemLink($onlyUrl=false, $withimage=true, $userSide=false) { + if ($this->getVar('block_default') == 1) return ""; + return parent::getEditItemLink($onlyUrl, $withimage, $userSide); + } + + /** + * getDeleteItemLink + * + * Overwrited Method + * + * @param string $onlyUrl + * @param boolean $withimage + * @param boolean $userSide + * @return string + */ + public function getDeleteItemLink($onlyUrl=false, $withimage=true, $userSide=false) { + if ($this->getVar('block_default') == 1) return ""; + return parent::getDeleteItemLink($onlyUrl, $withimage, $userSide); + } + +} + +/** + * System Blockspadmin Class + * + * @copyright The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @subpackage Block Positions + * @since ImpressCMS 1.2 + * @author Gustavo Pilla (aka nekro) + */ +class SystemBlockspadminHandler extends icms_view_block_position_Handler { + + /** + * Constructor + * + * @param IcmsDatabase $db + */ + public function __construct(& $db) { + icms_ipf_Handler::__construct($db, 'blockspadmin', 'id', 'title', 'description', 'system'); + $this->table = $this->db->prefix('block_positions'); + } +} + diff --git a/htdocs/modules/system/admin/blockspadmin/xoops_version.php b/htdocs/modules/system/admin/blockspadmin/xoops_version.php index 1c1319c965c5..48406272bc2d 100644 --- a/htdocs/modules/system/admin/blockspadmin/xoops_version.php +++ b/htdocs/modules/system/admin/blockspadmin/xoops_version.php @@ -1,29 +1,29 @@ - - * @version SVN: $Id: xoops_version.php 11009 2011-02-05 21:17:31Z skenow $ - */ - -$modversion = array( - 'name' => _MD_AM_BKPOSAD, - 'version' => "", - 'description' => _MD_AM_BKPOSAD_DSC, - 'author' => "", - 'credits' => "The ImpressCMS Project", - 'help' => "blocksp.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "blockspadmin.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=blockspadmin", - 'category' => XOOPS_SYSTEM_BLOCKP, + + * @version SVN: $Id: xoops_version.php 11009 2011-02-05 21:17:31Z skenow $ + */ + +$modversion = array( + 'name' => _MD_AM_BKPOSAD, + 'version' => "", + 'description' => _MD_AM_BKPOSAD_DSC, + 'author' => "", + 'credits' => "The ImpressCMS Project", + 'help' => "blocksp.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "blockspadmin.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=blockspadmin", + 'category' => XOOPS_SYSTEM_BLOCKP, 'group' => _MD_AM_GROUPS_LAYOUT); \ No newline at end of file diff --git a/htdocs/modules/system/admin/comments/admin_header.php b/htdocs/modules/system/admin/comments/admin_header.php index bbc0a7299125..15943995bc6c 100644 --- a/htdocs/modules/system/admin/comments/admin_header.php +++ b/htdocs/modules/system/admin/comments/admin_header.php @@ -1,4 +1,4 @@ -getByDirname('system'); - if (!in_array(XOOPS_GROUP_ADMIN, icms::$user->getGroups())) { - $sysperm_handler = icms::handler('icms_member_groupperm'); - if (!$sysperm_handler->checkRight('system_admin', XOOPS_SYSTEM_COMMENT, icms::$user->getGroups())) { - redirect_header(ICMS_URL . '/', 3, _NOPERM);; - exit(); - } - } -} else { - redirect_header(ICMS_URL . '/', 3, _NOPERM); - exit(); -} - +/** + * Administration of comments, Admin Header file + * + * Checks the rights of the user for being able to admin the comments + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @subpackage Comments + * @version SVN: $Id: admin_header.php 12313 2013-09-15 21:14:35Z skenow $ + */ + +include '../../../../mainfile.php'; +include ICMS_ROOT_PATH.'/include/cp_functions.php'; +if (is_object(icms::$user)) { + $module_handler = icms::handler('icms_module'); + $icmsModule =& $module_handler->getByDirname('system'); + if (!in_array(XOOPS_GROUP_ADMIN, icms::$user->getGroups())) { + $sysperm_handler = icms::handler('icms_member_groupperm'); + if (!$sysperm_handler->checkRight('system_admin', XOOPS_SYSTEM_COMMENT, icms::$user->getGroups())) { + redirect_header(ICMS_URL . '/', 3, _NOPERM);; + exit(); + } + } +} else { + redirect_header(ICMS_URL . '/', 3, _NOPERM); + exit(); +} + diff --git a/htdocs/modules/system/admin/comments/comment_delete.php b/htdocs/modules/system/admin/comments/comment_delete.php index 9a5864129418..91d9dfd11c20 100644 --- a/htdocs/modules/system/admin/comments/comment_delete.php +++ b/htdocs/modules/system/admin/comments/comment_delete.php @@ -1,4 +1,4 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of comments, versionfile - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package Administration - * @subpackage Comments - * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ - */ -$modversion = array( - 'name' => _MD_AM_COMMENTS, - 'version' => "", - 'description' => _MD_AM_COMMENTS_DSC, - 'author' => "", - 'credits' => "The ImpressCMS Project", - 'help' => "comments.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "comments.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=comments", - 'category' => XOOPS_SYSTEM_COMMENT, - 'group' => _MD_AM_GROUPS_CONTENT); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of comments, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @subpackage Comments + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ +$modversion = array( + 'name' => _MD_AM_COMMENTS, + 'version' => "", + 'description' => _MD_AM_COMMENTS_DSC, + 'author' => "", + 'credits' => "The ImpressCMS Project", + 'help' => "comments.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "comments.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=comments", + 'category' => XOOPS_SYSTEM_COMMENT, + 'group' => _MD_AM_GROUPS_CONTENT); diff --git a/htdocs/modules/system/admin/customtag/xoops_version.php b/htdocs/modules/system/admin/customtag/xoops_version.php index e85383e2cdca..c9318dc4d16d 100644 --- a/htdocs/modules/system/admin/customtag/xoops_version.php +++ b/htdocs/modules/system/admin/customtag/xoops_version.php @@ -1,26 +1,26 @@ - - * @version $Id: xoops_version.php 11012 2011-02-06 16:37:43Z skenow $ - */ - -$modversion = array( - 'name' => _MD_AM_CUSTOMTAGS, - 'version' => "1.0", - 'description' => _MD_AM_CUSTOMTAGS_DSC, - 'author' => "marcan "The ImpressCMS Projects", - 'help' => "", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "banners.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=customtag", - 'category' => XOOPS_SYSTEM_CUSTOMTAGS, + + * @version $Id: xoops_version.php 11012 2011-02-06 16:37:43Z skenow $ + */ + +$modversion = array( + 'name' => _MD_AM_CUSTOMTAGS, + 'version' => "1.0", + 'description' => _MD_AM_CUSTOMTAGS_DSC, + 'author' => "marcan "The ImpressCMS Projects", + 'help' => "", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "banners.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=customtag", + 'category' => XOOPS_SYSTEM_CUSTOMTAGS, 'group' => _MD_AM_GROUPS_CONTENT); \ No newline at end of file diff --git a/htdocs/modules/system/admin/findusers/xoops_version.php b/htdocs/modules/system/admin/findusers/xoops_version.php index 019337e93654..0339e82e3365 100644 --- a/htdocs/modules/system/admin/findusers/xoops_version.php +++ b/htdocs/modules/system/admin/findusers/xoops_version.php @@ -1,53 +1,53 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of finding users, versionfile - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package Administration - * @subpackage Users - * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ - */ -$modversion = array( - 'name' => _MD_AM_FINDUSER, - 'version' => "", - 'description' => _MD_AM_FINDUSER_DSC, - 'author' => "Kazumi Ono
( http://www.myweb.ne.jp/ )", - 'credits' => "The XOOPS Project", - 'help' => "findusers.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "users.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=findusers", - 'category' => XOOPS_SYSTEM_FINDU, - 'group' => _MD_AM_GROUPS_USERSANDGROUPS); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of finding users, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @subpackage Users + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ +$modversion = array( + 'name' => _MD_AM_FINDUSER, + 'version' => "", + 'description' => _MD_AM_FINDUSER_DSC, + 'author' => "Kazumi Ono
( http://www.myweb.ne.jp/ )", + 'credits' => "The XOOPS Project", + 'help' => "findusers.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "users.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=findusers", + 'category' => XOOPS_SYSTEM_FINDU, + 'group' => _MD_AM_GROUPS_USERSANDGROUPS); diff --git a/htdocs/modules/system/admin/groupperm.php b/htdocs/modules/system/admin/groupperm.php index e575dd12d942..bd30c6bda2f4 100644 --- a/htdocs/modules/system/admin/groupperm.php +++ b/htdocs/modules/system/admin/groupperm.php @@ -1,108 +1,108 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Update permissions for a member group - * - * Target for the group permissions form to handle the POST data - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package Administration - * @version SVN: $Id: groupperm.php 12313 2013-09-15 21:14:35Z skenow $ - */ -include '../../../include/cp_header.php'; -$modid = isset($_POST['modid']) ? (int) ($_POST['modid']) : 0; - -// we dont want system module permissions to be changed here -if ($modid <= 1 || !is_object(icms::$user) || !icms::$user->isAdmin($modid)) { - redirect_header(ICMS_URL . '/', 1, _NOPERM); - exit(); -} -$module_handler = icms::handler('icms_module'); -$module =& $module_handler->get($modid); -if (!is_object($module) || !$module->getVar('isactive')) { - redirect_header(ICMS_URL . '/admin.php', 1, _MODULENOEXIST); - exit(); -} - -$msg = array(); - -$member_handler = icms::handler('icms_member'); -$group_list =& $member_handler->getGroupList(); -if (is_array($_POST['perms']) && !empty($_POST['perms'])) { - $gperm_handler = icms::handler('icms_member_groupperm'); - foreach ($_POST['perms'] as $perm_name => $perm_data) { - if (FALSE != $gperm_handler->deleteByModule($modid, $perm_name)) { - foreach ($perm_data['groups'] as $group_id => $item_ids) { - foreach ($item_ids as $item_id => $selected) { - if ($selected == 1) { - // make sure that all parent ids are selected as well - if ($perm_data['parents'][$item_id] != '') { - $parent_ids = explode(':', $perm_data['parents'][$item_id]); - foreach ($parent_ids as $pid) { - if ($pid != 0 && !in_array($pid, array_keys($item_ids))) { - // one of the parent items were not selected, so skip this item - $msg[] = sprintf(_MD_AM_PERMADDNG, '' . $perm_name . '', '' . $perm_data['itemname'][$item_id] . '', '' . $group_list[$group_id] . '') . ' (' . _MD_AM_PERMADDNGP . ')'; - continue 2; - } - } - } - $gperm =& $gperm_handler->create(); - $gperm->setVar('gperm_groupid', $group_id); - $gperm->setVar('gperm_name', $perm_name); - $gperm->setVar('gperm_modid', $modid); - $gperm->setVar('gperm_itemid', $item_id); - if (!$gperm_handler->insert($gperm)) { - $msg[] = sprintf(_MD_AM_PERMADDNG, '' . $perm_name . '', '' . $perm_data['itemname'][$item_id] . '', '' . $group_list[$group_id] . ''); - } else { - $msg[] = sprintf(_MD_AM_PERMADDOK, '' . $perm_name . '', '' . $perm_data['itemname'][$item_id] . '', '' . $group_list[$group_id] . ''); - } - unset($gperm); - } - } - } - } else { - $msg[] = sprintf(_MD_AM_PERMRESETNG, $module->getVar('name') . '(' . $perm_name . ')'); - } - } -} - -$backlink = xoops_getenv("HTTP_REFERER"); -if ($module->getVar('hasadmin')) { - $adminindex = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : $module->getInfo('adminindex'); - if ($adminindex) { - $backlink = ICMS_MODULES_URL . '/' . $module->getVar('dirname') . '/' . $adminindex; - } -} -$backlink = $backlink ? $backlink : ICMS_URL . '/admin.php'; - -redirect_header($backlink, 2, implode("
", $msg)); - + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Update permissions for a member group + * + * Target for the group permissions form to handle the POST data + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @version SVN: $Id: groupperm.php 12313 2013-09-15 21:14:35Z skenow $ + */ +include '../../../include/cp_header.php'; +$modid = isset($_POST['modid']) ? (int) ($_POST['modid']) : 0; + +// we dont want system module permissions to be changed here +if ($modid <= 1 || !is_object(icms::$user) || !icms::$user->isAdmin($modid)) { + redirect_header(ICMS_URL . '/', 1, _NOPERM); + exit(); +} +$module_handler = icms::handler('icms_module'); +$module =& $module_handler->get($modid); +if (!is_object($module) || !$module->getVar('isactive')) { + redirect_header(ICMS_URL . '/admin.php', 1, _MODULENOEXIST); + exit(); +} + +$msg = array(); + +$member_handler = icms::handler('icms_member'); +$group_list =& $member_handler->getGroupList(); +if (is_array($_POST['perms']) && !empty($_POST['perms'])) { + $gperm_handler = icms::handler('icms_member_groupperm'); + foreach ($_POST['perms'] as $perm_name => $perm_data) { + if (FALSE != $gperm_handler->deleteByModule($modid, $perm_name)) { + foreach ($perm_data['groups'] as $group_id => $item_ids) { + foreach ($item_ids as $item_id => $selected) { + if ($selected == 1) { + // make sure that all parent ids are selected as well + if ($perm_data['parents'][$item_id] != '') { + $parent_ids = explode(':', $perm_data['parents'][$item_id]); + foreach ($parent_ids as $pid) { + if ($pid != 0 && !in_array($pid, array_keys($item_ids))) { + // one of the parent items were not selected, so skip this item + $msg[] = sprintf(_MD_AM_PERMADDNG, '' . $perm_name . '', '' . $perm_data['itemname'][$item_id] . '', '' . $group_list[$group_id] . '') . ' (' . _MD_AM_PERMADDNGP . ')'; + continue 2; + } + } + } + $gperm =& $gperm_handler->create(); + $gperm->setVar('gperm_groupid', $group_id); + $gperm->setVar('gperm_name', $perm_name); + $gperm->setVar('gperm_modid', $modid); + $gperm->setVar('gperm_itemid', $item_id); + if (!$gperm_handler->insert($gperm)) { + $msg[] = sprintf(_MD_AM_PERMADDNG, '' . $perm_name . '', '' . $perm_data['itemname'][$item_id] . '', '' . $group_list[$group_id] . ''); + } else { + $msg[] = sprintf(_MD_AM_PERMADDOK, '' . $perm_name . '', '' . $perm_data['itemname'][$item_id] . '', '' . $group_list[$group_id] . ''); + } + unset($gperm); + } + } + } + } else { + $msg[] = sprintf(_MD_AM_PERMRESETNG, $module->getVar('name') . '(' . $perm_name . ')'); + } + } +} + +$backlink = xoops_getenv("HTTP_REFERER"); +if ($module->getVar('hasadmin')) { + $adminindex = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : $module->getInfo('adminindex'); + if ($adminindex) { + $backlink = ICMS_MODULES_URL . '/' . $module->getVar('dirname') . '/' . $adminindex; + } +} +$backlink = $backlink ? $backlink : ICMS_URL . '/admin.php'; + +redirect_header($backlink, 2, implode("
", $msg)); + diff --git a/htdocs/modules/system/admin/groups/groupform.php b/htdocs/modules/system/admin/groups/groupform.php index f8ea03bf7858..31d379a4ea4d 100644 --- a/htdocs/modules/system/admin/groups/groupform.php +++ b/htdocs/modules/system/admin/groups/groupform.php @@ -1,4 +1,4 @@ - - * @version SVN: $Id: groupform.php 12313 2013-09-15 21:14:35Z skenow $ - */ - -$name_text = new icms_form_elements_Text(_AM_NAME, "name", 30, 50, $name_value); -$desc_text = new icms_form_elements_Textarea(_AM_DESCRIPTION, "desc", $desc_value); - -$s_cat_checkbox = new icms_form_elements_Checkbox(_AM_SYSTEMRIGHTS, "system_catids[]", $s_cat_value); - -include_once ICMS_MODULES_PATH . '/system/constants.php'; -$admin_dir = ICMS_MODULES_PATH . '/system/admin/'; -$dirlist = icms_core_Filesystem::getDirList($admin_dir); -/* changes to only allow permission admins you already have */ -$gperm = icms::handler('icms_member_groupperm'); -$groups = icms::$user->getGroups(); -foreach ($dirlist as $file) { - if (file_exists(ICMS_MODULES_PATH . '/system/admin/' . $file . '/icms_version.php')) { - include ICMS_MODULES_PATH . '/system/admin/' . $file . '/icms_version.php'; - } elseif (file_exists(ICMS_MODULES_PATH . '/system/admin/' . $file . '/xoops_version.php')) { - include ICMS_MODULES_PATH . '/system/admin/' . $file . '/xoops_version.php'; - } - if (!empty($modversion['category']) - && (count(array_intersect($groups, $gperm->getGroupIds('system_admin', $modversion['category']))) > 0 - || in_array(ICMS_GROUP_ADMIN, $groups)) - ) { - $s_cat_checkbox->addOption($modversion['category'], $modversion['name']); - } - unset($modversion); -} -unset($dirlist); - -$a_mod_checkbox = new icms_form_elements_Checkbox(_AM_ACTIVERIGHTS, "admin_mids[]", $a_mod_value); -$module_handler = icms::handler('icms_module'); -$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('hasadmin', 1)); -$criteria->add(new icms_db_criteria_Item('isactive', 1)); -$criteria->add(new icms_db_criteria_Item('dirname', 'system', '<>')); -/* criteria added to see if the active user can admin the module, do not filter for administrator group (module_admin)*/ -if (!in_array(XOOPS_GROUP_ADMIN, $groups)) { - $a_mod = $gperm->getItemIds('module_admin', $groups); - $criteria->add(new icms_db_criteria_Item('mid', '(' . implode(',', $a_mod) . ')', 'IN')); -} -$a_mod_checkbox->addOptionArray($module_handler->getList($criteria)); - -$r_mod_checkbox = new icms_form_elements_Checkbox(_AM_ACCESSRIGHTS, "read_mids[]", $r_mod_value); -$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('hasmain', 1)); -$criteria->add(new icms_db_criteria_Item('isactive', 1)); -/* criteria added to see if the active user can access the module, do not filter for administrator group (module_read)*/ -if (!in_array(XOOPS_GROUP_ADMIN, $groups)) { - $r_mod = $gperm->getItemIds('module_read', $groups); - $criteria->add(new icms_db_criteria_Item('mid', '(' . implode(',', $r_mod) . ')', 'IN')); -} -$r_mod_checkbox->addOptionArray($module_handler->getList($criteria)); - -$ed_mod_checkbox = new icms_form_elements_Checkbox(_AM_EDPERM, "useeditor_mids[]", $ed_mod_value); -$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('isactive', 1)); -/* criteria added to see where the active user can use the wysiwyg editors (use_wysiwygeditor) - * administrators don't have explicit entries for this, do not filter - */ -if (!in_array(XOOPS_GROUP_ADMIN, $groups)) { - $ed_mod = $gperm->getItemIds('use_wysiwygeditor', $groups); - $criteria->add(new icms_db_criteria_Item('mid', '(' . implode(',', $ed_mod) . ')', 'IN')); -} -$ed_mod_checkbox->addOptionArray($module_handler->getList($criteria)); - -$debug_mod_checkbox = new icms_form_elements_Checkbox(_AM_DEBUG_PERM, "enabledebug_mids[]", $debug_mod_value); -$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('isactive', 1)); -/* criteria added to see where the active user can view the debug mode (enable_debug) - * administrators do not have explicit entries for this, do not filter - */ -if (!in_array(XOOPS_GROUP_ADMIN, $groups)) { - $debug_mod = $gperm->getItemIds('enable_debug', $groups); - $criteria->add(new icms_db_criteria_Item('mid', '(' . implode(',', $debug_mod) . ')', 'IN')); -} -$debug_mod_checkbox->addOptionArray($module_handler->getList($criteria)); - -$group_manager_checkbox = new icms_form_elements_Checkbox(_AM_GROUPMANAGER_PERM, "groupmanager_gids[]", $group_manager_value); -$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('isactive', 1)); -$groups = $member_handler->getGroups(); -$gperm_handler = icms::handler('icms_member_groupperm'); - -foreach ($groups as $group) { - if ($gperm_handler->checkRight('group_manager', $group->getVar('groupid'), icms::$user->getGroups())) - $group_manager_checkbox->addOption($group->getVar('groupid'), $group->getVar('name')); -} -$icms_block_handler = icms::handler('icms_view_block'); -$posarr = $icms_block_handler->getBlockPositions(true); -$block_checkbox = array(); -$i = 0; -$groups = icms::$user->getGroups(); -foreach ($posarr as $k=>$v) { - $tit = (defined($posarr[$k]['title'])) ? constant($posarr[$k]['title']) : $posarr[$k]['title']; - $block_checkbox[$i] = new icms_form_elements_Checkbox('' . $tit . '
', "read_bids[]", $r_block_value); - $new_blocks_array = array(); - $blocks_array = $icms_block_handler->getAllBlocks("list", $k); - - /* compare to list of blocks the group can read, do not filter for administrator group */ - if (!in_array(XOOPS_GROUP_ADMIN, $groups)) { - $r_blocks = $gperm->getItemIds('block_read', $groups); - $n_blocks_array = array_intersect_key($blocks_array, array_flip($r_blocks)); - } else { - $n_blocks_array = $blocks_array; - } - foreach ($n_blocks_array as $key=>$value) { - $new_blocks_array[$key] = "" . $value . " (ID: " . $key . ")"; - } - $block_checkbox[$i]->addOptionArray($new_blocks_array); - $i++; -} -$r_block_tray = new icms_form_elements_Tray(_AM_BLOCKRIGHTS, "

"); -foreach ($block_checkbox as $k=>$v) { - $r_block_tray->addElement($block_checkbox[$k]); -} - -$op_hidden = new icms_form_elements_Hidden("op", $op_value); -$fct_hidden = new icms_form_elements_Hidden("fct", "groups"); -$submit_button = new icms_form_elements_Button("", "groupsubmit", $submit_value, "submit"); -$form = new icms_form_Theme($form_title, "groupform", "admin.php", "post", true); -$form->addElement($name_text, TRUE); -$form->addElement($desc_text); -$form->addElement($s_cat_checkbox); - -if (!isset($g_id) || ($g_id != XOOPS_GROUP_ADMIN && $g_id != XOOPS_GROUP_ANONYMOUS)) { - $form->addElement($group_manager_checkbox); -} -$form->addElement($a_mod_checkbox); -$form->addElement($r_mod_checkbox); -if (!isset($g_id) || $g_id != XOOPS_GROUP_ANONYMOUS) { - $form->addElement($ed_mod_checkbox); -} - -if (!isset($g_id) || $g_id != XOOPS_GROUP_ADMIN) { - $form->addElement($debug_mod_checkbox); -} - -$form->addElement($r_block_tray); -$form->addElement($op_hidden); -$form->addElement($fct_hidden); -if (!empty($g_id_value)) { - $g_id_hidden = new icms_form_elements_Hidden("g_id", $g_id_value); - $form->addElement($g_id_hidden); -} -$form->addElement($submit_button); -$form->setRequired($name_text); -$form->display(); // render() does not output the form, just contains the output +/** + * Form for setting group options + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ + * @copyright Copyright (c) 2000 XOOPS.org + * @author modified by UnderDog + * @version SVN: $Id: groupform.php 12313 2013-09-15 21:14:35Z skenow $ + */ + +$name_text = new icms_form_elements_Text(_AM_NAME, "name", 30, 50, $name_value); +$desc_text = new icms_form_elements_Textarea(_AM_DESCRIPTION, "desc", $desc_value); + +$s_cat_checkbox = new icms_form_elements_Checkbox(_AM_SYSTEMRIGHTS, "system_catids[]", $s_cat_value); + +include_once ICMS_MODULES_PATH . '/system/constants.php'; +$admin_dir = ICMS_MODULES_PATH . '/system/admin/'; +$dirlist = icms_core_Filesystem::getDirList($admin_dir); +/* changes to only allow permission admins you already have */ +$gperm = icms::handler('icms_member_groupperm'); +$groups = icms::$user->getGroups(); +foreach ($dirlist as $file) { + if (file_exists(ICMS_MODULES_PATH . '/system/admin/' . $file . '/icms_version.php')) { + include ICMS_MODULES_PATH . '/system/admin/' . $file . '/icms_version.php'; + } elseif (file_exists(ICMS_MODULES_PATH . '/system/admin/' . $file . '/xoops_version.php')) { + include ICMS_MODULES_PATH . '/system/admin/' . $file . '/xoops_version.php'; + } + if (!empty($modversion['category']) + && (count(array_intersect($groups, $gperm->getGroupIds('system_admin', $modversion['category']))) > 0 + || in_array(ICMS_GROUP_ADMIN, $groups)) + ) { + $s_cat_checkbox->addOption($modversion['category'], $modversion['name']); + } + unset($modversion); +} +unset($dirlist); + +$a_mod_checkbox = new icms_form_elements_Checkbox(_AM_ACTIVERIGHTS, "admin_mids[]", $a_mod_value); +$module_handler = icms::handler('icms_module'); +$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('hasadmin', 1)); +$criteria->add(new icms_db_criteria_Item('isactive', 1)); +$criteria->add(new icms_db_criteria_Item('dirname', 'system', '<>')); +/* criteria added to see if the active user can admin the module, do not filter for administrator group (module_admin)*/ +if (!in_array(XOOPS_GROUP_ADMIN, $groups)) { + $a_mod = $gperm->getItemIds('module_admin', $groups); + $criteria->add(new icms_db_criteria_Item('mid', '(' . implode(',', $a_mod) . ')', 'IN')); +} +$a_mod_checkbox->addOptionArray($module_handler->getList($criteria)); + +$r_mod_checkbox = new icms_form_elements_Checkbox(_AM_ACCESSRIGHTS, "read_mids[]", $r_mod_value); +$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('hasmain', 1)); +$criteria->add(new icms_db_criteria_Item('isactive', 1)); +/* criteria added to see if the active user can access the module, do not filter for administrator group (module_read)*/ +if (!in_array(XOOPS_GROUP_ADMIN, $groups)) { + $r_mod = $gperm->getItemIds('module_read', $groups); + $criteria->add(new icms_db_criteria_Item('mid', '(' . implode(',', $r_mod) . ')', 'IN')); +} +$r_mod_checkbox->addOptionArray($module_handler->getList($criteria)); + +$ed_mod_checkbox = new icms_form_elements_Checkbox(_AM_EDPERM, "useeditor_mids[]", $ed_mod_value); +$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('isactive', 1)); +/* criteria added to see where the active user can use the wysiwyg editors (use_wysiwygeditor) + * administrators don't have explicit entries for this, do not filter + */ +if (!in_array(XOOPS_GROUP_ADMIN, $groups)) { + $ed_mod = $gperm->getItemIds('use_wysiwygeditor', $groups); + $criteria->add(new icms_db_criteria_Item('mid', '(' . implode(',', $ed_mod) . ')', 'IN')); +} +$ed_mod_checkbox->addOptionArray($module_handler->getList($criteria)); + +$debug_mod_checkbox = new icms_form_elements_Checkbox(_AM_DEBUG_PERM, "enabledebug_mids[]", $debug_mod_value); +$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('isactive', 1)); +/* criteria added to see where the active user can view the debug mode (enable_debug) + * administrators do not have explicit entries for this, do not filter + */ +if (!in_array(XOOPS_GROUP_ADMIN, $groups)) { + $debug_mod = $gperm->getItemIds('enable_debug', $groups); + $criteria->add(new icms_db_criteria_Item('mid', '(' . implode(',', $debug_mod) . ')', 'IN')); +} +$debug_mod_checkbox->addOptionArray($module_handler->getList($criteria)); + +$group_manager_checkbox = new icms_form_elements_Checkbox(_AM_GROUPMANAGER_PERM, "groupmanager_gids[]", $group_manager_value); +$criteria = new icms_db_criteria_Compo(new icms_db_criteria_Item('isactive', 1)); +$groups = $member_handler->getGroups(); +$gperm_handler = icms::handler('icms_member_groupperm'); + +foreach ($groups as $group) { + if ($gperm_handler->checkRight('group_manager', $group->getVar('groupid'), icms::$user->getGroups())) + $group_manager_checkbox->addOption($group->getVar('groupid'), $group->getVar('name')); +} +$icms_block_handler = icms::handler('icms_view_block'); +$posarr = $icms_block_handler->getBlockPositions(true); +$block_checkbox = array(); +$i = 0; +$groups = icms::$user->getGroups(); +foreach ($posarr as $k=>$v) { + $tit = (defined($posarr[$k]['title'])) ? constant($posarr[$k]['title']) : $posarr[$k]['title']; + $block_checkbox[$i] = new icms_form_elements_Checkbox('' . $tit . '
', "read_bids[]", $r_block_value); + $new_blocks_array = array(); + $blocks_array = $icms_block_handler->getAllBlocks("list", $k); + + /* compare to list of blocks the group can read, do not filter for administrator group */ + if (!in_array(XOOPS_GROUP_ADMIN, $groups)) { + $r_blocks = $gperm->getItemIds('block_read', $groups); + $n_blocks_array = array_intersect_key($blocks_array, array_flip($r_blocks)); + } else { + $n_blocks_array = $blocks_array; + } + foreach ($n_blocks_array as $key=>$value) { + $new_blocks_array[$key] = "" . $value . " (ID: " . $key . ")"; + } + $block_checkbox[$i]->addOptionArray($new_blocks_array); + $i++; +} +$r_block_tray = new icms_form_elements_Tray(_AM_BLOCKRIGHTS, "

"); +foreach ($block_checkbox as $k=>$v) { + $r_block_tray->addElement($block_checkbox[$k]); +} + +$op_hidden = new icms_form_elements_Hidden("op", $op_value); +$fct_hidden = new icms_form_elements_Hidden("fct", "groups"); +$submit_button = new icms_form_elements_Button("", "groupsubmit", $submit_value, "submit"); +$form = new icms_form_Theme($form_title, "groupform", "admin.php", "post", true); +$form->addElement($name_text, TRUE); +$form->addElement($desc_text); +$form->addElement($s_cat_checkbox); + +if (!isset($g_id) || ($g_id != XOOPS_GROUP_ADMIN && $g_id != XOOPS_GROUP_ANONYMOUS)) { + $form->addElement($group_manager_checkbox); +} +$form->addElement($a_mod_checkbox); +$form->addElement($r_mod_checkbox); +if (!isset($g_id) || $g_id != XOOPS_GROUP_ANONYMOUS) { + $form->addElement($ed_mod_checkbox); +} + +if (!isset($g_id) || $g_id != XOOPS_GROUP_ADMIN) { + $form->addElement($debug_mod_checkbox); +} + +$form->addElement($r_block_tray); +$form->addElement($op_hidden); +$form->addElement($fct_hidden); +if (!empty($g_id_value)) { + $g_id_hidden = new icms_form_elements_Hidden("g_id", $g_id_value); + $form->addElement($g_id_hidden); +} +$form->addElement($submit_button); +$form->setRequired($name_text); +$form->display(); // render() does not output the form, just contains the output diff --git a/htdocs/modules/system/admin/groups/xoops_version.php b/htdocs/modules/system/admin/groups/xoops_version.php index a519203be09c..22683ecc431b 100644 --- a/htdocs/modules/system/admin/groups/xoops_version.php +++ b/htdocs/modules/system/admin/groups/xoops_version.php @@ -1,53 +1,53 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of usergroups, versionfile - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package Administration - * @subpackage Groups - * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ - */ -$modversion = array( - 'name' => _MD_AM_ADGS, - 'version' => "", - 'description' => _MD_AM_ADGS_DSC, - 'author' => "", - 'credits' => "", - 'help' => "groups.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "groups.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=groups", - 'category' => XOOPS_SYSTEM_GROUP, - 'group' => _MD_AM_GROUPS_USERSANDGROUPS); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of usergroups, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @subpackage Groups + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ +$modversion = array( + 'name' => _MD_AM_ADGS, + 'version' => "", + 'description' => _MD_AM_ADGS_DSC, + 'author' => "", + 'credits' => "", + 'help' => "groups.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "groups.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=groups", + 'category' => XOOPS_SYSTEM_GROUP, + 'group' => _MD_AM_GROUPS_USERSANDGROUPS); diff --git a/htdocs/modules/system/admin/images/js/imanager.js b/htdocs/modules/system/admin/images/js/imanager.js index 2c9d091de115..2f467be39b73 100644 --- a/htdocs/modules/system/admin/images/js/imanager.js +++ b/htdocs/modules/system/admin/images/js/imanager.js @@ -1,155 +1,155 @@ -function showDiv(type,id){ - divs = document.getElementsByTagName('div'); - for (i=0; i 0){ - for (i=0;i<=filter['args'].length-1;i++){ - var x = i+1; - eval('div_arg'+x).style.display = 'block'; - eval('targ'+x).innerHTML = filter['args'][i]['title']; - eval('larg'+x).innerHTML = filter['args'][i]['descr']; - eval('arg'+x).value = filter['args'][i]['value']; - } - } - } -} - -function filter_preview(id,xurl,img,width,height){ - var filter = xoopsGetElementById('filter'+id).value; - var arg1 = xoopsGetElementById(id+'arg1').value; - var arg2 = xoopsGetElementById(id+'arg2').value; - var arg3 = xoopsGetElementById(id+'arg3').value; - - for (i=0;i<=Filters.length-1;i++){ - if (Filters[i].value == filter){ - var filterdata = Filters[i]; - } - } - - var url = xurl+"/modules/system/admin/images/preview.php?file="+img+"&filter="+filter; - - if (filterdata['args'].length > 0){ - for (i=0;i<=filterdata['args'].length-1;i++){ - var x = i+1; - url = url+'&arg'+x+'='+eval('arg'+x); - } - } - - window.open(url,'preview_image','width='+(width+20)+',height='+(height+20)+',resizable=yes'); +function showDiv(type,id){ + divs = document.getElementsByTagName('div'); + for (i=0; i 0){ + for (i=0;i<=filter['args'].length-1;i++){ + var x = i+1; + eval('div_arg'+x).style.display = 'block'; + eval('targ'+x).innerHTML = filter['args'][i]['title']; + eval('larg'+x).innerHTML = filter['args'][i]['descr']; + eval('arg'+x).value = filter['args'][i]['value']; + } + } + } +} + +function filter_preview(id,xurl,img,width,height){ + var filter = xoopsGetElementById('filter'+id).value; + var arg1 = xoopsGetElementById(id+'arg1').value; + var arg2 = xoopsGetElementById(id+'arg2').value; + var arg3 = xoopsGetElementById(id+'arg3').value; + + for (i=0;i<=Filters.length-1;i++){ + if (Filters[i].value == filter){ + var filterdata = Filters[i]; + } + } + + var url = xurl+"/modules/system/admin/images/preview.php?file="+img+"&filter="+filter; + + if (filterdata['args'].length > 0){ + for (i=0;i<=filterdata['args'].length-1;i++){ + var x = i+1; + url = url+'&arg'+x+'='+eval('arg'+x); + } + } + + window.open(url,'preview_image','width='+(width+20)+',height='+(height+20)+',resizable=yes'); } \ No newline at end of file diff --git a/htdocs/modules/system/admin/images/xoops_version.php b/htdocs/modules/system/admin/images/xoops_version.php index bbb45fcab2ca..0d07eac262b9 100644 --- a/htdocs/modules/system/admin/images/xoops_version.php +++ b/htdocs/modules/system/admin/images/xoops_version.php @@ -1,54 +1,54 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of images, versionfile - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package Administration - * @subpackage Images - * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ - */ - -$modversion = array( - 'name' => _MD_AM_IMAGES, - 'version' => "", - 'description' => _MD_AM_IMAGES_DSC, - 'author' => "", - 'credits' => "The ImpressCMS Project", - 'help' => "images.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "images.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=images", - 'category' => XOOPS_SYSTEM_IMAGE, - 'group' => _MD_AM_GROUPS_MEDIA); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of images, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @subpackage Images + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ + +$modversion = array( + 'name' => _MD_AM_IMAGES, + 'version' => "", + 'description' => _MD_AM_IMAGES_DSC, + 'author' => "", + 'credits' => "The ImpressCMS Project", + 'help' => "images.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "images.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=images", + 'category' => XOOPS_SYSTEM_IMAGE, + 'group' => _MD_AM_GROUPS_MEDIA); diff --git a/htdocs/modules/system/admin/mailusers/xoops_version.php b/htdocs/modules/system/admin/mailusers/xoops_version.php index a68b5a61f0ca..28a83c1d1dea 100644 --- a/htdocs/modules/system/admin/mailusers/xoops_version.php +++ b/htdocs/modules/system/admin/mailusers/xoops_version.php @@ -1,4 +1,4 @@ - _MD_AM_MLUS, - 'version' => "", - 'description' => _MD_AM_MLUS_DSC, - 'author' => "Kazumi Ono
( http://www.myweb.ne.jp/ )", - 'credits' => "", - 'help' => "mailusers.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "mailusers.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=mailusers", - 'category' => XOOPS_SYSTEM_MAILU, +/** + * Administration of mailusers, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package Administration + * @subpackage Users + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ + +$modversion = array( + 'name' => _MD_AM_MLUS, + 'version' => "", + 'description' => _MD_AM_MLUS_DSC, + 'author' => "Kazumi Ono
( http://www.myweb.ne.jp/ )", + 'credits' => "", + 'help' => "mailusers.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "mailusers.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=mailusers", + 'category' => XOOPS_SYSTEM_MAILU, 'group' => _MD_AM_GROUPS_USERSANDGROUPS); \ No newline at end of file diff --git a/htdocs/modules/system/admin/mimetype/xoops_version.php b/htdocs/modules/system/admin/mimetype/xoops_version.php index bf040d5d1505..c4a7b7d2f80e 100644 --- a/htdocs/modules/system/admin/mimetype/xoops_version.php +++ b/htdocs/modules/system/admin/mimetype/xoops_version.php @@ -1,27 +1,27 @@ - - * @version SVN: $Id: xoops_version.php 9853 2010-02-23 17:44:27Z skenow $ - */ - -$modversion = array( - 'name' => _MD_AM_MIMETYPES, - 'version' => "1.0", - 'description' => _MD_AM_MIMETYPES_DSC, - 'author' => "Sina Asghari (aka stranger) ", - 'credits' => "The ImpressCMS Project", - 'help' => "", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "mimetype.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=mimetype", - 'category' => XOOPS_SYSTEM_MIMETYPES, + + * @version SVN: $Id: xoops_version.php 9853 2010-02-23 17:44:27Z skenow $ + */ + +$modversion = array( + 'name' => _MD_AM_MIMETYPES, + 'version' => "1.0", + 'description' => _MD_AM_MIMETYPES_DSC, + 'author' => "Sina Asghari (aka stranger) ", + 'credits' => "The ImpressCMS Project", + 'help' => "", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "mimetype.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=mimetype", + 'category' => XOOPS_SYSTEM_MIMETYPES, 'group' => _MD_AM_GROUPS_MEDIA); \ No newline at end of file diff --git a/htdocs/modules/system/admin/modulesadmin/xoops_version.php b/htdocs/modules/system/admin/modulesadmin/xoops_version.php index 2a6017013762..ea1c807c05a6 100644 --- a/htdocs/modules/system/admin/modulesadmin/xoops_version.php +++ b/htdocs/modules/system/admin/modulesadmin/xoops_version.php @@ -1,53 +1,53 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of modules, versionfile - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package System - * @subpackage Modules - * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ - */ -$modversion = array( - 'name' => _MD_AM_MDAD, - 'version' => "", - 'description' => _MD_AM_MDAD_DSC, - 'author' => "Kazumi Ono
( http://www.mywebaddons.com/ )", - 'credits' => "", - 'help' => "modulesadmin.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "modulesadmin.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=modulesadmin", - 'category' => XOOPS_SYSTEM_MODULE, - 'group' => _MD_AM_GROUPS_SITECONFIGURATION); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of modules, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package System + * @subpackage Modules + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ +$modversion = array( + 'name' => _MD_AM_MDAD, + 'version' => "", + 'description' => _MD_AM_MDAD_DSC, + 'author' => "Kazumi Ono
( http://www.mywebaddons.com/ )", + 'credits' => "", + 'help' => "modulesadmin.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "modulesadmin.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=modulesadmin", + 'category' => XOOPS_SYSTEM_MODULE, + 'group' => _MD_AM_GROUPS_SITECONFIGURATION); diff --git a/htdocs/modules/system/admin/pages/xoops_version.php b/htdocs/modules/system/admin/pages/xoops_version.php index 21b943cbfe76..ec3b85058c04 100644 --- a/htdocs/modules/system/admin/pages/xoops_version.php +++ b/htdocs/modules/system/admin/pages/xoops_version.php @@ -1,27 +1,27 @@ - -* @version SVN: $Id: xoops_version.php 11022 2011-02-15 01:29:18Z skenow $ -*/ - -$modversion = array( - 'name' => _MD_AM_PAGES, - 'version' => "1", - 'description' => _MD_AM_PAGES_DSC, - 'author' => "Rodrigo Pereira Lima aka TheRplima", - 'credits' => "The ImpressCMS Project", - 'help' => "pages.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "pages.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=pages", - 'category' => XOOPS_SYSTEM_PAGES, + +* @version SVN: $Id: xoops_version.php 11022 2011-02-15 01:29:18Z skenow $ +*/ + +$modversion = array( + 'name' => _MD_AM_PAGES, + 'version' => "1", + 'description' => _MD_AM_PAGES_DSC, + 'author' => "Rodrigo Pereira Lima aka TheRplima", + 'credits' => "The ImpressCMS Project", + 'help' => "pages.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "pages.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=pages", + 'category' => XOOPS_SYSTEM_PAGES, 'group' => _MD_AM_GROUPS_CONTENT); \ No newline at end of file diff --git a/htdocs/modules/system/admin/preferences/xoops_version.php b/htdocs/modules/system/admin/preferences/xoops_version.php index 5d29183e3a47..4eb73fd36027 100644 --- a/htdocs/modules/system/admin/preferences/xoops_version.php +++ b/htdocs/modules/system/admin/preferences/xoops_version.php @@ -1,53 +1,53 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** -* Administration of preferences, versionfile -* -* @copyright http://www.impresscms.org/ The ImpressCMS Project -* @license LICENSE.txt -* @package System -* @subpackage Preferences -* @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ -*/ -$modversion = array( - 'name' => _MD_AM_PREF, - 'version' => "", - 'description' => _MD_AM_PREF_DSC, - 'author' => "", - 'credits' => "The ImpressCMS Project", - 'help' => "preferences.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "pref.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=preferences", - 'category' => XOOPS_SYSTEM_PREF, - 'group' => _MD_AM_GROUPS_SITECONFIGURATION); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** +* Administration of preferences, versionfile +* +* @copyright http://www.impresscms.org/ The ImpressCMS Project +* @license LICENSE.txt +* @package System +* @subpackage Preferences +* @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ +*/ +$modversion = array( + 'name' => _MD_AM_PREF, + 'version' => "", + 'description' => _MD_AM_PREF_DSC, + 'author' => "", + 'credits' => "The ImpressCMS Project", + 'help' => "preferences.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "pref.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=preferences", + 'category' => XOOPS_SYSTEM_PREF, + 'group' => _MD_AM_GROUPS_SITECONFIGURATION); diff --git a/htdocs/modules/system/admin/rating/class/rating.php b/htdocs/modules/system/admin/rating/class/rating.php index cd30948961d1..e07303494641 100644 --- a/htdocs/modules/system/admin/rating/class/rating.php +++ b/htdocs/modules/system/admin/rating/class/rating.php @@ -1,229 +1,229 @@ - - * @version SVN: $Id: rating.php 11282 2011-06-23 14:44:34Z phoenyx $ - */ - -/** - * Rating object - * @package System - * @subpackage Ratings - */ -class SystemRating extends icms_ipf_Object { - - /** */ - public $_modulePlugin = FALSE; - - /** - * Constructor for the ratings object - * @param object $handler - */ - public function __construct(&$handler) { - parent::__construct($handler); - - $this->quickInitVar('ratingid', XOBJ_DTYPE_INT, TRUE); - $this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_RATING_DIRNAME); - $this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_RATING_ITEM); - $this->quickInitVar('itemid', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_ITEMID); - $this->quickInitVar('uid', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_UID); - $this->quickInitVar('date', XOBJ_DTYPE_LTIME, TRUE, _CO_ICMS_RATING_DATE); - $this->quickInitVar('rate', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_RATE); - - $this->initNonPersistableVar('name', XOBJ_DTYPE_TXTBOX, 'user', _CO_ICMS_RATING_NAME); - $this->setControl('dirname', array('method' => 'getModuleList', 'onSelect' => 'submit')); - $this->setControl('item', array('object' => &$this, 'method' => 'getItemList')); - $this->setControl('uid', 'user'); - $this->setControl('rate', array('method' => 'getRateList')); - } - - /** - * Custom accessors for properties - * - * @param string $key - * @param string $format - * @return mixed - */ - public function getVar($key, $format = 's') { - if ($format == 's' && in_array($key, array())) { - return call_user_func(array($this, $key)); - } - return parent::getVar($key, $format); - } - - /** - * Retrieve the username associated with a rating - * @return string - */ - public function name() { - return icms_member_user_Handler::getUserLink($this->getVar('uid', 'e'), TRUE, array()); - } - - /** - * Accessor for the dirname property - * @return string - */ - public function dirname() { - $moduleArray = $this->handler->getModuleList(); - return $moduleArray[$this->getVar('dirname', 'n')]; - } - - /** - * Enter description here ... - * @return - */ - public function getItemList() { - $plugin = $this->getModulePlugin(); - return $plugin->getItemList(); - } - - /** - * Retrieve the value of the rating as a link - * @return string - */ - public function getItemValue() { - $moduleUrl = ICMS_MODULES_URL . '/' . $this->getVar('dirname', 'n') . '/'; - $plugin = $this->getModulePlugin(); - $pluginItemInfo = $plugin->getItemInfo($this->getVar('item')); - if (!$pluginItemInfo) { - return ''; - } - $itemPath = sprintf($pluginItemInfo['url'], $this->getVar('itemid')); - $ret = '' . $pluginItemInfo['caption'] . ''; - return $ret; - } - - /** - * Accessor for the rate property - * @return int - */ - public function getRateValue() { - return $this->getVar('rate'); - } - - /** - * Create a link to the user profile associated with the rating - * - * @return string - * @see icms_member_user_Handler::getUserLink - */ - public function getUnameValue() { - return icms_member_user_Handler::getUserLink($this->getVar('uid')); - } - - /** - * Enter description here ... - */ - public function getModulePlugin() { - if (!$this->_modulePlugin) { - $this->_modulePlugin = $this->handler->pluginsObject->getPlugin('rating', $this->getVar('dirname', 'n')); - } - return $this->_modulePlugin; - } -} - -/** - * Handler for the ratings object - * @package System - * @subpackage Ratings - */ -class SystemRatingHandler extends icms_ipf_Handler { - - public $_rateOptions = array(); - public $_moduleList = FALSE; - public $pluginsObject; - - /** - * Constructor for the ratings handler - * - * @param object $db - */ - public function __construct($db) { - parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'system'); - $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; - - $this->_rateOptions[1] = 1; - $this->_rateOptions[2] = 2; - $this->_rateOptions[3] = 3; - $this->_rateOptions[4] = 4; - $this->_rateOptions[5] = 5; - - $this->pluginsObject = new icms_plugins_Handler(); - } - - /** - * Retrieve a list of modules enabling ratings - * @return array - */ - public function getModuleList() { - if (!$this->_moduleList) { - $moduleArray = $this->pluginsObject->getPluginsArray('rating'); - $this->_moduleList[0] = _CO_ICMS_MAKE_SELECTION; - foreach ($moduleArray as $k=>$v) { - $this->_moduleList[$k] = $v; - } - } - return $this->_moduleList; - } - - /** - * Accessor for the rate property - * @return array Rating options - */ - public function getRateList() { - return $this->_rateOptions; - } - - /** - * Get the average rating for an item - * - * @param int $itemid - * @param str $dirname - * @param str $item - * @return int|array 0 if there is no rating; an array containing the average and the total ratings for the item - */ - public function getRatingAverageByItemId($itemid, $dirname, $item) { - $itemid = (int) $itemid; - $sql = "SELECT AVG(rate), COUNT(ratingid) FROM " . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; - $result = $this->db->query($sql); - if (!$result) { - return 0; - } - list($average, $sum) = $this->db->fetchRow($result); - $ret['average'] = isset($average) ? $average : 0; - $ret['sum'] = isset($sum) ? $sum : 0; - return $ret; - } - - /** - * Determine if a user has already rated an item - * - * @param str $item - * @param int $itemid - * @param str $dirname - * @param int $uid - * @return bool|array - */ - public function already_rated($item, $itemid, $dirname, $uid) { - - $criteria = new icms_db_criteria_Compo(); - $criteria->add(new icms_db_criteria_Item('item', $item)); - $criteria->add(new icms_db_criteria_Item('itemid', (int) $itemid)); - $criteria->add(new icms_db_criteria_Item('dirname', $dirname)); - $criteria->add(new icms_db_criteria_Item('user.uid', (int) $uid)); - - $ret = $this->getObjects($criteria); - - if (!$ret) { - return FALSE; - } else { - return $ret[0]; - } - } -} + + * @version SVN: $Id: rating.php 11282 2011-06-23 14:44:34Z phoenyx $ + */ + +/** + * Rating object + * @package System + * @subpackage Ratings + */ +class SystemRating extends icms_ipf_Object { + + /** */ + public $_modulePlugin = FALSE; + + /** + * Constructor for the ratings object + * @param object $handler + */ + public function __construct(&$handler) { + parent::__construct($handler); + + $this->quickInitVar('ratingid', XOBJ_DTYPE_INT, TRUE); + $this->quickInitVar('dirname', XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_RATING_DIRNAME); + $this->quickInitVar('item', XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_RATING_ITEM); + $this->quickInitVar('itemid', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_ITEMID); + $this->quickInitVar('uid', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_UID); + $this->quickInitVar('date', XOBJ_DTYPE_LTIME, TRUE, _CO_ICMS_RATING_DATE); + $this->quickInitVar('rate', XOBJ_DTYPE_INT, TRUE, _CO_ICMS_RATING_RATE); + + $this->initNonPersistableVar('name', XOBJ_DTYPE_TXTBOX, 'user', _CO_ICMS_RATING_NAME); + $this->setControl('dirname', array('method' => 'getModuleList', 'onSelect' => 'submit')); + $this->setControl('item', array('object' => &$this, 'method' => 'getItemList')); + $this->setControl('uid', 'user'); + $this->setControl('rate', array('method' => 'getRateList')); + } + + /** + * Custom accessors for properties + * + * @param string $key + * @param string $format + * @return mixed + */ + public function getVar($key, $format = 's') { + if ($format == 's' && in_array($key, array())) { + return call_user_func(array($this, $key)); + } + return parent::getVar($key, $format); + } + + /** + * Retrieve the username associated with a rating + * @return string + */ + public function name() { + return icms_member_user_Handler::getUserLink($this->getVar('uid', 'e'), TRUE, array()); + } + + /** + * Accessor for the dirname property + * @return string + */ + public function dirname() { + $moduleArray = $this->handler->getModuleList(); + return $moduleArray[$this->getVar('dirname', 'n')]; + } + + /** + * Enter description here ... + * @return + */ + public function getItemList() { + $plugin = $this->getModulePlugin(); + return $plugin->getItemList(); + } + + /** + * Retrieve the value of the rating as a link + * @return string + */ + public function getItemValue() { + $moduleUrl = ICMS_MODULES_URL . '/' . $this->getVar('dirname', 'n') . '/'; + $plugin = $this->getModulePlugin(); + $pluginItemInfo = $plugin->getItemInfo($this->getVar('item')); + if (!$pluginItemInfo) { + return ''; + } + $itemPath = sprintf($pluginItemInfo['url'], $this->getVar('itemid')); + $ret = '' . $pluginItemInfo['caption'] . ''; + return $ret; + } + + /** + * Accessor for the rate property + * @return int + */ + public function getRateValue() { + return $this->getVar('rate'); + } + + /** + * Create a link to the user profile associated with the rating + * + * @return string + * @see icms_member_user_Handler::getUserLink + */ + public function getUnameValue() { + return icms_member_user_Handler::getUserLink($this->getVar('uid')); + } + + /** + * Enter description here ... + */ + public function getModulePlugin() { + if (!$this->_modulePlugin) { + $this->_modulePlugin = $this->handler->pluginsObject->getPlugin('rating', $this->getVar('dirname', 'n')); + } + return $this->_modulePlugin; + } +} + +/** + * Handler for the ratings object + * @package System + * @subpackage Ratings + */ +class SystemRatingHandler extends icms_ipf_Handler { + + public $_rateOptions = array(); + public $_moduleList = FALSE; + public $pluginsObject; + + /** + * Constructor for the ratings handler + * + * @param object $db + */ + public function __construct($db) { + parent::__construct($db, 'rating', 'ratingid', 'rate', '', 'system'); + $this->generalSQL = 'SELECT * FROM ' . $this->table . ' AS ' . $this->_itemname . ' INNER JOIN ' . $this->db->prefix('users') . ' AS user ON ' . $this->_itemname . '.uid=user.uid'; + + $this->_rateOptions[1] = 1; + $this->_rateOptions[2] = 2; + $this->_rateOptions[3] = 3; + $this->_rateOptions[4] = 4; + $this->_rateOptions[5] = 5; + + $this->pluginsObject = new icms_plugins_Handler(); + } + + /** + * Retrieve a list of modules enabling ratings + * @return array + */ + public function getModuleList() { + if (!$this->_moduleList) { + $moduleArray = $this->pluginsObject->getPluginsArray('rating'); + $this->_moduleList[0] = _CO_ICMS_MAKE_SELECTION; + foreach ($moduleArray as $k=>$v) { + $this->_moduleList[$k] = $v; + } + } + return $this->_moduleList; + } + + /** + * Accessor for the rate property + * @return array Rating options + */ + public function getRateList() { + return $this->_rateOptions; + } + + /** + * Get the average rating for an item + * + * @param int $itemid + * @param str $dirname + * @param str $item + * @return int|array 0 if there is no rating; an array containing the average and the total ratings for the item + */ + public function getRatingAverageByItemId($itemid, $dirname, $item) { + $itemid = (int) $itemid; + $sql = "SELECT AVG(rate), COUNT(ratingid) FROM " . $this->table . " WHERE itemid=$itemid AND dirname='$dirname' AND item='$item' GROUP BY itemid"; + $result = $this->db->query($sql); + if (!$result) { + return 0; + } + list($average, $sum) = $this->db->fetchRow($result); + $ret['average'] = isset($average) ? $average : 0; + $ret['sum'] = isset($sum) ? $sum : 0; + return $ret; + } + + /** + * Determine if a user has already rated an item + * + * @param str $item + * @param int $itemid + * @param str $dirname + * @param int $uid + * @return bool|array + */ + public function already_rated($item, $itemid, $dirname, $uid) { + + $criteria = new icms_db_criteria_Compo(); + $criteria->add(new icms_db_criteria_Item('item', $item)); + $criteria->add(new icms_db_criteria_Item('itemid', (int) $itemid)); + $criteria->add(new icms_db_criteria_Item('dirname', $dirname)); + $criteria->add(new icms_db_criteria_Item('user.uid', (int) $uid)); + + $ret = $this->getObjects($criteria); + + if (!$ret) { + return FALSE; + } else { + return $ret[0]; + } + } +} diff --git a/htdocs/modules/system/admin/rating/xoops_version.php b/htdocs/modules/system/admin/rating/xoops_version.php index abb9ce5d5171..3a67187119c7 100644 --- a/htdocs/modules/system/admin/rating/xoops_version.php +++ b/htdocs/modules/system/admin/rating/xoops_version.php @@ -1,27 +1,27 @@ - - * @version SVN: $Id: xoops_version.php 11030 2011-02-17 16:54:10Z skenow $ - */ - -$modversion = array( - 'name' => _MD_AM_RATINGS, - 'version' => "1.0", - 'description' => _MD_AM_RATINGS_DSC, - 'author' => "Sina Asghari (aka stranger) ", - 'credits' => "The ImpressCMS Projects", - 'help' => "", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "rating.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=rating", - 'category' => XOOPS_SYSTEM_RATINGS, + + * @version SVN: $Id: xoops_version.php 11030 2011-02-17 16:54:10Z skenow $ + */ + +$modversion = array( + 'name' => _MD_AM_RATINGS, + 'version' => "1.0", + 'description' => _MD_AM_RATINGS_DSC, + 'author' => "Sina Asghari (aka stranger) ", + 'credits' => "The ImpressCMS Projects", + 'help' => "", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "rating.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=rating", + 'category' => XOOPS_SYSTEM_RATINGS, 'group' => _MD_AM_GROUPS_CONTENT); \ No newline at end of file diff --git a/htdocs/modules/system/admin/smilies/smileform.php b/htdocs/modules/system/admin/smilies/smileform.php index 171c3133f449..668f8018c582 100644 --- a/htdocs/modules/system/admin/smilies/smileform.php +++ b/htdocs/modules/system/admin/smilies/smileform.php @@ -1,54 +1,54 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of smilies, form file - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package System - * @subpackage Smilies - * @version SVN: $Id: smileform.php 12313 2013-09-15 21:14:35Z skenow $ - */ -$smile_form = new icms_form_Theme($smiles['smile_form'], 'smileform', 'admin.php', 'post', TRUE); -$smile_form->setExtra('enctype="multipart/form-data"'); -$smile_form->addElement(new icms_form_elements_Text(_AM_SMILECODE, 'smile_code', 26, 25, $smiles['smile_code']), TRUE); -$smile_form->addElement(new icms_form_elements_Text(_AM_SMILEEMOTION, 'smile_desc', 26, 25, $smiles['smile_desc']), TRUE); -$smile_select = new icms_form_elements_File('', 'smile_url', 5000000); -$smile_label = new icms_form_elements_Label('', ''); -$smile_tray = new icms_form_elements_Tray(_IMAGEFILE . ' '); -$smile_tray->addElement($smile_select); -$smile_tray->addElement($smile_label); -$smile_form->addElement($smile_tray); -$smile_form->addElement(new icms_form_elements_Radioyn(_AM_DISPLAYF, 'smile_display', $smiles['smile_display'])); -$smile_form->addElement(new icms_form_elements_Hidden('id', $smiles['id'])); -$smile_form->addElement(new icms_form_elements_Hidden('op', $smiles['op'])); -$smile_form->addElement(new icms_form_elements_Hidden('fct', 'smilies')); -$smile_form->addElement(new icms_form_elements_Button('', 'submit', _SUBMIT, 'submit')); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of smilies, form file + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package System + * @subpackage Smilies + * @version SVN: $Id: smileform.php 12313 2013-09-15 21:14:35Z skenow $ + */ +$smile_form = new icms_form_Theme($smiles['smile_form'], 'smileform', 'admin.php', 'post', TRUE); +$smile_form->setExtra('enctype="multipart/form-data"'); +$smile_form->addElement(new icms_form_elements_Text(_AM_SMILECODE, 'smile_code', 26, 25, $smiles['smile_code']), TRUE); +$smile_form->addElement(new icms_form_elements_Text(_AM_SMILEEMOTION, 'smile_desc', 26, 25, $smiles['smile_desc']), TRUE); +$smile_select = new icms_form_elements_File('', 'smile_url', 5000000); +$smile_label = new icms_form_elements_Label('', ''); +$smile_tray = new icms_form_elements_Tray(_IMAGEFILE . ' '); +$smile_tray->addElement($smile_select); +$smile_tray->addElement($smile_label); +$smile_form->addElement($smile_tray); +$smile_form->addElement(new icms_form_elements_Radioyn(_AM_DISPLAYF, 'smile_display', $smiles['smile_display'])); +$smile_form->addElement(new icms_form_elements_Hidden('id', $smiles['id'])); +$smile_form->addElement(new icms_form_elements_Hidden('op', $smiles['op'])); +$smile_form->addElement(new icms_form_elements_Hidden('fct', 'smilies')); +$smile_form->addElement(new icms_form_elements_Button('', 'submit', _SUBMIT, 'submit')); diff --git a/htdocs/modules/system/admin/smilies/xoops_version.php b/htdocs/modules/system/admin/smilies/xoops_version.php index d3b532b705f0..c5efcec63a23 100644 --- a/htdocs/modules/system/admin/smilies/xoops_version.php +++ b/htdocs/modules/system/admin/smilies/xoops_version.php @@ -1,53 +1,53 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of smilies, versionfile - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package System - * @subpackage Smilies - * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ - */ -$modversion = array( - 'name' => _MD_AM_SMLS, - 'version' => "", - 'description' => _MD_AM_SMLS_DSC, - 'author' => "", - 'credits' => "The MPN SE Project", - 'help' => "smilies.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "smiles.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=smilies", - 'category' => XOOPS_SYSTEM_SMILE, - 'group' => _MD_AM_GROUPS_CONTENT); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of smilies, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package System + * @subpackage Smilies + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ +$modversion = array( + 'name' => _MD_AM_SMLS, + 'version' => "", + 'description' => _MD_AM_SMLS_DSC, + 'author' => "", + 'credits' => "The MPN SE Project", + 'help' => "smilies.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "smiles.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=smilies", + 'category' => XOOPS_SYSTEM_SMILE, + 'group' => _MD_AM_GROUPS_CONTENT); diff --git a/htdocs/modules/system/admin/tplsets/tplform.php b/htdocs/modules/system/admin/tplsets/tplform.php index f04e4f8b081a..fd2f90a425a7 100644 --- a/htdocs/modules/system/admin/tplsets/tplform.php +++ b/htdocs/modules/system/admin/tplsets/tplform.php @@ -1,71 +1,71 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of template sets, form file - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package System - * @subpackage Template Sets - * @version SVN: $Id: tplform.php 12313 2013-09-15 21:14:35Z skenow $ - */ -if ($tform['tpl_tplset'] != 'default') { - $form = new icms_form_Theme(_MD_EDITTEMPLATE, 'template_form', 'admin.php', 'post', TRUE); -} else { - $form = new icms_form_Theme(_MD_VIEWTEMPLATE, 'template_form', 'admin.php', 'post', TRUE); -} -$form->addElement(new icms_form_elements_Label(_MD_FILENAME, $tform['tpl_file'])); -$form->addElement(new icms_form_elements_Label(_MD_FILEDESC, $tform['tpl_desc'])); -$form->addElement(new icms_form_elements_Label(_MD_LASTMOD, formatTimestamp($tform['tpl_lastmodified'], 'l'))); -$config = array( - 'name' => 'html', - 'value' => $tform['tpl_source'], - 'language' => _LANGCODE, - 'width' => '100%', - 'height' => '400px', - 'syntax' => 'html'); -if ($tform['tpl_tplset'] == 'default') $config["is_editable"] = FALSE; -$tpl_src = icms_plugins_EditorHandler::getInstance('source')->get($icmsConfig['sourceeditor_default'], $config); -$tpl_src->setCaption(_MD_FILEHTML); -$form->addElement($tpl_src); -$form->addElement(new icms_form_elements_Hidden('id', $tform['tpl_id'])); -$form->addElement(new icms_form_elements_Hidden('op', 'edittpl_go')); -$form->addElement(new icms_form_elements_Hidden('redirect', 'edittpl')); -$form->addElement(new icms_form_elements_Hidden('fct', 'tplsets')); -$form->addElement(new icms_form_elements_Hidden('moddir', $tform['tpl_module'])); -if ($tform['tpl_tplset'] != 'default') { - $button_tray = new icms_form_elements_Tray(''); - $button_tray->addElement(new icms_form_elements_Button('', 'previewtpl', _PREVIEW, 'submit')); - $button_tray->addElement(new icms_form_elements_Button('', 'submittpl', _SUBMIT, 'submit')); - $form->addElement($button_tray); -} else { - $form->addElement(new icms_form_elements_Button('', 'previewtpl', _MD_VIEW, 'submit')); -} + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of template sets, form file + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package System + * @subpackage Template Sets + * @version SVN: $Id: tplform.php 12313 2013-09-15 21:14:35Z skenow $ + */ +if ($tform['tpl_tplset'] != 'default') { + $form = new icms_form_Theme(_MD_EDITTEMPLATE, 'template_form', 'admin.php', 'post', TRUE); +} else { + $form = new icms_form_Theme(_MD_VIEWTEMPLATE, 'template_form', 'admin.php', 'post', TRUE); +} +$form->addElement(new icms_form_elements_Label(_MD_FILENAME, $tform['tpl_file'])); +$form->addElement(new icms_form_elements_Label(_MD_FILEDESC, $tform['tpl_desc'])); +$form->addElement(new icms_form_elements_Label(_MD_LASTMOD, formatTimestamp($tform['tpl_lastmodified'], 'l'))); +$config = array( + 'name' => 'html', + 'value' => $tform['tpl_source'], + 'language' => _LANGCODE, + 'width' => '100%', + 'height' => '400px', + 'syntax' => 'html'); +if ($tform['tpl_tplset'] == 'default') $config["is_editable"] = FALSE; +$tpl_src = icms_plugins_EditorHandler::getInstance('source')->get($icmsConfig['sourceeditor_default'], $config); +$tpl_src->setCaption(_MD_FILEHTML); +$form->addElement($tpl_src); +$form->addElement(new icms_form_elements_Hidden('id', $tform['tpl_id'])); +$form->addElement(new icms_form_elements_Hidden('op', 'edittpl_go')); +$form->addElement(new icms_form_elements_Hidden('redirect', 'edittpl')); +$form->addElement(new icms_form_elements_Hidden('fct', 'tplsets')); +$form->addElement(new icms_form_elements_Hidden('moddir', $tform['tpl_module'])); +if ($tform['tpl_tplset'] != 'default') { + $button_tray = new icms_form_elements_Tray(''); + $button_tray->addElement(new icms_form_elements_Button('', 'previewtpl', _PREVIEW, 'submit')); + $button_tray->addElement(new icms_form_elements_Button('', 'submittpl', _SUBMIT, 'submit')); + $form->addElement($button_tray); +} else { + $form->addElement(new icms_form_elements_Button('', 'previewtpl', _MD_VIEW, 'submit')); +} diff --git a/htdocs/modules/system/admin/tplsets/xoops_version.php b/htdocs/modules/system/admin/tplsets/xoops_version.php index 5bc69c539b14..6b614d22a252 100644 --- a/htdocs/modules/system/admin/tplsets/xoops_version.php +++ b/htdocs/modules/system/admin/tplsets/xoops_version.php @@ -1,53 +1,53 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of template sets, versionfile - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package System - * @subpackage Template Sets - * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ - */ -$modversion = array( - 'name' => _MD_AM_TPLSETS, - 'version' => "", - 'description' => _MD_AM_TPLSETS_DSC, - 'author' => "", - 'credits' => "The ImpressCMS Project", - 'help' => "tplsets.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "tplsets.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=tplsets", - 'category' => XOOPS_SYSTEM_TPLSET, - 'group' => _MD_AM_GROUPS_LAYOUT); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of template sets, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package System + * @subpackage Template Sets + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ +$modversion = array( + 'name' => _MD_AM_TPLSETS, + 'version' => "", + 'description' => _MD_AM_TPLSETS_DSC, + 'author' => "", + 'credits' => "The ImpressCMS Project", + 'help' => "tplsets.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "tplsets.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=tplsets", + 'category' => XOOPS_SYSTEM_TPLSET, + 'group' => _MD_AM_GROUPS_LAYOUT); diff --git a/htdocs/modules/system/admin/userrank/class/userrank.php b/htdocs/modules/system/admin/userrank/class/userrank.php index 264d575fa174..049739abf0df 100644 --- a/htdocs/modules/system/admin/userrank/class/userrank.php +++ b/htdocs/modules/system/admin/userrank/class/userrank.php @@ -1,166 +1,166 @@ - - * @version SVN: $Id: userrank.php 12310 2013-09-13 21:33:58Z skenow $ - */ - -defined("ICMS_ROOT_PATH") or die ("ImpressCMS root path not defined"); - -icms_loadLanguageFile("system", "common"); -icms_loadLanguageFile("system", "userrank", TRUE); - -/** - * Ranks to assign members - * - * @package System - * @subpackage Users - */ -class SystemUserrank extends icms_ipf_Object { - - /** */ - public $content = FALSE; - - /** - * Create a new instance of the userrank object - * - * @param object $handler - */ - public function __construct(&$handler) { - parent::__construct($handler); - - $this->quickInitVar("rank_id", XOBJ_DTYPE_INT, TRUE); - $this->quickInitVar("rank_title", XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_USERRANK_RANK_TITLE, _CO_ICMS_USERRANK_RANK_TITLE_DSC); - $this->quickInitVar("rank_min", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_MIN, _CO_ICMS_USERRANK_RANK_MIN_DSC); - $this->quickInitVar("rank_max", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_MAX, _CO_ICMS_USERRANK_RANK_MAX_DSC); - $this->quickInitVar("rank_special", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_SPECIAL, _CO_ICMS_USERRANK_RANK_SPECIAL_DSC); - $this->quickInitVar("rank_image", XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_USERRANK_RANK_IMAGE, _CO_ICMS_USERRANK_RANK_IMAGE_DSC); - - $this->setControl("rank_special", "yesno"); - $this->setControl("rank_image", "image"); - } - - /** - * (non-PHPdoc) - * @see htdocs/libraries/icms/ipf/icms_ipf_Object::getVar() - */ - public function getVar($key, $format = "s") { - if ($format == "s" && in_array($key, array())) { - return call_user_func(array($this, $key)); - } - return parent::getVar($key, $format); - } - - /** - * Create a link for cloning the object - * @return str - */ - public function getCloneLink() { - $ret = '' . _CO_ICMS_CUSTOMTAG_CLONE . ''; - return $ret; - } - - /** - * Create a link to the image for the rank - * @return str - */ - public function getRankPicture() { - $ret = ''; - return $ret; - } - - /** - * Accessor for the rank_title property - * @return str - */ - public function getRankTitle() { - $ret = $this->getVar("rank_title"); - return $ret; - } -} - -/** - * Handler for the user ranks object - * - * @package System - * @subpackage Users - */ -class SystemUserrankHandler extends icms_ipf_Handler { - - /** */ - public $objects = FALSE; - - /** - * Create a new instance of the handler - * - * @param object $db - */ - public function __construct($db) { - global $icmsConfigUser; - parent::__construct($db, "userrank", "rank_id", "rank_title", "", "system"); - $this->table = $this->db->prefix("ranks"); - $this->enableUpload(array("image/gif", "image/jpeg", "image/pjpeg", "image/x-png", "image/png"), $icmsConfigUser["rank_maxsize"], $icmsConfigUser["rank_width"], $icmsConfigUser["rank_height"]); - } - - /** - * - * - * @param int $rank_id - * @param int $posts - * @return array - */ - public function getRank($rank_id = 0, $posts = 0) { - $rank_id = (int) $rank_id; - $posts = (int) $posts; - - $criteria = new icms_db_criteria_Compo(); - if ($rank_id != 0) { - $criteria->add(new icms_db_criteria_Item("rank_id", $rank_id)); - } else { - $criteria->add(new icms_db_criteria_Item("rank_min", $posts, "<=")); - $criteria->add(new icms_db_criteria_Item("rank_max", $posts, ">=")); - $criteria->add(new icms_db_criteria_Item("rank_special", "0")); - } - - $ranks = $this->getObjects($criteria); - if (count($ranks) != 1) { - $rank = array( - "id" => 0, - "title" => "", - "image" => ICMS_UPLOAD_URL . "blank.gif"); - } else { - $rank = array( - "id" => $rank_id, - "title" => $ranks[0]->getVar("rank_title"), - "image" => $this->getImageUrl() . $ranks[0]->getVar("rank_image")); - } - - return $rank; - } - - /** - * Relocate images for ranks from previous location - * @return bool - */ - public function MoveAllRanksImagesToProperPath() { - $sql = "SELECT rank_image FROM " . $this->table; - $Query = $this->query($sql, FALSE); - for ($i = 0; $i < count($Query); $i++) { - $values[] = $Query[$i]["rank_image"]; - } - - foreach ($values as $value) { - if (file_exists(ICMS_UPLOAD_PATH . "/" . $value)) { - icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . "/" . $value, $this->getImagePath() . $value); - } - } - - return TRUE; - } -} + + * @version SVN: $Id: userrank.php 12310 2013-09-13 21:33:58Z skenow $ + */ + +defined("ICMS_ROOT_PATH") or die ("ImpressCMS root path not defined"); + +icms_loadLanguageFile("system", "common"); +icms_loadLanguageFile("system", "userrank", TRUE); + +/** + * Ranks to assign members + * + * @package System + * @subpackage Users + */ +class SystemUserrank extends icms_ipf_Object { + + /** */ + public $content = FALSE; + + /** + * Create a new instance of the userrank object + * + * @param object $handler + */ + public function __construct(&$handler) { + parent::__construct($handler); + + $this->quickInitVar("rank_id", XOBJ_DTYPE_INT, TRUE); + $this->quickInitVar("rank_title", XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_USERRANK_RANK_TITLE, _CO_ICMS_USERRANK_RANK_TITLE_DSC); + $this->quickInitVar("rank_min", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_MIN, _CO_ICMS_USERRANK_RANK_MIN_DSC); + $this->quickInitVar("rank_max", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_MAX, _CO_ICMS_USERRANK_RANK_MAX_DSC); + $this->quickInitVar("rank_special", XOBJ_DTYPE_INT, TRUE, _CO_ICMS_USERRANK_RANK_SPECIAL, _CO_ICMS_USERRANK_RANK_SPECIAL_DSC); + $this->quickInitVar("rank_image", XOBJ_DTYPE_TXTBOX, TRUE, _CO_ICMS_USERRANK_RANK_IMAGE, _CO_ICMS_USERRANK_RANK_IMAGE_DSC); + + $this->setControl("rank_special", "yesno"); + $this->setControl("rank_image", "image"); + } + + /** + * (non-PHPdoc) + * @see htdocs/libraries/icms/ipf/icms_ipf_Object::getVar() + */ + public function getVar($key, $format = "s") { + if ($format == "s" && in_array($key, array())) { + return call_user_func(array($this, $key)); + } + return parent::getVar($key, $format); + } + + /** + * Create a link for cloning the object + * @return str + */ + public function getCloneLink() { + $ret = '' . _CO_ICMS_CUSTOMTAG_CLONE . ''; + return $ret; + } + + /** + * Create a link to the image for the rank + * @return str + */ + public function getRankPicture() { + $ret = ''; + return $ret; + } + + /** + * Accessor for the rank_title property + * @return str + */ + public function getRankTitle() { + $ret = $this->getVar("rank_title"); + return $ret; + } +} + +/** + * Handler for the user ranks object + * + * @package System + * @subpackage Users + */ +class SystemUserrankHandler extends icms_ipf_Handler { + + /** */ + public $objects = FALSE; + + /** + * Create a new instance of the handler + * + * @param object $db + */ + public function __construct($db) { + global $icmsConfigUser; + parent::__construct($db, "userrank", "rank_id", "rank_title", "", "system"); + $this->table = $this->db->prefix("ranks"); + $this->enableUpload(array("image/gif", "image/jpeg", "image/pjpeg", "image/x-png", "image/png"), $icmsConfigUser["rank_maxsize"], $icmsConfigUser["rank_width"], $icmsConfigUser["rank_height"]); + } + + /** + * + * + * @param int $rank_id + * @param int $posts + * @return array + */ + public function getRank($rank_id = 0, $posts = 0) { + $rank_id = (int) $rank_id; + $posts = (int) $posts; + + $criteria = new icms_db_criteria_Compo(); + if ($rank_id != 0) { + $criteria->add(new icms_db_criteria_Item("rank_id", $rank_id)); + } else { + $criteria->add(new icms_db_criteria_Item("rank_min", $posts, "<=")); + $criteria->add(new icms_db_criteria_Item("rank_max", $posts, ">=")); + $criteria->add(new icms_db_criteria_Item("rank_special", "0")); + } + + $ranks = $this->getObjects($criteria); + if (count($ranks) != 1) { + $rank = array( + "id" => 0, + "title" => "", + "image" => ICMS_UPLOAD_URL . "blank.gif"); + } else { + $rank = array( + "id" => $rank_id, + "title" => $ranks[0]->getVar("rank_title"), + "image" => $this->getImageUrl() . $ranks[0]->getVar("rank_image")); + } + + return $rank; + } + + /** + * Relocate images for ranks from previous location + * @return bool + */ + public function MoveAllRanksImagesToProperPath() { + $sql = "SELECT rank_image FROM " . $this->table; + $Query = $this->query($sql, FALSE); + for ($i = 0; $i < count($Query); $i++) { + $values[] = $Query[$i]["rank_image"]; + } + + foreach ($values as $value) { + if (file_exists(ICMS_UPLOAD_PATH . "/" . $value)) { + icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . "/" . $value, $this->getImagePath() . $value); + } + } + + return TRUE; + } +} diff --git a/htdocs/modules/system/admin/userrank/xoops_version.php b/htdocs/modules/system/admin/userrank/xoops_version.php index e69f833cb3d2..21b2c04ea5ce 100644 --- a/htdocs/modules/system/admin/userrank/xoops_version.php +++ b/htdocs/modules/system/admin/userrank/xoops_version.php @@ -1,53 +1,53 @@ - // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: Kazumi Ono (AKA onokazu) // -// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // -// Project: The XOOPS Project // -// ------------------------------------------------------------------------- // -/** - * Administration of user ranks, versionfile - * - * @copyright http://www.impresscms.org/ The ImpressCMS Project - * @license LICENSE.txt - * @package System - * @subpackage Users - * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ - */ -$modversion = array( - 'name' => _MD_AM_RANK, - 'version' => "", - 'description' => _MD_AM_RANK_DSC, - 'author' => "phpBB Group ( http://www.phpbb.com/ )", - 'credits' => "", - 'help' => "userrank.html", - 'license' => "GPL see LICENSE", - 'official' => 1, - 'image' => "userrank.gif", - 'hasAdmin' => 1, - 'adminpath' => "admin.php?fct=userrank", - 'category' => XOOPS_SYSTEM_URANK, - 'group' => _MD_AM_GROUPS_USERSANDGROUPS); + // +// ------------------------------------------------------------------------ // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// You may not change or alter any portion of this comment or credits // +// of supporting developers from this source code or any supporting // +// source code which is considered copyrighted (c) material of the // +// original comment or credit authors. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------ // +// Author: Kazumi Ono (AKA onokazu) // +// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // +// Project: The XOOPS Project // +// ------------------------------------------------------------------------- // +/** + * Administration of user ranks, versionfile + * + * @copyright http://www.impresscms.org/ The ImpressCMS Project + * @license LICENSE.txt + * @package System + * @subpackage Users + * @version SVN: $Id: xoops_version.php 12313 2013-09-15 21:14:35Z skenow $ + */ +$modversion = array( + 'name' => _MD_AM_RANK, + 'version' => "", + 'description' => _MD_AM_RANK_DSC, + 'author' => "phpBB Group ( http://www.phpbb.com/ )", + 'credits' => "", + 'help' => "userrank.html", + 'license' => "GPL see LICENSE", + 'official' => 1, + 'image' => "userrank.gif", + 'hasAdmin' => 1, + 'adminpath' => "admin.php?fct=userrank", + 'category' => XOOPS_SYSTEM_URANK, + 'group' => _MD_AM_GROUPS_USERSANDGROUPS); From 21bc3c4623f5412b59b8446ef55dcdc204ce6311 Mon Sep 17 00:00:00 2001 From: Emily Wan <93227982+emilylwan@users.noreply.github.com> Date: Fri, 17 Nov 2023 00:22:34 -0500 Subject: [PATCH 2/8] Hide uid of users in url Uses a hashed uid to appear in the url instead of the original uid --- htdocs/edituser.php | 10 +++++----- htdocs/include/findusers.php | 2 +- htdocs/install/class/dbmanager.php | 4 ++-- htdocs/install/makedata.php | 4 +++- htdocs/install/sql/mysql.structure.sql | 1 + htdocs/libraries/icms/data/comment/Renderer.php | 4 ++-- htdocs/libraries/icms/member/user/Handler.php | 9 ++++++++- htdocs/libraries/icms/member/user/Object.php | 1 + htdocs/user.php | 4 ++-- htdocs/userinfo.php | 14 +++++++------- 10 files changed, 32 insertions(+), 21 deletions(-) diff --git a/htdocs/edituser.php b/htdocs/edituser.php index 0a320c7a167f..343261cdf8fe 100644 --- a/htdocs/edituser.php +++ b/htdocs/edituser.php @@ -286,7 +286,7 @@ /** Include the footer file to complete page rendering */ include ICMS_ROOT_PATH . '/footer.php'; } else { - redirect_header('userinfo.php?uid=' . $uid, 1, _US_PROFUPDATED); + redirect_header('userinfo.php?uid=' . icms::$user->getVar('hash_uid'), 1, _US_PROFUPDATED); } exit(); } @@ -301,7 +301,7 @@ icms_PasswordMeter(); } - echo '' . _US_PROFILE . '  + echo '' . _US_PROFILE . '  »» ' . _US_EDITPROFILE . '

'; $form = new icms_form_Theme(_US_EDITPROFILE, 'userinfo', 'edituser.php', 'post', TRUE); $login_name_label = new icms_form_elements_Label(_US_LOGINNAME, icms::$user->getVar('login_name')); @@ -440,7 +440,7 @@ /** Include the header that starts page rendering */ include ICMS_ROOT_PATH . '/header.php'; echo "

" . _US_AVATAR . "

"; - echo '

' . _US_PROFILE . ' + echo '

' . _US_PROFILE . ' »» ' . _US_UPLOADMYAVATAR . '

'; $oldavatar = icms::$user->getVar('user_avatar'); if (!empty($oldavatar) && $oldavatar != 'blank.gif') { @@ -528,7 +528,7 @@ ); icms::$xoopsDB->query($sql); $avt_handler->addUser($avatar->getVar('avatar_id'), (int) icms::$user->getVar('uid')); - redirect_header('userinfo.php?t=' . time() . '&uid=' . (int) icms::$user->getVar('uid'), 0, _US_PROFUPDATED); + redirect_header('userinfo.php?t=' . time() . '&uid=' . icms::$user->getVar('hash_uid'), 0, _US_PROFUPDATED); } } } @@ -595,6 +595,6 @@ } } } - redirect_header('userinfo.php?uid=' . $uid, 0, _US_PROFUPDATED); + redirect_header('userinfo.php?uid=' . icms::$user->getVar('hash_uid'), 0, _US_PROFUPDATED); break; } diff --git a/htdocs/include/findusers.php b/htdocs/include/findusers.php index 1f39a3dbb32c..054953ea0124 100644 --- a/htdocs/include/findusers.php +++ b/htdocs/include/findusers.php @@ -500,7 +500,7 @@ function addusers() echo ""; } echo " - " . $foundusers[$j]->getVar("uname") . " + " . $foundusers[$j]->getVar("uname") . " " . $fuser_name . " " . ($foundusers[$j]->getVar("user_regdate") ? date(_SHORTDATESTRING, $foundusers[$j]->getVar("user_regdate")) : "") . " " . ($foundusers[$j]->getVar("last_login") ? date(_MEDIUMDATESTRING, $foundusers[$j]->getVar("last_login")) : "") . " diff --git a/htdocs/install/class/dbmanager.php b/htdocs/install/class/dbmanager.php index edc1a3c5d6e5..4b4627d3f19a 100644 --- a/htdocs/install/class/dbmanager.php +++ b/htdocs/install/class/dbmanager.php @@ -186,8 +186,8 @@ public function insert($table, $query) { $table = $this->db->prefix($table); $query = 'INSERT INTO '.$table.' '.$query; if (!$this->db->queryF($query)) { - //var_export($query); - //echo '
' . mysql_error() . '
'; + // var_export($query); + // echo '
' . mysql_error() . '
'; if (!isset($this->f_tables['insert'][$table])) { $this->f_tables['insert'][$table] = 1; } else { diff --git a/htdocs/install/makedata.php b/htdocs/install/makedata.php index 57c17696d478..4b77495b0319 100644 --- a/htdocs/install/makedata.php +++ b/htdocs/install/makedata.php @@ -194,6 +194,7 @@ function make_data(&$dbm, &$cm, $adminname, $adminlogin_name, $adminpass, $admin $regdate = time(); // RMV-NOTIFY (updated for extra columns in user table) // `uid`, + // `hash_uid`, // `name`, // `uname`, // `email`, @@ -229,7 +230,8 @@ function make_data(&$dbm, &$cm, $adminname, $adminlogin_name, $adminpass, $admin // `pass_expired`, // `enc_type`, - $dbm->insert('users', " VALUES (1, '', '".addslashes($adminname)."', '".addslashes($adminmail)."', '".XOOPS_URL."/', 'blank.gif', '".$regdate."', '', '', '', 0, '', '', '', '', '".$temp."', 0, 0, 7, 5, 'iTheme', '0.0', ".time().", 'thread', 0, 1, 0, '', '', '', '0', '".addslashes($language)."', 0, 0, 1, '".addslashes($adminlogin_name)."')"); + $hash_uid = hash('sha256', 1); + $dbm->insert('users', " VALUES (1,'".$hash_uid."', '', '".addslashes($adminname)."', '".addslashes($adminmail)."', '".XOOPS_URL."/', 'blank.gif', '".$regdate."', '', '', '', 0, '', '', '', '', '".$temp."', 0, 0, 7, 5, 'iTheme', '0.0', ".time().", 'thread', 0, 1, 0, '', '', '', '0', '".addslashes($language)."', 0, 0, 1, '".addslashes($adminlogin_name)."')"); diff --git a/htdocs/install/sql/mysql.structure.sql b/htdocs/install/sql/mysql.structure.sql index e78f05e9593a..c64fc272be53 100644 --- a/htdocs/install/sql/mysql.structure.sql +++ b/htdocs/install/sql/mysql.structure.sql @@ -491,6 +491,7 @@ CREATE TABLE tplsource ( CREATE TABLE users ( `uid` mediumint(8) unsigned NOT NULL auto_increment, + `hash_uid` varchar(64) NOT NULL default '', `name` varchar(60) NOT NULL default '', `uname` varchar(255) NOT NULL default '', `email` varchar(255) NOT NULL default '', diff --git a/htdocs/libraries/icms/data/comment/Renderer.php b/htdocs/libraries/icms/data/comment/Renderer.php index 29a06301e650..f54a91cdf7fc 100644 --- a/htdocs/libraries/icms/data/comment/Renderer.php +++ b/htdocs/libraries/icms/data/comment/Renderer.php @@ -358,7 +358,7 @@ private function _getPosterName($poster_id) { if ($poster['id'] > 0) { $com_poster =& $this->_memberHandler->getUser($poster_id); if (is_object($com_poster)) { - $poster['uname'] = '' . $com_poster->getVar('uname') . ''; + $poster['uname'] = '' . $com_poster->getVar('uname') . ''; return $poster; } } @@ -378,7 +378,7 @@ private function _getPosterArray($poster_id) { if ($poster['id'] > 0) { $com_poster =& $this->_memberHandler->getUser($poster['id']); if (is_object($com_poster)) { - $poster['uname'] = '' . $com_poster->getVar('uname') . ''; + $poster['uname'] = '' . $com_poster->getVar('uname') . ''; $poster_rank = $com_poster->rank(); $poster['rank_image'] = $poster_rank['image']; $poster['rank_title'] = $poster_rank['title']; diff --git a/htdocs/libraries/icms/member/user/Handler.php b/htdocs/libraries/icms/member/user/Handler.php index 57431892471a..bdeccb80cd1b 100644 --- a/htdocs/libraries/icms/member/user/Handler.php +++ b/htdocs/libraries/icms/member/user/Handler.php @@ -190,6 +190,13 @@ public function insert(&$user, $force = FALSE) { if ($user->isNew()) { $uid = $this->db->getInsertId(); $user->assignVar('uid', $uid); + $hash_uid = hash('sha256', $uid); + $user->assignVar('hash_uid', $hash_uid); + $sql = sprintf( + "UPDATE %s SET hash_uid = '%s' WHERE uid = '%u'", + $this->db->prefix('users'), $hash_uid, (int) $uid + ); + $result = $this->db->query($sql); } return TRUE; } @@ -418,7 +425,7 @@ static public function getUserLink($uid, $name = FALSE, $users = array(), $withC $fullname2 = $user->getVar('name'); if (($name) && !empty($fullname2)) $fullname = $user->getVar('name'); if (!empty($fullname)) $linkeduser = $fullname . "["; - $linkeduser .= ''; + $linkeduser .= ''; $linkeduser .= icms_core_DataFilter::htmlSpecialChars($username) . ""; if (!empty($fullname)) $linkeduser .= "]"; diff --git a/htdocs/libraries/icms/member/user/Object.php b/htdocs/libraries/icms/member/user/Object.php index cae820cf9f67..fe3c6d7a8000 100644 --- a/htdocs/libraries/icms/member/user/Object.php +++ b/htdocs/libraries/icms/member/user/Object.php @@ -74,6 +74,7 @@ class icms_member_user_Object extends icms_core_Object { */ public function __construct($id = null) { $this->initVar('uid', XOBJ_DTYPE_INT, null, false); + $this->initVar('hash_uid', XOBJ_DTYPE_INT, null, false); $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 60); $this->initVar('uname', XOBJ_DTYPE_TXTBOX, null, true, 255); $this->initVar('email', XOBJ_DTYPE_TXTBOX, null, true, 60); diff --git a/htdocs/user.php b/htdocs/user.php index 35c97c24803a..81d9195c9e72 100644 --- a/htdocs/user.php +++ b/htdocs/user.php @@ -88,7 +88,7 @@ header('Location: ' . $redirect); exit(); } else { - header('Location: ' . ICMS_URL . '/userinfo.php?uid=' . (int) icms::$user->getVar('uid')); + header('Location: ' . ICMS_URL . '/userinfo.php?uid=' . (int) icms::$user->getVar('hash_uid')); exit(); } exit(); @@ -119,7 +119,7 @@ header('Location: ' . $redirect); exit(); } else { - header('Location: ' . ICMS_URL . '/userinfo.php?uid=' . (int) icms::$user->getVar('uid')); + header('Location: ' . ICMS_URL . '/userinfo.php?uid=' . (int) icms::$user->getVar('hash_uid')); exit(); } exit(); diff --git a/htdocs/userinfo.php b/htdocs/userinfo.php index 21fbaa5ebb78..2dc0ef1029c6 100644 --- a/htdocs/userinfo.php +++ b/htdocs/userinfo.php @@ -39,17 +39,17 @@ $xoopsOption['pagetype'] = 'user'; include 'mainfile.php'; -$uid = (int) $_GET['uid']; +$hash_uid = (int) $_GET['uid']; if (icms_get_module_status("profile")) { $module = icms::handler("icms_module")->getByDirName("profile", true); if ($module->config['profile_social'] && file_exists(ICMS_MODULES_PATH . '/profile/index.php')) { - header('Location: ' . ICMS_MODULES_URL . '/profile/index.php?uid=' . $uid); + header('Location: ' . ICMS_MODULES_URL . '/profile/index.php?uid=' . $hash_uid); exit(); } elseif (!$module->config['profile_social'] && file_exists(ICMS_MODULES_PATH . '/profile/userinfo.php')) { - header('Location: ' . ICMS_MODULES_URL . '/profile/userinfo.php?uid=' . $uid); + header('Location: ' . ICMS_MODULES_URL . '/profile/userinfo.php?uid=' . $hash_uid); exit(); } unset($module); @@ -60,9 +60,9 @@ if (!$icmsConfigUser['allow_annon_view_prof'] && !is_object(icms::$user)) { redirect_header(ICMS_URL . '/user.php', 3, _NOPERM); } -if ($uid <= 0) { - redirect_header('index.php', 3, _US_SELECTNG); -} +// if ($uid <= 0) { +// redirect_header('index.php', 3, _US_SELECTNG); +// } $gperm_handler = icms::handler('icms_member_groupperm'); $groups = is_object(icms::$user) ? icms::$user->getGroups() : XOOPS_GROUP_ANONYMOUS; @@ -70,7 +70,7 @@ $isAdmin = $gperm_handler->checkRight('system_admin', XOOPS_SYSTEM_USER, $groups); if (is_object(icms::$user)) { - if ($uid == icms::$user->getVar('uid')) { + if ($hash_uid == icms::$user->getVar('hash_uid')) { $xoopsOption['template_main'] = 'system_userinfo.html'; include ICMS_ROOT_PATH . '/header.php'; $icmsTpl->assign('user_ownpage', true); From da7cd822ee059c6795c522408eee320260a92f19 Mon Sep 17 00:00:00 2001 From: Emily Wan <93227982+emilylwan@users.noreply.github.com> Date: Fri, 17 Nov 2023 10:39:31 -0500 Subject: [PATCH 3/8] Changes to make it not an int --- htdocs/libraries/icms/member/user/Object.php | 2 +- htdocs/user.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/libraries/icms/member/user/Object.php b/htdocs/libraries/icms/member/user/Object.php index fe3c6d7a8000..28843a87dc8a 100644 --- a/htdocs/libraries/icms/member/user/Object.php +++ b/htdocs/libraries/icms/member/user/Object.php @@ -74,7 +74,7 @@ class icms_member_user_Object extends icms_core_Object { */ public function __construct($id = null) { $this->initVar('uid', XOBJ_DTYPE_INT, null, false); - $this->initVar('hash_uid', XOBJ_DTYPE_INT, null, false); + $this->initVar('hash_uid', XOBJ_DTYPE_TXTBOX, null, false, 64); $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 60); $this->initVar('uname', XOBJ_DTYPE_TXTBOX, null, true, 255); $this->initVar('email', XOBJ_DTYPE_TXTBOX, null, true, 60); diff --git a/htdocs/user.php b/htdocs/user.php index 81d9195c9e72..1b311672856f 100644 --- a/htdocs/user.php +++ b/htdocs/user.php @@ -88,7 +88,7 @@ header('Location: ' . $redirect); exit(); } else { - header('Location: ' . ICMS_URL . '/userinfo.php?uid=' . (int) icms::$user->getVar('hash_uid')); + header('Location: ' . ICMS_URL . '/userinfo.php?uid=' . icms::$user->getVar('hash_uid')); exit(); } exit(); @@ -119,7 +119,7 @@ header('Location: ' . $redirect); exit(); } else { - header('Location: ' . ICMS_URL . '/userinfo.php?uid=' . (int) icms::$user->getVar('hash_uid')); + header('Location: ' . ICMS_URL . '/userinfo.php?uid=' . icms::$user->getVar('hash_uid')); exit(); } exit(); From 39583bea762e89434bca16b57b84cb83e5e21e7d Mon Sep 17 00:00:00 2001 From: Emily Wan <93227982+emilylwan@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:13:39 -0500 Subject: [PATCH 4/8] Use hmac --- htdocs/install/makedata.php | 4 +++- htdocs/libraries/icms/member/user/Handler.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/install/makedata.php b/htdocs/install/makedata.php index 4b77495b0319..e9d732990531 100644 --- a/htdocs/install/makedata.php +++ b/htdocs/install/makedata.php @@ -230,7 +230,9 @@ function make_data(&$dbm, &$cm, $adminname, $adminlogin_name, $adminpass, $admin // `pass_expired`, // `enc_type`, - $hash_uid = hash('sha256', 1); + $bytes = random_bytes(16); + $secret_key = bin2hex($bytes); + $hash_uid = hash_hmac('sha256', 1, $secret_key); $dbm->insert('users', " VALUES (1,'".$hash_uid."', '', '".addslashes($adminname)."', '".addslashes($adminmail)."', '".XOOPS_URL."/', 'blank.gif', '".$regdate."', '', '', '', 0, '', '', '', '', '".$temp."', 0, 0, 7, 5, 'iTheme', '0.0', ".time().", 'thread', 0, 1, 0, '', '', '', '0', '".addslashes($language)."', 0, 0, 1, '".addslashes($adminlogin_name)."')"); diff --git a/htdocs/libraries/icms/member/user/Handler.php b/htdocs/libraries/icms/member/user/Handler.php index bdeccb80cd1b..3f22706ee645 100644 --- a/htdocs/libraries/icms/member/user/Handler.php +++ b/htdocs/libraries/icms/member/user/Handler.php @@ -190,7 +190,9 @@ public function insert(&$user, $force = FALSE) { if ($user->isNew()) { $uid = $this->db->getInsertId(); $user->assignVar('uid', $uid); - $hash_uid = hash('sha256', $uid); + $bytes = random_bytes(16); + $secret_key = bin2hex($bytes); + $hash_uid = hash_hmac('sha256', $uid, $secret_key); $user->assignVar('hash_uid', $hash_uid); $sql = sprintf( "UPDATE %s SET hash_uid = '%s' WHERE uid = '%u'", From 77cd02ede1189823f036d3c915e17b4e3db660e2 Mon Sep 17 00:00:00 2001 From: Emily Wan <93227982+emilylwan@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:15:18 -0500 Subject: [PATCH 5/8] Change to random bits --- htdocs/install/makedata.php | 4 +--- htdocs/libraries/icms/member/user/Handler.php | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/install/makedata.php b/htdocs/install/makedata.php index e9d732990531..ed134661f104 100644 --- a/htdocs/install/makedata.php +++ b/htdocs/install/makedata.php @@ -230,9 +230,7 @@ function make_data(&$dbm, &$cm, $adminname, $adminlogin_name, $adminpass, $admin // `pass_expired`, // `enc_type`, - $bytes = random_bytes(16); - $secret_key = bin2hex($bytes); - $hash_uid = hash_hmac('sha256', 1, $secret_key); + $hash_uid = bin2hex(random_bytes(32)); $dbm->insert('users', " VALUES (1,'".$hash_uid."', '', '".addslashes($adminname)."', '".addslashes($adminmail)."', '".XOOPS_URL."/', 'blank.gif', '".$regdate."', '', '', '', 0, '', '', '', '', '".$temp."', 0, 0, 7, 5, 'iTheme', '0.0', ".time().", 'thread', 0, 1, 0, '', '', '', '0', '".addslashes($language)."', 0, 0, 1, '".addslashes($adminlogin_name)."')"); diff --git a/htdocs/libraries/icms/member/user/Handler.php b/htdocs/libraries/icms/member/user/Handler.php index 3f22706ee645..a1015081a6dc 100644 --- a/htdocs/libraries/icms/member/user/Handler.php +++ b/htdocs/libraries/icms/member/user/Handler.php @@ -190,9 +190,7 @@ public function insert(&$user, $force = FALSE) { if ($user->isNew()) { $uid = $this->db->getInsertId(); $user->assignVar('uid', $uid); - $bytes = random_bytes(16); - $secret_key = bin2hex($bytes); - $hash_uid = hash_hmac('sha256', $uid, $secret_key); + $hash_uid = bin2hex(random_bytes(32)); $user->assignVar('hash_uid', $hash_uid); $sql = sprintf( "UPDATE %s SET hash_uid = '%s' WHERE uid = '%u'", From 9f8b91728d6e67c087a144556e41948049e1177a Mon Sep 17 00:00:00 2001 From: Emily Wan <93227982+emilylwan@users.noreply.github.com> Date: Tue, 21 Nov 2023 18:20:13 -0500 Subject: [PATCH 6/8] Add methods to get given user from database --- htdocs/libraries/icms/member/Handler.php | 14 ++++++++++++++ htdocs/libraries/icms/member/user/Handler.php | 18 ++++++++++++++++++ htdocs/userinfo.php | 6 +++--- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/htdocs/libraries/icms/member/Handler.php b/htdocs/libraries/icms/member/Handler.php index 1952942d3b59..6b884787c169 100644 --- a/htdocs/libraries/icms/member/Handler.php +++ b/htdocs/libraries/icms/member/Handler.php @@ -131,6 +131,20 @@ public function &getUser($id) { return $this->_members[$id]; } + /** + * retrieve a user by hash_uid + * + * @param string $hash_uid for the user + * @return object icms_member_user_Object {@link icms_member_user_Object} reference to the user + */ + + public function &getUserHash($hash_uid) { + if (! isset($this->_members[$hash_uid])) { + $this->_members[$hash_uid] = & $this->_uHandler->getHash($hash_uid); + } + return $this->_members[$hash_uid]; + } + /** * delete a group * diff --git a/htdocs/libraries/icms/member/user/Handler.php b/htdocs/libraries/icms/member/user/Handler.php index a1015081a6dc..5f1a07aaf502 100644 --- a/htdocs/libraries/icms/member/user/Handler.php +++ b/htdocs/libraries/icms/member/user/Handler.php @@ -98,6 +98,24 @@ public function &get($id) { return $user; } + /** + * retrieve a user from hash_uid + * + * @param string $hash_uid hash_uid of the user + * @return mixed reference to the {@link icms_member_user_Object} object, FALSE if failed + */ + public function &getHash($hash_uid) { + $user = FALSE; + $sql = "SELECT * FROM " . $this->db->prefix('users') . " WHERE hash_uid = '" . $hash_uid . "'"; + if (!$result = $this->db->query($sql)) {return $user;} + $numrows = $this->db->getRowsNum($result); + if ($numrows == 1) { + $user = new icms_member_user_Object(); + $user->assignVars($this->db->fetchArray($result)); + } + return $user; + } + /** * insert a new user in the database * diff --git a/htdocs/userinfo.php b/htdocs/userinfo.php index 2dc0ef1029c6..969be3cdf4a0 100644 --- a/htdocs/userinfo.php +++ b/htdocs/userinfo.php @@ -39,7 +39,7 @@ $xoopsOption['pagetype'] = 'user'; include 'mainfile.php'; -$hash_uid = (int) $_GET['uid']; +$hash_uid = $_GET['uid']; if (icms_get_module_status("profile")) { $module = icms::handler("icms_module")->getByDirName("profile", true); @@ -85,7 +85,7 @@ 'lang_deleteaccount' => $icmsConfigUser['self_delete'] ? _US_DELACCOUNT : '')); $thisUser = icms::$user; } else { - $thisUser = icms::handler('icms_member')->getUser($uid); + $thisUser = icms::handler('icms_member')->getUserHash($hash_uid); if (!is_object($thisUser) || !$thisUser->isActive()) { redirect_header('index.php', 3, _US_SELECTNG); } @@ -94,7 +94,7 @@ $icmsTpl->assign('user_ownpage', false); } } else { - $thisUser = icms::handler('icms_member')->getUser($uid); + $thisUser = icms::handler('icms_member')->getUserHash($hash_uid); if (!is_object($thisUser) || !$thisUser->isActive()) { redirect_header('index.php', 3, _US_SELECTNG); } From b3dc56b39b96d6f9a9f5c7bac52a90c8d906f2d8 Mon Sep 17 00:00:00 2001 From: Emily Wan <93227982+emilylwan@users.noreply.github.com> Date: Sat, 2 Dec 2023 16:42:07 -0500 Subject: [PATCH 7/8] Changes as suggested by comments --- htdocs/install/makedata.php | 3 ++- htdocs/install/sql/mysql.structure.sql | 3 ++- htdocs/libraries/icms/member/user/Handler.php | 5 +++-- htdocs/userinfo.php | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/install/makedata.php b/htdocs/install/makedata.php index ed134661f104..037767fd918c 100644 --- a/htdocs/install/makedata.php +++ b/htdocs/install/makedata.php @@ -230,7 +230,8 @@ function make_data(&$dbm, &$cm, $adminname, $adminlogin_name, $adminpass, $admin // `pass_expired`, // `enc_type`, - $hash_uid = bin2hex(random_bytes(32)); + $secret_string = bin2hex(random_bytes(16)); + $hash_uid = hash_hmac('sha256', 1, $secret_string); $dbm->insert('users', " VALUES (1,'".$hash_uid."', '', '".addslashes($adminname)."', '".addslashes($adminmail)."', '".XOOPS_URL."/', 'blank.gif', '".$regdate."', '', '', '', 0, '', '', '', '', '".$temp."', 0, 0, 7, 5, 'iTheme', '0.0', ".time().", 'thread', 0, 1, 0, '', '', '', '0', '".addslashes($language)."', 0, 0, 1, '".addslashes($adminlogin_name)."')"); diff --git a/htdocs/install/sql/mysql.structure.sql b/htdocs/install/sql/mysql.structure.sql index c64fc272be53..c580ad104a89 100644 --- a/htdocs/install/sql/mysql.structure.sql +++ b/htdocs/install/sql/mysql.structure.sql @@ -529,7 +529,8 @@ CREATE TABLE users ( `login_name` varchar(255) NOT NULL default '', PRIMARY KEY (`uid`), KEY `uname` (`uname`(10)), - UNIQUE KEY `login_name` (`login_name`(10)) + UNIQUE KEY `login_name` (`login_name`(10)), + UNIQUE KEY `hash_uid` (`hash_uid`) ); # diff --git a/htdocs/libraries/icms/member/user/Handler.php b/htdocs/libraries/icms/member/user/Handler.php index 5f1a07aaf502..8d06ed835e59 100644 --- a/htdocs/libraries/icms/member/user/Handler.php +++ b/htdocs/libraries/icms/member/user/Handler.php @@ -106,7 +106,7 @@ public function &get($id) { */ public function &getHash($hash_uid) { $user = FALSE; - $sql = "SELECT * FROM " . $this->db->prefix('users') . " WHERE hash_uid = '" . $hash_uid . "'"; + $sql = "SELECT * FROM " . $this->db->prefix('users') . " WHERE hash_uid = " . $this->db->quoteString($hash_uid) . " LIMIT 1"; if (!$result = $this->db->query($sql)) {return $user;} $numrows = $this->db->getRowsNum($result); if ($numrows == 1) { @@ -208,7 +208,8 @@ public function insert(&$user, $force = FALSE) { if ($user->isNew()) { $uid = $this->db->getInsertId(); $user->assignVar('uid', $uid); - $hash_uid = bin2hex(random_bytes(32)); + $secret_string = bin2hex(random_bytes(16)); + $hash_uid = hash_hmac('sha256', $uid, $secret_string); $user->assignVar('hash_uid', $hash_uid); $sql = sprintf( "UPDATE %s SET hash_uid = '%s' WHERE uid = '%u'", diff --git a/htdocs/userinfo.php b/htdocs/userinfo.php index 969be3cdf4a0..297ff52d1822 100644 --- a/htdocs/userinfo.php +++ b/htdocs/userinfo.php @@ -39,7 +39,7 @@ $xoopsOption['pagetype'] = 'user'; include 'mainfile.php'; -$hash_uid = $_GET['uid']; +$hash_uid = (string) $_GET['uid']; if (icms_get_module_status("profile")) { $module = icms::handler("icms_module")->getByDirName("profile", true); From 894de026b6e31d17172f39ea457ac553a78ddda7 Mon Sep 17 00:00:00 2001 From: Emily Wan <93227982+emilylwan@users.noreply.github.com> Date: Sat, 23 Dec 2023 14:55:09 -0500 Subject: [PATCH 8/8] Filter hash_uid --- htdocs/userinfo.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/userinfo.php b/htdocs/userinfo.php index 297ff52d1822..3e8ea2992c87 100644 --- a/htdocs/userinfo.php +++ b/htdocs/userinfo.php @@ -39,7 +39,8 @@ $xoopsOption['pagetype'] = 'user'; include 'mainfile.php'; -$hash_uid = (string) $_GET['uid']; +$dirty_hash_uid = (string) $_GET['uid']; +$hash_uid = icms_core_DataFilter::checkVar($dirty_hash_uid, 'str'); if (icms_get_module_status("profile")) { $module = icms::handler("icms_module")->getByDirName("profile", true);