#!/usr/bin/perl BEGIN { my $homedir = ( getpwuid($>) )[7]; my @user_include; foreach my $path (@INC) { if ( -d $homedir . '/perl' . $path ) { push @user_include, $homedir . '/perl' . $path; } } unshift @INC, @user_include; } ############ # us-co: United States-Colorado ############ # # This code may be freely reproduced, distributed, transmitted, used, modified, # built upon, or otherwise exploited by anyone for any purpose, commercial or non-commercial, # and in any way, including by methods that have not yet been invented or conceived. # # Purpose: Provide link/citation directly to various Colorado legislative docs and sublevels # DOCUMENTATION # # Legislation for the state of Colorado resides in PDF and WordPerfect files. # Session laws are also available in HTML # Consolidated law is availabe at michie.com in HTML # # Approach uses PDF and HTML files. # CODE CONTRIBUTORS # Joe Carmel # Brian Gryth (subject matter expert) # CHANGE HISTORY require LWP::UserAgent; $ua = LWP::UserAgent->new; # Get URL string after the ? from the URL. $posted_information=$ENV{QUERY_STRING}; print "Content-type: text/html\n\n"; do "cgi-bin/shared.pl"; $posted_information=~s|^x=||; ######################################## # Bills ######################################## # http://www.leg.state.co.us/Clics/CLICS2009A/csl.nsf/bf-3HB?OpenView&StartKey=HB09-1052&Count=1 # http://www.leg.state.co.us/Clics/CLICS2009A/csl.nsf/bf-2SB?OpenView&StartKey=SB09-100&Count=1 # http://www.leg.state.co.us/Clics/CLICS2009A/csl.nsf/bf-2?OpenView&StartKey=SR09-001&Count=1 if ($posted_information=~m!^(hb|sb|hcr|hm|hjr|hjm|hr|sjr|sm|sr|sjm)-(\d+)(s\d?)?-(\d+)!i) { $billtype=uc($1); $year=$2; $session=lc($3); $billnum=$4; if ($billtype eq "HB") {$bfnum=3;} elsif ($billtype eq "SB") {$bfnum=2;} elsif ($billtype eq "HCR") {$bfnum=1;} elsif ($billtype eq "HM") {$bfnum=1;} elsif ($billtype eq "HJR") {$bfnum=3;} elsif ($billtype eq "HR") {$bfnum=3;} elsif ($billtype eq "SCR") {$bfnum=2;} elsif ($billtype eq "SJR") {$bfnum=2;} elsif ($billtype eq "SM") {$bfnum=2;} elsif ($billtype eq "SR") {$bfnum=2;} elsif ($billtype eq "SJM") {$bfnum=2;} elsif ($billtype eq "HJM") {$bfnum=1;} if ($session eq "") {$session="A";} $shortyear=$year; if ($year < 50) {$year=2000+$year;} else {$year=1900+$year;} $baseurl="http://www.leg.state.co.us"; $website=sprintf("http://www.leg.state.co.us/Clics/CLICS%d%s/csl.nsf/bf-%d%s?OpenView&StartKey=%s%02d-%03d&Count=1", $year,$session,$bfnum,$billtype,$billtype,$shortyear,$billnum); # Remove billtype for resolutions from website address if ($billtype eq "HR" || $billtype eq "SR") {$website=~s|bf-(.)..|bf-\1|;} # print "".$website."\n"; # exit; $legdoc=GetFileFromURL($website); if ($legdoc=~s|\nSEC. \1.|; # Store the file and Display the Stored File with the Anchor. $outfn="Bills/".$congress."-".$billtype.$billnum.$billstage.".html"; $anchor="SEC-".$section; StoreFileandDisplayToAnchor($legdoc,$outfn,$anchor); RedirectToWebsite($website); } elsif ($posted_information=~m!^CRS-(\d+)!i) { if ($posted_information=~m!^CRS-(\d+)-([^-]*?)-([0-9\.]+)$!i) { $crstitle=$1; $crsarticle=$2; $crssection=$3; } elsif ($posted_information=~m!^CRS-(\d+)-([\d.])+$!i) { $crstitle=$1; $crsarticle=$2; $crssection=""; } elsif ($posted_information=~m!^CRS-(\d+)$!i) { $crstitle=$1; $crsarticle=""; $crssection=""; } else { print "Improper format for Colorado Revised Statute
us-co?CRS-[title]-[article]-[section]"; exit; } # print "Hello"; # exit; # $website="http://www.michie.com/colorado/lpext.dll?f=FifLink&t=document-frame.htm&l=jump&iid=6e0451f1.601eaa37.0.0&nid=6e7f#JD_12-5-114"; # RedirectToWebsite($website); # $website="http://disney.com"; # print "".$website.""; # exit; # Get list of all Titles $website="http://www.michie.com/colorado/lpext.dll?f=templates&fn=tools-contents.htm&cp=cocode/2&2.0"; $legdoc=GetFileFromURL($website); $baseurl="http://www.michie.com"; # Find Title link if ($legdoc=~m|\n]*?>TITLE $crstitle\s|) { $href=$1; if ($crsarticle eq "") { RedirectToWebsite($baseurl.$href); } # Find Article Link else { $legdoc=GetFileFromURL($baseurl.$href); if ($legdoc=~m|Art\. $crsarticle\. |) { $href=$1; # $href="/colorado/lpext.dll?f=FifLink&t=document-frame.htm&l=jump&iid=6e0451f1.601eaa37.0.0&nid=6e7f#JD_12-5-114"; # $crssection=""; if ($crssection eq "") { RedirectToWebsite($baseurl.$href); } # Find Section Link else { $legdoc=""; $legdoc=GetFileFromURL($baseurl.$href); $temp=$crstitle."-".$crsarticle."-".$crssection; if ($legdoc=~m|$temp\.\s|) { $href=$1; RedirectToWebsite($baseurl.$href); } else { print "Can't find Title ".$crstitle." Article ".$crsarticle." section ".$crssection." in the Colorado Revised Statutes"; exit; } } } else { print "Can't find Title ".$crstitle." Article ".$crsarticle." in the Colorado Revised Statutes"; exit; } } } else { print "Can't find Title ".$crstitle." in the Colorado Revised Statutes"; exit; } } ######################################## # Display the list of LegisLink formats ######################################## else { print < State of Colorado LegisLinks

State of Colorado (us-co)
LegisLinks*

http://legislink.org/us-co? . . .

Simplified Human-Readable URLs for Legislative Citations

Pre-enactment Enacted Legislation (not available yet)
Legislation (top of file)
  Format: [bill-type]-[year][session]-[bill-number]
  Example LegisLink URL: http://legislink.org/us-co?HB-09-1001
  Edit the citation:
     
http://legislink.org/us-co?
  Source: Colorado General Assembly (PDF Files)
  Availability: 2007 - present
Session Laws
  Format: SL-[year][session]-[bill-number]-[section]
  Example: http://legislink.org/us-co?01S2-1001-3
  Source: Session Laws of Colorado
  Availability: 1993 - present
Consolidated Law
Legend
Colorado Revised Statutes (titles, articles, and sections)
  Format: CRS-[title]-[article]-[section]
  Example LegisLink URL: http://legislink.org/us-co?CRS-12-5-115.5
  Edit the citation:
     
http://legislink.org/us-co?
  Source: Michie's Legal Resources
  Availability: current version only
bill-number: House legislation numbering starts at 1001, Senate starts at 1
bill-stage: ENG (engrossed), REN (reengrossed), REV (revised) RER (rerevised),
                    ENR (enrolled)
bill-type: HB/SB (Bill), HCR/SCR (Concurrent Res), HJM/SJM (Joint Memorial),
                    HJR/SJR (Joint Res), HM/SM (Memorial), HR/SR (Res)
session: Regular session uses no designation. 1st Special Session uses "S",
                  2nd Special Session uses "S1", etc.
This website redirects your browser to official government or government designated websites or retrieves that data at the time URLs are submitted.
While most websites try to keep you there, the goal here is to get you where you want to go.

Documents may be stored temporarily at LegisLink.org to provide sub-document access when that access is not provided by the official repository.
Always check the domain in the URL at the top of your browser to know the origin of the page being viewed.

Creative Commons License
This work is in the Public Domain with available source code and a wikispace.
EOD exit; } ####################################### # GetFileFromURL ####################################### sub GetFileFromURL { my $website=$_[0]; my $errorstr=$_[1]; # $ua->env_proxy; my $req; if (!($req = $ua->get($website))) { print "".$website." not available\n"; print "\n"; print "

".$website." is unavailable at this time.

\n"; print "

Here's a link to the government's URL you requested. ".$website.""; print ""; exit; } my $body=""; # $body = $http->body(); if ($req->is_success) { $body=$req->decoded_content; # or whatever } else { print "".$req->status_line.""; exit; } # Text for availability if ($errorstr && $body=~m|$errorstr|) { print "".$website." not available\n"; print "\n"; print "

".$website." is unavailable at this time.

\n"; print "

Here's a link to the government's URL you requested. ".$website.""; print ""; exit; } # $http->reset(); return($body); }