diff --git a/admin.php b/admin.php
index 9787a13..4410531 100644
--- a/admin.php
+++ b/admin.php
@@ -1,39 +1,37 @@
';
- echo '
';
-
- //users
-
- include('user/users.php');
-
- echo '
';
- //profile
- include('user/profile.php');
- echo '
';
-
- echo '';
- echo '
';
-
- //edit user
- include('user/editUser.php');
-
-
- echo '
';
- //new user
- include('user/newUser.php');
- echo '
';
- }
- else
- {
- include('includes/profile.php');
- }
-
-
- require('includes/footer.php');
-?>
\ No newline at end of file
+//11-24-16
+
+require('includes/header.php');
+
+if($admin)
+{
+ echo '';
+ echo '
';
+
+ //users
+
+ include('user/users.php');
+
+ echo '
';
+ //profile
+ include('user/profile.php');
+ echo '
';
+
+ echo '';
+ echo '
';
+
+ //edit user
+ include('user/editUser.php');
+
+
+ echo '
';
+ //new user
+ include('user/newUser.php');
+ echo '
';
+}
+else
+{
+ include('includes/profile.php');
+}
+
+require('includes/footer.php');
\ No newline at end of file
diff --git a/includes/header.php b/includes/header.php
index d372d5c..86429fa 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -1,114 +1,114 @@
-
- Panda Quotes
-
-
-
-
-
-
-
-
-
- ';
- }
- elseif($loggedIn)
- {
- echo '
-
- Panda Quotes
-
-
-
-
-
-
-
-
-
- ';
- }
- else
- {
- echo '
-
- Panda Quotes
-
-
-
-
-
-
-
-
-
- ';
- }
+}
+
+
+if($admin)
+{
+ echo '
+
+ Panda Quotes
+
+
+
+
+
+
+
+
+
+ ';
+}
+elseif($loggedIn)
+{
+ echo '
+
+ Panda Quotes
+
+
+
+
+
+
+
+
+
+ ';
+}
+else
+{
+ echo '
+
+ Panda Quotes
+
+
+
+
+
+
+
+
+
+ ';
+}
diff --git a/index.php b/index.php
index 87395fe..5983c01 100644
--- a/index.php
+++ b/index.php
@@ -1,40 +1,32 @@
';
- echo '';
- echo 'VIDEO ';
- echo '
';
-
- echo '';
- echo '
- ';
- echo '
';
-
-
- echo '';
-
-
-
-
-
- include('includes/footer.php');
-
-?>
+include('includes/header.php');
+
+//first row
+
+
+include 'quotes/panda.php';
+
+
+include('quotes/public.php');
+
+include('quotes/private.php');
+
+
+//4-row
+echo '';
+echo '
';
+echo 'VIDEO ';
+echo '
';
+
+echo '
';
+
+
+echo '
';
+
+include('includes/footer.php');
diff --git a/quotes.php b/quotes.php
index bdb33ec..d733580 100644
--- a/quotes.php
+++ b/quotes.php
@@ -1,50 +1,41 @@
';
- echo '';
-
- //add quote
-
- include('quotes/newQuote.php');
-
- echo '
';
- //profile
- include('user/profile.php');
- echo '
';
-
- echo '';
- echo '
';
-
- //people
- include('quotes/people.php');
-
-
- echo '
';
- //add person
- include('quotes/newPerson.php');
- echo '
';
-
- echo '';
- echo '
';
-
- //people
- include('quotes/allQuotes.php');
-
-
- echo '
';
-
- echo '
';
- }
- else
- {
- include('includes/profile.php');
- }
-
- include('includes/footer.php');
-
-?>
\ No newline at end of file
+if($loggedIn)
+{
+ echo '';
+ echo '
';
+
+ include('quotes/newQuote.php');
+
+ echo '
';
+
+ include('user/profile.php');
+ echo '
';
+
+ echo '';
+ echo '
';
+
+ include('quotes/people.php');
+
+
+ echo '
';
+
+ include('quotes/newPerson.php');
+ echo '
';
+
+ echo '';
+ echo '
';
+
+ include('quotes/allQuotes.php');
+
+
+ echo '
';
+}
+else
+{
+ include('includes/profile.php');
+}
+
+include('includes/footer.php');
diff --git a/quotes/allQuotes.php b/quotes/allQuotes.php
index 3506a51..c90e195 100644
--- a/quotes/allQuotes.php
+++ b/quotes/allQuotes.php
@@ -1,87 +1,81 @@
Quotes';
+
+ $q = "select * from quote";
+
+ $r = mysqli_query($dbc, $q);
+
+ echo '
+
+
+
+ Quote
+ Person
+ Created By
+ Date
+ Delete
+
+
+ ';
+
+ while($row = mysqli_fetch_array($r))
+ {
+ echo '';
+
+ //quote
+ echo "" . $row['quote'] . " ";
+
+ //person
+ $q2 = "select name from people where person_id='"
+ . $row['person_id'] . "'";
+ $r2 = mysqli_query($dbc, $q2);
+ while($row2 = mysqli_fetch_array($r2))
{
- $del_id = mysqli_real_escape_string($dbc, trim($_POST['del_quote_id']));
-
- $q = "delete from quote where quote_id='$del_id' limit 1";
-
- $r = mysqli_query($dbc, $q);
-
- header("Location: quotes.php");
+ echo "" . $row2['name'] . " ";
}
-
-
- echo 'Quotes ';
-
- $q = "select * from quote";
-
- $r = mysqli_query($dbc, $q);
-
- echo '
-
-
-
- Quote
- Person
- Created By
- Date
- Delete
-
-
-
- ';
-
- while($row = mysqli_fetch_array($r))
+
+ //created by
+ $q2 = "select user_name from users where user_id='"
+ . $row['user_id'] . "'";
+ $r2 = mysqli_query($dbc, $q2);
+ while($row2 = mysqli_fetch_array($r2))
{
- echo '';
-
- //quote
- echo "" . $row['quote'] . " ";
-
- //person
- $q2 = "select name from people where person_id='" . $row['person_id'] . "'";
- $r2 = mysqli_query($dbc, $q2);
- while($row2 = mysqli_fetch_array($r2))
- {
- echo "" . $row2['name'] . " ";
- }
-
- //created by
- $q2 = "select user_name from users where user_id='" . $row['user_id'] . "'";
- $r2 = mysqli_query($dbc, $q2);
- while($row2 = mysqli_fetch_array($r2))
- {
- echo "" . $row2['user_name'] . " ";
- }
-
- //date
- $c = Carbon::createFromTimestampUTC(strtotime($row['creation_date'] . ' UTC'));
- echo '' . $c->format('l jS \of F Y') . ' ';
-
-
-
- //del
- echo '';
- echo '';
- echo ' ';
-
- echo ' ';
+ echo "" . $row2['user_name'] . " ";
}
-
- echo '
-
-
';
- }
+ //date
+ $c = Carbon::createFromTimestampUTC(strtotime(
+ $row['creation_date'] . ' UTC'));
+ echo '' . $c->format('l jS \of F Y') . ' ';
-?>
\ No newline at end of file
+ //del
+ echo '';
+ echo '';
+ echo ' ';
+
+ echo ' ';
+ }
+ echo '
';
+}
\ No newline at end of file
diff --git a/quotes/newPerson.php b/quotes/newPerson.php
index 3bd3f68..6dd081f 100644
--- a/quotes/newPerson.php
+++ b/quotes/newPerson.php
@@ -1,44 +1,46 @@
New Person ';
-
- echo '';
-
- foreach($errors as $msg)
- {
- echo " - $msg ";
- }
+ $i_first = mysqli_real_escape_string($dbc,
+ trim($_POST['person_first']));
+ $i_last = mysqli_real_escape_string($dbc,
+ trim($_POST['person_last']));
+
+ $q = "insert into people (name, creation_date) values ('"
+ . $i_first . " " . $i_last . "' , now())";
+
+ $r = mysqli_query($dbc, $q);
+
+ header("Location: quotes.php");
}
-?>
\ No newline at end of file
+ echo 'New Person ';
+
+ echo '';
+
+ foreach($errors as $msg)
+ echo " - $msg ";
+
+}
diff --git a/quotes/newQuote.php b/quotes/newQuote.php
index ddf75ea..d5e8262 100644
--- a/quotes/newQuote.php
+++ b/quotes/newQuote.php
@@ -1,80 +1,84 @@
New Quote ';
-
- echo '';
-
- foreach($errors as $msg)
- {
- echo " - $msg ";
+ header("Location: quotes.php");
}
}
+
+ echo 'New Quote ';
+
+ echo '';
+
+ foreach($errors as $msg)
+ echo " - $msg ";
+
+}
\ No newline at end of file
diff --git a/quotes/panda.php b/quotes/panda.php
index cdee17b..ab887f2 100644
--- a/quotes/panda.php
+++ b/quotes/panda.php
@@ -1,198 +1,187 @@
= count($words))
+ {
+ $lines[] = $currentLine;
+ break;
+ }
+ //Check to see if we can add another word to this line
+ $metrics = $image->queryFontMetrics($draw, $currentLine . ' '
+ . $words[$i+1]);
+ while($metrics['textWidth'] <= $maxWidth)
{
- $currentLine = $words[$i];
+ //If so, do it and keep doing it!
+ $currentLine .= ' ' . $words[++$i];
if($i+1 >= count($words))
- {
- $lines[] = $currentLine;
break;
- }
- //Check to see if we can add another word to this line
- $metrics = $image->queryFontMetrics($draw, $currentLine . ' ' . $words[$i+1]);
- while($metrics['textWidth'] <= $maxWidth)
- {
- //If so, do it and keep doing it!
- $currentLine .= ' ' . $words[++$i];
- if($i+1 >= count($words))
- break;
- $metrics = $image->queryFontMetrics($draw, $currentLine . ' ' . $words[$i+1]);
- }
- //We can't add the next word to this line, so loop to the next line
- $lines[] = $currentLine;
- $i++;
- //Finally, update line height
- if($metrics['textHeight'] > $lineHeight)
- $lineHeight = $metrics['textHeight'];
+ $metrics = $image->queryFontMetrics($draw, $currentLine . ' '
+ . $words[$i+1]);
}
- return array($lines, $lineHeight);
+ //We can't add the next word to this line, so loop to the next line
+ $lines[] = $currentLine;
+ $i++;
+ //Finally, update line height
+ if($metrics['textHeight'] > $lineHeight)
+ $lineHeight = $metrics['textHeight'];
}
-
- function displayImage($quote, $person, $imageLoc)
- {
- $draw = new ImagickDraw();
+ return array($lines, $lineHeight);
+}
+function displayImage($quote, $person, $imageLoc)
+{
+ $draw = new ImagickDraw();
+ $image = new Imagick();
+ $image->readImage($imageLoc);
- $image = new Imagick();
- $image->readImage($imageLoc);
- //grayscale
+ /* Green text */
+ $draw->setFillColor("rgb(0,255,0)");
- //$image->modulateImage(100, 0, 100);
+ /* Font properties */
+ $draw->setFont('Bookman-DemiItalic');
- /* Green text */
- $draw->setFillColor("rgb(0,255,0)");
+ $fontsize = 0.05 * $image->getimagewidth();
- /* Font properties */
- $draw->setFont('Bookman-DemiItalic');
-
- $fontsize = 0.05 * $image->getimagewidth();
-
- $draw->setFontSize( "$fontsize" );
-
- //width = 1180 font is 50
- //width = 300 font is 15
-
- //font = slope of diff(width) + x intercept
-
+ $draw->setFontSize( "$fontsize" );
+ $xpos = $image->getimagewidth()/4;
+ $ypos = $image->getimageheight()/4;
- $xpos = $image->getimagewidth()/4;
- $ypos = $image->getimageheight()/4;
-
-
- $msg = '"' . $quote . '"' . " - $person";
- list($lines, $lineHeight) = wordWrapAnnotation($image, $draw, $msg, $image->getimagewidth() /2);
- for($i = 0; $i < count($lines); $i++)
- {
+ $msg = '"' . $quote . '"' . " - $person";
- $image->annotateImage($draw, $xpos, $ypos + $i*$lineHeight, 0, $lines[$i]);
+ list($lines, $lineHeight) = wordWrapAnnotation($image,
+ $draw, $msg, $image->getimagewidth() /2);
+ for($i = 0; $i < count($lines); $i++)
+ $image->annotateImage($draw, $xpos, $ypos + $i*$lineHeight,
+ 0, $lines[$i]);
+
+
+ /* Give image a format */
+ $image->setImageFormat('png');
+
+ echo ' ';
+}
+function printHalf($query)
+{
+ $r = mysqli_query ($dbc, $query);
+
+ while($row = mysqli_fetch_array($r))
+ {
+ $q2 = "select name from people where person_id='" .
+ $row['person_id'] . "' limit 1";
+
+ $r2 = mysqli_query($dbc, $q2);
+
+ while($row2 = mysqli_fetch_array($r2))
+ {
+ $images = glob('../img/*');
+ displayImage($row['quote'], $row2['name'],
+ $images[rand(0, count($images) - 1)]);
}
+ }
+ echo '';
+}
+
+echo '';
- /* Give image a format */
- $image->setImageFormat('png');
+echo '
';
+echo '
Random Quote ';
+$q ="select * from quote where visibility=true order by rand() limit 1";
+$r = mysqli_query ($dbc, $q);
+while($row = mysqli_fetch_array($r))
+{
+ $q2 = "select name from people where person_id='" . $row['person_id']
+ . "' limit 1";
+ $r2 = mysqli_query($dbc, $q2);
- echo '
';
+ while($row2 = mysqli_fetch_array($r2))
+ {
+ $images = glob('../img/*');
+ displayImage($row['quote'], $row2['name'],
+ $images[rand(0, count($images) - 1)]);
}
- function printHalf($query)
+}
+echo '
';
+echo '
';
+echo '
Most Recent ';
+$q ="select * from quote where visibility=true order by creation_date
+desc limit 1";
+$r = mysqli_query ($dbc, $q);
+
+while($row = mysqli_fetch_array($r))
+{
+ $q2 = "select name from people where person_id='" . $row['person_id']
+ . "' limit 1";
+
+ $r2 = mysqli_query($dbc, $q2);
+
+ while($row2 = mysqli_fetch_array($r2))
{
- //random
-
+ $images = glob('../img/*');
+ displayImage($row['quote'], $row2['name'],
+ $images[rand(0, count($images) - 1)]);
+ }
+}
- $r = mysqli_query ($dbc, $query);
+echo '';
- while($row = mysqli_fetch_array($r))
- {
- $q2 = "select name from people where person_id='" . $row['person_id'] . "' limit 1";
+echo '
';
- $r2 = mysqli_query($dbc, $q2);
+echo '';
- while($row2 = mysqli_fetch_array($r2))
- {
- $images = glob('../img/*');
- displayImage($row['quote'], $row2['name'], $images[rand(0, count($images) - 1)]);
- }
- }
+echo '
';
- echo '
';
- }
-
-
- echo '
';
-
- echo '
';
- echo '
Random Quote ';
- $q ="select * from quote where visibility=true order by rand() limit 1";
- $r = mysqli_query ($dbc, $q);
-
- while($row = mysqli_fetch_array($r))
- {
- $q2 = "select name from people where person_id='" . $row['person_id'] . "' limit 1";
+if(isset($_POST['panda']))
+{
+ displayImage($_POST['panda_quote'], $_POST['panda_name'],
+ $images[rand(0, count($images) - 1)]);
+}
+echo 'Create a panda quote! ';
- $r2 = mysqli_query($dbc, $q2);
- while($row2 = mysqli_fetch_array($r2))
- {
- $images = glob('../img/*');
- displayImage($row['quote'], $row2['name'], $images[rand(0, count($images) - 1)]);
- }
- }
- echo '';
-
-
- echo '
';
- echo '
Most Recent ';
- $q ="select * from quote where visibility=true order by creation_date desc limit 1";
- $r = mysqli_query ($dbc, $q);
+ echo '
';
+
+
+echo '
';
+
+echo '
';
+//profile
+include('user/profile.php');
+echo '
';
+
+echo '
';
+
- echo '
';
-
- echo '';
-
- echo '';
-
- echo '
';
-
- if(isset($_POST['panda']))
- {
- displayImage($_POST['panda_quote'], $_POST['panda_name'], $images[rand(0, count($images) - 1)]);
- }
- echo '
Create a panda quote! ';
-
-
-
- echo '
';
-
-
- echo '
';
-
- echo '
';
- //profile
- include('user/profile.php');
- echo '
';
-
- echo '
';
-
-
?>
diff --git a/quotes/people.php b/quotes/people.php
index d4f0036..d377b54 100644
--- a/quotes/people.php
+++ b/quotes/people.php
@@ -1,60 +1,58 @@
People';
-
- $q = "select * from people";
-
- $r = mysqli_query($dbc, $q);
-
- echo '
-
-
-
- Name
- Delete
-
-
-
- ';
-
- while($row = mysqli_fetch_array($r))
- {
- echo '';
-
- //display name
- echo "" . $row['name'] . " ";
-
- //del
- echo '';
- echo '';
- echo ' ';
-
- echo ' ';
- }
-
- echo '
-
-
';
+ $delete_id = mysqli_real_escape_string($dbc,
+ trim($_POST['del_person_id']));
+
+ $q = "delete from people where person_id='$delete_id' limit 1";
+
+ mysqli_query($dbc, $q);
+
+ $q = "delete from quote where person_id='$delete_id'";
+
+ mysqli_query($dbc, $q);
}
-?>
\ No newline at end of file
+ echo 'People ';
+
+ $q = "select * from people";
+
+ $r = mysqli_query($dbc, $q);
+
+ echo '
+
+
+
+ Name
+ Delete
+
+
+ ';
+
+ while($row = mysqli_fetch_array($r))
+ {
+ echo '';
+
+ //display name
+ echo "" . $row['name'] . " ";
+
+ //del
+ echo '';
+ echo '';
+ echo ' ';
+
+ echo ' ';
+ }
+ echo '
+
+
';
+}
\ No newline at end of file
diff --git a/quotes/private.php b/quotes/private.php
index 9803d03..91ea366 100644
--- a/quotes/private.php
+++ b/quotes/private.php
@@ -1,124 +1,91 @@
';
- echo 'Private Quotes ';
+if($loggedIn)
+{
+ echo '';
+ echo '
Private Quotes ';
- $q_people = "select * from people order by name asc";
+ $q_people = "select * from people order by name asc";
- $r_people = mysqli_query($dbc, $q_people);
- $i = 1;
- $row_count = $r_people->num_rows;
- //echo $row_count;
+ $r_people = mysqli_query($dbc, $q_people);
+ $i = 1;
+ $row_count = $r_people->num_rows;
- //$people_array = mysqli_fetch_array($r_people);
+ echo '
';
- echo '
';
+ while($row = mysqli_fetch_array($r_people))
+ {
- while($row = mysqli_fetch_array($r_people))
+ if($i <= $row_count/2)
{
+ $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=false";
- if($i <= $row_count/2)
- {
- //printPerson($row['person_id']);
- //echo $row['name'];
- $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=false";
- //echo $q_quotes;
- $r = mysqli_query($dbc, $q_quotes);
+ $r = mysqli_query($dbc, $q_quotes);
- if($r->num_rows == 0)
- {
-
- //echo 'nada';
- }
- else
- {
- echo '
';
-
- echo '
';
- while($row_quote = mysqli_fetch_array($r))
- {
- echo '"' . $row_quote['quote'] . '" ';
- }
- echo '
';
+ if($r->num_rows != 0)
+ {
+ echo '
';
- $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1";
- //echo $q_name;
+ echo '
';
+ while($row_quote = mysqli_fetch_array($r))
+ echo '"' . $row_quote['quote'] . '" ';
- $r_name = mysqli_query($dbc, $q_name);
+ echo '
';
- while($row_name = mysqli_fetch_array($r_name))
- {
- echo '
' . $row_name['name'] . '
';
- }
+ $q_name = "select name from people where person_id='" .
+ $row['person_id'] . "' limit 1";
+ $r_name = mysqli_query($dbc, $q_name);
- echo '
';
+ while($row_name = mysqli_fetch_array($r_name))
+ {
+ echo '
' . $row_name['name'] . '
';
}
-
+ echo '
';
}
- $i++;
}
+ $i++;
+ }
- echo '
';
+ echo '
';
- echo '
';
+ echo '
';
- $i = 1;
- $r_people = mysqli_query($dbc, $q_people);
- while($row = mysqli_fetch_array($r_people))
+ $i = 1;
+ $r_people = mysqli_query($dbc, $q_people);
+ while($row = mysqli_fetch_array($r_people))
+ {
+ if($i <= $row_count && $i > $row_count/2)
{
- if($i <= $row_count && $i > $row_count/2)
+ $q_quotes = "select * from quote where person_id='" .
+ $row['person_id'] . "' and visibility=false";
+ $r = mysqli_query($dbc, $q_quotes);
+
+ if($r->num_rows != 0)
{
- //printPerson($row['person_id']);
- //echo $row['name'];
- $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=false";
- //echo $q_quotes;
- $r = mysqli_query($dbc, $q_quotes);
+ echo '
';
- if($r->num_rows == 0)
- {
+ echo '
';
+ while($row_quote = mysqli_fetch_array($r))
+ echo '"' . $row_quote['quote'] . '" ';
- //echo 'nada';
- }
- else
- {
- echo '
';
-
- echo '
';
- while($row_quote = mysqli_fetch_array($r))
- {
- echo '"' . $row_quote['quote'] . '" ';
- }
- echo '
';
+ echo '';
- $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1";
- //echo $q_name;
+ $q_name = "select name from people where person_id='" .
+ $row['person_id'] . "' limit 1";
- $r_name = mysqli_query($dbc, $q_name);
+ $r_name = mysqli_query($dbc, $q_name);
- while($row_name = mysqli_fetch_array($r_name))
- {
- echo '
' . $row_name['name'] . '
';
- }
+ while($row_name = mysqli_fetch_array($r_name))
+ echo '
' . $row_name['name'] . '
';
- echo '
';
- }
+ echo '
';
}
-
-
- $i ++;
}
-
- echo '
';
-
-
- echo '
';
+ $i ++;
}
-
-?>
+
+ echo '
';
+}
diff --git a/quotes/public.php b/quotes/public.php
index ea1d85f..75168a4 100644
--- a/quotes/public.php
+++ b/quotes/public.php
@@ -1,120 +1,98 @@
';
- echo 'Quotes ';
-
- $q_people = "select * from people order by name asc";
-
- $r_people = mysqli_query($dbc, $q_people);
- $i = 1;
- $row_count = $r_people->num_rows;
- //echo $row_count;
-
- //$people_array = mysqli_fetch_array($r_people);
-
- echo '';
-
- while($row = mysqli_fetch_array($r_people))
+echo '
';
+echo '
Quotes ';
+
+$q_people = "select * from people order by name asc";
+
+$r_people = mysqli_query($dbc, $q_people);
+$i = 1;
+$row_count = $r_people->num_rows;
+
+echo '
';
+
+while($row = mysqli_fetch_array($r_people))
+{
+
+ if($i <= $row_count/2)
{
-
- if($i <= $row_count/2)
+ $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=true";
+
+ $r = mysqli_query($dbc, $q_quotes);
+
+ if($r->num_rows != 0)
{
- //printPerson($row['person_id']);
- //echo $row['name'];
- $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=true";
- //echo $q_quotes;
- $r = mysqli_query($dbc, $q_quotes);
+ echo '
';
- if($r->num_rows == 0)
+ echo '
';
+ while($row_quote = mysqli_fetch_array($r))
{
-
- //echo 'nada';
+ echo '"' . $row_quote['quote'] . '" ';
}
- else
- {
- echo '
';
-
- echo '
';
- while($row_quote = mysqli_fetch_array($r))
- {
- echo '"' . $row_quote['quote'] . '" ';
- }
- echo '
';
+ echo '';
- $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1";
- //echo $q_name;
+ $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1";
+ //echo $q_name;
- $r_name = mysqli_query($dbc, $q_name);
+ $r_name = mysqli_query($dbc, $q_name);
- while($row_name = mysqli_fetch_array($r_name))
- {
- echo '
' . $row_name['name'] . '
';
- }
-
- echo '
';
+ while($row_name = mysqli_fetch_array($r_name))
+ {
+ echo '
' . $row_name['name'] . '
';
}
-
+
+ echo '
';
}
- $i++;
-
+
}
-
-
- echo '
';
-
- echo '
';
-
- $i = 1;
- $r_people = mysqli_query($dbc, $q_people);
- while($row = mysqli_fetch_array($r_people))
+ $i++;
+
+}
+
+echo '
';
+
+echo '
';
+
+$i = 1;
+$r_people = mysqli_query($dbc, $q_people);
+while($row = mysqli_fetch_array($r_people))
+{
+ if($i <= $row_count && $i > $row_count/2)
{
- if($i <= $row_count && $i > $row_count/2)
+ //printPerson($row['person_id']);
+ //echo $row['name'];
+ $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=true";
+ //echo $q_quotes;
+ $r = mysqli_query($dbc, $q_quotes);
+
+ if($r->num_rows != 0)
{
- //printPerson($row['person_id']);
- //echo $row['name'];
- $q_quotes = "select * from quote where person_id='" . $row['person_id'] . "' and visibility=true";
- //echo $q_quotes;
- $r = mysqli_query($dbc, $q_quotes);
+ echo '
';
- if($r->num_rows == 0)
+ echo '
';
+ while($row_quote = mysqli_fetch_array($r))
{
-
- //echo 'nada';
+ echo '"' . $row_quote['quote'] . '" ';
}
- else
- {
- echo '
';
-
- echo '
';
- while($row_quote = mysqli_fetch_array($r))
- {
- echo '"' . $row_quote['quote'] . '" ';
- }
- echo '
';
-
- $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1";
- //echo $q_name;
+ echo '';
- $r_name = mysqli_query($dbc, $q_name);
+ $q_name = "select name from people where person_id='" . $row['person_id'] . "' limit 1";
+ //echo $q_name;
- while($row_name = mysqli_fetch_array($r_name))
- {
- echo '
' . $row_name['name'] . '
';
- }
+ $r_name = mysqli_query($dbc, $q_name);
- echo '
';
+ while($row_name = mysqli_fetch_array($r_name))
+ {
+ echo '
' . $row_name['name'] . '
';
}
+
+ echo '
';
}
-
-
- $i ++;
}
-
- echo '
';
+ $i ++;
+}
+
+echo '
';
-
- echo '';
-
-?>
diff --git a/quotes_connect.php b/quotes_connect.php
index 4c75624..cfde725 100644
--- a/quotes_connect.php
+++ b/quotes_connect.php
@@ -1,9 +1,9 @@
\ No newline at end of file
+
+try
+{
+ $dbc = mysqli_connect("127.0.0.1", "quote_user",
+ 'supersecretpassword', "quotes");
+} catch (Exception $ex) {
+ echo 'Bad things just happened';
+}
\ No newline at end of file
diff --git a/user/editUser.php b/user/editUser.php
index 7e59aa5..76cd473 100644
--- a/user/editUser.php
+++ b/user/editUser.php
@@ -1,102 +1,111 @@
Edit User ';
-
- echo '';
-
- foreach($errors as $msg)
+
+ $q = "select user_id from users where user_name ='$i_username'";
+ $r = mysqli_query($dbc, $q);
+
+ while($row = mysqli_fetch_array($r))
{
- echo " - $msg ";
+ $q = "update users set first_name ='$i_first' where user_id='"
+ . $row['user_id'] . "'";
+ $r2 = mysqli_query($dbc, $q);
+
+ $q = "update users set last_name ='$i_last' where user_id='"
+ . $row['user_id'] . "'";
+ $r2 = mysqli_query($dbc, $q);
+
+ $q = "update users set pass ='$passcom' where user_id='"
+ . $row['user_id'] . "'";
+ $r2 = mysqli_query($dbc, $q);
+ //echo $q;
+
+ $q = "update users set admin =$admin_temp where user_id='"
+ . $row['user_id'] . "'";
+ $r2 = mysqli_query($dbc, $q);
+ //echo $q;
+
}
+
+ header("Location: admin.php");
+ }
+
+ echo 'Edit User ';
+
+ echo '';
+
+ foreach($errors as $msg)
+ echo " - $msg ";
+}
\ No newline at end of file
diff --git a/user/newUser.php b/user/newUser.php
index f339a34..a6d0585 100644
--- a/user/newUser.php
+++ b/user/newUser.php
@@ -1,93 +1,90 @@
Add User ';
+
+ echo '';
+
+
+
- foreach($errors as $msg)
- {
- echo " - $msg ";
- }
- }
-
-?>
\ No newline at end of file
+ ';
+
+ foreach($errors as $msg)
+ echo " - $msg ";
+}
\ No newline at end of file
diff --git a/user/profile.php b/user/profile.php
index 172ebb8..0158add 100644
--- a/user/profile.php
+++ b/user/profile.php
@@ -1,145 +1,146 @@
You are now logged out';
+
+ echo(" ");
+}
+
+if(isset($_POST['log_in']))
+{
+ //echo 'Login procces';
+ if(isset($_POST['user_name']))
{
- $_SESSION = array();
-
- echo 'You are now logged out ';
-
- echo(" ");
+ $i_username = @mysqli_real_escape_string($dbc,
+ trim($_POST['user_name']));
+ }
+ else
+ {
+ $errors['User Name'] = 'You need to enter a user name!';
}
- if(isset($_POST['log_in']))
+ if(isset($_POST['password']))
{
- //echo 'Login procces';
- if(isset($_POST['user_name']))
- {
- $i_username = @mysqli_real_escape_string($dbc, trim($_POST['user_name']));
- }
- else
- {
- $errors['User Name'] = 'You need to enter a user name!';
- }
-
- if(isset($_POST['password']))
- {
- $i_password = @mysqli_real_escape_string($dbc, trim($_POST['password']));
- }
- else
- {
- $errors['password'] = "You need to enter a password!";
- }
-
-
- if($i_password && $i_username)
+ $i_password = @mysqli_real_escape_string($dbc,
+ trim($_POST['password']));
+ }
+ else
+ {
+ $errors['password'] = "You need to enter a password!";
+ }
+
+
+ if($i_password && $i_username)
+ {
+
+ //valid username
+ $q3 = "select * from users where user_name='$i_username'";
+ //echo $q3;
+ $r3 = mysqli_query($dbc, $q3);
+
+ if(@mysqli_num_rows($r3) == 1)
{
-
- //valid username
- $q3 = "select * from users where user_name='$i_username'";
- //echo $q3;
- $r3 = mysqli_query($dbc, $q3);
-
- if(@mysqli_num_rows($r3) == 1)
+ //echo 'das good';
+ $firstName = "";
+ while($row = mysqli_fetch_array($r3))
{
- //echo 'das good';
- $firstName = "";
- while($row = mysqli_fetch_array($r3))
- {
- $firstName = $row['first_name'];
-
- }
-
- $q2 = "select * from users where user_name = '$i_username' and pass ='" . SHA1($i_password . $firstName) . "'";
-
- //echo $q2;
-
- $r2 = mysqli_query($dbc, $q2);
-
-
- //30 minutes of error seaching to realize if frogot the s in mysqli
- if(@mysqli_num_rows($r2) == 1)
- {
- while($row = mysqli_fetch_array($r2))
- {
-
- $_SESSION['use'] = true;
- $_SESSION['fname'] = $firstName;
- $_SESSION['user_id'] = $row['user_id'];
- $_SESSION['username'] = $row['user_name'];
- $_SESSION['agent'] = md5($_SERVER['HTTP_USERAGENT'] . 'salt');
-
-
- header("Location: index.php");
- }
- }
- else
+ $firstName = $row['first_name'];
+
+ }
+
+ $q2 = "select * from users where user_name =
+'$i_username' and pass ='" . SHA1($i_password . $firstName) . "'";
+
+ //echo $q2;
+
+ $r2 = mysqli_query($dbc, $q2);
+
+
+ //30 minutes of error seaching to realize if frogot the s in mysqli
+ if(@mysqli_num_rows($r2) == 1)
+ {
+ while($row = mysqli_fetch_array($r2))
{
- $errors['password'] = "You entered an invalid password";
+
+ $_SESSION['use'] = true;
+ $_SESSION['fname'] = $firstName;
+ $_SESSION['user_id'] = $row['user_id'];
+ $_SESSION['username'] = $row['user_name'];
+ $_SESSION['agent'] =
+ md5($_SERVER['HTTP_USERAGENT'] . 'salt');
+
+
+ header("Location: index.php");
}
}
else
{
- $errors['user'] = "You entered an invalid user name!";
+ $errors['password'] = "You entered an invalid password";
}
}
+ else
+ {
+ $errors['user'] = "You entered an invalid user name!";
+ }
}
+}
+
+echo '';
+
+echo '';
+
+if($loggedIn)
+ echo 'Profile';
+else
+ echo 'Log In';
+
+echo ' ';
+
+
+echo '';
+if($loggedIn)
+{
+ echo '
Welcome ' . $_SESSION['fname'] . ' ';
+
+ echo '
';
+
+}
+else
+{
+ //prints login form
+
+ echo '
';
+
+}
+foreach($errors as $msg)
+ echo " - $msg
";
-?>
\ No newline at end of file
+echo '
';
\ No newline at end of file
diff --git a/user/users.php b/user/users.php
index c43d9b3..fd25351 100644
--- a/user/users.php
+++ b/user/users.php
@@ -1,71 +1,68 @@
Users ';
-
- $q = "select * from users order by first_name asc";
+ $i_id = mysqli_real_escape_string($dbc, trim($_POST['del_user_id']));
+
+ $q = "delete from users where user_id='$i_id'";
+
$r = mysqli_query($dbc, $q);
-
- echo '';
+
+ header("Location: admin.php");
+ }
+ echo 'Users ';
+
+ $q = "select * from users order by first_name asc";
+ $r = mysqli_query($dbc, $q);
+
+ echo '';
+}
\ No newline at end of file