PageRenderTime 25ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/redirect.php

https://code.google.com/
PHP | 27 lines | 18 code | 2 blank | 7 comment | 0 complexity | a34d08267573dacdeb9c21ed7c6de033 MD5 | raw file
  1. <?php
  2. // Configurations
  3. include_once('include/config/config.php');
  4. // URL Shortener Class
  5. include_once("include/shortener/shortener.php");
  6. // Database Singleton
  7. include_once("include/config/database.php");
  8. // Log Class
  9. include_once("include/log/log.php");
  10. try {
  11. $key = $_GET['key'];
  12. // Instantiate Shortener
  13. $shortener = new Shortener();
  14. // Get Long URL for the given key
  15. $url = $shortener->getLongURL($key);
  16. // Redirect
  17. header('HTTP/1.1 301 Moved Permanently');
  18. header('Location: ' . $url);
  19. $logger = new Log();
  20. $logger->log($key);
  21. exit();
  22. } catch (Exception $e) {
  23. include_once('where.php');
  24. }
  25. ?>