**!!! ACHTUNG - evtl. veraltet - ACHTUNG !!!** Diese Seite wurde zuletzt am 9. Juli 2014 um 10:34 Uhr geƤndert. Voraussetzungen: * rubygems * gem install camping markaby kick_ass.rb: #!/usr/bin/ruby require "httpauth" module BasicAuth def service( *a ) @username, password = HTTPAuth::Basic.get_credentials( @env ) app = Kernel.const_get( self.class.name.gsub( /^(\w+)::.+$/, '\1' ) ) if @authenticated = app.const_get( :Authentication ).authenticate( @username, password ) s = super( *a ) else @status = 401 @headers[['Content-type']] = "text/plain" @headers[['WWW-Authenticate']] = HTTPAuth::Basic.pack_challenge( app.to_s ) @body = 'Unauthorized' s = self end s end end Camping.goes :Patty module Patty include BasicAuth class Authentication class << self def authenticate( username, password ) [[|username, password ]] == [[|"patty", "kickass" ]] end end end module Controllers class Index < R "/" def get render :index end end class Knee < R "/knee" def get system( "kill -INT $(pgrep gedit) > /dev/null 2>&1" ) redirect Index end end class Face < R "/face" def get system( "/usr/local/bin/truecrypt --text --dismount --force > /dev/null 2>&1" ) redirect Index end end class Chuck < R "/chuck_norris" def get system( "sudo /sbin/shutdown -h now > /dev/null 2>&1" ) redirect Index end end end module Views def layout xhtml_transitional do head do title { "CopKickAss" } end body { self << yield } end end def index h1 "CopKickAss" p "Welcome to my site for a home visit by the cops!" p "How do you want to kick?" ul do li { a "Roundhouse kick to the knee", :href => "knee" } li { a "Roundhouse kick to the face", :href => "face" } li { a "Roundhouse kick by Chuck Norris", :href => "chuck_norris" } end end end end