|
|
|
@ -3,18 +3,19 @@
|
|
|
|
|
$exists = [];
|
|
|
|
|
$url = '';
|
|
|
|
|
|
|
|
|
|
function archiving ($url) {
|
|
|
|
|
function geturl (): string {
|
|
|
|
|
$p = str_replace('https://', '', $_POST['hozonsite']);
|
|
|
|
|
$p = str_replace('http://', '', $p);
|
|
|
|
|
|
|
|
|
|
system("cd ".$url." && wget -LpExk --no-check-certificate --max-redirect=3 --default-page=index.html --reject js,json,mp4,mov,mkv,mp3,ogg,ogv ".$_POST['hozonsite']);
|
|
|
|
|
|
|
|
|
|
$ex = explode('/', parse_url($_POST['hozonsite'])['path']);
|
|
|
|
|
$ex = $ex[array_key_last($ex)];
|
|
|
|
|
if (null !== parse_url($_POST['hozonsite'])['query']) $ex .= '@'.parse_url($_POST['hozonsite'])['query'];
|
|
|
|
|
if ($ex == '') $ex = 'index.html';
|
|
|
|
|
$basename = isset(parse_url($_POST['hozonsite'])['path']) ? $ex : 'index.html';
|
|
|
|
|
unset($ex);
|
|
|
|
|
$ex = explode('/', $p);
|
|
|
|
|
$ex[array_key_last($ex)] = str_replace('?', '@', $ex[array_key_last($ex)]);
|
|
|
|
|
$ex[array_key_last($ex)] = parse_url($ex[array_key_last($ex)])['path'];
|
|
|
|
|
|
|
|
|
|
if ($ex[array_key_last($ex)] == $basename) {
|
|
|
|
|
unset($ex[array_key_last($ex)]);
|
|
|
|
@ -24,7 +25,16 @@
|
|
|
|
|
unset($ex);
|
|
|
|
|
$basename .= (!str_ends_with($basename, '.html') && !str_ends_with($basename, '.htm') && !str_ends_with($basename, '.xhtml') ? '.html' : '');
|
|
|
|
|
|
|
|
|
|
return $url.'/'.$p.'/'.$basename;
|
|
|
|
|
return $p.'/'.$basename;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function archiving (string $url): array {
|
|
|
|
|
system("cd ".$url." && wget -LpExk --no-check-certificate --restrict-file-names=windows --max-redirect=3 --default-page=index.html --reject js,json,mp4,mov,mkv,mp3,ogg,ogv ".$_POST['hozonsite']);
|
|
|
|
|
if (count(array_diff(scandir($url), array('..', '.'))) == 0) {
|
|
|
|
|
return ['code' => 0, 'err' => '保存に失敗しました。'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ['code' => 1, 'url' => $url.'/'.geturl()];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function striptags (string $text): string {
|
|
|
|
@ -65,7 +75,7 @@
|
|
|
|
|
$file = striptags($file); // 危険なタグの削除
|
|
|
|
|
|
|
|
|
|
// ヘッダーの追加
|
|
|
|
|
$file = "<!DOCTYPE html><html><head><meta charset=\"utf-8\" /><head><body><div style=\"background-color: #320202; display: block; border: 4px #ff3b3b groove; color: #ea8181; padding: 10px; z-index: 999999; position: fixed; left: 0; top: 0; width: 100%;\">保存サイトでアーカイブしました。Archived with Hozon Site.<br /><a style=\"color: #ffeb3b;\" href=\"/\">トップページへ</a></div><div style=\"padding-top: 74px;\">".$file.'</div></body></html>';
|
|
|
|
|
$file = "<!DOCTYPE html><html><head><meta charset=\"utf-8\" /><head><body><div style=\"background-color: #320202 !important; display: block !important; border: 4px #ff3b3b groove !important; color: #ea8181 !important; padding: 10px !important; z-index: 999999 !important; position: fixed !important; left: 0 !important; top: 0 !important; font-size: 14px !important; font-family: unset !important; width: 100% !important;\">保存サイトでアーカイブしました。Archived with Hozon Site.<br /><a style=\"color: #ffeb3b !important;\" href=\"/\">トップページへ</a></div><div style=\"padding-top: 74px !important;\">".$file.'</div></body></html>';
|
|
|
|
|
|
|
|
|
|
// 保存
|
|
|
|
|
file_put_contents(urldecode($path), $file);
|
|
|
|
@ -77,17 +87,7 @@
|
|
|
|
|
$err = 'URLは「http://」又は「https://」で始めます。';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$url = str_replace('https://', '', $_POST['hozonsite']);
|
|
|
|
|
$url = str_replace('http://', '', $url);
|
|
|
|
|
if (
|
|
|
|
|
!str_ends_with($url, '.html') &&
|
|
|
|
|
!str_ends_with($url, '\/') &&
|
|
|
|
|
!str_ends_with($url, '.htm') &&
|
|
|
|
|
!str_ends_with($url, '.xhtml') &&
|
|
|
|
|
!str_ends_with($url, '.php') &&
|
|
|
|
|
!str_ends_with($url, '.asp') &&
|
|
|
|
|
!str_ends_with($url, '.aspx')
|
|
|
|
|
) $url = $url.'*';
|
|
|
|
|
$url = geturl();
|
|
|
|
|
$fullurl = 'archive/'.time();
|
|
|
|
|
$exists = glob('archive/*/'.$url);
|
|
|
|
|
|
|
|
|
@ -103,10 +103,16 @@
|
|
|
|
|
if (count($exists) == 0 || (count($exists) > 0 && isset($_POST['agree']))) {
|
|
|
|
|
if (!mkdir('./'.$fullurl, 0755, true)) die('エラー'); // ダイレクトリーを作成出来なければ、死ね
|
|
|
|
|
$url = archiving('./'.$fullurl); // ウエブページのダウンロード
|
|
|
|
|
sanitize_archive($url); // 危険なタグの削除
|
|
|
|
|
if ($url['code'] == 0) {
|
|
|
|
|
$err = $url['err'];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$url = $url['url'];
|
|
|
|
|
sanitize_archive($url); // 危険なタグの削除
|
|
|
|
|
|
|
|
|
|
header('Location: '.$url); // 移転
|
|
|
|
|
die();
|
|
|
|
|
header('Location: '.$url); // 移転
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -124,7 +130,7 @@
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<?php if ($err != '') { ?><div class="error"><?php echo $err; ?></div> <?php } ?>
|
|
|
|
|
<h1><img src="/logo.jpg" alt="ロゴ" /></h1>
|
|
|
|
|
<h1><img class="headerimg" src="/logo.jpg" alt="ロゴ" /></h1>
|
|
|
|
|
<div class="body">
|
|
|
|
|
<p>
|
|
|
|
|
<a href="/">トップ</a> |
|
|
|
|
|