mIRC Home    About    Download    Register    News    Help

Print Thread
#22014 03/05/03 12:41 AM
Joined: Apr 2003
Posts: 16
C
cap00t Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Apr 2003
Posts: 16
this works for getting a specific number at a specific place out of a txt file:

Code:
alias fstats {
  if ($read(fstats.txt,w,*<a href="index.cgi?action=mlall"><B>*</B></a>*)) {
  var %tm = $read(fstats.txt,$readn) 
  /msg #adasda Total Members: $gettok($mid(%tm,$calc($pos(%tm,mlall) + 10)),1,$asc(<)) 
}  



so i thought this would work too:

Code:
alias fstats {
  if ($read(fstats.txt,w,*<a href="index.cgi?action=mlall"><B>*</B></a>*)) {
  var %tm = $read(fstats.txt,$readn) 
  elseif ($read(fstats.txt,w,*Newest Member: <A HREF="index.cgi?action=viewprofile&username=*"><B>*</B>*)) {
  var %nm = $read(fstats.txt,$readn) 
  /msg #adasda Total Members: $gettok($mid(%tm,$calc($pos(%tm,mlall) + 10)),1,$asc(<)) Newest Member: $gettok($mid(%nm,$calc($pos(%nm,viewprof) + 25)),1,$asc(<))
}  



but it doesnt...

any suggestions?

#22015 03/05/03 01:47 AM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Maybe take out the 'else' from 'elseif'
Code:
alias fstats {
  if ($read(fstats.txt,w,*<a href="index.cgi?action=mlall"><B>*</B></a>*)) {
    var %tm = $ifmatch
  }
  [color:gray]if[/color] ($read(fstats.txt,w,*Newest Member: <A HREF="index.cgi?action=viewprofile&username=*"><B>*</B>*)) {
    var %nm = $ifmatch
  }
  msg #adasda Total Members: $gettok($mid(%tm,$calc($pos(%tm,mlall) + 10)),1,$asc(<)) Newest Member: $gettok($mid(%nm,$calc($pos(%nm,viewprof) + 25)),1,$asc(<))
}

#22016 03/05/03 03:55 AM
Joined: Apr 2003
Posts: 16
C
cap00t Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Apr 2003
Posts: 16
yes! smile

thx, this works; but i came into more trouble:

i look for this part of the text:
<font size="1">2 Guests, 8 Users<BR> ... and want to output 2 Guests, 8 Users

the number of guests and users will change everytime so i use * when i search for it like this:

Code:
if ($read(fstats.txt,w,*&lt;font size="1"&gt;* Guests, * Users&lt;BR&gt;*)) {
    var %on = $ifmatch 
  }  

and use $gettok like this:
Code:
$gettok($mid(%on,$calc($pos(%on,size) +9)),1,$asc(&lt;))  

..but it doesnt work crazy

it works fine here with:
Code:
if ($read(fstats.txt,w,*&lt;a href="index.cgi?action=mlall"&gt;&lt;B&gt;*&lt;/B&gt;&lt;/a&gt;*)) {    
    var %tm = $ifmatch  
  }  

and
Code:
$gettok($mid(%tm,$calc($pos(%tm,mlall) + 10)),1,$asc(&lt;))    


to get 689 out of <a href="index.cgi?action=mlall"><B>689</B></a>

why does the second example work and first one not??

i already tried to remove the spaces between * and Guests and so on..

and the txt is 100% there in the textfile smile

comments welcome, thx ..

#22017 03/05/03 04:06 AM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
If that is all the line contains
//var %on = <font size="1">2 Guests, 8 Users<BR> | echo -a $gettok($gettok(%on,2,62),1,60)
2 Guests, 8 Users

If there is more in the line, you would have to consider that as well.

#22018 03/05/03 05:54 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Code:
alias fstats {
  if $sock(fstats) { sockclose fstats }
  sockopen fstats hyperboards.hyperboards.com 80
}
on *:SOCKOPEN:fstats:{
  if $sockerr { echo $color(info) -s * Error: $sock($sockname).wsmsg | return }
  sockwrite -n $sockname GET /index.cgi HTTP/1.0
  sockwrite -n $sockname HOST: hyperboards.hyperboards.com
  sockwrite -n $sockname $crlf
}
on *:sockread:fstats:{
  if $sockerr { echo $color(info) -s * Error: $sock($sockname).wsmsg | return }
  var %a
  sockread %a
  while $sockbr {
    var %a = $remhtml(%a)
    if Total Members:* iswm  %a { set -u900 %fstats.tmembers $gettok(%a,3,32) }
    if Newest Member:* iswm  %a { set -u900 %fstats.nmember $gettok(%a,3,32) }
    if Total Topics:* iswm  %a {
      set -u900 %fstats.ttopics $gettok(%a,3,32)
      set -u900 %fstats.tposts $gettok(%a,7,32)
    }
    if *Guests*Users* iswm %a {
      !.echo -q $regsub(%a,/(.*Users)(.+)/,\1,%a)
      set -u900 %fstats.online %a
    }
    if Last Updated Topic:* iswm  %a { set -u900 %fstats.ltopic $gettok($gettok(%a,4-,32),1,41) $+ ) }
    sockread %a
  }
}
on *:sockclose:fstats:{
  linesep -s
  echo 9 -s Forum Statistics
  echo 14 -s Total Topics:9 %fstats.ttopics
  echo 14 -s Total Posts:9 %fstats.tposts
  echo 14 -s Total Members:9 %fstats.tmembers
  echo 14 -s Newest Member:9 %fstats.nmember
  echo 14 -s Last Updated Topic:9 %fstats.ltopic
  echo 14 -s Online:9 %fstats.online
  linesep -s
}

alias -l remhtml {
  var %a | !.echo -q $regsub($1-,/(^[^&lt;]*&gt;|&lt;[^&gt;]*&gt;|&lt;[^&gt;]*$)/g,,%a)
  return $remove(%a,&amp;nbsp;)
}
The %fstats.* variables are set for 15 minutes (900 secs).

#22019 03/05/03 10:17 PM
Joined: Apr 2003
Posts: 16
C
cap00t Offline OP
Pikka bird
OP Offline
Pikka bird
C
Joined: Apr 2003
Posts: 16
Code:
if ($read(fstats.txt,w,*&lt;td valign="top" align="left"&gt;&lt;font size="1"&gt;*Users&lt;BR&gt;&lt;A HREF*)) {
    var %on = $ifmatch 
  }  

+
Code:
$gettok($mid(%on,$calc($pos(%on,size="1"&gt;) +9)),1,$asc(&lt;))  


works smile)

nevertheless thx for your help smirk


Link Copied to Clipboard