';
echo '
' . JText::_('Page Identification') . "\n";
if ( $gets != null ) {
echo '
';
echo JText::_('The PHP code below may be used to help MetaMod to identify the exact page that you are viewing. For help using this feature, please see this page');
echo '';
/* make an array of items that were present in _GET, but were *not* present
* in the original query string. These will be marked as "optional".
* $_GET often contains extra variables that were not actually passed
* into the application - they are added by various components etc.
* We may or may not want to include these extra ones in the rule.
* Therefore we get a list of the *actual* ones that the user passed
* in, via the apache server string $_SERVER['QUERY_STRING'].
* Any that are not on this list get tagged to tell the operator that
* they may not be required.
*/
$qs_orig = explode( '&', $_SERVER['QUERY_STRING'] );
$qs = array();
foreach ( $qs_orig as $q ) {
$qs[] = ( ( $where = strpos($q, '=') ) === false ) ? $q : substr( $q, 0, $where ) ;
}
$optional = array(); /* this array will hold all the items that were not explicitly requested */
foreach ( array_keys($gets) as $get) {
if ( array_search( $get, $qs ) === false
&& $get != 'option'
&& $get != 'Itemid'
&& $get != 'view'
&& $get != 'id'
) $optional[] = $get;
}
/* add post data, if the page was a post */
if ( $posts != null && count($posts) ) {
$gets = $gets + $posts;
}
/* we always want 'option' to be first in the list, for usability reasons - primarily because
* we can almost guarantee that it's there every single time.
*/
foreach ( array( 'Itemid','category_id','catid','section_id','sectionid','id','page','view','option') as $key ) {
modMetaModHelper::move_to_end_of_array ( $key, $gets );
}
$gets = array_reverse( $gets );
echo '
';
echo "{$operand}if{$color_end} (
\n";
$first = true;
$found_optional = false;
foreach( array_keys($gets) as $get ) {
// get rid of common problems with URLs, namely what happens with "%22" in URLs...
if ( substr( $get, 0, 5 ) == 'quot;' ) continue;
if ( substr( $get, 0, 3 ) == 'lt;' ) continue;
if ( substr( $get, 0, 3 ) == 'gt;' ) continue;
echo '
';
if ( $first ) {
$first = false;
} else {
echo " {$operand}and{$color_end} ";
}
$val = JRequest::getVar($get); // put in a var_export here somewhere?
// $val = str_replace("'", '\\\'', $val); // escape single quotes
$get = str_replace("'", '\\\'', $get); // escape single quotes
if ($get == 'Itemid' or $get == 'option' or $get == 'view' or $get == 'id') {
echo $var . '$' . htmlentities( $get, ENT_QUOTES, 'UTF-8' ) . $color_end;
} else {
echo "JRequest::getVar({$constant}'" . htmlentities( $get, ENT_QUOTES, 'UTF-8' ) . "'{$color_end}) ";
}
echo " $operand==$color_end $constant" . htmlentities( var_export( $val, true ), ENT_QUOTES, 'UTF-8' ) . "$color_end ";
if ( array_search( $get, $optional ) !== false ) {
echo '/*!*/';
$found_optional = true;
}
echo '
';
}
echo " ) {$operand}return{$color_end} XXX;
/* " . JText::_('replace XXX with the module ID or position to display') . ' */';
echo '
';
if ($found_optional) {
echo '
' . JText::_( 'OPTIONAL_RULES') . '';
}
}
echo '
';
}
function timezone_offset($timestamp,$zone) {
$old_tz = getenv('TZ');
putenv("TZ=$zone");
$offset = date("Z",$timestamp);
putenv("TZ=$old_tz");
return $offset;
}
function getUserIP() {
if ( isset( $_SERVER ) ) {
if ( isset( $_SERVER["HTTP_X_FORWARDED_FOR"]) ) {
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
if ( $ip != '' && strtolower($ip) != 'unknown' ) {
$addresses = explode( ',', $ip);
return $addresses[ count($addresses) - 1 ];
}
}
if (isset($_SERVER["HTTP_CLIENT_IP"]) && $_SERVER["HTTP_CLIENT_IP"] != '' )
return $_SERVER["HTTP_CLIENT_IP"];
return $_SERVER["REMOTE_ADDR"];
}
if ( $ip = getenv( 'HTTP_X_FORWARDED_FOR' )) {
if ( strtolower($ip) != 'unknown' ) {
$addresses = explode( ',', $ip);
return $addresses[ count($addresses) - 1 ];
}
}
if ($ip = getenv('HTTP_CLIENT_IP')) {
return $ip;
}
return getenv('REMOTE_ADDR');
}
function convertToUtf8( &$geoip ) {
if ($geoip == null) return;
$attributes = get_object_vars($geoip);
foreach($attributes as $key => $value) $geoip->$key = utf8_encode($value);
}
function moduleIdsAndChanges( &$params, $position ) {
return modMetaModHelper::moduleIds( $params, true, $position );
}
// params: the params of the MetaMod we are expanding
// doChangeCache: whether to do it or not. WIll only be false if called by legacy (1.0.3) MetaMod Pro.
// position: the module position that the MetaMod is in. We give it this so we can filter this out
// of the list of module positions returned (so we don't get an infinite loop of the MetaMod including
// its own position)
function moduleIds( &$params, $doChangeCache = false, $position = null )
{
global $Itemid;
$id = JRequest::getVar('id');
$view = JRequest::getWord('view');
$option = JRequest::getVar('option');
// Retrieve parameters
$php = trim( $params->get( 'php', '' ) );
$logged_in_users = intval( $params->get( 'logged_in_users', '0' ) );
$start_datetime = trim( $params->get( 'start_datetime', '' ) );
$end_datetime = trim( $params->get( 'end_datetime', '' ) );
$timezone = trim( $params->get( 'timezone', 'default' ) );
$use_geoip = intval( $params->get( 'use_geoip', '0' ) );
$module_ids = trim( $params->get( 'module_ids', '0' ) );
$debug = trim( $params->get( 'debug', '0' ) );
if ($debug == 2) { /* advanced debug */
modMetaModHelper::advanced_debug();
}
if ($timezone == "default") {
$config =& JFactory::getConfig();
$offset = $config->getValue('config.offset') * 3600;
} else {
$offset = modMetaModHelper::timezone_offset( time(), $timezone );
}
$now_time = time() + $offset; // can now be compared directly with getData($start_datetime)
// if you were to print this date, it should print in the locale set up in Joomla
if ($debug) {
echo '