From cc7bdf6b3a4dafb46e1de2e067fc5055cce5461f Mon Sep 17 00:00:00 2001 From: rootcoma Date: Sun, 1 Dec 2013 13:51:00 -0800 Subject: [PATCH] Redirect user.php->profile.php, show deletes on report.php, open modal with row info --- php/includes/storage.php | 35 +++++++++++++++++++++++ php/index.php | 3 +- php/reports.php | 62 +++++++++++++++++++++++++++++++++++++--- php/user.php | 38 +++++++++++++++--------- 4 files changed, 120 insertions(+), 18 deletions(-) diff --git a/php/includes/storage.php b/php/includes/storage.php index c671f0b..da140b4 100644 --- a/php/includes/storage.php +++ b/php/includes/storage.php @@ -46,6 +46,41 @@ return $result; } + public function getTopDeletions($page, $max) { + if(!$this->isConnected()) { + throw new StorageConnectionException(); + } + if($page < 1) { + $page = 1; + } + if($max < 1) { + $max = 1; + } + $q = $this->db->prepare('SELECT td.*, tq.question as question + FROM triviadelete td + INNER JOIN triviaquestion tq + ON tq.id=td.line_num + ORDER BY id DESC LIMIT :offset, :maxResults'); + $q->execute(array(':offset'=>($page-1) * $max, ':maxResults'=>$max)); + if ($q === false) { + throw new StorageSchemaException(); + } + $result = $q->fetchAll(); + return $result; + } + + public function getCountDeletions() { + if(!$this->isConnected()) { + throw new StorageConnectionException(); + } + $q = $this->db->query('SELECT count(id) FROM triviareport'); + if ($q === false) { + throw new StorageSchemaException(); + } + $result = $q->fetchColumn(); + return $result; + } + public function getTopReports($page, $max) { if(!$this->isConnected()) { throw new StorageConnectionException(); diff --git a/php/index.php b/php/index.php index 2bab2c4..8b3de83 100644 --- a/php/index.php +++ b/php/index.php @@ -66,7 +66,7 @@ try { } $storage->close(); ?> - +
@@ -98,6 +98,7 @@ try { + diff --git a/php/reports.php b/php/reports.php index 77bcd24..7e39d79 100644 --- a/php/reports.php +++ b/php/reports.php @@ -40,6 +40,16 @@ if($newPage < 1) { $newPage = 1; } +if(array_key_exists('dp', $_GET)) { + $deletePage = $_GET['dp']; +} +if(!isset($deletePage)) { + $deletePage = 1; +} +if($deletePage < 1) { + $deletePage = 1; +} + $maxResults = 5; ?> @@ -100,7 +110,7 @@ $maxResults = 5; echo "
Error: Database is not available
"; } ?> - +
@@ -147,7 +157,7 @@ $maxResults = 5; echo "
Error: Database is not available
"; } ?> - +
@@ -219,7 +229,6 @@ $maxResults = 5; -

Added Questions

@@ -235,7 +244,7 @@ $maxResults = 5; echo "
Error: Database is not available
"; } ?> -
+
@@ -262,6 +271,50 @@ $maxResults = 5; +
+
+

Pending Deletions

+ getTopDeletions($deletePage, $maxResults); + $resultCount = $storage->getCountDeletions(); + } catch(StorageSchemaException $e) { + echo "
Error: Database schema is not queryable
"; + } catch(StorageConnectionException $e) { + echo "
Error: Database is not available
"; + } + ?> +
+ + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> + + + paginate(); + ?> + + + @@ -270,6 +323,7 @@ $maxResults = 5; + diff --git a/php/user.php b/php/user.php index b1e4878..0a2efee 100644 --- a/php/user.php +++ b/php/user.php @@ -1,5 +1,3 @@ - - +try { + $users = $storage->getUserLikeUsernameCanonical($usernameCanonical, $page, $maxResults); + $usersCount = $storage->getCountUserLikeUsernameCanonical($usernameCanonical); +} catch(StorageSchemaException $e) { + $errors[] = "Error: Database schema is not queryable"; +} catch(StorageConnectionException $e) { + $errors[] = "Error: Database is not available"; +} + +$storage->close(); + +// Redirect to profile if only 1 result found +if(count($users) == 1) { + header('Location: profile.php?username=' . $users[0]['username']); + die(); +} +?> + Players · TriviaTime @@ -84,15 +102,10 @@ $maxResults = 10; getUserLikeUsernameCanonical($usernameCanonical, $page, $maxResults); - $usersCount = $storage->getCountUserLikeUsernameCanonical($usernameCanonical); - } catch(StorageSchemaException $e) { - echo "
Error: Database schema is not queryable
"; - } catch(StorageConnectionException $e) { - echo "
Error: Database is not available
"; + if(count($errors) != 0) { + foreach($errors as $error) { + echo "
$error
"; + } } if($usersCount==0) { echo "
User not found.
"; @@ -101,7 +114,6 @@ $maxResults = 10; if($usernameCanonical=='') { echo "
Enter a username above to search for stats.
"; } - $storage->close(); ?>