示例#1
0
$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
$form = new Xoops\Form\SimpleForm('', 'form_id', 'request.php?id=666', true);
$form->setExtra('enctype="multipart/form-data"');
$code = new Xoops\Form\Text('String', 'string', 2, 25, '', 'string...');
$code->setDescription('Description text');
$code->setPattern('^.{3,}$', 'You need at least 3 characters');
$code->setDatalist(array('list 1', 'list 2', 'list 3'));
$form->addElement($code, true);
$select = new Xoops\Form\Select('Select', 'id', '', 1, false);
示例#2
0
 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 . '&amp;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]) . '&amp;' : $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') . '&amp;com_id=' . $comment->getVar('id') . '&amp;com_mode=' . $mode . '&amp;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') . '&amp;com_id=' . $comment->getVar('id') . '&amp;com_mode=' . $mode . '&amp;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') . '&amp;com_id=' . $comment->getVar('id') . '&amp;com_rootid=' . $comment->getVar('rootid') . '&amp;com_mode=' . $mode . '&amp;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') . '&amp;com_id=' . $comment->getVar('id') . '&amp;com_rootid=' . $comment->getVar('rootid') . '&amp;com_mode=' . $mode . '&amp;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') . '&amp;com_mode=' . $mode . '&amp;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;
         }
     }
 }
示例#3
0
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @package      debugbar
 * @since
 * @author       XOOPS Development Team
 */
use Xoops\Core\Request;
use Xmf\Module\Helper;
use Xmf\Module\Permission;
include_once __DIR__ . '/admin_header.php';
$moduleAdmin = new \Xoops\Module\Admin();
$moduleAdmin->displayNavigation('permissions.php');
$helper = Helper::getHelper('monolog');
$permHelper = new Permission();
if ($permHelper) {
    // this is the name and item we are going to work with
    $gperm_name = 'use_monolog';
    $gperm_itemid = 0;
    // if this is a post operation get our variables
    if ('POST' === Request::getMethod()) {
        $name = $permHelper->defaultFieldName($gperm_name, $gperm_itemid);
        $groups = Request::getVar($name, array(), 'POST');
        $permHelper->savePermissionForItem($gperm_name, $gperm_itemid, $groups);
        echo $xoops->alert('success', _MA_MONOLOG_FORM_PROCESSED, _MA_MONOLOG_PERMISSION_FORM);
    }
    $form = new \Xoops\Form\ThemeForm(_MA_MONOLOG_PERMISSION_FORM, 'form', '', 'POST');
    $permElement = $permHelper->getGroupSelectFormForItem($gperm_name, $gperm_itemid, _MA_MONOLOG_PERMISSION_GROUPS, null, true);
    $form->addElement($permElement);
    $form->addElement(new \Xoops\Form\Button('', 'submit', _MA_MONOLOG_FORM_SUBMIT, 'submit'));
    echo $form->render();
}
include_once __DIR__ . '/admin_footer.php';
示例#4
0
$op = Request::getString('op', 'list');
$memberslist_id = Request::getArray('memberslist_id', array());
// Call Header
$xoops->header('admin:mailusers/mailusers_send_mail.tpl');
// Define Stylesheet
$xoops->theme()->addBaseStylesheetAssets('modules/system/css/admin.css');
$xoops->theme()->addBaseScriptAssets(array('@jquery', 'media/xoops/xoops.js', 'modules/system/js/admin.js'));
$admin_page = new \Xoops\Module\Admin();
$admin_page->renderNavigation('send_mails.php');
switch ($op) {
    case 'list':
    default:
        $display_criteria = 1;
        $form = new Xoops\Form\ThemeForm(_AM_MAILUSERS_LIST, "mailusers", "send_mails.php", 'post', true);
        //----------------------------------------
        if (!empty($memberslist_id) && Request::getMethod() == 'POST') {
            $user_count = count($memberslist_id);
            $display_names = "";
            for ($i = 0; $i < $user_count; ++$i) {
                $uid_hidden = new Xoops\Form\Hidden("mail_to_user[]", $memberslist_id[$i]);
                $form->addElement($uid_hidden);
                $display_names .= "<a href='" . \XoopsBaseConfig::get('url') . "/userinfo.php?uid=" . $memberslist_id[$i] . "' rel='external'>" . XoopsUser::getUnameFromId($memberslist_id[$i]) . "</a>, ";
                unset($uid_hidden);
            }
            $users_label = new Xoops\Form\Label(_AM_MAILUSERS_SENDTOUSERS2, substr($display_names, 0, -2));
            $form->addElement($users_label);
            $form->addElement($users_label);
            $display_criteria = 0;
        }
        //----------------------------------------
        if (!empty($display_criteria)) {
示例#5
0
 /**
  * @covers Xoops\Core\Request::getMethod
  */
 public function testGetMethod()
 {
     $method = Request::getMethod();
     $this->assertTrue(in_array($method, array('GET', 'HEAD', 'POST', 'PUT')));
 }