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. */ use Xoops\Core\Request; /** * @copyright XOOPS Project (http://xoops.org) * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @author trabis <*****@*****.**> * @version $Id$ */ include dirname(dirname(__DIR__)) . '/mainfile.php'; $xoops = Xoops::getInstance(); if (Request::getBool('pdf', false)) { $content = \Xoops\Utils::dumpVar($xoops->getConfigs(), false); $tpl = new XoopsTpl(); $tpl->assign('dummy_content', $content); $content2 = $tpl->fetch('module:system/system_dummy.tpl'); if ($xoops->service('htmltopdf')->isAvailable()) { $xoops->service('htmltopdf')->addHtml($content2); $xoops->service('htmltopdf')->outputPdfInline('codex_example.pdf'); } else { $xoops->header(); echo 'Please install an HtmlToPdf provider!'; \Xoops\Utils::dumpFile(__FILE__); $xoops->footer(); } } else { $xoops->header();
} $error_msg .= $obj->getHtmlErrors(); } $admin_page->addItemButton(AvatarsLocale::LIST_OF_AVATARS, 'avatar_custom.php', 'application-view-detail'); $admin_page->renderButton(); $xoops->tpl()->assign('info_msg', $xoops->alert('info', $info_msg, XoopsLocale::INFORMATION_FOR_UPLOADS)); $xoops->tpl()->assign('error_msg', $xoops->alert('error', $error_msg, XoopsLocale::ERRORS)); $form = $xoops->getModuleForm($obj, 'avatar'); $xoops->tpl()->assign('form', $form->render()); break; //Delete //Delete case "delete": $avatar_id = Request::getInt('avatar_id', 0); $obj = $avatar_Handler->get($avatar_id); if (Request::getBool('ok', false, 'POST')) { if (!$xoops->security()->check()) { $xoops->redirect("avatar_custom.php", 3, implode(",", $xoops->security()->getErrors())); } if ($avatar_Handler->delete($obj)) { // Delete file $file = $obj->getVar('avatar_file'); if ($file !== 'avatars/blank.gif') { $fullname = $xoops_upload_path . '/' . $file; if (is_file($fullname)) { chmod($fullname, 0777); unlink($fullname); } } // Update member profiles $qb = $xoops->db()->createXoopsQueryBuilder();
use Xoops\Core\Request; /** * @copyright XOOPS Project (http://xoops.org) * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @author trabis <*****@*****.**> * @version $Id$ */ include dirname(dirname(__DIR__)) . '/mainfile.php'; $xoops = Xoops::getInstance(); // Warning: code depending on Xoops\Core\HttpRequest may need to change $request = \Xoops\Core\HttpRequest::getInstance(); $xoops->header(); \Xoops\Utils::dumpVar(Request::get()); $result['id'] = Request::getInt('id', 13); $result['string'] = Request::getString('string', 'defaultValueHere'); $result['bool'] = Request::getBool('bool', false); $result['order'] = Request::getString('order', 'ASC'); $result['url'] = $request->getUrl(); $result['uri'] = $request->getUri(); $result['referer'] = $request->getReferer(); $result['phpsessid_cookie'] = Request::getString('PHPSESSID', '', 'cookie'); $result['ip'] = $request->getClientIp(); $result['isget'] = 'GET' === Request::getMethod(); $result['ispost'] = 'POST' === Request::getMethod(); $result['ismobile'] = $request->is('mobile'); $result['isrobot'] = $request->is('robot'); $result['files'] = Request::getArray('file_identifier', array(), 'files'); \Xoops\Utils::dumpVar($result); echo '<a href="?id=12&string=I love you&bool=everythingsistrue&order=DESC">Good uri</a>'; echo ' - <a href="?id=test&order=DESCENDING">Bad uri</a>'; // Form
$xoops = Xoops::getInstance(); $xoops->disableErrorReporting(); $xoops->simpleHeader(false); $helper->loadLanguage('admin'); $helper->loadLanguage('tinymce'); $op = Request::getCmd('op', ''); if ($op === 'save') { if (!$xoops->security()->check()) { $xoops->redirect('xoops_xlanguage.php', 2, implode(',', $xoops->security()->getErrors())); } XoopsLoad::load('system', 'system'); $msg[] = _AM_SMILIES_SAVE; $obj = $helper->getHandlerSmilies()->create(); $obj->setVar('smiley_code', Request::getString('smiley_code', '')); $obj->setVar('smiley_emotion', Request::getString('smiley_emotion', '')); $obj->setVar('smiley_display', Request::getBool('smiley_display', 1)); $obj->setVar('smiley_url', 'smilies/' . Request::getPath('smiley_url', '')); $xoops_upload_file = Request::getArray('xoops_upload_file', array()); $mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'); $upload_size = 500000; $uploader = new XoopsMediaUploader(\XoopsBaseConfig::get('uploads-path') . '/smilies', $mimetypes, $upload_size, null, null); if ($uploader->fetchMedia($xoops_upload_file[0])) { $uploader->setPrefix('smil'); if (!$uploader->upload()) { $msg[] = $uploader->getErrors(); $obj->setVar('smiley_url', 'blank.gif'); } else { $obj->setVar('smiley_url', 'smilies/' . $uploader->getSavedFileName()); } } if ($helper->getHandlerSmilies()->insert($obj)) {
public function displayPost() { $xoops = Xoops::getInstance(); if (Request::getMethod() !== 'POST') { $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } $id = Request::getInt('com_id'); $modid = Request::getInt('com_modid'); if (empty($modid)) { $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } /* @var $comment CommentsComment */ $comment = $this->getHandlerComment()->get($id); if (!is_object($comment)) { $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } if (!$comment->isNew()) { $modid = $comment->getVar('modid'); } else { $comment->setVar('modid', $modid); } $module = $xoops->getModuleById($modid); if (!is_object($module)) { $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } $moddir = $module->getVar('dirname'); if ($xoops->isAdminSide) { if (empty($id)) { $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } $redirect_page = $this->url('admin/main.php?com_modid=' . $modid . '&com_itemid'); } else { if (COMMENTS_APPROVENONE == $xoops->getModuleConfig('com_rule', $module->getVar('dirname'))) { $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } $redirect_page = ''; } /* @var $plugin CommentsPluginInterface */ if ($plugin = \Xoops\Module\Plugin::getPlugin($moddir, 'comments')) { if (!$xoops->isAdminSide) { $redirect_page = $xoops->url('modules/' . $moddir . '/' . $plugin->pageName() . '?'); if (is_array($extraParams = $plugin->extraParams())) { $extra_params = ''; foreach ($extraParams as $extra_param) { $extra_params .= isset($_POST[$extra_param]) ? $extra_param . '=' . htmlspecialchars($_POST[$extra_param]) . '&' : $extra_param . '=amp;'; } $redirect_page .= $extra_params; } $redirect_page .= $plugin->itemName(); } $comment_url = $redirect_page; $op = Request::getBool('com_dopost') ? 'post' : ''; $op = Request::getBool('com_dopreview') ? 'preview' : $op; $op = Request::getBool('com_dodelete') ? 'delete' : $op; if ($op === 'preview' || $op === 'post') { if (!$xoops->security()->check()) { $op = ''; } } if ($op === 'post' && !$xoops->isUser()) { $xoopsCaptcha = XoopsCaptcha::getInstance(); if (!$xoopsCaptcha->verify()) { $captcha_message = $xoopsCaptcha->getMessage(); $op = 'preview'; } } $title = XoopsLocale::trim(Request::getString('com_title')); $text = XoopsLocale::trim(Request::getString('com_text')); $mode = XoopsLocale::trim(Request::getString('com_mode', 'flat')); $order = XoopsLocale::trim(Request::getString('com_order', COMMENTS_OLD1ST)); $itemid = Request::getInt('com_itemid'); $pid = Request::getInt('com_pid'); $rootid = Request::getInt('com_rootid'); $status = Request::getInt('com_status'); $dosmiley = Request::getBool('com_dosmiley'); $doxcode = Request::getBool('com_doxcode'); $dobr = Request::getBool('com_dobr'); $dohtml = Request::getBool('com_html'); $doimage = Request::getBool('com_doimage'); $icon = XoopsLocale::trim(Request::getString('com_icon')); $comment->setVar('title', $title); $comment->setVar('text', $text); $comment->setVar('itemid', $itemid); $comment->setVar('pid', $pid); $comment->setVar('rootid', $rootid); $comment->setVar('status', $status); $comment->setVar('dosmiley', $dosmiley); $comment->setVar('doxcode', $doxcode); $comment->setVar('dobr', $dobr); $comment->setVar('dohtml', $dohtml); $comment->setVar('doimage', $doimage); $comment->setVar('icon', $icon); switch ($op) { case "delete": $this->displayDelete(); break; case "preview": $comment->setVar('doimage', 1); if ($comment->getVar('dohtml') != 0) { if ($xoops->isUser()) { if (!$xoops->user->isAdmin($comment->getVar('modid'))) { $comment->setVar('dohtml', 0); } } else { $comment->setVar('dohtml', 0); } } $xoops->header(); if (!$xoops->isAdminSide && !empty($captcha_message)) { echo $xoops->alert('error', $captcha_message); } echo $this->renderHeader($comment->getVar('title', 'p'), $comment->getVar('text', 'p'), false, time()); $this->displayCommentForm($comment); $xoops->footer(); break; case "post": $comment->setVar('doimage', 1); $comment_handler = $this->getHandlerComment(); $add_userpost = false; $call_approvefunc = false; $call_updatefunc = false; // RMV-NOTIFY - this can be set to 'comment' or 'comment_submit' $notify_event = false; if (!empty($id)) { $accesserror = false; if ($xoops->isUser()) { if ($xoops->user->isAdmin($comment->getVar('modid'))) { if (!empty($status) && $status != COMMENTS_PENDING) { $old_status = $comment->getVar('status'); $comment->setVar('status', $status); // if changing status from pending state, increment user post if (COMMENTS_PENDING == $old_status) { $add_userpost = true; if (COMMENTS_ACTIVE == $status) { $call_updatefunc = true; $call_approvefunc = true; // RMV-NOTIFY $notify_event = 'comment'; } } else { if (COMMENTS_HIDDEN == $old_status && COMMENTS_ACTIVE == $status) { $call_updatefunc = true; // Comments can not be directly posted hidden, // no need to send notification here } else { if (COMMENTS_ACTIVE == $old_status && COMMENTS_HIDDEN == $status) { $call_updatefunc = true; } } } } } else { $comment->setVar('dohtml', 0); if ($comment->getVar('uid') != $xoops->user->getVar('uid')) { $accesserror = true; } } } else { $comment->setVar('dohtml', 0); $accesserror = true; } if (false != $accesserror) { $xoops->redirect($redirect_page . '=' . $comment->getVar('itemid') . '&com_id=' . $comment->getVar('id') . '&com_mode=' . $mode . '&com_order=' . $order, 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } } else { $comment->setVar('created', time()); $comment->setVar('ip', $xoops->getEnv('REMOTE_ADDR')); if ($xoops->isUser()) { if ($xoops->user->isAdmin($comment->getVar('modid'))) { $comment->setVar('status', COMMENTS_ACTIVE); $add_userpost = true; $call_approvefunc = true; $call_updatefunc = true; // RMV-NOTIFY $notify_event = 'comment'; } else { $comment->setVar('dohtml', 0); switch ($xoops->getModuleConfig('com_rule')) { case COMMENTS_APPROVEALL: case COMMENTS_APPROVEUSER: $comment->setVar('status', COMMENTS_ACTIVE); $add_userpost = true; $call_approvefunc = true; $call_updatefunc = true; // RMV-NOTIFY $notify_event = 'comment'; break; case COMMENTS_APPROVEADMIN: default: $comment->setVar('status', COMMENTS_PENDING); $notify_event = 'comment_submit'; break; } } if ($xoops->getModuleConfig('com_anonpost', $module->getVar('dirname')) && $comment->getVar('noname')) { $comment->setVar('uid', 0); } else { $comment->setVar('uid', $xoops->user->getVar('uid')); } } else { $comment->setVar('dohtml', 0); $comment->setVar('uid', 0); if ($xoops->getModuleConfig('com_anonpost', $module->getVar('dirname')) != 1) { $xoops->redirect($redirect_page . '=' . $comment->getVar('itemid') . '&com_id=' . $comment->getVar('id') . '&com_mode=' . $mode . '&com_order=' . $order, 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } } if ($comment->getVar('uid') == 0) { switch ($xoops->getModuleConfig('com_rule')) { case COMMENTS_APPROVEALL: $comment->setVar('status', COMMENTS_ACTIVE); $add_userpost = true; $call_approvefunc = true; $call_updatefunc = true; // RMV-NOTIFY $notify_event = 'comment'; break; case COMMENTS_APPROVEADMIN: case COMMENTS_APPROVEUSER: default: $comment->setVar('status', COMMENTS_PENDING); // RMV-NOTIFY $notify_event = 'comment_submit'; break; } } } if ($comment->getVar('title') == '') { $comment->setVar('title', XoopsLocale::NO_TITLE); } $comment->setVar('modified', time()); if (isset($extra_params)) { $comment->setVar('exparams', $extra_params); } if (false != $comment_handler->insert($comment)) { $newcid = $comment->getVar('id'); // set own id as root id if this is a top comment if ($comment->getVar('rootid') == 0) { $comment->setVar('rootid', $newcid); if (!$comment_handler->updateByField($comment, 'rootid', $comment->getVar('rootid'))) { $comment_handler->delete($comment); $xoops->header(); echo $xoops->alert('error', $comment->getHtmlErrors()); $xoops->footer(); } } // call custom approve function if any if (false != $call_approvefunc) { $plugin->approve($comment); } if (false != $call_updatefunc) { $criteria = new CriteriaCompo(new Criteria('modid', $comment->getVar('modid'))); $criteria->add(new Criteria('itemid', $comment->getVar('itemid'))); $criteria->add(new Criteria('status', COMMENTS_ACTIVE)); $comment_count = $comment_handler->getCount($criteria); $plugin->update($comment->getVar('itemid'), $comment_count); } // increment user post if needed $uid = $comment->getVar('uid'); if ($uid > 0 && false != $add_userpost) { $member_handler = $xoops->getHandlerMember(); $poster = $member_handler->getUser($uid); if ($poster instanceof XoopsUser) { $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') + 1); } } // RMV-NOTIFY // trigger notification event if necessary if ($notify_event && $xoops->isActiveModule('notifications')) { $notifications = Notifications::getInstance(); $not_modid = $comment->getVar('modid'); $not_catinfo = $notifications->getCommentsCategory($module->getVar('dirname')); $not_category = $not_catinfo['name']; $not_itemid = $comment->getVar('itemid'); $not_event = $notify_event; // Build an ABSOLUTE URL to view the comment. Make sure we // point to a viewable page (i.e. not the system administration // module). $comment_tags = array(); $comment_tags['X_COMMENT_URL'] = $comment_url . '=' . $comment->getVar('itemid') . '&com_id=' . $comment->getVar('id') . '&com_rootid=' . $comment->getVar('rootid') . '&com_mode=' . $mode . '&com_order=' . $order . '#comment' . $comment->getVar('id'); if ($xoops->isActiveModule('notifications')) { Notifications::getInstance()->getHandlerNotification()->triggerEvent($not_category, $not_itemid, $not_event, $comment_tags, false, $not_modid); } } if (!isset($comment_post_results)) { // if the comment is active, redirect to posted comment if ($comment->getVar('status') == COMMENTS_ACTIVE) { $xoops->redirect($redirect_page . '=' . $comment->getVar('itemid') . '&com_id=' . $comment->getVar('id') . '&com_rootid=' . $comment->getVar('rootid') . '&com_mode=' . $mode . '&com_order=' . $order . '#comment' . $comment->getVar('id'), 1, _MD_COMMENTS_THANKSPOST); } else { // not active, so redirect to top comment page $xoops->redirect($redirect_page . '=' . $comment->getVar('itemid') . '&com_mode=' . $mode . '&com_order=' . $order . '#comment' . $comment->getVar('id'), 1, _MD_COMMENTS_THANKSPOST); } } } else { if (!isset($purge_comment_post_results)) { $xoops->header(); echo $xoops->alert('error', $comment->getHtmlErrors()); $xoops->footer(); } else { $comment_post_results = $comment->getErrors(); } } break; default: $xoops->redirect(\XoopsBaseConfig::get('url') . '/', 1, implode('<br />', $xoops->security()->getErrors())); break; } } }
if (!$xoops->security()->check()) { $xoops->redirect('categories.php', 3, implode('<br />', $xoops->security()->getErrors())); } $imgcat_id = Request::getInt('imgcat_id', 0); if (isset($imgcat_id) && $imgcat_id != 0) { $obj = $helper->getHandlerCategories()->get($imgcat_id); $isnew = false; } else { $obj = $helper->getHandlerCategories()->create(); $isnew = true; } $obj->setVar('imgcat_name', Request::getString('imgcat_name', '')); $obj->setVar('imgcat_maxsize', Request::getInt('imgcat_maxsize', 100000)); $obj->setVar('imgcat_maxwidth', Request::getInt('imgcat_maxwidth', 128)); $obj->setVar('imgcat_maxheight', Request::getInt('imgcat_maxheight', 128)); $obj->setVar('imgcat_display', Request::getBool('imgcat_display', 1)); $obj->setVar('imgcat_weight', Request::getInt('imgcat_weight', 0)); $obj->setVar('imgcat_storetype', Request::getString('imgcat_storetype', 'file')); $obj->setVar('imgcat_type', 'C'); if ($imgcat_id = $helper->getHandlerCategories()->insert($obj)) { // delete permissions if (!$isnew) { $criteria = new CriteriaCompo(new Criteria('gperm_itemid', $imgcat_id)); $criteria->add(new Criteria('gperm_modid', $xoops->module->getVar('mid'))); $criteria2 = new CriteriaCompo(new Criteria('gperm_name', 'imgcat_write')); $criteria2->add(new Criteria('gperm_name', 'imgcat_read'), 'OR'); $criteria->add($criteria2); $xoops->getHandlerGroupPermission()->deleteAll($criteria); } // Save permissions $permissions = array('readgroup' => 'imgcat_read', 'writegroup' => 'imgcat_write');
$edituser->setVar('user_from', Request::getString('user_from', '')); $edituser->setVar('user_sig', XoopsLocale::substr(Request::getString('user_sig', ''), 0, 255)); $edituser->setVar('user_viewemail', Request::getBool('user_viewemail', 0)); $edituser->setVar('user_aim', Request::getString('user_aim', '')); $edituser->setVar('user_yim', Request::getString('user_yim', '')); $edituser->setVar('user_msnm', Request::getString('user_msnm', '')); $edituser->setVar('attachsig', Request::getBool('attachsig', 0)); $edituser->setVar('timezone', Request::getString('timezone', 'UTC')); $edituser->setVar('uorder', Request::getInt('uorder', 0)); $edituser->setVar('umode', Request::getString('umode', 'flat')); $edituser->setVar('notify_method', Request::getInt('notify_method', 1)); $edituser->setVar('notify_mode', Request::getInt('notify_mode', 1)); $edituser->setVar('bio', XoopsLocale::substr(Request::getString('bio', ''), 0, 255)); $edituser->setVar('user_occ', Request::getString('user_occ', '')); $edituser->setVar('user_intrest', Request::getString('user_intrest', '')); $edituser->setVar('user_mailok', Request::getBool('user_mailok', 0)); if (!$member_handler->insertUser($edituser)) { $xoops->header(); echo $edituser->getHtmlErrors(); $xoops->footer(); } else { $xoops->redirect('userinfo.php?uid=' . $uid, 1, XoopsLocale::S_YOUR_PROFILE_UPDATED); } exit; } } if ($op === 'editprofile') { $xoops->header('module:system/system_edituser.tpl'); $xoops->tpl()->assign('uid', $xoops->user->getVar("uid")); $xoops->tpl()->assign('editprofile', true); $form = new Xoops\Form\ThemeForm(XoopsLocale::EDIT_PROFILE, 'userinfo', 'edituser.php', 'post', true);
/** * @covers Xoops\Core\Request::getBool */ public function testGetBool() { $varname = 'RequestTest'; $_REQUEST[$varname] = '9'; $this->assertTrue(Request::getBool($varname)); $_REQUEST[$varname] = 'a string'; $this->assertTrue(Request::getBool($varname)); $_REQUEST[$varname] = true; $this->assertTrue(Request::getBool($varname)); $_REQUEST[$varname] = ''; $this->assertFalse(Request::getBool($varname)); $_REQUEST[$varname] = false; $this->assertFalse(Request::getBool($varname)); $this->assertFalse(Request::getBool($varname . 'no-such-key')); }
* @author trabis <*****@*****.**> * @version $Id$ */ include dirname(dirname(__DIR__)) . '/mainfile.php'; $xoops = Xoops::getInstance(); $xoops->header(); // we ask Xoops for our cache $cache = $xoops->cache(); /** * If requested, delete the caches for our module. The cache has hierarchical * keys, so we can treat them similar to a directory tree. One delete clears * everything underneath, so we don't have to delete each item. * * module/{dirname} is the naming standard for module specific cache entries. */ if (Request::getBool('delete', false, 'GET')) { $cache->delete('module/codex'); } $keys = array('module/codex/firstkey', 'module/codex/secondkey', 'module/codex/alternate', 'module/codex/xmfdemo'); echo '<h3>Current Cache State</h3>'; echo '<dl>'; foreach ($keys as $key) { echo "<dt>{$key}</dt>"; $value = '<em>Not Found</em>'; if (!($value = $cache->read($key))) { $value = '<em>Not Found</em>'; } echo "<dd>{$value}</dd>"; } echo '</dl>'; echo '<h3>Caching Content</h3>';