commit 7516daff37ce9bc9c9cf5c7502e45fb751fdf484 Author: anon Date: Thu May 16 01:07:31 2024 +0200 init diff --git a/main.tcl b/main.tcl new file mode 100755 index 0000000..134b449 --- /dev/null +++ b/main.tcl @@ -0,0 +1,89 @@ +#!/usr/bin/tclsh +package require http +package require Tk + +set top "XKic" + +proc charArtimetric {char operator} { + set asciiValue [scan $char %c] + if {$operator == "+"} { + if {$asciiValue == "z"} { return [list "A" 1] } + if {$asciiValue == "Z"} { return [list "a" 1] } + } + if {$operator == "-"} { + if {$asciiValue == "a"} { return [list "Z" 1] } + if {$asciiValue == "A"} { return [list "z" 1] } + } + return [list [format %c [expr $asciiValue $operator 1]] 0] +} + +proc stringArtimetric {str operator n} { + set rReverse "" + for {set carry 0; set i [expr [string length $str] - 1]} {$i >= 0} {incr i -1} { + set c [string index $str $i] + for {set h 0} {$h < [expr 1 + $carry]} {incr h} { + set rc [charArtimetric $c $operator] + set c [lindex $rc 0] + } + append rReverse $c + if [lindex $rc 1] { + set $carry 1 + } else { + for {set h [expr $i - 1]} {$h >= 0} {incr h -1} { + append rReverse [string index $str $h] + } + break + } + } + set r [string reverse $rReverse] + return $r +} + +proc get0x0page {page} { + set baseUrl "http://0x0.st/" + set extensionList [list ".txt" ".log"] + + .output delete 1.0 end + + foreach extension $extensionList { + set url "" + append url $baseUrl $page $extension + + .controls.url configure -text $url + set response [http::geturl $url] + + if {[http::ncode $response] == 200} { + .output insert end [http::data $response] + return + } + } + + .output insert end "**Missing page**" +} + +proc previous {} { + set ::top [stringArtimetric $::top - 1] + get0x0page $::top +} + +proc next {} { + set ::top [stringArtimetric $::top + 1] + get0x0page $::top +} + +wm title . "0x0.st peeper" + +text .output +pack .output -expand 1 -fill both + +frame .controls +pack .controls -side bottom +button .controls.previous -text "Previous" -command previous +button .controls.next -text "Next" -command next +label .controls.url +pack .controls.previous -side left +pack .controls.next -side left +pack .controls.url -side right + + +get0x0page $::top