The online racing simulator
[php] reading bans.ban
(11 posts, started )
[php] reading bans.ban
Hey i got everything working on the reading bans... but only how do i convert "__int64 Time" to a decent php var?

Greetz Glenn

url: http://lfs.windstyle.eu/bans.php

Time shows up as weird text
Test with this code

<?php
$str
= 'Q2VjaSBlc3QgdW5lIGNoYe5uZSBlbmNvZOll';
echo
base64_decode($str);
?>
Hello,

I'm looking after a script in php to display all current banned on my website. It's possible ?
Quote from rodo37 :Hello,

I'm looking after a script in php to display all current banned on my website. It's possible ?

I got it working.. only the time doesn't show up so you don't know till when he/she is banned..
Quote from windstyle :I got it working.. only the time doesn't show up so you don't know till when he/she is banned..

Hello,

Unix Time is 1 January 1970
64bit Time is 1 January 1601

So, if you have the number of second since 1601 to 1970, you can use the function time();

$time = second_betwen_1601_and_1970
$totaltime = $time + time();

Ban =

$ban_time - $totaltime = Time left in second (I think...)

I'm not an expert in php...
Quote from rodo37 :Hello,

Unix Time is 1 January 1970
64bit Time is 1 January 1601

So, if you have the number of second since 1601 to 1970, you can use the function time();

$time = second_betwen_1601_and_1970
$totaltime = $time + time();

Ban =

$ban_time - $totaltime = Time left in second (I think...)

I'm not an expert in php...

jeah i already found out about that, but it's just that there isn't anyway for me to convert those bytes to a decent value in php i can get alot of numbers out of it.. but none of them makes sence
Quote from windstyle :jeah i already found out about that, but it's just that there isn't anyway for me to convert those bytes to a decent value in php i can get alot of numbers out of it.. but none of them makes sence

Try N2 for the unpack string, for the unsigned 64 bit int. It's a bit of a munge, but it *might* work. It seems to be a bit hit and miss and works on some of my boxes and not on others.
Quote from the_angry_angel :Try N2 for the unpack string, for the unsigned 64 bit int. It's a bit of a munge, but it *might* work. It seems to be a bit hit and miss and works on some of my boxes and not on others.

Doesn't seem to work
http://lfs.windstyle.eu/bans.php:
[1] => Array
(
[username] => MariusMM
[Time] => Array
(
[1] => -1166256534
[2] => -1035679743
)

[BanHours] => 168
)

#9 - filur
This might work, not tested much.


<?php 
// windows systemtimeasfiletime to unix timestamp
// wstft_to_unixtime(byte[8])
function wstft_to_unixtime($bytes)
{
    
$time_hi array_shift// grab first element of array returned by unpack
        
unpack('I'substr($bytes4)) // skip first 4 bytes, unpack last 4 bytes as unsigned integer
    
);
    
    
// $time_hi is now equal to the original 64-bit integer bitshifted 32 steps to the right (/= 2^32)
    // 100ns * (2^32) = 429.4967296 seconds
    // thus $time_hi now consists of the number of 429.4967296-second intervals between 1601 and 1970
    
    // there are 116444736000000000 100-nanosecond intervals between jan1 1601 and jan1 1970
    
    
$time_hi -= 27111902.8// remove 1601-1970 time difference (also shifted 32 steps to the right)
    
$time_hi *= 429.4967296// turn into seconds
    
    
return $time_hi;
}
?>

*Edit: didn't know bcmath was bundled with php, the above would only be useful if you for some reason don't have bcmath.
Hello, you are lucky because i never read this part of forum

The problem is that numbers var are to small on PHP for Time64 and you lost precision if you use it. For this you must use BCMath : http://aspn.activestate.com/ASPN/docs/PHP/ref.bc.html

I attached a PHP file who admin ban ( work perfectly). You can find in this your response windstyle . With this file you can show, modify, delete banned player.

It don't work alone because this source it's only a part of a admin platin for LFS serveur on Unix system (FRH Team server ). But with little modification it can work alone as you want. ( $no_proc is used only to find path of the ban file because it's for our admin platin, you must modify this particularity for you and remove SESSION part )


If you want you can modify and release it as you want on your name but just specify who is the first developper thank's . It's also on GNU Licence like all my sources.

If you want more infos no problem

Bye

Gai-Luron
Attached files
admin_ban.rar - 3 KB - 187 views
Many thanks Gai-Luron, I've customized your script for our server @ www.deathrock.be, of course I leave your name as principal developper

[php] reading bans.ban
(11 posts, started )
FGED GREDG RDFGDR GSFDG