Newer
Older
Digital_Repository / Repositories / statistics / includes / inc.fns.input_check.es.php
  1. <?php
  2. /*
  3. Check all the input. We are only using _REQUEST which may or may not
  4. be a good idea. Unsetting GET and POST.
  5. */
  6.  
  7. $checkit = new checkit();
  8. $short = $GLOBALS["config_vars"]["input_filter"]["keys"][$GLOBALS["config_vars"]["thisrequest"]];
  9. unset($_GET);
  10. unset($_POST);
  11. foreach ($_REQUEST as $k=>$v) {
  12. if (is_array($v)) {
  13. foreach($v as $k1=>$v1) {
  14. if(is_array($v1)) {
  15. foreach($v1 as $k2=>$v2) {
  16. if(is_array($v2)) {
  17. $logger->setLog("Array too deep under $k>$k1>$k2",__LINE__,__FILE__);
  18. } else {
  19. // do something
  20. $logger->setLog("IGNORE: $k>$k1>$k2",__LINE__,__FILE__);
  21. }
  22. }
  23. } else {
  24. if (isset($short[$k]['keys'][$k1])) {
  25. $checkit->setConfig($short[$k]['keys'][$k1]);
  26. $checkit->doCheck($v1);
  27. $response = $checkit->getResponse();
  28. if($response == UNSET_REPLACE) {
  29. $newval = $checkit->getNewValue();
  30. $_REQUEST[$k][$k1] = $newval;
  31. $logger->setLog("REPLACE $v1 with $newval",__LINE__,__FILE__);
  32. } else {
  33. handle_response($response);
  34. }
  35. $logger->setLog("Acting on key:(".$short[$k]['keys'][$k1]['type'].") ($response) $k1",__LINE__,__FILE__);
  36. } else {
  37. unset($_REQUEST[$k]);
  38. $logger->setLog("Unsetting [$k][$k1]",__LINE__,__FILE__);
  39. }
  40. }
  41. }
  42. } else {
  43. if (isset($short[$k])) {
  44. $checkit->setConfig($short[$k]);
  45. $checkit->doCheck($v);
  46. $response = $checkit->getResponse();
  47. if($response == UNSET_REPLACE) {
  48. $newval = $checkit->getNewValue();
  49. $_REQUEST[$k][$k1] = $newval;
  50. $logger->setLog("REPLACE $v1 with $newval",__LINE__,__FILE__);
  51. } else {
  52. handle_response($response);
  53. }
  54. $logger->setLog("Acting on key:(".$short[$k]['type'].") ($response) $k",__LINE__,__FILE__);
  55. } else {
  56. unset($_REQUEST[$k]);
  57. $logger->setLog("Unsetting $k",__LINE__,__FILE__);
  58. }
  59. }
  60. }
  61.  
  62. function handle_response($response)
  63. {
  64. if ($response == UNSET_CONTINUE) { /* Take no action. */ }
  65. if ($response == UNSET_REQUEST) { unset($_REQUEST); }
  66. if ($response == UNSET_KEY) { unset($_REQUEST[$k]); }
  67. if ($response == UNSET_ACTION) { unset($_REQUEST["action"]); }
  68. if ($response == UNSET_REPLACE) { unset($_REQUEST["action"]); }
  69. }
  70. ?>