k;j=0<=k?++l:--l){h.push([n[j],j])}h.sort(function(o,i){var p;p=o[0]-i[0];if(p===0){p=o[1]-i[1]}return p});return h[m][1]};g.prototype.highestCol=function(h){return e.inArray(Math.max.apply(c,h),h)};g.prototype.destroy=function(){var h,j,i;j=this.$container;j.off("ss-arrange");j.off("ss-rearrange");j.off("ss-setTargetPosition");j.off("ss-destroy");i=this.options.activeClass;h=j.find("."+i);if(this.options.enableDrag){h.draggable("destroy")}if(this.options.enableCrossDrop){j.droppable("destroy")}h.removeClass(i);return j.removeClass(this.identifier)};return g})();return e.fn[d]=function(g){return this.each(function(){var k,i,j,h;i=(j=e(this).attr("class"))!=null?(h=j.match(/shapeshifted_container_\w+/))!=null?h[0]:void 0:void 0;if(i){k="resize."+i;e(c).off(k);e(this).removeClass(i)}return e.data(this,"plugin_"+d,new b(this,g))})}})(jQuery,window,document)}).call(this);
\ No newline at end of file
diff --git a/css/styles.css b/css/styles.css
new file mode 100644
index 0000000..c70e2f8
--- /dev/null
+++ b/css/styles.css
@@ -0,0 +1,401 @@
+.tops {
+ width: 100%;
+ height: 125px;
+ background-image: url("../images/topo.png");
+ background-repeat: repeat;
+ float: left;
+ }
+
+#topline {
+ width: 100%;
+ height: 40px;
+ background-color: #99cccc;
+ opacity: 0.4;
+ float: left;
+ }
+
+
+div.socials {
+ margin: 0;
+ position: absolute;
+ top: 0;
+ right: 0;
+ text-align: right;
+ font-size: 1.2em;
+ padding: 1.25em .5em;
+ }
+
+.socials ul {
+ list-style: none;
+ }
+
+.socials li {
+ position: relative;
+ display: inline-block;
+ margin-right: .125em;
+ }
+
+li.social_tw a {
+ text-decoration: none;
+ background-image: url("../images/twittericon.png");
+ }
+
+#logoline {
+ width: 100%;
+ height: 45px;
+ float: left;
+ }
+
+div#logo {
+ float: left;
+ font-family: Garamond, "Times New Roman", serif;
+ font-size: 24px;
+ }
+
+
+
+#slogan {
+ float: left;
+ font-family: Garamond, "Times New Roman", serif;
+ font-size: 16px
+ padding: 40
+ }
+
+#menu {
+ width: 100%;
+ height: 40px;
+ background-color: #99cccc;
+ opacity: 0.4;
+ clear: both;
+ float: left;
+ }
+
+#menu ul {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ overflow: hidden;
+}
+
+#menu li {
+ float: left;
+ display: inline-block
+ padding: .5em;
+ margin: 10;
+ }
+
+body {
+ font-family: 'Source Sans Pro', Helvetica, sans-serif;
+ font-size: 12px;
+ line-height: 1.3rem;
+ font-weight: 400;
+ margin: 0;
+ padding: 0;
+}
+.tops {
+ width: 100%;
+ height: 100%;
+ background-image: url("../images/topo.png");
+ background-repeat: repeat;
+ float: left;
+}
+#topline {
+ width: 100%;
+ height: 100%;
+ padding: 10px;
+ background-color: rgba(153, 204, 204, .4);
+ float: left;
+}
+div.socials {
+ margin: 0;
+ position: absolute;
+ top: 0px;
+ right: 5px;
+}
+.socials ul {
+ list-style: none;
+}
+.socials li {
+ position: relative;
+ display: inline;
+ margin-right: .125em;
+}
+.socials li a {
+ text-decoration: none;
+}
+#logoline {
+ width: 100%;
+ height: 100%;
+ float: left;
+}
+#logo {
+ float: left;
+ letter-spacing: .15em;
+ font-family: Garamond, "Times New Roman", serif;
+ font-size: 1.5rem;
+ padding: 0px 10px 0px 0px;
+}
+#slogan {
+ float: left;
+ font-family: "Trebuchet MS", Helvetica, sans-serif;
+ font-size: .7rem;
+ padding: 25px 0px 0px 0px;
+}
+#menu {
+ width: 100%;
+ height: 100%;
+ background-color: rgba(153, 204, 204, .4);
+ float: left;
+}
+#menu ul {
+ list-style: none;
+ margin: 5px 35px;
+ padding: 1px 10px;
+ overflow: hidden;
+}
+#menu li {
+ display: inline-block;
+ padding: 1px;
+ margin: 1px 10px;
+ font-size: 1rem;
+ font-family: "Trebuchet MS", Helvetica, sans-serif;
+ text-transform: uppercase;
+}
+#menu a {
+ text-decoration: none;
+ color: black;
+}
+#menu a:hover {
+ color: gray;
+}
+#menu #currentpage {
+ text-decoration: underline;
+}
+.maincontainer {
+ clear: both;
+ width: 100%;
+}
+.dashboard {
+ width: 20%;
+ height: 100%;
+ float: left;
+ background-color: #EFF0F2;
+ padding: 0px;
+ margin-top: 10px;
+ border-right: solid 1px black;
+ border-bottom: solid 1px black;
+}
+.dashhead {
+ text-align: center;
+ color: white;
+ font-size: 1.2rem;
+ text-transform: uppercase;
+ padding: 20px 0px 10px 0px;
+}
+.dashitem {
+ color: #3F5388;
+ padding: 10px;
+ line-height: 1em;
+}
+form {
+ width: 100%;
+ margin: 0px;
+}
+input[type=submit] {
+ float: right;
+ position: relative;
+ padding: 7px 15px;
+ left: 0px;
+ border: 2px solid #207cca;
+ background-color: #207cca;
+ color: white;
+}
+input[type=search],
+input[type=email],
+input[type=text],
+input[type=password],
+textarea {
+ width: 100%;
+ padding: 8px 15px;
+ background: rgba(239, 240, 242, 0.4);
+ /* border: 1px solid black; */
+}
+div {
+ overflow: hidden;
+ padding-right: 0em;
+}
+#newuser {
+ text-align: right;
+ color: #3F5388;
+ padding: 10px;
+ line-height: 1em;
+ margin: 0px 10px;
+ text-transform: uppercase;
+}
+#newuser a {
+ text-decoration: none;
+}
+#dashtop {
+ background-color: #333C45;
+}
+#login {
+ background-color: #ECC64B;
+}
+label[for="rememberme"] {
+ margin: 0px 20px;
+}
+#bills {
+ background-color: #99CCCC;
+}
+#testimony {
+ background-color: #0A9DA5;
+}
+#lawmakers {
+ background-color: #364F8A;
+}
+#topics {
+ background-color: #8CAC8C;
+}
+.billmain {
+ width: 79%;
+ height: 100%;
+ background-color: white;
+ float: left;
+ margin: 0px;
+ position: relative;
+}
+
+.active {
+ border: 1px solid black;
+ padding: 0px 10px;
+ margin: 10px 0px 5px 10px;
+ background-color: #EFF0F2;
+}
+.active p {
+ font-size: 1.3rem;
+ text-transform: uppercase;
+ font-style: italic;
+}
+.billimage {
+ background-image: url("../images/billpage.png");
+ position: relative;
+ width: 70px;
+ height: 70px;
+ float: left;
+ margin: 0px 5px 0px 0px;
+ border: 1px solid gray;
+}
+.billimage span {
+ font-size: 1.5em;
+ font-family: 'Source Sans Pro', Helvetica, sans-serif;
+ font-weight: bold;
+ line-height: 70px;
+ padding: 0px 5px;
+ text-align: center;
+}
+.lastaction {
+ padding: 0px 0px 5px 0px;
+ font-style: italic;
+}
+.billsummary {
+ font-size: 1rem;
+ line-height: 1.1rem;
+}
+.legislators_main {
+ position: relative;
+ width: 100%;
+}
+.legislators_main div {
+ height: 50px;
+ position: absolute;
+ width: 50px;
+ border: 1px solid;
+}
+.comments {
+ border-top: 1px gray solid;
+ width: 100%;
+ height: 100%;
+ padding: 5px 0px 5px 5px;
+}
+.pro h3, .neutral h3, .anti h3 {
+ color: black;
+ text-transform: uppercase;
+ font-size: 1.2em;
+ line-height: 1.5em;
+ text-align: center;
+}
+.pro {
+ float: left;
+ width: 32%;
+ border-right: 1px dashed black;
+ padding-right: 5px;
+ min-height: 1px;
+ line-height: 1.2em;
+}
+.neutral {
+ float: left;
+ width: 32%;
+ border-right: 1px dashed black;
+ padding-left: 5px;
+ padding-right: 5px;
+ min-height: 1px;
+ line-height: 1.2em;
+}
+.anti {
+ float: left;
+ width: 31%;
+ padding-left: 5px;
+ min-height: 1px;
+ line-height: 1.2em;
+}
+.commentbox input[type=radio] {
+ margin: 0px 5px 0px 0px;
+ display: inline-block;
+ width: 20px;
+ height: 25px;
+}
+.commentbox label {
+ width: auto;
+ height: auto;
+ float: left;
+ margin: 0px 10px 10px 0px;
+ font-size: 1.8em;
+ text-align: center;
+ line-height: 20px;
+ vertical-align: baseline;
+}
+.comments span {
+ color: blue;
+ text-transform: uppercase;
+ font-size: 1.2em;
+ line-height: 1.5em;
+}
+.prolabel {
+ background-size: 20px;
+ width: 20px;
+ height: 25px;
+ background-repeat: no-repeat;
+ position: relative;
+}
+.antilabel {
+ width: 20px;
+ height: 25px;
+ background-size: 20px;
+ background-repeat: no-repeat;
+ position: relative;
+}
+.footer {
+ width: 100%;
+ height: 100%x;
+ background-image: url("../images/topo.png");
+ background-repeat: repeat;
+ background-color: #F5FDE3;
+ clear: both;
+}
+#cc {
+ padding: 10px;
+ float: left;
+ vertical-align: top;
+ width: 40%;
+ line-height: 1rem;
+}
diff --git a/lib/api_functions.php b/lib/api_functions.php
new file mode 100644
index 0000000..3f35bd6
--- /dev/null
+++ b/lib/api_functions.php
@@ -0,0 +1,17 @@
+
\ No newline at end of file
diff --git a/lib/classes/api_getter.php b/lib/classes/api_getter.php
new file mode 100644
index 0000000..af2be27
--- /dev/null
+++ b/lib/classes/api_getter.php
@@ -0,0 +1,21 @@
+url_base
+ $key = $this->api_key
+ $url = $url_base . 'bills/' . $bill_id . $key;
+ $bill_json = file_get_contents($url);
+ $bill_detail = json_decode($bill_json, true);
+ return $bill_detail[action_dates][last];
+}
+
+}
+?>
\ No newline at end of file
diff --git a/lib/classes/dao.php b/lib/classes/dao.php
new file mode 100644
index 0000000..88bdf21
--- /dev/null
+++ b/lib/classes/dao.php
@@ -0,0 +1,111 @@
+dbhost};dbname={$this->database};port={$this->dbport}", $this->user, $this->password);
+ }
+
+ public function check_login($name, $password) {
+ $conn = $this->getConnection();
+ $name = $conn->quote($name);
+ $rows = $conn->query("SELECT password FROM users WHERE username = $name");
+ if ($rows) {
+ foreach ($rows as $row) { #only one row should match
+ if ($password === $row["password"]) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE; # user not found, or wrong password
+ }
+
+ public function ensure_logged_in() {
+ if (!isset($_SESSION[$name])) {
+ redirect("index.php", "You must login first");
+ }
+ }
+
+ public function redirect($url, $flash_message = NULL) {
+ if ($flash_message) {
+ $_SESSION["flash"] = $flash_message;
+ }
+ header("Location: $url");
+ die;
+ }
+
+ public function saveComment ($username, $comment, $bill, $comment_type) {
+ $conn = $this->getConnection();
+ $saveQuery =
+ "INSERT INTO comments
+ (username, comment, bill_id, comment_type)
+ VALUES
+ (:username, :comment, :bill, :comment_type)";
+ $q = $conn->prepare($saveQuery);
+ $q->bindParam(":username", $username);
+ $q->bindParam(":comment", $comment);
+ $q->bindParam(":bill", $bill);
+ $q->bindParam(":comment_type", $comment_type);
+ return $q->execute();
+ }
+
+ public function getComments ($bill, $comment_type) {
+ $conn = $this->getConnection();
+ return $conn->query("SELECT username, comment, date FROM comments WHERE bill_id = '$bill' AND comment_type = '$comment_type'");
+ }
+
+ public function newUser ($username, $password, $email) {
+ $conn = $this->getConnection();
+ $saveQuery =
+ "INSERT INTO users
+ (username, password, email)
+ VALUES
+ (:username, :password, :email)";
+ $q = $conn->prepare($saveQuery);
+ $q->bindParam(":username", $username);
+ $q->bindParam(":password", $password);
+ $q->bindParam(":email", $email);
+ return $q->execute();
+ }
+
+ public function saveBills ($bill_id, $year, $title, $bill_name, $connection) {
+
+ $saveQuery =
+ "INSERT INTO bills
+ (bill_id, year, title, bill_name)
+ VALUES
+ (:bill_id, :year, :title, :bill_name)";
+ $q = $connection->prepare($saveQuery);
+ $q->bindParam(":bill_id", $bill_id);
+ $q->bindParam(":year", $year);
+ $q->bindParam(":title", $title);
+ $q->bindParam(":bill_name", $bill_name);
+ $q->execute();
+ return $bill_name;
+ }
+
+ public function getBills () {
+ $conn = $this->getConnection();
+ return $conn->query("SELECT bill_name, bill_id, title, (votes_for + votes_against) AS total
+ FROM bills
+ ORDER BY total
+ LIMIT 5");
+ }
+
+ public function getLegislators () {
+ $conn = $this->getConnection();
+ return $conn->query("SELECT first_name, last_name, middle_name, district, party, chamber, photo_url
+ FROM legislators");
+ }
+
+} // end Dao
+?>
\ No newline at end of file
diff --git a/lib/cron_functions.php b/lib/cron_functions.php
new file mode 100644
index 0000000..58844ac
--- /dev/null
+++ b/lib/cron_functions.php
@@ -0,0 +1,64 @@
+" . print_r($legislators, 1) . "";
+
+ $dao = new Dao();
+ $connection = $dao->getConnection();
+ $i = 1;
+ foreach ($legislators as $legislator) {
+ $sql = "INSERT INTO lawmakers(leg_id, last_name, first_name, middle_name, district, party, active, chamber, photo_url)
+ VALUES('" . $legislator['leg_id'] . "', " .
+ "'" . $legislator['last_name'] . "', " .
+ "'" . $legislator['first_name'] . "', " .
+ "'" . $legislator['middle_name'] . "', " .
+ $legislator['district'] . ", " .
+ "'" . $legislator['party'] . "', " .
+ $legislator['active'] . ", " .
+ "'" . $legislator['chamber'] . "', " .
+ "'" . $legislator['photo_url'] . "')";
+ echo "inserting record $i
";
+ $i++;
+
+ $count = $connection->exec($sql) or die(print_r($connection->errorInfo(), true));
+ echo "rows actually inserted $count ";
+ }
+
+ /* Save new bill information to bills table */
+
+ /* read the json file contents */
+
+ $jsondata = file_get_contents('http://openstates.org/api/v1/bills/?apikey=bcc2a830883c4f459dbffe94b2a3e90f&state=id&search_window=session');
+
+//convert json object to php associative array
+ $bills = json_decode($jsondata, true);
+
+ // echo "" . print_r($bills, 1) . "
";
+
+ $dao = new Dao();
+ $connection = $dao->getConnection();
+ $i = 1;
+ foreach ($bills as $bill) {
+ $bill_name = $bill['bill_id'];
+ $year = $bill['session'];
+ $title = $bill['title'];
+ $bill_id = $bill['id'];
+
+ echo "inserting record $i
";
+ $i++;
+
+ $dao->saveBills($bill_id, $year, $title, $bill_name, $connection) or die(print_r($connection->errorInfo(), true));
+ echo "$bill_name actually inserted";
+ }
+
+
+ ?>
\ No newline at end of file
diff --git a/lib/etc/README.md b/lib/etc/README.md
new file mode 100644
index 0000000..9e9a4fd
--- /dev/null
+++ b/lib/etc/README.md
@@ -0,0 +1,2 @@
+# idleg
+Interactive Portal to Idaho Legislature - Under Construction
diff --git a/lib/etc/nhoffman.sql b/lib/etc/nhoffman.sql
new file mode 100644
index 0000000..b792ed9
--- /dev/null
+++ b/lib/etc/nhoffman.sql
@@ -0,0 +1,91 @@
+CREATE TABLE IF NOT EXISTS users (
+email VARCHAR(256) NOT NULL,
+username VARCHAR(64) NOT NULL PRIMARY KEY,
+password VARCHAR(64) NOT NULL,
+firstname VARCHAR(64),
+lastname VARCHAR(64),
+party VARCHAR(12),
+website VARCHAR(64),
+district_cong TINYINT,
+district_leg TINYINT,
+registered TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+verified BOOL
+);
+
+CREATE TABLE IF NOT EXISTS comments (
+comment_id BIGINT(20) NOT NULL PRIMARY KEY AUTO_INCREMENT,
+username VARCHAR(64),
+comment MEDIUMBLOB,
+comment_link VARCHAR(200),
+comment_type VARCHAR(9),
+votes_for TINYINT,
+votes_against TINYINT,
+flags TINYINT,
+bill_id VARCHAR(20),
+comment_ip VARCHAR(100),
+comment TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+comment_parent BIGINT(20),
+approved BOOL
+);
+
+CREATE TABLE IF NOT EXISTS topics (
+topic_id BIGINT(20) NOT NULL PRIMARY KEY AUTO_INCREMENT,
+topic VARCHAR(64)
+);
+
+CREATE TABLE IF NOT EXISTS bills_topics (
+bill_id BIGINT(20),
+topic_id BIGINT(20)
+);
+
+CREATE TABLE IF NOT EXISTS bills (
+bill_id VARCHAR(15) NOT NULL PRIMARY KEY,
+year YEAR(4),
+title MEDIUMBLOB,
+bill_name VARCHAR(6),
+votes_for BIGINT(20),
+votes_against BIGINT(20)
+);
+
+CREATE TABLE IF NOT EXISTS lawmakers (
+leg_id VARCHAR(9) NOT NULL PRIMARY KEY,
+first_name VARCHAR(32) NOT NULL,
+last_name VARCHAR(32) NOT NULL,
+middle_name VARCHAR(32),
+suffix VARCHAR(8),
+nickname VARCHAR(32),
+district INT(2),
+twitter VARCHAR(64),
+facebook VARCHAR(64),
+website VARCHAR(64),
+party VARCHAR(24),
+active BOOL,
+chamber VARCHAR(12),
+photo_url VARCHAR(64)
+);
+
+CREATE TABLE IF NOT EXISTS leg_geo (
+district INT(2) PRIMARY KEY,
+polygon POLYGON NOT NULL
+);
+
+CREATE TABLE IF NOT EXISTS user_bills (
+bill_id BIGINT(20),
+user_id VARCHAR(64)
+);
+
+CREATE TABLE IF NOT EXISTS user_friends (
+user_id VARCHAR(64),
+friend_id VARCHAR(64)
+);
+
+CREATE TABLE IF NOT EXISTS user_topics (
+user_id VARCHAR(64),
+topic_id BIGINT(20)
+);
+
+CREATE TABLE IF NOT EXISTS user_lawmakers (
+user_id VARCHAR(64),
+lawmaker VARCHAR(9)
+);
+
diff --git a/lib/functions.php b/lib/functions.php
new file mode 100644
index 0000000..7a517ab
--- /dev/null
+++ b/lib/functions.php
@@ -0,0 +1,93 @@
+prepare('SELECT * from users where username = "paleomedia"');
+$query->execute();
+?>
+
+fetch(PDO::FETCH_ASSOC)){
+ var_dump($rows); } ?>
+
+
+connect_error) {
+ die("Connection failed: " . $db->connect_error);
+ }
+ echo "Connected successfully (".$db->host_info.")";
+
+
+$db = new PDO("mysql:host=127.0.0.1;port=8889;dbname=idleg_test", "root", "root");
+ var_dump($db);
+
+ if ($db->connect_error) {
+ die("Connection failed: " . $db->connect_error);
+ }
+ echo "Connected successfully (".$db->host_info.")";
+
+?>
+
+
+
+
+/* read the json file contents */
+
+setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+} catch (PDOException $ex) {
+ print "Error!: " . $ex->getMessage() . "
";
+ die();
+}
+
+//insert into mysql table
+ mysql_select_db("lawmakers", $cxn);
+ $sql = "INSERT INTO lawmakers(first_name, last_name, middle_name, district, party, active, chamber, photo_url)
+ VALUES('$first_name', '$last_name', '$middle_name', '$district', '$party', '$active', '$chamber', '$photo_url')";
+ if(!mysql_query($sql,$con))
+ {
+ die('Error : ' . mysql_error());
+ }
+ }
+
+?>
\ No newline at end of file
diff --git a/lib/granted.php b/lib/granted.php
new file mode 100644
index 0000000..6169482
--- /dev/null
+++ b/lib/granted.php
@@ -0,0 +1,14 @@
+
+
+Logout
\ No newline at end of file
diff --git a/lib/handler.php b/lib/handler.php
new file mode 100644
index 0000000..ceca7ef
--- /dev/null
+++ b/lib/handler.php
@@ -0,0 +1,31 @@
+saveComment($username, $comment, $bill, $comment_type);
+ }
+ catch (Exception $e) {
+ var_dump($e);
+ die;
+ }
+ }
+ else {
+ $dao = new Dao();
+ $dao -> redirect("../index.php", "Please log in to comment.");
+ }
+
+ header("Location:../index.php");
\ No newline at end of file
diff --git a/lib/login.php b/lib/login.php
new file mode 100644
index 0000000..9eed8d2
--- /dev/null
+++ b/lib/login.php
@@ -0,0 +1,34 @@
+ check_login($name, $password)) {
+ $_SESSION["name"] = $name;
+
+ if ($_POST['rememberme']=1) {
+ $expireTime = time() + 60*60*24*180; # 180 days from now
+ setcookie("username", $_SESSION["name"], $expireTime); }
+
+ $dao -> redirect("../index.php", "Login successful! Welcome back, $name.");
+ }
+ else {
+ $dao -> redirect("../index.php", "Incorrect user name and/or password.");
+ }
+ }
+ catch (Exception $e) {
+ var_dump($e);
+ die;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/lib/logout.php b/lib/logout.php
new file mode 100644
index 0000000..811c895
--- /dev/null
+++ b/lib/logout.php
@@ -0,0 +1,21 @@
+
\ No newline at end of file
diff --git a/lib/newuser.php b/lib/newuser.php
new file mode 100644
index 0000000..41651b7
--- /dev/null
+++ b/lib/newuser.php
@@ -0,0 +1,37 @@
+ newUser($username, $password, $email)) {
+ $_SESSION["name"] = $username;
+
+ if (isset($_POST['rememberme']) && $_POST['rememberme']) {
+ $expireTime = time() + 60*60*24*180; # 180 days from now
+ setcookie("username", $_SESSION["name"], $expireTime); }
+
+ $dao -> redirect("../index.php", "Welcome to idleg, $username!");
+
+
+ }
+ else {
+ $dao -> redirect("../index.php", "User setup failed.");
+ }
+ }
+ catch (Exception $e) {
+ var_dump($e);
+ die;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/lib/session_start.php b/lib/session_start.php
new file mode 100644
index 0000000..c00731e
--- /dev/null
+++ b/lib/session_start.php
@@ -0,0 +1,24 @@
+
+ = $_SESSION["flash"] ?>
+
\ No newline at end of file
diff --git a/lib/sql_logins.php b/lib/sql_logins.php
new file mode 100644
index 0000000..770f8fc
--- /dev/null
+++ b/lib/sql_logins.php
@@ -0,0 +1,27 @@
+