[PHP] Clientless Silkroad Security + ServerStats

07/13/2011 14:12 inv123#46
Quote:
Originally Posted by S3cret View Post
Hi there it's me again.

I wanna update the serverstats all 10 seconds in my db. I wanted to use a cronjob but my server does only allow them in a 1 minute interval. So I thought I could make the updatescript update the stats 5 times (all 10 secs) and close then. I wanted to make use of a for loop and timers but this doesn't work:
Heres the code (is there no way in this board to use an expander?)
PHP Code:
<?php
    $_REQUEST
["host"] = "gwgt1.joymax.com";
    
$_REQUEST["port"] = 15779;
    
$_REQUEST["locale"] = 18;
    
$_REQUEST["version"] = 314;
    
$_REQUEST["timeout"] = 5;

    
$db mysqli_connect(blabla);

    if (
mysqli_connect_errno() == 0) { //DB-Connection successful

        
for ($i 1$i <= 5$i++) {
            
$Timer microtime(TRUE);

            
// Execute the server stats page and store the results. This code doesn't change.
            
ob_start();
            include( 
"ServerStats.php" );
            
$result ob_get_contents();
            
ob_end_clean();



            
//code that updates the db, definitely works!



            //let 10 seconds pass
            
while (microtime(TRUE) - $Timer <= 10000) {
                
usleep(500000); //0.5 secs sleeping
            
}

        }

    }

?>
WAt the moment when i run this script the page is loading for years and the stats are not updated a single time.

Any idea what could be the issue? I'm really not a pro in php^^

Regards
Try this one if you cant or not able to set CRON jobs.
But there are also some web based cron job websites, but they are not realy helpfull
[Only registered and activated users can see links. Click Here To Register...]
07/13/2011 14:13 S3cret#47
Quote:
Originally Posted by inv123 View Post
Try this one if you cant or not able to set CRON jobs.
But there are also some web based cron job websites, but they are not realy helpfull
[Only registered and activated users can see links. Click Here To Register...]
Alright, I will test this out. Thank you.
07/13/2011 14:16 lesderid#48
Quote:
Originally Posted by S3cret View Post
Wow ur so freaking funny. May I expect a serious answer from you or are u just searching for attention?
I know I am.

And I don't need attention, I have enough already.
Just a bit bored atm.

Oh and no, you may not expect a serious answer. :D
07/15/2011 12:32 S3cret#49
Hi it's me again.
For testing I always used a server of a friend and it always worked.

Now when I wanted to put everything to my server I got errors, sometimes just 1, sometimes more...

This error comes more often.
Code:
Array ( [0] => [1] => Warning: mcrypt_ecb() [function.mcrypt-ecb]: Attempt to use an empty IV, which is NOT recommend in /var/www/xxx/html/silkroad/serverstats/SilkroadSecurity.php on line 174 [2] => Error [3] => Could not receive data. )
The other one doesn't want to display right now. It's longer containing all mcrypt lines and also the 'Could not receive data.' error at the end.

This is 100% my server but what makes it block?
07/15/2011 12:47 theoneofgod#50
@S3cret
Your server is lacking certain functionality that is required.
07/15/2011 13:00 S3cret#51
Before I got another error and the operator of my webspace had to move it to a different server. This is done and I just checked the phpinfo again.
BCMath support: enabled
Sockets Support: enabled
mcrypt support: enabled (but only version 2.5.7, not 2.5.8, can this be the reason?)
07/15/2011 16:21 pushedx#52
Quote:
Originally Posted by S3cret View Post
Before I got another error and the operator of my webspace had to move it to a different server. This is done and I just checked the phpinfo again.
BCMath support: enabled
Sockets Support: enabled
mcrypt support: enabled (but only version 2.5.7, not 2.5.8, can this be the reason?)
Doubtful, as long as you have a modern MCRYPT it should be ok. Use [Only registered and activated users can see links. Click Here To Register...] to get rid of the MCrypt warnings.

It's possible the way a web server is setup it might have all the components needed, but actually performs differently. There's too much going on to really say why it works on some hosts and not on others really. For example, I tested on one free host and it worked fine always but others have tried getting the same from them and it didn't.

It's possible it's something in the code, but there's not much to change really with the socket code. There are a very limited number of ways to use the socket_write and socket_recv functions.

Try this:

Replace lines 110 - 116
Code:
$response = socket_recv_buffer( $socket, 2 );
if( $response == false )
{
	@socket_close( $socket );
	echo( "Error" . PHP_EOL . "<br />" . PHP_EOL . "Could not receive data.");
return;
}
with this:
Code:
$r = false;
for($x = 0; $x < 5; ++$x)
{
	$response = socket_recv_buffer( $socket, 2 );
	if( $response === false )
	{
		sleep(1);
	}
	else
	{
		$r = true;
		break;
	}
}
if( $r == false )
{
	@socket_close( $socket );
	echo( "Error" . PHP_EOL . "<br />" . PHP_EOL . "Could not receive data." );
	return;
}
That should give it up to 5 seconds to receive data that select said was there. I'm not sure if it'll actually do anything, but I'll try to mess with some possible changes later when I get back around to PHP stuff.
07/15/2011 17:27 S3cret#53
Thanks for your effort.
Your codechange didn't make it work so far.

I'm thinking about contacting my operator again...
08/18/2011 20:58 Evil_Warlock#54
Can anyone tell me if i can use this with bplaced.net? Or am I wasting my time trying to get it to work? Is the standart freeware bplaced.net server capable of running this?
08/18/2011 21:29 pushedx#55
Quote:
Originally Posted by Evil_Warlock View Post
Can anyone tell me if i can use this with bplaced.net? Or am I wasting my time trying to get it to work? Is the standart freeware bplaced.net server capable of running this?
I'll give it a try later today after my site is activated there. I made an account but the site doesn't load yet.
08/19/2011 15:46 Evil_Warlock#56
Quote:
Originally Posted by pushedx View Post
I'll give it a try later today after my site is activated there. I made an account but the site doesn't load yet.
Thanks you so much for your help! =)
08/19/2011 20:41 pushedx#57
To anyone that couldn't run the first version, try this second version. The socket functions have been changed to the file socket functions. You still need sockets enabled on the server, but not having regular socket access won't matter as long as file sockets are allowed.

That host, bplaced, allows file sockets, fsockopen, but not regular sockets, socket_connect. I changed a little of the socket code to work with the new style and I think it works as it should: [Only registered and activated users can see links. Click Here To Register...].

However, as with the previous version, this type of code on PHP servers like this isn't really stable so some problems may arise. bplaced only allows a script execution time of 12s, so you won't be able to use this on a lot of servers that have longer delays because the script takes longer to execute. Most sites default to 30s I think, so you might need to try another host if that is a problem.
10/02/2011 01:06 EuSouHunteR#58
Array ( [0] => Error [1] => The version packet was rejected because the version is too new. [2] =>
[3] => )
10/02/2011 23:48 inv123#59
Quote:
Originally Posted by EuSouHunteR View Post
Array ( [0] => Error [1] => The version packet was rejected because the version is too new. [2] =>
[3] => )
The error says itselfs, you have to change the version variable in index.php
10/03/2011 16:56 * White *#60
Code:
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in c:\appserv\www\SilkroadSecurity.php on line 7
Trying on localhost with appserver and get this.

on line 7 i have
Code:
public $m_initial_blowfish_key = 0;