]> git.plutz.net Git - invoices/blobdiff - invoices.cgi
use transaction id for all updates
[invoices] / invoices.cgi
index 7e2f35193ae76bfd1012f3d91e0f62c7a40c3837..10aa8fc8726c6a79463d311738a6e96fd2341024 100755 (executable)
@@ -24,6 +24,15 @@ printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
 EOF
 }
 
+tid(){
+  # transaction ID to modify a given file
+  local file="$1"
+  { stat -c %F%i%n%N%s%Y "$file" 2>&-
+    printf %s "$SESSION_ID"
+    server_key
+  } | sha256sum | cut -d\  -f1
+}
+
 info="$(PATH "${PATH_INFO}")"
 
 case $info in
@@ -44,7 +53,6 @@ case $info in
   /update_client)
     . "$_EXEC/clients.sh"
     update_client
-    REDIRECT /clients/
     ;;
   /senders)
     . "$_EXEC/senders.sh"
@@ -59,22 +67,20 @@ case $info in
   /update_sender)
     . "$_EXEC/senders.sh"
     update_sender
-    REDIRECT /senders/
     ;;
   /invoices)
     . "$_EXEC/invoices.sh"
     { list_invoices
-      printf '[a .new href="/invoice/%s" New]' "$(timeid)"
+      printf '[a .new href="/invoices/%s" New]' "$(timeid)"
     } | yield_page invoices
     ;;
-  /invoice/*)
+  /invoices/*)
     . "$_EXEC/invoices.sh"
-    edit_invoice "${info#/invoice/}" |yield_page invoice
+    edit_invoice "${info#/invoices/}" |yield_page invoice
     ;;
   /update_invoice)
     . "$_EXEC/invoices.sh"
     update_invoice
-    REDIRECT "/invoice/$id"
     ;;
   *) REDIRECT /invoices
     ;;