err-helper.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * Copyright (c) 2016, 2018, the Open Gallery's contributors
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * * Neither Open Gallery nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY
  21. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *
  28. * err-helper.php
  29. *
  30. * JS Error helper.
  31. *
  32. * @author Daniele Bonini <danielemi@hotmail.com>
  33. * @copyrights (c) 2016, 2018, the Open Gallery's contributors
  34. * @license https://opensource.org/licenses/BSD-3-Clause
  35. */
  36. require "../../Private/core/init.inc";
  37. //require "../../../Private/classes/OpenGallery/OpenGallery/class.err.inc";
  38. use OpenGallery\OpenGallery\Err;
  39. header("Content-Type: text/javascript");
  40. // PARAMETERS VALIDATION AND NORMALIZATION
  41. //errNo
  42. //define("ERR_NO", substr(filter_input(INPUT_GET, "errNo", FILTER_SANITIZE_STRING), 0, 100));
  43. //errKey
  44. //define("ERR_KEY", array_search(ERR_NO, Err::$A_ERR_NO));
  45. //errMsg
  46. //define("ERR_MSG", substr(filter_input(INPUT_GET, "errMsg", FILTER_SANITIZE_STRING), 0, 200));
  47. //errScript
  48. //define("ERR_SCRIPT", substr(filter_input(INPUT_GET, "errScript", FILTER_SANITIZE_STRING), 0, 255));
  49. //errLine
  50. //define("ERR_LINE", substr(filter_input(INPUT_GET, "errLine", FILTER_SANITIZE_NUMBER_INT), 0, 5));
  51. ?>
  52. var ERR_NO = "<?php echo ERR_NO; ?>";
  53. var ERR_KEY = "<?php echo ERR_KEY; ?>";
  54. var ERR_MSG = "<?php echo ERR_MSG; ?>";
  55. var ERR_SCRIPT = "<?php echo ERR_SCRIPT; ?>";
  56. var ERR_LINE = "<?php echo ERR_LINE; ?>";
  57. var ERR_STACK = "<?php echo ERR_STACK; ?>";
  58. var A_ERR_NO = {
  59. <?php
  60. $start=true;
  61. foreach (Err::$A_ERR_NO as $key => $value) {
  62. if (!$start) {
  63. echo ",\n";
  64. } else {
  65. $start=false;
  66. }
  67. echo "'$key':\"$value\"";
  68. }
  69. echo "\n";
  70. ?>
  71. };
  72. var A_ERR_MSG = {
  73. <?php
  74. $start=true;
  75. foreach (Err::$A_ERR_MSG as $key => $value) {
  76. if (!$start) {
  77. echo ",\n";
  78. } else {
  79. $start=false;
  80. }
  81. echo "'$key':\"$value\"";
  82. }
  83. echo "\n";
  84. ?>
  85. };
  86. var A_ERR_EXTDES_MSG = {
  87. <?php
  88. $start=true;
  89. foreach (Err::$A_ERR_EXTDES_MSG as $key => $value) {
  90. if (!$start) {
  91. echo ",\n";
  92. } else {
  93. $start=false;
  94. }
  95. echo "'$key':\"$value\"";
  96. }
  97. echo "\n";
  98. ?>
  99. };
  100. function clearErrors() {
  101. $(".form-error").each(function(index, Element) {
  102. $(this).hide();
  103. });
  104. $(".form-error-adapt").each(function(index, Element) {
  105. $(this).hide();
  106. });
  107. }