Просмотр файла pages/scaner.php

Размер файла: 6.19Kb
  1. <?php
  2. include '../system/func.php';
  3. $title="Сканер сайтов";
  4. include '../system/head.php';
  5. title($title);
  6. @setcookie("lastaddress",$_GET['addr'],time()+691200);
  7. if($_GET['mode']){
  8. $url = htmlspecialchars(trim($_GET['addr']));
  9. if(!preg_match("#^https?://#iU",$url)) $url= "http://".$url;
  10. $purl = @parse_url($url);
  11. //get extens. file
  12. $ext = strtolower(strrchr($url,'.'));
  13. if($ext=='.jpg' or $ext=='.gif' or $ext=='.bmp' or $ext=='.ico' or $ext=='.png'){
  14. echo "
  15. <div class='menu'> <img src='".$url."' alt=''/>
  16. </div> ";
  17. include '../system/foot.php';
  18. exit;
  19. }
  20. $cnt = @file_get_contents($url);
  21. //charset processing
  22. preg_match("#encoding ?= ?('|\")([^'\"]+)('|\")#i",$cnt,$ch);
  23. if(empty($ch[2])){
  24. preg_match("#charset ?= ?([^'\"]+)('|\")#i",$cnt,$ch);
  25. $ch[2] = $ch[1];
  26. }
  27. if($ch[2]!=='utf-8')
  28. $cnt = iconv($ch[2],"utf-8//IGNORE",$cnt);
  29. if(!$cnt){ echo"<div class='err'> Невозможно обратится к адресу (".$url.")<br />
  30. Проверьте правильность введенного вами адреса и проверьте, доступен ли он с обычного браузера</div>";
  31. echo '<div class="menu">&#171; <a href="scaner.php">Назад</a></div>';
  32. include '../system/foot.php';
  33. exit;
  34. }
  35. //icon processing
  36. preg_match("#<link ?rel ?= ?('|\") ?shortcut icon('|\") +href ?= ?('|\")([^'\"]+)('|\")#i",$cnt,$out);
  37.  
  38.  
  39. if(empty($out[4])) $out[4] = '/favicon.ico';
  40. //title processing
  41. preg_match("#< ?title ?>(.+)< ?/ ?title ?>#i",$cnt,$title);
  42. if(empty($title[1])){
  43. preg_match("# ?title ?= ?('|\")([^'\"]+)('|\")#i",$cnt,$title);
  44. $title[1] = $title[2];
  45. }
  46. //stat info
  47. echo"
  48. <div class='menu'>Адрес<br/> ".strtolower($url)."<br/>
  49. Загаловок <b>".htmlspecialchars($title[1])."</b></div>";
  50.  
  51. if($_GET['mode']=='scan'){
  52.  
  53. //replaces
  54. $cnt = preg_replace("#@import ?('|\")/?([^;'\"]+)#is","<a href='scaner.php?addr=http://".$purl['host']."/".$purl['path']."&mode=scan'>\\2</a>",$cnt);
  55. //x-ray
  56. $cnt = htmlspecialchars($cnt);
  57. //absolute site
  58. $cnt = preg_replace("#&lt;link ?rel ?= ?('|&quot;) ?stylesheet('|&quot;) +href ?= ?('|&quot;)/([a-z/\.\?\#0-9-_\+\(\)]+)('|&quot;)(.+)( ?/ ?&gt;)+#i","<a href='scaner.php?addr=http://".$purl['host']."/\\4&mode=scan'>\\0</a>",$cnt);
  59. $cnt = preg_replace("#((&lt;img ?src ?= ?)('|&quot;))/([a-z/\.\?\#0-9]+)(('|&quot;)(.+)/ ?&gt;)#i","\\1<a href='scaner.php?addr=http://".trim($purl['host'],'/')."/\\4&mode=scan'>\\4</a>\\5",$cnt);
  60. $cnt = preg_replace("#&lt;script(.*) +(src|href) ?= ?('|&quot;)/([a-z/\.\?\#0-9-_\+\(\)]+)('|&quot;)(.+)( ?&gt;)+#i","<a href='scaner.php?addr=http://".$purl['host']."/\\4&mode=scan'>\\0</a>",$cnt);
  61. $cnt = preg_replace("#(&lt;a(.*) +href ?= ?('|&quot;))/([a-z/\.\?\#0-9-_\+\(\)]+)(('|&quot;)(.+)( ?&gt;)+)#i","\\1<a href='scaner.php?addr=http://".$purl['host']."/\\4&mode=scan'>\\4</a>\\5",$cnt);
  62.  
  63. //localy
  64. $cnt = preg_replace("#&lt;link ?rel ?= ?('|&quot;) ?stylesheet('|&quot;) +href ?= ?('|&quot;)([^/][a-z/\.\?\#0-9-_\+\(\)]+)('|&quot;)(.+)( ?/ ?&gt;)+#is","<a href='scaner.php?addr=http://".$purl['host']."/".$purl['path']."\\4&mode=scan'>\\0</a>",$cnt);
  65. $cnt = preg_replace("#((&lt;img ?src ?= ?)('|&quot;))([^/][a-z/\.\?\#0-9]+)(('|&quot;)(.+)/ ?&gt;)#is","\\1<a href='scaner.php?addr=http://".trim($purl['host'],'/')."/".$purl['path']."\\4&mode=scan'>\\4</a>\\5",$cnt);
  66. $cnt = preg_replace("#&lt;script([^;]) +(src|href) ?= ?('|&quot;)([^/][a-z/\.\?\#0-9\-_\+\(\)]+)('|&quot;)(.+)( ?&gt;)+#is","<a href='scaner.php?addr=http://".$purl['host']."/".$purl['path']."\\4&mode=scan'>\\0</a>",$cnt);
  67. $cnt = preg_replace("#(&lt;a(.*) +href ?= ?('|&quot;))([^/][a-z/\.\?\#0-9\-_\+\(\),]+)(('|&quot;)(.+)( ?&gt;)+)#is","\\1<a href='scaner.php?addr=http://".$purl['host']."/".$purl['path']."\\4&mode=scan'>\\4</a>\\5",$cnt);
  68.  
  69. //url
  70. $cnt = preg_replace("#&lt;link ?rel ?= ?('|&quot;) ?stylesheet('|&quot;) +href ?= ?('|&quot;)(http?://[a-z/\.\?\#0-9-_\+\(\)]+)('|&quot;)(.+)( ?/ ?&gt;)+#i","<a href='scaner.php?addr=\\4&mode=scan'>\\0</a>",$cnt);
  71. $cnt = preg_replace("#((&lt;img ?src ?= ?)('|&quot;))(http://[a-z/\.\?\#0-9]+)(('|&quot;)(.+)/ ?&gt;)#i","\\1<a href='scaner.php?addr=\\4&mode=scan'>\\4</a>\\5",$cnt);
  72. $cnt = preg_replace("#&lt;script(.*) +(src|href) ?= ?('|&quot;)(http://[a-z/\.\?\#0-9\-_\+\(\)]+)('|&quot;)(.+)( ?&gt;)+#i","<a href='scaner.php?addr=\\4&mode=scan'>\\0</a>",$cnt);
  73. $cnt = preg_replace("#(&lt;a(.*) +href ?= ?('|&quot;))(http://[a-z/\.\?\#0-9\-_\+\(\),]+)(('|&quot;)(.+)( ?&gt;)+)#i","\\1<a href='scaner.php?addr=\\4&mode=scan'>\\4</a>\\5",$cnt);
  74. }
  75. switch($_GET['mode']){
  76.  
  77. case'scan':
  78. echo"<div class='menu'>";
  79. echo nl2br($cnt);
  80. echo"</div>";
  81. echo '<div class="menu">&#171; <a href="scaner.php">Назад</a></div>';
  82. //scan
  83. break;
  84. case 'copyscan':
  85. echo"<div class='menu'><textarea name='text' cols='80' rows='15' style='width: 93%'>".nl2br($cnt)."</textarea></div>";
  86. echo '<div class="menu">&#171; <a href="scaner.php">Назад</a></div>';
  87. break;
  88. default:
  89. include '../system/foot.php';
  90.  
  91. exit;
  92. }
  93.  
  94.  
  95. }else{
  96. //radioactivity - ray
  97. $_COOKIE['lastaddress'] = htmlspecialchars($_COOKIE['lastaddress']);
  98.  
  99. echo"
  100. <div class='menu'>
  101. <form method='get' action='scaner.php'>
  102. <b>Адрес:</b><br />
  103. <input type='text' name='addr' id='addr' value='{$_COOKIE['lastaddress']}'/><br />
  104. <input type='submit' id='button' value='Сканировать'/><br/>
  105. <input type='radio' id='copyradio' class='formradio' name='mode' value='scan' checked>Обычный<br />
  106. <input type='radio' id='copyradio' class='formradio' name='mode' value='copyscan'>Копировать</form></div>";
  107. echo '<div class="menu">&#171; <a href="index.php">Назад</a></div>';
  108. }
  109. include '../system/foot.php';
  110. ?>