diff --git a/.htaccess b/.htaccess index afeb18f..e93d4d6 100644 --- a/.htaccess +++ b/.htaccess @@ -15,6 +15,39 @@ RewriteRule ^edit-recipe/([0-9]+)$ ?site=edit-recipe&number=$1 #Loginseite - RewriteRule ^login/url=(.+)$ ?site=login&refurl=$1 [L] + RewriteRule ^login/url=(.+)$ ?site=login&refurl=$1 + #API Calls + RewriteRule ^api/([\w-]+)/([\w-]+)$ php/api.php?site=api&call=$1&function=$2 [L] + + + Order Deny,Allow + Deny from all + Allow from 127.0.0.1 + + + + Order Allow,Deny + Allow from all + + + + Order Allow,Deny + Allow from all + + + + Order Allow,Deny + Allow from all + + + + Order Allow,Deny + Allow from all + + + + Order Allow,Deny + Allow from all + diff --git a/bin/autocomplete.js b/bin/autocomplete.js index 2378e98..31daf95 100644 --- a/bin/autocomplete.js +++ b/bin/autocomplete.js @@ -71,10 +71,8 @@ var values = []; $(document).ready(function(){ $.ajax({ type: "POST", - url: "/php/edit-recipes.php", - data: { - function: "auto", - }, + url: "/api/recipes/auto", + data: {}, success: function(data){ values = data.split("||"); } diff --git a/bin/edit-recipe.js b/bin/edit-recipe.js index c232c80..dd171e0 100644 --- a/bin/edit-recipe.js +++ b/bin/edit-recipe.js @@ -1,16 +1,15 @@ $(document).ready(function(){ var recipeID = window.location.href.split("/")[(window.location.href.split("/").length-1)]; - $("#FormSubmitfunction").prop("value", "update"); + $("#newRecipeForm").prop("action", "/api/recipes/update"); $.ajax({ type: "POST", - url: "/php/edit-recipes.php", + url: "/api/recipes/edit", data: { - function: "edit", id: recipeID }, success: function(data){ var recipe = JSON.parse(data); - $("#FormSubmitfunction").after(""); + $("#safeRecipe").before(""); $("#RecipeFormName").val(recipe.Name); $("#recipeDurationInput").val(recipe.Dauer); $("#recipeDescription").val(recipe.Beschreibung); diff --git a/bin/list.js b/bin/list.js index f469531..c2f447f 100644 --- a/bin/list.js +++ b/bin/list.js @@ -3,9 +3,8 @@ $(document).ready(function(){ var dataId = $(this).parent().data("id"); $.ajax({ type: "POST", - url: "php/edit-list.php", + url: "api/list/check", data: { - function: "check", id: dataId, status: $(this).prop("checked") }, @@ -18,10 +17,7 @@ $(document).ready(function(){ $("#remove").click(function(){ $.ajax({ type: "POST", - url: "php/edit-list.php", - data: { - function: "del" - }, + url: "api/list/del", success: function(){ location.reload(); } diff --git a/bin/manageRecipe.js b/bin/manageRecipe.js index fb8723a..d968106 100644 --- a/bin/manageRecipe.js +++ b/bin/manageRecipe.js @@ -14,9 +14,8 @@ $(document).ready(function(){ if(!(confirm("Wirklich löschen?"))){return;} $.ajax({ type: "POST", - url: "/php/edit-recipes.php", + url: "/api/recipes/del", data: { - function: "del", id: $("#recipeHeader").data("recipeid") }, success: function(data){ diff --git a/bin/recipe.js b/bin/recipe.js index 7fba722..d87a83f 100644 --- a/bin/recipe.js +++ b/bin/recipe.js @@ -14,9 +14,8 @@ $(document).ready(function(){ if(!(confirm("Wirklich löschen?"))){return;} $.ajax({ type: "POST", - url: "/php/edit-recipes.php", + url: "/api/recipes/del", data: { - function: "del", id: $("#recipeHeader").data("recipeid") }, success: function(data){ @@ -45,10 +44,9 @@ $(document).ready(function(){ }); $.ajax({ type: "POST", - url: "/php/edit-list.php", + url: "/api/list/multiple", data: { - list: list, - function: "multiple" + list: list }, success: function(data){ window.location = "/"; diff --git a/bin/settings.js b/bin/settings.js index 51164bb..0461d18 100644 --- a/bin/settings.js +++ b/bin/settings.js @@ -52,13 +52,13 @@ $(document).ready(function(){ }); $("#export-recipe-button").click(function(){ - $.post("/php/edit-recipes.php", {function:"export"}, function(data){ + $.post("/api/recipes/export", {}, function(data){ downloadObjectAsJson(JSON.parse(data), "recipes"); }); }); $("#export-list-button").click(function(){ - $.post("/php/edit-list.php", {function:"export"}, function(data){ + $.post("/api/list/export", {}, function(data){ downloadObjectAsJson(JSON.parse(data), "list"); }); }); @@ -70,9 +70,8 @@ $(document).ready(function(){ reader.onload = function(){ var content = JSON.parse(reader.result); if(content.sites!=null){ - $.post("/php/edit-recipes.php", + $.post("/api/recipes/import", { - function: "import", content: reader.result }, function(data){ @@ -87,9 +86,8 @@ $(document).ready(function(){ ); } else if(content.list!=null){ - $.post("/php/edit-list.php", + $.post("/api/list/import", { - function: "import", content: reader.result }, function(data){ diff --git a/config/.htaccess b/config/.htaccess deleted file mode 100644 index 98e9e6d..0000000 --- a/config/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ -# prevent access to these files while not logged in - - Require all denied - diff --git a/cont/.htaccess b/cont/.htaccess deleted file mode 100644 index 98e9e6d..0000000 --- a/cont/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ -# prevent access to these files while not logged in - - Require all denied - diff --git a/cont/list.php b/cont/list.php index 7810c60..15a2b90 100644 --- a/cont/list.php +++ b/cont/list.php @@ -2,7 +2,7 @@

Liste

-
+
Neu"; } ?> - - +
Name:
Dauer (Minuten):
diff --git a/install/install_action.php b/install/install_action.php index a6cd929..6596719 100644 --- a/install/install_action.php +++ b/install/install_action.php @@ -209,5 +209,5 @@ foreach($SQLStatements as $statement){ $result = $connection->query($statement); } $connection->close(); -header ("Location: adduser.php"); +header ("Location: install_adduser.php"); ?> diff --git a/install/adduser.php b/install/install_adduser.php similarity index 100% rename from install/adduser.php rename to install/install_adduser.php diff --git a/php/.htaccess b/php/.htaccess deleted file mode 100644 index da07521..0000000 --- a/php/.htaccess +++ /dev/null @@ -1,16 +0,0 @@ -# prevent access to these files while not logged in - - Require all denied - - - - Require all denied - - - - Require all denied - - - - Require all denied - diff --git a/php/api.php b/php/api.php new file mode 100644 index 0000000..5422efd --- /dev/null +++ b/php/api.php @@ -0,0 +1,20 @@ + diff --git a/php/edit-list.php b/php/edit-list.php index 82326c9..6fab0cf 100644 --- a/php/edit-list.php +++ b/php/edit-list.php @@ -1,9 +1,8 @@ newItem($_POST["anzahl"], $_POST["einheit"], $_POST["name"]); header("Location: /list"); diff --git a/php/edit-recipes.php b/php/edit-recipes.php index aa068c6..54be070 100644 --- a/php/edit-recipes.php +++ b/php/edit-recipes.php @@ -1,9 +1,8 @@ removeRecipe($_POST["id"]); break; diff --git a/php/edit-user.php b/php/edit-user.php index 4729fee..9aa0bdd 100644 --- a/php/edit-user.php +++ b/php/edit-user.php @@ -1,12 +1,11 @@ get_info($_COOKIE["token"]); } - switch ($_POST["function"]) { + switch ($_GET["function"]) { case 'change-pw': $user->change_password($_POST["current"], $_POST["new"]); break;