本文整理汇总了PHP中System::serverGetVar方法的典型用法代码示例。如果您正苦于以下问题:PHP System::serverGetVar方法的具体用法?PHP System::serverGetVar怎么用?PHP System::serverGetVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System::serverGetVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transform
/**
* transform text to images
*
* @param string $args['text']
*/
function transform($args)
{
$text = $args['text'];
// check the user agent - if it is a bot, return immediately
$robotslist = array("ia_archiver", "googlebot", "mediapartners-google", "yahoo!", "msnbot", "jeeves", "lycos");
$useragent = System::serverGetVar('HTTP_USER_AGENT');
for ($cnt = 0; $cnt < count($robotslist); $cnt++) {
if (strpos(strtolower($useragent), $robotslist[$cnt]) !== false) {
return $text;
}
}
$smilies = $this->getVar('smilie_array');
$remove_inactive = $this->getVar('remove_inactive');
if (is_array($smilies) && count($smilies) > 0) {
// sort smilies, see http://code.zikula.org/BBSmile/ticket/1
uasort($smilies, array($this, 'cmp_smiliesort'));
$imagepath = System::getBaseUrl() . DataUtil::formatForOS($this->getVar('smiliepath'));
$imagepath_auto = System::getBaseUrl() . DataUtil::formatForOS($this->getVar('smiliepath_auto'));
$auto_active = $this->getVar('activate_auto');
// pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
// This is important!
$text = ' ' . $text;
foreach ($smilies as $smilie) {
// check if smilie is active
if ($smilie['active'] == 1) {
// check if alt is a define
$smilie['alt'] = defined($smilie['alt']) ? constant($smilie['alt']) : $smilie['alt'];
if ($smilie['type'] == 0) {
$text = str_replace($smilie['short'], ' <img src="' . $imagepath . '/' . $smilie['imgsrc'] . '" alt="' . $smilie['alt'] . '" /> ', $text);
} else {
if ($auto_active == 1) {
$text = str_replace($smilie['short'], ' <img src="' . $imagepath_auto . '/' . $smilie['imgsrc'] . '" alt="' . $smilie['alt'] . '" /> ', $text);
}
}
if (!empty($smilie['alias'])) {
$aliases = explode(",", trim($smilie['alias']));
if (is_array($aliases) && count($aliases) > 0) {
foreach ($aliases as $alias) {
if ($smilie['type'] == 0) {
$text = str_replace($alias, ' <img src="' . $imagepath . '/' . $smilie['imgsrc'] . '" alt="' . $smilie['alt'] . '" /> ', $text);
} else {
if ($auto_active == 1) {
$text = str_replace($alias, ' <img src="' . $imagepath_auto . '/' . $smilie['imgsrc'] . '" alt="' . $smilie['alt'] . '" /> ', $text);
}
}
}
}
}
} else {
// End of if smilie is active
$text = str_replace($smilie['short'], '', $text);
}
}
// foreach
// Remove our padding from the string..
$text = substr($text, 1);
}
// End of if smilies is array and not empty
return $text;
}
示例2: editAction
/**
* update category
*/
public function editAction()
{
$this->checkCsrfToken();
if (!SecurityUtil::checkPermission('Categories::', '::', ACCESS_ADMIN)) {
throw new \Zikula\Framework\Exception\ForbiddenException();
}
$args = array();
if ($this->request->request->get('category_copy', null)) {
$args['op'] = 'copy';
$args['cid'] = $_POST['category']['id'];
return $this->redirect(ModUtil::url('Categories', 'admin', 'op', $args));
}
if ($this->request->request->get('category_move', null)) {
$args['op'] = 'move';
$args['cid'] = $_POST['category']['id'];
return $this->redirect(ModUtil::url('Categories', 'admin', 'op', $args));
}
if ($this->request->request->get('category_delete', null)) {
$args['op'] = 'delete';
$args['cid'] = $_POST['category']['id'];
return $this->redirect(ModUtil::url('Categories', 'admin', 'op', $args));
}
if ($this->request->request->get('category_user_edit', null)) {
$_SESSION['category_referer'] = System::serverGetVar('HTTP_REFERER');
$args['dr'] = $_POST['category']['id'];
return $this->redirect(ModUtil::url('Categories', 'user', 'edit', $args));
}
$cat = new Category();
$data = $cat->getDataFromInput();
if (!$cat->validate('admin')) {
$category = $this->request->request->get('category', null);
$args['cid'] = $category['id'];
$args['mode'] = 'edit';
return $this->redirect(ModUtil::url('Categories', 'admin', 'edit', $args));
}
$attributes = array();
$values = $this->request->request->get('attribute_value');
foreach ($this->request->request->get('attribute_name') as $index => $name) {
if (!empty($name)) {
$attributes[$name] = $values[$index];
}
}
$cat->setDataField('__ATTRIBUTES__', $attributes);
// retrieve old category from DB
$category = $this->request->request->get('category', null);
$oldCat = new Category(DBObject::GET_FROM_DB, $category['id']);
// update new category data
$cat->update();
// since a name change will change the object path, we must rebuild it here
if ($oldCat->_objData['name'] != $cat->_objData['name']) {
$obj = $cat->_objData;
CategoryUtil::rebuildPaths('path', 'name', $obj['id']);
}
$msg = __f('Done! Saved the %s category.', $oldCat->_objData['name']);
LogUtil::registerStatus($msg);
return $this->redirect(ModUtil::url('Categories', 'admin', 'view'));
}
示例3: _createNew
/**
* Create a new session.
*
* @param string $sessid The session ID.
* @param string $ipaddr The IP address of the host with this session.
*
* @return boolean
*/
public static function _createNew($sessid, $ipaddr)
{
$now = date('Y-m-d H:i:s', time());
$obj = array('sessid' => $sessid, 'ipaddr' => $ipaddr, 'uid' => 0, 'lastused' => $now);
$GLOBALS['_ZSession']['obj'] = $obj;
$GLOBALS['_ZSession']['new'] = true;
// Generate a random number, used for some authentication (using prime numer bounds)
//self::setVar('rand', RandomUtil::getString(32, 40, false, true, true, false, true, true, true));
// Initialize the array of random values for modules authentication
self::setVar('rand', array());
// write hash of useragent into the session for later validation
self::setVar('useragent', sha1(System::serverGetVar('HTTP_USER_AGENT')));
// init status & error message arrays
self::setVar('uid', 0);
return true;
}
示例4: smarty_function_servergetvar
/**
* Zikula_View function to get module variable
*
* This function obtains a server-specific variable from the system.
*
* Note that the results should be handled by the safetext or the safehtml
* modifier before being displayed.
*
*
* Available parameters:
* - name: The name of the module variable to obtain
* - assign: (optional) If set then result will be assigned to this template variable
* - default: (optional) The default value to return if the server variable is not set
*
* Example
* {servergetvar name='PHP_SELF'}
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return string The module variable.
*/
function smarty_function_servergetvar($params, Zikula_View $view)
{
$assign = isset($params['assign']) ? $params['assign'] : null;
$default = isset($params['default']) ? $params['default'] : null;
$name = isset($params['name']) ? $params['name'] : null;
if (!$name) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('System::serverGetVar', 'name')));
return false;
}
$result = System::serverGetVar($name, $default);
if ($assign) {
$view->assign($assign, $result);
} else {
return DataUtil::formatForDisplay($result);
}
}
示例5: changestatus
/**
* Change the status of a block.
*
* Invert the status of a given block id (collapsed/uncollapsed).
*
* @return void
*/
public function changestatus()
{
$bid = FormUtil::getPassedValue('bid');
$uid = UserUtil::getVar('uid');
$entity = $this->name . '_Entity_UserBlock';
$item = $this->entityManager->getRepository($entity)->findOneBy(array('uid' => $uid, 'bid' => $bid));
if ($item['active'] == 1) {
$item['active'] = 0;
} else {
$item['active'] = 1;
}
$this->entityManager->flush();
// now lets get back to where we came from
$this->redirect(System::serverGetVar('HTTP_REFERER'));
}
示例6: start
/**
* {@inheritdoc}
*/
public function start()
{
// create IP finger print
$current_ipaddr = '';
$_REMOTE_ADDR = System::serverGetVar('REMOTE_ADDR');
$_HTTP_X_FORWARDED_FOR = System::serverGetVar('HTTP_X_FORWARDED_FOR');
// create the ip fingerprint
$current_ipaddr = md5($_REMOTE_ADDR . $_HTTP_X_FORWARDED_FOR);
// start session check expiry and ip fingerprint if required
if (parent::start()) {
// check if session has expired or not
$now = time();
$inactive = $now - (int) (System::getVar('secinactivemins') * 60);
$daysold = $now - (int) (System::getVar('secmeddays') * 86400);
$lastused = $this->getMetadataBag()->getLastUsed();
$rememberme = SessionUtil::getVar('rememberme');
$uid = $this->getBag('attributes')->get('uid');
switch (System::getVar('seclevel')) {
case 'Low':
// Low security - users stay logged in permanently
// no special check necessary
break;
case 'Medium':
// Medium security - delete session info if session cookie has
// expired or user decided not to remember themself and inactivity timeout
// OR max number of days have elapsed without logging back in
if (!$rememberme && $lastused < $inactive || $lastused < $daysold || $uid == '0' && $lastused < $inactive) {
$this->expire();
}
break;
case 'High':
default:
// High security - delete session info if user is inactive
//if ($rememberme && ($lastused < $inactive)) { // see #427
if ($lastused < $inactive) {
$this->expire();
}
break;
}
}
return true;
}
示例7: start
public function start()
{
$config = array('gc_probability' => System::getVar('gc_probability'), 'gc_divisor' => 10000, 'gc_maxlifetime' => System::getVar('secinactivemins'));
$path = System::getBaseUri();
if (empty($path)) {
$path = '/';
} elseif (substr($path, -1, 1) != '/') {
$path .= '/';
}
$config['cookie_path'] = $path;
$host = System::serverGetVar('HTTP_HOST');
if (($pos = strpos($host, ':')) !== false) {
$host = substr($host, 0, $pos);
}
// PHP configuration variables
// Set lifetime of session cookie
$seclevel = System::getVar('seclevel');
switch ($seclevel) {
case 'High':
// Session lasts duration of browser
$lifetime = 0;
// Referer check
// ini_set('session.referer_check', $host.$path);
$config['referer_check'] = $host;
break;
case 'Medium':
// Session lasts set number of days
$lifetime = System::getVar('secmeddays') * 86400;
break;
case 'Low':
default:
// (Currently set to 1 year)
$lifetime = 31536000;
break;
}
$config['cookie_lifetime'] = $lifetime;
$this->storage->setOptions($config);
return parent::start();
}
示例8: 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.'));
}
}
示例9: _base_vars
/**
* Assign template vars for base theme paths and other useful variables.
*
* @return void
*/
private function _base_vars()
{
// identify the page type
$this->pagetype = 'module';
if (stristr(System::serverGetVar('PHP_SELF'), 'admin.php') || strtolower($this->type) == 'admin') {
$this->pagetype = 'admin';
} else {
$module = FormUtil::getPassedValue('module', null, 'GETPOST', FILTER_SANITIZE_STRING);
if (empty($module)) {
$this->pagetype = 'home';
}
}
// set some basic class variables from Zikula
$this->isloggedin = UserUtil::isLoggedIn();
$this->uid = UserUtil::getVar('uid');
// assign the query string
$this->qstring = System::serverGetVar('QUERY_STRING', '');
// assign the current script
$this->requesturi = System::getCurrentUri();
// define the cache_id if not set yet
if ($this->caching && !$this->cache_id) {
// module / type / function / customargs|homepage/startpageargs / uid_X|guest
$this->cache_id = $this->toplevelmodule . '/' . $this->type . '/' . $this->func . (!$this->homepage ? $this->_get_customargs() : '/homepage/' . str_replace(',', '/', System::getVar('startargs'))) . '/' . UserUtil::getUidCacheString();
}
// assign some basic paths for the engine
$this->template_dir = $this->themepath . '/templates';
// default directory for templates
$this->themepath = 'themes/' . $this->directory;
$theme = ThemeUtil::getTheme($this->name);
if (null === $theme) {
$this->imagepath = $this->themepath . '/images';
$this->imagelangpath = $this->themepath . '/images/' . $this->language;
$this->stylepath = $this->themepath . '/style';
$this->scriptpath = $this->themepath . '/javascript';
} else {
$this->imagepath = $this->themepath . '/Resources/public/images';
$this->imagelangpath = $this->themepath . '/Resources/public/images/' . $this->language;
$this->stylepath = $this->themepath . '/Resources/public/css';
$this->scriptpath = $this->themepath . '/Resources/public/js';
}
// make the base vars available to all templates
$this->assign('module', $this->toplevelmodule)->assign('uid', $this->uid)->assign('loggedin', $this->isloggedin)->assign('pagetype', $this->pagetype)->assign('themepath', $this->themepath)->assign('imagepath', $this->imagepath)->assign('imagelangpath', $this->imagelangpath)->assign('stylepath', $this->stylepath)->assign('scriptpath', $this->scriptpath);
// load the theme variables
$variables = ModUtil::apiFunc('ZikulaThemeModule', 'user', 'getvariables', array('theme' => $this->name));
$this->assign($variables['variables']);
}
示例10: resequence
/**
* resequence categories
*/
public function resequence()
{
if (!SecurityUtil::checkPermission('Categories::', '::', ACCESS_EDIT)) {
return LogUtil::registerPermissionError();
}
$dr = (int)FormUtil::getPassedValue('dr', 0, 'GET');
$url = System::serverGetVar('HTTP_REFERER');
if (!$dr) {
return LogUtil::registerError($this->__('Error! The document root is invalid.'), null, $url);
}
$cats = CategoryUtil::getSubCategories($dr, false, false, false, false);
$cats = CategoryUtil::resequence($cats, 10);
$ak = array_keys($cats);
foreach ($ak as $k) {
$obj = new Categories_DBObject_Category($cats[$k]);
$obj->update();
}
$this->redirect(System::serverGetVar('HTTP_REFERER'));
}
示例11: _securityanalyzer
/**
* Get security analyzer data.
*
* @return array data
*/
private function _securityanalyzer()
{
$data = array();
// check for magic_quotes
$data['magic_quotes_gpc'] = \DataUtil::getBooleanIniValue('magic_quotes_gpc');
// check for register_globals
$data['register_globals'] = \DataUtil::getBooleanIniValue('register_globals');
// check for config.php beeing writable
$data['config_php'] = (bool) is_writable('config/config.php');
// check for .htaccess in temp directory
$temp_htaccess = false;
$tempDir = $GLOBALS['ZConfig']['System']['temp'];
if ($tempDir) {
// check if we have an absolute path which is possibly not within the document root
$docRoot = \System::serverGetVar('DOCUMENT_ROOT');
if (\StringUtil::left($tempDir, 1) == '/' && strpos($tempDir, $docRoot) === false) {
// temp dir is outside the webroot, no .htaccess file needed
$temp_htaccess = true;
} else {
if (strpos($tempDir, $docRoot) === false) {
$ldir = dirname(__FILE__);
$p = strpos($ldir, DIRECTORY_SEPARATOR . 'system');
// we are in system/Admin
$b = substr($ldir, 0, $p);
$filePath = $b . '/' . $tempDir . '/.htaccess';
} else {
$filePath = $tempDir . '/.htaccess';
}
$temp_htaccess = (bool) file_exists($filePath);
}
} else {
// already customized, admin should know about what he's doing...
$temp_htaccess = true;
}
$data['temp_htaccess'] = $temp_htaccess;
$data['scactive'] = (bool) \ModUtil::available('SecurityCenterModule');
// check for outputfilter
$data['useids'] = (bool) (\ModUtil::available('SecurityCenterModule') && System::getVar('useids') == 1);
$data['idssoftblock'] = System::getVar('idssoftblock');
return $data;
}
示例12: checksubmitter
/**
* Work out the status for a comment
*
* this function checks for blacklisted proxies and if the user
* has already commented
*
* @author Mark West
* @access prviate
* @return mixed int 1 to require moderation, 0 for instant submission, 2 for discarding the comment, void error
*/
private function checksubmitter($uid = null)
{
// check for open proxies
// credit to wordpress for this logic function wp_proxy_check()
$ipnum = System::serverGetVar('REMOTE_ADDR');
// set the current uid if not present
if (!isset($uid)) {
$uid = UserUtil::getVar('uid');
}
if ($this->getVar('proxyblacklist') && !empty($ipnum)) {
$rev_ip = implode('.', array_reverse(explode('.', $ipnum)));
// opm.blitzed.org is appended to use thier proxy lookup service
// results of gethostbyname are cached
$lookup = $rev_ip.'.opm.blitzed.org';
if ($lookup != gethostbyname($lookup)) {
return 2;
}
}
// check if the comment comes from user that we trust
// i.e. one who has an approved comment already
if (UserUtil::isLoggedIn() && $this->getVar('dontmoderateifcommented')) {
$commentedlist = $this->getcommentingusers();
if (is_array($commentedlist) && in_array($uid, $commentedlist)) {
return 0;
}
return 1;
}
return 0;
}
示例13: view
/**
* view items
*
* @param int $startnum the start item id for the pager
* @return string HTML output
*/
public function view($args)
{
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Pages::', '::', ACCESS_EDIT), LogUtil::getErrorMsgPermission());
// initialize sort array - used to display sort classes and urls
$sort = array();
$fields = array('pageid', 'title', 'cr_date'); // possible sort fields
foreach ($fields as $field) {
$sort['class'][$field] = 'z-order-unsorted'; // default values
}
// Get parameters from whatever input we need.
$startnum = (int)FormUtil::getPassedValue('startnum', isset($args['startnum']) ? $args['startnum'] : null, 'GETPOST');
$language = FormUtil::getPassedValue('language', isset($args['language']) ? $args['language'] : null, 'POST');
$purge = FormUtil::getPassedValue('purge', false, 'GET');
$orderby = FormUtil::getPassedValue('orderby', isset($args['orderby']) ? $args['orderby'] : 'pageid', 'GETPOST');
$original_sdir = FormUtil::getPassedValue('sdir', isset($args['sdir']) ? $args['sdir'] : 1, 'GETPOST');
$this->view->assign('startnum', $startnum);
$this->view->assign('orderby', $orderby);
$this->view->assign('sdir', $original_sdir);
$sdir = $original_sdir ? 0 : 1; //if true change to false, if false change to true
// change class for selected 'orderby' field to asc/desc
if ($sdir == 0) {
$sort['class'][$orderby] = 'z-order-desc';
$orderdir = 'DESC';
}
if ($sdir == 1) {
$sort['class'][$orderby] = 'z-order-asc';
$orderdir = 'ASC';
}
$filtercats = FormUtil::getPassedValue('pages', null, 'GETPOST');
$filtercats_serialized = FormUtil::getPassedValue('filtercats_serialized', false, 'GET');
$filtercats = $filtercats_serialized ? unserialize($filtercats_serialized) : $filtercats;
$catsarray = Pages_Util::formatCategoryFilter($filtercats);
// complete initialization of sort array, adding urls
foreach ($fields as $field) {
$sort['url'][$field] = ModUtil::url('Pages', 'admin', 'view', array(
'language' => $language,
'filtercats_serialized' => serialize($filtercats),
'orderby' => $field,
'sdir' => $sdir));
}
$this->view->assign('sort', $sort);
$this->view->assign('filter_active', (empty($language) && empty($catsarray)) ? false : true);
if ($purge) {
if (ModUtil::apiFunc('Pages', 'admin', 'purgepermalinks')) {
LogUtil::registerStatus($this->__('Purging of the pemalinks was successful'));
} else {
LogUtil::registerError($this->__('Purging of the pemalinks has failed'));
}
return System::redirect(strpos(System::serverGetVar('HTTP_REFERER'), 'purge') ? ModUtil::url('Pages', 'admin', 'view') : System::serverGetVar('HTTP_REFERER'));
}
// get module vars
$modvars = $this->getVars();
if ($modvars['enablecategorization']) {
$catregistry = CategoryRegistryUtil::getRegisteredModuleCategories('Pages', 'pages');
$this->view->assign('catregistry', $catregistry);
}
$multilingual = System::getVar('multilingual', false);
// Get all matching pages
$items = ModUtil::apiFunc('Pages', 'user', 'getall',
array('startnum' => $startnum,
'numitems' => $modvars['itemsperpage'],
'order' => $orderby,
'orderdir' => $orderdir,
'ignoreml' => ($multilingual ? false : true),
'language' => $language,
'category' => null,
'catfilter' => isset($catsarray) ? $catsarray : null,
'catregistry' => isset($catregistry) ? $catregistry : null));
if (!$items) {
$items = array();
}
$pages = array();
foreach ($items as $key => $item)
{
$options = array();
$options[] = array('url' => ModUtil::url('Pages', 'user', 'display', array('pageid' => $item['pageid'])),
'image' => 'kview.png',
'title' => $this->__('View'));
if (SecurityUtil::checkPermission('Pages::', "$item[title]::$item[pageid]", ACCESS_EDIT)) {
$options[] = array('url' => ModUtil::url('Pages', 'admin', 'modify', array('pageid' => $item['pageid'])),
//.........这里部分代码省略.........
示例14: create
/**
* Create a comment for a specific item
*
* This is a standard function that is called with the results of the
* form supplied by EZComments_user_view to create a new item
*
* @param $comment the comment (taken from HTTP put)
* @param $mod the name of the module the comment is for (taken from HTTP put)
* @param $objectid ID of the item the comment is for (taken from HTTP put)
* @param $redirect URL to return to (taken from HTTP put)
* @param $subject The subject of the comment (if any) (taken from HTTP put)
* @param $replyto The ID of the comment for which this an anser to (taken from HTTP put)
* @since 0.1
*/
public function create($args)
{
$mod = isset($args['mod']) ? $args['mod'] : FormUtil::getPassedValue('mod', null, 'POST');
$objectid = isset($args['objectid']) ? $args['objectid'] : FormUtil::getPassedValue('objectid', null, 'POST');
$areaid = isset($args['areaid']) ? $args['areaid'] : FormUtil::getPassedValue('areaid', null, 'POST');
$comment = isset($args['comment']) ? $args['comment'] : FormUtil::getPassedValue('comment', null, 'POST');
$subject = isset($args['subject']) ? $args['subject'] : FormUtil::getPassedValue('subject', null, 'POST');
$replyto = isset($args['replyto']) ? $args['replyto'] : FormUtil::getPassedValue('replyto', null, 'POST');
$owneruid = isset($args['owneruid']) ? $args['owneruid'] : FormUtil::getPassedValue('owneruid', null, 'POST');
$redirect = isset($args['redirect']) ? $args['redirect'] : FormUtil::getPassedValue('redirect', null, 'POST');
$useurl = isset($args['useurl']) ? $args['useurl'] : FormUtil::getPassedValue('useurl', null, 'POST');
// check if the user logged in and if we're allowing anon users to
// set a name and email address
if (!UserUtil::isLoggedIn()) {
$anonname = isset($args['anonname']) ? $args['anonname'] : FormUtil::getPassedValue('anonname', null, 'POST');
$anonmail = isset($args['anonmail']) ? $args['anonmail'] : FormUtil::getPassedValue('anonmail', null, 'POST');
$anonwebsite = isset($args['anonwebsite']) ? $args['anonwebsite'] : FormUtil::getPassedValue('anonwebsite', null, 'POST');
} else {
$anonname = '';
$anonmail = '';
$anonwebsite = '';
}
if (!isset($owneruid) || !($owneruid > 1)) {
$owneruid = 0;
}
$redirect = str_replace('&', '&', base64_decode($redirect));
$redirect = !empty($redirect) ? $redirect : System::serverGetVar('HTTP_REFERER');
$useurl = base64_decode($useurl);
// save the submitted data if any error occurs
$ezcomment = unserialize(SessionUtil::getVar('ezcomment', 'a:0:{}'));
if (isset($ezcomment[$mod][$objectid])) {
unset($ezcomment[$mod][$objectid]);
}
if (!empty($subject)) {
$ezcomment[$mod][$objectid]['subject'] = $subject;
}
if (!empty($comment)) {
$ezcomment[$mod][$objectid]['comment'] = $comment;
}
if (!empty($anonname)) {
$ezcomment[$mod][$objectid]['anonname'] = $anonname;
}
if (!empty($anonmail)) {
$ezcomment[$mod][$objectid]['anonmail'] = $anonmail;
}
if (!empty($anonwebsite)) {
$ezcomment[$mod][$objectid]['anonwebsite'] = $anonwebsite;
}
// Confirm authorisation code
// check csrf token
SessionUtil::setVar('ezcomment', serialize($ezcomment));
$this->checkCsrfToken();
SessionUtil::delVar('ezcomment');
// and check we've actually got a comment....
if (empty($comment)) {
SessionUtil::setVar('ezcomment', serialize($ezcomment));
return LogUtil::registerError($this->__('Error! The comment contains no text.'), null, $redirect . "#commentform_{$mod}_{$objectid}");
}
// Check hooked modules for validation
$hookvalidators = $this->notifyHooks(new Zikula_ValidationHook('ezcomments.ui_hooks.comments.validate_edit', new Zikula_Hook_ValidationProviders()))->getValidators();
if ($hookvalidators->hasErrors()) {
SessionUtil::setVar('ezcomment', serialize($ezcomment));
return LogUtil::registerError($this->__('Error! The hooked content does not validate. Could it possibly be that a captcha code was entered incorrectly?'), null, $redirect . "#commentform_{$mod}_{$objectid}");
}
// now parse out the hostname+subfolder from the url for storing in the DB
$url = str_replace(System::getBaseUri(), '', $useurl);
$id = ModUtil::apiFunc('EZComments', 'user', 'create', array('mod' => $mod, 'objectid' => $objectid, 'areaid' => $areaid, 'url' => $url, 'comment' => $comment, 'subject' => $subject, 'replyto' => $replyto, 'uid' => UserUtil::getVar('uid'), 'owneruid' => $owneruid, 'useurl' => $useurl, 'redirect' => $redirect, 'anonname' => $anonname, 'anonmail' => $anonmail, 'anonwebsite' => $anonwebsite));
if ($id) {
// clear respective cache
ModUtil::apiFunc('EZComments', 'user', 'clearItemCache', array('id' => $id, 'modname' => $mod, 'objectid' => $objectid, 'url' => $url));
} else {
// redirect if it was not successful
SessionUtil::setVar('ezcomment', $ezcomment);
System::redirect($redirect . "#commentform_{$mod}_{$objectid}");
}
// clean/set the session data
if (isset($ezcomment[$mod][$objectid])) {
unset($ezcomment[$mod][$objectid]);
if (empty($ezcomment[$mod])) {
unset($ezcomment[$mod]);
}
}
if (empty($ezcomment)) {
SessionUtil::delVar('ezcomment');
} else {
SessionUtil::setVar('ezcomment', serialize($ezcomment));
//.........这里部分代码省略.........
示例15: start
/**
* {@inheritdoc}
*/
public function start()
{
$path = System::getBaseUri();
if (empty($path)) {
$path = '/';
} elseif (substr($path, -1, 1) != '/') {
$path .= '/';
}
$host = System::serverGetVar('HTTP_HOST');
if (($pos = strpos($host, ':')) !== false) {
$host = substr($host, 0, $pos);
}
// PHP configuration variables
ini_set('session.use_trans_sid', 0);
// Stop adding SID to URLs
@ini_set('url_rewriter.tags', '');
// some environments dont allow this value to be set causing an error that prevents installation
ini_set('session.serialize_handler', 'php');
// How to store data
ini_set('session.use_cookies', 1);
// Use cookie to store the session ID
ini_set('session.auto_start', 1);
// Auto-start session
ini_set('session.name', SessionUtil::getCookieName());
// Name of our cookie
// Set lifetime of session cookie
$seclevel = System::getVar('seclevel');
switch ($seclevel) {
case 'High':
// Session lasts duration of browser
$lifetime = 0;
// Referer check
// ini_set('session.referer_check', $host.$path);
ini_set('session.referer_check', $host);
break;
case 'Medium':
// Session lasts set number of days
$lifetime = System::getVar('secmeddays') * 86400;
break;
case 'Low':
default:
// Session lasts unlimited number of days (well, lots, anyway)
// (Currently set to 25 years)
$lifetime = 788940000;
break;
}
ini_set('session.cookie_lifetime', $lifetime);
// domain and path settings for session cookie
// if (System::getVar('intranet') == false) {
// Cookie path
ini_set('session.cookie_path', $path);
// Garbage collection
ini_set('session.gc_probability', System::getVar('gc_probability'));
ini_set('session.gc_divisor', 10000);
ini_set('session.gc_maxlifetime', System::getVar('secinactivemins') * 60);
// Inactivity timeout for user sessions
ini_set('session.hash_function', 1);
// Set custom session handlers
ini_set('session.save_handler', 'user');
if (System::getVar('sessionstoretofile')) {
ini_set('session.save_path', System::getVar('sessionsavepath'));
}
session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
// create IP finger print
$current_ipaddr = '';
$_REMOTE_ADDR = System::serverGetVar('REMOTE_ADDR');
$_HTTP_X_FORWARDED_FOR = System::serverGetVar('HTTP_X_FORWARDED_FOR');
if (System::getVar('sessionipcheck')) {
// feature for future release
}
// create the ip fingerprint
$current_ipaddr = md5($_REMOTE_ADDR . $_HTTP_X_FORWARDED_FOR);
// start session check expiry and ip fingerprint if required
if (session_start() && isset($GLOBALS['_ZSession']['obj']) && $GLOBALS['_ZSession']['obj']) {
// check if session has expired or not
$now = time();
$inactive = $now - (int) (System::getVar('secinactivemins') * 60);
$daysold = $now - (int) (System::getVar('secmeddays') * 86400);
$lastused = strtotime($GLOBALS['_ZSession']['obj']['lastused']);
$rememberme = SessionUtil::getVar('rememberme');
$uid = $GLOBALS['_ZSession']['obj']['uid'];
$ipaddr = $GLOBALS['_ZSession']['obj']['ipaddr'];
// IP check
if (System::getVar('sessionipcheck', false)) {
if ($ipaddr !== $current_ipaddr) {
session_destroy();
return false;
}
}
switch (System::getVar('seclevel')) {
case 'Low':
// Low security - users stay logged in permanently
// no special check necessary
break;
case 'Medium':
// Medium security - delete session info if session cookie has
// expired or user decided not to remember themself and inactivity timeout
//.........这里部分代码省略.........