index.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * Copyright (C) 2021 Echedey López Romero <elr@disroot.org>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // Show errors on screen
  19. ini_set('display_errors', '1');
  20. ini_set('display_startup_errors', '1');
  21. error_reporting(E_ALL);
  22. // Turn on the output repairing by Tidy
  23. ini_set('tidy.clean_output', '1');
  24. // Load variables
  25. include './variables.php';
  26. // Load functions
  27. include './functions.php';
  28. // Main operation thread
  29. // Check that the operation is done
  30. if (isset($_REQUEST['operation'])) {
  31. $Operation = $_REQUEST['operation'];
  32. // Validate the type of the operation
  33. if ($Operation == 'consult' || $Operation == 'all') {
  34. if ($Operation == 'consult') {
  35. // Check that the operators are sent
  36. if (!isset($_REQUEST['month']) || !isset($_REQUEST['day'])) {
  37. $Result = '<span class="d-block text-center">Must send a month '
  38. . 'and a day.</span>' . PHP_EOL;
  39. } else {
  40. // Set the operators' value
  41. $Month = $_REQUEST['month'];
  42. $Day = $_REQUEST['day'];
  43. // Validate the type of the operators' value
  44. if ($Month == '' || $Day == '') {
  45. $Result = '<span class="d-block text-center">Must set a month '
  46. . 'and a day.</span>' . PHP_EOL;
  47. } else if (is_string($Month) && is_numeric($Day)) {
  48. // Validate day per month
  49. if ($Day >= 1 && $Day <= $Months[$Month]) {
  50. $Result = Consult($Months, $Month, $Day, $Horoscope);
  51. } else {
  52. $Result = '<span class="d-block text-center">Must '
  53. . 'set corresponding values of month and day.'
  54. . '</span>' . PHP_EOL;
  55. }
  56. } else {
  57. $Result = '<span class="d-block text-center">Must set correct '
  58. . 'values for the month and the day.</span>'
  59. . PHP_EOL;
  60. }
  61. }
  62. } else {
  63. $Result = ConsultAll($Horoscope);
  64. }
  65. } else {
  66. $Result = '<span class="d-block text-center">The operation must be '
  67. . '«consult» o «all».</span>' . PHP_EOL;
  68. }
  69. }
  70. // Load view
  71. include './view.php';