stardotstar
05-22-2009, 02:14 AM
There is a bug in the latest openx
https://developer.openx.org/jira/browse/OX-3620;jsessionid=D8D11F34B901099E32A6DCBC1D2A2617?p age=com.atlassian.jira.plugin.system.issuetabpanel s%3Aall-tabpanel
Which is:
3. The alocal.php forces the PHP timezone to date_timezone_set('UTC'), always!
4. My site which has a PHP timezone 'Europe/Tallinn' defined now goes wild everytime date() related functions are used after any local OpenX tag. SQL queries which use the current date are obviously wrong then and so on.
5. Changing the [timezone]:location= config option has no effect. (Cause the PHP code does not use it at all)
This worked in 2.4.5 and is a regression. I understand that the new statistic timestamps are to be saved in UTC however this should not break existing timezones for websites when using the local mode tag.
A solution would be to restore a previously set timezone after the view_local has been called."
I need to know how to reset the board timezone in the plugin for phpadsnew integration (currently only supported up to vb3.5 - I have it working on 3.8.2 except for this timezone issue.
Can a dev point me to the best way to put the timezone back after the plugin has done its thing in getting the ad?
Here is the plugin:
if (!function_exists('view_ad'))
{
/**
* Calls view_raw function from phpAdsNew either locally or via xml-rpc to get HTML advertisement code, see phpAdsNew for infos.
*
* @param string Zone name (zone:x) or keywords (keyword1|keyword2|...)
* @param integer Client-ID
* @param string Target
* @param string Source
* @param integer Withtext
*
* @return string
*/
function view_ad($what, $clientid = 0, $target = '', $source = '', $withtext = 0)
{
global $vbulletin;
static $panpath;
if (!$panpath)
{
trim($vbulletin->options['panpath']);
$panpath = @parse_url($vbulletin->options['panpath']);
}
// Calculate an identifier for the requested ad - this could be used to cache banners retrieved via xmlrpc in future versions
$adid = sprintf('%u', crc32($what . $clientid . $target . $source . $withtext));
if ($vbulletion->options['addtemplatename'] or $vbulletin->config['Misc']['debug'])
{
// Be verbose
$adcomment = 'id="' . $adid . '" what="' . htmlspecialchars($what) . '" clientid="' . htmlspecialchars($clientid)
. '" target="' . htmlspecialchars($target) . '" source="' . htmlspecialchars($source)
. '" withtext="' . htmlspecialchars($withtext) . '"';
}
else
{
$adcomment = $adid;
}
if ($vbulletin->options['panpath'] == '')
{
// Path to phpAdsNew is empty - disable ads
return "<!-- ad {$adcomment} / -->";
}
elseif (strtolower($panpath['scheme']) == 'http')
{
// get banner from phpAdsNew via xml-rpc
/*
// ATTN:
// In phpAdsNew 2.0.6 (and maybe earlier versions) is a tiny bug which prevents xml-rpc from working cleanly.
//
// Patch:
// --- phpAdsNew/misc/samples/xmlrpc/php/lib-xmlrpc.inc.php.orig Tue Aug 16 10:51:26 2005
// +++ phpAdsNew/misc/samples/xmlrpc/php/lib-xmlrpc.inc.php Thu Oct 27 17:12:26 2005
// @@ -76,6 +76,7 @@
// global $xmlrpcStruct;
//
// global $xmlrpcTypes;
// + global $xmlrpc_valid_parents;
// global $xmlEntities;
// global $xmlrpcerr;
// global $xmlrpcstr;
//
// See https://sourceforge.net/tracker/?func=detail&atid=111386&aid=1339623&group_id=11386 for details.
*/
global $xmlrpcbanner, $phpAds_remoteInfo;
require_once(DIR . '/includes/lib-xmlrpc-class.inc.php'); // see misc/samples/xmlrpc/php/ directory of your phpAdsNew installation
if (!$xmlrpcbanner)
{
$xmlrpcbanner = new phpAds_XmlRpc($panpath['host'], $panpath['path'], (intval($panpath['port']) > 0 ? $panpath['port'] : 80));
}
$ad = $xmlrpcbanner->view_raw($what, $clientid, $target, $source, $withtext);
return "<!-- BEGIN ad {$adcomment} -->{$ad['html']}<!-- END ad {$adid} -->";
}
else
{
// get banner via direct invocation of phpAdsNew
// this is basically taken from the invocationcode generated by phpAdsNew - it does its own checks to prevent multiple inclusion
global $phpAds_context;
if (@require($vbulletin->options['panpath'] . (strstr($vbulletin->options['panpath'] , '/phpadsnew.inc.php') ? '' : '/phpadsnew.inc.php' )))
{
if (!isset($phpAds_context))
{
$phpAds_context = array();
}
$ad = view_raw($what, $clientid, $target, $source, $withtext, $phpAds_context);
if ($vbulletin->options['panbandupes'])
{
// Remember bannerid to prevent showing banner multiple times on same page
$phpAds_context[] = array('!=' => 'bannerid:'.$ad['bannerid']);
}
return "<!-- BEGIN ad {$adcomment} -->{$ad['html']}<!-- END ad {$adid} -->";
putenv("TZ=Australia/Sydney");
}
}
}
}
You will see my attempt to "putenv" back but it works not.
Once I have this worked out I will post step by steps for 3.8.2 in the product thread!
Appreciated,
Will
https://developer.openx.org/jira/browse/OX-3620;jsessionid=D8D11F34B901099E32A6DCBC1D2A2617?p age=com.atlassian.jira.plugin.system.issuetabpanel s%3Aall-tabpanel
Which is:
3. The alocal.php forces the PHP timezone to date_timezone_set('UTC'), always!
4. My site which has a PHP timezone 'Europe/Tallinn' defined now goes wild everytime date() related functions are used after any local OpenX tag. SQL queries which use the current date are obviously wrong then and so on.
5. Changing the [timezone]:location= config option has no effect. (Cause the PHP code does not use it at all)
This worked in 2.4.5 and is a regression. I understand that the new statistic timestamps are to be saved in UTC however this should not break existing timezones for websites when using the local mode tag.
A solution would be to restore a previously set timezone after the view_local has been called."
I need to know how to reset the board timezone in the plugin for phpadsnew integration (currently only supported up to vb3.5 - I have it working on 3.8.2 except for this timezone issue.
Can a dev point me to the best way to put the timezone back after the plugin has done its thing in getting the ad?
Here is the plugin:
if (!function_exists('view_ad'))
{
/**
* Calls view_raw function from phpAdsNew either locally or via xml-rpc to get HTML advertisement code, see phpAdsNew for infos.
*
* @param string Zone name (zone:x) or keywords (keyword1|keyword2|...)
* @param integer Client-ID
* @param string Target
* @param string Source
* @param integer Withtext
*
* @return string
*/
function view_ad($what, $clientid = 0, $target = '', $source = '', $withtext = 0)
{
global $vbulletin;
static $panpath;
if (!$panpath)
{
trim($vbulletin->options['panpath']);
$panpath = @parse_url($vbulletin->options['panpath']);
}
// Calculate an identifier for the requested ad - this could be used to cache banners retrieved via xmlrpc in future versions
$adid = sprintf('%u', crc32($what . $clientid . $target . $source . $withtext));
if ($vbulletion->options['addtemplatename'] or $vbulletin->config['Misc']['debug'])
{
// Be verbose
$adcomment = 'id="' . $adid . '" what="' . htmlspecialchars($what) . '" clientid="' . htmlspecialchars($clientid)
. '" target="' . htmlspecialchars($target) . '" source="' . htmlspecialchars($source)
. '" withtext="' . htmlspecialchars($withtext) . '"';
}
else
{
$adcomment = $adid;
}
if ($vbulletin->options['panpath'] == '')
{
// Path to phpAdsNew is empty - disable ads
return "<!-- ad {$adcomment} / -->";
}
elseif (strtolower($panpath['scheme']) == 'http')
{
// get banner from phpAdsNew via xml-rpc
/*
// ATTN:
// In phpAdsNew 2.0.6 (and maybe earlier versions) is a tiny bug which prevents xml-rpc from working cleanly.
//
// Patch:
// --- phpAdsNew/misc/samples/xmlrpc/php/lib-xmlrpc.inc.php.orig Tue Aug 16 10:51:26 2005
// +++ phpAdsNew/misc/samples/xmlrpc/php/lib-xmlrpc.inc.php Thu Oct 27 17:12:26 2005
// @@ -76,6 +76,7 @@
// global $xmlrpcStruct;
//
// global $xmlrpcTypes;
// + global $xmlrpc_valid_parents;
// global $xmlEntities;
// global $xmlrpcerr;
// global $xmlrpcstr;
//
// See https://sourceforge.net/tracker/?func=detail&atid=111386&aid=1339623&group_id=11386 for details.
*/
global $xmlrpcbanner, $phpAds_remoteInfo;
require_once(DIR . '/includes/lib-xmlrpc-class.inc.php'); // see misc/samples/xmlrpc/php/ directory of your phpAdsNew installation
if (!$xmlrpcbanner)
{
$xmlrpcbanner = new phpAds_XmlRpc($panpath['host'], $panpath['path'], (intval($panpath['port']) > 0 ? $panpath['port'] : 80));
}
$ad = $xmlrpcbanner->view_raw($what, $clientid, $target, $source, $withtext);
return "<!-- BEGIN ad {$adcomment} -->{$ad['html']}<!-- END ad {$adid} -->";
}
else
{
// get banner via direct invocation of phpAdsNew
// this is basically taken from the invocationcode generated by phpAdsNew - it does its own checks to prevent multiple inclusion
global $phpAds_context;
if (@require($vbulletin->options['panpath'] . (strstr($vbulletin->options['panpath'] , '/phpadsnew.inc.php') ? '' : '/phpadsnew.inc.php' )))
{
if (!isset($phpAds_context))
{
$phpAds_context = array();
}
$ad = view_raw($what, $clientid, $target, $source, $withtext, $phpAds_context);
if ($vbulletin->options['panbandupes'])
{
// Remember bannerid to prevent showing banner multiple times on same page
$phpAds_context[] = array('!=' => 'bannerid:'.$ad['bannerid']);
}
return "<!-- BEGIN ad {$adcomment} -->{$ad['html']}<!-- END ad {$adid} -->";
putenv("TZ=Australia/Sydney");
}
}
}
}
You will see my attempt to "putenv" back but it works not.
Once I have this worked out I will post step by steps for 3.8.2 in the product thread!
Appreciated,
Will