function publisher_date_to_date_show($options) { $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $publisher = Publisher::getInstance(); $block = array(); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('datesub', strtotime($options[0]), '>')); $criteria->add(new Criteria('datesub', strtotime($options[1]), '<')); $criteria->setSort('datesub'); $criteria->setOrder('DESC'); // creating the ITEM objects that belong to the selected category $itemsObj = $publisher->getItemHandler()->getItemObjects($criteria); $totalItems = count($itemsObj); if ($itemsObj) { for ($i = 0; $i < $totalItems; ++$i) { $newItems['itemid'] = $itemsObj[$i]->getVar('itemid'); $newItems['title'] = $itemsObj[$i]->title(); $newItems['categoryname'] = $itemsObj[$i]->getCategoryName(); $newItems['categoryid'] = $itemsObj[$i]->getVar('categoryid'); $newItems['date'] = $itemsObj[$i]->datesub(); $newItems['poster'] = $itemsObj[$i]->linkedPosterName(); $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65); $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink(); $block['items'][] = $newItems; } $block['lang_title'] = _MB_PUBLISHER_ITEMS; $block['lang_category'] = _MB_PUBLISHER_CATEGORY; $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; $block['lang_date'] = _MB_PUBLISHER_DATE; $modulename = $myts->displayTarea($publisher->getModule()->getVar('name')); $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . " " . $modulename; $block['lang_articles_from_to'] = sprintf(_MB_PUBLISHER_ARTICLES_FROM_TO, $options[0], $options[1]); } return $block; }
function smarty_outputfilter_shortcodes($output, Smarty_Internal_Template $template) { $shortcodes = \Xoops\Core\Text\Sanitizer::getInstance()->getShortCodes(); $shortcodes->addShortcode('nosc42', function ($attributes, $content, $tagName) { return $content; }); // break out the body content $bodyPattern = '/<body[^>]*>(.*?)<\\/body>/is'; // breaks out form elements $scPattern = '/((<textarea[\\S\\s]*\\/textarea>)|(<input[\\S\\s]*>)|(<select[\\S\\s]*\\/select>)|(<script[\\S\\s]*\\/script>)|(<style[\\S\\s]*\\/style>))/U'; $text = preg_replace_callback($bodyPattern, function ($matches) use($scPattern, $shortcodes) { $element = preg_replace_callback($scPattern, function ($innerMatches) { return '[nosc42]' . $innerMatches[0] . '[/nosc42]'; }, $matches[1]); if ($element === null) { trigger_error('preg_last_error=' . preg_last_error(), E_USER_WARNING); return $matches[1]; } return $element; }, $output); if ($text === null) { trigger_error('preg_last_error=' . preg_last_error(), E_USER_WARNING); return $output; } $text = $shortcodes->process($text); return $text; }
/** * purifyText * * @param string $text text to clean * @param boolean $keyword replace some punctuation with white space * * @return string cleaned text */ public static function purifyText($text, $keyword = false) { $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $text = str_replace(' ', ' ', $text); $text = str_replace('<br />', ' ', $text); $text = str_replace('<br/>', ' ', $text); $text = str_replace('<br', ' ', $text); $text = strip_tags($text); $text = html_entity_decode($text); $text = $myts->undoHtmlSpecialChars($text); $text = str_replace(')', ' ', $text); $text = str_replace('(', ' ', $text); $text = str_replace(':', ' ', $text); $text = str_replace('&euro', ' euro ', $text); $text = str_replace('&hellip', '...', $text); $text = str_replace('&rsquo', ' ', $text); $text = str_replace('!', ' ', $text); $text = str_replace('?', ' ', $text); $text = str_replace('"', ' ', $text); $text = str_replace('-', ' ', $text); $text = str_replace('\\n', ' ', $text); $text = str_replace('―', ' ', $text); if ($keyword) { $text = str_replace('.', ' ', $text); $text = str_replace(',', ' ', $text); $text = str_replace('\'', ' ', $text); } $text = str_replace(';', ' ', $text); return $text; }
/** * search - search * * @param string[] $queryArray search terms * @param string $andor and/or how to treat search terms * @param integer $limit max number to return * @param integer $offset offset of first row to return * @param integer $userid a specific user id to limit the query * * @return array of result items * 'title' => the item title * 'content' => brief content or summary * 'link' => link to visit item * 'time' => time modified (unix timestamp) * 'uid' => author uid * 'image' => icon for search display * */ public function search($queryArray, $andor, $limit, $offset, $userid) { $andor = strtolower($andor) === 'and' ? 'and' : 'or'; $qb = \Xoops::getInstance()->db()->createXoopsQueryBuilder(); $eb = $qb->expr(); $qb->select('DISTINCT *')->fromPrefix('page_content')->where($eb->neq('content_status', '0'))->orderBy('content_create', 'DESC')->setFirstResult($offset)->setMaxResults($limit); if (is_array($queryArray) && !empty($queryArray)) { $queryParts = array(); foreach ($queryArray as $i => $q) { $qterm = ':qterm' . $i; $qb->setParameter($qterm, '%' . $q . '%', \PDO::PARAM_STR); $queryParts[] = $eb->orX($eb->like('content_title', $qterm), $eb->like('content_text', $qterm), $eb->like('content_shorttext', $qterm)); } if ($andor === 'and') { $qb->andWhere(call_user_func_array(array($eb, "andX"), $queryParts)); } else { $qb->andWhere(call_user_func_array(array($eb, "orX"), $queryParts)); } } else { $qb->setParameter(':uid', (int) $userid, \PDO::PARAM_INT); $qb->andWhere($eb->eq('content_author', ':uid')); } $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $items = array(); $result = $qb->execute(); while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) { $content = $myrow["content_shorttext"] . "<br /><br />" . $myrow["content_text"]; $content = $myts->displayTarea($content); $items[] = array('title' => $myrow['content_title'], 'content' => Metagen::getSearchSummary($content, $queryArray), 'link' => "viewpage.php?id=" . $myrow["content_id"], 'time' => $myrow['content_create'], 'uid' => $myrow['content_author'], 'image' => 'images/logo_small.png'); } return $items; }
function smarty_block_noshortcodes($params, $content, $template, &$repeat) { // only output on the closing tag if (!$repeat) { if (isset($content)) { $ts = \Xoops\Core\Text\Sanitizer::getInstance(); return $ts->escapeShortCodes($content); } } }
/** * Output a dump of a variable * * @param mixed $var variable to dump * @param bool $echo true to echo dump, false to return dump as string * * @return string */ public static function dumpVar($var, $echo = true) { $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $msg = $myts->displayTarea(var_export($var, true)); $msg = "<div style='padding: 5px; font-weight: bold'>{$msg}</div>"; if ($echo) { echo $msg; } return $msg; }
/** * @param string $title * @param string $keywords * @param string $description * @param bool $categoryPath */ public function __construct($title, $keywords = '', $description = '', $categoryPath = false) { $this->publisher = Publisher::getInstance(); $this->_myts = \Xoops\Core\Text\Sanitizer::getInstance(); $this->setCategoryPath($categoryPath); $this->setTitle($title); $this->setDescription($description); if ($keywords == '') { $keywords = $this->createMetaKeywords(); } $this->setKeywords($keywords); }
/** * Get an array with all the options * * @param integer $encode encode special characters, potential values: * 0 - skip * 1 - only for value * 2 - for both value and name * * @return array Associative array of value->name pairs */ public function getOptions($encode = 0) { $options = $this->get('option', []); if (!$encode) { return $options; } $myts = Sanitizer::getInstance(); $value = array(); foreach ($options as $val => $name) { $value[(bool) $encode ? $myts->htmlSpecialChars($val) : $val] = $encode > 1 ? $myts->htmlSpecialChars($name) : $name; } return $value; }
function publisher_items_recent_show($options) { $publisher = Publisher::getInstance(); $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $block = array(); $selectedcatids = explode(',', $options[0]); if (in_array(0, $selectedcatids)) { $allcats = true; } else { $allcats = false; } $sort = $options[1]; $order = PublisherUtils::getOrderBy($sort); $limit = $options[2]; $start = 0; // creating the ITEM objects that belong to the selected category if ($allcats) { $criteria = null; } else { $criteria = new CriteriaCompo(); $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN')); } $itemsObj = $publisher->getItemHandler()->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true); $totalItems = count($itemsObj); if ($itemsObj) { for ($i = 0; $i < $totalItems; ++$i) { $newItems['itemid'] = $itemsObj[$i]->getVar('itemid'); $newItems['title'] = $itemsObj[$i]->title(); $newItems['categoryname'] = $itemsObj[$i]->getCategoryName(); $newItems['categoryid'] = $itemsObj[$i]->getVar('categoryid'); $newItems['date'] = $itemsObj[$i]->datesub(); $newItems['poster'] = $itemsObj[$i]->linkedPosterName(); $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65); $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink(); $block['items'][] = $newItems; } $block['lang_title'] = _MB_PUBLISHER_ITEMS; $block['lang_category'] = _MB_PUBLISHER_CATEGORY; $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; $block['lang_date'] = _MB_PUBLISHER_DATE; $modulename = $myts->displayTarea($publisher->getModule()->getVar('name')); $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . " " . $modulename; } return $block; }
/** * Blocks functions * * @copyright XOOPS Project (http://xoops.org) * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @author Kazumi Ono (AKA onokazu) * @package system * @version $Id$ */ function b_system_info_show($options) { $xoops = Xoops::getInstance(); $xoops->db(); $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $block = array(); if (!empty($options[3])) { $block['showgroups'] = true; $qb = $xoops->db()->createXoopsQueryBuilder(); $eb = $qb->expr(); $sql = $qb->select('u.uid')->addSelect('u.uname')->addSelect('u.email')->addSelect('u.user_viewemail')->addSelect('u.user_avatar')->addSelect('g.name AS groupname')->fromPrefix('system_usergroup', 'l')->leftJoinPrefix('l', 'system_user', 'u', 'l.uid=u.uid')->leftJoinPrefix('l', 'system_group', 'g', 'l.groupid=g.groupid')->where($eb->eq('g.group_type', ':gtype'))->orderBy('l.groupid')->addOrderBy('u.uid')->setParameter(':gtype', 'Admin', \PDO::PARAM_STR); $result = $sql->execute(); if ($result->errorCode() < 2000) { // return 00000 is ok, 01nnn is warning $prev_caption = ""; $i = 0; while ($userinfo = $result->fetch(PDO::FETCH_ASSOC)) { $response = $xoops->service("Avatar")->getAvatarUrl($userinfo); $avatar = $response->getValue(); $avatar = empty($avatar) ? \XoopsBaseConfig::get('uploads-url') . '/blank.gif' : $avatar; if ($prev_caption != $userinfo['groupname']) { $prev_caption = $userinfo['groupname']; $block['groups'][$i]['name'] = $myts->htmlSpecialChars($userinfo['groupname']); } if ($xoops->isUser()) { $block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlSpecialChars($userinfo['uname']), 'pm_link' => \XoopsBaseConfig::get('url') . "/pmlite.php?send2=1&to_userid=" . $userinfo['uid'], 'avatar' => $avatar); } else { if ($userinfo['user_viewemail']) { $block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlSpecialChars($userinfo['uname']), 'msg_link' => $userinfo['email'], 'avatar' => $avatar); } else { $block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlSpecialChars($userinfo['uname'])); } } ++$i; } } } else { $block['showgroups'] = false; } $block['logourl'] = \XoopsBaseConfig::get('url') . '/images/' . $options[2]; $block['recommendlink'] = "<a href=\"javascript:openWithSelfMain('" . \XoopsBaseConfig::get('url') . "/misc.php?action=showpopups&type=friend&op=sendform&t=" . time() . "','friend'," . $options[0] . "," . $options[1] . ")\">" . SystemLocale::RECOMMEND_US . "</a>"; return $block; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->sanitizer = Sanitizer::getInstance(); $this->object = new SyntaxHighlight($this->sanitizer); }
/** * Sets database and sanitizer for easy access */ public function __construct() { //$this->db = \Xoops::getInstance()->db(); $this->ts = Sanitizer::getInstance(); }
/** * return the content of the block for output * * @param string $format Dtype::FORMAT_xxxx constant * @param string $c_type type of content, possible values * H : custom HTML block * P : custom PHP block * S : use text sanitizer (smilies enabled) * T : use text sanitizer (smilies disabled) * * @return string content for output */ public function getContent($format = 's', $c_type = 'T') { $format = strtolower($format); $c_type = strtoupper($c_type); switch ($format) { case 's': // check the type of content // H : custom HTML block // P : custom PHP block // S : use text sanitizer (smilies enabled) // T : use text sanitizer (smilies disabled) if ($c_type === 'H') { return str_replace('{X_SITEURL}', $this->xoops_url . '/', $this->getVar('content', 'n')); } else { if ($c_type === 'P') { ob_start(); echo eval($this->getVar('content', 'n')); $content = ob_get_contents(); ob_end_clean(); return str_replace('{X_SITEURL}', $this->xoops_url . '/', $content); } else { if ($c_type === 'S') { $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $content = str_replace('{X_SITEURL}', $this->xoops_url . '/', $this->getVar('content', 'n')); return $myts->displayTarea($content, 1, 1); } else { $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $content = str_replace('{X_SITEURL}', \XoopsBaseConfig::get('url') . '/', $this->getVar('content', 'n')); return $myts->displayTarea($content, 1, 0); } } } break; case 'e': return $this->getVar('content', 'e'); break; default: return $this->getVar('content', 'n'); break; } }
/** * codeIcon * * @return string */ public function codeIcon() { $textarea_id = $this->getName(); $xoops = \Xoops::getInstance(); $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $code = ''; $code .= '<img src="' . $xoops->url('images/form/url.gif') . '" alt="' . \XoopsLocale::URL . '" title="' . \XoopsLocale::URL . '" onclick="xoopsCodeUrl(\'' . $textarea_id . '\', \'' . $myts->escapeForJavascript(\XoopsLocale::ENTER_LINK_URL) . '\', \'' . $myts->escapeForJavascript(\XoopsLocale::ENTER_WEBSITE_TITLE) . '\')" onmouseover="style.cursor=\'hand\'" /> '; $code .= '<img src="' . $xoops->url('images/form/email.gif') . '" alt="' . \XoopsLocale::EMAIL . '" title="' . \XoopsLocale::EMAIL . '" onclick="xoopsCodeEmail(\'' . $textarea_id . '\', \'' . $myts->escapeForJavascript(\XoopsLocale::ENTER_EMAIL) . '\');" onmouseover="style.cursor=\'hand\'" /> '; $code .= '<img src="' . $xoops->url('images/form/imgsrc.gif') . '" alt="' . \XoopsLocale::IMAGES . '" title="' . \XoopsLocale::IMAGES . '" onclick="xoopsCodeImg(\'' . $textarea_id . '\', \'' . $myts->escapeForJavascript(\XoopsLocale::ENTER_IMAGE_URL) . '\', \'' . $myts->escapeForJavascript(\XoopsLocale::ENTER_IMAGE_POSITION) . '\', \'' . $myts->escapeForJavascript(\XoopsLocale::IMAGE_POSITION_DESCRIPTION) . '\', \'' . $myts->escapeForJavascript(\XoopsLocale::E_ENTER_IMAGE_POSITION) . '\', \'' . $myts->escapeForJavascript(\XoopsLocale::WIDTH) . '\');" onmouseover="style.cursor=\'hand\'" /> '; $extensions = array_filter($myts->listExtensions()); foreach ($extensions as $extension) { list($button, $js) = $myts->getDhtmlEditorSupport($extension, $textarea_id); if (!empty($button)) { $code .= $button; } if (!empty($js)) { $this->js .= $js; } } $code .= '<img src="' . $xoops->url('images/form/code.gif') . '" alt="' . \XoopsLocale::SOURCE_CODE . '" title="' . \XoopsLocale::SOURCE_CODE . '" onclick="xoopsCodeCode(\'' . $textarea_id . '\', \'' . $myts->escapeForJavascript(\XoopsLocale::ENTER_CODE) . '\');" onmouseover="style.cursor=\'hand\'" /> '; $code .= '<img src="' . $xoops->url('images/form/quote.gif') . '" alt="' . \XoopsLocale::QUOTE . '" title="' . \XoopsLocale::QUOTE . '" onclick="xoopsCodeQuote(\'' . $textarea_id . '\', \'' . $myts->escapeForJavascript(\XoopsLocale::ENTER_QUOTE) . '\');" onmouseover="style.cursor=\'hand\'" /> '; $response = \Xoops::getInstance()->service('emoji')->renderEmojiSelector($this->getName()); if ($response->isSuccess()) { $emojiSelector = $response->getValue(); $code .= $emojiSelector; } return $code; }
public static function seoTitle($title = '', $withExt = true) { /** * if XOOPS ML is present, let's sanitize the title with the current language */ $myts = \Xoops\Core\Text\Sanitizer::getInstance(); if (method_exists($myts, 'formatForML')) { $title = $myts->formatForML($title); } // Transformation de la chaine en minuscule // Codage de la chaine afin d'éviter les erreurs 500 en cas de caractères imprévus $title = rawurlencode(strtolower($title)); // Transformation des ponctuations // Tab Space ! " # % & ' ( ) , / : ; < = > ? @ [ \ ] ^ { | } ~ . $pattern = array("/%09/", "/%20/", "/%21/", "/%22/", "/%23/", "/%25/", "/%26/", "/%27/", "/%28/", "/%29/", "/%2C/", "/%2F/", "/%3A/", "/%3B/", "/%3C/", "/%3D/", "/%3E/", "/%3F/", "/%40/", "/%5B/", "/%5C/", "/%5D/", "/%5E/", "/%7B/", "/%7C/", "/%7D/", "/%7E/", "/\\./"); $rep_pat = array("-", "-", "", "", "", "-100", "", "-", "", "", "", "-", "", "", "", "-", "", "", "-at-", "", "-", "", "-", "", "-", "", "-", ""); $title = preg_replace($pattern, $rep_pat, $title); // Transformation des caractères accentués // è é ê ë ç à â ä î ï ù ü û ô ö $pattern = array("/%B0/", "/%E8/", "/%E9/", "/%EA/", "/%EB/", "/%E7/", "/%E0/", "/%E2/", "/%E4/", "/%EE/", "/%EF/", "/%F9/", "/%FC/", "/%FB/", "/%F4/", "/%F6/"); $rep_pat = array("-", "e", "e", "e", "e", "c", "a", "a", "a", "i", "i", "u", "u", "u", "o", "o"); $title = preg_replace($pattern, $rep_pat, $title); if (sizeof($title) > 0) { if ($withExt) { $title .= '.html'; } return $title; } return ''; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->sanitizer = Sanitizer::getInstance(); $this->object = new TextFilter($this->sanitizer); }
/** * Retrieve a list of objects data * * @param CriteriaElement|null $criteria criteria to match * @param int $limit Max number of objects to fetch * @param int $start Which record to start at * * @return array */ public function getList(CriteriaElement $criteria = null, $limit = 0, $start = 0) { //$qb = Xoops::getInstance()->db()->createXoopsQueryBuilder(); $qb = $this->handler->db2->createXoopsQueryBuilder(); $ret = array(); $qb->select($this->handler->keyName); if (!empty($this->handler->identifierName)) { $qb->addSelect($this->handler->identifierName); } $qb->from($this->handler->table, null); if ($limit != 0 || $start != 0) { $qb->setFirstResult($start)->setMaxResults($limit); } $qb->orderBy($this->handler->keyName); // any criteria order will override if (!empty($criteria)) { $qb = $criteria->renderQb($qb); } $result = $qb->execute(); if (!$result) { return $ret; } $myts = \Xoops\Core\Text\Sanitizer::getInstance(); while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) { // identifiers should be textboxes, so sanitize them like that $ret[$myrow[$this->handler->keyName]] = empty($this->handler->identifierName) ? 1 : $myts->htmlSpecialChars($myrow[$this->handler->identifierName]); } return $ret; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->sanitizer = Sanitizer::getInstance(); $this->object = new UnorderedList($this->sanitizer); }
/** * Updated by Catzwolf 11 Jan 2004 * find the username for a given ID * * @param int $userid ID of the user to find * @param int $usereal switch for usename or realname * * @return string name of the user. name for 'anonymous' if not found. */ public static function getUnameFromId($userid, $usereal = 0) { $xoops = \Xoops::getInstance(); $userid = (int) $userid; $usereal = (int) $usereal; if ($userid > 0) { $member_handler = $xoops->getHandlerMember(); $user = $member_handler->getUser($userid); if (is_object($user)) { $ts = \Xoops\Core\Text\Sanitizer::getInstance(); if ($usereal) { $name = $user->getVar('name'); if ($name != '') { return $ts->htmlSpecialChars($name); } else { return $ts->htmlSpecialChars($user->getVar('uname')); } } else { return $ts->htmlSpecialChars($user->getVar('uname')); } } } return $xoops->getConfig('anonymous'); }
/** * Get {@link Xoops\Form\ThemeForm} for registering new users * * @param XoopsUser $user * @param $profile * @param null $step * @return Xoops\Form\ThemeForm */ function profile_getRegisterForm(XoopsUser $user, $profile, $step = null) { $xoops = Xoops::getInstance(); $action = $_SERVER['REQUEST_URI']; $step_no = $step['step_no']; $use_token = $step['step_no'] > 0 ? true : false; $reg_form = new Xoops\Form\ThemeForm($step['step_name'], 'regform', $action, 'post', $use_token); if ($step['step_desc']) { $reg_form->addElement(new Xoops\Form\Label('', $step['step_desc'])); } if ($step_no == 1) { //$uname_size = $GLOBALS['xoopsConfigUser']['maxuname'] < 35 ? $GLOBALS['xoopsConfigUser']['maxuname'] : 35; $elements[0][] = array('element' => new Xoops\Form\Text(XoopsLocale::USERNAME, 'uname', 40, $xoops->getConfig('maxuname'), $user->getVar('uname', 'e')), 'required' => true); $weights[0][] = 0; $elements[0][] = array('element' => new Xoops\Form\Text(XoopsLocale::EMAIL, 'email', 40, 160, $user->getVar('email', 'e')), 'required' => true); $weights[0][] = 0; $elements[0][] = array('element' => new Xoops\Form\Password(XoopsLocale::PASSWORD, 'pass'), 'required' => true); $weights[0][] = 0; $elements[0][] = array('element' => new Xoops\Form\Password(XoopsLocale::VERIFY_PASSWORD, 'vpass'), 'required' => true); $weights[0][] = 0; } // Dynamic fields /* @var $profile_handler ProfileProfileHandler */ $profile_handler = \Xoops::getModuleHelper('profile')->getHandler('profile'); $fields = $profile_handler->loadFields(); $_SESSION['profile_required'] = array(); $weights = array(); /* @var ProfileField $field */ foreach ($fields as $field) { if ($field->getVar('step_id') == $step['step_id']) { $fieldinfo['element'] = $field->getEditElement($user, $profile); //assign and check (=) if ($fieldinfo['required'] = $field->getVar('field_required')) { $_SESSION['profile_required'][$field->getVar('field_name')] = $field->getVar('field_title'); } $key = $field->getVar('cat_id'); $elements[$key][] = $fieldinfo; $weights[$key][] = $field->getVar('field_weight'); } } ksort($elements); foreach (array_keys($elements) as $k) { array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]); foreach (array_keys($elements[$k]) as $i) { $reg_form->addElement($elements[$k][$i]['element'], $elements[$k][$i]['required']); } } //end of Dynamic User fields $myts = \Xoops\Core\Text\Sanitizer::getInstance(); if ($step_no == 1 && $xoops->getConfig('reg_dispdsclmr') != 0 && $xoops->getConfig('reg_disclaimer') != '') { $disc_tray = new Xoops\Form\ElementTray(XoopsLocale::DISCLAIMER, '<br />'); $disc_text = new Xoops\Form\Label("", "<div class=\"pad5\">" . $myts->displayTarea($xoops->getConfig('reg_disclaimer'), 1) . "</div>"); $disc_tray->addElement($disc_text); $agree_chk = new Xoops\Form\Checkbox('', 'agree_disc'); $agree_chk->addOption(1, XoopsLocale::I_AGREE_TO_THE_ABOVE); $disc_tray->addElement($agree_chk); $reg_form->addElement($disc_tray); } if ($step_no == 1) { $reg_form->addElement(new Xoops\Form\Captcha(), true); } $reg_form->addElement(new Xoops\Form\Hidden('uid', $user->getVar('uid'))); $reg_form->addElement(new Xoops\Form\Hidden('step', $step_no)); $reg_form->addElement(new Xoops\Form\Button('', 'submitButton', XoopsLocale::A_SUBMIT, 'submit')); return $reg_form; }
/** * @param string $display * @param int $max_char_title * @param int $max_char_summary * @param bool $full_summary * * @return array */ public function toArray($display = 'default', $max_char_title = 0, $max_char_summary = 0, $full_summary = false) { $item_page_id = -1; if (is_numeric($display)) { $item_page_id = $display; $display = 'all'; } $item['itemid'] = $this->getVar('itemid'); $item['uid'] = $this->getVar('uid'); $item['titlelink'] = $this->getItemLink(false, $max_char_title); $item['subtitle'] = $this->subtitle(); $item['datesub'] = $this->datesub(); $item['counter'] = $this->getVar('counter'); switch ($display) { case 'summary': case 'list': break; case 'full': case 'wfsection': case 'default': $summary = $this->summary($max_char_summary); if (!$summary) { $summary = $this->body($max_char_summary); } $item['summary'] = $summary; $item = $this->toArrayFull($item); break; case 'all': $item = $this->toArrayFull($item); $item = $this->toArrayAll($item, $item_page_id); break; } // Highlighting searched words $highlight = true; if ($highlight && isset($_GET['keywords'])) { $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $keywords = $myts->htmlSpecialChars(trim(urldecode($_GET['keywords']))); $fields = array('title', 'maintext', 'summary'); foreach ($fields as $field) { if (isset($item[$field])) { $item[$field] = $this->highlight($item[$field], $keywords); } } } return $item; }
/** * @param array $obj * @param XoopsModule $mod */ public function getForm(&$obj, XoopsModule $mod) { $xoops = Xoops::getInstance(); $helper = Userconfigs::getInstance(); $config_handler = $helper->getHandlerConfig(); /* @var $plugin UserconfigsPluginInterface */ if ($plugin = \Xoops\Module\Plugin::getPlugin($mod->getVar('dirname'), 'userconfigs')) { parent::__construct('', 'pref_form', 'index.php', 'post', true); if ($mod->getVar('dirname') !== 'system') { $xoops->loadLanguage('modinfo', $mod->getVar('dirname')); $xoops->loadLocale($mod->getVar('dirname')); } $configs = $plugin->configs(); $configNames = array(); foreach (array_keys($configs) as $i) { $configNames[$configs[$i]['name']] =& $configs[$i]; } $configCats = $plugin->categories(); if (!$configCats) { $configCats = array('default' => array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => '')); } if (!in_array('default', array_keys($configCats))) { $configCats['default'] = array('name' => _MD_USERCONFIGS_CONFIGS, 'description' => ''); } foreach (array_keys($configNames) as $name) { if (!isset($configNames[$name]['category'])) { $configNames[$name]['category'] = 'default'; } } $tabTray = new Xoops\Form\TabTray('', 'pref_tabtay'); $tabs = array(); foreach ($configCats as $name => $info) { $tabs[$name] = new Xoops\Form\Tab($info['name'], 'pref_tab_' . $name); if (isset($info['description']) && $info['description'] != '') { $tabs[$name]->addElement(new Xoops\Form\Label('', $info['description'])); } } $count = count($obj); for ($i = 0; $i < $count; ++$i) { $title = \Xoops\Locale::translate($obj[$i]->getVar('conf_title'), $mod->getVar('dirname')); $desc = $obj[$i]->getVar('conf_desc') != '' ? \Xoops\Locale::translate($obj[$i]->getVar('conf_desc'), $mod->getVar('dirname')) : ''; switch ($obj[$i]->getVar('conf_formtype')) { case 'textarea': $myts = \Xoops\Core\Text\Sanitizer::getInstance(); if ($obj[$i]->getVar('conf_valuetype') === 'array') { // this is exceptional.. only when value type is arrayneed a smarter way for this $ele = $obj[$i]->getVar('conf_value') != '' ? new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars(implode('|', $obj[$i]->getConfValueForOutput())), 5, 5) : new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), '', 5, 5); } else { $ele = new Xoops\Form\TextArea($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput()), 5, 5); } break; case 'select': $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id'))); $opcount = count($options); for ($j = 0; $j < $opcount; ++$j) { $optval = \Xoops\Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname')); $optkey = \Xoops\Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname')); $ele->addOption($optval, $optkey); } break; case 'select_multi': $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true); $options = $config_handler->getConfigOptions(new Criteria('conf_id', $obj[$i]->getVar('conf_id'))); $opcount = count($options); for ($j = 0; $j < $opcount; ++$j) { $optval = \Xoops\Locale::translate($options[$j]->getVar('confop_value'), $mod->getVar('dirname')); $optkey = \Xoops\Locale::translate($options[$j]->getVar('confop_name'), $mod->getVar('dirname')); $ele->addOption($optval, $optkey); } break; case 'yesno': $ele = new Xoops\Form\RadioYesNo($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); break; case 'theme': case 'theme_multi': $ele = $obj[$i]->getVar('conf_formtype') !== 'theme_multi' ? new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()) : new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput(), 5, true); $dirlist = XoopsLists::getThemesList(); if (!empty($dirlist)) { asort($dirlist); $ele->addOptionArray($dirlist); } break; case 'tplset': $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); $tplset_handler = $xoops->getHandlerTplSet(); $tplsetlist = $tplset_handler->getNameList(); asort($tplsetlist); foreach ($tplsetlist as $key => $name) { $ele->addOption($key, $name); } break; case 'cpanel': $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); /* $ele = new Xoops\Form\Select($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput()); XoopsLoad::load("cpanel", "system"); $list = XoopsSystemCpanel::getGuis(); $ele->addOptionArray($list); */ break; case 'timezone': $ele = new Xoops\Form\SelectTimeZone($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); break; case 'language': $ele = new Xoops\Form\SelectLanguage($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); break; case 'locale': $ele = new Xoops\Form\SelectLocale($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); break; case 'startpage': $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); $module_handler = $xoops->getHandlerModule(); $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); $criteria->add(new Criteria('isactive', 1)); $moduleslist = $module_handler->getNameList($criteria, true); $moduleslist['--'] = XoopsLocale::NONE; $ele->addOptionArray($moduleslist); break; case 'group': $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false); break; case 'group_multi': $ele = new Xoops\Form\SelectGroup($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true); break; // RMV-NOTIFY: added 'user' and 'user_multi' // RMV-NOTIFY: added 'user' and 'user_multi' case 'user': $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 1, false); break; case 'user_multi': $ele = new Xoops\Form\SelectUser($title, $obj[$i]->getVar('conf_name'), false, $obj[$i]->getConfValueForOutput(), 5, true); break; case 'module_cache': $module_handler = $xoops->getHandlerModule(); $modules = $module_handler->getObjectsArray(new Criteria('hasmain', 1), true); $currrent_val = $obj[$i]->getConfValueForOutput(); $cache_options = array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH); if (count($modules) > 0) { $ele = new Xoops\Form\ElementTray($title, '<br />'); foreach (array_keys($modules) as $mid) { $c_val = isset($currrent_val[$mid]) ? (int) $currrent_val[$mid] : null; $selform = new Xoops\Form\Select($modules[$mid]->getVar('name'), $obj[$i]->getVar('conf_name') . "[{$mid}]", $c_val); $selform->addOptionArray($cache_options); $ele->addElement($selform); unset($selform); } } else { $ele = new Xoops\Form\Label($title, SystemLocale::NO_MODULE_TO_CACHE); } break; case 'site_cache': $ele = new Xoops\Form\Select($title, $obj[$i]->getVar('conf_name'), $obj[$i]->getConfValueForOutput()); $ele->addOptionArray(array('0' => XoopsLocale::NO_CACHE, '30' => sprintf(XoopsLocale::F_SECONDS, 30), '60' => XoopsLocale::ONE_MINUTE, '300' => sprintf(XoopsLocale::F_MINUTES, 5), '1800' => sprintf(XoopsLocale::F_MINUTES, 30), '3600' => XoopsLocale::ONE_HOUR, '18000' => sprintf(XoopsLocale::F_HOURS, 5), '86400' => XoopsLocale::ONE_DAY, '259200' => sprintf(XoopsLocale::F_DAYS, 3), '604800' => XoopsLocale::ONE_WEEK, '2592000' => XoopsLocale::ONE_MONTH)); break; case 'password': $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $ele = new Xoops\Form\Password($title, $obj[$i]->getVar('conf_name'), 32, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; case 'color': $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $ele = new Xoops\Form\ColorPicker($title, $obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; case 'hidden': $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $ele = new Xoops\Form\Hidden($obj[$i]->getVar('conf_name'), $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; case 'textbox': default: $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $ele = new Xoops\Form\Text($title, $obj[$i]->getVar('conf_name'), 5, 255, $myts->htmlSpecialChars($obj[$i]->getConfValueForOutput())); break; } $hidden = new Xoops\Form\Hidden('conf_ids[]', $obj[$i]->getVar('conf_id')); if (isset($ele)) { $ele->setDescription($desc); if ($obj[$i]->getVar('conf_formtype') !== 'hidden') { $name = 'default'; if (isset($configNames[$obj[$i]->getVar('conf_name')]['category'])) { $name = $configNames[$obj[$i]->getVar('conf_name')]['category']; } $tabs[$name]->addElement($ele); } else { $this->addElement($ele); } $this->addElement($hidden); unset($ele); unset($hidden); } } foreach (array_keys($tabs) as $name) { if ($tabs[$name]->getElements()) { $tabTray->addElement($tabs[$name]); } } $this->addElement($tabTray); $this->addElement(new Xoops\Form\Hidden('op', 'save')); $this->addElement(new Xoops\Form\Hidden('mid', $mod->getVar('mid'))); $this->addElement(new Xoops\Form\Button('', 'button', XoopsLocale::A_SUBMIT, 'submit')); } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->sanitizer = Sanitizer::getInstance(); $this->object = new NullExtension($this->sanitizer); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $ts = Sanitizer::getInstance(); $this->object = $this->getMockForAbstractClass('\\Xoops\\Core\\Text\\Sanitizer\\SanitizerComponent', [$ts]); $this->reflectedObject = new \ReflectionClass('\\Xoops\\Core\\Text\\Sanitizer\\SanitizerComponent'); }
/** * getAssignableUserRankList - return a list of ranks that can be assigned * * @param Response $response \Xoops\Core\Service\Response object * * @return void - response->value set to array of (int) id => (string) rank title * entries of assignable ranks */ public function getAssignableUserRankList(Response $response) { $db = \Xoops::getInstance()->db(); $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $ret = array(); $sql = $db->createXoopsQueryBuilder(); $eb = $sql->expr(); $sql->select('rank_id')->addSelect('rank_title')->fromPrefix('userrank_rank', 'r')->where($eb->eq('rank_special', ':rankspecial'))->orderBy('rank_title')->setParameter(':rankspecial', 1); $result = $sql->execute(); while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) { $ret[$myrow['rank_id']] = $myts->htmlSpecialChars($myrow['rank_title']); } $response->setValue($ret); }
if (!isset($_POST['submit'])) { $xoops->theme()->addScript(null, array('type' => 'application/x-javascript'), $zxcvbn); //show change password form $form = new Xoops\Form\ThemeForm(_PROFILE_MA_CHANGEPASSWORD, 'form', $_SERVER['REQUEST_URI'], 'post', true); $form->addElement(new Xoops\Form\Password(_PROFILE_MA_OLDPASSWORD, 'oldpass'), true); $password = new Xoops\Form\Password(_PROFILE_MA_NEWPASSWORD, 'newpass', null, null, '', 'off', 'New Password'); $password->setPattern('^.{8,}$', 'You need at least 8 characters'); $form->addElement($password, true); $form->addElement(new Xoops\Form\Label(XoopsLocale::PASSWORD_STRENGTH, '', 'crack_time')); $form->addElement(new Xoops\Form\Password(XoopsLocale::VERIFY_PASSWORD, 'vpass'), true); $form->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit')); $form->assign($xoops->tpl()); $xoops->appendConfig('profile_breadcrumbs', array('caption' => _PROFILE_MA_CHANGEPASSWORD)); } else { $xoops->getConfigs(); $myts = \Xoops\Core\Text\Sanitizer::getInstance(); $oldpass = trim($_POST['oldpass']); $password = trim($_POST['newpass']); $vpass = trim($_POST['vpass']); $errors = array(); if (!password_verify($oldpass, $xoops->user->getVar('pass', 'n'))) { $errors[] = _PROFILE_MA_WRONGPASSWORD; } if (mb_strlen($password) < $xoops->getConfig('minpass')) { $errors[] = sprintf(XoopsLocale::EF_PASSWORD_MUST_BE_GREATER_THAN, $xoops->getConfig('minpass')); } if ($password != $vpass) { $errors[] = XoopsLocale::E_PASSWORDS_MUST_MATCH; } if ($errors) { $msg = implode('<br />', $errors);
/** * return the content of the block for output * * @param string $format Dtype::FORMAT_xxxx constant * @param string $c_type type of custom content, a XoopsBlock::CUSTOM_xxxx constant * H : custom HTML block * P : custom PHP block * S : use text sanitizer (smilies enabled) * T : use text sanitizer (smilies disabled) * * @return string content for output */ public function getContent($format = 's', $c_type = 'T') { $format = strtolower($format); $c_type = strtoupper($c_type); switch ($format) { case Dtype::FORMAT_SHOW: case 's': // apply c_type rules for content display $content = $this->getVar('content', Dtype::FORMAT_NONE); switch ($c_type) { case XoopsBlock::CUSTOM_HTML: return $this->convertSiteURL($content); case XoopsBlock::CUSTOM_PHP: ob_start(); echo eval($content); $content = ob_get_contents(); ob_end_clean(); return $this->convertSiteURL($content); case XoopsBlock::CUSTOM_SMILIE: $myts = Sanitizer::getInstance(); return $myts->filterForDisplay($this->convertSiteURL($content), 1, 1); case XoopsBlock::CUSTOM_TEXT: default: $myts = Sanitizer::getInstance(); return $myts->filterForDisplay($this->convertSiteURL($content), 1, 0); } break; case Dtype::FORMAT_EDIT: case 'e': return $this->getVar('content', Dtype::FORMAT_EDIT); break; default: return $this->getVar('content', Dtype::FORMAT_NONE); break; } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $this->sanitizer = Sanitizer::getInstance(); $this->object = new Embed($this->sanitizer); }
/** * @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$ */ function smarty_function_translate($params, &$smarty) { $key = isset($params['key']) ? $params['key'] : ''; $dirname = isset($params['dirname']) ? $params['dirname'] : 'xoops'; return \Xoops\Core\Text\Sanitizer::getInstance()->escapeForJavascript(\Xoops\Locale::translate($key, $dirname)); }