diff --git a/.htaccess b/.htaccess
index afeb18f..399fc0d 100644
--- a/.htaccess
+++ b/.htaccess
@@ -15,6 +15,41 @@
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]
+
+#Deny every *.php file
+
+ Order Deny,Allow
+ Deny from all
+ Allow from 127.0.0.1
+
+
+#allow following files
+
+ 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/adduser.js b/bin/adduser.js
index d2cb4c7..9fc6819 100644
--- a/bin/adduser.js
+++ b/bin/adduser.js
@@ -1,13 +1,12 @@
$(document).ready(function(){
$("#button_newuser").click(function(){
- $.post("/php/edit-user.php",
+ $.post("/api/user/new",
{
- function: "new-user",
username: $("#text_user").val(),
passwd: $("#text_passwd").val()
},
function(data){
- if(data==0){
+ if(data=="0"){
infoPopUp("Benutzer erfolgreich erstellt!", 100);
$("#text_user").val("");
$("#text_passwd").val("");
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..ecea9fd 100644
--- a/bin/settings.js
+++ b/bin/settings.js
@@ -31,9 +31,8 @@ $(document).ready(function(){
}
});
$("#passwordSaveButton").click(function(){
- $.post("/php/edit-user.php",
+ $.post("/api/user/change-pw",
{
- function: "change-pw",
current: $("#old-password-input").val(),
new: $("#new-password-input").val()
},
@@ -52,13 +51,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 +69,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 +85,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
-