Initial commit Change-Id: I0000000000000000000000000000000000000000

This commit is contained in:
2012-02-05 16:40:26 -05:00
commit 70806096b6
73 changed files with 22457 additions and 0 deletions

11
classes/access.php Executable file
View File

@@ -0,0 +1,11 @@
<?php
/**
A simple auth module that should be included on any page that requires authentication
@author ricky barrette
@author Twenty Codes, LLC
*/
session_start();
if(!$_SESSION['access'] == 'admin') {
header('Location: login.php' ) ;
}
?>

11
classes/auth.php Executable file
View File

@@ -0,0 +1,11 @@
<?php
/**
A simple auth module that should be included on any page that requires authentication
@author ricky barrette
@author Twenty Codes, LLC
*/
session_start();
if(!$_SESSION['loggedIn']) {
header('Location: login.php' ) ;
}
?>

177
classes/blog.php Executable file
View File

@@ -0,0 +1,177 @@
<?php
class blog {
var $host;
var $username;
var $password;
var $table;
/**
* Contructor
* @param String $host
* @param String $username
* @param String $password
* @param String $db
*/
public function blog($host, $username, $password, $db){
$this->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 .= <<<ENTRY_DISPLAY
<div class="post">
<img src="$gravatar" /> <b>$username : $title</b><hr/>
<p> $bodytext
<hr class="commentfooter" /> Posted: $date</p>
</div>
<br/>
ENTRY_DISPLAY;
}
$entry_display .= '<div align="center">'.$pagelist.'</div>';
}
else {
$entry_display .= <<<ENTRY_DISPLAY
<p>
No entries have been made on this page.
</p>
ENTRY_DISPLAY;
}
/*
$entry_display .= <<<ADMIN_OPTION
<p class="admin_link">
<a href="{$_SERVER['PHP_SELF']}?new_comment=1">Add a New Entry</a>
</p>
ADMIN_OPTION;
*/
return $entry_display;
}
/*
This function will be used to display the new comment entry form
*/
public function display_post() {
return <<<ADMIN_FORM
<h2>
New Blog Entry
</h2>
<form action="{$_SERVER['PHP_SELF']}" method="post">
<input type="hidden" name="blog" value="1" />
<div class="clearfix">
<label for="title">Title</label><br />
<div class="input">
<input name="title" id="title" type="text" maxlength="55" class="xlarge" required/>
</div>
</div>
<div class="clearfix">
<label for="bodytext">Body Text</label><br />
<div class="input">
<textarea name="bodytext" id="bodytext" rows=10 cols=56 class="xxlarge"required></textarea>
</div>
</div>
<div class="actions">
<button type="submit" class="btn primary" onclick="checkRequired(this.forum)" >Create This Entry</button>
<button type="reset" class="btn">Cancel</button>
</div>
</form>
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 = <<<MySQL_QUERY
CREATE TABLE IF NOT EXISTS blog (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(150),
bodytext TEXT,
created VARCHAR(100),
name VARCHAR(20),
email VARCHAR(100)
)
MySQL_QUERY;
return mysql_query($sql);
}
}
?>

187
classes/comments.php Executable file
View File

@@ -0,0 +1,187 @@
<?php
class comments {
var $host;
var $username;
var $password;
var $db;
var $table;
/**
* Contructor
* @param String $host
* @param String $username
* @param String $password
* @param String $db
*/
public function comments($table, $host, $username, $password, $db){
$this->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 .= <<<ENTRY_DISPLAY
<h2>
Comments
</h2>
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 .= <<<ENTRY_DISPLAY
<div class="post"><img src="$gravatar" /> <b>$username : $title</b>
ENTRY_DISPLAY;
if($_SESSION['access'] == "admin" || $_SESSION['username'] == $username)
$entry_display .= <<<ENTRY_DISPLAY
<a align="right" href="$page?deletepost=$id&thread=$report" onclick="return confirm('Are you sure You want to delete this post forever?');">Delete Post</a>
ENTRY_DISPLAY;
$entry_display .= <<<ENTRY_DISPLAY
<hr/>
<p> $bodytext
<hr class="commentfooter" /> Posted: $date</p>
</div>
<br/>
ENTRY_DISPLAY;
}
}
else {
$entry_display .= <<<ENTRY_DISPLAY
<p>
No entries have been made on this page.
</p>
ENTRY_DISPLAY;
}
/*
$entry_display .= <<<ADMIN_OPTION
<p class="admin_link">
<a href="{$_SERVER['PHP_SELF']}?new_comment=1">Add a New Entry</a>
</p>
ADMIN_OPTION;
*/
return $entry_display;
}
/*
This function will be used to display the new comment entry form
*/
public function display_post($report) {
return <<<ADMIN_FORM
<h2>
New Comment
</h2>
<form action="{$_SERVER['PHP_SELF']}" method="post">
<input type="hidden" name="comment" value="$report" />
<div class="clearfix">
<label for="title">Title</label><br />
<div class="input">
<input name="title" id="title" type="text" maxlength="55" class="xlarge" required/>
</div>
</div>
<div class="clearfix">
<label for="bodytext">Body Text</label><br />
<div class="input">
<textarea name="bodytext" id="bodytext" rows=10 cols=56 class="xxlarge"required></textarea>
</div>
</div>
<div class="actions">
<button type="submit" class="btn primary" onclick="checkRequired(this.forum)" >Create This Entry</button>
<button type="reset" class="btn">Cancel</button>
</div>
</form>
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 = <<<MySQL_QUERY
CREATE TABLE IF NOT EXISTS $table (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(150),
bodytext TEXT,
created VARCHAR(100),
report INTEGER,
name VARCHAR(20),
email VARCHAR(100)
)
MySQL_QUERY;
return mysql_query($sql);
}
}
?>

11
classes/conf.php Executable file
View File

@@ -0,0 +1,11 @@
<?php
define('DB_HOST', '127.0.0.1');
define('DB_USER', 'exceptionuser');
define('DB_PASSWORD', '#xCeption');
define('DB_DATABASE', 'exceptions_testing');
define('COMPANY_NAME', 'Twenty Codes, LLC');
define('EMAIL', 'twentycodes@gmail.com');
define('MAP_LOCATION', '/exceptionhandler/maps/');
define('REPORT_URL', 'http://powers.doesntexist.com:666/testing/index.php?report=');
?>

211
classes/content.php Normal file
View File

@@ -0,0 +1,211 @@
<?php
/*
This class will be used to maintian web page content.
*/
class content {
var $host;
var $username;
var $password;
var $db;
var $id;
var $key;
function content($host, $username, $password, $db, $key){
$this->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 .= "</br><a href=\"content_manager.php?pagekey=$key\">Edit</a>";
}
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
<form action="{$_SERVER['PHP_SELF']}" method="post">
<input type="hidden" name="page" value="$id" />
<input type="hidden" name="pagekey" value="$key" />
<div class="clearfix">
<label for="title">Title</label><br />
<div class="input">
<input name="title" id="title" type="text" maxlength="55" class="xlarge" value="$title"> </input>
</div>
</div>
<div class="clearfix">
<label for="bodytext">Body Text</label><br />
<div class="input">
<textarea name="bodytext" id="bodytext" rows=10 cols=56 class="xxlarge">$body</textarea>
</div>
</div>
<div class="actions">
<button type="submit" class="btn primary" >Save</button>
<button type="reset" class="btn">Cancel</button>
</div>
</form>
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 = <<<MySQL_QUERY
CREATE TABLE IF NOT EXISTS pages ( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, title TEXT, bodytext TEXT, pagekey TEXT)
MySQL_QUERY;
return mysql_query($sql);
}
public function stri_replace( $find, $replace, $string ) {
// Case-insensitive str_replace()
$parts = explode( strtolower($find), strtolower($string) );
$pos = 0;
foreach( $parts as $key=>$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('&quot;','"',$txt);
$txt = str_replace('&lt;','<',$txt);
$txt = str_replace('&gt;','>',$txt);
$txt = str_replace('&amp;','&',$txt);
//Ajdusts links - anything starting with HTTP opens in a new window
$txt = $this->stri_replace("<a href=\"http://","<a target=\"_blank\" href=\"http://",$txt);
$txt = $this->stri_replace("<a href=http://","<a target=\"_blank\" href=http://",$txt);
//Basic formatting
$eol = ( strpos($txt,"\r") === FALSE ) ? "\n" : "\r\n";
$html = '<p>'.str_replace("$eol$eol","</p><p>",$txt).'</p>';
$html = str_replace("$eol","<br />\n",$html);
$html = str_replace("</p>","</p>\n\n",$html);
$html = str_replace("<p></p>","<p>&nbsp;</p>",$html);
//Wipes <br> after block tags (for when the user includes some html in the text).
$wipebr = Array("table","tr","td","blockquote","ul","ol","li");
for($x = 0; $x < count($wipebr); $x++) {
$tag = $wipebr[$x];
$html = $this->stri_replace("<$tag><br />","<$tag>",$html);
$html = $this->stri_replace("</$tag><br />","</$tag>",$html);
}
return $html;
}
}
?>

34
classes/email.php Executable file
View File

@@ -0,0 +1,34 @@
<?php
require_once('conf.php');
/*
Generates and sends a email to notify devs of a new or updated exception report
*/
function reportEmail($app, $version, $msg, $status, $id){
$companyEmail = EMAIL;
$url = REPORT_URL;
$email = <<<EMAIL
$app $version has generated the following exception:
$msg
$url$id
This email was generated by the Twenty Codes, LLC Exception Handler.
EMAIL;
mail( 'arsenickiss7891@gmail.com' , "$status excpetion report for $app $version" , $email, "From: Exception Handler" );
/*
The following was used if mail() doesnt work. This method seems to be problematic
$temp = fopen("/exceptionhandler/email", 'w');
fwrite($temp, $email);
fclose($temp);
shell_exec("ssmtp -t < /exceptionhandler/email");
unlink("/exceptionhandler/email");
*/
}
?>

342
classes/exceptionReports.php Executable file
View File

@@ -0,0 +1,342 @@
<?php
class exceptionReports{
var $host;
var $username;
var $password;
var $table;
var $maps;
var $email;
var $reporturl;
/**
deletes a report by is id
*/
public function delete_report($id){
mysql_query("DELETE FROM report_comments WHERE report = '$id'");
return mysql_query("DELETE FROM reports WHERE id = '$id'")or die(mysql_error());
}
/**
updates the status of a report
*/
public function set_status($id, $status){
return mysql_query("UPDATE reports SET status='$status' WHERE id=$id");
}
/**
diplays a list of exception reports, this list will link to the indiviual reports
*/
public function display_report_list() {
/* 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 reports"));
/* 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 reports ORDER BY id DESC LIMIT ".$start.", ".$limit);
/* Now get the page list and echo it */
$pagelist = $p->pageList($_GET['page'], $pages);
/* Or you can use a simple "Previous | Next" listing if you don't want the numeric page listing */
//$next_prev = $p->nextPrev($_GET['page'], $pages);
//echo $next_prev;
/* From here you can do whatever you want with the data from the $result link. */
/*
get all the reports
*/
// $result = mysql_query("SELECT * FROM reports");
while($report = mysql_fetch_assoc($r)) {
$msg = stripslashes($report['msg']);
$app = stripslashes($report['app']);
$id = $report['id'];
$status = $report['status'];
$version = $report['version'];
$count = $report['count'];
$status_icon = '<img height="3%" src="res/newbutton.png"/>';
if($status == 'updated')
$status_icon = '<img height="3%" src="res/updatedbutton.png"/>';
else if ($status == 'old')
$status_icon = '<img height="3%" src="res/oldbutton.png"/>';
$entry_display .= <<<ENTRY_DISPLAY
<div class="post">
<b>#$id</b> $status_icon App: <b class="centered">$app $version</b> <div align="right"> Count: <b>$count</b></div><hr/>
<a href="{$_SERVER['PHP_SELF']}?report=$id">$msg</a>
</div>
<br/>
ENTRY_DISPLAY;
}
$entry_display .= '<div class="centered">'.$pagelist.'</div>';
return $entry_display;
}
/**
This will display the specified report
*/
public function display_report($id) {
$id = mysql_real_escape_string($id);
/*
get all the reports
*/
$r = mysql_query("SELECT * FROM reports WHERE id=".$id);
if($report = mysql_fetch_assoc($r)) {
$msg = stripslashes($report['msg']);
$stackTrace = stripslashes($report['stackTrace']);
$cause =stripslashes($report['cause']);
$date = nl2br(stripslashes($report['date']));
$device = nl2br(stripslashes($report['device']));
$version = stripslashes($report['version']);
$app = stripslashes($report['app']);
$description = nl2br(stripslashes($report['description']));
$count = $report['count'];
$status = $report['status'];
$status_icon = '<img height="5%" src="res/newbutton.png"/>';
$update_status_button = '<a href="index.php?report='.$id.'&status=old">Mark as Old</a>';
if($status == 'updated')
$status_icon = '<img height="5%" src="res/updatedbutton.png"/>';
else if ($status == 'old'){
$status_icon = '<img height="5%" src="res/oldbutton.png"/>';
$update_status_button = '<a href="index.php?report='.$id.'&status=new">Mark as New</a>';
}
$entry_display .= <<<ENTRY_DISPLAY
<P align="right">
$update_status_button
<a href="index.php?delete=$id" onclick="return confirm('Are you sure You want to delete this report forever?');">Delete Report</a>
</P>
ENTRY_DISPLAY;
$entry_display .= <<<ENTRY_DISPLAY
<SCRIPT language=javascript Type=Text/javascript>
Function copyToClipBoard(sContents)
{
window.clipboardData.setData("Text", sContents);
alert("The contents have been copied to your clipboard.\t");
}
</SCRIPT>
<form name="report" >
<h2>
<b class="big"> #$id </b>$status_icon
<br/>
$msg
</h2>
<b>Count:</b> $count
<br/>
<br/>
<b>App</b>
<br/>
$app
<br/>
<br/>
<b>Version</b>
<br/>
$version
<br/>
<br/>
<b>Stack Trace</b>
<br/>
<div name="stack" class="codebox" onClick="javascript:document.report.stack.select();
copyToClipBoard(document.report.stack.value);">$stackTrace</div>
<br/>
<b>Cause</b>
<br/>
<div name="cause" class="codebox" onClick="javascript:document.report.cause.select();
copyToClipBoard(document.report.cause.value);">$cause</div>
<br/>
<b>Date</b>
<br/>
$date
<br/>
<b>Devices</b>
<br/>
$device
<br/>
<b>User Descriptions</b>
<br/>
$description
</form>
ENTRY_DISPLAY;
/*
comments
*/
include_once('comments.php');
$obj = new comments("report_comments",DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
$entry_display .= $obj->get_comments($id);
$entry_display .= $obj->display_post($id);;
} else {
echo "<b>No Report Found: $id</b>";
}
return $entry_display;
}
/*
Files a new exception report into the database
*/
public function file_report($report){
include('email.php');
$output = "Filing report...";
/*
add escapes to the data
*/
$report['msg'] = mysql_real_escape_string($report['msg']);
$report['stackTrace'] = mysql_real_escape_string($report['stackTrace']);
$report['cause'] = mysql_real_escape_string($report['cause']);
$report['date'] = mysql_real_escape_string($report['date']) ."\n";
$report['device'] = mysql_real_escape_string($report['device']) ."\n";
$report['version'] = mysql_real_escape_string($report['version']);
$report['app'] = mysql_real_escape_string($report['app']);
$report['description'] = "--START NEW DESCRIPTION--- " . mysql_real_escape_string($report['description']) ."\n";
/*
check to see if a map exist
if it does, then we want to map the stack & cause
*/
$map = $maps. $report['app'] . $report['version'] . ".txt";
if (file_exists($map)) {
$output .= $map . " Exists";
$stack = fopen("tmp/stack", 'w');
$cause = fopen("tmp/cause", 'w');
fwrite($stack, stripcslashes($report['stackTrace']));
fwrite($cause, stripcslashes($report['cause']));
fclose($stack);
fclose($cause);
$retrace = "java -jar ../lib/retrace.jar ".$map . " ";
$output .= "\n";
$output .= $retrace;
$report['stackTrace'] = shell_exec($retrace . "tmp/stack");
$output .= $report['stackTrace'];
$report['cause'] = shell_exec($retrace . "tmp/cause");
unlink("tmp/stack");
unlink("tmp/cause");
} else {
$output .= "There was no existing map for ". $map;
}
/*
Serach for duplicates and try to update them
*/
$updateStm = "UPDATE reports SET count=count+1, status='updated', description=concat(description,'".$report['description']."'), device=concat(device,'".$report['device']."'), date=concat(date,'".$report['date']."') WHERE msg='".$report['msg']."' AND stackTrace='".$report['stackTrace']."' AND cause='".$report['cause']."' AND version='".$report['version']."' AND app='".$report['app']."'";
mysql_query($updateStm);
/*
check to see if there were any row affected
*/
if(mysql_affected_rows()<=0)
{
/*
insert the new report
*/
$insert = "INSERT INTO reports (msg, stackTrace, cause, date, device, version, app, description, count, status) VALUES ('".$report['msg']."', '".$report['stackTrace']."', '".$report['cause']."', '".$report['date']."', '".$report['device']."', '".$report['version']."', '".$report['app']."', '".$report['description']."', 1, 'new')";
if( mysql_query($insert))
$output .= "Successfully filed new report";
reportEmail($report['app'], $report['version'], $report['msg'], "NEW", mysql_insert_id());
return $output;
}
else
{
$output .= "Successfully updated an old report";
/*
we will run a query to get the row id of the updated rows
*/
$query = mysql_query("SELECT * FROM reports WHERE msg='".$report['msg']."' AND stackTrace='".$report['stackTrace']."' AND cause='".$report['cause']."' AND version='".$report['version']."' AND app='".$report['app']."'");
while($r = mysql_fetch_assoc($query)) {
reportEmail($report['app'], $report['version'], $report['msg'], "UPDATED", $r['id']);
}
return $output;
}
}
/*
Converts the entire exception reports database into JSON so it can be downloaded, and parsed
*/
public function get_reports(){
$result = mysql_query("SELECT * FROM reports");
$reports = array();
if(mysql_num_rows($result)) {
while($report = mysql_fetch_assoc($result)) {
$reports[] = array('report'=>$report);
}
}
// header('Content-type: application/json');
return json_encode(array('reports'=>$reports));
}
/*
Connects the 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();
}
/**
Builds the database that will be used to for exception reports
*/
private function buildDB() {
$sql = <<<MySQL_QUERY
CREATE TABLE IF NOT EXISTS reports (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
msg TEXT,
stackTrace TEXT,
cause TEXT,
date TEXT,
device TEXT,
version TEXT,
app TEXT,
description TEXT,
count INTEGER,
status TEXT
)
MySQL_QUERY;
return mysql_query($sql);
}
}
?>

29
classes/footer.php Executable file
View File

@@ -0,0 +1,29 @@
<?php
require_once('classes/conf.php');
require_once('classes/content.php');
$column2 = new content(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE, "column2");
$title = $column2->get_title();
$column2 = "<h2>$title</h2></br>".$column2->get_body();
echo <<< LAYOUT
<!-- Column 1 end -->
</div>
<div class="col2">
<!-- Column 2 start -->
$column2
<!-- Column 2 end -->
</div>
</div>
</div>
LAYOUT;
$name = COMPANY_NAME;
$year = date("Y");
echo <<< FOOTER
<div id="footer">&copy; $name $year</div>
FOOTER;
?>
</body>
</html>

153
classes/guest.php Executable file
View File

@@ -0,0 +1,153 @@
<?php
/**
This class is used to maintian the guests table in the database
@author ricky barrette
@author Twenty Codes, LLC
*/
class guest {
var $host;
var $username;
var $password;
var $table;
/**
* Contructor
* @param String $host
* @param String $username
* @param String $password
* @param String $db
*/
public function guest($host, $username, $password, $db){
$this->host = $host;
$this->username = $username;
$this->password = $password;
$this->table = $db;
$this->connect();
}
/**
Generates and sends a email to notify users of their email
*/
function sendEmail($userEmail, $title, $body){
mail( $userEmail , $title , $body);
}
public function email_guests($title, $body){
$r = mysql_query("SELECT * FROM guests");
if ( $r !== false && mysql_num_rows($r) > 0 )
while ( $a = mysql_fetch_assoc($r) )
$this->sendEmail($a['email'], $title, $body);
}
/**
Display all users as links that remove them
*/
public function display_guest_list() {
$entry_display .= '<h2>Guest List:</h2>';
/* Instantiate class */
require_once("pager.php");
$p = new Pager;
/* Show many results per page? */
$limit = 10;
/* 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 guests"));
/* 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 guests ORDER BY f_name 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) ) {
$address = $a['address'];
$email = $a['email'];
$name = $a['f_name'].' '.$a['l_name'];
$plus_one = $a['plus_one_f_name'].' '.$a['plus_one_l_name'];
$entry_display .= <<<GUEST
<b>$name & $plus_one</b>
<br/>
$address
<br/>
$email
<br/>
<br/>
GUEST;
}
$entry_display .= '<div align="center">'.$pagelist.'</div>';
}
else
$entry_display .= '<p>No entries have been made on this page. </p>';
return $entry_display;
}
public function get_guest_count(){
$sql="select * from guests";
$result=mysql_query($sql);
return mysql_num_rows($result);
}
/**
inserts a new user into the database
@author ricky barrette
*/
public function new_guest($f_name, $l_name, $address, $email, $plus_one_f_name, $plus_one_l_name) {
$sql="select * from guests where email='$email'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1) // If there is a match.
die("User/Email already exists");
$email = mysql_real_escape_string(strip_tags($email));
$f_name = mysql_real_escape_string(strip_tags($f_name));
$l_name = mysql_real_escape_string(strip_tags($l_name));
$address = mysql_real_escape_string(strip_tags($address));
$hash=md5($email);
$sql = "INSERT INTO guests (f_name, l_name, address, email, hash, plus_one_f_name, plus_one_l_name) VALUES('$f_name','$l_name','$address','$email','$hash','$plus_one_f_name','$plus_one_l_name')";
return mysql_query($sql) or die("Could not insert. " . mysql_error());
}
/**
Connects to the database
@author ricky barrette
*/
public function connect() {
$connection = 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();
}
/**
Builds the users table
@author ricky barrette
*/
private function buildDB() {
$sql = <<<MySQL_QUERY
CREATE TABLE IF NOT EXISTS guests (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
f_name TEXT,
l_name TEXT,
address TEXT,
email TEXT,
hash TEXT,
plus_one_f_name TEXT,
plus_one_l_name TEXT)
MySQL_QUERY;
return mysql_query($sql);
}
}
?>

37
classes/header.php Executable file
View File

@@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/screen.css" />
<link rel="shortcut icon" href="res/icon.png" type="image/x-icon" />
<?php
session_start();
require_once('classes/conf.php');
require_once('classes/content.php');
$column1 = new content(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE, "column1");
$title = $column1->get_title();
echo <<<HEADER
<title>$title</title>
</head>
<body>
<div id="header">
<div class="topbar-wrapper" style="z-index: 5;">
<div class="topbar">
<div class="container fixed">
<h3><a class="logo" href="index.php">$title</a></h3>
HEADER;
include_once("classes/navigation_bar.php");
?>
</div>
</div>
</div> <!-- topbar-wrapper -->
</div>
<br/>
<br/>
<div class="colmask leftmenu">
<div class="colleft">
<div class="col1">
<!-- Column 1 start -->
<br/>

43
classes/navigation_bar.php Executable file
View File

@@ -0,0 +1,43 @@
<?php
/*
PRIMARY NAV
*/
$items = array(array("link"=>"index.php", "label"=>"Home"));
array_push($items, array("link"=>"forum.php", "label"=>"Forum"));
array_push($items, array("link"=>"user_manager.php", "label"=>"Control Panel"));
if($_SESSION['access'] == 'admin')
array_push($items, array("link"=>"map_manager.php", "label"=>"Maps"));
if($_SESSION['loggedIn'])
array_push($items, array("link"=>"logout.php", "label"=>"Logout ".$_SESSION['username']));
else
array_push($items, array("link"=>"login.php", "label"=>"Log In"));
$menu = '<ul>';
foreach ($items as $val)
$menu .= '<li><a href="'.$val['link'].'">'.$val['label'].'</a></li>';
$menu .= '</ul>';
/*
SECONDARY NAV
*/
$menu .= '<ul class="nav secondary-nav">';
$items = array();
foreach ($items as $val) {
$menu .= '<li><a href="'.$val['link'].'">'.$val['label'].'</a></li>';
}
$menu .= <<<SEARCH
<form action="index.php"><input name="search" id="search" type="text" placeholder="Report Number"/></form>
SEARCH;
$menu .= '</ul>';
echo $menu;
?>

120
classes/pager.php Executable file
View File

@@ -0,0 +1,120 @@
<?php
/**************************************************************************************
* Class: Pager
* Author: Tsigo <tsigo@tsiris.com>
* Methods:
* findStart
* findPages
* pageList
* nextPrev
* Redistribute as you see fit.
**************************************************************************************/
class Pager
{
/***********************************************************************************
* int findStart (int limit)
* Returns the start offset based on $_GET['page'] and $limit
***********************************************************************************/
function findStart($limit)
{
if ((!isset($_GET['page'])) || ($_GET['page'] == "1"))
{
$start = 0;
$_GET['page'] = 1;
}
else
{
$start = ($_GET['page']-1) * $limit;
}
return $start;
}
/***********************************************************************************
* int findPages (int count, int limit)
* Returns the number of pages needed based on a count and a limit
***********************************************************************************/
function findPages($count, $limit)
{
$pages = (($count % $limit) == 0) ? $count / $limit : floor($count / $limit) + 1;
return $pages;
}
/***********************************************************************************
* string pageList (int curpage, int pages)
* Returns a list of pages in the format of "« < [pages] > »"
***********************************************************************************/
function pageList($curpage, $pages)
{
$page_list = "";
/* Print the first and previous page links if necessary */
if (($curpage != 1) && ($curpage))
{
$page_list .= " <a href=\"".$_SERVER['PHP_SELF']."?page=1\" title=\"First Page\"><<</a> ";
}
if (($curpage-1) > 0)
{
$page_list .= " <a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage-1)."\" title=\"Previous Page\"><</a> ";
}
/* Print the numeric page list; make the current page unlinked and bold */
for ($i=1; $i<=$pages; $i++)
{
if ($i == $curpage)
{
$page_list .= " <b>".$i."</b>";
}
else
{
$page_list .= " <a href=\"".$_SERVER['PHP_SELF']."?page=".$i."\" title=\"Page ".$i."\">".$i."</a>";
}
$page_list .= " ";
}
/* Print the Next and Last page links if necessary */
if (($curpage+1) <= $pages)
{
$page_list .= " <a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage+1)."\" title=\"Next Page\">></a> ";
}
if (($curpage != $pages) && ($pages != 0))
{
$page_list .= " <a href=\"".$_SERVER['PHP_SELF']."?page=".$pages."\" title=\"Last Page\">>></a> ";
}
$page_list .= "</td>\n";
return $page_list;
}
/***********************************************************************************
* string nextPrev (int curpage, int pages)
* Returns "Previous | Next" string for individual pagination (it's a word!)
***********************************************************************************/
function nextPrev($curpage, $pages)
{
$next_prev = "";
if (($curpage-1) <= 0)
{
$next_prev .= "Previous";
}
else
{
$next_prev .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage-1)."\">Previous</a>";
}
$next_prev .= " | ";
if (($curpage+1) > $pages)
{
$next_prev .= "Next";
}
else
{
$next_prev .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage+1)."\">Next</a>";
}
return $next_prev;
}
}
?>

165
classes/threads.php Executable file
View File

@@ -0,0 +1,165 @@
<?php
class threads{
var $host;
var $username;
var $password;
var $table;
/**
* Contructor
* @param String $host
* @param String $username
* @param String $password
* @param String $db
*/
public function threads($host, $username, $password, $db){
$this->host = $host;
$this->username = $username;
$this->password = $password;
$this->table = $db;
$this->connect();
}
/**
deletes a report by is id
*/
public function delete_thread($id){
mysql_query("DELETE FROM comments WHERE report = '$id'");
return mysql_query("DELETE FROM threads WHERE id = '$id'")or die(mysql_error());
}
/**
diplays a list of exception reports, this list will link to the indiviual reports
*/
public function display_report_list() {
/* 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 threads"));
/* 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 threads ORDER BY id LIMIT ".$start.", ".$limit);
/* Now get the page list and echo it */
$pagelist = $p->pageList($_GET['page'], $pages);
/*
get all the reports
*/
$entry_display = '<br/>';
while($thread = mysql_fetch_assoc($r)) {
$title = $thread['title'];
$id = $thread['id'];
$author = $thread['author'];
$entry_display .= <<<ENTRY_DISPLAY
<div class="post">
<a href="forum.php?thread=$id" >#$id $title</a> Started by: $author
</div>
<br/>
ENTRY_DISPLAY;
}
$entry_display .= '<div align="center">'.$pagelist.'</div>';
return $entry_display;
}
/**
This will display the specified report
*/
public function display_thread($id) {
$id = mysql_real_escape_string($id);
/*
get all the reports
*/
$r = mysql_query("SELECT * FROM threads WHERE id=".$id);
if($thread = mysql_fetch_assoc($r)) {
$title = $thread['title'];
$author = $thread['author'];
$time = $thread['time'];
$entry_display = <<<THREAD
<h1>$title</h1>
Started By: $author ~ $time
THREAD;
if($_SESSION['access'] == "admin" || $_SESSION['username'] == $author)
echo <<<DELETE
<a align="right" href="forum.php?delete=$id" onclick="return confirm('Are you sure You want to delete this thread forever?');">Delete Thread</a>
DELETE;
/*
comments
*/
require_once('comments.php');
$comments = new comments("comments",DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
$entry_display .= $comments->get_comments($id);
$entry_display .= $comments->display_post($id);;
} else
return "<b>No Thread Found: $id</b>";
return $entry_display;
}
/*
Files a new exception report into the database
*/
public function file_thread($title, $author, $time){
/*
add escapes to the data
*/
$title = mysql_real_escape_string($title);
/*
insert the new report
*/
$insert = "INSERT INTO threads (title, author, time) VALUES ('$title', '$author', '$time')";
mysql_query($insert);
return mysql_insert_id();
}
/*
Connects the 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();
}
/**
Builds the database that will be used to for exception reports
*/
private function buildDB() {
$sql = <<<MySQL_QUERY
CREATE TABLE IF NOT EXISTS threads (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
title TEXT,
author TEXT,
time TEXT
)
MySQL_QUERY;
return mysql_query($sql);
}
}
?>

75
classes/thumbnail.php Executable file
View File

@@ -0,0 +1,75 @@
<?php
//Thumbnail save settings, feel free to change these. Pre-existing thumbnails need to be deeted for the changes to take effect!!!
$thumbsize = "55"; // Thumbnail size.
$thumbquality = "130"; //the thumbnail JPEG quality.
// Image folder
$images = $_GET['imagefolder'];
// Thumbnail folder
$thumbnails = $_GET['thumbfolder'];
// The file you are resizing
$file = $_GET['im'];
//image name:
$tn_name = $_GET['name'];
// This sets it to a .jpg, but you can change this to png or gif
header('Content-type: image/jpeg');
// Setting the resize parameters
list($width, $height) = getimagesize($file);
if ($width == $height) {
$modwidth = $thumbsize;
$modheight = $thumbsize;
}
else if ($width < $height) {
$zoom = $thumbsize / $width;
$modwidth = $thumbsize;
$modheight = $height * $zoom;
$dstx = 0;
$dsty = ($thumbsize - $modheight)/2;
}
else {
$zoom = $thumbsize / $height;
$modheight = $thumbsize;
$modwidth = $width * $zoom;
$dstx = ($thumbsize - $modwidth)/2;
$dsty = 0;
}
// Resizing the Image
$tn = imagecreatetruecolor($thumbsize, $thumbsize);
$image = imagecreatefromjpeg($file);
imagecopyresampled($tn, $image, $dstx, $dsty, 0, 0, $modwidth, $modheight, $width, $height);
// preparing name for the thumbnail
$splitname = explode (".", $tn_name);
// check if thumbs directory already exists, if not: make one
if (!is_dir("$thumbnails")) {
echo "making dir";
mkdir($thumbnails, 0755);
}
// if it exists, check if directory is writeable, if not: chmod
elseif(!is_writeable("$thumbnails")) {
chmod($thumbnails, 0755);
}
// copying thumbnail with _tn before extension to server
ImageJPEG($tn, $thumbnails . "/$splitname[0]_thumb.jpg", $thumbquality);
// Outputting a .jpg, you can make this gif or png if you want
imagejpeg($tn, null, $thumbquality);
chmod($thumbnails . "/$splitname[0]_thumb.jpg", 0755);
?>

44
classes/thumbnails.php Executable file
View File

@@ -0,0 +1,44 @@
<?php
function php_thumbnails($imagefolder) {
$images = $imagefolder;
$thumbnails = $imagefolder."/thumbs";
//load images into an array and sort them alphabeticall:
$files = array();
if ($handle = opendir($images)){
while (false !== ($file = readdir($handle)))
//Only do JPG's
if(eregi("((.jpeg|.jpg)$)", $file))
$files[] = array("name" => $file);
closedir($handle);
}
//Obtain a list of columns
foreach ($files as $key => $row)
$name[$key] = $row['name'];
//Put images in order:
array_multisort($name, SORT_ASC, $files);
//set the GET variable name
$pic = $imagefolder;
foreach ($files as $file){
$name = $file['name'];
$splitname = explode (".", $name);
$pictitle = str_replace("_"," ",$splitname[0]);
$link = "<a rel=\"lightbox[" . $images . "]\" title=\"$splitname[0]\" href=\"" . $images . "/" . $name . "\">";
if (file_exists("$thumbnails/".$splitname[0]."_thumb.jpg")){
// Load the thumbnail image
echo($link);
echo("<img class=\"thumb\" src=\"" . $thumbnails . "/".$splitname[0]."_thumb.jpg\" alt=\"$pictitle\"></a> \n");
} else {
// Create a thumbnail image
echo($link);
echo("<img class=\"thumb\" src=\"thumbnail.php?imagefolder=" . $images . "&thumbfolder=" . $thumbnails . "&name=" . $file['name'] . "&im=" . $images . "/" . $file['name'] . "\" alt=\"$pictitle\"></a> \n");
}
}
reset($files);
}
?>

195
classes/users.php Executable file
View File

@@ -0,0 +1,195 @@
<?php
/**
This class is used to maintian the users table in the database
@author ricky barrette
@author Twenty Codes, LLC
*/
class users {
var $host;
var $username;
var $password;
var $table;
/**
* Contructor
* @param String $host
* @param String $username
* @param String $password
* @param String $db
*/
public function users($host, $username, $password, $db){
$this->host = $host;
$this->username = $username;
$this->password = $password;
$this->table = $db;
$this->connect();
}
/**
Chnages the password of a user
*/
public function change_password($user, $old, $new){
mysql_query("UPDATE users SET pass='$new' WHERE user='$user' AND pass='$old'");
$count=mysql_affected_rows();
if($count==1)
return true;
else
return false;
}
/**
deletes a user by their username and hasded email
*/
public function delete_user($user, $email){
return mysql_query("DELETE FROM users WHERE user='$user' AND email='$email'")or die(mysql_error());
}
/**
Display all users as links that remove them
*/
public function display_users() {
$entry_display .= <<<ENTRY_DISPLAY
<h2>
Users:
</h2>
ENTRY_DISPLAY;
/* 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 users"));
/* 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 users ORDER BY user 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) ) {
$user = stripslashes($a['user']);
$email = stripslashes($a['email']);
$username = $a['name'];
$gravatar = 'http://www.gravatar.com/avatar/' . $email . '?s=48';
$entry_display .= <<<ENTRY_DISPLAY
<img src="$gravatar" /> <b>$user</b> <a href="user_manager.php?user=$user&email=$email" onclick="return confirm('Are you sure You want to delete the user &lsquo; $user &rsquo; forever?');">Delete $user</a><br/>
ENTRY_DISPLAY;
}
$entry_display .= '<div align="center">'.$pagelist.'</div>';
}
else {
$entry_display .= <<<ENTRY_DISPLAY
<p>
No entries have been made on this page.
</p>
ENTRY_DISPLAY;
}
/*
$entry_display .= <<<ADMIN_OPTION
<p class="admin_link">
<a href="{$_SERVER['PHP_SELF']}?new_comment=1">Add a New Entry</a>
</p>
ADMIN_OPTION;
*/
return $entry_display;
}
/**
checks if a user/pass combo exists in the database
@return true if user/pas combo exists
@author ricky barrette
*/
public function login($user, $pass) {
$sql="select * from users where user='".mysql_real_escape_string($user)."' and pass='$pass';";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
$a = mysql_fetch_assoc($result);
if($count==1){ // If there is a match.
$_SESSION["username"] = $user; // Creates a cookie saving the username
$_SESSION["loggedIn"] = true; // Creates a cookie saying the user is logged in
$_SESSION["access"] = $a['access'];
$_SESSION["email"] = $a['email'];
return true;
} else
return false;
}
/**
inserts a new user into the database
@author ricky barrette
*/
public function new_user($user, $pass, $access, $email) {
$sql="select * from users where user='".mysql_real_escape_string($user)."' and pass='$pass';";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1) // If there is a match.
die("User/Email already exists");
$user = mysql_real_escape_string(strip_tags($user));
$email = md5(mysql_real_escape_string(strip_tags($email)));
$sql = "INSERT INTO users (user, email, access, pass) VALUES('$user','$email','$access','$pass')";
return mysql_query($sql) or die("Could not select database. " . mysql_error());
}
/**
Connects to the database
@author ricky barrette
*/
public function connect() {
$connection = 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();
}
/**
Builds the users table
@author ricky barrette
*/
private function buildDB() {
$sql = <<<MySQL_QUERY
CREATE TABLE IF NOT EXISTS users (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
user TEXT,
email TEXT,
access TEXT,
pass TEXT
)
MySQL_QUERY;
$result = mysql_query($sql);
if($result){
$sql="select * from users where user='admin'";
$result = mysql_query($sql);
$count=mysql_num_rows($result);
if(! $count==1)
mysql_query("INSERT INTO users (user, email, access, pass) VALUES('admin', 'd41d8cd98f00b204e9800998ecf8427e', 'admin','d82494f05d6917ba02f7aaa29689ccb444bb73f20380876cb05d1f37537b7892')");
}
return $result;
}
}
?>