BeBot - An Anarchy Online and Age Of Conan chat automaton

Development => Coding and development discussion => Topic started by: Temar on September 07, 2007, 07:36:31 pm

Title: Getting expire time
Post by: Temar on September 07, 2007, 07:36:31 pm
This doesnt seem to be working correctly
Code: [Select]
<?
function check_expire($expire)
{
echo "expire = ".$expire."\n";
if ($expire == '0')
Return ("0");
echo "meeeep\n";
echo "expire2 = ".$expire."\n";
// if (preg_match("/^([0-9]+(:[0-9][0-9]){0,3}) (.*)/$i", $msg, $info))
if (preg_match("/^([0-9]+(:[0-9][0-9]){0,3})$/i", $expire, $info))
{
echo "match\n";
echo "0 - ".$info[0]."\n";
echo "1 - ".$info[1]."\n";
echo "2 - ".$info[2]."\n";
echo "3 - ".$info[3]."\n";
echo "4 - ".$info[4]."\n";
echo "5 - ".$info[5]."\n";
$d = $info[1] * 24 * 60 * 60;
$h = $info[2] * 60 * 60;
$m = $info[3] * 60;
$expire = time() + $d + $h + $m;
$expireex = $expire - time();
echo "expireR = ".$expireex."\n";
Return $expire;
}
if (preg_match("/^([1-9][0-9]*[mhd]?)$/i", $expire, $info))
{
echo "match2\n";
$expirenum = substr($expire, -1);
echo "expirenum = ".$expirenum."\n";
if (stristr($expire, 'm'))
$expire = time() + ($expirenum * 60);
else if (stristr($expire, 'h'))
$expire = time() + ($expirenum * 60 * 60);
else if (stristr($expire, 'd'))
$expire = time() + ($expirenum * 24 * 60 * 60);
$expireex = $expire - time();
echo "expireR = ".$expireex."\n";
Return $expire;
}
else
Return FALSE;
}
console says when going !automsg add 00:01:30 test
Code: [Select]
expire = 00:01:30
meeeep
expire2 = 00:01:30
match
0 - 00:01:30
1 - 00:01:30
2 - :30
3 -
4 -
5 -
expireR = 0
expires now
and with !automsg add 30 test
Code: [Select]
expire = 30
meeeep
expire2 = 30
match
0 - 30
1 - 30
2 -
3 -
4 -
5 -
expireR = 2592000
it expires in 30 days not mins

What i want is for the user to use just MM or HH:MM or DD:HH:MM or nothing if no expire also 0 = no expire, and 2 digits not requires so like H:MM or D:H:MM
:D
SimplePortal 2.3.7 © 2008-2024, SimplePortal