snippet.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. set_include_path(get_include_path() . PATH_SEPARATOR .
  3. dirname(__FILE__) ."/include");
  4. /* remove ill effects of magic quotes */
  5. if (get_magic_quotes_gpc()) {
  6. function stripslashes_deep($value) {
  7. $value = is_array($value) ?
  8. array_map('stripslashes_deep', $value) : stripslashes($value);
  9. return $value;
  10. }
  11. $_POST = array_map('stripslashes_deep', $_POST);
  12. $_GET = array_map('stripslashes_deep', $_GET);
  13. $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
  14. $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
  15. }
  16. require_once "functions.php";
  17. require_once "sessions.php";
  18. require_once "db-prefs.php";
  19. require_once "sanity_check.php";
  20. require_once "version.php";
  21. require_once "config.php";
  22. require_once "prefs.php";
  23. require_once "users.php";
  24. $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
  25. $key = db_escape_string($_REQUEST['key']);
  26. $result = db_query($link, "SELECT snippet FROM ttirc_snippets WHERE ".DB_KEY_FIELD." = '$key'");
  27. header("Content-Type: text/plain; charset=utf-8");
  28. if (db_num_rows($result) != 0) {
  29. $text = db_fetch_result($result, 0, "snippet");
  30. print $text;
  31. } else {
  32. print "Snippet not found.";
  33. }
  34. db_close($link);
  35. ?>