• Welcome to Valhalla Legends Archive.
 

PHP bot (I know this has been talked about before)

Started by huperphuff, January 26, 2005, 10:49 PM

Previous topic - Next topic

AC_Drkan

#16
Tried having it auto refresh the page but after 5 minutes of nobody saying anything the script just dies. and stop executing. It dosen't ever fully finish running the script.

EDIT:
Yeah! not a double Posting!

Anybody interested in seeing the code?

And YES THERS IS A WAY TO USE BNLS!
"The Arguments of Today Result in the Wars of Tomorrow" - Quote By Muah.
<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

<kow`> "There are 10 types of people in the world... those who understand binary and those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID


<[TN]FBMachine> i got kicked out of barnes and noble once for moving all the bibles into the fiction section

God i love Bash.org.

tA-Kane

If I remember correctly, PHP hosts (the webservers) have a script-run timeout. "If the script runs for longer than X seconds, then assume it's in an infinite loop and kill it."

Have you actually gotten around that?
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

AC_Drkan

Quote from: tA-Kane on January 29, 2005, 11:27 PM
If I remember correctly, PHP hosts (the webservers) have a script-run timeout. "If the script runs for longer than X seconds, then assume it's in an infinite loop and kill it."

Have you actually gotten around that?

Well, Somewhat.
At times it works and at other times it dosen't.
Im currently trying to find a way to edit my php.ini settings on the webserver.

Anyone know where they might be?
"The Arguments of Today Result in the Wars of Tomorrow" - Quote By Muah.
<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

<kow`> "There are 10 types of people in the world... those who understand binary and those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID


<[TN]FBMachine> i got kicked out of barnes and noble once for moving all the bibles into the fiction section

God i love Bash.org.

UnderCover

Let me tell you a little secret with PHP

set_time_limit(0) -- Cause PHP to NOT Timeout

When I created a PHP Bot, I used the flush() and ob_flush() during my loops to display text that people sent to channels or text that was sent to me by Bnet (such as NULL)

So therefore if battle.net sends you info every certain period (Null sort of like Ping in IRC) then you shouldn't be timing out.

Also, BG3 what a great program!  I used one of my PHP scripts ot connect to it and Volia I am in a Private channel with PHP!!!!

AC_Drkan

Quote from: UnderCover on February 04, 2005, 05:32 AM
Let me tell you a little secret with PHP

set_time_limit(0) -- Cause PHP to NOT Timeout

When I created a PHP Bot, I used the flush() and ob_flush() during my loops to display text that people sent to channels or text that was sent to me by Bnet (such as NULL)

So therefore if battle.net sends you info every certain period (Null sort of like Ping in IRC) then you shouldn't be timing out.

Also, BG3 what a great program!  I used one of my PHP scripts ot connect to it and Volia I am in a Private channel with PHP!!!!

Knew it.
But Still The Connection Times Out.
I Tried Making It Send Things Toi Battle.net Every x Loops To Prevent a Timeout But Failed.

For All You Source Pirates:

<?php

set_time_limit
(0);

///////////////////////////////////////////////
//  User Variables       //
///////////////////////////////////////////////

$config = array();
$config['Username'] = ""; // The Username you wish to connect with
$config['Password'] = ""; // The Password for the Usernmae you supplied
$config['SiteControl'] = FALSE; // Allow the Bot To control the Site too
$config['HomeChannel'] = "Public Chat 1"; // Home Channel you Want the Bot To Sit in
$config['Server'] = "USEast.Battle.Net"; // Server you want to connect too
$config['Port'] = 6112; // Port to Connect to the Server on
$config['Trigger'] = "!"; // Bot Trigger
$config['Master'] = ""; // Bot's Master
$config['PowerUser1'] = ""; // More Access
$config['PowerUser2'] = ""; // More More Access
$config['PowerUser2'] = ""; // More More More Access
$config['LogFile'] = "BotLog.txt"; // Name of The Log File

///////////////////////////////////////////////
//        Don't Edit Below       //
///////////////////////////////////////////////

$config['WhisperCount'] = 0;
$config['FirstRun'] = TRUE;

$conn = array();


Start();

function 
logBot ($data){
global $config;
$data .= "\n";
if ($fp fopen($config['LogFile'], "ab")) {
       
if ((fwrite($fp$data) === FALSE)) {
           
echo("Could not write to file.<br />");
        
}
    
} else {
        
echo("File could not be opened.<br />");
    
}
}

function 
Start() {
global $conn;
global $config;
$conn['Terminate'] = FALSE;
$conn['ConnectionString'] = chr(3).chr(4);
$conn['Enter'] = chr(10).chr(13);
$conn['Socket'] = fsockopen("tcp://".$config['Server'], $config['Port'], $errno$errstr1);
if (!$conn['Socket']) {
$conn['Terminate'] = TRUE;
logBot("Unable to Connect to ".$config['Server']." On Port ".$config['Port'].".");
} else {
$conn['Terminate'] = FALSE;
logBot("Connected to ".$config['Server']." On Port ".$config['Port'].".");
}

if (!$conn['Terminate']) {
fputs($conn['Socket'], $conn['ConnectionString']);
fputs($conn['Socket'], $config['Username'].$conn['Enter']);
fputs($conn['Socket'], $config['Password'].$conn['Enter']);

while(!$conn['Terminate']) {
set_time_limit(20);

// if(false === ($info = fgets($conn['Socket']))){
//  $conn['Terminate'] = true;
//  logBot("Socket read failed!");
// }
$info fgets($conn['Socket']);
logBot($info);

$refuse strpos($info"refused");
if($refuse){
$conn['Terminate'] = true;
logBot("Connection was refused.");
}
$badlogin strpos($info"Login Incorrect");
if($badlogin){
$conn['Terminate'] = true;
logBot("Invalid login.");
}

if ($config['FirstRun']) {
fputs($conn['Socket'], "/join ".$config['HomeChannel'].$conn['Enter']);
$config['FirstRun'] = FALSE;
}

// BNET PARSING
switch (substr($info09)) {
case "2000 NULL":
if($conn['BNLS'] = fsockopen("bnls.valhallalegends.com"9367$errno$errstr1)) {
$bnls true;
$close fclose($conn['BNLS']);
} else {
$bnls false;
}
if ($bnls true) {
$stat "::..:: Server Stats :.: BNLS: [ÁR UP ÁW] ::..::";
} else {
$stat "::..:: Server Stats :.: BNLS: [ÁY DOWN ÁW] ::..::";
}
fputs($conn['Socket'], $stat.$conn['Enter']);
break;
case "1007 CHAN":
break;
case "1002 JOIN":
break;
case "1003 LEAV":
break;
case "1001 USER":
break;
case "2010 NAME":
break;
case "1010 WHIS":
$parsedstring substr($info10);
$parsedstring str_replace("0000"""$parsedstring);

if (strstr($parsedstring$config['Trigger']."quit")) {
fputs($conn['Socket'], "::..:: Bye Cruel World!".$conn['Enter']);
$conn['Terminate'] = TRUE;
}
break;
case "1018 INFO":
break;
case "1019 ERRO":
break;
case "1023 EMOT":
break;
case "1005 TALK":
break;

default:
break;

}
// END BNET PARSING
}
}
}

Looks similar to some bots ;)
Times out after like 10 seconds.

We Should make a Team of People to Develop a PHP Battle.net Bot.

And Yes, 100% Written By ME
"The Arguments of Today Result in the Wars of Tomorrow" - Quote By Muah.
<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

<kow`> "There are 10 types of people in the world... those who understand binary and those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID


<[TN]FBMachine> i got kicked out of barnes and noble once for moving all the bibles into the fiction section

God i love Bash.org.

tA-Kane

And Dude, You Don't Need To Capitalize Every Word. It Makes You Look Really Stupid.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

AC_Drkan

Quote from: tA-Kane on February 07, 2005, 06:47 PM
And Dude, You Don't Need To Capitalize Every Word. It Makes You Look Really Stupid.

Force of Habit. lol......

but in all seriousness, how does that code look? Are there any flaws as to why it won't run forever?!?!
"The Arguments of Today Result in the Wars of Tomorrow" - Quote By Muah.
<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

<kow`> "There are 10 types of people in the world... those who understand binary and those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID


<[TN]FBMachine> i got kicked out of barnes and noble once for moving all the bibles into the fiction section

God i love Bash.org.

l)ragon

if your going to just ignore chan, join, leave, etc. why not just comment them out or remove them completely.
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

UnderCover

Quote

fsockopen("bnls.valhallalegends.com", 9367, $errno, $errstr, 1))


Just wondering what are you trying to connect to? :)

One reason is it's timing out is because your connecting to BNLS and the BNLS server is waiting for you to send certain information to it.

When I was trying to connect etc I couldn't figfure out how to adjust my strings into binarary code, so I just said screw it and would connect to BNET to a public channel...

Anyway heres what you need to do to connect to BNET and hopefully not time out:

change fsockopen("useast.battle.net", 6112, $errno, $errstr, 1)) to fsockopen("bnls.valhallalegends.com", 9367, $errno, $errstr, 1))

then
add the following right after it

fputs($server, "\x03$username\r\n\x03$password\r\n");

where you can have $username = the username and $password = the password

What that does is use a telnet key combo which if you were to try to connect to bnet through telnet it would sit at a black screen on connection waiting for a ky combo to get in which is CTRL+C, thats the command for PHP to do that.  Then \r\n is for new lines etc.

Now you can connect and your all set.  Now for the timeout portion.  What I did earlier was whenever battle.net sent me a NULL (for get what number i think 0050) I sent to the server PONG or something (just like an IRC script) just to be sure I don't time out.

Contact me if you want and I can help you more with the bot, just click on my name on the elft to find out my email address.


Arta


AC_Drkan

Quote from: Arta[vL] on February 08, 2005, 05:51 AM
Why are you connecting to BNLS at all?

The answer to that question is because i was connecting to bnls to see if it was up.
If your run that on any ordinary php file it will tell you the server status.
"The Arguments of Today Result in the Wars of Tomorrow" - Quote By Muah.
<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

<kow`> "There are 10 types of people in the world... those who understand binary and those who don't."
<SpaceRain> That's only 2 types of people, kow.
<SpaceRain> STUPID


<[TN]FBMachine> i got kicked out of barnes and noble once for moving all the bibles into the fiction section

God i love Bash.org.

Artanix

Well, a couple of months ago I made a script in php that logged into battle.net as "anonymous" and then did a /stats user game then logged off and spits out the results to the browser....Should still work:

http://www.dark-illusion.info/stats/stats.php

If ya'll want me to post the code, tell me.


Artanix

Hmm, looks like it only works for USWest and Europe. Odd.  :-X

|