mIRC Home    About    Download    Register    News    Help

Print Thread
#84772 31/05/04 04:33 PM
Joined: May 2004
Posts: 11
P
PHM Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: May 2004
Posts: 11
I have a web site that I'm trying to use sockets to
I want to make a random quote script
that takes quotes from my web site
and randomly picks one and displays it on channel

here is the URL
Random Quote Page

Here Is how the Code Goes
Code:
 <html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link REL="SHORTCUT ICON" HREF="http://www.phministries.net/icon.ico">
<title>::::PH-Ministry:::PHMinistries:::To Minister In The Heart Of Worship:::PHM-Network:::</title>
</head>
<tr><td> 1 . &nbsp <tr><td> 05/31/04 Said &nbsp <tr><td> Christopher Said &nbsp <tr><td> [23:09] <Kaatje> shrugs [23:09] <Kaatje> i love snakes [23:09] <Kaatje> i cant wait eat 1 <br> <tr><td> 2 . &nbsp <tr><td> 05/31/04 Said &nbsp <tr><td> Christopher Said &nbsp <tr><td> my brother started teasing me about jimmy the other day, so I started to sing, oh how I love jesus, and my brother confused me, and I sang "Oh how I love jimmy instead :/  <br> </body>

</html> 


the page is in php,
can someone help me scan random lines
so that it can be added to a quote in php?


Joined: May 2003
Posts: 79
A
Babel fish
Offline
Babel fish
A
Joined: May 2003
Posts: 79
First of all, the html code is not good. Why do you have all those <tr> and <td>, there is no <table> ? Then, you should read a tutorial on the cookies (you won't need to read the HTTP protocol as there is a lot of example on how to get a web page). Also, to facilitate the search, you could modify your code so it could be like this:
Code:
&lt;!-- quote start --&gt;
1. Here is the first quote&lt;br&gt;Blah...&lt;br&gt;one quote is on one line
2. Another quote, another line&lt;br&gt;just an example
&lt;!-- quote end --&gt;

So you can know where the quotes exactly are, and you just have to take a random line as one quote is one line for example. It's just some hints, as I don't want (neither I have the time) to code it for you, everyone should learn a little smirk
Good luck.

Joined: May 2004
Posts: 11
P
PHM Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: May 2004
Posts: 11
ok i fixed it
it will only be one line ever
i wrote a php script
that selects a random number
then outputs 1 line tahts random
now what id like to figure out
how to put that into a variable into mirc

Random Quote Script PHP

Code:
 &lt;html&gt;

&lt;head&gt;
&lt;meta name="GENERATOR" content="Microsoft FrontPage 5.0"&gt;
&lt;meta name="ProgId" content="FrontPage.Editor.Document"&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=windows-1252"&gt;
&lt;link REL="SHORTCUT ICON" HREF="http://www.phministries.net/icon.ico"&gt;
&lt;title&gt;::::PH-Ministry:::PHMinistries:::To Minister In The Heart Of Worship:::PHM-Network:::&lt;/title&gt;
&lt;/head&gt;
Quote Number 2 This Quote Is Brought To You By Christopher The Quote &lt;&lt; my brother started teasing me about jimmy the other day, so I started to sing, oh how I love jesus, and my brother confused me, and I sang "Oh how I love jimmy instead :/  &gt;&gt; Provided To To You By PHMinistries.net&lt;/body&gt;

&lt;/html&gt; 

anyone able to help?

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
This code will request a quote and display it in the Status window.
Of course, you can change echo %s to a different command which
will post %s to the place you want it to appear.

alias showquote sockopen q www[/i].phministries.net 80
On *:sockopen:q:{
if $sockerr {
echo -s - Error: couldn't contact website.
return
}
var %s = sockwrite -tn q
%s GET /members/admin/blankquotes.php HTTP/1.0
%s Host: www[/i].phministries.net
%s
}
On *:sockread:q:{
var %s
sockread %s
if Quote * iswm %s {
echo -s - %s
sockclose q
}
}
On *:sockclose:q:{
echo -s - Error: couldn't fetch quote.
}


Paste in the remote and type /showquote

Joined: May 2004
Posts: 11
P
PHM Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: May 2004
Posts: 11
I'm having a problem editing it to get it to enter a channel

is this what im supposed to edit?

echo -s - %s

this is the message i get in status

[19:20] -> *Quote* Number 2 This Quote Is Brought To You By Christopher The Quote << my brother started teasing me about jimmy the other day, so I started to sing, oh how I love jesus, and my brother confused me, and I sang "Oh how I love jimmy instead smirk >> Provided To To You By PHMinistries.net</body>
-
Quote No such nick/channel

Last edited by PHM; 31/05/04 10:20 PM.
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Yes, that line is what you need to edit, but what did you change it do?

Keep in mind that neither # nor $chan will work, because they do not exist in the sockread event.

You will need to specify an explicit target. For example, /msg #chatworld %s

Joined: May 2004
Posts: 11
P
PHM Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: May 2004
Posts: 11
thanks man,
i didnt realize that last part that it wont use # or $chan
so i did it on the alias,
last question where would i get the info to kill the <body> tag?

Quote Number 2 This Quote Is Brought To You By Christopher The Quote << my brother started teasing me about jimmy the other day, so I started to sing, oh how I love jesus, and my brother confused me, and I sang "Oh how I love jimmy instead smirk >> Provided To To You By PHMinistries.net</body>

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Edit your PHP file so that there's a line break (\n) before the closing </body> tag.

Joined: May 2004
Posts: 11
P
PHM Offline OP
Pikka bird
OP Offline
Pikka bird
P
Joined: May 2004
Posts: 11
Thanks for all the help guys smile

really apreciate it.

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
You're welcome laugh

And remember, the script identifies the quote line by its first word, "Quote ..."

If you wish to change that word in your HTML output, you will need to edit the script condition too:

if Quote * iswm %s {
<display quote>
}

(* is a wildcard which matches the rest of the line)


Link Copied to Clipboard