本文整理汇总了PHP中t3lib_div::cmpIP方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div::cmpIP方法的具体用法?PHP t3lib_div::cmpIP怎么用?PHP t3lib_div::cmpIP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_div
的用法示例。
在下文中一共展示了t3lib_div::cmpIP方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDevMode
public static function getDevMode()
{
if (self::$devMode === null) {
self::$devMode = t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
}
return self::$devMode;
}
示例2: getGroups
/**
* Find usergroup records, currently only for frontend
*
* @param array Data of user.
* @param array Group data array of already known groups. This is handy if you want select other related groups. Keys in this array are unique IDs of those groups.
* @return mixed Groups array, keys = uid which must be unique
*/
function getGroups($user, $knownGroups)
{
global $TYPO3_CONF_VARS;
$groupDataArr = array();
if ($this->mode == 'getGroupsFE') {
$groups = array();
if (is_array($user) && $user[$this->db_user['usergroup_column']]) {
$groupList = $user[$this->db_user['usergroup_column']];
$groups = array();
$this->getSubGroups($groupList, '', $groups);
}
// ADD group-numbers if the IPmask matches.
if (is_array($TYPO3_CONF_VARS['FE']['IPmaskMountGroups'])) {
foreach ($TYPO3_CONF_VARS['FE']['IPmaskMountGroups'] as $IPel) {
if ($this->authInfo['REMOTE_ADDR'] && $IPel[0] && t3lib_div::cmpIP($this->authInfo['REMOTE_ADDR'], $IPel[0])) {
$groups[] = intval($IPel[1]);
}
}
}
$groups = array_unique($groups);
if (count($groups)) {
$list = implode(',', $groups);
if ($this->writeDevLog) {
t3lib_div::devLog('Get usergroups with id: ' . $list, 'tx_sv_auth');
}
$lockToDomain_SQL = ' AND (lockToDomain=\'\' OR lockToDomain IS NULL OR lockToDomain=\'' . $this->authInfo['HTTP_HOST'] . '\')';
if (!$this->authInfo['showHiddenRecords']) {
$hiddenP = 'AND hidden=0 ';
}
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->db_groups['table'], 'deleted=0 ' . $hiddenP . ' AND uid IN (' . $list . ')' . $lockToDomain_SQL);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$groupDataArr[$row['uid']] = $row;
}
if ($res) {
$GLOBALS['TYPO3_DB']->sql_free_result($res);
}
} else {
if ($this->writeDevLog) {
t3lib_div::devLog('No usergroups found.', 'tx_sv_auth', 2);
}
}
} elseif ($this->mode == 'getGroupsBE') {
# Get the BE groups here
# still needs to be implemented in t3lib_userauthgroup
}
return $groupDataArr;
}
示例3: isDevIpMask
/**
* IP-based Access restrictions
* @TODO: in util_dev auslagern!?
*
* @param string $remoteAddress
* @param string $devIPmask
* @return boolean
*/
public static function isDevIpMask($remoteAddress = '', $devIPmask = '')
{
$devIPmask = trim(strcmp($devIPmask, '') ? $devIPmask : $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
$remoteAddress = trim(strcmp($remoteAddress, '') ? $remoteAddress : t3lib_div::getIndpEnv('REMOTE_ADDR'));
return t3lib_div::cmpIP($remoteAddress, $devIPmask);
}
示例4: beLoginLinkIPList
/**
* Returns a link to the BE login screen with redirect to the front-end
*
* @return string HTML, a tag for a link to the backend.
*/
function beLoginLinkIPList()
{
if (!empty($this->config['config']['beLoginLinkIPList'])) {
if (t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $this->config['config']['beLoginLinkIPList'])) {
$label = !$this->beUserLogin ? $this->config['config']['beLoginLinkIPList_login'] : $this->config['config']['beLoginLinkIPList_logout'];
if ($label) {
if (!$this->beUserLogin) {
$link = '<a href="' . htmlspecialchars(TYPO3_mainDir . 'index.php?redirect_url=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' . $label . '</a>';
} else {
$link = '<a href="' . htmlspecialchars(TYPO3_mainDir . 'index.php?L=OUT&redirect_url=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '">' . $label . '</a>';
}
return $link;
}
}
}
}
示例5: checkLockToIP
/**
* If TYPO3_CONF_VARS['BE']['enabledBeUserIPLock'] is enabled and an IP-list is found in the User TSconfig objString "options.lockToIP", then make an IP comparison with REMOTE_ADDR and return the outcome (true/false)
*
* @return boolean True, if IP address validates OK (or no check is done at all)
* @access private
*/
function checkLockToIP()
{
global $TYPO3_CONF_VARS;
$out = 1;
if ($TYPO3_CONF_VARS['BE']['enabledBeUserIPLock']) {
$IPList = $this->getTSConfigVal('options.lockToIP');
if (trim($IPList)) {
$baseIP = t3lib_div::getIndpEnv('REMOTE_ADDR');
$out = t3lib_div::cmpIP($baseIP, $IPList);
}
}
return $out;
}
示例6: isAllowedIp
/**
* Checks if the current client ip is allowed.
*
* @param string $whitelist
* The ip whitelist.
*
* @return bool
* Whether the current client ip is allowed or not.
*/
public function isAllowedIp($whitelist)
{
$remote = $_SERVER['REMOTE_ADDR'];
// Use TYPO3 v6+ cmpIP if possible.
if (is_callable(array('TYPO3\\CMS\\Core\\Utility\\GeneralUtility', 'cmpIP'))) {
return \TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP($remote, $whitelist);
}
// Use TYPO3 v6- cmpIP if possible.
if (is_callable(array('t3lib_div', 'cmpIP'))) {
return \t3lib_div::cmpIP($remote, $whitelist);
}
// Fallback to the Chin Leung implementation.
// @author Chin Leung
// @see https://stackoverflow.com/questions/35559119/php-ip-address-whitelist-with-wildcards
$whitelist = explode(',', $whitelist);
if (in_array($remote, $whitelist)) {
// If the ip is matched, return true.
return true;
} else {
// Check the wildcards.
foreach ($whitelist as $ip) {
$ip = trim($ip);
$wildcardPos = strpos($ip, "*");
# Check if the ip has a wildcard
if ($wildcardPos !== false && substr($remote, 0, $wildcardPos) . "*" == $ip) {
return true;
}
}
}
return false;
}
示例7: ob_clean
// *********************
if ($temp_extId = t3lib_div::_GP('eID')) {
if ($classPath = t3lib_div::getFileAbsFileName($TYPO3_CONF_VARS['FE']['eID_include'][$temp_extId])) {
// Remove any output produced until now
ob_clean();
require $classPath;
}
exit;
}
// ***********************************
// Create $TSFE object (TSFE = TypoScript Front End)
// Connecting to database
// ***********************************
$TSFE = t3lib_div::makeInstance('tslib_fe', $TYPO3_CONF_VARS, t3lib_div::_GP('id'), t3lib_div::_GP('type'), t3lib_div::_GP('no_cache'), t3lib_div::_GP('cHash'), t3lib_div::_GP('jumpurl'), t3lib_div::_GP('MP'), t3lib_div::_GP('RDCT'));
/** @var $TSFE tslib_fe */
if ($TYPO3_CONF_VARS['FE']['pageUnavailable_force'] && !t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $TYPO3_CONF_VARS['SYS']['devIPmask'])) {
$TSFE->pageUnavailableAndExit('This page is temporarily unavailable.');
}
$TSFE->connectToDB();
// In case of a keyword-authenticated preview, re-initialize the TSFE object:
if ($temp_previewConfig = $TSFE->ADMCMD_preview()) {
$TSFE = t3lib_div::makeInstance('tslib_fe', $TYPO3_CONF_VARS, t3lib_div::_GP('id'), t3lib_div::_GP('type'), t3lib_div::_GP('no_cache'), t3lib_div::_GP('cHash'), t3lib_div::_GP('jumpurl'), t3lib_div::_GP('MP'), t3lib_div::_GP('RDCT'));
$TSFE->ADMCMD_preview_postInit($temp_previewConfig);
}
if ($TSFE->RDCT) {
$TSFE->sendRedirect();
}
// *******************
// Output compression
// *******************
// Remove any output produced until now
示例8: evaluateConditionCommon
/**
* Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"
*
* @param string The condition to match against its criterias.
* @return mixed Returns true or false based on the evaluation
*/
protected function evaluateConditionCommon($key, $value)
{
if (t3lib_div::inList('browser,version,system,useragent', strtolower($key))) {
$browserInfo = $this->getBrowserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
}
switch ($key) {
case 'browser':
$values = t3lib_div::trimExplode(',', $value, true);
// take all identified browsers into account, eg chrome deliver
// webkit=>532.5, chrome=>4.1, safari=>532.5
// so comparing string will be
// "webkit532.5 chrome4.1 safari532.5"
$all = '';
foreach ($browserInfo['all'] as $key => $value) {
$all .= $key . $value . ' ';
}
foreach ($values as $test) {
if (stripos($all, $test) !== false) {
return true;
}
}
break;
case 'version':
$values = t3lib_div::trimExplode(',', $value, true);
foreach ($values as $test) {
if (strcspn($test, '=<>') == 0) {
switch (substr($test, 0, 1)) {
case '=':
if (doubleval(substr($test, 1)) == $browserInfo['version']) {
return true;
}
break;
case '<':
if (doubleval(substr($test, 1)) > $browserInfo['version']) {
return true;
}
break;
case '>':
if (doubleval(substr($test, 1)) < $browserInfo['version']) {
return true;
}
break;
}
} else {
if (strpos(' ' . $browserInfo['version'], $test) == 1) {
return true;
}
}
}
break;
case 'system':
$values = t3lib_div::trimExplode(',', $value, true);
foreach ($values as $test) {
if (strpos(' ' . $browserInfo['system'], $test) == 1) {
return true;
}
}
break;
case 'device':
if (!isset($this->deviceInfo)) {
$this->deviceInfo = $this->getDeviceType(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
}
$values = t3lib_div::trimExplode(',', $value, true);
foreach ($values as $test) {
if ($this->deviceInfo == $test) {
return true;
}
}
break;
case 'useragent':
$test = trim($value);
if (strlen($test)) {
return $this->searchStringWildcard($browserInfo['useragent'], $test);
}
break;
case 'language':
$values = t3lib_div::trimExplode(',', $value, true);
foreach ($values as $test) {
if (preg_match('/^\\*.+\\*$/', $test)) {
$allLanguages = preg_split('/[,;]/', t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
if (in_array(substr($test, 1, -1), $allLanguages)) {
return true;
}
} else {
if (t3lib_div::getIndpEnv('HTTP_ACCEPT_LANGUAGE') == $test) {
return true;
}
}
}
break;
case 'IP':
if (t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $value)) {
return true;
}
//.........这里部分代码省略.........
示例9: initFE
public function initFE()
{
global $TT, $TSFE;
// ***********************************
// Create $TSFE object (TSFE = TypoScript Front End)
// Connecting to database
// ***********************************
$TSFE = t3lib_div::makeInstance('tslib_fe', $TYPO3_CONF_VARS, t3lib_div::_GP('id'), t3lib_div::_GP('type'), t3lib_div::_GP('no_cache'), t3lib_div::_GP('cHash'), t3lib_div::_GP('jumpurl'), t3lib_div::_GP('MP'), t3lib_div::_GP('RDCT'));
if ($TYPO3_CONF_VARS['FE']['pageUnavailable_force'] && !t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $TYPO3_CONF_VARS['SYS']['devIPmask'])) {
$TSFE->pageUnavailableAndExit('This page is temporarily unavailable.');
}
$TSFE->connectToDB();
if ($TSFE->RDCT) {
$TSFE->sendRedirect();
}
// *********
// FE_USER
// *********
$TT->push('Front End user initialized', '');
$TSFE->initFEuser();
$TT->pull();
// *****************************************
// Proces the ID, type and other parameters
// After this point we have an array, $page in TSFE, which is the
// page-record of the current page, $id
// *****************************************
$TT->push('Process ID', '');
// not needed and doesnot work with realurl //
$TSFE->checkAlternativeIdMethods();
$TSFE->clear_preview();
$TSFE->determineId();
// Now, if there is a backend user logged in and he has NO access to
// this page, then re-evaluate the id shown!
if ($TSFE->beUserLogin && !$BE_USER->extPageReadAccess($TSFE->page)) {
// Remove user
unset($BE_USER);
$TSFE->beUserLogin = 0;
// Re-evaluate the page-id.
$TSFE->checkAlternativeIdMethods();
$TSFE->clear_preview();
$TSFE->determineId();
}
$TSFE->makeCacheHash();
$TT->pull();
// *******************************************
// Get compressed $TCA-Array();
// After this, we should now have a valid $TCA, though minimized
// *******************************************
$TSFE->getCompressedTCarray();
// ********************************
// Starts the template
// *******************************
$TT->push('Start Template', '');
$TSFE->initTemplate();
$TSFE->tmpl->getFileName_backPath = PATH_site;
$TT->pull();
// ******************************************************
// Get config if not already gotten
// After this, we should have a valid config-array ready
// ******************************************************
$TSFE->getConfigArray();
}
示例10: explain
/**
* Explain select queries
* If $this->explainOutput is set, SELECT queries will be explained here. Only queries with more than one possible result row will be displayed.
* The output is either printed as raw HTML output or embedded into the TS admin panel (checkbox must be enabled!)
*
* TODO: Feature is not DBAL-compliant
*
* @param string SQL query
* @param string Table(s) from which to select. This is what comes right after "FROM ...". Required value.
* @param integer Number of resulting rows
* @return boolean True if explain was run, false otherwise
*/
protected function explain($query, $from_table, $row_count)
{
if ((int) $this->explainOutput == 1 || (int) $this->explainOutput == 2 && t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
// raw HTML output
$explainMode = 1;
} elseif ((int) $this->explainOutput == 3 && is_object($GLOBALS['TT'])) {
// embed the output into the TS admin panel
$explainMode = 2;
} else {
return FALSE;
}
$error = $this->sql_error();
$trail = t3lib_utility_Debug::debugTrail();
$explain_tables = array();
$explain_output = array();
$res = $this->sql_query('EXPLAIN ' . $query, $this->link);
if (is_resource($res)) {
while ($tempRow = $this->sql_fetch_assoc($res)) {
$explain_output[] = $tempRow;
$explain_tables[] = $tempRow['table'];
}
$this->sql_free_result($res);
}
$indices_output = array();
// Notice: Rows are skipped if there is only one result, or if no conditions are set
if ($explain_output[0]['rows'] > 1 || t3lib_div::inList('ALL', $explain_output[0]['type'])) {
// only enable output if it's really useful
$debug = TRUE;
foreach ($explain_tables as $table) {
$tableRes = $this->sql_query('SHOW TABLE STATUS LIKE \'' . $table . '\'');
$isTable = $this->sql_num_rows($tableRes);
if ($isTable) {
$res = $this->sql_query('SHOW INDEX FROM ' . $table, $this->link);
if (is_resource($res)) {
while ($tempRow = $this->sql_fetch_assoc($res)) {
$indices_output[] = $tempRow;
}
$this->sql_free_result($res);
}
}
$this->sql_free_result($tableRes);
}
} else {
$debug = FALSE;
}
if ($debug) {
if ($explainMode) {
$data = array();
$data['query'] = $query;
$data['trail'] = $trail;
$data['row_count'] = $row_count;
if ($error) {
$data['error'] = $error;
}
if (count($explain_output)) {
$data['explain'] = $explain_output;
}
if (count($indices_output)) {
$data['indices'] = $indices_output;
}
if ($explainMode == 1) {
t3lib_utility_Debug::debug($data, 'Tables: ' . $from_table, 'DB SQL EXPLAIN');
} elseif ($explainMode == 2) {
$GLOBALS['TT']->setTSselectQuery($data);
}
}
return TRUE;
}
return FALSE;
}
示例11: debug
function debug($variable = '', $name = '*variable*', $line = '*line*', $file = '*file*', $recursiveDepth = 3, $debugLevel = E_DEBUG)
{
// If you wish to use the debug()-function, and it does not output something, please edit the IP mask in TYPO3_CONF_VARS
if (!t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
return;
}
if (is_object($GLOBALS['error']) && @is_callable(array($GLOBALS['error'], 'debug'))) {
$GLOBALS['error']->debug($variable, $name, $line, $file, $recursiveDepth, $debugLevel);
} else {
$title = $name === '*variable*' ? '' : $name;
$group = $line === '*line*' ? NULL : $line;
t3lib_div::debug($variable, $title, $group);
}
}
示例12: getIndpEnv
/**
* Abstraction method which returns System Environment Variables regardless of server OS, CGI/MODULE version etc. Basically this is SERVER variables for most of them.
* This should be used instead of getEnv() and $_SERVER/ENV_VARS to get reliable values for all situations.
* Usage: 221
*
* @param string Name of the "environment variable"/"server variable" you wish to use. Valid values are SCRIPT_NAME, SCRIPT_FILENAME, REQUEST_URI, PATH_INFO, REMOTE_ADDR, REMOTE_HOST, HTTP_REFERER, HTTP_HOST, HTTP_USER_AGENT, HTTP_ACCEPT_LANGUAGE, QUERY_STRING, TYPO3_DOCUMENT_ROOT, TYPO3_HOST_ONLY, TYPO3_HOST_ONLY, TYPO3_REQUEST_HOST, TYPO3_REQUEST_URL, TYPO3_REQUEST_SCRIPT, TYPO3_REQUEST_DIR, TYPO3_SITE_URL, _ARRAY
* @return string Value based on the input key, independent of server/os environment.
*/
public static function getIndpEnv($getEnvName)
{
/*
Conventions:
output from parse_url():
URL: http://username:password@192.168.1.4:8080/typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/?arg1,arg2,arg3&p1=parameter1&p2[key]=value#link1
[scheme] => 'http'
[user] => 'username'
[pass] => 'password'
[host] => '192.168.1.4'
[port] => '8080'
[path] => '/typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/'
[query] => 'arg1,arg2,arg3&p1=parameter1&p2[key]=value'
[fragment] => 'link1'
Further definition: [path_script] = '/typo3/32/temp/phpcheck/index.php'
[path_dir] = '/typo3/32/temp/phpcheck/'
[path_info] = '/arg1/arg2/arg3/'
[path] = [path_script/path_dir][path_info]
Keys supported:
URI______:
REQUEST_URI = [path]?[query] = /typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/?arg1,arg2,arg3&p1=parameter1&p2[key]=value
HTTP_HOST = [host][:[port]] = 192.168.1.4:8080
SCRIPT_NAME = [path_script]++ = /typo3/32/temp/phpcheck/index.php // NOTICE THAT SCRIPT_NAME will return the php-script name ALSO. [path_script] may not do that (eg. '/somedir/' may result in SCRIPT_NAME '/somedir/index.php')!
PATH_INFO = [path_info] = /arg1/arg2/arg3/
QUERY_STRING = [query] = arg1,arg2,arg3&p1=parameter1&p2[key]=value
HTTP_REFERER = [scheme]://[host][:[port]][path] = http://192.168.1.4:8080/typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/?arg1,arg2,arg3&p1=parameter1&p2[key]=value
(Notice: NO username/password + NO fragment)
CLIENT____:
REMOTE_ADDR = (client IP)
REMOTE_HOST = (client host)
HTTP_USER_AGENT = (client user agent)
HTTP_ACCEPT_LANGUAGE = (client accept language)
SERVER____:
SCRIPT_FILENAME = Absolute filename of script (Differs between windows/unix). On windows 'C:\\blabla\\blabl\\' will be converted to 'C:/blabla/blabl/'
Special extras:
TYPO3_HOST_ONLY = [host] = 192.168.1.4
TYPO3_PORT = [port] = 8080 (blank if 80, taken from host value)
TYPO3_REQUEST_HOST = [scheme]://[host][:[port]]
TYPO3_REQUEST_URL = [scheme]://[host][:[port]][path]?[query] (scheme will by default be "http" until we can detect something different)
TYPO3_REQUEST_SCRIPT = [scheme]://[host][:[port]][path_script]
TYPO3_REQUEST_DIR = [scheme]://[host][:[port]][path_dir]
TYPO3_SITE_URL = [scheme]://[host][:[port]][path_dir] of the TYPO3 website frontend
TYPO3_SITE_SCRIPT = [script / Speaking URL] of the TYPO3 website
TYPO3_DOCUMENT_ROOT = Absolute path of root of documents: TYPO3_DOCUMENT_ROOT.SCRIPT_NAME = SCRIPT_FILENAME (typically)
TYPO3_SSL = Returns TRUE if this session uses SSL/TLS (https)
TYPO3_PROXY = Returns TRUE if this session runs over a well known proxy
Notice: [fragment] is apparently NEVER available to the script!
Testing suggestions:
- Output all the values.
- In the script, make a link to the script it self, maybe add some parameters and click the link a few times so HTTP_REFERER is seen
- ALSO TRY the script from the ROOT of a site (like 'http://www.mytest.com/' and not 'http://www.mytest.com/test/' !!)
*/
# if ($getEnvName=='HTTP_REFERER') return '';
$retVal = '';
switch ((string) $getEnvName) {
case 'SCRIPT_NAME':
$retVal = (php_sapi_name() == 'cgi' || php_sapi_name() == 'cgi-fcgi') && ($_SERVER['ORIG_PATH_INFO'] ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO'] : ($_SERVER['ORIG_SCRIPT_NAME'] ? $_SERVER['ORIG_SCRIPT_NAME'] : $_SERVER['SCRIPT_NAME']);
// add a prefix if TYPO3 is behind a proxy: ext-domain.com => int-server.com/prefix
if (t3lib_div::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
if (t3lib_div::getIndpEnv('TYPO3_SSL') && $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL']) {
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'] . $retVal;
} elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix']) {
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'] . $retVal;
}
}
break;
case 'SCRIPT_FILENAME':
$retVal = str_replace('//', '/', str_replace('\\', '/', (php_sapi_name() == 'cgi' || php_sapi_name() == 'isapi' || php_sapi_name() == 'cgi-fcgi') && ($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) ? $_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED'] : ($_SERVER['ORIG_SCRIPT_FILENAME'] ? $_SERVER['ORIG_SCRIPT_FILENAME'] : $_SERVER['SCRIPT_FILENAME'])));
break;
case 'REQUEST_URI':
// Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar']) {
// This is for URL rewriters that store the original URI in a server variable (eg ISAPI_Rewriter for IIS: HTTP_X_REWRITE_URL)
list($v, $n) = explode('|', $GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar']);
$retVal = $GLOBALS[$v][$n];
} elseif (!$_SERVER['REQUEST_URI']) {
// This is for ISS/CGI which does not have the REQUEST_URI available.
$retVal = '/' . ereg_replace('^/', '', t3lib_div::getIndpEnv('SCRIPT_NAME')) . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '');
} else {
$retVal = $_SERVER['REQUEST_URI'];
}
// add a prefix if TYPO3 is behind a proxy: ext-domain.com => int-server.com/prefix
if (t3lib_div::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
if (t3lib_div::getIndpEnv('TYPO3_SSL') && $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL']) {
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'] . $retVal;
} elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix']) {
$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'] . $retVal;
}
}
break;
//.........这里部分代码省略.........
示例13: main
/**
* The main method of the Plugin
*
* @return Mixed Either returns an error or sends a redirect header
*/
public function main()
{
// Declare globals
global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
// Set the path to phpMyAdmin
$extPath = t3lib_extMgm::extPath('phpmyadmin');
$typo3DocumentRoot = t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT');
// Set class config for module
$this->MCONF = $GLOBALS['MCONF'];
// Get config
$extensionConfiguration = unserialize($TYPO3_CONF_VARS['EXT']['extConf']['phpmyadmin']);
// IP-based Access restrictions
$devIPmask = trim($TYPO3_CONF_VARS['SYS']['devIPmask']);
$remoteAddress = t3lib_div::getIndpEnv('REMOTE_ADDR');
// Check for IP restriction (devIpMask), and die if not allowed
$useDevIpMask = (bool) $extensionConfiguration['useDevIpMask'];
if ($useDevIpMask === TRUE) {
// Abort if devIPmask is wildcarded
if ($devIPmask != '*') {
$message = '<h1>Access Denied</h1>
<p>
This phpMyAdmin-Module was configured with IP-based access restrictions and your
REMOTE_ADDR (' . $remoteAddress . ') is not in TYPO3 devIPmask (' . $devIPmask . ').
</p>';
if (!t3lib_div::cmpIP($remoteAddress, $devIPmask)) {
die($message);
}
}
}
// Check for ip restriction, and die if not allowed
$allowedIps = trim($extensionConfiguration['allowedIps']);
if (!empty($allowedIps)) {
$message = '<h1>Access Denied</h1>
<p>
This phpMyAdmin-Module was configured with IP-based access restrictions and your
REMOTE_ADDR (' . $remoteAddress . ') is not in the list of allowed IPs (' . $allowedIps . ').
</p>';
if (!t3lib_div::cmpIP($remoteAddress, $allowedIps)) {
die($message);
}
}
// Path to install dir
$this->MCONF['PMA_absolute_path'] = $extPath . $this->MCONF['PMA_subdir'];
// PMA uses relative file inclusion, so we need to ensure a proper include_path
@set_include_path($this->MCONF['PMA_absolute_path'] . PATH_SEPARATOR . get_include_path());
// Path to web dir
$this->MCONF['PMA_relative_path'] = t3lib_extMgm::extRelPath('phpmyadmin') . $this->MCONF['PMA_subdir'];
// If phpMyAdmin is configured in the conf.php script, we continue to load it...
if ($this->MCONF['PMA_absolute_path'] && @is_dir($this->MCONF['PMA_absolute_path'])) {
// Need to have cookie visible from parent directory
session_set_cookie_params(0, '/', '', 0);
// Create signon session
$session_name = 'tx_phpmyadmin';
session_name($session_name);
session_start();
// Store the credentials in the session
$_SESSION['PMA_single_signon_user'] = TYPO3_db_username;
$_SESSION['PMA_single_signon_password'] = TYPO3_db_password;
$_SESSION['PMA_single_signon_host'] = TYPO3_db_host;
$_SESSION['PMA_single_signon_only_db'] = TYPO3_db;
// Configure some other parameters
$_SESSION['PMA_extConf'] = $TYPO3_CONF_VARS['EXT']['extConf']['phpmyadmin'];
$_SESSION['PMA_hideOtherDBs'] = $extensionConfiguration['hideOtherDBs'];
// Get signon uri for redirect
$path_ext = substr($extPath, strlen($typo3DocumentRoot), strlen($extPath));
$path_ext = substr($path_ext, 0, 1) != '/' ? '/' . $path_ext : $path_ext;
$path_pma = $path_ext . $this->MCONF['PMA_subdir'];
$_SESSION['PMA_SignonURL'] = $path_pma . 'index.php';
// Try to get the TYPO3 backend uri even if it's installed in a subdirectory
// Compile logout path and add a slash if the returned string does not start with
$path_typo3 = substr(PATH_typo3, strlen($typo3DocumentRoot), strlen(PATH_typo3));
$path_typo3 = substr($path_typo3, 0, 1) != '/' ? '/' . $path_typo3 : $path_typo3;
$_SESSION['PMA_LogoutURL'] = $path_typo3 . 'logout.php';
// Prepend document root if uploadDir does not start with a slash "/"
$extensionConfiguration['uploadDir'] = trim($extensionConfiguration['uploadDir']);
if (strpos($extensionConfiguration['uploadDir'], '/') !== 0) {
$_SESSION['PMA_uploadDir'] = $typo3DocumentRoot . '/' . $extensionConfiguration['uploadDir'];
} else {
$_SESSION['PMA_uploadDir'] = $extensionConfiguration['uploadDir'];
}
$_SESSION['PMA_typo_db'] = TYPO3_db;
// Check if Ajax is enabled by config - @see http://forge.typo3.org/issues/51384
$ajaxEnable = (bool) $extensionConfiguration['ajaxEnable'];
if ($ajaxEnable === TRUE) {
$_SESSION['AjaxEnable'] = TRUE;
} else {
$_SESSION['AjaxEnable'] = FALSE;
}
$id = session_id();
// Force to set the cookie according to issue #8884
// http://bugs.typo3.org/view.php?id=8884#c23323
setcookie($session_name, $id, 0, '/', '');
// Close that session
session_write_close();
// Mapping language keys for phpMyAdmin
//.........这里部分代码省略.........
示例14: init
/**
* Standard init function
* Initializes :
* - the reference to the parent Extension ( stored in $this->_oParent )
* - the XML conf
* - the internal collection of Validators
* - the internal collection of DataHandlers
* - the internal collection of Renderers
* - the internal collection of Renderlets
* - the Renderer as configured in the XML conf in the /formidable/control/renderer/ section
* - the DataHandler as configured in the XML conf in the /formidable/control/datahandler/ section
*
* // CURRENT SERVER EVENT CHECKPOINTS ( means when to process the even; ex: <onclick runat="server" when="after-compilation" /> )
* // DEFAULT IS *after-init*
* //
* // start
* // before-compilation
* // before-compilation
* // after-compilation
* // before-init
* // before-init-renderer
* // after-init-renderer
* // before-init-renderlets
* // after-init-renderlets
* // before-init-datahandler
* // after-init-datahandler
* // after-init
* // before-render
* // after-render
* // end
*
* @param object Parent extension using FORMidable
* @param mixed Absolute path to the XML configuration file
* @param [type] $iForcedEntryId: ...
* @return void
*/
function init(&$oParent, $mXml, $iForcedEntryId = FALSE)
{
$this->garbageCollector();
$this->sessionStart();
$this->start_tstamp = t3lib_div::milliseconds();
$this->makeHtmlParser();
$this->_makeJsonObj();
if ($this->__getEnvExecMode() !== "FE") {
// virtualizing FE for BE and eID (ajax) modes
$this->__virtualizeFE();
}
/***** BASE INIT *****
*
*/
$this->sExtPath = PATH_formidable;
$this->sExtRelPath = t3lib_extMgm::siteRelPath("ameos_formidable");
$this->sExtWebPath = t3lib_div::getIndpEnv("TYPO3_SITE_URL") . t3lib_extMgm::siteRelPath("ameos_formidable");
$this->sApiVersion = $GLOBALS["TYPO3_CONF_VARS"]["EXTCONF"]["ameos_formidable"]["ext_emconf.php"]["version"];
$this->sApiVersionInt = t3lib_div::int_from_ver($GLOBALS["TYPO3_CONF_VARS"]["EXTCONF"]["ameos_formidable"]["ext_emconf.php"]["version"]);
$this->conf =& $GLOBALS["TSFE"]->config["config"]["tx_ameosformidable."];
$this->_oParent =& $oParent;
$this->oParent =& $oParent;
$this->aTempDebug = array();
$this->_loadDeclaredDataSources();
$this->_loadDeclaredValidators();
$this->_loadDeclaredDataHandlers();
$this->_loadDeclaredRenderers();
$this->_loadDeclaredRenderlets();
$this->_loadDeclaredActionlets();
/***** XML INIT *****
*
*/
if ($this->bInitFromTs === FALSE) {
/** Cyrille Berliat : Patch to handle direct XML arrays when passed to init */
if (is_array($mXml)) {
$this->_aConf = $mXml;
} else {
$this->_xmlPath = $this->toServerPath($mXml);
$this->_loadXmlConf();
}
} else {
$this->_aConf = $mXml;
$this->_aConf = $this->refineTS($this->_aConf);
}
/***** DEBUG INIT *****
*
* After this point raw xml data is available ( means before precompilation )
* So it is now possible to get some basic config from the xml
*
*/
/* determine if meta+control+elements or head+body */
if ($this->_navConf("/head") !== FALSE) {
$this->sXpathToMeta = "/head/";
$this->sXpathToControl = "/head/";
}
if ($this->_navConf("/body") !== FALSE) {
$this->sXpathToElements = "/body/";
}
if (t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
$this->bDebugIP = TRUE;
}
$this->oJs = t3lib_div::makeInstance("formidable_jslayer");
$this->oJs->_init($this);
/***** INIT FORM SIGNATURE *****
//.........这里部分代码省略.........
示例15: checkBackendAccessSettingsFromInitPhp
/**
* Implementing the access checks that the typo3/init.php script does before a user is ever logged in.
* Used in the frontend.
*
* @return boolean Returns true if access is OK
* @see typo3/init.php, t3lib_beuserauth::backendCheckLogin()
*/
public function checkBackendAccessSettingsFromInitPhp()
{
global $TYPO3_CONF_VARS;
// **********************
// Check Hardcoded lock on BE:
// **********************
if ($TYPO3_CONF_VARS['BE']['adminOnly'] < 0) {
return FALSE;
}
// **********************
// Check IP
// **********************
if (trim($TYPO3_CONF_VARS['BE']['IPmaskList'])) {
if (!t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $TYPO3_CONF_VARS['BE']['IPmaskList'])) {
return FALSE;
}
}
// **********************
// Check SSL (https)
// **********************
if (intval($TYPO3_CONF_VARS['BE']['lockSSL']) && $TYPO3_CONF_VARS['BE']['lockSSL'] != 3) {
if (!t3lib_div::getIndpEnv('TYPO3_SSL')) {
return FALSE;
}
}
// Finally a check from t3lib_beuserauth::backendCheckLogin()
if ($this->isUserAllowedToLogin()) {
return TRUE;
} else {
return FALSE;
}
}