このコミットが含まれているのは:
守矢諏訪子 2022-12-28 17:06:10 +09:00
コミット 17d2bf8fbb
2個のファイルの変更17行の追加11行の削除

10
src/langchange.php ノーマルファイル
ファイルの表示

@ -0,0 +1,10 @@
<?php
$lang = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : 'ja';
if (isset($_POST['langchange'])) {
$lang = null !== $_COOKIE['lang'] && $_COOKIE['lang'] == 'en' ? 'ja' : 'en';
setcookie('lang', $lang);
unset($_POST['langchange']);
header('Location: /');
}
?>

ファイルの表示

@ -1,13 +1,5 @@
<?php
$lang = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : 'ja';
if (isset($_POST['langchange'])) {
$lang = null !== $_COOKIE['lang'] && $_COOKIE['lang'] == 'en' ? 'ja' : 'en';
setcookie('lang', $lang);
unset($_POST['langchange']);
header('Location: /');
}
include('../src/langchange.php');
include('../lang/'.$lang.'.php');
include('../config.php');
@ -41,7 +33,7 @@
}
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']);
system("cd ".$url." && wget -N -p -x -E -r -l 1 --no-remove-listing --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' => LOC_ERROR_HOZON_NI_SIPPAI];
}
@ -51,9 +43,13 @@
function striptags (string $text): string {
$text = preg_replace('/\<script[\s\S]+?\<\/script\>/', '', $text);
$text = preg_replace('/\<noscript[\s\S]+?\<\/noscript\>/', '', $text);
$text = preg_replace('/\.css\?/', '.css@', $text);
//$text = preg_replace('/'.parse_url($_POST['hozonsite'])['scheme'].'\:\/\/(.*)'.parse_url($_POST['hozonsite'])['host'].'/', '', $text);
$text = preg_replace('/visibility: hidden/', '', $text);
$text = preg_replace('/\<div class\=\"blocker-error\"\>[\s\S]+?\<\/div\>/', '', $text);
$text = preg_replace('/\<div class\=\"blocker\"\>[\s\S]+?\<\/div\>/', '', $text);
$text = preg_replace('/(https\:\/\/)(.*)\//', '/', $text);
$allowed = [
'!doctype',
@ -87,7 +83,7 @@
$file = striptags($file); // 危険なタグの削除
// ヘッダーの追加
$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;\">".SITE_NAME_JA."でアーカイブしました。Archived with ".SITE_NAME_EN.".<br /><a style=\"color: #ffeb3b !important;\" href=\"/\">トップページへ To toppage</a></div><div style=\"padding-top: 74px !important;\">".$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;\">".SITE_NAME_JA."でアーカイブしました。Archived with ".SITE_NAME_EN.".<br /><a style=\"color: #ffeb3b !important;\" href=\"/\">トップページへ To toppage</a></div><div style=\"padding-top: 74px !important;\">".$file.'</div></body></html>';
// 保存
file_put_contents(urldecode($path), $file);