PageRenderTime 53ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 1ms

/search/viewcache.php

https://bitbucket.org/molusc/sma-website
PHP | 147 lines | 96 code | 35 blank | 16 comment | 11 complexity | 9fb3e5ad1a24cfc905093a5911fcc86d MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /******************************************************************************
  3. * iSearch2 - website search engine *
  4. * *
  5. * Visit the iSearch homepage at http://www.iSearchTheNet.com/isearch *
  6. * *
  7. * Copyright (C) 2002-2007 Z-Host. All rights reserved. *
  8. * *
  9. ******************************************************************************/
  10. // PHPLOCKITOPT NOENCODE
  11. $isearch_path = dirname(__FILE__);
  12. define('IN_ISEARCH', true);
  13. require_once "$isearch_path/inc/core.inc.php";
  14. /* Open the search component (read only) */
  15. isearch_open(True);
  16. $isearch_pageTitle = $isearch_lang['viewcache_title'];
  17. /* Display the frame set */
  18. echo <<<EOF
  19. EOF;
  20. $frame = isset($_REQUEST['frame']) ? $_REQUEST['frame'] : '';
  21. $url = isset($_REQUEST['url']) ? $_REQUEST['url'] : '';
  22. if ($frame == '')
  23. {
  24. /* Display the frame set */
  25. echo '
  26. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
  27. <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $isearch_languageCode . '">
  28. <head>
  29. <meta http-equiv="Content-Type" content="text/html; charset='.$isearch_config['char_set'].'" />
  30. <title>' . $isearch_pageTitle . '</title>
  31. <meta name="author" content="Ian Willis" />
  32. <meta name="copyright" content="Copyright Z-Host. All rights reserved." />
  33. <meta name="robots" content="noindex,nofollow" />
  34. <link rel="stylesheet" href="'.$isearch_config['base_url'].'/style/'.$isearch_config['style_name'].'.css" type="text/css" />
  35. </head>
  36. <frameset cols="100%" rows="100,*" >
  37. <frame frameborder="0" src="viewcache.php?frame=top&amp;url=' . $url . '" />
  38. <frame frameborder="0" src="viewcache.php?frame=bottom&amp;url=' . $url . '" />
  39. </frameset>
  40. <noframes>
  41. <body>
  42. ';
  43. include "$isearch_path/inc/header.inc.php";
  44. echo <<<EOF
  45. <h3>Sorry, you are unable to view cache contents - your browser does not support frames.</h3>
  46. EOF;
  47. include "$isearch_path/inc/footer.inc.php";
  48. echo <<<EOF
  49. </body>
  50. </noframes>
  51. </html>
  52. EOF;
  53. }
  54. else if ($frame == 'top')
  55. {
  56. /* Display the top frame (message saying that this page is cached) */
  57. echo '
  58. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  59. <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $isearch_languageCode . '">
  60. <head>
  61. <meta http-equiv="Content-Type" content="text/html; charset='.$isearch_config['char_set'].'" />
  62. <title>' . $isearch_pageTitle . '</title>
  63. <meta name="author" content="Ian Willis" />
  64. <meta name="copyright" content="Copyright Z-Host. All rights reserved." />
  65. <meta name="robots" content="noindex,nofollow" />
  66. <link rel="stylesheet" href="'.$isearch_config['base_url'].'/style/'.$isearch_config['style_name'].'.css" type="text/css" />
  67. </head>
  68. <body>
  69. ';
  70. include "$isearch_path/inc/header.inc.php";
  71. echo <<<EOF
  72. <h1 class="isearch">$isearch_pageTitle</h1>
  73. EOF;
  74. $isearch_cachedpage = preg_replace("/(%u)/", "<a href=\"$url\">$url</a>", $isearch_lang['cachedpage']);
  75. echo '
  76. <h2 class="isearch-cachedpage">' . $isearch_cachedpage . '</h2>
  77. ';
  78. include "$isearch_path/inc/footer.inc.php";
  79. echo <<<EOF
  80. </body>
  81. </html>
  82. EOF;
  83. }
  84. else if ($frame == 'bottom')
  85. {
  86. /* Display the cached page */
  87. $result = mysql_query ("SELECT cache, base FROM $isearch_table_urls WHERE url='$url'", $isearch_db);
  88. if (($result) && ($resultItem = mysql_fetch_object($result)))
  89. {
  90. $cache = $resultItem->cache;
  91. if (!eregi("<head>.*<base .*></head>", $cache))
  92. {
  93. /* Insert a base tag into the head of this cached page */
  94. $base = $resultItem->base;
  95. $cache = eregi_replace("</head>", "<base href=\"$base\" />\n</head>", $cache);
  96. }
  97. echo $cache;
  98. }
  99. }
  100. /* Close the search component */
  101. isearch_close();
  102. ?>