Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Keep track of saved results, so we know which we can safely delete

  • Loading branch information...
commit 957b8bd0a8a332eadfa148ec93bab6d22549a3ea 1 parent cdbbe79
@NielsLeenheer authored
View
18 backend/index.php
@@ -99,6 +99,7 @@
SET
version = "' . mysql_real_escape_string($payload->version) . '",
revision = "' . mysql_real_escape_string($payload->revision) . '",
+ timestamp = NOW(),
ip = "' . mysql_real_escape_string(get_ip_address()) . '",
uniqueid = "' . mysql_real_escape_string($payload->uniqueid) . '",
score = "' . mysql_real_escape_string($payload->score) . '",
@@ -163,6 +164,23 @@
break;
+ case 'save':
+ $payload = json_decode($_REQUEST['payload']);
+
+ if (!$readonly) {
+ mysql_query('
+ UPDATE
+ results
+ SET
+ used = used + 1,
+ lastUsed = NOW()
+ WHERE
+ uniqueid = "' . mysql_real_escape_string($payload->uniqueid) . '"
+ ');
+ }
+
+ break;
+
case 'confirm':
$payload = json_decode($_REQUEST['payload']);
View
12 backend/models/results.php
@@ -107,6 +107,18 @@ function getByUniqueId($id) {
");
if ($row = mysql_fetch_object($res)) {
+
+ // Update use counter
+ mysql_query('
+ UPDATE
+ results
+ SET
+ used = used + 1,
+ lastUsed = NOW()
+ WHERE
+ uniqueid = "' . mysql_real_escape_string($id) . '"
+ ');
+
return $row;
}
}
View
3  index.html
@@ -322,7 +322,8 @@ <h1 data-i18n><span>HTML<strong>5</strong>test</span> <em>how well does your bro
buttons.appendChild(button);
new Save(button, {
- id: r.uniqueid
+ id: r.uniqueid,
+ onSave: function() { submit('save', '{"uniqueid": "' + r.uniqueid + '"}'); }
});
var button = document.createElement('a');
View
4 scripts/base.js
@@ -377,6 +377,10 @@
"</p>" +
"<p>The unique id for this test is:<br><code>" + this.options.id + "</code></p>" +
"</div>";
+
+ if (this.options.onSave) {
+ this.options.onSave();
+ }
},
open: function(e) {
Please sign in to comment.
Something went wrong with that request. Please try again.