Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Is it possible to connect to SS via PHP?
Goto page 1, 2  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  cccc for PSP Post :: Post First c program  View next topic  
Author Message
Half
Guest


Offline

PostPosted: Fri Mar 31, 2006 9:17 pm    Post subject: Is it possible to connect to SS via PHP? Reply to topic Reply with quote

If so, can anyone give me a quick insight on how it would be done?
Back to top
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Fri Mar 31, 2006 9:22 pm    Post subject: Reply to topic Reply with quote

Possible, maybe. Unlikely, yes.
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
Half
Guest


Offline

PostPosted: Fri Mar 31, 2006 10:19 pm    Post subject: Reply to topic Reply with quote

I don't mean a continuous connection, but like connect then check messages maybe, or get a player count for a zone, or check for available squads/names. This seems feasible to me but I don't know the method of how it would be done.
Back to top
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Mar 31, 2006 11:08 pm    Post subject: Reply to topic Reply with quote

Possible in the same way that the sun could explode tomorrow. It could happen, but it probably wont.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Half
Guest


Offline

PostPosted: Fri Mar 31, 2006 11:21 pm    Post subject: Reply to topic Reply with quote

You guys are amazingly helpful
Back to top
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Fri Mar 31, 2006 11:27 pm    Post subject: Reply to topic Reply with quote

PHP has Sockets which will let you connect with UDP. Just look at the source for some bot cores or on the Wiki for packet information. You can check player counts for a zone just by using the Ping Protocol which will tell you the current ping to a zone and the player count, just like on the main menu of Continuum.

Actually logging into a zone to do messaging is a lot more complex, and you'd need to look through a bot core for how to do that.
Back to top
View users profile Send private message Add User to Ignore List Send email
Half
Guest


Offline

PostPosted: Fri Mar 31, 2006 11:36 pm    Post subject: Reply to topic Reply with quote

t.y. MGB, I'll give it a look
Back to top
BDwinsAlt
Agurus's Posse


Age:33
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Sat Apr 01, 2006 12:28 am    Post subject: Reply to topic Reply with quote

I have seen a Java Applet connect to an ASSS zone before. Maybe Java would be the way for you to go. It works a lot better and is easier for situations like this. TWCore and Hybrid are bot cores written in Java. So we know it will work.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Sat Apr 01, 2006 12:37 am    Post subject: Reply to topic Reply with quote

BDwinsAlt wrote:
TWCore and Hybrid are bot cores written in Java. So we know it will work.

Any language with sockets will work with Subspace. Its not like you are trying to mount a Ford motor in a VW Bug.
Back to top
View users profile Send private message Add User to Ignore List Send email
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sat Apr 01, 2006 6:20 am    Post subject: Reply to topic Reply with quote

I think for the java thing to work, the applet and zone must be on the same server.
_________________
ss news
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Maverick
broken record


Age:39
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Sat Apr 01, 2006 10:07 am    Post subject: Reply to topic Reply with quote

Half wrote:
get a player count for a zone

http://stats.trenchwars.org/index.php?a=display
_________________
Nickname: Maverick (I changed my name!)
TWCore developer | Subspace statistics
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
a dead fish
Newbie


Age:57
Gender:Gender:Male
Joined: Jan 13 2006
Posts: 3
Location: Hernando, FL
Offline

PostPosted: Sat Apr 01, 2006 12:04 pm    Post subject: Reply to topic Reply with quote

Mine GO BOOM wrote:
[..]


Any language with sockets will work with Subspace. Its not like you are trying to mount a Ford motor in a VW Bug.


ehhe, where there's a will, there's a way...

http://britishv8.org/swaps/vwv8ford.htm

icon_eek.gif
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sat Apr 22, 2006 4:44 pm    Post subject: Reply to topic Reply with quote

Mine GO BOOM wrote:
PHP has Sockets which will let you connect with UDP. Just look at the source for some bot cores or on the Wiki for packet information. You can check player counts for a zone just by using the Ping Protocol which will tell you the current ping to a zone and the player count, just like on the main menu of Continuum.


I was bored today...

Code: Show/Hide
<?php

$host = "66.36.241.110";
$port = 5901;

$fp = fsockopen("udp://".$host, $port);

fwrite($fp, pack("V",time()), 4);
$total = fread($fp, 4);
$timestamp = fread($fp, 4);

fclose($fp);

echo array_pop(unpack("V", $total));

?>
Checks the current population of SSCU 17th Parallel

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
_________________
It's a shark! Oh my god! Unbelievable!
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Sat Apr 22, 2006 10:49 pm    Post subject: Reply to topic Reply with quote

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole.... wrote:
Checks the current population of SSCU 17th Parallel

Might as well check the ping while you are at it, as it requires so little code.
Back to top
View users profile Send private message Add User to Ignore List Send email
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Sat Apr 22, 2006 11:40 pm    Post subject: Reply to topic Reply with quote

I think I recall Cypher had something that connected to a bot over PHP for viewing chat or something like that
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sat Apr 22, 2006 11:58 pm    Post subject: Reply to topic Reply with quote

Mine GO BOOM wrote:
[..]


Might as well check the ping while you are at it, as it requires so little code.


Very few people care about the ping between the web server and the zone.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sun Apr 23, 2006 6:00 am    Post subject: Reply to topic Reply with quote

Here's the same code snippet in Ruby.
Just in case someone wants to use Ruby on Rails. icon_wink.gif

Code: Show/Hide
require 'socket'

ip = "66.36.241.110"
port = 5901

socket = UDPSocket.open
socket.connect ip, port
socket.send [Time.now.to_i].pack("V"), 4
data = socket.recvfrom 8

total,timestamp = data.first.unpack("VV")

puts "Population: #{total}\n"


Despite of what Dr. Brain said, could someone add the ping code?
It's like I don't to see the wood for the trees.

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Sun Apr 23, 2006 11:33 am    Post subject: Reply to topic Reply with quote

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole.... wrote:
Despite of what Dr. Brain said, could someone add the ping code?

First problem is that time() only returns seconds. Need to create a 32bit timestamp with milliseconds (or if you want, could even go higher as microtime on unix gets pretty damn small). I know this works on unix, didn't test on windows. The bitwise AND keeps the number unsigned at least, but doesn't account for roll overs. So a better get_ms() function could be created.
Code: Show/Hide
<?php

function get_ms()
{
   list($msec, $sec) = explode(" ", microtime());
   return round(($sec + $msec) * 1000) & 0x7FFFFFFF;
}

$host = "66.36.241.110";
$port = 5901;

$fp = fsockopen("udp://".$host, $port);

fwrite($fp, pack("V", get_ms()), 4);
$total = fread($fp, 4);
$timestamp = fread($fp, 4);

fclose($fp);

$population = array_pop(unpack("V", $total));
$ping = get_ms() - array_pop(unpack("V", $timestamp));

echo "Population: " . $population . "<br>\n";
echo "Ping: " . $ping .  " ms<br>\n";

?>
Back to top
View users profile Send private message Add User to Ignore List Send email
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sun Apr 23, 2006 11:54 am    Post subject: Reply to topic Reply with quote

Using the timestamp that the server sent back has no real advantage in such a small script, hasn't it?

The only advantage I see is when you ping multiple zones at once?

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Sun Apr 23, 2006 1:35 pm    Post subject: Reply to topic Reply with quote

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole.... wrote:
Using the timestamp that the server sent back has no real advantage in such a small script, hasn't it?

The only advantage I see is when you ping multiple zones at once?

Correct. The above code would work fine if you set the socket to non-blocking and just have a timeout wait of a second or two. Technically, you should remember the timestamp you send out, so you know that the packet you got back was the last one you sent and not a previous one.
Back to top
View users profile Send private message Add User to Ignore List Send email
Donkano
Server Help Squatter


Gender:Gender:Male
Joined: Jul 02 2003
Posts: 763
Offline

PostPosted: Sun Apr 23, 2006 1:39 pm    Post subject: Reply to topic Reply with quote

MGB, that script does work on Windows. Tested it on a Windows 2003 Server computer.

I tried targetting it on SSDV Into the moat and STFU Anything Goes and both timed out. Do you know why?
Back to top
View users profile Send private message Add User to Ignore List
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sun Apr 23, 2006 2:18 pm    Post subject: Reply to topic Reply with quote

Donkano wrote:
MGB, that script does work on Windows. Tested it on a Windows 2003 Server computer.

I tried targetting it on SSDV Into the moat and STFU Anything Goes and both timed out. Do you know why?


Works fine on WinXP.
Make sure you have the port increased by one.

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
Back to top
View users profile Send private message Add User to Ignore List
Donkano
Server Help Squatter


Gender:Gender:Male
Joined: Jul 02 2003
Posts: 763
Offline

PostPosted: Sun Apr 23, 2006 3:23 pm    Post subject: Reply to topic Reply with quote

Here is something that I would like to see done:

PHP does the following:
Connects to a directory server.
Finds all zones starting with with a specific string (to target networks/groups)
Lists all those zones with their IP/Port, ping and population

Would look something like this for output:
SSDV Into the moat
- IP: 69.93.119.226
- Port: 3000
- Population: 4
- Ping: 90ms


If anyone has the time for this, I would appreciate it. I would like to put it on the SSDV website so that it can display zone information.
Back to top
View users profile Send private message Add User to Ignore List
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Mon Apr 24, 2006 3:16 am    Post subject: Reply to topic Reply with quote

Donkano wrote:
Here is something that I would like to see done:

PHP does the following:
Connects to a directory server.
Finds all zones starting with with a specific string (to target networks/groups)
Lists all those zones with their IP/Port, ping and population

Would look something like this for output:
SSDV Into the moat
- IP: 69.93.119.226
- Port: 3000
- Population: 4
- Ping: 90ms


If anyone has the time for this, I would appreciate it. I would like to put it on the SSDV website so that it can display zone information.


I could try... I have no experience with sockets, packets and protocols though (except what's been posted in this thread)

But this should be a good variety to all the programming tasks at university.

Is http://wiki.minegoboom.com/index.php/Directory_Client_Protocol the only information available about the protocol?

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole....
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Mon Apr 24, 2006 3:23 am    Post subject: Reply to topic Reply with quote

Donkano wrote:
Here is something that I would like to see done:

PHP does the following:
Connects to a directory server.
I don't think that's a good idea. There's only one dirserv and a webpage that talks to it could easily be abused.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Misc User Apps All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 666 page(s) served in previous 5 minutes.

phpBB Created this page in 0.497018 seconds : 50 queries executed (90.0%): GZIP compression disabled