Guest User

Untitled

a guest
Oct 8th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. $container['view'] = function ($container) {
  2. $view = new SlimViewsTwig(
  3. $container['settings']['view']['template_path'],
  4. $container['settings']['view']['twig'],
  5. [
  6. 'debug' => true // This line should enable debug mode
  7. ]
  8. );
  9.  
  10. $basePath = rtrim(str_ireplace('index.php', '', $container['request']->getUri()->getBasePath()), '/');
  11. $view->addExtension(new SlimViewsTwigExtension($container['router'], $basePath));
  12.  
  13. $view->addExtension(new Twig_Extension_Debug());
  14.  
  15. return $view;
  16. };
  17.  
  18. $container['validate_sanitize'] = function ($container)
  19. {
  20. $class_path = $container->get('settings')['class_path'];
  21. require $class_path . 'ValidateSanitize.php';
  22. $validator = new ValidateSanitize();
  23. return $validator;
  24. };
  25.  
  26. $container['hash_password'] = function($container)
  27. {
  28. $class_path = $container->get('settings')['class_path'];
  29. require $class_path . 'HashPassword.php';
  30. $hash = new HashPassword();
  31. return $hash;
  32. };
  33.  
  34. $app->post('/register', function(Request $request, Response $response)
  35. {
  36. $arr_tainted_params = $request->getParsedBody();
  37.  
  38. $sanitizer_validator = $this→get('validate_sanitize'); //here for example
  39. $password_hasher = $this->get('hash_password');
  40.  
  41. $tainted_email = $arr_tainted_params['email'];
  42. $tainted_username = $arr_tainted_params['username'];
  43. $tainted_password = $arr_tainted_params['password'];
  44.  
  45. $model = $this->get('model');
  46. $sql_wrapper = $this->get('sql_wrapper');
  47. $sql_queries = $this->get('sql_queries');
  48. $db_handle = $this->get('dbase');
  49.  
  50. $cleaned_email = $sanitizer_validator->sanitize_input($tainted_email, FILTER_SANITIZE_EMAIL);
  51. $cleaned_username = $sanitizer_validator->sanitize_input($tainted_username, FILTER_SANITIZE_STRING);
  52. $cleaned_password = $sanitizer_validator->sanitize_input($tainted_password, FILTER_SANITIZE_STRING);
  53. });
  54.  
  55. <?php
  56.  
  57. require 'routes/change_password.php';
  58. require 'routes/forgot_password.php';
  59. require 'routes/homepage.php';
  60. require 'routes/login.php';
  61. require 'routes/logout.php';
  62. require 'routes/register.php';
  63.  
  64. <?php
  65.  
  66. session_start();
  67.  
  68. require __DIR__ . '/../vendor/autoload.php';
  69.  
  70. $settings = require __DIR__ . '/app/settings.php'; //an array of options containing database configurations and the path to twig templates
  71.  
  72. $container = new SlimContainer($settings); //not sure what this does
  73.  
  74. require __DIR__ . '/app/dependencies.php';
  75.  
  76. $app = new SlimApp($container);
  77.  
  78. require __DIR__ . '/app/routes.php';
  79.  
  80. $app→run();
Add Comment
Please, Sign In to add comment