mIRC Homepage
Posted By: ATMA mirc + php == 1337 - 02/05/03 12:16 AM
any one know how i can get mirc to use PHP and mySQL and stuff like that?????????

e.g.
write some code in PHP
then have it send data to a mySQL database

is this possible?????? confused
Posted By: KingTomato Re: mirc + php == 1337 - 02/05/03 12:30 AM
Yes, very possible.. Just need to use sockets. >:D You'd write a script in php that recieves get variables, then have mirc visit the web page, and set the values. Eg..

If you have the page submit.php and you would like to send it values of $_GET["fname"] and $_GET["lname"], you could have mirc visit www.mysite.com and send a get request to $+(/submit.php?fname=,%fname,&,lname=,%lname) >:D
Posted By: ATMA Re: mirc + php == 1337 - 02/05/03 12:35 AM
heh? u have me lost i dont know how to use sockets yet its like the one thing i dont know =/
Posted By: KingTomato Re: mirc + php == 1337 - 02/05/03 12:43 AM
Describe what you want to do with this script, and I;'ll build the first have. For example, what data will you be sending? Is mirc going to replace a form field on a php page? Etc etc
Posted By: ATMA Re: mirc + php == 1337 - 02/05/03 12:49 AM
ok here is what i want it to do--


every 5 min it looks to find some one on the chan
then it sends data to the SQL database saying
ison or isnton
then prints it out on a webpage (i can do that part -.-)
if i just have a small script like that to work off i can figur out how to do stuff =p
Posted By: KingTomato Re: mirc + php == 1337 - 02/05/03 01:35 AM
Okay, So i assume your going to have a php webpage that is going to place everything into the MySQL database.

So if you had something like online.php?nick1=on&nick2=on&nick3=off&nick4=on&nick5=on&nick6=off
Then in the php, just send mysql_query("insert into <db> values ($_GET[nick1], $_GET[nick2],...$_GET[nickN]);");

Now, you'll get "on" or "off" in the database. You can print out status on the webpage based on whether they are on or off. Now, as for seinding the information, you can use:

-----------------------------

on 1:CONNECT: {
.timerchkonline 0 300 /checkonline
}

alias checkonline {
; set the name of the channel your checking for people on.
/set -u0 %chan #mychannel
; set the names of the people whom your checking
/set -u0 %people ATMA KingTomato ...
; Now, ghet status
/set -u0 %a 1
/unset %status
while (%a <= $numtok(%people, 32)) {
/set %status $+(%status,&,$gettok(%people, %a, 32),=)
if ($gettok(%people, %a, 32) ison %chan) { /set %status $+(%status,On) }
else { /set %status $+(%status,Off) }
/inc -u0 %a
}
/sockopen status www.yoursite.com 80
}

on 1:SOCKOPEN:status: {
if ($sockerr) { /echo -a Error: Could not submit Status }
else {
/sockwrite -n $sockname GET /online.php [ $+ [ $+(?,%status) ] ] HTTP/1.0
/sockwrite -n $sockname Host: www.yoursite.com
/sockwrite -n $sockname Connection: Keep-Alive
/sockwrite -n $sockname
}
if ($isFile(result.txt)) { .remove result.txt }
}

on 1:SOCKREAD:status: {
/sockread -f &result
/bwrite result.txt -1 -1 &result
}

on 1:SOCKCLOSE:status: {
; now, the result.txt file contains the text that would appear on the webpage
; as if you were to visit it in your browser. Use this to return if it was
; a success.
}

---------------------------------------------------

Change those in red..
Posted By: ATMA Re: mirc + php == 1337 - 02/05/03 10:06 AM
hmmmm when ever i try to run the code i get a socet error
Error: Could not submit Status

do you know what could be couseing it my site is http://www.matrixn3t.net idk what the problem could be =/

im a n00b to sockets =/
Posted By: KingTomato Re: mirc + php == 1337 - 02/05/03 04:39 PM
If you could, could you give me the name of the php file, and how you want the variables to be fullfilled? When I get a working version, i'll post it.
Posted By: ATMA Re: mirc + php == 1337 - 02/05/03 04:56 PM
ok well thx what i want it to do is echo this information to a table:

server:
Nick:
last used command:
Channels
Op%: out of X/Y

if you could do that it would be nice thanks
Posted By: KingTomato Re: mirc + php == 1337 - 02/05/03 05:39 PM
Okay, I'm working on it now, so if you would like to see the stages, keep refreshing http://www.kingtomato.com/online.php
Posted By: codemastr Re: mirc + php == 1337 - 02/05/03 07:56 PM
If I were you, I wouldn't bother with sockets. There is a dll for mIRC available that lets you communicate with a MySQL server. You can find it on mircscripts.org under the dll section, it is called "mIRC MySQL"
Posted By: KingTomato Re: mirc + php == 1337 - 02/05/03 08:41 PM
heh, was unaware..
There ya, use that >:D ty Codemastr
Posted By: ATMA Re: mirc + php == 1337 - 03/05/03 02:23 AM
hmmm looks really nice thx so far ^_^
Posted By: CloCkWeRX Re: mirc + php == 1337 - 06/05/03 04:47 AM
another option is to find dragonzap's STDIO dll and run PHP 4.1.0 or greater with the CLI sapi...

You can capture output, input, etc. Screw this DLL 2 mySQl messyness, i won't even rant about sockets.

pmsg me if you are interested in finding out more
© mIRC Discussion Forums