From cc7bdf6b3a4dafb46e1de2e067fc5055cce5461f Mon Sep 17 00:00:00 2001 From: rootcoma Date: Sun, 1 Dec 2013 13:51:00 -0800 Subject: [PATCH 1/5] 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(); ?> From 8b9eb3f973f77c4b77a1db7a936e830adb89bf3f Mon Sep 17 00:00:00 2001 From: rootcoma Date: Sun, 1 Dec 2013 13:51:25 -0800 Subject: [PATCH 2/5] Adding modal-table js --- php/js/triviatime.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 php/js/triviatime.js diff --git a/php/js/triviatime.js b/php/js/triviatime.js new file mode 100644 index 0000000..4dccfaf --- /dev/null +++ b/php/js/triviatime.js @@ -0,0 +1,30 @@ +var createModalDiv = function() { + if($('#infoModal').length == 0) { + $('body').append('' + + ''); + } +}; +$(function() { + $(".modal-table > tbody > tr").click(function() { + createModalDiv(); + var headers = $(this).parent("tbody").parent("table").find('th'); + var values = $(this).children("td"); + var content = ''; + for(var i=0;i"; + content += "

" + values.eq(i).text() + "

"; + } + $('#infoModal > .modal-body').html(content); + $('#infoModal').modal('show'); + }); +}); \ No newline at end of file From 2e6f10f91a8bcd3a54fa97e99ff2ed117725063c Mon Sep 17 00:00:00 2001 From: rootcoma Date: Sun, 1 Dec 2013 13:59:03 -0800 Subject: [PATCH 3/5] Fixing labelledby, adding newline --- php/js/triviatime.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/js/triviatime.js b/php/js/triviatime.js index 4dccfaf..300f688 100644 --- a/php/js/triviatime.js +++ b/php/js/triviatime.js @@ -1,7 +1,7 @@ var createModalDiv = function() { if($('#infoModal').length == 0) { $('body').append('' - + '