viewnfo.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /* $Id: viewnfo.php 2893 2007-04-14 13:20:30Z b4rt $ */
  3. /*******************************************************************************
  4. LICENSE
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License (GPL)
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  14. *******************************************************************************/
  15. // prevent direct invocation
  16. if ((!isset($cfg['user'])) || (isset($_REQUEST['cfg']))) {
  17. @ob_end_clean();
  18. @header("location: ../../index.php");
  19. exit();
  20. }
  21. /******************************************************************************/
  22. // common functions
  23. require_once('inc/functions/functions.common.php');
  24. // dir functions
  25. require_once('inc/functions/functions.dir.php');
  26. // is enabled ?
  27. if ($cfg["enable_view_nfo"] != 1) {
  28. AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: ".$cfg["user"]." tried to use nfo-viewer");
  29. @error("nfo-viewer is disabled. Action has been logged.", "", "");
  30. }
  31. // target
  32. $file = UrlHTMLSlashesDecode(tfb_getRequestVar("path"));
  33. $path = $cfg["path"].$file;
  34. // only valid dirs + entries with permission
  35. if (!((tfb_isValidPath($path, ".nfo") || tfb_isValidPath($path, ".txt") || tfb_isValidPath($path, ".log")) &&
  36. (isValidEntry($file)) &&
  37. (hasPermission($file, $cfg["user"], 'r')))) {
  38. AuditAction($cfg["constants"]["error"], "ILLEGAL NFO-ACCESS: ".$cfg["user"]." tried to view ".$file);
  39. @error("Illegal access. Action has been logged.", "", "");
  40. }
  41. // init template-instance
  42. tmplInitializeInstance($cfg["theme"], "page.viewnfo.tmpl");
  43. // set vars
  44. $tmpl->setvar('file', $file);
  45. $folder = htmlspecialchars(substr($file, 0, strrpos($file, "/" )));
  46. $tmpl->setvar('folder', $folder);
  47. if ($fileHandle = @fopen($path,'r')) {
  48. $output = "";
  49. while (!@feof($fileHandle))
  50. $output .= @fgets($fileHandle, 4096);
  51. @fclose ($fileHandle);
  52. } else {
  53. $output = "Error opening NFO File: ".$file;
  54. }
  55. if ((empty($_REQUEST["dos"]) && empty($_REQUEST["win"])) || !empty($_REQUEST["dos"]))
  56. $tmpl->setvar('output', htmlentities($output, ENT_COMPAT, "cp866"));
  57. else
  58. $tmpl->setvar('output', htmlentities($output));
  59. //
  60. tmplSetTitleBar($cfg["pagetitle"].' - View NFO');
  61. tmplSetFoot();
  62. tmplSetIidVars();
  63. // parse template
  64. $tmpl->pparse();
  65. ?>