commit 70806096b6797e147a6127fd50c4d9048f66a8d2
Author: Ricky Barrette
Date: Sun Feb 5 16:40:26 2012 -0500
Initial commit Change-Id: I0000000000000000000000000000000000000000
diff --git a/README b/README
new file mode 100755
index 0000000..4216c9b
--- /dev/null
+++ b/README
@@ -0,0 +1,5 @@
+When pushing changes to production, copy everything over execpt conf.php
+
+default admin:
+admin
+admin
diff --git a/classes/access.php b/classes/access.php
new file mode 100755
index 0000000..e5f362a
--- /dev/null
+++ b/classes/access.php
@@ -0,0 +1,11 @@
+
diff --git a/classes/auth.php b/classes/auth.php
new file mode 100755
index 0000000..88fe50d
--- /dev/null
+++ b/classes/auth.php
@@ -0,0 +1,11 @@
+
diff --git a/classes/blog.php b/classes/blog.php
new file mode 100755
index 0000000..d676a27
--- /dev/null
+++ b/classes/blog.php
@@ -0,0 +1,177 @@
+host = $host;
+ $this->username = $username;
+ $this->password = $password;
+ $this->table = $db;
+ $this->connect();
+ }
+
+ /**
+ deletes all the comments in the blog database for the suppled id
+ */
+ public function delete_thread($id){
+ $q = "DELETE FROM blog WHERE id = '$report'";
+ return mysql_query($q);
+ }
+
+ /**
+ Display all comment entrys for the specified report
+ */
+ public function get_blog() {
+
+ /* Instantiate class */
+ require_once("pager.php");
+ $p = new Pager;
+
+ /* Show many results per page? */
+ $limit = 5;
+
+ /* Find the start depending on $_GET['page'] (declared if it's null) */
+ $start = $p->findStart($limit);
+
+ /* Find the number of rows returned from a query; Note: Do NOT use a LIMIT clause in this query */
+ $count = mysql_num_rows(mysql_query("SELECT * FROM blog"));
+
+ /* Find the number of pages based on $count and $limit */
+ $pages = $p->findPages($count, $limit);
+
+ /* Now we use the LIMIT clause to grab a range of rows */
+ $r = mysql_query("SELECT * FROM blog ORDER BY id DESC LIMIT ".$start.", ".$limit);
+
+ /* Now get the page list and echo it */
+ $pagelist = $p->pageList($_GET['page'], $pages);
+
+ if ( $r !== false && mysql_num_rows($r) > 0 ) {
+ while ( $a = mysql_fetch_assoc($r) ) {
+ $title = stripslashes($a['title']);
+ $bodytext = stripslashes($a['bodytext']);
+ $username = $a['name'];
+ $gravatar = 'http://www.gravatar.com/avatar/' . $a['email'] . '?s=48';
+ $date = $a['created'];
+
+ $entry_display .= <<
+$username : $title
+
$bodytext
+
Posted: $date
+
+
+ENTRY_DISPLAY;
+ }
+ $entry_display .= '
'.$pagelist.'
';
+ }
+ else {
+ $entry_display .= <<
+ No entries have been made on this page.
+
+
+ENTRY_DISPLAY;
+ }
+
+ /*
+ $entry_display .= <<
+ Add a New Entry
+
+
+ ADMIN_OPTION;
+ */
+ return $entry_display;
+ }
+
+ /*
+ This function will be used to display the new comment entry form
+ */
+ public function display_post() {
+ return <<
+ New Blog Entry
+
+
+
+ADMIN_FORM;
+ }
+
+ public function write($p) {
+ if ( $p['title'] )
+ $title = mysql_real_escape_string(strip_tags($_POST['title']));
+ if ( $p['bodytext'])
+ $bodytext = mysql_real_escape_string(strip_tags($_POST['bodytext']));
+ $name = $_SESSION['username'];
+ $email = $_SESSION['email'];
+
+ if ( $title && $bodytext ) {
+ $created = date("g:iA M d, Y");
+ $sql = "INSERT INTO blog (title, bodytext, created, name, email)VALUES('$title','$bodytext','$created','$name', '$email' )";
+ return mysql_query($sql) or die("Could not select database. " . mysql_error());
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ This function connects to the database
+ */
+ public function connect() {
+ mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error());
+ mysql_select_db($this->table) or die("Could not select database. " . mysql_error());
+
+ return $this->buildDB();
+ }
+
+ private function buildDB() {
+ $sql = <<
\ No newline at end of file
diff --git a/classes/comments.php b/classes/comments.php
new file mode 100755
index 0000000..f77aa47
--- /dev/null
+++ b/classes/comments.php
@@ -0,0 +1,187 @@
+host = $host;
+ $this->username = $username;
+ $this->password = $password;
+ $this->db = $db;
+ $this->table = $table;
+ $this->connect();
+ }
+
+ /**
+ deletes all the comments in the database for the suppled report
+ */
+ public function delete_comment($id, $thread){
+ $table = $this->table;
+ $q = "DELETE FROM $table WHERE report = '$thread' and id = '$id'";
+ mysql_query($q);
+ return"Deleted Post";
+ }
+
+ /**
+ Display all comment entrys for the specified report
+ */
+ public function get_comments($report) {
+
+ $page = $_SERVER['PHP_SELF'];
+
+ $table = $this->table;
+
+ $entry_display .= <<
+ Comments
+
+
+ENTRY_DISPLAY;
+
+ $q = "SELECT * FROM $table WHERE report=".$report." ORDER BY id";
+ $r = mysql_query($q);
+
+ if ( $r !== false && mysql_num_rows($r) > 0 ) {
+ while ( $a = mysql_fetch_assoc($r) ) {
+ $title = stripslashes($a['title']);
+ $bodytext = stripslashes($a['bodytext']);
+ $username = $a['name'];
+ $gravatar = 'http://www.gravatar.com/avatar/' . $a['email'] . '?s=48';
+ $date = $a['created'];
+ $id = $a['id'];
+
+ $entry_display .= <<$username : $title
+ENTRY_DISPLAY;
+
+ if($_SESSION['access'] == "admin" || $_SESSION['username'] == $username)
+ $entry_display .= <<Delete Post
+ENTRY_DISPLAY;
+
+
+ $entry_display .= <<
+
$bodytext
+
Posted: $date
+
+
+ENTRY_DISPLAY;
+ }
+ }
+ else {
+ $entry_display .= <<
+ No entries have been made on this page.
+
+
+ENTRY_DISPLAY;
+ }
+
+ /*
+ $entry_display .= <<
+ Add a New Entry
+
+
+ADMIN_OPTION;
+*/
+ return $entry_display;
+ }
+
+ /*
+ This function will be used to display the new comment entry form
+ */
+ public function display_post($report) {
+
+ return <<
+ New Comment
+
+
+
+ADMIN_FORM;
+ }
+
+ public function write($thread, $title, $body) {
+ $table = $this->table;
+ $title = mysql_real_escape_string(strip_tags($title));
+ $bodytext = mysql_real_escape_string(strip_tags($body));
+ $name = $_SESSION['username'];
+ $email = $_SESSION['email'];
+
+ if ( $title && $bodytext ) {
+ $created = date("g:iA M d, Y");
+ $sql = "INSERT INTO $table (title, bodytext, created, report, name, email) VALUES ('$title','$bodytext','$created','$thread', '$name', '$email' )";
+ return mysql_query($sql) or die("Could not instert." . mysql_error());
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ This function connects to the database
+ */
+ public function connect() {
+ mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error());
+ mysql_select_db($this->db) or die("Could not select database. " . mysql_error());
+
+ return $this->buildDB();
+ }
+
+ private function buildDB() {
+ $table = $this->table;
+ $sql = <<
diff --git a/classes/conf.php b/classes/conf.php
new file mode 100755
index 0000000..04f74ce
--- /dev/null
+++ b/classes/conf.php
@@ -0,0 +1,11 @@
+
diff --git a/classes/content.php b/classes/content.php
new file mode 100644
index 0000000..85bce34
--- /dev/null
+++ b/classes/content.php
@@ -0,0 +1,211 @@
+host = $host;
+ $this->username = $username;
+ $this->password = $password;
+ $this->db = $db;
+ $this->connect();
+ $this->id = $this->get_id_from_key($key);
+ $this->key = $key;
+ }
+
+ public function get_id_from_key($key){
+ $q = "SELECT * FROM pages WHERE pagekey='$key'";
+ $r = mysql_query($q);
+
+ if ( $r !== false && mysql_num_rows($r) > 0 ) {
+ $a = mysql_fetch_assoc($r);
+ return $a['id'];
+ }
+}
+
+/**
+ deletes a page by its id
+ */
+ public function delete_content(){
+ $id = $this->id;
+ $q = "DELETE FROM pages WHERE id = '$id'";
+ return mysql_query($q);
+ }
+
+ /**
+ returns the raw content for a page in an array
+ keys are:
+ title
+ bodytext
+ id
+ */
+ public function get_content() {
+ $q = "SELECT * FROM pages WHERE id=".$this->id;
+ $r = mysql_query($q);
+
+ if ( $r !== false && mysql_num_rows($r) > 0 ) {
+ return mysql_fetch_assoc($r);
+ }
+ }
+
+ /*
+ returns a html formated body
+ */
+ public function get_body() {
+ $key = $this->key;
+ $a = $this->get_content();
+ $body = $this->txt2html($a['bodytext']);
+ if($_SESSION['access'] == admin) {
+ $body .= "Edit";
+ }
+ return $body;
+ }
+
+ /*
+ returns a non formated body
+ */
+ public function get_title() {
+ $a = $this->get_content();
+ return $a['title'];
+ }
+
+ /*
+ This function will be used to edit a page
+ */
+ public function display_editor() {
+ $content = $this->get_content();
+ $id = $this->id;
+ $key = $this->key;
+ $title = $content['title'];
+ $body = $content['bodytext'];
+
+ return <<
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ADMIN_FORM;
+ }
+
+ /*
+ saves page information
+ */
+ public function write($title, $body) {
+ $title = mysql_real_escape_string(strip_tags($title));
+ $bodytext = mysql_real_escape_string($body);
+ $key = $this->key;
+ $updateStm = "UPDATE pages SET title='$title', bodytext='$body' WHERE pagekey='$key'";
+
+ mysql_query($updateStm);
+
+ if(mysql_affected_rows()<=0){
+ $sql = "INSERT INTO pages (title, bodytext, pagekey)VALUES('$title','$bodytext','$key')";
+ mysql_query($sql);
+ }
+ }
+
+ /**
+ This function connects to the database
+ */
+ public function connect() {
+ mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error());
+ mysql_select_db($this->db) or die("Could not select database. " . mysql_error());
+
+ return $this->buildDB();
+ }
+
+ private function buildDB() {
+ $sql = <<$part ){
+ $parts[ $key ] = substr($string, $pos, strlen($part));
+ $pos += strlen($part) + strlen($find);
+ }
+
+ return( join( $replace, $parts ) );
+}
+
+
+public function txt2html($txt) {
+// Transforms txt in html
+
+ //Kills double spaces and spaces inside tags.
+ while( !( strpos($txt,' ') === FALSE ) ) $txt = str_replace(' ',' ',$txt);
+ $txt = str_replace(' >','>',$txt);
+ $txt = str_replace('< ','<',$txt);
+
+ //Transforms accents in html entities.
+ $txt = htmlentities($txt);
+
+ //We need some HTML entities back!
+ $txt = str_replace('"','"',$txt);
+ $txt = str_replace('<','<',$txt);
+ $txt = str_replace('>','>',$txt);
+ $txt = str_replace('&','&',$txt);
+
+ //Ajdusts links - anything starting with HTTP opens in a new window
+ $txt = $this->stri_replace("stri_replace("'.str_replace("$eol$eol","