The original code used the vbdate()-function in a way that created bogus times, which actually is a design flaw in the function itself. However, since the Unix timestamp is independent from the default timezone settings i see no point in the original logic anyway, unless you alter the code to take advantage of vbdate's built in hourdiff mechanism, but since that mechanism uses the current users timezone you could get pretty unpredictable times.
I have altered the code so that a current UTC time is first created and then modified with the forums' timezone setttings to create a local forum time. In short, the product works fine now with the following changes.
Replace:
PHP Code:
$vsaabgreeter_servertime = mktime('0'.date('H', TIMENOW), '0'.date('i', TIMENOW), '0'.date('s', TIMENOW), '0'.date('m', TIMENOW), '0'.date('d', TIMENOW), '0'.date('Y', TIMENOW), -1);
$vsaabgreeter_forumtime = mktime('0'.vbdate('H', TIMENOW), '0'.vbdate('i', TIMENOW), '0'.vbdate('s', TIMENOW), '0'.vbdate('m', TIMENOW), '0'.vbdate('d', TIMENOW), '0'.vbdate('Y', TIMENOW), -1);
$vsaabgreeter_propertime = TIMENOW;
if ($vsaabgreeter_servertime > $vsaabgreeter_forumtime)
{
$vsaabgreeter_timeoffset = $vsaabgreeter_servertime - $vsaabgreeter_forumtime;
$vsaabgreeter_propertime = TIMENOW - $vsaabgreeter_timeoffset + 10;
}
else
{
$vsaabgreeter_timeoffset = $vsaabgreeter_forumtime - $vsaabgreeter_servertime;
$vsaabgreeter_propertime = TIMENOW + $vsaabgreeter_timeoffset + 10;
}
$vsaabgreeter_execdate = date('m-d', $vsaabgreeter_propertime);
$vsaabgreeter_done = false;
$vsaabgreeter_posted = $vbulletin->db->query_read(" SELECT daydone FROM " . TABLE_PREFIX . "vsa_birthdaythread WHERE daydone = '".$vbulletin->db->escape_string($vsaabgreeter_execdate)."' ");
if ($vbulletin->db->num_rows($vsaabgreeter_posted) > 0)
{
$vsaabgreeter_done = true;
}
$vsaabgreeter_exechour = date('H', $vsaabgreeter_propertime);
[hr]-[/hr]
With:
PHP Code:
$vsaabgreeter_Time = new DateTime("now", new DateTimeZone('UTC'));
$vsaabgreeter_offset = $vbulletin->options[timeoffset];
$vsaabgreeter_Time->modify(($vsaabgreeter_offset >= 0 ? '+' . $vsaabgreeter_offset : $vsaabgreeter_offset) . 'hour');
$vsaabgreeter_execdate = $vsaabgreeter_Time->format('m-d');
$vsaabgreeter_done = false;
$vsaabgreeter_posted = $vbulletin->db->query_read(" SELECT daydone FROM " . TABLE_PREFIX . "vsa_birthdaythread WHERE daydone = '".$vbulletin->db->escape_string($vsaabgreeter_execdate)."' ");
if ($vbulletin->db->num_rows($vsaabgreeter_posted) > 0)
{
$vsaabgreeter_done = true;
}
$vsaabgreeter_exechour = $vsaabgreeter_Time->format('H');
[hr]-[/hr]
Note that the exclude times are still there, which by default means that no threads will be created after 20:00. These times can be altered in the array shown below
PHP Code:
$vsaabgreeter_exchrs = array(20,21,22,23);
[hr]-[/hr]
or removed completely by replacing:
PHP Code:
$vsaabgreeter_exechour = $vsaabgreeter_Time->format('H');
$vsaabgreeter_exchrs = array(20,21,22,23);
if (!$vsaabgreeter_done AND !in_array($vsaabgreeter_exechour, $vsaabgreeter_exchrs))
[hr]-[/hr]
with
PHP Code:
if (!$vsaabgreeter_done)
[hr]-[/hr]
Attached is a file with all changes.