From d0617dd707b38ebbc560f5aab691a6ac9f2e8237 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 24 Dec 2013 14:30:06 -0500 Subject: [PATCH 1/4] Added pretty parameter Closes #22 --- templates/api.phtml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/templates/api.phtml b/templates/api.phtml index c94b09b..e0ae256 100644 --- a/templates/api.phtml +++ b/templates/api.phtml @@ -35,6 +35,13 @@ if ($this->module['api_key'])

{endpoint}?key={key} where {endpoint} is the call being made and {key} is your API key.

+

Results

+ +

The API only returns a JSON formatted string and utilizes both HTTP status codes as well as a response_code variable in the results. On error, there will also be a error variable that will contain additional information about the error that was encountered.

+ +

Pretty Print

+ +

To help with readability of the returned JSON we offer the pretty parameter which will force the JSON output to be prettified. Simply add &pretty=true after your key to use this parameter.

Endpoints

From af9998591ecb202720ffcc8526a4e21259b0ad3e Mon Sep 17 00:00:00 2001 From: Joshua Sherman Date: Sat, 28 Dec 2013 13:56:48 -0500 Subject: [PATCH 2/4] No error when password was bad Caused a weird refresh, not ideal. --- modules/user/authenticate.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/user/authenticate.php b/modules/user/authenticate.php index 6c6363a..c1b8f1b 100644 --- a/modules/user/authenticate.php +++ b/modules/user/authenticate.php @@ -26,9 +26,8 @@ class user_authenticate extends AnonymousModule if ($user['password'] == crypt($_POST['password'], $user['password'])) { setcookie('__auth', base64_encode($uid . '|' . $user['auth']), time() + Time::YEAR, '/'); + return array('status' => 'success', 'url' => '/leaderboards'); } - - return array('status' => 'success', 'url' => '/leaderboards'); } return array('error' => 'Invalid email address or password.'); From ff77cedbdf6beab70e5bbaea5f89dc14d094e57b Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Mon, 30 Jun 2014 08:29:14 -0400 Subject: [PATCH 3/4] Musta been working on something O_o --- modules/api/v1/leaderboard.php | 2 +- modules/leaderboard/edit.php | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/api/v1/leaderboard.php b/modules/api/v1/leaderboard.php index b131677..a67a2bd 100644 --- a/modules/api/v1/leaderboard.php +++ b/modules/api/v1/leaderboard.php @@ -27,7 +27,7 @@ class api_v1_leaderboard extends APIv1 if ($this->uid != $leaderboard['uid']) { - throw new Exception('Leaderboard UID does not belong to you.'); + throw new Exception('Leaderboard does not belong to you.'); } // Sets up our key suffixes diff --git a/modules/leaderboard/edit.php b/modules/leaderboard/edit.php index bd3debf..9fc9207 100644 --- a/modules/leaderboard/edit.php +++ b/modules/leaderboard/edit.php @@ -1,14 +1,30 @@ $leaderboards[$_GET['uid']]); + } + catch (Exception $e) + { + exit($e->getMessage()); + } } } From 82671242864968347f0317d86d79e2c7fab4a9f5 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sat, 12 Jul 2014 18:05:17 -0400 Subject: [PATCH 4/4] Local changes --- public/index.php | 2 +- public/js/jerky.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/index.php b/public/index.php index daa7d24..c70dd10 100644 --- a/public/index.php +++ b/public/index.php @@ -1,6 +1,6 @@ ");var c=""== $(a).attr("method")?"GET":$(a).attr("method"),d=$(a).attr("action");if(""==d)injectMessage(a,"Form element lacks action attribute","error"),$("button, input, textarea",a).removeAttr("readonly"),document.body.style.cursor="default",$("progress",a).remove(),$('[type="submit"]',a).show();else{var f=$(a).serialize(),e=void 0!=typeof $(a).data("readonly")&&!1==$(a).data("readonly");if(e){if(void 0!=typeof $(a).data("preprocessor"))window[$(a).data("preprocessor")]();$("input[type=text]",a).val("");$("select", -a).val("");$("textarea",a).val("");void 0!=typeof $(a).data("focus")&&$($(a).data("focus")).focus()}$.ajax({type:c,url:d,data:f,dataType:"json",success:function(b){"undefined"!=typeof b.success?(b.status="success",b.message=b.success):"undefined"!=typeof b.error&&(b.status="error",b.message=b.error);if("success"!=b.status&&"undefined"!=typeof b.message)injectMessage(a,b.message,"error");else if("success"==b.status){if(("undefined"==typeof b.retain||!1==b.retain)&&!e)$("input[type=text]",a).val(""), +a).val("");$("textarea",a).val("");void 0!=typeof $(a).data("focus")&&$($(a).data("focus")).focus()}$.ajax({type:c,url:d,data:f,dataType:"json",success:function(b,c,d){"undefined"!=typeof b.success?(b.status="success",b.message=b.success):"undefined"!=typeof b.error&&(b.status="error",b.message=b.error);if("success"!=b.status&&"undefined"!=typeof b.message)injectMessage(a,b.message,"error");else if("success"==b.status){if(("undefined"==typeof b.retain||!1==b.retain)&&!e)$("input[type=text]",a).val(""), $("input[type=email]",a).val(""),$("select",a).val(""),$("textarea",a).val("");"undefined"!=typeof b.message&&injectMessage(a,b.message,"success");"undefined"!=typeof b.url&&(parent.location.href=b.url)}if("undefined"!=typeof b.callback)window[b.callback](b);$("button, input, textarea",a).removeAttr("readonly");document.body.style.cursor="default";$("progress",a).remove();$('[type="submit"]',a).show()},error:function(b,c,d){injectMessage(a,d,"error");$("button, input, textarea",a).removeAttr("readonly"); document.body.style.cursor="default";$("progress",a).remove();$('[type="submit"]',a).show()}})}}else return!1}});$("form.ajax").submit(function(){return!1});$("table tr:even td").addClass("even");$("table tr:odd td").addClass("odd")}); function injectMessage(a,c,d,f){"undefined"==typeof d&&(d="error");var e="alert-"+Date.now();c='";$(".alert[generated]",a).remove();$(a).hasClass("box")||$(a).parent(".two-column")?$('[type="submit"]',a).before(c):$(a).prepend(c);e="#"+e;"undefined"!=typeof f&&$(e,a).delay(f).remove();return $(e,a)}function autoTab(a){$(a).val().length>=$(a).attr("maxlength")&&$(a).next().focus()}