/pages/advanced_search_result/header_php.php

https://github.com/bitweaver/commerce · PHP · 134 lines · 90 code · 23 blank · 21 comment · 45 complexity · 8b2de2638dd70ccff180c1a7bfd3e195 MD5 · raw file

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // |zen-cart Open Source E-commerce |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 2004 The zen-cart developers |
  7. // | |
  8. // | http://www.zen-cart.com/index.php |
  9. // | |
  10. // | Portions Copyright (c) 2003 osCommerce |
  11. // +----------------------------------------------------------------------+
  12. // | This source file is subject to version 2.0 of the GPL license, |
  13. // | that is bundled with this package in the file LICENSE, and is |
  14. // | available through the world-wide-web at the following url: |
  15. // | http://www.zen-cart.com/license/2_0.txt. |
  16. // | If you did not receive a copy of the zen-cart license and are unable |
  17. // | to obtain it through the world-wide-web, please send a note to |
  18. // | license@zen-cart.com so we can mail you a copy immediately. |
  19. // +----------------------------------------------------------------------+
  20. // $Id$
  21. //
  22. require_once(DIR_FS_MODULES . 'require_languages.php');
  23. $error = false;
  24. if ( (isset($_REQUEST['keyword']) && empty($_REQUEST['keyword'])) &&
  25. (isset($_REQUEST['dfrom']) && (empty($_REQUEST['dfrom']) || ($_REQUEST['dfrom'] == DOB_FORMAT_STRING))) &&
  26. (isset($_REQUEST['dto']) && (empty($_REQUEST['dto']) || ($_REQUEST['dto'] == DOB_FORMAT_STRING))) &&
  27. (isset($_REQUEST['pfrom']) && !is_numeric($_REQUEST['pfrom'])) &&
  28. (isset($_REQUEST['pto']) && !is_numeric($_REQUEST['pto'])) ) {
  29. $error = true;
  30. $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
  31. } else {
  32. $dfrom = '';
  33. $dto = '';
  34. $pfrom = '';
  35. $pto = '';
  36. $keywords = '';
  37. if (isset($_REQUEST['dfrom'])) {
  38. $dfrom = (($_REQUEST['dfrom'] == DOB_FORMAT_STRING) ? '' : $_REQUEST['dfrom']);
  39. }
  40. if (isset($_REQUEST['dto'])) {
  41. $dto = (($_REQUEST['dto'] == DOB_FORMAT_STRING) ? '' : $_REQUEST['dto']);
  42. }
  43. if (isset($_REQUEST['pfrom'])) {
  44. $pfrom = $_REQUEST['pfrom'];
  45. }
  46. if (isset($_REQUEST['pto'])) {
  47. $pto = $_REQUEST['pto'];
  48. }
  49. if (isset($_REQUEST['keyword'])) {
  50. $keywords = $_REQUEST['keyword'];
  51. }
  52. $date_check_error = false;
  53. if (zen_not_null($dfrom)) {
  54. if (!zen_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) {
  55. $error = true;
  56. $date_check_error = true;
  57. $messageStack->add_session('search', ERROR_INVALID_FROM_DATE);
  58. }
  59. }
  60. if (zen_not_null($dto)) {
  61. if (!zen_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) {
  62. $error = true;
  63. $date_check_error = true;
  64. $messageStack->add_session('search', ERROR_INVALID_TO_DATE);
  65. }
  66. }
  67. if (($date_check_error == false) && zen_not_null($dfrom) && zen_not_null($dto)) {
  68. if (mktime(0, 0, 0, $dfrom_array[1], $dfrom_array[2], $dfrom_array[0]) > mktime(0, 0, 0, $dto_array[1], $dto_array[2], $dto_array[0])) {
  69. $error = true;
  70. $messageStack->add_session('search', ERROR_TO_DATE_LESS_THAN_FROM_DATE);
  71. }
  72. }
  73. $price_check_error = false;
  74. if (zen_not_null($pfrom)) {
  75. if (!settype($pfrom, 'float')) {
  76. $error = true;
  77. $price_check_error = true;
  78. $messageStack->add_session('search', ERROR_PRICE_FROM_MUST_BE_NUM);
  79. }
  80. }
  81. if (zen_not_null($pto)) {
  82. if (!settype($pto, 'float')) {
  83. $error = true;
  84. $price_check_error = true;
  85. $messageStack->add_session('search', ERROR_PRICE_TO_MUST_BE_NUM);
  86. }
  87. }
  88. if (($price_check_error == false) && is_float($pfrom) && is_float($pto)) {
  89. if ($pfrom >= $pto) {
  90. $error = true;
  91. $messageStack->add_session('search', ERROR_PRICE_TO_LESS_THAN_PRICE_FROM);
  92. }
  93. }
  94. if (zen_not_null($keywords)) {
  95. if (!zen_parse_search_string($keywords, $search_keywords)) {
  96. $error = true;
  97. $messageStack->add_session('search', ERROR_INVALID_KEYWORDS);
  98. }
  99. }
  100. }
  101. if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) {
  102. $error = true;
  103. // redundant should be able to remove this
  104. $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
  105. }
  106. if ($error == true) {
  107. zen_redirect(zen_href_link(FILENAME_ADVANCED_SEARCH, zen_get_all_get_params(), 'NONSSL', true, false));
  108. }
  109. $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_ADVANCED_SEARCH));
  110. $breadcrumb->add(NAVBAR_TITLE_2);
  111. ?>