コード例 #1
0
ファイル: index.php プロジェクト: ming-hai/XoopsCore
 * @version         $Id$
 */
include dirname(dirname(__DIR__)) . '/mainfile.php';
$search = Search::getInstance();
if (!$search->getConfig('enable_search')) {
    header('Location: ' . XOOPS_URL . '/index.php');
    exit;
}
$xoops = Xoops::getInstance();
$action = Request::getCmd('action', 'search');
$query = Request::getString('query', '');
$andor = Request::getWord('andor', 'AND');
$mid = Request::getInt('mid', 0);
$uid = Request::getInt('uid', 0);
$start = Request::getInt('start', 0);
$mids = Request::getArray('mids', array());
$queries = array();
if ($action === "results") {
    if ($query == "") {
        $xoops->redirect("index.php", 1, _MD_SEARCH_PLZENTER);
    }
} else {
    if ($action === "showall") {
        if ($query == "" || empty($mid)) {
            $xoops->redirect("index.php", 1, _MD_SEARCH_PLZENTER);
        }
    } else {
        if ($action === "showallbyuser") {
            if (empty($mid) || empty($uid)) {
                $xoops->redirect("index.php", 1, _MD_SEARCH_PLZENTER);
            }
コード例 #2
0
ファイル: related.php プロジェクト: ming-hai/XoopsCore
 if (!$xoops->security()->check()) {
     $xoops->redirect('related.php', 3, implode(',', $xoops->security()->getErrors()));
 }
 $related_id = Request::getInt('related_id', 0);
 if ($related_id > 0) {
     $obj = $related_Handler->get($related_id);
 } else {
     $obj = $related_Handler->create();
 }
 //main
 $obj->setVar('related_name', Request::getString('related_name', ''));
 $obj->setVar('related_domenu', Request::getInt('related_domenu', 1));
 $obj->setVar('related_navigation', Request::getInt('related_navigation', 1));
 if ($related_newid = $related_Handler->insert($obj)) {
     $related_id = $related_id != 0 ? $related_id : $related_newid;
     $datas = Request::getArray('datas');
     $datas_exists = $link_Handler->getContentByRelated($related_newid);
     $datas_delete = array_diff(array_values($datas_exists), $datas);
     $datas_add = array_diff($datas, array_values($datas_exists));
     // delete
     if (count($datas_delete) != 0) {
         $criteria = $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('link_related_id', $related_id));
         $criteria->add(new Criteria('link_content_id', '(' . implode(', ', $datas_delete) . ')', 'IN'));
         $links_ids = $link_Handler->getIds($criteria);
         if (!$link_Handler->DeleteByIds($links_ids)) {
         }
     }
     // Add
     if (count($datas_add) != 0) {
         foreach ($datas_add as $weight => $content_id) {
コード例 #3
0
ファイル: xoops_smilies.php プロジェクト: ming-hai/XoopsCore
$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)) {
        $xoops->redirect('xoops_smilies.php', 2, implode('<br />', $msg));
    }
コード例 #4
0
ファイル: search.php プロジェクト: ming-hai/XoopsCore
    $xoops->redirect(PUBLISHER_URL, 2, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$xoops->disableModuleCache();
$xoops->header('module:publisher/publisher_search.tpl');
$xoopsTpl = $xoops->tpl();
$module_info_search = $publisher->getModule()->getInfo("search");
XoopsLoad::loadFile($publisher->path($module_info_search["file"]));
$limit = 10;
//$publisher->getConfig('idxcat_perpage');
$uid = 0;
$queries = array();
$andor = Request::getString('andor');
$start = Request::getInt('start');
$category = Request::getArray('category');
$username = Request::getString('uname');
$searchin = Request::getArray('searchin');
$sortby = Request::getString('sortby');
$term = Request::getString('term');
if (empty($category) || is_array($category) && in_array("all", $category)) {
    $category = array();
} else {
    $category = !is_array($category) ? explode(",", $category) : $category;
    $category = array_map("intval", $category);
}
$andor = in_array(strtoupper($andor), array("OR", "AND", "EXACT")) ? strtoupper($andor) : "OR";
$sortby = in_array(strtolower($sortby), array("itemid", "datesub", "title", "categoryid")) ? strtolower($sortby) : "itemid";
if (!(empty($_POST["submit"]) && empty($term))) {
    $next_search["category"] = implode(",", $category);
    $next_search["andor"] = $andor;
    $next_search["term"] = $term;
    $query = trim($term);
コード例 #5
0
ファイル: request.php プロジェクト: ming-hai/XoopsCore
$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);
$select->addOption(1, 'Select 1');
$select->addOption(2, 'Select 2');
$select->addOption('somebad id here', 'Select with bad id');
コード例 #6
0
ファイル: content.php プロジェクト: ming-hai/XoopsCore
 $obj->setVar('content_dotitle', in_array('title', $content_option));
 $obj->setVar('content_donotifications', in_array('notifications', $content_option));
 if (preg_match('/^\\d+$/', Request::getInt('content_weight', 0)) == false) {
     $error = true;
     $error_message .= PageLocale::E_WEIGHT . '<br />';
     $obj->setVar('content_weight', 0);
 } else {
     $obj->setVar('content_weight', Request::getInt('content_weight', 0));
 }
 if ($error == true) {
     $xoops->tpl()->assign('error_message', $error_message);
 } else {
     if ($newcontent_id = $content_Handler->insert($obj)) {
         // update permissions
         $perm_id = $content_id > 0 ? $content_id : $newcontent_id;
         $groups_view_item = Request::getArray('groups_view_item', array());
         $gperm_Handler->updatePerms($perm_id, $groups_view_item);
         //notifications
         if ($content_id == 0 && $xoops->isActiveModule('notifications')) {
             $notification_handler = Notifications::getInstance()->getHandlerNotification();
             $tags = array();
             $tags['MODULE_NAME'] = 'page';
             $tags['ITEM_NAME'] = Request::getString('content_title', '');
             $tags['ITEM_URL'] = \XoopsBaseConfig::get('url') . '/modules/page/viewpage.php?id=' . $newcontent_id;
             $notification_handler->triggerEvent('global', 0, 'newcontent', $tags);
             $notification_handler->triggerEvent('item', $newcontent_id, 'newcontent', $tags);
         }
         $xoops->redirect('content.php', 2, XoopsLocale::S_DATABASE_UPDATED);
     }
     echo $xoops->alert('error', $obj->getHtmlErrors());
 }
コード例 #7
0
ファイル: send_mails.php プロジェクト: redmexico/XoopsCore
     // Send
 // Send
 case 'send':
     $mail_send_to = Request::getArray('mail_send_to', array('mail'));
     $mail_inactive = Request::getInt('mail_inactive', 0);
     $mail_mailok = Request::getInt('mail_mailok', 0);
     $mail_lastlog_min = Request::getString('mail_lastlog_min', '');
     $mail_lastlog_max = Request::getString('mail_lastlog_max', '');
     $mail_idle_more = Request::getInt('mail_idle_more', 0);
     $mail_idle_less = Request::getInt('mail_idle_less', 0);
     $mail_regd_min = Request::getString('mail_regd_min', '');
     $mail_regd_max = Request::getString('mail_regd_max', '');
     $mail_to_group = Request::getArray('mail_to_group', array());
     $mail_to_group = array_map("intval", $mail_to_group);
     $mail_start = Request::getInt('mail_start', 0);
     $mail_to_user = Request::getArray('mail_to_user', array());
     $mail_to_user = array_map("intval", $mail_to_user);
     $mail_fromname = Request::getString('mail_fromname');
     $mail_fromemail = Request::getString('mail_fromemail');
     $mail_subject = Request::getString('mail_subject');
     $mail_body = Request::getString('mail_body');
     $count_criteria = 0;
     // user count via criteria;
     if (!empty($mail_send_to)) {
         $added = array();
         $added_id = array();
         $criteria = array();
         if ($mail_inactive) {
             $criteria[] = "level = 0";
         } else {
             if ($mail_mailok) {
コード例 #8
0
ファイル: item.php プロジェクト: ming-hai/XoopsCore
 /**
  * The name says it all
  */
 public function setVarsFromRequest()
 {
     $xoops = Xoops::getInstance();
     //Required fields
     if (isset($_REQUEST['categoryid'])) {
         $this->setVar('categoryid', Request::getInt('categoryid'));
     }
     if (isset($_REQUEST['title'])) {
         $this->setVar('title', Request::getString('title'));
     }
     if (isset($_REQUEST['body'])) {
         $this->setVar('body', Request::getText('body'));
     }
     //Not required fields
     if (isset($_REQUEST['summary'])) {
         $this->setVar('summary', Request::getText('summary'));
     }
     if (isset($_REQUEST['subtitle'])) {
         $this->setVar('subtitle', Request::getString('subtitle'));
     }
     if (isset($_REQUEST['item_tag'])) {
         $this->setVar('item_tag', Request::getString('item_tag'));
     }
     if (isset($_REQUEST['image_featured'])) {
         $image_item = Request::getArray('image_item');
         $image_featured = Request::getString('image_featured');
         //Todo: get a better image class for xoops!
         //Image hack
         $image_item_ids = array();
         $qb = \Xoops::getInstance()->db()->createXoopsQueryBuilder();
         $qb->select('i.image_id', 'i.image_name')->fromPrefix('image', 'i')->orderBy('i.image_id');
         $result = $qb->execute();
         while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
             $image_name = $myrow['image_name'];
             $id = $myrow['image_id'];
             if ($image_name == $image_featured) {
                 $this->setVar('image', $id);
             }
             if (in_array($image_name, $image_item)) {
                 $image_item_ids[] = $id;
             }
         }
         $this->setVar('images', implode('|', $image_item_ids));
     }
     if (isset($_REQUEST['uid'])) {
         $this->setVar('uid', Request::getInt('uid'));
     } elseif ($this->isNew()) {
         $this->setVar('uid', $xoops->isUser() ? $xoops->user->getVar('uid') : 0);
     }
     if (isset($_REQUEST['author_alias'])) {
         $this->setVar('author_alias', Request::getString('author_alias'));
         if ($this->getVar('author_alias') != '') {
             $this->setVar('uid', 0);
         }
     }
     if (isset($_REQUEST['datesub'])) {
         $this->setVar('datesub', strtotime($_REQUEST['datesub']['date']) + $_REQUEST['datesub']['time']);
     } elseif ($this->isNew()) {
         $this->setVar('datesub', time());
     }
     if (isset($_REQUEST['item_short_url'])) {
         $this->setVar('short_url', Request::getString('item_short_url'));
     }
     if (isset($_REQUEST['item_meta_keywords'])) {
         $this->setVar('meta_keywords', Request::getString('item_meta_keywords'));
     }
     if (isset($_REQUEST['item_meta_description'])) {
         $this->setVar('meta_description', Request::getString('item_meta_description'));
     }
     if (isset($_REQUEST['weight'])) {
         $this->setVar('weight', Request::getInt('weight'));
     }
     if (isset($_REQUEST['allowcomments'])) {
         $this->setVar('cancomment', Request::getInt('allowcomments'));
     } elseif ($this->isNew()) {
         $this->setVar('cancoment', $this->publisher->getConfig('submit_allowcomments'));
     }
     if (isset($_REQUEST['status'])) {
         $this->setVar('status', Request::getInt('status'));
     } elseif ($this->isNew()) {
         $this->setVar('status', $this->publisher->getConfig('submit_status'));
     }
     if (isset($_REQUEST['dohtml'])) {
         $this->setVar('dohtml', Request::getInt('dohtml'));
     } elseif ($this->isNew()) {
         $this->setVar('dohtml', $this->publisher->getConfig('submit_dohtml'));
     }
     if (isset($_REQUEST['dosmiley'])) {
         $this->setVar('dosmiley', Request::getInt('dosmiley'));
     } elseif ($this->isNew()) {
         $this->setVar('dosmiley', $this->publisher->getConfig('submit_dosmiley'));
     }
     if (isset($_REQUEST['doxcode'])) {
         $this->setVar('doxcode', Request::getInt('doxcode'));
     } elseif ($this->isNew()) {
         $this->setVar('doxcode', $this->publisher->getConfig('submit_doxcode'));
     }
     if (isset($_REQUEST['doimage'])) {
         $this->setVar('doimage', Request::getInt('doimage'));
     } elseif ($this->isNew()) {
         $this->setVar('doimage', $this->publisher->getConfig('submit_doimage'));
     }
     if (isset($_REQUEST['dolinebreak'])) {
         $this->setVar('dobr', Request::getInt('dolinebreak'));
     } elseif ($this->isNew()) {
         $this->setVar('dobr', $this->publisher->getConfig('submit_dobr'));
     }
     if (isset($_REQUEST['notify'])) {
         $this->setVar('notifypub', Request::getInt('notify'));
     }
 }
コード例 #9
0
ファイル: categories.php プロジェクト: ming-hai/XoopsCore
 $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');
     foreach ($permissions as $k => $permission) {
         $groups = Request::getArray($k, array(FixedGroups::ADMIN));
         if (!in_array(FixedGroups::ADMIN, $groups)) {
             array_push($groups, FixedGroups::ADMIN);
         }
         foreach ($groups as $group) {
             $perm_obj = $xoops->getHandlerGroupPermission()->create();
             $perm_obj->setVar('gperm_groupid', $group);
             $perm_obj->setVar('gperm_itemid', $imgcat_id);
             $perm_obj->setVar('gperm_name', $permission);
             $perm_obj->setVar('gperm_modid', $xoops->module->getVar('mid'));
             $xoops->getHandlerGroupPermission()->insert($perm_obj);
             unset($perm_obj);
         }
     }
     $xoops->redirect('categories.php', 2, _AM_IMAGES_CAT_SAVE);
 }
コード例 #10
0
ファイル: RequestTest.php プロジェクト: redmexico/XoopsCore
 /**
  * @covers Xoops\Core\Request::getArray
  */
 public function testGetArray()
 {
     $varname = 'RequestTest';
     $testArray = array('one', 'two', 'three');
     $_REQUEST[$varname] = $testArray;
     $get = Request::getArray($varname, null, 'request');
     $this->assertTrue(is_array($get));
     $this->assertEquals($get, $testArray);
     $testArray2 = array('one', 'two', '<script>three</script>');
     $_REQUEST[$varname] = $testArray2;
     $get = Request::getArray($varname, null, 'request');
     $this->assertTrue(is_array($get));
     $this->assertEquals($get, $testArray);
 }