<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: http code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 04:22:55 GMT</pubDate>
    <description>DZone Snippets: http code</description>
    <item>
      <title>Seamlessly return a string from http or https feeds</title>
      <link>http://snippets.dzone.com/posts/show/5624</link>
      <description>// This class uses URI module to detect regular or secure links, and returns the response as a string, in my case to pass onto a feed parser like simple-rss. I'm working on a simple http authentication addon.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#beef.&lt;br /&gt;require 'net/http'&lt;br /&gt;require 'net/https'&lt;br /&gt;require 'simple-rss'&lt;br /&gt;&lt;br /&gt;class SeamlessFeed&lt;br /&gt;  def initialize(url,user=nil,password=nil)&lt;br /&gt;    @url = URI.parse(url)&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def output&lt;br /&gt;    if self.is_secure?&lt;br /&gt;      http = Net::HTTP.new(@url.host, 443)&lt;br /&gt;      http.use_ssl = true&lt;br /&gt;      http.start do |http|&lt;br /&gt;        request = Net::HTTP::Get.new(@url.path)&lt;br /&gt;        @response = http.request(request)&lt;br /&gt;        @response.value&lt;br /&gt;      end&lt;br /&gt;    else&lt;br /&gt;      @response = Net::HTTP.get_response(@url) #Why can't they all be like this, eh?&lt;br /&gt;    end&lt;br /&gt;    return @response.body&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def is_readable?&lt;br /&gt;    feed = SimpleRSS.parse(self.output)&lt;br /&gt;    return true unless feed.channel.items.size &lt; 1&lt;br /&gt;  rescue SimpleRSSError&lt;br /&gt;    return false&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;protected&lt;br /&gt;  def is_secure?&lt;br /&gt;    @url.scheme == 'https'&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 09 Jun 2008 20:15:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5624</guid>
      <author>m0wfo (Chris Mowforth)</author>
    </item>
    <item>
      <title>Creating a bucket in Amazon S3 through an irb session</title>
      <link>http://snippets.dzone.com/posts/show/5441</link>
      <description>1) Log into an irb session, and enter your S3 login details.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'rubygems'&lt;br /&gt;require 'aws/s3'&lt;br /&gt;&lt;br /&gt;  AWS::S3::Base.establish_connection!(&lt;br /&gt;    :access_key_id     =&gt; 'REPLACE_ME',&lt;br /&gt;    :secret_access_key =&gt; 'REPLACE_ME'&lt;br /&gt;  )&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;output:&lt;br /&gt;=&gt; #&lt;AWS::S3::Connection:0xb75e0594 @http=#&lt;Net::HTTP s3.amazonaws.com:80 open=false&gt;, @secret_access_key="", @options={:server=&gt;"s3.amazonaws.com", :access_key_id=&gt;"", :port=&gt;80, :secret_access_key=&gt;"", :persistent=&gt;true}, @access_key_id="19S45GYAGWK8DC2B8VG2"&gt;&lt;br /&gt;&lt;br /&gt;2) Browse the existing buckets.&lt;br /&gt;&lt;code&gt;AWS::S3::Service.buckets&lt;/code&gt;&lt;br /&gt;output:&lt;br /&gt;=&gt; [#&lt;AWS::S3::Bucket:0xb75cc850 @object_cache=[], @attributes={"name"=&gt;"ogg.twitteraudio.com", "creation_date"=&gt;Sat Apr 26 10:40:16 UTC 2008}&gt;, #&lt;AWS::S3::Bucket:0xb75cc83c @object_cache=[], @attributes={"name"=&gt;"t1000", "creation_date"=&gt;Fri Apr 25 21:35:21 UTC 2008}&gt;, #&lt;AWS::S3::Bucket:0xb75cc814 @object_cache=[], @attributes={"name"=&gt;"t2000", "creation_date"=&gt;Fri Apr 25 21:53:15 UTC 2008}&gt;]&lt;br /&gt;&lt;br /&gt;3) Browse the buckets in a programmatical way.&lt;br /&gt;&lt;code&gt;AWS::S3::Service.buckets.each {|b| puts b.name}&lt;/code&gt;&lt;br /&gt;output:&lt;br /&gt;ogg.twitteraudio.com&lt;br /&gt;t1000&lt;br /&gt;t2000&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;4) Add a new bucket called t3000.&lt;br /&gt;&lt;code&gt;AWS::S3::Bucket.create('t3000')&lt;/code&gt;&lt;br /&gt;output:&lt;br /&gt;=&gt; true&lt;br /&gt;&lt;br /&gt;5) Observe adding the bucket again doesn't cause an error.&lt;br /&gt;&lt;code&gt;AWS::S3::Bucket.create('t3000')&lt;/code&gt;&lt;br /&gt;output:&lt;br /&gt;=&gt; true&lt;br /&gt;&lt;br /&gt;6) View the buckets again. &lt;br /&gt;&lt;code&gt;AWS::S3::Service.buckets&lt;/code&gt;&lt;br /&gt;output:&lt;br /&gt;=&gt; [#&lt;AWS::S3::Bucket:0xb75cc850 @object_cache=[], @attributes={"name"=&gt;"ogg.twitteraudio.com", "creation_date"=&gt;Sat Apr 26 10:40:16 UTC 2008}&gt;, #&lt;AWS::S3::Bucket:0xb75cc83c @object_cache=[], @attributes={"name"=&gt;"t1000", "creation_date"=&gt;Fri Apr 25 21:35:21 UTC 2008}&gt;, #&lt;AWS::S3::Bucket:0xb75cc814 @object_cache=[], @attributes={"name"=&gt;"t2000", "creation_date"=&gt;Fri Apr 25 21:53:15 UTC 2008}&gt;]&lt;br /&gt;&lt;br /&gt;Note: You would expect t3000 to be in there however it didn't appear possibly because of the bucket permissions.&lt;br /&gt;&lt;br /&gt;7) Let's then look for bucket t3000.&lt;br /&gt;&lt;code&gt;t3000 = AWS::S3::Bucket.find('t3000')&lt;/code&gt;&lt;br /&gt;output:&lt;br /&gt;=&gt; #&lt;AWS::S3::Bucket:0xb76df724 @object_cache=[], @attributes={"prefix"=&gt;nil, "name"=&gt;"t3000", "marker"=&gt;nil, "max_keys"=&gt;1000, "is_truncated"=&gt;false, "xmlns"=&gt;"http://s3.amazonaws.com/doc/2006-03-01/"}&gt;&lt;br /&gt;&lt;br /&gt;8) Now that we've found the bucket let's upload a text file called works.txt.&lt;br /&gt;&lt;code&gt;file = "works.txt"&lt;/code&gt;&lt;br /&gt;output:&lt;br /&gt;=&gt; "works.txt"&lt;br /&gt;&lt;code&gt;AWS::S3::S3Object.store(file, open(file), 't3000', :access =&gt; :public_read)&lt;/code&gt;&lt;br /&gt;output:&lt;br /&gt;=&gt; #&lt;AWS::S3::S3Object::Response:0x-608926458 200 OK&gt;&lt;br /&gt;&lt;br /&gt;9) Setting the file access to :public_read allows us to view the file from the http location http://t3000.s3.amazonaws.com/works.txt&lt;br /&gt;&lt;br /&gt;References: &lt;br /&gt;&lt;a href="http://amazon.rubyforge.org/"&gt;http://amazon.rubyforge.org/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://snippets.dzone.com/posts/show/4088"&gt;upload_to_s3 - Ruby S3 upload client&lt;/a&gt; [dzone.com]&lt;br /&gt;&lt;br /&gt;*update: 14:30 30 April 2008 *&lt;br /&gt;I didn't use Bucket.objects(:reload) which is the reason why the bucket t3000 didn't show up with the statement Service.buckets&lt;br /&gt;&lt;br /&gt;Reference: &lt;a href="http://spattendesign.com/2007/12/5/amazon-s3-ruby-and-rails-slides"&gt;spatten design - Amazon S3, Ruby and Rails slides&lt;/a&gt; [spattendesign.com]</description>
      <pubDate>Tue, 29 Apr 2008 17:20:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5441</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Redirect a URL with Ruby CGI</title>
      <link>http://snippets.dzone.com/posts/show/5415</link>
      <description>&lt;code&gt;&lt;br /&gt;#!/usr/bin/ruby&lt;br /&gt;&lt;br /&gt;require 'cgi'&lt;br /&gt;&lt;br /&gt;cgi = CGI.new&lt;br /&gt;print cgi.header({'Status' =&gt; '302 Moved', 'location' =&gt;  'http://www.wired.com'})&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;or&lt;br /&gt;&lt;code&gt;&lt;br /&gt;url = 'http://www.wired.com/'&lt;br /&gt;print cgi.header({'status'=&gt;'REDIRECT', 'Location'=&gt;url})&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;&lt;a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/48889"&gt;RE: cgi redirect&lt;/a&gt; [nagaokaut.ac.jp]&lt;br /&gt;&lt;a href="http://www.mokehehe.com/assari/index.php?Ruby%2FCGI"&gt;Ruby/CGI - assari&lt;/a&gt; [mokehehe.com]&lt;br /&gt;&lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"&gt;HTTP/1.1: Status Code Definitions&lt;/a&gt; [w3.org]</description>
      <pubDate>Mon, 21 Apr 2008 12:25:30 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5415</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>https://hosted67.renlearn.com/77571/HomeConnect/Login.aspx</title>
      <link>http://snippets.dzone.com/posts/show/5209</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;// insert code here..&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 11 Mar 2008 01:09:27 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5209</guid>
      <author>benthere (Patricia)</author>
    </item>
    <item>
      <title>ProjectX client-side code</title>
      <link>http://snippets.dzone.com/posts/show/5150</link>
      <description>This Ruby code uses a unified XML format to create a password record on a web server. It's intended to be run as a batch file which gets called from another Ruby application called maintain_projectx which gets called from a cronjob.&lt;br /&gt;&lt;br /&gt;In this example the password is stored on the server not for authentication but simply to provide a reminder service in the event the user forgets it.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'net/http'&lt;br /&gt;require 'rexml/document'&lt;br /&gt;include REXML&lt;br /&gt;&lt;br /&gt;class ProjectXClient&lt;br /&gt;  attr :doc&lt;br /&gt;  def initialize(raw_url)&lt;br /&gt;    url = URI.escape(raw_url)&lt;br /&gt;    xml_data = Net::HTTP.get_response(URI.parse(url)).body&lt;br /&gt;    @doc = Document.new(xml_data)&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;if __FILE__ == $0&lt;br /&gt;&lt;br /&gt;  xml_project = &lt;&lt;PROJECT&lt;br /&gt;  &lt;project name='password'&gt;&lt;br /&gt;    &lt;method name='create'&gt;&lt;br /&gt;      &lt;params&gt;&lt;br /&gt;        &lt;param var='password' val='p6789c'/&gt;&lt;br /&gt;        &lt;param var='title' val='hotmail'/&gt;&lt;br /&gt;      &lt;/params&gt;&lt;br /&gt;    &lt;/method&gt;&lt;br /&gt;  &lt;/project&gt;&lt;br /&gt;PROJECT&lt;br /&gt;  &lt;br /&gt;  pxc = ProjectXClient.new("http://yourdomain.com/p/projectx.cgi?xml_project=" + xml_project)&lt;br /&gt;  doc = pxc.doc&lt;br /&gt;  puts doc&lt;br /&gt;    &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;output -what's returned from the server is an XML response containing a result. The result echos the method executed and the output from that method, which in this instance is the xml record node 'entry'.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;result method='rtn_create'&gt;&lt;br /&gt;  &lt;append id='19367'&gt;&lt;br /&gt;    &lt;entry id='19367'&gt;&lt;br /&gt;      &lt;password&gt;p6789c&lt;/password&gt;&lt;br /&gt;      &lt;title&gt;hotmail&lt;/title&gt;&lt;br /&gt;      &lt;description/&gt;&lt;br /&gt;    &lt;/entry&gt;&lt;br /&gt;  &lt;/append&gt;&lt;br /&gt;&lt;/result&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Mon, 18 Feb 2008 18:49:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5150</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Getting Started With WWW::Mechanize</title>
      <link>http://snippets.dzone.com/posts/show/5134</link>
      <description>This Ruby code uses WWW:mechanize to act like a web browser.  &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt; require 'rubygems'&lt;br /&gt; require 'mechanize'&lt;br /&gt;&lt;br /&gt; agent = WWW::Mechanize.new&lt;br /&gt; page = agent.get('http://google.com/')&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Refer to the documentation at http://mechanize.rubyforge.org/mechanize/. Then gem install mechanize, and try running the code in an irb session.&lt;br /&gt;&lt;br /&gt;output (extract):&lt;br /&gt;&lt;code&gt;&lt;br /&gt;=&gt; #&lt;WWW::Mechanize::Page&lt;br /&gt; {url #&lt;URI::HTTP:0xfdbbbb286 URL:http://www.google.com/&gt;}&lt;br /&gt; {meta}&lt;br /&gt; {title "Google"}&lt;br /&gt; {iframes}&lt;br /&gt; {frames}&lt;br /&gt; {links&lt;br /&gt;  #&lt;WWW::Mechanize::Page::Link&lt;br /&gt;   "Images"&lt;br /&gt;   "http://images.google.com/imghp?hl=en&amp;tab=wi"&gt;&lt;br /&gt;  #&lt;WWW::Mechanize::Page::Link&lt;br /&gt;   "Maps"&lt;br /&gt;   "http://maps.google.com/maps?hl=en&amp;tab=wl"&gt;&lt;br /&gt;  #&lt;WWW::Mechanize::Page::Link&lt;br /&gt;   "News"&lt;br /&gt;   "http://news.google.com/nwshp?hl=en&amp;tab=wn"&gt;&lt;br /&gt;  #&lt;WWW::Mechanize::Page::Link&lt;br /&gt;   "Shopping"&lt;br /&gt;   "http://www.google.com/prdhp?hl=en&amp;tab=wf"&gt;&lt;br /&gt;  #&lt;WWW::Mechanize::Page::Link&lt;br /&gt;   "Gmail"&lt;br /&gt;   "http://mail.google.com/mail/?hl=en&amp;tab=wm"&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 12 Feb 2008 17:53:54 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5134</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>bScan - Simple Web Aplications Scanner</title>
      <link>http://snippets.dzone.com/posts/show/5094</link>
      <description>// Web application scanner (ex: phpBB, myCMS, myBlog, mySite etc..) - Only in PHP !&lt;br /&gt;// Find XSS, sql injection, remote file inclusion&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#####################################################################################&lt;br /&gt;#	Black_H  / Nooz -- 30:01:07 &lt;br /&gt;#	Bl4ck.H&lt;&gt;gmail&lt;&gt;com&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;class BScan&lt;br /&gt;&lt;br /&gt;#####################################################################################&lt;br /&gt;#	Regex&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;@@space    = '([[:space:]]*)'&lt;br /&gt;&lt;br /&gt;@@userdat  = '('&lt;br /&gt;@@userdat += '(\$_SERVER\[([\'\"]*)HTTP_)|'&lt;br /&gt;@@userdat += '(\$_GET)|'&lt;br /&gt;@@userdat += '(\$_POST)|'&lt;br /&gt;@@userdat += '(\$_COOKIE)|'&lt;br /&gt;@@userdat += '(\$_REQUEST)|'&lt;br /&gt;@@userdat += '(\$_FILES)|'&lt;br /&gt;@@userdat += '(\$_ENV)|'&lt;br /&gt;@@userdat += '(\$_HTTP_COOKIE_VARS)|'&lt;br /&gt;@@userdat += '(\$_HTTP_ENV_VARS)|'&lt;br /&gt;@@userdat += '(\$_HTTP_GET_VARS)|'&lt;br /&gt;@@userdat += '(\$_HTTP_POST_FILES)|'&lt;br /&gt;@@userdat += '(\$_HTTP_POST_VARS)|'&lt;br /&gt;@@userdat += '(\$_HTTP_SERVER_VARS\[([\'\"]*)HTTP_)'&lt;br /&gt;@@userdat += ')'&lt;br /&gt;&lt;br /&gt;@@regex = Hash.new&lt;br /&gt;@@regex = &lt;br /&gt;	{'TYPE' =&gt; 'vars overwrite','LEVEL' =&gt; '2','REGEX' =&gt; /extract#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'vars overwrite','LEVEL' =&gt; '2','REGEX' =&gt; /import_request_variables#{@@space}\((.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'fopen vuln','LEVEL' =&gt; '3','REGEX' =&gt; /fopen#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'copy vuln','LEVEL' =&gt; '3','REGEX' =&gt; /copy#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'fwrite vuln','LEVEL' =&gt; '3','REGEX' =&gt; /fwrite#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'sql injection','LEVEL' =&gt; '2','REGEX' =&gt; /(mysql_query|mssql_query|mysqli_query)#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'crlf injection','LEVEL' =&gt; '1','REGEX' =&gt; /mail#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'cross site scripting','LEVEL' =&gt; '1','REGEX' =&gt; /\&lt;\?\=#{@@space}(.*)#{@@userdat}/i},&lt;br /&gt;	{'TYPE' =&gt; 'cross site scripting','LEVEL' =&gt; '1','REGEX' =&gt; /(print|echo|print_r|var_dump)#{@@space}(|\(|\")(.*)#{@@userdat}/i},&lt;br /&gt;	{'TYPE' =&gt; 'php code execution','LEVEL' =&gt; '3','REGEX' =&gt; /eval#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'php code execution','LEVEL' =&gt; '3','REGEX' =&gt; /file_put_contents#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'variable attribution', 'LEVEL' =&gt; '2','REGEX' =&gt; /(.*)\$#{@@userdat}(.*)/i},&lt;br /&gt;	{'TYPE' =&gt; 'chmod affectation','LEVEL' =&gt; '1','REGEX' =&gt; /chmod#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'file disclosure','LEVEL' =&gt; '2','REGEX' =&gt; /(readfile|file_get_contents|file)#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'file disclosure','LEVEL' =&gt; '2','REGEX' =&gt; /(show_source|highlight_file)#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'bzopen vuln','LEVEL' =&gt; '2','REGEX' =&gt; /bzopen#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'file deletion','LEVEL' =&gt; '2','REGEX' =&gt; /(rmdir|unlink|delete)#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'command execution','LEVEL' =&gt; '3','REGEX' =&gt; /(exec|system|passthru|shell_exec|proc_open|pcntl_exec)#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'buffer overflow','LEVEL' =&gt; '3','REGEX' =&gt; /(confirm_phpdoc_compiled|mssql_pconnect|mssql_connect|crack_opendict|snmpget|ibase_connect)#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'ip falsification','LEVEL' =&gt; '1','REGEX' =&gt; /(.*)(HTTP_CLIENT_IP|HTTP_X_FORWARDED_FOR|HTTP_PC_REMOTE_ADDR)(.*)/i},&lt;br /&gt;	{'TYPE' =&gt; 'putenv vuln','LEVEL' =&gt; '2','REGEX' =&gt; /putenv#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'full path disclosure','LEVEL' =&gt; '1','REGEX' =&gt; /(htmlentities|htmlspecialchars)#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'magic_quotes_gpc bypass','LEVEL' =&gt; '1','REGEX' =&gt; /(stripslashes|urldecode)#{@@space}\((.*)#{@@userdat}(.*)\)/i},&lt;br /&gt;	{'TYPE' =&gt; 'file inclusion','LEVEL' =&gt; '3','REGEX' =&gt; /(include|include_once|require|require_once)#{@@space}(|\(|\")(.*)#{@@userdat}/i}&lt;br /&gt;&lt;br /&gt;#####################################################################################&lt;br /&gt;#	Main&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;  def initialize()&lt;br /&gt;&lt;br /&gt;	################&lt;br /&gt;	#	Usage&lt;br /&gt;&lt;br /&gt;if (ARGV.length &lt; 4)&lt;br /&gt;puts  '&lt;br /&gt; ---------------------------------------------------------------------&lt;br /&gt;|             Credits: Black_H &lt;bl4ck.h@gmail.com&gt;                    |&lt;br /&gt;|                 URL: Lemon-Inside.sup.fr                            |&lt;br /&gt;|                Note: Premier code Ruby                              |&lt;br /&gt; ---------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt; ---------------------------------------------------------------------&lt;br /&gt;|   Usage:  scan.rb -d &lt;Dossier&gt; -i &lt;Save.html&gt;                       |&lt;br /&gt;|   Ex:  scan.rb -d ./ -i output.html                                 |&lt;br /&gt; ---------------------------------------------------------------------		&lt;br /&gt; '&lt;br /&gt; end&lt;br /&gt; &lt;br /&gt;	################&lt;br /&gt;	#	Options &amp; Vars&lt;br /&gt;	&lt;br /&gt;	@@scan_alldir =  self.options('d')&lt;br /&gt;	@@out_file =  self.options('i')&lt;br /&gt;	&lt;br /&gt;	@@ban = [".", "..", "scan.rb", @@out_file.to_s]&lt;br /&gt;&lt;br /&gt;	@@scan_buffer = Array.new&lt;br /&gt;	&lt;br /&gt;	################&lt;br /&gt;	#	Options Error ?&lt;br /&gt;	&lt;br /&gt;	if (@@scan_alldir != false and @@scan_alldir.empty? == false)&lt;br /&gt;	self.dscan(@@scan_alldir)&lt;br /&gt;	self.output(@@scan_buffer)&lt;br /&gt;	@@scan_buffer = ''&lt;br /&gt;	end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;#####################################################################################&lt;br /&gt;#	Dir Scan &lt;br /&gt;#&lt;br /&gt;  &lt;br /&gt;  def dscan(dir)&lt;br /&gt;      &lt;br /&gt;	d = Dir.open(dir.to_s)&lt;br /&gt;	d = d.sort - @@ban&lt;br /&gt;	&lt;br /&gt;      d.each { |fichier|&lt;br /&gt;&lt;br /&gt;      case File.ftype(dir+fichier)&lt;br /&gt;        when "directory"&lt;br /&gt;          self.dscan(dir + fichier + "/")&lt;br /&gt;        when "file"&lt;br /&gt;		  puts  'Scan =&gt; ' + dir + fichier &lt;br /&gt;          self.fscan(dir + fichier)&lt;br /&gt;      end&lt;br /&gt;&lt;br /&gt;	  }&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;#####################################################################################&lt;br /&gt;#	File Scan &lt;br /&gt;#&lt;br /&gt;  &lt;br /&gt;  def fscan(file)&lt;br /&gt;&lt;br /&gt;	fichier = File.readlines(file)&lt;br /&gt;	i = 1&lt;br /&gt;&lt;br /&gt;	fichier.each { |line|&lt;br /&gt;						&lt;br /&gt;		@@regex.each  { |info|&lt;br /&gt;			&lt;br /&gt;			test = (line  =~ info['REGEX']) &lt;br /&gt;		&lt;br /&gt;				if (test) &lt;br /&gt;			&lt;br /&gt;				@@scan_buffer += ['FILE' =&gt; file, 'LINE' =&gt; i.to_s, 'MATCH' =&gt; line, 'LEVEL' =&gt; info['LEVEL'], 'TYPE' =&gt; info['TYPE']]&lt;br /&gt;				#	5 , 1 , 3 , 4 , 2&lt;br /&gt;				next @@scan_buffer&lt;br /&gt;				end&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;	i += 1&lt;br /&gt;  	} &lt;br /&gt;	&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;#####################################################################################&lt;br /&gt;#	Output buffer&lt;br /&gt;#&lt;br /&gt;  &lt;br /&gt;  def output(buffer)&lt;br /&gt;  &lt;br /&gt;	@html_hmodel = '&lt;html&gt;'&lt;br /&gt;	@html_hmodel += '&lt;style type="text/css"&gt;'&lt;br /&gt;	@html_hmodel += '&lt;!--'&lt;br /&gt;	@html_hmodel += '.level0 {background-color: #CCCCCC;}'&lt;br /&gt;	@html_hmodel += '.level1 {background-color: #33FF66;}'&lt;br /&gt;	@html_hmodel += '.level2 {background-color: #FFFF33;}'&lt;br /&gt;	@html_hmodel += '.level3 {background-color: #FF0000;}'&lt;br /&gt;	@html_hmodel += '--&gt;&lt;/style&gt;&lt;body&gt;&lt;h1&gt;BScan v1.0&lt;/h1&gt;&lt;pre&gt;'&lt;br /&gt;&lt;br /&gt;	code = @html_hmodel&lt;br /&gt;	&lt;br /&gt;	buffer.each { |infos|&lt;br /&gt;	&lt;br /&gt;	keys = infos.keys&lt;br /&gt;	code += "&lt;span class='level" + infos["LEVEL"] + "'&gt;" + keys[1].to_s + ' : ' + infos["TYPE"] + '&lt;/span&gt;&lt;br /&gt;'&lt;br /&gt;	code += "&lt;span class='" + infos["LEVEL"] + "'&gt;" + keys[3].to_s + ' : ' + infos["LEVEL"] + '&lt;/span&gt;&lt;br /&gt;'&lt;br /&gt;	code += "&lt;span class='" + infos["LEVEL"] + "'&gt;" + keys[4].to_s + ' : ' + infos["FILE"] + '&lt;/span&gt;&lt;br /&gt;'&lt;br /&gt;	code += "&lt;span class='" + infos["LEVEL"] + "'&gt;" + keys[0].to_s + ' : ' + infos["LINE"] + '&lt;/span&gt;&lt;br /&gt;'&lt;br /&gt;	code += "&lt;span class='" + infos["LEVEL"] + "'&gt;" + keys[2].to_s + ' : ' + infos["MATCH"] + '&lt;/span&gt;&lt;br /&gt;'&lt;br /&gt;	&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;		code += "&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;"&lt;br /&gt;		fhtml = File.open(@@out_file.to_s, "w")&lt;br /&gt;		fhtml.write code&lt;br /&gt;		code = ''&lt;br /&gt;&lt;br /&gt;	&lt;br /&gt;  end&lt;br /&gt;#####################################################################################&lt;br /&gt;#	Parse &amp; Get Options&lt;br /&gt;#&lt;br /&gt; &lt;br /&gt;  def options(param)&lt;br /&gt;  &lt;br /&gt;	i = 0&lt;br /&gt;		ARGV.each  { |valeur|&lt;br /&gt;		&lt;br /&gt;    		if (valeur == '-' + param.to_s)&lt;br /&gt;				return ARGV[i+1]&lt;br /&gt;			elseif (valeur != '-' + param.to_s)&lt;br /&gt;				return false&lt;br /&gt;			end&lt;br /&gt;		i += 1&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;	end&lt;br /&gt;  &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;scan = BScan.new&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 03 Feb 2008 11:51:05 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5094</guid>
      <author>Black_H (Black_H)</author>
    </item>
    <item>
      <title>Ruby equivalent of a simple Wget</title>
      <link>http://snippets.dzone.com/posts/show/4656</link>
      <description>Reads the file contents from a URL. I used this code to work around the problem with the Ruby RSS reader which couldn't read the RSS file from digg.com.  The reason being that the website would not allow files to be downloaded without supplying the User-Agent string.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'open-uri'&lt;br /&gt;puts open('http://digg.com/rss/index.xml',&lt;br /&gt;     'User-Agent' =&gt; 'Ruby-Wget').read&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 15 Oct 2007 11:20:43 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4656</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Ruby remote file checker</title>
      <link>http://snippets.dzone.com/posts/show/4638</link>
      <description>&lt;code&gt;&lt;br /&gt;require 'rubygems'&lt;br /&gt;require 'open-uri'&lt;br /&gt;require 'net/http'&lt;br /&gt;&lt;br /&gt;def remote_file_exists?(url)&lt;br /&gt;  url = URI.parse(url)&lt;br /&gt;  Net::HTTP.start(url.host, url.port) do |http|&lt;br /&gt;    return http.head(url.request_uri).code == "200"&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 12 Oct 2007 00:17:27 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4638</guid>
      <author>sikelianos (Zeke Sikelianos)</author>
    </item>
    <item>
      <title>Resolving a tinyURL to destination URL</title>
      <link>http://snippets.dzone.com/posts/show/4591</link>
      <description>Resolving a tinyURL to its original destination URL in a fastest way.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    &lt; ?php&lt;br /&gt;&lt;br /&gt;    // request like this http://&lt;domain&gt;/tinyurl.php?c=&lt;tinyurl&gt;&lt;br /&gt;&lt;br /&gt;    $num = $_GET['c'];&lt;br /&gt;&lt;br /&gt;    if($fp = fsockopen ("tinyurl.com", 80, $errno, $errstr, 30))&lt;br /&gt;    {&lt;br /&gt;    if ($fp) {&lt;br /&gt;    fputs ($fp, "HEAD /$num HTTP/1.0\r\nHost: tinyurl.com\r\n\r\n");&lt;br /&gt;    while (!feof($fp)) {$headers .= fgets ($fp,128);}&lt;br /&gt;    fclose ($fp);&lt;br /&gt;    }&lt;br /&gt;    $arr1=explode("Location:",$headers);&lt;br /&gt;    $arr=explode("\n",trim($arr1[1]));&lt;br /&gt;    echo trim($arr[0]);&lt;br /&gt;    }&lt;br /&gt;    ?&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;http://www.webforth.com/2007/07/resolving-tinyurls-to-the-desination-url</description>
      <pubDate>Sun, 30 Sep 2007 08:05:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4591</guid>
      <author>mixdev (Arun Vijayan)</author>
    </item>
  </channel>
</rss>
