本文整理汇总了PHP中SessionUtil::setVar方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionUtil::setVar方法的具体用法?PHP SessionUtil::setVar怎么用?PHP SessionUtil::setVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionUtil
的用法示例。
在下文中一共展示了SessionUtil::setVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
public function main() {
//Security check!SecurityUtil::checkPermission(
if (!SecurityUtil::checkPermission('IWbookings::', '::', ACCESS_READ)) {
LogUtil::registerError($this->__('You are not allowed to administrate the bookings'));
return false;
}
if (ModUtil::getVar('IWbookings', 'NTPtime')) {
$tOffset = SessionUtil::getVar('timeOffset');
if (empty($tOffset)) {
// Calculate time diference between our server and a NTP time server
$timeOffset = ModUtil::apiFunc('IWbookings', 'user', 'getNTPDate') - DateUtil::makeTimestamp();
SessionUtil::setVar('timeOffset', $timeOffset);
}
}
//Esborrem les reserva antigues i les reserves d'anul�laci�
if ((ModUtil::getVar('IWbookings', 'eraseold') == 1) && (SecurityUtil::checkPermission('IWbookings::', '::', ACCESS_ADMIN))) {
ModUtil::apiFunc('IWbookings', 'user', 'esborra_antigues', array('sid' => -1));
}
if (ModUtil::getVar('IWbookings', 'month_panel')) {
System::redirect(ModUtil::url('IWbookings', 'user', 'assigna', array('sid' => -1,
'mensual' => 1)));
} else {
System::redirect(ModUtil::url('IWbookings', 'user', 'espais', array('sid' => -1,
'mensual' => 0)));
}
return true;
}
示例2: contentMainEditExpandAll
public static function contentMainEditExpandAll($belowPageId = null)
{
$expandedPageIds = SessionUtil::getVar('contentExpandedPageIds', array());
foreach (Content_Util::contentMainEditGetPagesList($belowPageId) as $page) {
$expandedPageIds[$page['id']] = 1;
}
SessionUtil::setVar('contentExpandedPageIds', $expandedPageIds);
}
示例3: bbsmiles
/**
* bbsmiles
* returns a html snippet with buttons for inserting bbsmiles into a text
*
* @param $args['textfieldid'] id of the textfield for inserting smilies
*/
public function bbsmiles($args)
{
if (!isset($args['textfieldid']) || empty($args['textfieldid'])) {
return LogUtil::registerArgsError();
}
// if we have more than one textarea we need to distinguish them, so we simply use
// a counter stored in a session var until we find a better solution
$counter = SessionUtil::getVar('bbsmile_counter', 0);
$counter++;
SessionUtil::setVar('bbsmile_counter', $counter);
$this->view->assign('counter', $counter);
$this->view->assign('textfieldid', $args['textfieldid']);
PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet('BBSmile'));
$templatefile = DataUtil::formatForOS(ModUtil::getName()) . '.tpl';
if ($this->view->template_exists($templatefile)) {
return $this->view->fetch($templatefile);
}
$this->view->add_core_data();
return $this->view->fetch('bbsmile_user_bbsmiles.tpl');
}
示例4: getTheme
/**
* Get the user's theme.
*
* This function will return the current theme for the user.
* Order of theme priority:
* - page-specific
* - category
* - user
* - system
*
* @param boolean $force True to ignore the cache.
*
* @return string the name of the user's theme
* @throws RuntimeException If this function was unable to calculate theme name.
*/
public static function getTheme($force = false)
{
static $theme;
if (isset($theme) && !$force) {
return $theme;
}
if (CookieUtil::getCookie('zikulaMobileTheme') == '1' && ModUtil::getVar('Theme', 'enable_mobile_theme', false)) {
$pagetheme = 'Mobile';
} else {
if (CookieUtil::getCookie('zikulaMobileTheme') != '2' && ModUtil::getVar('Theme', 'enable_mobile_theme', false)) {
include_once "system/Theme/lib/vendor/Mobile_Detect.php";
$detect = new Mobile_Detect();
if ($detect->isMobile()) {
$pagetheme = 'Mobile';
}
} else {
$pagetheme = FormUtil::getPassedValue('theme', null, 'GETPOST');
}
}
// Page-specific theme
$type = FormUtil::getPassedValue('type', null, 'GETPOST');
$qstring = System::serverGetVar('QUERY_STRING');
if (!empty($pagetheme)) {
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($pagetheme));
if ($themeinfo['state'] == ThemeUtil::STATE_ACTIVE && ($themeinfo['user'] || $themeinfo['system'] || $themeinfo['admin'] && $type == 'admin') && is_dir('themes/' . DataUtil::formatForOS($themeinfo['directory']))) {
return self::_getThemeFilterEvent($themeinfo['name'], 'page-specific');
}
}
// check for an admin theme
if (($type == 'admin' || $type == 'adminplugin') && SecurityUtil::checkPermission('::', '::', ACCESS_EDIT)) {
$admintheme = ModUtil::getVar('Admin', 'admintheme');
if (!empty($admintheme)) {
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($admintheme));
if ($themeinfo && $themeinfo['state'] == ThemeUtil::STATE_ACTIVE && is_dir('themes/' . DataUtil::formatForOS($themeinfo['directory']))) {
return self::_getThemeFilterEvent($themeinfo['name'], 'admin-theme');
}
}
}
// set a new theme for the user
$newtheme = FormUtil::getPassedValue('newtheme', null, 'GETPOST');
if (!empty($newtheme) && System::getVar('theme_change')) {
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($newtheme));
if ($themeinfo && $themeinfo['state'] == ThemeUtil::STATE_ACTIVE && is_dir('themes/' . DataUtil::formatForOS($themeinfo['directory']))) {
if (self::isLoggedIn()) {
self::setVar('theme', $newtheme);
} else {
SessionUtil::setVar('theme', $newtheme);
}
return self::_getThemeFilterEvent($themeinfo['name'], 'new-theme');
}
}
// User theme
if (System::getVar('theme_change') || SecurityUtil::checkPermission('::', '::', ACCESS_ADMIN)) {
if (self::isLoggedIn()) {
$usertheme = self::getVar('theme');
} else {
$usertheme = SessionUtil::getVar('theme');
}
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($usertheme));
if ($themeinfo && $themeinfo['state'] == ThemeUtil::STATE_ACTIVE && is_dir('themes/' . DataUtil::formatForOS($themeinfo['directory']))) {
return self::_getThemeFilterEvent($themeinfo['name'], 'user-theme');
}
}
// default site theme
$defaulttheme = System::getVar('Default_Theme');
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($defaulttheme));
if ($themeinfo && $themeinfo['state'] == ThemeUtil::STATE_ACTIVE && is_dir('themes/' . DataUtil::formatForOS($themeinfo['directory']))) {
return self::_getThemeFilterEvent($themeinfo['name'], 'default-theme');
}
if (!System::isInstalling()) {
throw new RuntimeException(__('UserUtil::getTheme() is unable to calculate theme name.'));
}
}
示例5: view
/**
* view a page
*
* @param int pid Page ID
* @param string name URL name, alternative for pid
* @param bool preview Display preview
* @param bool editmode Flag for enabling/disabling edit mode
*
* @return Renderer output
*/
public function view($args)
{
$pageId = isset($args['pid']) ? $args['pid'] : FormUtil::getPassedValue('pid');
$versionId = isset($args['vid']) ? $args['vid'] : FormUtil::getPassedValue('vid');
$urlname = isset($args['name']) ? $args['name'] : FormUtil::getPassedValue('name');
$preview = isset($args['preview']) ? $args['preview'] : FormUtil::getPassedValue('preview');
$editmode = isset($args['editmode']) ? $args['editmode'] : FormUtil::getPassedValue('editmode', null, 'GET');
if ($pageId === null && !empty($urlname)) {
$pageId = ModUtil::apiFunc('Content', 'Page', 'solveURLPath', compact('urlname'));
System::queryStringSetVar('pid', $pageId);
}
if ((bool) $this->getVar('inheritPermissions', false) === true) {
$this->throwForbiddenUnless(ModUtil::apiFunc('Content', 'page', 'checkPermissionForPageInheritance', array('pageId' => $pageId, 'level' => ACCESS_READ)), LogUtil::getErrorMsgPermission());
} else {
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Content:page:', $pageId . '::', ACCESS_READ), LogUtil::getErrorMsgPermission());
}
$versionHtml = '';
$hasEditAccess = false;
if ((bool) $this->getVar('inheritPermissions', false) === true) {
$hasEditAccess = ModUtil::apiFunc('Content', 'page', 'checkPermissionForPageInheritance', array('pageId' => $pageId, 'level' => ACCESS_EDIT));
} else {
$hasEditAccess = SecurityUtil::checkPermission('Content:page:', $pageId . '::', ACCESS_EDIT);
}
if ($versionId !== null && $hasEditAccess) {
$preview = true;
$version = ModUtil::apiFunc('Content', 'History', 'getPageVersion', array('id' => $versionId, 'preview' => $preview, 'includeContent' => true));
$versionData =& $version['data'];
$page =& $versionData['page'];
$pageId = $page['id'];
$action = ModUtil::apiFunc('Content', 'History', 'contentHistoryActionTranslate', $version['action']);
$translatable = array('revisionNo' => $version['revisionNo'], 'date' => $version['date'], 'action' => $action, 'userName' => $version['userName'], 'ipno' => $version['ipno']);
$iconSrc = 'images/icons/extrasmall/clock.png';
$versionHtml = "<p class=\"content-versionpreview\"><img alt=\"\" src=\"{$iconSrc}\"/> " . $this->__f('Version #%1$s - %2$s - %3$s by %4$s from %5$s', $translatable) . "</p>";
}
// now get the page up for display
if ($pageId !== null && $versionId === null) {
$page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $pageId, 'preview' => $preview, 'includeContent' => true, 'filter' => array('checkActive' => !($preview && $hasEditAccess))));
} else {
if ($versionId === null) {
return LogUtil::registerArgsError();
}
}
if ($page === false) {
return false;
}
if ($editmode !== null) {
SessionUtil::setVar('ContentEditMode', $editmode);
} else {
$editmode = SessionUtil::getVar('ContentEditMode', null);
}
if ($editmode) {
$this->view->setCaching(false);
}
$this->view->setCacheId("{$pageId}|{$versionId}");
if ($this->view->is_cached('user/page.tpl')) {
return $this->view->fetch('user/page.tpl');
}
// Register a page variable breadcrumbs with the Content page hierarchy as array of array(url, title)
if ((bool) $this->getVar('registerBreadcrumbs', false) === true) {
// first include self, then loop over parents until root is reached
$breadcrumbs[] = array('url' => ModUtil::url('Content', 'user', 'view', array('pid' => $page['id'])), 'title' => $page['title']);
$loopPageid = $page['parentPageId'];
while ($loopPageid > 0) {
$loopPage = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $loopPageid, 'includeContent' => false, 'includeLayout' => false, 'translate' => $this->translateTitles));
array_unshift($breadcrumbs, array('url' => ModUtil::url('Content', 'user', 'view', array('pid' => $loopPage['id'])), 'title' => $loopPage['title']));
$loopPageid = $loopPage['parentPageId'];
}
PageUtil::registerVar('breadcrumbs', false, $breadcrumbs);
}
$multilingual = ModUtil::getVar(ModUtil::CONFIG_MODULE, 'multilingual');
if ($page['language'] == ZLanguage::getLanguageCode()) {
$multilingual = false;
}
// override the PageVar title if configued in the settings
if ($this->getVar('overrideTitle')) {
$pageTitle = html_entity_decode($page['title']);
PageUtil::setVar('title', $preview ? $this->__("Preview") . ' - ' . $pageTitle : $pageTitle);
}
$this->view->assign('page', $page);
$this->view->assign('preview', $preview);
$this->view->assign('editmode', $editmode);
$this->view->assign('multilingual', $multilingual);
$this->view->assign('enableVersioning', $this->getVar('enableVersioning'));
// add layout type and column count as page variables to the template
// columncount can be used via plugin contentcolumncount, since it holds regular expressions that slow down
$this->view->assign('contentLayoutType', $page['layout']);
// add access parameters
Content_Util::contentAddAccess($this->view, $pageId);
// exclude writers from statistics
if (!$hasEditAccess && !$preview && !$editmode && $this->getVar('countViews')) {
//.........这里部分代码省略.........
示例6: mediashare_user_slideshow
/**
* View items in slideshow
*/
function mediashare_user_slideshow($args)
{
$albumId = mediashareGetIntUrl('aid', $args, 1);
$mediaId = mediashareGetIntUrl('mid', $args, 0);
$delay = mediashareGetIntUrl('delay', $args, 5);
$mode = mediashareGetStringUrl('mode', $args, 'stopped');
$viewkey = FormUtil::getPassedValue('viewkey');
$center = isset($args['center']) ? '_center' : '';
$back = mediashareGetIntUrl('back', $args, 0);
// Check access to album (media ID won't do a difference if not from this album)
if (!mediashareAccessAlbum($albumId, mediashareAccessRequirementViewSomething)) {
return LogUtil::registerPermissionError();
}
// Fetch current album
if (!($album = pnModAPIFunc('mediashare', 'user', 'getAlbum', array('albumId' => $albumId)))) {
return false;
}
if ($album === true) {
return LogUtil::registerError(__('Unknown album.', $dom));
}
// Fetch media items
if (($items = pnModAPIFunc('mediashare', 'user', 'getMediaItems', array('albumId' => $albumId))) === false) {
return false;
}
// Find current, previous and next items
if ($mediaId == 0 && count($items) > 0) {
$mediaId = $items[0]['id'];
}
$mediaItem = null;
if (count($items) > 0) {
$prevMediaId = $items[count($items) - 1]['id'];
$nextMediaId = $items[0]['id'];
foreach ($items as $item) {
if ($mediaItem != null) {
// Media-Current item found, so this must be next
$nextMediaId = $item['id'];
break;
}
if ($item['id'] == $mediaId) {
$mediaItem = $item;
} else {
// Media-item not found, so this must become prev
$prevMediaId = $item['id'];
}
}
} else {
$prevMediaId = -1;
$nextMediaId = -1;
}
// Add media display HTML
$mediadir = pnModAPIFunc('mediashare', 'user', 'getRelativeMediadir');
for ($i = 0, $cou = count($items); $i < $cou; ++$i) {
if (!($handler = pnModAPIFunc('mediashare', 'mediahandler', 'loadHandler', array('handlerName' => $items[$i]['mediaHandler'])))) {
return false;
}
$result = $handler->getMediaDisplayHtml($mediadir . $items[$i]['originalRef'], null, null, 'mediaItem', array());
$items[$i]['html'] = str_replace(array("\r", "\n"), array(' ', ' '), $result);
}
$viewUrl = pnModUrl('mediashare', 'user', 'slideshow', array('mid' => $mediaItem['id']));
if ($back) {
SessionUtil::setVar('mediashareQuitUrl', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
}
$quitUrl = SessionUtil::getVar('mediashareQuitUrl');
if ($quitUrl == null) {
$quitUrl = pnModUrl('mediashare', 'user', 'view', array('aid' => $album['id']));
}
// Build the output
$render =& pnRender::getInstance('mediashare', false);
$render->assign('viewUrl', $viewUrl);
$render->assign('mediaId', $mediaId);
$render->assign('mediaItem', $mediaItem);
$render->assign('prevMediaId', $prevMediaId);
$render->assign('nextMediaId', $nextMediaId);
$render->assign('mediaItems', $items);
$render->assign('album', $album);
$render->assign('albumId', $albumId);
$render->assign('delay', $delay);
$render->assign('mode', $mode);
$render->assign('thumbnailSize', pnModGetVar('mediashare', 'thumbnailSize'));
$render->assign('theme', pnUserGetTheme());
$render->assign('templateName', "slideshow{$center}.html");
$render->assign('quitUrl', $quitUrl);
// Add the access array
if (!mediashareAddAccess($render, $album)) {
return false;
}
$render->load_filter('output', 'pagevars_notcombined');
if (pnConfigGetVar('shorturls')) {
$render->load_filter('output', 'shorturls');
}
$render->display('mediashare_user_slideshow.html');
return true;
}
示例7: upgrade
public function upgrade($oldversion) {
$dom = ZLanguage::getModuleDomain('IWbooks');
switch ($oldversion) {
case 0.8:
$dbconn = & DBConnectionStack::getConnection(true);
$pntable = & DBUtil::getTables();
$llibrestable = $pntable['llibres'];
$llibrescolumn = &$pntable['llibres_column'];
$sql = "ALTER TABLE $llibrestable
CHANGE $llibrescolumn[etapa] $llibrescolumn[etapa] varchar(32) NOT NULL default ''";
$dbconn->Execute($sql);
$sql = "ALTER TABLE $llibrestable
DROP pn_tipus";
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
SessionUtil::setVar('errormsg', __('Failed to update the tables', $dom));
return false;
}
ModUtil::setVar('IWbooks', 'plans', '
PRI#Educació Primària|
ESO#Educació Secundària Obligatòria|
BTE#Batxillerat Tecnològic|
BSO#Batxillerat Social|
BHU#Batxillerat Humanístic|
BCI#Batxillerat Científic|
BAR#Batxillerat Artístic');
ModUtil::setVar('IWbooks', 'darrer_nivell', '4');
return IWbooks_upgrade(0.9);
case 0.9:
// Codi per a versió 1.0
$dbconn = & DBConnectionStack::getConnection(true);
$pntable = & DBUtil::getTables();
$llibrestable = $pntable['llibres'];
$llibrescolumn = &$pntable['llibres_column'];
$sql = "ALTER TABLE $llibrestable
ADD pn_observacions varchar(100) NOT NULL,
ADD pn_materials text NOT NULL";
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
SessionUtil::setVar('errormsg', $llibrestable . $oldversion . __('Failed to update the tables', $dom));
return false;
}
ModUtil::setVar('IWbooks', 'llistar_materials', '1');
ModUtil::setVar('IWbooks', 'mida_font', '11');
ModUtil::setVar('IWbooks', 'marca_aigua', '0');
return IWbooks_upgrade(1.0);
case 1.0:
// Codi per a versió 2.0
ModUtil::delVar('IWbooks', 'darrer_nivell');
ModUtil::setVar('IWbooks', 'nivells', '
1#1r|
2#2n|
3#3r|
4#4t|
5#5è|
6#6è|
A#P3|
B#P4|
C#P5');
if (!DBUtil::changeTable('IWbooks')) {
return false;
}
if (!DBUtil::changeTable('IWbooks_materies')) {
return false;
}
return IWbooks_upgrade(2.0);
break;
}
// Actualització amb èxit
return true;
}
示例8: getPassedValue
/**
* Return the requested key from input in a safe way.
*
* This function is safe to use for recursive arrays and either
* returns a non-empty string or the (optional) default.
*
* This method is based on FormUtil::getPassedValue but array-safe.
*
* @param string $key The field to return.
* @param mixed $default The value to return if the requested field is not found (optional) (default=false).
* @param string $source The source field to get a parameter from.
* @param string $filter The filter directive to apply.
* @param array $args The filter processing args to apply.
* @param string $objectType The object access path we're getting; used to assign validation errors .
*
* @deprecated since 1.3.0, use request object instead.
*
* @return mixed The requested input key or the specified default.
*/
public static function getPassedValue($key, $default = null, $source = null, $filter = null, array $args = array(), $objectType = null)
{
if (!$key) {
return z_exit(__f('Empty %1$s passed to %2$s.', array('key', 'FormUtil::getPassedValue')));
}
$source = strtoupper($source);
if (!$filter) {
$filter = FILTER_DEFAULT;
}
$args = array();
$failed = null;
switch (true) {
case isset($_REQUEST[$key]) && !isset($_FILES[$key]) && (!$source || $source == 'R' || $source == 'REQUEST'):
if (is_array($_REQUEST[$key])) {
$args['flags'] = FILTER_REQUIRE_ARRAY;
}
$value = filter_var($_REQUEST[$key], $filter, $args);
$failed = $value === false ? $_REQUEST : null;
break;
case isset($_GET[$key]) && (!$source || $source == 'G' || $source == 'GET'):
if (is_array($_GET[$key])) {
$args['flags'] = FILTER_REQUIRE_ARRAY;
}
$value = filter_var($_GET[$key], $filter, $args);
$failed = $value === false ? $_GET : null;
break;
case isset($_POST[$key]) && (!$source || $source == 'P' || $source == 'POST'):
if (is_array($_POST[$key])) {
$args['flags'] = FILTER_REQUIRE_ARRAY;
}
$value = filter_var($_POST[$key], $filter, $args);
$failed = $value === false ? $_POST : null;
break;
case isset($_COOKIE[$key]) && (!$source || $source == 'C' || $source == 'COOKIE'):
if (is_array($_COOKIE[$key])) {
$args['flags'] = FILTER_REQUIRE_ARRAY;
}
$value = filter_var($_COOKIE[$key], $filter, $args);
$failed = $value === false ? $_COOKIE : null;
break;
case isset($_FILES[$key]) && ($source == 'F' || $source == 'FILES'):
if (is_array($_FILES[$key])) {
$args['flags'] = FILTER_REQUIRE_ARRAY;
}
$value = $_FILES[$key];
$failed = $value === false ? $_COOKIE : null;
break;
case (isset($_GET[$key]) || isset($_POST[$key])) && ($source == 'GP' || $source == 'GETPOST'):
if (isset($_GET[$key])) {
if (is_array($_GET[$key])) {
$args['flags'] = FILTER_REQUIRE_ARRAY;
}
$value = filter_var($_GET[$key], $filter, $args);
$failed = $value === false ? $_GET : null;
}
if (isset($_POST[$key])) {
if (is_array($_POST[$key])) {
$args['flags'] = FILTER_REQUIRE_ARRAY;
}
$value = filter_var($_POST[$key], $filter, $args);
$failed = $value === false ? $_POST : null;
}
break;
default:
if ($source) {
static $valid = array('R', 'REQUEST', 'G', 'GET', 'P', 'POST', 'C', 'COOKIE', 'F', 'FILES', 'GP', 'GETPOST');
if (!in_array($source, $valid)) {
z_exit(__f('Invalid input source [%s] received.', DataUtil::formatForDisplay($source)));
return $default;
}
}
$value = $default;
}
if ($failed && $objectType) {
//SessionUtil::setVar ($key, $failed[$key], "/validationErrors/$objectType");
SessionUtil::setVar($objectType, $failed[$key], '/validationFailedObjects');
}
return $value;
}
示例9: _processIdsResult
/**
* Process results from IDS scan.
*
* @param IDS_Init $init PHPIDS init object reference.
* @param IDS_Report $result The result object from PHPIDS.
*
* @return void
*/
private function _processIdsResult(IDS_Init $init, IDS_Report $result)
{
// $result contains any suspicious fields enriched with additional info
// Note: it is moreover possible to dump this information by simply doing
//"echo $result", calling the IDS_Report::$this->__toString() method implicitely.
$requestImpact = $result->getImpact();
if ($requestImpact < 1) {
// nothing to do
return;
}
// update total session impact to track an attackers activity for some time
$sessionImpact = SessionUtil::getVar('idsImpact', 0) + $requestImpact;
SessionUtil::setVar('idsImpact', $sessionImpact);
// let's see which impact mode we are using
$idsImpactMode = System::getVar('idsimpactmode', 1);
$idsImpactFactor = 1;
if ($idsImpactMode == 1) {
$idsImpactFactor = 1;
} elseif ($idsImpactMode == 2) {
$idsImpactFactor = 10;
} elseif ($idsImpactMode == 3) {
$idsImpactFactor = 5;
}
// determine our impact threshold values
$impactThresholdOne = System::getVar('idsimpactthresholdone', 1) * $idsImpactFactor;
$impactThresholdTwo = System::getVar('idsimpactthresholdtwo', 10) * $idsImpactFactor;
$impactThresholdThree = System::getVar('idsimpactthresholdthree', 25) * $idsImpactFactor;
$impactThresholdFour = System::getVar('idsimpactthresholdfour', 75) * $idsImpactFactor;
$usedImpact = ($idsImpactMode == 1) ? $requestImpact : $sessionImpact;
// react according to given impact
if ($usedImpact > $impactThresholdOne) {
// db logging
// determine IP address of current user
$_REMOTE_ADDR = System::serverGetVar('REMOTE_ADDR');
$_HTTP_X_FORWARDED_FOR = System::serverGetVar('HTTP_X_FORWARDED_FOR');
$ipAddress = ($_HTTP_X_FORWARDED_FOR) ? $_HTTP_X_FORWARDED_FOR : $_REMOTE_ADDR;
$currentPage = System::getCurrentUri();
$currentUid = UserUtil::getVar('uid');
$intrusionItems = array();
foreach ($result as $event) {
$eventName = $event->getName();
$malVar = explode(".", $eventName, 2);
$filters = array();
foreach ($event as $filter) {
array_push($filters, array(
'id' => $filter->getId(),
'description' => $filter->getDescription(),
'impact' => $filter->getImpact(),
'tags' => $filter->getTags(),
'rule' => $filter->getRule()));
}
$tagVal = $malVar[1];
$newIntrusionItem = array(
'name' => array($eventName),
'tag' => $tagVal,
'value' => $event->getValue(),
'page' => $currentPage,
'uid' => $currentUid,
'ip' => $ipAddress,
'impact' => $result->getImpact(),
'filters' => serialize($filters),
'date' => DateUtil::getDatetime()
);
if (array_key_exists($tagVal, $intrusionItems)) {
$intrusionItems[$tagVal]['name'][] = $newIntrusionItem['name'][0];
} else {
$intrusionItems[$tagVal] = $newIntrusionItem;
}
}
// log details to database
foreach ($intrusionItems as $tag => $intrusionItem) {
$intrusionItem['name'] = implode(", ", $intrusionItem['name']);
// create new ZIntrusion instance
$obj = new SecurityCenter_DBObject_Intrusion();
//.........这里部分代码省略.........
示例10: setDataToSession
/**
* Set the current object data into session.
*
* @param array $data The object data.
* @param string $key The session key.
* @param string $path The session object input path.
* @param boolean $autocreate The autocreate passed to SessionUtil::setVar.
* @param boolean $overwriteExistingVar The overwriteExistingVar variable passed to SessionUtil::setVar.
*
* @return array The session data.
*/
public function setDataToSession($data = null, $key = null, $path = '', $autocreate = true, $overwriteExistingVar = false)
{
if (!$data) {
$data = $this->_objData;
}
if (!$key) {
$key = $this->_objPath;
}
if (!$path) {
$path = $this->_objSessionPath;
}
if (!$this->setDataToSessionPreProcess($data)) {
return false;
}
SessionUtil::setVar($path, $data, $path, $autocreate, $overwriteExistingVar);
$this->_objData = $data;
return $this->_objData;
}
示例11: mediashare_randomblock_display
function mediashare_randomblock_display($blockinfo)
{
// Security check
if (!SecurityUtil::checkPermission('mediashare:randomblock:', "{$blockinfo['title']}::{$blockinfo['bid']}", ACCESS_READ)) {
return;
}
$dom = ZLanguage::getModuleDomain('mediashare');
// Get variables from content block
$vars = pnBlockVarsFromContent($blockinfo['content']);
$sessionVarName = 'mediashare_block_' . $blockinfo['bid'];
$sessionVars = SessionUtil::getVar($sessionVarName);
if ($sessionVars == '' || $sessionVars == null) {
$sessionVars = array();
}
if (isset($sessionVars['oldContent']) && isset($sessionVars['lastUpdate'])) {
$past = time() - $sessionVars['lastUpdate'];
if ($past < $vars['cacheTime']) {
// No need to refresh - move old content into real content
$blockinfo['content'] = $sessionVars['oldContent'];
return themesideblock($blockinfo);
}
}
if ($vars['type'] == 'album') {
$randomInfo = pnModAPIFunc('mediashare', 'user', 'getRandomMediaItem', array('albumId' => $vars['albumId'], 'mode' => 'album'));
} else {
if ($vars['type'] == 'latest') {
$randomInfo = pnModAPIFunc('mediashare', 'user', 'getRandomMediaItem', array('latest' => true, 'mode' => 'latest'));
} else {
$randomInfo = pnModAPIFunc('mediashare', 'user', 'getRandomMediaItem');
}
}
if ($randomInfo === false) {
return false;
}
$mediaId = $randomInfo['mediaId'];
$albumId = $randomInfo['albumId'];
if (empty($mediaId)) {
return;
}
// Get image info
$mediaInfo = pnModAPIFunc('mediashare', 'user', 'getMediaItem', array('mediaId' => $mediaId));
// Get album info
$albumInfo = pnModAPIFunc('mediashare', 'user', 'getAlbum', array('albumId' => $albumId));
$originalURL = pnModAPIFunc('mediashare', 'user', 'getMediaUrl', array('mediaItem' => $mediaInfo, 'src' => 'originalRef'));
$previewURL = pnModAPIFunc('mediashare', 'user', 'getMediaUrl', array('mediaItem' => $mediaInfo, 'src' => 'previewRef'));
$thumbnailURL = pnModAPIFunc('mediashare', 'user', 'getMediaUrl', array('mediaItem' => $mediaInfo, 'src' => 'thumbnailRef'));
$albumURL = pnModUrl('mediashare', 'user', 'view', array('aid' => $albumId, 'mid' => $mediaId));
// Create the final HTML by substituting various macros into the user specified HTML code
$substitutes = array('originalURL' => $originalURL, 'previewURL' => $previewURL, 'thumbnailURL' => $thumbnailURL, 'albumURL' => $albumURL, 'title' => $mediaInfo['title'], 'owner' => __('Unknown', $dom), 'albumTitle' => $albumInfo['title']);
$html = $vars['html'];
foreach ($substitutes as $key => $value) {
$pattern = '${' . $key . '}';
$html = str_replace($pattern, $value, $html);
}
$blockinfo['content'] = $html;
$sessionVars['oldContent'] = $html;
$sessionVars['lastUpdate'] = time();
SessionUtil::setVar($sessionVarName, $sessionVars);
// ... and return encapsulated in a theme block
return themesideblock($blockinfo);
}
示例12: menu
/**
* Compose the user menu depending on which agendas can access
*
* @param array $args Agenda identity and mounht and year position
*
* @return The user menu
*/
public function menu($args) {
// Security check
$this->throwForbiddenUnless(SecurityUtil::checkPermission('IWagendas::', '::', ACCESS_READ));
$dia = FormUtil::getPassedValue('dia', isset($args['dia']) ? $args['dia'] : date("d"), 'REQUEST');
$mes = FormUtil::getPassedValue('mes', isset($args['mes']) ? $args['mes'] : date("m"), 'REQUEST');
$any = FormUtil::getPassedValue('any', isset($args['any']) ? $args['any'] : date("Y"), 'REQUEST');
$daid = FormUtil::getPassedValue('daid', isset($args['daid']) ? $args['daid'] : 0, 'REQUEST');
$llistat = FormUtil::getPassedValue('llistat', isset($args['llistat']) ? $args['llistat'] : null, 'REQUEST');
$purga = FormUtil::getPassedValue('purga', isset($args['purga']) ? $args['purga'] : null, 'REQUEST');
$reduced = FormUtil::getPassedValue('reduced', isset($args['reduced']) ? $args['reduced'] : 0, 'POST');
$odaid = $daid;
$gdaid = 0;
if ($daid == 0) {
$usability = ModUtil::func('IWagendas', 'user', 'getGdataFunctionsUsability');
if ($usability === true) {
//if user use gCalendar integration and daid is zero get the gCalendar default
$defaultCalendar = ModUtil::apiFunc('IWagendas', 'user', 'getGCalendarUserDefault');
$gdaid = $defaultCalendar['daid'];
}
}
$user = UserUtil::getVar('uid');
if ($gdaid == 0)
$gdaid = $daid;
// If it's a shared agenda, get the data and check the perms
if ($daid != 0) {
// Get the agenda data
$registre = ModUtil::apiFunc('IWagendas', 'user', 'getAgenda', array('daid' => $daid));
//Comprovem que la consulta anterior ha tornat amb resultats
if ($registre == false) {
return SessionUtil::setVar('errormsg', $this->__('Event not found'));
}
} else {
$registre['grup'] = '0';
$registre['resp'] = '';
$registre['activa'] = '';
}
// Check whether the user can access the agenda
$te_acces = ModUtil::func('IWagendas', 'user', 'te_acces', array('daid' => $daid,
'grup' => $registre['grup'],
'resp' => $registre['resp'],
'activa' => $registre['activa']));
// If the user has no access, show an error message and stop execution
if ($te_acces == 0) {
LogUtil::registerError($this->__('You are not allowed to administrate the agendas'));
return System::redirect(ModUtil::url('IWagendas', 'user', 'main'));
}
// Pass the name of the agenda to the template
if ($daid == 0) {
$this->view->assign('agendaname', $this->__('Personal'));
} else {
$this->view->assign('agendaname', $registre['nom_agenda']);
}
$this->view->assign('daid', $daid);
$subsArray = array();
if (UserUtil::isLoggedIn()) {
//get the agendas where the user is subscribed
$subs = ModUtil::apiFunc('IWagendas', 'user', 'getUserSubscriptions');
foreach ($subs as $sub) {
array_push($subsArray, $sub['daid']);
}
}
//get all the agendas where the user can access
$agendas = ModUtil::func('IWagendas', 'user', 'getUserAgendas');
$color = (isset($agendas[$daid]['color'])) ? $agendas[$daid]['color'] : '';
$this->view->assign('color', $color);
$i = 0;
$ipr = 3;
$agendasArray = array();
foreach ($agendas as $agenda) {
if ($agenda['color'] == '') {
// Set a default color
$userColor = '#FFFFFF';
// Get gCalendar user color
$pos = strpos($agenda['gColor'], '|' . $user . '$');
$userColor = ($pos > 0) ? substr($agenda['gColor'], $pos - 7, 7) : '';
$agenda['color'] = $userColor;
}
$newdiv = ($i % $ipr == 0) ? 1 : 0;
$enddiv = ($i % $ipr == $ipr - 1 || $i == count($agendas) - 1) ? 1 : 0;
$i++;
$subs = (!in_array($agenda['daid'], $subsArray)) ? 0 : 1;
$gCalendar = (isset($agenda['gCalendarId']) && $agenda['gCalendarId'] != '') ? 1 : 0;
$name = (strlen($agenda['nom_agenda']) > 13) ? mb_strimwidth($agenda['nom_agenda'], 0, 13, '...') : $agenda['nom_agenda'];
$agendasArray[] = array('nom_agenda' => $name,
'fullName' => $agenda['nom_agenda'],
'daid' => $agenda['daid'],
'color' => $agenda['color'],
'subs' => $subs,
'newdiv' => $newdiv,
'enddiv' => $enddiv,
'gCalendar' => $gCalendar);
//.........这里部分代码省略.........
示例13: fixLanguageToSession
/**
* Fix language to session.
*
* @return void
*/
private function fixLanguageToSession()
{
if ($this->langFixSession) {
SessionUtil::setVar('language', $this->languageCode);
}
}
示例14: permisos
/**
* Get the user permissions for the noteboard
* @author: Albert Pérez Monfort (aperezm@xtec.cat)
* @param: args The id of the note
* The string of mached notes by the user
* @return: True if success and false otherwise
*/
public function permisos($args) {
$uid = FormUtil::getPassedValue('uid', isset($args['uid']) ? $args['uid'] : UserUtil::getVar('uid'), 'POST');
$sv = FormUtil::getPassedValue('sv', isset($args['sv']) ? $args['sv'] : null, 'POST');
$requestByCron = false;
if (!ModUtil::func('IWmain', 'user', 'checkSecurityValue', array('sv' => $sv))) {
// Security check
if (!SecurityUtil::checkPermission('IWnoteboard::', '::', ACCESS_READ)) {
return LogUtil::registerPermissionError();
}
} else {
$requestByCron = true;
}
$n_permisos = 0;
$nivell_permisos = array();
//if user is not registered have a fixed permissions
if (!UserUtil::isLoggedIn() && !$requestByCron) {
$nivell_permisos = array('nivell' => 1,
'verifica' => 2,
'potverificar' => false,
'grups' => array(0));
//return not registered permissions
return $nivell_permisos;
}
// Arguments needed
if (!isset($uid) || ($uid != UserUtil::getVar('uid') && !$requestByCron)) {
SessionUtil::setVar('errormsg', $this->__('Error! Could not do what you wanted. Please check your input.'));
return $nivell_permisos;
}
$myJoin = array();
$myJoin[] = array('join_table' => 'groups',
'join_field' => array('gid'),
'object_field_name' => array('gid'),
'compare_field_table' => 'gid',
'compare_field_join' => 'gid');
$myJoin[] = array('join_table' => 'group_membership',
'join_field' => array(),
'object_field_name' => array(),
'compare_field_table' => 'gid',
'compare_field_join' => 'gid');
$pntables = DBUtil::getTables();
$ccolumn = $pntables['groups_column'];
$ocolumn = $pntables['group_membership_column'];
$where = "b.$ocolumn[gid] = a.$ccolumn[gid] AND b.$ocolumn[uid] = $uid";
$items = DBUtil::selectExpandedObjectArray('groups', $myJoin, $where, '');
// Check for an error with the database code, and if so set an appropriate
// error message and return
if ($items === false) {
return $nivell_permisos;
}
$verifica = 2;
$potverificar = false;
$permisosModVar = ModUtil::getVar('IWnoteboard', 'permisos');
$verificaModVar = ModUtil::getVar('IWnoteboard', 'verifica');
$quiverificaModVar = ModUtil::getVar('IWnoteboard', 'quiverifica');
foreach ($items as $item) {
// get user permissions level
$permis = substr($permisosModVar, strpos($permisosModVar, '$' . $item['gid'] . '-') + strlen($item['gid']) + 2, 1);
$verifica = (strpos($verificaModVar, '$' . $item['gid'] . '$') != 0 && $verifica != 1) ? 0 : 1;
if ($permis > $n_permisos) {
$n_permisos = $permis;
}
if ($quiverificaModVar == $item['gid']) {
$potverificar = true;
}
$grups[] = $item['gid'];
}
$nivell_permisos = array('nivell' => $n_permisos,
'verifica' => $verifica,
'potverificar' => $potverificar,
'grups' => $grups);
return $nivell_permisos;
}
示例15: display
//.........这里部分代码省略.........
}
$hasIdentifier |= $hasSlug;
$this->throwNotFoundUnless($hasIdentifier, $this->__('Error! Invalid identifier received.'));
$entity = ModUtil::apiFunc($this->name, 'selection', 'getEntity', array('ot' => $objectType, 'id' => $idValues, 'slug' => $slugTitle));
$this->throwNotFoundUnless($entity != null, $this->__('No such item.'));
// we take the children postings of the parent issue
if ($objectType == 'posting') {
$postingid = $entity['id'];
$postingsWhere = 'tbl.parent = \'' . DataUtil::formatForStore($postingid) . '\'';
$order = ModUtil::getVar($this->name, 'sortingPostings');
if ($order == 'descending') {
$sdir = 'desc';
} else {
$sdir = 'asc';
}
$selectionArgs = array('ot' => 'posting', 'where' => $postingsWhere, 'orderBy' => 'createdDate' . ' ' . $sdir);
// the current offset which is used to calculate the pagination
$currentPage = (int) (isset($args['pos']) && !empty($args['pos'])) ? $args['pos'] : $this->request->getGet()->filter('pos', 1, FILTER_VALIDATE_INT);
// the number of items displayed on a page for pagination
$resultsPerPage = (int) (isset($args['num']) && !empty($args['num'])) ? $args['num'] : $this->request->getGet()->filter('num', 0, FILTER_VALIDATE_INT);
if ($resultsPerPage == 0) {
$csv = (int) (isset($args['usecsv']) && !empty($args['usecsv'])) ? $args['usecsv'] : $this->request->getGet()->filter('usecsvext', 0, FILTER_VALIDATE_INT);
$resultsPerPage = $csv == 1 ? 999999 : $this->getVar('pagesize', 10);
}
$selectionArgs['currentPage'] = $currentPage;
$selectionArgs['resultsPerPage'] = $resultsPerPage;
list($entities, $objectCount) = ModUtil::apiFunc($this->name, 'selection', 'getEntitiesPaginated', $selectionArgs);
// we check if the user may see the form to answer to posting
$mayEdit = MUBoard_Util_Controller::mayEdit($id);
$this->view->assign('mayEdit', $mayEdit);
}
if ($objectType == 'forum') {
$forumid = $entity['id'];
$parentWhere = 'tbl.parent_id IS NULL';
$parentWhere .= ' AND ';
$parentWhere .= 'tbl.forum = \'' . DataUtil::formatForStore($forumid) . '\'';
$order = ModUtil::getVar($this->name, 'sortingPostings');
if ($order == 'descending') {
$sdir = 'desc';
} else {
$sdir = 'asc';
}
$selectionArgs = array('ot' => 'posting', 'where' => $parentWhere, 'orderBy' => 'createdDate' . ' ' . $sdir);
// the current offset which is used to calculate the pagination
$currentPage = (int) (isset($args['pos']) && !empty($args['pos'])) ? $args['pos'] : $this->request->getGet()->filter('pos', 1, FILTER_VALIDATE_INT);
// the number of items displayed on a page for pagination
$resultsPerPage = (int) (isset($args['num']) && !empty($args['num'])) ? $args['num'] : $this->request->getGet()->filter('num', 0, FILTER_VALIDATE_INT);
if ($resultsPerPage == 0) {
$csv = (int) (isset($args['usecsv']) && !empty($args['usecsv'])) ? $args['usecsv'] : $this->request->getGet()->filter('usecsvext', 0, FILTER_VALIDATE_INT);
$resultsPerPage = $csv == 1 ? 999999 : $this->getVar('pagesize', 10);
}
$selectionArgs['currentPage'] = $currentPage;
$selectionArgs['resultsPerPage'] = $resultsPerPage;
list($entities, $objectCount) = ModUtil::apiFunc($this->name, 'selection', 'getEntitiesPaginated', $selectionArgs);
}
// build ModUrl instance for display hooks
$currentUrlArgs = array('ot' => $objectType);
foreach ($idFields as $idField) {
$currentUrlArgs[$idField] = $idValues[$idField];
}
// add a call to the posting
if ($objectType == 'posting') {
MUBoard_Util_Model::addView($idValues);
}
// get actual time
$nowtime = DateUtil::getDatetime();
// set sessionvar with calling time
SessionUtil::setVar('muboardonline', $nowtime);
$currentUrlObject = new Zikula_ModUrl($this->name, 'user', 'display', ZLanguage::getLanguageCode(), $currentUrlArgs);
$type = $this->request->getGet()->filter('type', 'admin', FILTER_SANITIZE_STRING);
$func = $this->request->getGet()->filter('func', 'view', FILTER_SANITIZE_STRING);
$editPostings = ModUtil::getVar($this->name, 'editPostings');
// assign output data to view object.
$this->view->assign($objectType, $entity)->assign('postings', $entities)->assign('currentUrlObject', $currentUrlObject)->assign('func', $func)->assign('editPostings', $editPostings)->assign($repository->getAdditionalTemplateParameters('controllerAction', $utilArgs));
$this->view->assign('currentPage', $currentPage)->assign('pager', array('numitems' => $objectCount, 'itemsperpage' => $resultsPerPage));
$dom = ZLanguage::getModuleDomain($this->name);
// we set Pagetitle
$sitename = ModUtil::getVar('ZConfig', 'sitename');
if ($objectType == 'category') {
$titletobject = __('Forum - Category: ', $dom);
}
if ($objectType == 'forum') {
$titletobject = __('Forum - Category: ', $dom) . ' ' . $entity['category']['title'] . ' - ' . __('Forum: ', $dom);
}
if ($objectType == 'posting') {
$titletobject = 'Forum: ' . ' ' . $entity['forum']['title'] . ' - ' . __('Issue: ', $dom);
}
PageUtil::setVar('title', $sitename . ' - ' . $titletobject . ' ' . $entity['title']);
// we set description
if ($objectType == 'category' || $objectType == 'forum') {
$descriptionobject = $entity['description'];
}
if ($objectType == 'posting') {
$descriptionobject = $entity['text'];
$descriptionobject = substr($descriptionobject, 0, 160) . '...';
}
PageUtil::setVar('description', $descriptionobject);
// fetch and return the appropriate template
return MUBoard_Util_View::processTemplate($this->view, 'user', $objectType, 'display', $args);
}