Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Version: 1.11
- Date: 16/06/2011
- */
- alias rlv { return $gettok($read($script,2),2,32) }
- alias -l rl {
- if ($regex($1,/Wessie|Skye`Rackloy|Suou/i)) { return 1 }
- else { return 0 }
- }
- on *:LOAD: {
- if (!$hget(r-a-dio)) {
- hmake r-a-dio
- if ($exists(r-a-dio.hsh)) {
- hload r-a-dio r-a-dio.hsh
- }
- else {
- hadd r-a-dio logfile r-a-dio_log.txt
- }
- }
- }
- on *:EXIT: { hsave radio radio.hsh | hsave tags tags.bin }
- on *:UNLOAD: {
- sockclose stream_
- hsave radio radio.hsh
- if (!%update_radio) {
- hfree radio
- .timerstream off
- .timerLPhash off
- unset %radio.*
- }
- }
- /*
- # Module: stream_socket
- # Commands: [/] radiostream, [/] radiocheck, [/] showerror
- # Usage: /radiostream, /radiocheck, /showerror error_message
- # Info: Main Module of the script, don't disable.
- */
- #stream_socket on
- alias radiostream {
- if ($hget(stream_)) { hfree stream_ }
- hadd -m stream_ address shoutcast1.rootnode.net
- hadd stream_ state first
- hadd stream_ status trying
- sockopen stream_ shoutcast1.rootnode.net 1130
- if (!$timer(stream)) { .timerstream -o 0 20 radiocheck }
- echo -a Opening socket to stream.
- }
- alias radiocheck {
- if (!$sock(stream_)) {
- radiostream
- }
- }
- on *:sockopen:stream*:{
- var %id = $sockname
- echo -a $hget(%id,address)
- if (!$sockerr) {
- sockwrite -n $sockname GET / HTTP/1.1
- sockwrite -n $sockname Host: $hget(%id,address)
- sockwrite -n $sockname icy-metadata:1
- sockwrite $sockname $crlf
- echo -a Write to socket complete.
- }
- else { showerror Could not connect to stream! }
- }
- on *:sockclose:stream*: { radiostream | .timerweb_send off }
- on *:sockread:stream*:{
- var %id = $sockname, %state = $hget(%id,state), %read
- if (!$timer(web_send)) { .timerweb_send 0 50 radio.listeners web_send }
- if (%state == data) {
- var %meta = $hget(%id,icy-metaint)
- if (%meta) {
- var %read $hget(%id,read)
- sockread %read &data
- if ($sockbr == %read) { hadd %id state meta }
- else { hadd %id read $calc(%read - $sockbr) }
- }
- }
- elseif (%state == meta) {
- var %metalen $hget(%id,metalen)
- if (!%metalen) {
- sockread 1 &byte
- var %metalen = $calc($bvar(&byte,1,1) * 16)
- if (%metalen == 0) {
- hadd %id state data
- hadd %id read $hget(%id,icy-metaint)
- }
- else { hadd %id metalen %metalen }
- }
- else {
- sockread %metalen &read
- if ($bvar(&read,0) >= 750) { sockclose stream_ | radiostream | echo -a LOL'D | halt }
- var %read $+($hget(%id,metadata),$bvar(&read,1,$bvar(&read,0)).text)
- if (%metalen == $sockbr) {
- var %p = $calc($regex(%read,/[\W_]/g) / $len(%read))
- if (%p > 0.75) { showerror Bugged stream detected - stream closed }
- noop $regex(tags, %read,/.*Streamtitle='(.*)';StreamUrl='(.*)';/i)
- hadd %id StreamUrl $regml(2)
- ;echo -s Hello: $+(',$unescapehtml($regml(tags, 1)),') * $hget(%id,StreamTitle)
- if ($+(',$unescapehtml($regml(tags, 1)),') != $hget(%id,StreamTitle)) { hadd %id OldStreamTitle $hget(%id,StreamTitle) }
- hadd %id StreamTitle $+(',$unescapehtml($regml(tags, 1)),')
- hadd %id read $hget(%id,icy-metaint)
- hadd %id metalen $null
- hadd %id state data
- if ($+(',$regml(tags, 1),') != $hget(%id,OldStreamTitle)) { radio.next %read }
- }
- else {
- hadd %id metadata %read
- hadd %id metalen $calc(%metalen - $sockbr)
- }
- }
- }
- elseif (%state == header) {
- sockread %read
- if ($len(%read) == 0) {
- var %content = $hget(%id,content-type),%ext
- if (%content == audio/aacp) { %ext = .aac }
- elseif (%content == audio/mpeg) { %ext = .mp3 }
- elseif (%content == video/nsv) { %ext = .nsv }
- else { %ext = .dat }
- hadd %id ext %ext
- if ($hget(%id,icy-metaint)) { hadd %id read $v1 }
- else {
- var %f = $+($options().output,$filter($hget(%id,icy-name)),%ext)
- hadd %id file $qt(%f)
- }
- hadd %id state data
- hadd %id status streaming
- }
- else {
- var %param = $gettok(%read,1,58),%value = $gettok(%read,2-,58)
- if ($istok(icy-name|icy-genre|icy-url|icy-metaint|icy-br|content-type,%param,124)) { hadd %id %param %value }
- }
- }
- elseif (%state == first) {
- sockread %read
- var %code = $gettok(%read,2,32),%info = $gettok(%read,3-,32)
- if (%code != 200) {
- showerror $iif(%info,Could not connect to stream: %info,Could not connect: Unexpected server response)
- sockclose stream_
- }
- else { hadd %id state header | echo -a Socket connected to stream. }
- }
- }
- alias -l showerror { echo $color(info) -ag Streamer: $$1- }
- #stream_socket end
- /*
- # [OLD]
- # Module: radio.next
- # Commands: [/] radio.next, [/] radio.lp, [/] radio.add
- # Usage: /radio.next, /radio.lp last_song, /radio.add duration_of_song title_of_song
- # Info: Handler of starting songs and creator of announce event, don't disable.
- */
- #radio.next on
- alias radio.next {
- ; Update listener count
- ;radio.listeners
- ; Increase 'now starting' announce variable
- inc %radio.announce
- ; Record ending time of last song
- set %radio.end $ctime
- ; Print out debugging information
- echo -s Saved: $hget(stream_,OldStreamTitle) $duration($calc(%radio.end - %radio.start)) $sha1($hget(stream_,OldStreamTitle))
- ; Call .lp to save last song in database
- radio.lp $hget(stream_,OldStreamTitle)
- web_send_data lp $hget(stream_,OldStreamTitle)
- web_send_data np %radio.listeners %radio.kbps $hget(stream_,StreamTitle)
- .timerweb_send 0 40 radio.listeners web_send
- ; Call .add to save duration of last song in database
- radio.add $calc(%radio.end - %radio.start) $hget(stream_,OldStreamTitle)
- ; Record starting time for next song
- set %radio.start $ctime
- ; Call _stream_tags to check for updated tags
- radio_stream_tags
- if (%radio.announce >= $a_active) && (%radio.active) {
- if ($hget(radio,$sha1($hget(stream_,StreamTitle)))) { var %radio.total = $gettok($ifmatch,1,59), %radio.last = $gettok($ifmatch,2,59) }
- else { var %radio.total = ?, %radio.last = ? }
- var %radio.now $calc($ctime - %radio.start)
- write radiostarting.txt Now starting:04 $hget(stream_,StreamTitle) $+([,$format(%radio.now,2),/,$format(%radio.total,2),]) $+($chr(40),%radio.listeners,/,%radio.max,$chr(41)) 04LP: $lpmessage(%radio.last)
- msg #r/a/dio Now starting:04 $hget(stream_,StreamTitle) $+([,$format(%radio.now,2),/,$format(%radio.total,2),]) $+($chr(40),%radio.listeners,/,%radio.max,$chr(41)) 04LP: $lpmessage(%radio.last)
- unset %radio.announce
- }
- }
- alias -l radio.lp {
- set %radio.lp5 %radio.lp4
- set %radio.lp4 %radio.lp3
- set %radio.lp3 %radio.lp2
- set %radio.lp2 %radio.lp1
- set %radio.lp1 $ctime $1-
- }
- alias radio.add {
- if (!$hget(radio)) {
- hmake radio 100
- if ($exists(radio.hsh)) { hload radio radio.hsh }
- }
- hadd radio $sha1($2-) $+($1,;,$ctime)
- }
- #radio.next end
- /*
- # Module: last_played
- # Command: [$] hc
- # Info: Last played event handler.
- */
- #last_played on
- alias -l hc { return $+($chr(40),$1,$2,$chr(41)) }
- on $*:TEXT:/^[!.@]lp/i:#r/a/dio: {
- if (%radio.active) {
- var %t1 = $hc($round($calc(($ctime - $gettok(%radio.lp1,1,32)) / 60),0),min) $+(04,$gettok(%radio.lp1,2-,32)) $+(03,|)
- var %t2 = $hc($round($calc(($ctime - $gettok(%radio.lp2,1,32)) / 60),0),min) $+(04,$gettok(%radio.lp2,2-,32)) $+(03,|)
- var %t3 = $hc($round($calc(($ctime - $gettok(%radio.lp3,1,32)) / 60),0),min) $+(04,$gettok(%radio.lp3,2-,32)) $+(03,|)
- var %t4 = $hc($round($calc(($ctime - $gettok(%radio.lp4,1,32)) / 60),0),min) $+(04,$gettok(%radio.lp4,2-,32)) $+(03,|)
- var %t5 = $hc($round($calc(($ctime - $gettok(%radio.lp5,1,32)) / 60),0),min) $+(04,$gettok(%radio.lp5,2-,32))
- msg $chan Last played: %t1 %t2 %t3 %t4 %t5
- }
- }
- #last_played end
- /*
- # Module: now_playing
- # Commands: None
- # Info: Now playing event handler. Don't disable, instead use build-in commands.
- */
- #now_playing on
- on $*:TEXT:/^[!.@]np/i:#r/a/dio: {
- if (!$timer(LPhash)) || (!$timer(tags)) { .timerLPhash 0 1800 hsave radio radio.hsh | .timerTAGS 0 1800 hsave tags tags.bin }
- var %md5 = $iif($2 == $md5($ip),1,$iif($2 == $me,1,0))
- if (%md5) && ($rl($nick)) && ($3) {
- if ($3 == set) && ($4 isnum) { set %radio.announce.wait $4 | .msg $chan Set announce to every %radio.announce.wait song(s). }
- elseif ($3 == option) && ($regex($4,/(enable|disable)/i)) { set %radio.active $iif($4 == enable,1,0) | .msg $chan $iif(%radio.active,Enabled,Disabled) now playing trigger. }
- elseif ($3 == restart) {
- sockclose stream_
- radiostream
- .notice $nick The stream on client $md5($ip) has restarted.
- }
- elseif ($3 == shutdown) {
- sockclose stream_
- if ($hget(radio)) {
- hsave radio radio.hsh
- hfree radio
- }
- set %radio.online 0
- .timerstream off
- .notice $nick Stream connection shutdown confirmed.
- }
- elseif ($3 == start) {
- radiostream
- if (!$hget(radio)) {
- hmake radio 100
- if ($exists(radio.hsh)) { hload radio radio.hsh }
- }
- set %radio.online 1
- .notice $nick Stream connection is being estabilished.
- }
- elseif ($3 == status) {
- .notice $nick Status report: $iif($sock(stream_),03,04) Connected | $iif(%radio.active,03,04) Trigger | $iif(%radio.online,03,04) Connect attempt
- }
- }
- elseif ($2 == version) { .notice $nick Using version $rlv of RadioStream }
- elseif ($sock(stream_)) {
- if (%md5) {
- radio.listeners
- if ($hget(radio,$sha1($hget(stream_,StreamTitle)))) { var %radio.total = $gettok($ifmatch,1,59), %radio.last = $gettok($ifmatch,2,59) }
- else { var %radio.total = ?, %radio.last = ? }
- var %radio.now $calc($ctime - %radio.start)
- msg $chan Now playing:04 $hget(stream_,StreamTitle) $+([,$format(%radio.now,2),/,$format(%radio.total,2),]) $+($chr(40),%radio.listeners,/,%radio.max,$chr(41)) 04LP: $lpmessage(%radio.last)
- }
- elseif ($2 == debug) { msg #r/a/dio Debug: %radio.announce - $a_active }
- elseif ($2 == hash) && ($rl($nick)) { .notice $nick Hash for this client is: $md5($ip) }
- elseif (%radio.active) && (!$2) {
- radio.listeners
- if ($hget(radio,$sha1($hget(stream_,StreamTitle)))) { var %radio.total = $gettok($ifmatch,1,59), %radio.last = $gettok($ifmatch,2,59) }
- else { var %radio.total = ?, %radio.last = ? }
- var %radio.now $calc($ctime - %radio.start)
- msg $chan Now playing:04 $hget(stream_,StreamTitle) $+([,$format(%radio.now,2),/,$format(%radio.total,2),]) $+($chr(40),%radio.listeners,/,%radio.max,$chr(41)) 04LP: $lpmessage(%radio.last)
- }
- }
- elseif (%radio.online) {
- msg $chan Stream connection is down, trying to reconnect.
- set %radio.announce %radio.announce.wait
- radiostream
- }
- }
- alias lpmessage {
- if ($1 == ?) { return Never played before. }
- else { return $replacex($duration($calc($ctime - $1)),wks,w,wk,w,days,d,day,d,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s) ago. }
- }
- #now_playing end
- /*
- # [OLD]
- # Module: radio.listeners
- # Commands: [/] radio.listeners
- # Usage: /radio.listeners
- # Info: Updates the listener count used by the now_playing component.
- */
- #radio.listeners on
- alias radio.listeners {
- if ($1 == web_send) { set %radio_listeners_do web_send }
- if (!$sock(radio.listeners)) { sockopen radio.listeners shoutcast1.rootnode.net 1130 }
- }
- on *:SOCKOPEN:radio.listeners: {
- sockwrite -nt $sockname GET /7.html HTTP/1.0
- sockwrite -nt $sockname User-Agent: Mozilla
- sockwrite -nt $sockname Host: shoutcast1.rootnode.net:1130
- sockwrite -nt $sockname $crlf
- }
- on *:SOCKREAD:radio.listeners: {
- sockread &radio.t
- var %bg = $xbfind(&radio.t,4,>).end, %ng = $xbfind(&radio.t,$calc($xbfind(&radio.t,0,<) - 1),<), %radio.lrg = $bvar(&radio.t,%bg,$calc(%ng - %bg)).text
- set %radio.listeners $gettok(%radio.lrg,1,44)
- set %radio.max $gettok(%radio.lrg,4,44)
- set %radio.kbps $gettok(%radio.lrg,6,44)
- }
- on *:SOCKCLOSE:radio.listeners: {
- if (%radio_listeners_do == web_send) {
- web_send_data np %radio.listeners %radio.kbps
- unset %radio_listeners_do
- }
- }
- alias -l xbfind {
- if ($3 isalpha) { bset -t &xbfindtemp 1 $3 }
- elseif ($prop == .text) { bset -t &xbfindtemp 1 $3 }
- elseif ($prop == .textend) { bset -t &xbfindtemp 1 $3 }
- else { bset &xbfindtemp 1 $3 }
- var %xb.m $bvar(&xbfindtemp,1,$bvar(&xbfindtemp,0))
- if ($2 == 0) {
- if ($bvar($1,0)) {
- var %xb.t = 0, %xb.p = 1
- while ($bfind($1, %xb.p, %xb.m)) {
- var %xb.p $ifmatch
- inc %xb.p
- inc %xb.t
- }
- return %xb.t
- }
- }
- else {
- if ($bvar($1,0)) {
- var %xb.t = 0, %xb.p = 1, %xb.r
- while ($bfind($1, %xb.p, %xb.m)) {
- var %xb.p $ifmatch
- inc %xb.t
- if (%xb.t == $2) { var %xb.r %xb.p | break }
- inc %xb.p
- }
- if ($prop == end) { return $calc(%xb.r + $numtok(%xb.m,32)) }
- if ($prop == textend) { return $calc(%xb.r + $numtok(%xb.m,32)) }
- return %xb.r
- }
- }
- }
- #radio.listeners end
- /*
- # Module: html_free
- # Commands: [$] html_free
- # Usage: $html_free(text_to_free_from_html)
- # Info: Removes any html tags and anything inbetween tags.
- */
- #html_free on
- alias html_free {
- var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
- return %x
- }
- #html_free end
- /*
- # Module: format
- # Commands: [$] format
- # Usage: $format(number_to_format)
- # Info: Returns number_to_format in a human readable time format.
- */
- #format on
- alias format {
- if ($1 isnum) {
- var %t $1
- var %h $int($calc(%t / 3600))
- if (!%h) { var %h 00 }
- dec %t $calc(%h * 3600)
- var %n $int($calc(%t / 60))
- if (!%n) { var %n 00 }
- dec %t $calc(%n * 60)
- if (!%t) { var %t 00 }
- return $iif($2 != 2,$iif(%h,$iif(%h < 10,$+(0,%h),%h),00) $+ :) $+ $iif(%n,$iif(%n < 10,$+(0,%n),%n),00) $+ : $+ $iif(%t,$iif(%t < 10,$+(0,%t),%t),00)
- }
- else { return $1 }
- }
- #format end
- /*
- # Module: tags_extension
- # Usage: None
- # Info: Users with access can change tags of the stream, these will be saved
- for next time the same tags come up. ([!tags help] for Users)
- */
- #tags_extension on
- alias tagaccess {
- if (!%tagaccess) { set %tagaccess Wessie Skye`Rackloy }
- if ($nick isin %tagaccess) { return 1 }
- else { return 0 }
- }
- on $*:TEXT:/^[!.@^]tags/i:#r/a/dio: {
- var %tagCommand = $2
- if ($tagaccess($nick)) {
- if (%tagCommand == Help) {
- .notice $nick Help available at "PASTEBIN LINK TROLOLO".
- }
- elseif ($regex(%tagCommand,/(SET|ADD)/i)) {
- var %tagHash = $3, %tagMeta = $4-
- var %tagRegex = /[a-f0-9]{40}/
- if ($regex(%tagHash,%tagRegex)) {
- if (%tagMeta) {
- tags_add %tagHash %tagMeta
- .notice $nick Added: $hget(stream_,StreamTitle) -> %tagMeta
- }
- }
- elseif (%tagHash == Current) {
- if (%tagMeta) {
- var %tagHash = $sha1($hget(stream_,StreamTitle))
- tags_add %tagHash %tagMeta
- .notice $nick Added: $hget(stream_,StreamTitle) -> %tagMeta
- radio_stream_tags
- }
- }
- else {
- .notice $nick Invalid hash, not a valid sha1 hash. Use "!tag hash <originaltag>" to get the sha1 hash.
- }
- }
- elseif ($regex(%tagCommand,/(DEL|REMOVE)/i)) {
- var %tagHash = $3
- var %tagRegex = /[a-f0-9]{40}/
- if ($regex(%tagHash,%tagRegex)) {
- tags_del %taghash
- .notice $nick Deleted %taghash
- }
- elseif ($regex(%tagHash,/(CURRENT)/i)) {
- tags_del %tags_current
- .notice $nick Deleted %tags_current
- }
- }
- elseif ($regex(%tagCommand,/(HASH)/i)) {
- var %tagMeta = $3-
- .notice $nick Hash: %tagMeta -> $sha1(%tagMeta)
- }
- elseif (%tagCommand == User) && ($3 == add) {
- if ($nick == Wessie) {
- set %tagaccess %tagaccess $4
- }
- }
- elseif (%tagCommand == change) && ($nick == Wessie) {
- streamTags $3-
- .notice $nick Taggie
- }
- else {
- .notice $nick Well that isn't a command now is it.
- }
- }
- }
- alias tags_del {
- var %tagHash = $1
- if ($hget(tags,%taghash)) {
- hdel tags %taghash
- }
- }
- alias tags_add {
- var %tagHash = $1, %tagMeta = $2-
- if (!$hget(tags)) {
- hmake tags 600
- if ($exists(tags.bin)) {
- hload tags tags.bin
- }
- }
- hadd tags %tagHash %tagMeta
- }
- alias streamTags {
- if ($sock(Tags_stream)) { sockclose Tags_stream }
- set %tags_meta $url_Encode($1-)
- sockopen Tags_stream shoutcast1.rootnode.net 1130
- }
- on *:SOCKOPEN:Tags_stream: {
- sockwrite -nt $sockname GET /admin.cgi?mode=updinfo&charset=UTF-8&song= $+ %tags_meta HTTP/1.1
- sockwrite -nt $sockname Host: shoutcast1.rootnode.net
- sockwrite -nt $sockname User-Agent: Mozilla/5.0
- sockwrite -nt $sockname Authorization: Basic %tags_auth
- sockwrite -nt $sockname $crlf
- }
- on *:SOCKREAD:Tags_stream: {
- sockclose $sockname
- }
- alias radio_stream_tags {
- var %tags_sha1 = $sha1($hget(stream_,StreamTitle))
- var %tags_tags = $hget(tags,%tags_sha1)
- if (%tags_tags) {
- echo -s Tags: Old -> %tags_tags
- set %tags_current %tags_sha1
- hadd stream_ StreamTitle %tags_tags
- streamTags %tags_tags
- }
- }
- #tags_extension end
- /*
- # Module: [$] url_encode
- # Usage: $url_encode(text_to_encode)
- # Info: Returns html encoded text_to_encode.
- */
- #url_encode on
- alias -l Url_Encode { return $regsubex($1-,/([^\d\w])/g,$+(%,$base($asc(\t),10,16))) }
- #url_encode end
- /*
- # Module: [$] a
- # Usage: $a
- # Info: Returns int that remembles the amount of song
- that should be played before announcing again.
- */
- #activity_tracker on
- on $*:TEXT:/^.{5}/:#r/a/dio: {
- a_count
- noop $regsubex($1-,/[\w\d]/g,$a_count)
- var %a_char = $a_count(1)
- if (!$hget(a_table)) { hmake a_table 5 }
- hadd -u300 a_table $a(char) $+(%a_char,;,$nick)
- if (!$timer(a_activity)) { .timera_activity 0 300 hadd a_table a_lines 1 }
- hinc a_table a_lines
- }
- alias -l a {
- if (!$2) { return $+($1,$hget(a_table,a_lines)) }
- else { return $hget(a_table,$+($1,$2)) }
- }
- alias -l a_count {
- if ($isid) {
- if (!$1) { inc %a_count 1 }
- return %a_count
- }
- else { unset %a_count }
- }
- alias -l a_active {
- var %a_t = 1
- while ($a(char,%a_t)) {
- var %a_c = $gettok($ifmatch,1,59), %a_p = $gettok($ifmatch,2,59)
- var %a_persons = $addtok(%a_persons,%a_p,59)
- var %a_characters = $calc(%a_characters + %a_c)
- inc %a_t
- }
- var %a_lines = %a_t - 1
- var %a_persons = $numtok(%a_persons,59)
- return $a_formula(%a_characters,%a_lines,%a_persons)
- }
- alias a_formula {
- /*
- 1 = Characters
- 2 = Lines
- 3 = Persons
- */
- ;return $calc(($1 / $2) / $3)
- return $iif($round($calc(($1 / $2) / $3),0) == 0,10,$ifmatch)
- }
- #activity_tracker end
- /*
- # Module: [$] unescapehtml
- # Usage: $unescapehtml(text_to_unescape)
- # Info: Unescapes html encoded characters.
- */
- #unescapehtml on
- alias unescapehtml {
- var %commonchars = lt|gt|amp|quot
- var %commoncharcodes = 60|62|38|34|39
- var %i = $regex($1, /(&(?:#\d+| $+ %commonchars $+ );)/gi), %chr, %after, %retval
- if (!%i) { return $1 }
- set -n %retval $1
- while (%i) {
- %chr = $mid($regml(%i), 2, -1)
- if ($findtok(%commonchars, %chr, 1, 124)) { %chr = $gettok(%commoncharcodes, $ifmatch, 124) }
- else {
- %chr = $mid(%chr, 2)
- if (%chr > 255) { %chr = 63 }
- }
- set -n %after $mid(%retval, $calc($regml(%i).pos + $len($regml(%i))))
- set -n %retval $+($left(%retval, $calc($regml(%i).pos - 1)), $chr(%chr), %after)
- dec %i
- }
- return %retval
- }
- #unescapehtml end
- /*
- # Module: [/] web_send
- # Usage: /web_send song_tags
- # Info: Sends $song_tags to r-a-dio website server.
- */
- #web_send on
- alias noqt2 { return $left($right($1-,-1),-1) }
- alias web_send_data {
- var %sock = $+(web_send_,$1,$r(0,10000))
- sockopen %sock r-a-dio.com 80
- ;lp = web_send_data lp lastsong
- ;np = web_send_data np listeners bitrate np
- if ($1 == lp) {
- set $+(%,%sock,_data) $+(/x_data/updlp.php?user=Saki&pass=niceone&djid=,%radio.djid,&lp,=,$url_encode($noqt2($2-)))
- }
- elseif ($1 == np) && (!$4) {
- set $+(%,%sock,_data) $+(/x_data/updstrstat.php?user=Saki&pass=niceone&djid=,%radio.djid,&listeners=,$2,&bitrate=,$3)
- ;,&np=,$url_encode($noqt2($hget(stream_,StreamTitle))))
- }
- elseif ($1 == np) {
- set $+(%,%sock,_data) $+(/x_data/updstrstat.php?user=Saki&pass=niceone&djid=,%radio.djid,&listeners=,$2,&bitrate=,$3,&np=,$url_encode($noqt2($4-)))
- }
- .timerclearweb_send 0 600 unset %web_send_*
- }
- on *:SOCKOPEN:web_send_*: {
- sockwrite -nt $sockname GET $($+(%,$sockname,_data),2) HTTP/1.1
- sockwrite -nt $sockname Host: r-a-dio.com
- sockwrite -nt $sockname $crlf
- }
- on *:SOCKREAD:web_send_*: {
- var %v
- sockread %v
- if ($regex(%v,/Error_code: (\n+)/i)) {
- var %error_code = $regml(1)
- if (%error_code != 0) {
- echo -s (R/a/dio) [web_send]: Failed to upload song title $+([,Data=,$($+(%,$sockname,_data),2),])
- if (%error_code == 1) {
- echo -a web_send ERROR 'Missing username or password'
- }
- elseif (%error_code == 2) {
- echo -a web_send ERROR 'Incorrect username or password'
- }
- elseif (%error_code == 3) {
- echo -a web_send ERROR 'Incorrect privileges'
- }
- elseif (%error_code == 4) {
- echo -a web_send ERROR 'Invalid/Missing parameters'
- }
- else {
- echo -a web_send ERROR 'Unknown error $+([,%error_code,]) $+ '
- }
- }
- }
- }
- on *:SOCKCLOSE:web_send_*: {
- unset $+(%,$sockname,_data)
- }
- alias get_dat_dj {
- set %radio.dj_get $1
- echo -a G: $1
- if (%radio.dj_get == 0) {
- set %radio.djid 0
- }
- else {
- sockopen get_dj r-a-dio.com 80
- }
- }
- on *:SOCKOPEN:get_dj: {
- sockwrite -nt $sockname GET /x_data/getdjid.php?user=saki&pass=niceone&dj= $+ %radio.dj_get HTTP/1.1
- sockwrite -nt $sockname Host: r-a-dio.com
- sockwrite -nt $sockname $crlf
- }
- on *:SOCKREAD:get_dj: {
- var %t
- sockread %t
- if (error_code: isin %t) {
- var %error_code = $gettok(%t,2,32)
- if (%error_code != 0) {
- echo -s [GET DJ] Yep its an error -> %t
- }
- }
- elseif ($regex(%t,/^[0-9][0-9]?$/i)) {
- if (%t) && (!%d) { var %d = 1 | set %radio.djid %t }
- }
- }
- #web_send end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement