From 97413411070aa803f40be7547196f9c9ae8d384f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=86=E3=82=AF=E3=83=8B=E3=82=AB=E3=83=AB=E8=AB=8F?= =?UTF-8?q?=E8=A8=AA=E5=AD=90?= Date: Sun, 15 May 2022 21:49:58 +0900 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E3=81=AAURL=EF=BC=8B?= =?UTF-8?q?=E6=97=A2=E3=81=AB=E4=BF=9D=E5=AD=98=E3=81=97=E3=81=9FURL?= =?UTF-8?q?=E3=81=AE=E7=A2=BA=E8=AA=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- views/404.php | 2 +- www/index.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/views/404.php b/views/404.php index 544b381..e48804e 100644 --- a/views/404.php +++ b/views/404.php @@ -1,4 +1,4 @@ - このURLを見つけられませんでした。
+
トップページに戻る diff --git a/www/index.php b/www/index.php index 67d13b1..4dd220d 100644 --- a/www/index.php +++ b/www/index.php @@ -19,9 +19,26 @@ // パラメートルがなければ、スキップ。 if (isset($_POST['sosin'])) { $newadd = $_POST['newadd']; + if (!str_starts_with($newadd, 'http://') && !str_starts_with($newadd, 'https://')) { + $title = '076エラー - 不正なURL'; + $h1 = '【エラー】不正なURL'; + $bg = 'daityan'; + $bgpos = 'top right 100px'; + $err = 'URLは「http://」又は「https://」で始まります。'; + include_once('../views/404.php'); + exit; + } + $data = file_get_contents('links.json'); $arr = json_decode($data, true); + foreach ($arr as $k => $v) { + if ($newadd == $v) { + header('Location: /?newurl='.$k); + exit; + } + } + $newstring = mkstring(); $arr[$newstring] = $newadd; @@ -29,6 +46,7 @@ file_put_contents('links.json', $newdata); header('Location: /?newurl='.$newstring); + exit; } else if (null === $_GET['url'] && null !== $_GET['newurl']) { $newurl = $_GET['newurl']; @@ -57,6 +75,7 @@ $h1 = '【404】未検出'; $bg = 'daityan'; $bgpos = 'top right 100px'; + $err = 'このURLを見つけられませんでした。'; include_once('../views/404.php'); } ?>