mIRC Control Panel - In HTML

By TMFKSOFT on Apr 23, 2013

I haven't posted any mIRC Scripts for a long time.
A VERY LONG TIME.

So in the spirit of my old Statistics Script I bring you a full Control Panel for mIRC,
Im still working on it so dont expect the world!

What does it HAVE:

  • Self Hosted WebServer - No Extra stuff needed it hosts its self
  • Ability to list all networks
  • Ability to list all joined channels per network
  • Ability to list all users in each channel
  • Ability to return channel topics and modes as well as edit channel Topics.
  • Ability to join and part channels
  • Ability to list private messages per server

Whats upcoming?

  • Login system
  • Anything else you suggest

Please Note: Due to the lack of a login system this control panel allows public access to your mIRC Client this will be sorted in future versions.

Ok. Cool. So. where do I start?

Load the script up into mIRC and configure it you may want to change the port to something completely random to avoid people dropping across the panel without meaning to. When you've configured it use /cpanel to start it,
You can type /cpanel or /cpanel stop to stop it again.

Here is a screenshot: http://d.pr/i/XbRI

I hope to release a proper version that will look even better and allow you to add to it.

Have fun!
Thankies.
Thomas Edwards

; mIRC Control Panel
; By Thomas Edwards 2013
; Using this script you can control your mIRC from any web enabled device.

; Instructions:
; Set your admin username and your password below and type /cpanel to start
; Typing /cpanel again will turn the panel off.
; You can edit what IP or Port it listens on.
; You can also enable a stats mode to enable public users to view where you are connected
; and what channels you are currently in.

alias cpanel_config {
  ; CPanel Configuration
  set %cpanel.user Admin
  set %cpanel.pass Pass
  set %cpanel.host 127.0.0.1
  set %cpanel.port 8080

  ; The following Variable toggles information in the @cpanel window.
  set %cpanel.quiet 0

  ; CPanel Vars - Ignore these
  set %cpanel.running 0
  set %cpanel.conn 0
}

alias cpanel {
  if ($1 == start) {
    if (%cpanel.running == 1) {
      echo mIRC Control Panel is already running!
    }
    else {
      cpanel_start
    }
  }
  else if ($1 == stop) {
    if (%cpanel.running == 0) {
      echo mIRC Control Panel is not running! You can't stop what you havent started!
    }
    else {
      cpanel_stop
    }
  }
  else if ($1 == config) {
    if (%cpanel.quiet == 0) {
      echo Loading mIRC Control Panel configuration.
    }
    cpanel_config
  }
  else {
    if (%cpanel.running == 0) {
      cpanel_start
    }
    else {
      cpanel_stop
    }
  }
}

alias cpanel_start {
  cpanel_config
  if (%cpanel.quiet == 0) {
    echo mIRC Control Panel by Thomas Edwards Started.
    echo =!= Listening on %cpanel.host $+ : $+ %cpanel.port =!=
    echo =!= Web URL: http:// $+ %cpanel.host $+ : $+ %cpanel.port $+ /login =!=
    ; We dont actually do anything till now! :P
    socklisten -d %cpanel.host cpanel_listener %cpanel.port
  }
  set %cpanel.running 1
}
alias cpanel_stop {
  if (%cpanel.quiet == 0) {
    echo mIRC Control Panel by Thomas Edwards halted.
    if ($1 == panel) {
      echo =!= Stopped via Web Panel =!=
    }
  }
  set %cpanel.running 0
}

; Now for the madness!

on 1:socklisten:cpanel_listener:{
  sockaccept cpanel_conn $+ %cpanel.conn
  if (%cpanel.quiet == 0) {
    echo =!= Accepted connection to mIRC Control Panel CCID cpanel_conn $+ %cpanel.conn =!=
  }
  inc %cpanel.conn
}
on 1:sockread:cpanel_conn*:{
  var Úta
  sockread Úta
  tokenize 32 Úta
  var %url $lower($2)
  echo =!= GOT: Úta
  if ($gettok(%url,1,47) == home || %url == $chr(47)) {
    sockwrite -n $sockname $cpanel_code(200)
    cpanel_head $sockname
    sockwrite -n $sockname <h1>Network List</h1>
    if ($scon(0) == 0) {
      sockwrite -n Your client is not connected to any IRC Networks!
    }
    else {
      var %i 1
      while (%i <= $scon(0)) {
        if ($scon(%i).status == connected) {
          sockwrite -n $sockname Connection # $+ %i - <a href="/network/ $+ %i $+ "> $+ $scon(%i).network $+ </a> - <a href="/network/ $+ %i $+ /dc">Disconnect</a></br>
        }
        else {
          sockwrite -n $sockname Connection # $+ %i - <i>Not connected</i></br>
        }
        inc %i
      }
    }
    cpanel_footer $sockname
  }
  else if ($gettok(%url,1,47) == network) {
    ; Asking for something network related.
    var %netid $gettok(%url,2,47)
    var ¬tion $gettok(%url,3,47)
    if (¬tion == $null || ¬tion == view) {
      sockwrite -n $sockname $cpanel_code(200)
      cpanel_head $sockname
      sockwrite -n $sockname <h3>Details regarding the network ' $+ $scon(%netid).network $+ '</h3>
      sockwrite -n $sockname <hr/><h3>Your Details</h3>
      scon %netid
      sockwrite -n $sockname Your Nickname: $nick
      sockwrite -n $sockname <br/> Your Host: $host
      sockwrite -n $sockname <br/> Channel Count: $chan(0)
      sockwrite -n $sockname <hr/>
      sockwrite -n $sockname <h3>Channels you currently reside in:</h3>
      if ($chan(0) > 0) {
        var %i 1
        while (%i <= $chan(0)) {
          sockwrite -n $sockname <a href="/channel/ $+ %netid $+ / $+ %i $+ /view"> $+ $chan(%i) $+ </a> - Total Users: $nick($chan(%i),0) - <a href="/channel/ $+ %netid $+ / $+ %i $+ /part">Part Channel</a> <br>
          inc %i
        }
      }
      else {
        sockwrite -n $sockname <i>You're not in any channels!</i>
      }
      sockwrite -n $sockname <hr><form action="/join/ $+ %netid $+ /"> Join a channel: #<input name="c"/> <button type="submit">Join</button></form>
      sockwrite -n $sockname <hr/><h3>Query Windows</h3>
      if ($query(0) > 0) {
        var %i 1
        while (%i <= $query(0)) {
          sockwrite -n $sockname <a href="/query/ $+ %netid $+ / $+ %i $+ "> $+ $query(%i) $+ </a> - $line($query(%i),0) Lines <br/>
          inc %i
        }
      }
      else {
        sockwrite -n $sockname <i>You have no Query Windows Open</i>
      }
      cpanel_footer $sockname
    }
    else if (¬tion == dc) {
      if ($scon(%netid).status == connected) {
        scon %netid
        quit Disconnected - Action Taken via mIRC Control Panel
        if (%cpanel.quiet == 0) {
          echo =!= Connection Terminated via mIRC Control Panel =!=
        }
      }
      sockwrite -n $sockname $cpanel_code(200)
      cpanel_redirect $sockname /
    }
  }
  else if ($gettok(%url,1,47) == scripts) {
    var %scid $gettok(%url,2,47)
    if (%scid == $null) {
      sockwrite -n $sockname $cpanel_code(200)
      cpanel_head $sockname
      sockwrite -n $sockname <h3>Loaded Scripts</h3>
      if ($script(0) > 0) {
        sockwrite -n $sockname <b>You have $script(0) scripts loaded.</b><br>
        var %i 1
        while (%i < $script(0)) {
          sockwrite -n $sockname $chr(35) $+ %i  <a href="/scripts/ $+ %i $+ "> $+ $script(%i) $+ </a> - <a href="/scripts/ $+ %i $+ /unload">Unload</a><br/>
          inc %i
        }
        sockwrite -n $sockname $chr(35) $+ $script(0) - $script - <b>Current Script</b>
      }
      else {
        sockwrite -n $sockname <b>You have no Scripts currently loaded.</b>
      }
    }
    else {
      sockwrite -n $sockname $cpanel_code(200)
      cpanel_head $sockname
      sockwrite -n $sockname <h3>Viewing $script(%scid) $+ </h3>
      sockwrite -n $sockname <div id="chat" style="width:100% $+ $chr(37) $+ ;height:60 $+ $chr(37) $+ ;border:1px solid black;overflow:scroll;"><table>
      var %i 2
      while (%i <= $lines($script(%scid))) {
        sockwrite -n $sockname <tr><td style="background:silver;text-align:center;"> $+ %i $+ </td><td> $+ $readini($script(%scid),script,$calc(%i-2)) $+ </td></tr>
        inc %i
      }
      sockwrite -n $sockname </table></div>

    }
    cpanel_footer $sockname
  }
  else if ($gettok(%url,1,47) == query) {
    var %netid $gettok(%url,2,47)
    var %quid $gettok(%url,3,47)
    scon %netid
    sockwrite -n $sockname $cpanel_code(200)
    cpanel_head $sockname
    if ($query(%quid)) {
      sockwrite -n $sockname <center><h3><a href="/network/ $+ %netid $+ /"> $+ $network $+ </a> > $query(%quid) </h3></center><hr/>
      sockwrite -n $sockname <div id="chat" style="width:100% $+ $chr(37) $+ ;height:60 $+ $chr(37) $+ ;border:1px solid black;overflow:scroll;float:left;"><pre>
      var %i 1
      while (%i <= $line($query(%quid),0)) {
        var %line $line($query(%quid),%i)
        var %line $replace(%line,$chr(60),&#60;,$chr(62),&#62;)
        sockwrite -n $sockname %line $+ $crlf
        inc %i
      }
      sockwrite -n $sockname </pre></div>

    }
    else {
      sockwrite -n $sockname <h3>No Such Query Window!</h3>
    }
  }
  else if ($gettok(%url,1,47) == channel) {
    ; Channel stuff requested
    var %netid $gettok(%url,2,47)
    var %cid $gettok(%url,3,47)
    var ¬tion $gettok(%url,4,47)
    if (¬tion == part) {
      scon %netid
      part $chan(%cid) Parted via mIRC Control Panel
      echo Parted $chan(%cid)
      sockwrite -n $sockname $cpanel_code(200)
      cpanel_redirect $sockname /network/ $+ %netid
    }
    else if (¬tion == view) {
      scon %netid
      sockwrite -n $sockname $cpanel_code(200)
      cpanel_head $sockname
      sockwrite -n $sockname <center><h3> $+ <a href="/network/ $+ %netid $+ "> $+ $network $+ </a> > $chan(%cid) $+ </h3></center>
      sockwrite -n $sockname <hr/><b>Mode(s):</b><small> $chan(%cid).mode </small>
      sockwrite -n $sockname <br/><b>User Count:</b><small> $nick($chan(%cid),0) </small>
      sockwrite -n $sockname <br/><b>Topic:</b><small> $chan(%cid).topic
      if ($me isop $chan(%cid)) {
        sockwrite -n $sockname  <a href="/channel/ $+ %netid $+ / $+ %cid $+ /topic">(Change Topic)</a>
      }
      sockwrite -n $sockname </small></b>
      sockwrite -n $sockname <div id="chat" style="width:80 $+ $chr(37) $+ ;height:60 $+ $chr(37) $+ ;border:1px solid black;overflow:scroll;float:left;"><pre>
      var %i 1
      while (%i <= $line($chan(%cid),0)) {
        var %line $line($chan(%cid),%i)
        var %line $replace(%line,$chr(60),&#60;,$chr(62),&#62;)
        sockwrite -n $sockname %line $+ $crlf
        inc %i
      }
      sockwrite -n $sockname </pre></div>
      sockwrite -n $sockname <div style="width:19 $+ $chr(37) $+ ;height:60 $+ $chr(37) $+ ;border:1px solid black;overflow:scroll;float:right;text-align:right;">
      var %i 1
      while (%i <= $nick($chan(%cid),0)) {
        sockwrite -n $sockname $nick($chan(%cid),%i)).pnick </br>
        inc %i
      }
      sockwrite -n $sockname </div>
      sockwrite -n $sockname <script> var objDiv = document.getElementById("chat"); objDiv.scrollTop = objDiv.scrollHeight; </script>
      cpanel_footer $sockname
    }
    else if (¬tion == topic) {
      sockwrite -n $sockname $cpanel_code(200)
      cpanel_head $sockname
      sockwrite -n $sockname <h3>Change topic in $chan(%cid) </h3>
      if ($me isop $chan(%cid)) {
        sockwrite -n $sockname <form action="/channel/ $+ %netid $+ / $+ %cid $+ /ctopic/">
        sockwrite -n $sockname <b>Topic:</b> <input size="100" name="t" value=" $+ $chan(%cid).topic $+ "/> <button type="submit">Update</button></form>
      }
      else {
        sockwrite -n $sockname You need at least OP to change the topic in $chan(%cid) $+ !
      }
      cpanel_footer $sockname
    }
    else {
      sockwrite -n $sockname $cpanel_code(404)
      sockwrite -n $sockname Unknown action ¬tion $+ !
    }
  }
  else if ($gettok(%url,1,47) == join) {
    var %netid $gettok(%url,2,47)
    var %channel $gettok($gettok(%url,3,47),2,61)
    scon %netid
    if (%cpanel.quiet == 0) { echo =!= Joining # $+ %channel =!= }
    join $chr(35) $+ %channel
    sockwrite -n $sockname $cpanel_code(200)
    cpanel_redirect $sockname /network/ $+ %netid

  }
  else {
    sockwrite -n $sockname $cpanel_code(404)
    sockwrite -n $sockname <h1>404 Not Found</h1>
    sockwrite -n $sockname The Page you are looking for is not here!
    sockwrite -n $sockname <br/> We couldnt find <b> $+ $gettok(%url,1,47) $+ </b>
    cpanel_footer $sockname
  }
  sockclose $sockname
}
alias cpanel_code {
  if ($1 == 404) {
    var %ret HTTP/1.1 404 Not Found
  }
  else if ($1 == 200) {
    var %ret HTTP/1.1 200 OK
  }
  else {
    var %ret HTTP/1.1 $1 Responded
  }
  var %ret %ret $+ $crlf $+ Content-Type: text/html
  ;var %ret %ret $+ $crlf $+ WWW-Authenticate: Basic realm="mIRC Control Panel"
  var %ret %ret $+ $crlf $+ $crlf
  return %ret
}
alias cpanel_css {
  sockwrite -n $1 <style>
  sockwrite -n $1 body $chr(123) font-family:"Arial"; $chr(125)
  sockwrite -n $1 </style>
}
alias cpanel_head {
  sockwrite -n $1 <title>mIRC Control Panel</title>
  cpanel_css $1
  sockwrite -n $1 <center>mIRC Control Panel</center>
  sockwrite -n $1 <hr />
  sockwrite -n $1 <center><a href="/home">Home</a> <!-- <a href="/scripts">Loaded Scripts</a> --> - <a href="/logout">Logout</a></center>
  sockwrite -n $1 <hr/>
}
alias cpanel_footer {
  sockwrite -n $1 <hr />
  sockwrite -n $1 <center><small>mIRC Control Panel by Thomas Edwards &copy; 2013</small></center>
}
alias cpanel_redirect {
  cpanel_css $1
  sockwrite -n $1 <h1>Redirecting</h1>
  sockwrite -n $1 If you are not redirected <a href=" $+ $2- $+ ">Click Here</a>!
  sockwrite -n $1 <meta http-equiv="refresh" content="0.1;URL=' $+ $2- $+ '">
}

Comments

Sign in to comment.
ovelayer   -  Apr 23, 2013

very nice work!

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.