Archive

Archive for June, 2007

morse.mrc – Morse Talk

;;;; Morse Talk v1.0.2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Written by:                                                                ;;
;;   Brian Schmidt aka. brianMan.                                             ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Readme / Help ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load this script in mIRC, if you don't know how to do this, then perhaps   ;;
;; you shouldn't be using this script.                                        ;;
;;                                                                            ;;
;; This morse script is only able to convert to and from 0-9 and A-Z          ;;
;;                                                                            ;;
;; The script consists of 2 identifiers, 1 alias and a MORSE-to-normal text   ;;
;; catcher.                                                                   ;;
;;                                                                            ;;
;; To talk to the active window, with morse code simply type:                 ;;
;;   "/morse This will be written in morse code"                              ;;
;; Will output:                                                               ;;
;;   "[s2m] - .... .. ...  .-- .. .-.. .-..  -... .  .-- .-. .. - - . -.      ;;
;;    .. -.  -- --- .-. ... .  -.-. --- -.. . "                               ;;
;;                                                                            ;;
;; Any user that have the same morse script loaded will have the morse code   ;;
;; automatically converted into normal text, so they will actually see the    ;;
;; following on their screen:                                                 ;;
;;   "[m2s] THIS WILL BE WRITTEN IN MORSE CODE"                               ;;
;;                                                                            ;;
;; The 2 identifiers available is $string2morse and $morse2string, wich can   ;;
;; be used in other scripts.                                                  ;;
;;   "//echo -a Some of $string2morse(this) text will be in morse"            ;;
;; Will output:                                                               ;;
;;   "Some of - .... .. ...  text will be in morse"                           ;;
;; And:                                                                       ;;
;;   "//echo -a $morse2string(- .... .. ... )"                                ;;
;; Will output:                                                               ;;
;;   "THIS"                                                                   ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Changelog ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; v1.0.2                                                                     ;;
;; * Fixed many of the scripts replacement routines.                          ;;
;; + Added automatic morse->ascii conversion between several people using     ;;
;;   script.                                                                  ;;
;; * Split up the parts of the script, so that it will be easier to use in    ;;
;;   other scripts.                                                           ;;
;;                                                                            ;;
;; v1.0.0                                                                     ;;
;; + Initial release.                                                         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alias string2morse {
    var %string2morse = $replace($1-,$chr(32),$chr(15) $+ $chr(32))
    var %string2morse = $replace(%string2morse,A,$chr(15) $+ .- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,B,$chr(15) $+ -... $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,C,$chr(15) $+ -.-. $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,D,$chr(15) $+ -.. $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,E,$chr(15) $+ . $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,F,$chr(15) $+ ..-.- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,G,$chr(15) $+ --. $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,H,$chr(15) $+ .... $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,I,$chr(15) $+ .. $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,J,$chr(15) $+ .--- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,K,$chr(15) $+ -.- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,L,$chr(15) $+ .-.. $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,M,$chr(15) $+ -- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,N,$chr(15) $+ -. $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,O,$chr(15) $+ --- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,P,$chr(15) $+ .--. $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,Q,$chr(15) $+ --.- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,R,$chr(15) $+ .-. $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,S,$chr(15) $+ ... $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,T,$chr(15) $+ - $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,U,$chr(15) $+ ..- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,V,$chr(15) $+ ...- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,W,$chr(15) $+ .-- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,X,$chr(15) $+ -..- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,Y,$chr(15) $+ -.-- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,Z,$chr(15) $+ --.. $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,0,$chr(15) $+ ----- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,1,$chr(15) $+ .---- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,2,$chr(15) $+ ..--- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,3,$chr(15) $+ ...-- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,4,$chr(15) $+ ....- $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,5,$chr(15) $+ ..... $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,6,$chr(15) $+ -.... $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,7,$chr(15) $+ --... $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,8,$chr(15) $+ ---.. $+ $chr(32) $+ $chr(15))
    var %string2morse = $replace(%string2morse,9,$chr(15) $+ ----. $+ $chr(32) $+ $chr(15))
    return %string2morse
}

alias morse2string {
    var %morse2string = $replace($1-,$chr(15) $+ $chr(32),$chr(32))
    var %morse2string = $replace(%morse2string,$chr(15) $+ .- $+ $chr(32) $+ $chr(15),A)
    var %morse2string = $replace(%morse2string,$chr(15) $+ -... $+ $chr(32) $+ $chr(15),B)
    var %morse2string = $replace(%morse2string,$chr(15) $+ -.-. $+ $chr(32) $+ $chr(15),C)
    var %morse2string = $replace(%morse2string,$chr(15) $+ -.. $+ $chr(32) $+ $chr(15),D)
    var %morse2string = $replace(%morse2string,$chr(15) $+ . $+ $chr(32) $+ $chr(15),E)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ..-.- $+ $chr(32) $+ $chr(15),F)
    var %morse2string = $replace(%morse2string,$chr(15) $+ --. $+ $chr(32) $+ $chr(15),G)
    var %morse2string = $replace(%morse2string,$chr(15) $+ .... $+ $chr(32) $+ $chr(15),H)
    var %morse2string = $replace(%morse2string,$chr(15) $+ .. $+ $chr(32) $+ $chr(15),I)
    var %morse2string = $replace(%morse2string,$chr(15) $+ .--- $+ $chr(32) $+ $chr(15),J)
    var %morse2string = $replace(%morse2string,$chr(15) $+ -.- $+ $chr(32) $+ $chr(15),K)
    var %morse2string = $replace(%morse2string,$chr(15) $+ .-.. $+ $chr(32) $+ $chr(15),L)
    var %morse2string = $replace(%morse2string,$chr(15) $+ -- $+ $chr(32) $+ $chr(15),M)
    var %morse2string = $replace(%morse2string,$chr(15) $+ -. $+ $chr(32) $+ $chr(15),N)
    var %morse2string = $replace(%morse2string,$chr(15) $+ --- $+ $chr(32) $+ $chr(15),O)
    var %morse2string = $replace(%morse2string,$chr(15) $+ .--. $+ $chr(32) $+ $chr(15),P)
    var %morse2string = $replace(%morse2string,$chr(15) $+ --.- $+ $chr(32) $+ $chr(15),Q)
    var %morse2string = $replace(%morse2string,$chr(15) $+ .-. $+ $chr(32) $+ $chr(15),R)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ... $+ $chr(32) $+ $chr(15),S)
    var %morse2string = $replace(%morse2string,$chr(15) $+ - $+ $chr(32) $+ $chr(15),T)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ..- $+ $chr(32) $+ $chr(15),U)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ...- $+ $chr(32) $+ $chr(15),V)
    var %morse2string = $replace(%morse2string,$chr(15) $+ .-- $+ $chr(32) $+ $chr(15),W)
    var %morse2string = $replace(%morse2string,$chr(15) $+ -..- $+ $chr(32) $+ $chr(15),X)
    var %morse2string = $replace(%morse2string,$chr(15) $+ -.-- $+ $chr(32) $+ $chr(15),Y)
    var %morse2string = $replace(%morse2string,$chr(15) $+ --.. $+ $chr(32) $+ $chr(15),Z)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ----- $+ $chr(32) $+ $chr(15),0)
    var %morse2string = $replace(%morse2string,$chr(15) $+ .---- $+ $chr(32) $+ $chr(15),1)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ..--- $+ $chr(32) $+ $chr(15),2)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ...-- $+ $chr(32) $+ $chr(15),3)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ....- $+ $chr(32) $+ $chr(15),4)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ..... $+ $chr(32) $+ $chr(15),5)
    var %morse2string = $replace(%morse2string,$chr(15) $+ -.... $+ $chr(32) $+ $chr(15),6)
    var %morse2string = $replace(%morse2string,$chr(15) $+ --... $+ $chr(32) $+ $chr(15),7)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ---.. $+ $chr(32) $+ $chr(15),8)
    var %morse2string = $replace(%morse2string,$chr(15) $+ ----. $+ $chr(32) $+ $chr(15),9)
    return %morse2string
}

alias morse {
    echo -tac info Wrote: $1-
    msg $active [s2m] $string2morse($1-)
}

on ^*:TEXT:[s2m]*:*:{
    haltdef
    echo -tc normal $target < $+ $nick $+ > [m2s] $morse2string($2-)
}
Categories: Code, mIRC Tags: , ,

progress.mrc – Progress Meter

;;;; Progress Meter v1.0.1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Written by:                                                                ;;
;;   Brian Schmidt aka. brianMan aka. b|man.                                  ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Readme / Help ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load this script in mIRC, if you don't know how to do this, then perhaps   ;;
;; you shouldn't be using this script.                                        ;;
;;                                                                            ;;
;; This script is mainly used in other script for creating percentage         ;;
;; progress bars.                                                             ;;
;; Simply use it like this:                                                   ;;
;; $progress(100) and offcourse replace 100 with whatever percentage it needs ;;
;; to fill out.                                                               ;;
;; You can feed it optional parameters for the design of the bar:             ;;
;; $progress( [,filled[,not-filled[,bracket-begin[,bracket-end]]]])   ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Changelog ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; v1.0.1                                                                     ;;
;; * Fixed optional fill-char/not-fill-char.                                  ;;
;; - Removed the possibility to replace the brackets on-the-fly due to the    ;;
;;   fact that it didn't work. Trying to figure out a good way to do this.    ;;
;;                                                                            ;;
;; v1.0.0                                                                     ;;
;; + Initial release.                                                         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alias progress {
    var %prc $round($calc( $$1 / 10),0)
    var %i = 1
    while ($len(%out) < 10) {
        if (%i <= %prc) var %out = %out $+ |
        else var %out = %out $+ .
        inc %i
    }
    if ($2 != $null) var %out = $replace(%out,|,$2)
    if ($3 != $null) var %out = $replace(%out,.,$3)
    ;; Commented out due to not working, see changelog for v1.0.1
    ;; if ($4 != $null && $5 != $null) var %out = $replace(%out,|,$4) var %out = $4 $+ %out $+ $5
    ;; else var %out = $chr(91) $+ %out $+ $chr(93)
    var %out = $chr(91) $+ %out $+ $chr(93)
    return %out
}
Categories: Code, mIRC Tags: , ,

shortDuration.mrc – Simpler, shorter duration

;;;; Short Duration v1.0.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Written by:                                                                ;;
;;   Brian Schmidt aka. brianMan.                                             ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Readme / Help ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load this script in mIRC, if you don't know how to do this, then perhaps   ;;
;; you shouldn't be using this script.                                        ;;
;;                                                                            ;;
;; Very simple script that gives me an extra identifier for making the        ;;
;; duration delivered by mIRC's own $duration shorter and cleaner.            ;;
;; really very customizable                                                   ;;
;;                                                                            ;;
;; Identifiers available:                                                     ;;
;;   $shortDuration()                                                         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Changelog ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; v1.0.0                                                                     ;;
;; + Initial release.                                                         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alias shortDuration {
    return $replace($1-,$chr(32),,secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d,wks,w,wk,w)
}
Categories: Code, mIRC Tags: , ,

simple_amip.mrc – Simple AMIP Announcer

;;;; Simple AMIP Announcer v1.0.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Written by:                                                                ;;
;;   Brian Schmidt aka. brianMan.                                             ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Readme / Help ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load this script in mIRC, if you don't know how to do this, then perhaps   ;;
;; you shouldn't be using this script.                                        ;;
;;                                                                            ;;
;; Simple script to announce in a channel what you're listening to.           ;;
;; The scripts interacts with the AMIP plugin for WinAMP, which can be found  ;;
;; on this address: http://amip.tools-for.net/wiki/                           ;;
;;                                                                            ;;
;; This script has it's 2 default outputs bound to the F3 and Shift+F3 keys.  ;;
;;                                                                            ;;
;; Identifiers available:                                                     ;;
;;   $amip_announce                                                           ;;
;;                                                                            ;;
;; Examples:                                                                  ;;
;;   msg $active $amip_announce                                               ;;
;;   msg $active $amip_announce(xml)                                          ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Changelog ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; v1.0.0                                                                     ;;
;; + Initial release.                                                         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alias F3 /msg $active $amip_announce
alias SF3 /msg $active $amip_announce(xml)
alias amip_announce {
    ;; Check if it's a stream or a file.
    if (($left($dde mPlug var_fn "",7) == http://) || ($left($dde mPlug var_fn "",8) == https://)) {
        var %is_stream = 1
    }
    else {
        var %is_stream = 0
    }

    ;; Fetch the various information from AMIP.
    var %tag.auto = $dde mPlug var_name ""
    var %tag.fullpath = $dde mPlug var_fn ""
    var %tag.extension = $iif(%is_stream == 1,stream,$dde mPlug var_ext "")
    var %tag.artist = $dde mPlug var_1 ""
    var %tag.title = $dde mPlug var_2 ""
    var %tag.album = $dde mPlug var_4 ""
    var %tag.track = $dde mPlug var_3 ""
    var %tag.bitrate = $dde mPlug var_br ""
    ;; These can only be set if it's not a stream.
    if (%is_stream == 0) {
        var %tag.length.sec = $dde mPlug var_sl ""
        var %tag.length.nice = $replace($duration(%tag.length.sec),secs,s,sec,s,mins,m,min,m,hrs,h,hr,h,days,d,day,d,wks,w,wk,w)
        var %tag.size.byte = $file($dde mPlug var_fn "").size
        var %tag.size.nice = $round($csize(%tag.size.byte),2)
        var %tag.size.nice.ext = $csize(%tag.size.byte).ext
    }
    if ($1 == xml) {
        var %output = < $+ %tag.extension
        if ((%tag.artist == $null) || ($len(%tag.artist) == 0) || (%tag.title == $null) || ($len(%tag.title) == 0)) {
            var %output = %output $+ $chr(32) $+ song=" $+ %tag.auto  $+ "
        }
        else {
            var %output = %output $+ $chr(32) $+ artist=" $+ %tag.artist  $+ "
            var %output = %output $+ $chr(32) $+ title=" $+ %tag.title  $+ "
        }
        if ((%tag.album != $null)) {
            var %output = %output $+ $chr(32) $+ album=" $+ %tag.album $+ "
        }
        if ((%tag.track != $null) && ($len(%tag.track) != 0)) {
            var %output = %output $+ $chr(32) $+ track=" $+ %tag.track $+ "
        }
        if (%is_stream == 0) {
            var %output = %output $+ $chr(32) $+ length=" $+ %tag.length.nice $+ "
            var %output = %output $+ $chr(32) $+ size=" $+ %tag.size.nice $+ $chr(32) $+ %tag.size.nice.ext $+ "
        }
        var %output = %output $+ $chr(32) $+ bitrate=" $+ %tag.bitrate $+ "
        if (%is_stream == 1) {
            var %output = %output $+ $chr(32) $+ url=" $+ %tag.fullpath $+ "
        }
        var %output = %output $+ $chr(32) $+ />
    }
    elseif ($1 == action) {
        var %output = is listening to:
        var %output = %output $+ $chr(32) $+ %tag.auto
        if (%is_stream == 0) {
            var %output = %output $+ $chr(32) $+ ( $+ %tag.length.nice $+ )
        }
        else {
            var %output = %output $+ $chr(32) $+ ( $+ %tag.fullpath $+ )
        }
    }
    else {
        var %output = %tag.extension $+ :
        var %output = %output $+ $chr(32) $+ %tag.auto
        if (%is_stream == 0) {
            var %output = %output $+ $chr(32) $+ ( $+ %tag.length.nice $+ )
        }
        else {
            var %output = %output $+ $chr(32) $+ ( $+ %tag.fullpath $+ )
        }
    }
    return %output
}
Categories: Code, mIRC Tags: , ,

hdd.mrc – Show harddrive statistics

;;;; HDD Listing v1.3.1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Written by:                                                                ;;
;;   Brian Schmidt aka. brianMan.                                             ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Readme / Help ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Load this script in mIRC, if you don't know how to do this, then perhaps   ;;
;; you shouldn't be using this script.                                        ;;
;;                                                                            ;;
;; Simple script, wich many others have allready made in various forms and    ;;
;; shapes, that very simple lists all harddrives connected, their sizes,      ;;
;; free space, and a total size/total free space.                             ;;
;;                                                                            ;;
;; Commands available:                                                        ;;
;;   /hdd                                                                     ;;
;;   /hdd total                                                               ;;
;;   /hdd drives                                                              ;;
;;   /hdd C                                                                   ;;
;;                                                                            ;;
;; Identifiers available:                                                     ;;
;;   $hdd                                                                     ;;
;;   $hdd(0).total                                                            ;;
;;   $hdd(0).totalfree                                                        ;;
;;   $hdd(0).totalfreeprc                                                     ;;
;;   $hdd(0).c                                                                ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Changelog ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; v1.3.1                                                                     ;;
;; * Corrected a few $csize to $bytes                                         ;;
;; * Changed the format the HDD info was output                               ;;
;;                                                                            ;;
;; v1.3.0                                                                     ;;
;; + Removed the csise.mrc dependency, now uses built-in $bytes instead       ;;
;;                                                                            ;;
;; v1.2.0                                                                     ;;
;; + Added drive specific calls, both as identifiers and regular output       ;;
;;                                                                            ;;
;; v1.1.0                                                                     ;;
;; - Moved the "Convert Size" to external script "csize.mrc".                 ;;
;; + Added identifiers for use in other scripts.                              ;;
;; + Can now be called with "total" and "drives" options                      ;;
;;                                                                            ;;
;; v1.0.0                                                                     ;;
;; + Initial release.                                                         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alias hdd {
    var %num = 99
    var %i = 0
    if ($len($prop) == 1 || $len($1) == 1) {
        if ($isid == $true) {
            var %HD.tmp = $prop
        }
        else {
            var %HD.tmp = $1
        }
        if ($disk(%HD.tmp)) {
            var %HD.single = $upper(%HD.tmp) $+ : Capacity: $bytes($disk(%HD.tmp).size).suf $+ . Used: $bytes($calc($disk(%HD.tmp).size - $disk(%HD.tmp).free)).suf ( $+ $round($calc(($disk(%HD.tmp).size - $disk(%HD.tmp).free) / $disk(%HD.tmp).size * 100),1) $+ $chr(37) $+ ) Free: $bytes($disk(%HD.tmp).free).suf ( $+ $round($calc($disk(%HD.tmp).free / $disk(%HD.tmp).size * 100),1) $+ $chr(37) $+ )
        }
        else {
            var %HD.single = No such drive: $upper(%HD.tmp) $+ :
        }
    }
    else {
        while ( %num <= 122 ) {
            inc %i
            if ($disk($chr(%num))) {
                if (%num > 99) {
                    var %HD.out = %HD.out -
                }
                var %HD.out = %HD.out $upper($chr(%num)) $+ : $bytes($disk($chr(%num)).free).suf $+ / $+ $bytes($disk($chr(%num)).size).suf ( $+ $round($calc($disk($chr(%num)).free / $disk($chr(%num)).size * 100),1) $+ $chr(37) $+ )
                var %HD.total = $calc(%HD.total + $disk($chr(%num)).size)
                var %HD.totalfree = $calc(%HD.totalfree + $disk($chr(%num)).free)
            }
            inc %num
        }
    }
    if ($isid == $true) {
        if ($prop == total) {
            return %HD.total
        }
        elseif ($prop == totalfree) {
            return %HD.totalfree
        }
        elseif ($prop == totalfreeprc) {
            return $round($calc(%HD.totalfree / %HD.total * 100),1)
        }
        elseif (%HD.single) {
            return %HD.single
        }
        else {
            return %i
        }
    }
    if ($1 == total) {
        msg $active Free total: $bytes(%HD.totalfree).suf $+ / $+ $bytes(%HD.total).suf ( $+ $round($calc(%HD.totalfree / %HD.total * 100),1) $+ $chr(37) $+ )
    }
    elseif ($1 == drives) {
        msg $active Free: %HD.out
    }
    elseif (%HD.single) {
        msg $active %HD.single
    }
    else {
        msg $active Free: %HD.out
        msg $active Free total: $bytes(%HD.totalfree).suf $+ / $+ $bytes(%HD.total).suf ( $+ $round($calc(%HD.totalfree / %HD.total * 100),1) $+ $chr(37) $+ )
    }
}
Categories: Code, mIRC Tags: , ,

class IMDb

<?php
require_once('HTTP/Request.php');
class imdb
{
    var $id             = '';

    var $host           = 'www.imdb.com';
    var $agent          = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
    var $body           = '';

    var $title          = '';
    var $year           = '';
    var $aka            = '';
    var $genre          = '';

    function open($id)
    {
        $this->id = $id;
        $req =& new HTTP_Request('');
        $req->addHeader('User-Agent', $this->agent);
        $req->setURL('http://'.$this->host.'/title/tt'.$this->id.'/');

        if (!PEAR::isError($req->sendRequest())) {
            $this->body = $req->getResponseBody();
        }
    }

    function title()
    {
        if ($this->title == '') {
            $this->title = stristr($this->body, '<title>');
            $title_e = strpos(strtolower($this->title), '</title>');
            $this->title = substr($this->title, 7, $title_e - 7);
            $this->title = substr($this->title, 0, strpos(strtolower($this->title), '(', 0) - 1);
        }
        return $this->title;
    }

    function year()
    {
        if ($this->year == '') {
            $title_e = strpos(strtolower($this->body), ')</title>');
            $this->year = substr($this->body, $title_e - 4, 4);
        }
        return $this->year;
    }

    function aka()
    {
        if ($this->aka == '') {
            $aka_s = strpos(strtolower($this->body), 'also known as');
            if ($aka_s == 0) {
                return array();
            }
            $aka_e = strpos(strtolower($this->body), "\n", $aka_s);
            $arr_aka_all = explode('<br />', str_replace('&#32;', ' ', substr($this->body, $aka_s, $aka_e - $aka_s)));
            array_shift($arr_aka_all);
            foreach ($arr_aka_all as $str_aka) {
                $arr_aka = explode(' (', $str_aka);
                if (count($arr_aka) < 2) {
                    continue;
                }
                $this->aka[] = array(
                    'title'     => $arr_aka[0],
                    'year'      => substr($arr_aka[1], 0, strlen($arr_aka[1])-1),
                    'country'   => (strlen(trim($arr_aka[2])) != 0) ? substr(trim($arr_aka[2]), 0, strlen(trim($arr_aka[2]))-1) : NULL,
                    'comment'   => (strlen(trim($arr_aka[3])) != 0) ? substr(trim($arr_aka[3]), 0, strlen(trim($arr_aka[3]))-1) : NULL
                );
            }
        }
        return $this->aka;
    }

    function genre()
    {
        if ($this->genre == '') {
            $genre_s = strpos(strtolower($this->body), '/sections/genres/');
            if ($genre_s == 0) {
                return array();
            }
            $genre_s = strpos(strtolower($this->body), '>', $genre_s);
            $genre_e = strpos(strtolower($this->body), "\n", $genre_s);
            $this->genre = explode(' / ', substr(strip_tags(substr($this->body, $genre_s + 1, $genre_e - $genre_s + 1)), 0, strlen(strip_tags(substr($this->body, $genre_s + 1, $genre_e - $genre_s + 1))) - 7));
        }
        return $this->genre;
    }

}
?>
Categories: Code, PHP Tags: ,

class SlidePager

<?php
class SlidePager
{
    /**
     * Personalised/simplified version of PEAR::Pager (sliding) class.
     * Example:
     *
     * require_once 'class.SlidePager.php';
     *
     * $params = array(
     *     'pagerData'     => $items,
     *     'urlVar'        => 'num',
     *     'urlPrepend'    => base_url() . '/page',
     *     'urlAppend'     => '/',
     *     'perPage'       => 10,
     *     'buffer'        => 4,
     *     'linkClass'     => 'paginator',
     *     'spanClass'     => 'paginator',
     *     'currentClass'  => 'pagiCurrent'
     * );
     *
     * $pager =& new SlidePager;
     * $pager->Pager($params);
     * $arr_posts = $pager->getData();
     */



    /**
     * @var integer total number of items
     * @access private
     */

    var $totalItems;

    /**
     * @var integer number of items per page
     * @access private
     */

    var $perPage        = 10;

    /**
     * @var integer number of items
     * @access private
     */

    var $buffer         = 4;

    /**
     * @var integer current (default) page number
     * @access private
     */

    var $currentPage    = 1;

    /**
     * @var integer total (default) number of pages
     * @access private
     */

    var $totalPages     = 1;

    /**
     * @var string string/file to prepend current page number
     * @access private
     */

    var $urlPrepend     = '';

    /**
     * @var string string to append current page number
     * @access private
     */

    var $urlAppend      = '';

    /**
     * @var string GET variable name which stores current page number
     * @access private
     */

    var $urlVar         = 'num';

    /**
     * @var array data to be paged
     * @access private
     */

    var $pagerData      = null;

    /**
     * @var string the finished paginator
     * @access public
     */

    var $pager          = '';

    /**
     * @var integer previous page numer
     * @access private
     */

    var $prevPage;

    /**
     * @var integer next page number
     * @access private
     */

    var $nextPage;

    /**
     *
     *
     */

    var $pagerSize;
    var $linkClass      = '';
    var $spanClass      = '';
    var $currentClass   = '';

    function Pager($options)
    {
        foreach ($options as $key => $value) {
            $this->{$key} = $value;
        }
        $this->currentPage = (isset($_REQUEST[$this->urlVar]) && $_REQUEST[$this->urlVar] != 0) ? $_REQUEST[$this->urlVar] : 1;
        $this->pagerSize = (2 * $this->buffer) + 1;
        $this->totalItems = count($this->pagerData);
        $this->totalPages = ceil($this->totalItems / $this->perPage);
        $this->prevPage = ($this->currentPage <= 1) ? NULL : $this->currentPage - 1;
        $this->nextPage = ($this->currentPage >= $this->totalPages) ? NULL : $this->currentPage + 1;
        if ($this->totalPages > 1) {
            if ($this->currentPage > 1) {
                $pagerPrev = '<a href="' . $this->urlPrepend . '1' . $this->urlAppend . '" class="' . $this->linkClass . '" title="First page">&lt;&lt;</a>';
                $pagerPrev .= '<a href="' . $this->urlPrepend . $this->prevPage . $this->urlAppend . '" class="' . $this->linkClass . '" title="Previous page (' . $this->prevPage . ')">&lt;</a>';
            }
            else {
                $pagerPrev = '<span class="' . $this->spanClass . '">&lt;&lt;</span>';
                $pagerPrev .= '<span class="' . $this->spanClass . '">&lt;</span>';
            }

            if ($this->currentPage < $this->totalPages) {
                $pagerNext = '<a href="' . $this->urlPrepend . $this->nextPage . $this->urlAppend . '" class="' . $this->linkClass . '" title="Next page (' . $this->nextPage . ')">&gt;</a>';
                $pagerNext .= '<a href="' . $this->urlPrepend . $this->totalPages . $this->urlAppend . '" class="' . $this->linkClass . '" title="Last page">&gt;&gt;</a>';
            }
            else {
                $pagerNext = '<span class="' . $this->spanClass . '">&gt;</span>';
                $pagerNext .= '<span class="' . $this->spanClass . '">&gt;&gt;</span>';
            }

            if (($this->currentPage - $this->buffer) <= 1) {
                $pagerOffset = 1;
                $pagerMax = ($this->totalPages < $this->pagerSize) ? $this->totalPages : $this->pagerSize;
            }
            elseif (($this->currentPage + $this->buffer) > $this->totalPages) {
                $pagerOffset = ((($this->totalPages - $this->pagerSize) + 1) <= 1) ? 1 : (($this->totalPages - $this->pagerSize) + 1);
                $pagerMax = (($this->pagerSize + $pagerOffset) > $this->totalPages) ? $this->totalPages : ($this->pagerSize + $pagerOffset);
            }
            else {
                $pagerOffset = (($this->currentPage + $this->buffer) > $this->totalPages) ? ($this->totalPages - ($this->pagerSize + 1)) : $this->currentPage - $this->buffer;
                $pagerMax = (($this->pagerSize + $pagerOffset) > $this->totalPages) ? $this->totalPages : (($this->pagerSize + $pagerOffset) - 1);
            }

            $pagerNumbers = '';
            for ($i = $pagerOffset; $i <= $pagerMax; $i++) {
                $pagerNumbers .= ($i == $this->currentPage) ? '<span class="' . $this->currentClass . '">' . $i . '</span>' : '<a href="' . $this->urlPrepend . $i . $this->urlAppend . '" class="' . $this->linkClass . '" title="Go to page ' . $i . '">' . $i . '</a>';
            }
            $this->pager = $pagerPrev . $pagerNext . $pagerNumbers;
        }
    }

    function GetData()
    {
        $itemsOffset = ($this->currentPage * $this->perPage) - $this->perPage;
        $itemsMax = (($itemsOffset + $this->perPage) > $this->totalItems) ? $this->totalItems : ($itemsOffset + $this->perPage);
        for ($i = $itemsOffset; $i < $itemsMax; $i++) {
            $data[] = $this->pagerData[$i];
        }
        return $data;
    }
}
?>
Categories: Code, PHP Tags: ,

function array_natsort()

<?php
/**
 * @author Brian Schmidt
 * @version 1.0
 * @return array
 * @param $arrData Array containing data to sort
 * @param $strIndex Name of column to use as an index
 * @param $strSortBy Column to sort the array by
 * @param $strSortType String containing either asc or desc [default to asc]
 * @access public
 * @desc Naturally sorts an array using the column $strSortBy
 * @example $arr_sorted = array_natsort(array(array('a' => 10, 'b' => 'foo'), array('a' => 2, 'b' => 'foo'), array('a' => 11, 'b' => 'foo')), 'a', 'a');
 */

function array_natsort($arrData, $strIndex, $strSortBy, $strSortType = FALSE)
{
    if (!is_array($arrData) || !$strIndex || !$strSortBy) {
        return $arrData;
    }
    $arrSort = $arrResult = array();
    foreach ($arrData as $arrRow) {
        $arrSort[$arrRow[$strIndex]] = $arrRow[$strSortBy];
    }
    natsort($arrSort);
    if ($strSortType == "desc") {
        arsort($arrSort);
    }
    foreach ($arrSort as $arrSortKey => $arrSorted) {
        foreach ($arrData as $arrOriginal) {
            if ($arrOriginal[$strIndex]==$arrSortKey) {
                array_push($arrResult, $arrOriginal);
            }
        }
    }
    return $arrResult;
}
?>
Categories: Code, PHP Tags: ,

function calc_age()

<?php
/**
 * @author Brian Schmidt
 * @version 1.0
 * @return array
 * @param string $str_birthday
 * @access public
 * @desc Returns the current age from a rough calculation of the birthdate.
 * @example echo calc_age('1976-12-13 19:00');
 */

function calc_age($str_birthday)
{
    if (!$str_birthday) {
        return FALSE;
    }
    $int_age = floor((time()-strtotime($str_birthday))/(60*60*24*365.22222222222));
    return $int_age;
}
?>
Categories: Code, PHP Tags: ,

function create_thumb()

<?php
/**
 * @author Brian Schmidt
 * @version 1.0
 * @return void
 * @param string $src_img
 * @param string $dst_img
 * @param integer $max_w
 * @param integer $max_h
 * @param array $bg
 * @access public
 * @uses imageCopyResampleBicubic()
 * @desc Creates a thumbnail dynamically, with correct aspect ratio.
 * @example create_thumb('old_img.png', 'new_img.png', '100', '100');
 */

function create_thumb($src_img, $dst_img, $max_w, $max_h, $bg = NULL)
{
    list($src_w, $src_h, $src_type, $src_attr) = getImageSize($src_img);
    if ($src_w > $max_w || $src_h > $max_h) {
        $ratio_w = $src_w / $max_w;
        $ratio_h = $src_h / $max_h;
        $dst_w = ($ratio_w > $ratio_h) ? $max_w : ($src_w / $ratio_h);
        $dst_h = ($ratio_w > $ratio_h) ? ($src_h / $ratio_w) : $max_h;
        $start_x = ($bg) ? (($max_w - $dst_w) / 2) : 0;
        $start_y = ($bg) ? (($max_h - $dst_h) / 2) : 0;
        switch ($src_type) {
            case 1:
                $img_src = imageCreateFromGif($src_img);
                break;
            case 2:
                $img_src = imageCreateFromJpeg($src_img);
                break;
            case 3:
                $img_src = imageCreateFromPng($src_img);
                break;
            case 6:
            default:
                $img_src = imageCreateFromGd2($src_img);
        }
        if (imageIsTrueColor($img_src)) {
            $img_dst = ($bg) ? @imageCreateTrueColor($max_w, $max_h) : @imageCreateTrueColor($dst_w, $dst_h);
        } else {
            $img_dst = ($bg) ? @imageCreate($max_w, $max_h) : @imageCreate($dst_w, $dst_h);
        }
        if ($bg) {
            $fill = imageColorAllocate($img_dst, $bg[0], $bg[1], $bg[2]);
            imageFill($img_dst, 0, 0, $fill);
        }
        imageCopyResampleBicubic($img_dst, $img_src, $start_x, $start_y, 0, 0, $dst_w, $dst_h, $src_w, $src_h);

        switch ($src_type) {
            case 1:
                imageGif($img_dst, $dst_img);
                break;
            case 2:
                imageJpeg($img_dst, $dst_img);
                break;
            case 3:
                imagePng($img_dst, $dst_img);
                break;
            case 6:
            default:
                imageGd2($img_dst, $dst_img);
        }

        imageDestroy($img_dst);
    } else {
        copy($src_img, $dst_img);
    }
}
?>
Categories: Code, PHP Tags: ,