An easy point of sale system with automatic inventory tracking. https://netsyms.biz/apps/nickelbox/
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

api.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. * Simple JSON API to allow other apps to access data from this app.
  7. *
  8. * Requests can be sent via either GET or POST requests. POST is recommended
  9. * as it has a lower chance of being logged on the server, exposing unencrypted
  10. * user passwords.
  11. */
  12. require __DIR__ . '/required.php';
  13. header("Content-Type: application/json");
  14. $username = $VARS['username'];
  15. $password = $VARS['password'];
  16. $user = User::byUsername($username);
  17. if ($user->exists() !== true || Login::auth($username, $password) !== Login::LOGIN_OK) {
  18. header("HTTP/1.1 403 Unauthorized");
  19. die("\"403 Unauthorized\"");
  20. }
  21. // query max results
  22. $max = 20;
  23. if (preg_match("/^[0-9]+$/", $VARS['max']) === 1 && $VARS['max'] <= 1000) {
  24. $max = (int) $VARS['max'];
  25. }
  26. switch ($VARS['action']) {
  27. case "ping":
  28. $out = ["status" => "OK", "maxresults" => $max, "pong" => true];
  29. exit(json_encode($out));
  30. default:
  31. header("HTTP/1.1 400 Bad Request");
  32. die("\"400 Bad Request\"");
  33. }