All pastes #205543 Raw Edit

Untitled

public text v1 · immutable
#205543 ·published 2006-10-16 21:54 UTC
rendered paste body
alias bash { dialog -m bash bash }
dialog Bash {
  title "Bash.Org"
  size -1 -1 174 108
  option dbu
  button "Random", 1, 8 39 35 11
  edit "", 2, 49 23 120 77, vsbar multi
  edit "Quote Info Soon To Come", 3, 4 6 165 12, disable center
  edit "", 7, 8 59 35 10
  button ">", 6, 18 73 14 12
  box "Get Quote", 4, 4 23 43 77
  menu "File", 8
  item "Quit", 9, 8, ok
}
on *:DIALOG:bash:sclick:*:{
  if ($did == 1) {
    did -r bash 2
    bashgetrand 
  }
  elseif ($did == 6) {
    did -r bash 2
    bashgetnum $did(bash,7).text
  }
}
alias bashgetrand {
  set %bash.get.type rand
  if ($sock(0909478bashget)) { sockclose 0909478bashget }
  sockopen 0909478bashget stirk.org 80
}
alias bashgetnum {
  set %bash.get.type $1
  if ($sock(0909478bashget)) { sockclose 0909478bashget }
  sockopen 0909478bashget stirk.org 80
}
on *:SOCKOPEN:0909478bashget:{
  sockwrite -n $sockname GET /parsers/bash.php?id= $+ %bash.get.type HTTP/1.1 
  sockwrite -n $sockname Host: www.stirk.org $+ $crlf $+ $crlf 
}
on *:SOCKREAD:0909478bashget:{
  var %read
  sockread %read
  if (*<br />* iswm %read) {
    did -a Bash 2 $nohtml(%read) $crlf
  }
}
alias nohtml {
  var %nohtml = $regsubex($regsubex($1,/<.+?>/g,),/&#(\d+);/g,$fixentities(\t))
  %nohtml = $replacecs(%nohtml,&quot;,",&apos;,',&amp;,&,&lt;,<,&gt;,>,&nbsp;,$chr(160),&iexcl;,¡,&curren;,¤,&cent;,¢,&pound;,£,&yen;,¥,&brvbar;,¦,&sect;,§)
  %nohtml = $replacecs(%nohtml,&uml;,¨,&copy;,©,&ordf;,ª,&laquo;,«,&not;,¬,&shy;,-,&reg;,®,&trade;,™,&macr;,¯,&deg;,°,&plusmn;,±,&sup2;,²,&sup3;,³,&acute;,´)
  %nohtml = $replacecs(%nohtml,&micro;,µ,&para;,¶,&middot;,·,&cedil;,¸,&supl;,¹,&ordm;,º,&raquo;,»,&frac14;,¼,&frac12;,½,&frac34;,¾,&iquest;,¿,&times;,×)
  %nohtml = $replacecs(%nohtml,&divider;,÷)
  %nohtml = $replacecs(%nohtml,&Agrave;,À,&Aacute;,Á,&Acirc;,Â,&Atilde;,Ã,&Auml;,Ä,&Aring;,Å,&Aelig;,Æ,&Ccedil;,Ç,&Egrave;,È,&Eacute;,É,&Ecirc;,Ê)
  %nohtml = $replacecs(%nohtml,&Euml;,Ë,&Igrave;,Ì,&Iacute;,Í,&Icirc;,Î,&Iuml;,Ï,&ETH;,Ð,&Ntilde;,Ñ,&Ograve;,Ò,&Oacute;,Ó,&Ocirc;,Ô,&Otilde;,Õ,&Ouml;,Ö)
  %nohtml = $replacecs(%nohtml,&Oslash;,Ø,&Ugrave;,Ù,&Ucirc;,Ú,&Uuml;,Ü,&Yacute;,Ý,&THORN;,Þ,&agrave;,à,&aacute;,á,&acirc;,â,&atilde;,ã,&auml;,ä,&aring;,å)
  %nohtml = $replacecs(%nohtml,&aelig;,æ,&ccedil;,ç,&agrave;,è,&eacute;,é,&ecirc;,ê,&euml;,ë,&igrave;,ì,&iacute;,í,&icirc;,î,&iuml;,ï,&eth;,ð,&ntilde;,ñ)
  %nohtml = $replacecs(%nohtml,&ograve;,ò,&oacute;,ó,&ocirc;,ô,&otilde;,õ,&ouml;,ö,&oslash;,ø,&ugrave;,ù,&uacute;,ú,&ucirc;,û,&uuml;,ü,&yacute;,ý,&thorn;,þ)
  %nohtml = $replacecs(%nohtml,&yuml;,ÿ,&OElig;,Œ,&celig;,œ,&Scaron;,Š,&scaron;,š,&Yuml;,Ÿ,&circ;,ˆ,&tilde;,˜,&ndash;,–,&mdash;,—,&lsquo;,‘,&rsquo;,’)
  %nohtml = $replacecs(%nohtml,&sbquo;,‚,&ldquo;,“,&rdquo;,”,&bdquo;,„,&dagger;,†,&Dagger;,‡,&hellip;,…,&permil;,‰,&lsaquo;,‹,&rsaquo;,›,&euro;,€)
  return %nohtml 
}
alias -l fixentities {
  if ($1 < 128) return $chr($1)
  elseif ($1 isnum 128-2047) return $chr($calc(192 + ($1 / 64))) $+ $chr($calc(128 + ($1 % 64)))
  elseif ($1 isnum 2048-65535) return $+($chr($calc(224 + ($1 / 4096))),$chr($calc(128 + (($1 / 64) % 64))),$chr($calc(128 + ($1 % 64))))
}