Skip to content

Commit

Permalink
Fix #83 by setting the cookie for the root path, it was previously
Browse files Browse the repository at this point in the history
setting the cookies for every sub folder, I am amazed how this worked
until now
  • Loading branch information
vampy committed Oct 30, 2017
1 parent 69bd03b commit 14ce82b
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion assets/js/addon.js
Expand Up @@ -174,7 +174,7 @@
EMPTY_FUNCTION, "GET");
});

// addon proprieties changed
// addon properties changed
addonFormSubmit("#addon-edit-props", function(data) {
jsonCallback(data, function() {
// update view
Expand Down
13 changes: 9 additions & 4 deletions assets/js/util.js
Expand Up @@ -233,18 +233,23 @@ function getByID(id) {
/**
* Parse a json string
*
* @param {string} raw_string the json string
* @param {string|object} raw_string_or_object the json string
*
* @return {object} the parsed json data, or empty object if there was an error, and message written to the console
*/
function parseJSON(raw_string) {
function parseJSON(raw_string_or_object) {
// already an object return
if (_.isObject(raw_string_or_object)) {
return raw_string_or_object;
}

var jData = {}; // silently fail on the client side

try {
jData = JSON.parse(raw_string);
jData = JSON.parse(raw_string_or_object);
} catch (e) {
console.error("Parson JSON error: ", e);
console.error("Raw string: ", raw_string);
console.error("Raw string: ", raw_string_or_object);
}

return jData;
Expand Down
2 changes: 1 addition & 1 deletion include/Addon.class.php
Expand Up @@ -1665,7 +1665,7 @@ public static function search($search_query, $type, array $search_flags)
if ($e->getCode() == ErrorType::ADDON_REVISION_MISSING)
{
// ignore corrupt addon
Debug::addMessage("No revision for addon = " . $addon['name']);
Debug::addMessage("No revision for addon = " . $addon['id']);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion include/Session.class.php
Expand Up @@ -187,7 +187,7 @@ public static function start($name = "STK_SESSID", $lifetime_sec = 21600)
{
// apparently session_set_cookie_params does not work, see first comment on this page
// https://secure.php.net/manual/ro/function.session-set-cookie-params.php
setcookie(session_name(), session_id(), time() + $lifetime_sec);
setcookie(session_name(), session_id(), time() + $lifetime_sec, "/");
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion json/addons.php
Expand Up @@ -20,13 +20,14 @@
*/
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . "config.php");

header("Content-Type: application/json");
if (empty($_POST["action"]))
{
exit_json_error("action param is not defined or is empty");
}
if (!User::isLoggedIn())
{
exit_json_error("You are not logged in");
exit_json_error("You are not logged in.");
}


Expand Down
1 change: 1 addition & 0 deletions json/bugs.php
Expand Up @@ -19,6 +19,7 @@
*/
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . "config.php");

header("Content-Type: application/json");
if (empty($_POST["action"]))
{
exit_json_error("action param is not defined or is empty");
Expand Down
1 change: 1 addition & 0 deletions json/image_list.php
Expand Up @@ -26,6 +26,7 @@

require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . "config.php");

header("Content-Type: application/json");
// Quit if no ID was passed
if (!isset($_GET['id']))
{
Expand Down
1 change: 1 addition & 0 deletions json/license.php
Expand Up @@ -26,6 +26,7 @@
*/
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . "config.php");

header("Content-Type: application/json");
// Quit if no ID was passed
if (!isset($_GET['id']))
{
Expand Down
1 change: 1 addition & 0 deletions json/manage.php
Expand Up @@ -19,6 +19,7 @@
*/
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . "config.php");

header("Content-Type: application/json");
if (!isset($_POST["action"]) || empty($_POST["action"]))
{
exit_json_error("action param is not defined or is empty");
Expand Down
1 change: 1 addition & 0 deletions json/rating.php
Expand Up @@ -20,6 +20,7 @@
*/
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . "config.php");

header("Content-Type: application/json");
if (empty($_GET['addon-id']))
{
exit_json_error('No addon id provided');
Expand Down
1 change: 1 addition & 0 deletions json/search.php
Expand Up @@ -20,6 +20,7 @@
*/
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . "config.php");

header("Content-Type: application/json");
if (empty($_GET["data-type"]))
{
exit_json_error("data-type param is not defined or is empty");
Expand Down
1 change: 1 addition & 0 deletions json/users.php
Expand Up @@ -19,6 +19,7 @@
*/
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . "config.php");

header("Content-Type: application/json");
if (!isset($_POST["action"]))
{
exit_json_error("action param is not defined or is empty");
Expand Down

0 comments on commit 14ce82b

Please sign in to comment.