api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

base.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. $settings = [
  3. 'database' => 'php-crud-api',
  4. 'username' => 'php-crud-api',
  5. 'password' => 'php-crud-api',
  6. 'controllers' => 'records,columns,cache,openapi',
  7. 'middlewares' => 'cors,jwtAuth,basicAuth,authorization,validation,ipAddress,sanitation,multiTenancy,pageLimits,joinLimits,customization',
  8. 'jwtAuth.mode' => 'optional',
  9. 'jwtAuth.time' => '1538207605',
  10. 'jwtAuth.secret' => 'axpIrCGNGqxzx2R9dtXLIPUSqPo778uhb8CA0F4Hx',
  11. 'basicAuth.mode' => 'optional',
  12. 'basicAuth.passwordFile' => __DIR__ . DIRECTORY_SEPARATOR . '.htpasswd',
  13. 'authorization.tableHandler' => function ($operation, $tableName) {
  14. return !($tableName == 'invisibles' && !isset($_SESSION['claims']['name']) && empty($_SESSION['username']));
  15. },
  16. 'authorization.columnHandler' => function ($operation, $tableName, $columnName) {
  17. return !($columnName == 'invisible');
  18. },
  19. 'authorization.recordHandler' => function ($operation, $tableName) {
  20. return ($tableName == 'comments') ? 'filter=message,neq,invisible' : '';
  21. },
  22. 'ipAddress.tables' => 'barcodes',
  23. 'ipAddress.columns' => 'ip_address',
  24. 'sanitation.handler' => function ($operation, $tableName, $column, $value) {
  25. return is_string($value) ? strip_tags($value) : $value;
  26. },
  27. 'validation.handler' => function ($operation, $tableName, $column, $value, $context) {
  28. return ($column['name'] == 'post_id' && !is_numeric($value)) ? 'must be numeric' : true;
  29. },
  30. 'multiTenancy.handler' => function ($operation, $tableName) {
  31. return ($tableName == 'kunsthåndværk') ? ['user_id' => 1] : [];
  32. },
  33. 'pageLimits.pages' => 5,
  34. 'pageLimits.records' => 10,
  35. 'joinLimits.depth' => 2,
  36. 'joinLimits.tables' => 4,
  37. 'joinLimits.records' => 10,
  38. 'customization.beforeHandler' => function ($operation, $tableName, $request, $environment) {
  39. $environment->start = 0.003/*microtime(true)*/;
  40. },
  41. 'customization.afterHandler' => function ($operation, $tableName, $response, $environment) {
  42. if ($tableName == 'kunsthåndværk' && $operation == 'increment') {
  43. return $response->withHeader('X-Time-Taken', 0.006/*microtime(true)*/ - $environment->start);
  44. }
  45. },
  46. 'debug' => false,
  47. ];