不正なURL+既に保存したURLの確認
このコミットが含まれているのは:
コミット
9741341107
|
@ -1,4 +1,4 @@
|
||||||
<?php include_once('includes/header.php') ?>
|
<?php include_once('includes/header.php') ?>
|
||||||
このURLを見つけられませんでした。<br />
|
<?php echo $err; ?><br />
|
||||||
<a href="/">トップページに戻る</a>
|
<a href="/">トップページに戻る</a>
|
||||||
<?php include_once('includes/footer.php'); ?>
|
<?php include_once('includes/footer.php'); ?>
|
||||||
|
|
|
@ -19,9 +19,26 @@
|
||||||
// パラメートルがなければ、スキップ。
|
// パラメートルがなければ、スキップ。
|
||||||
if (isset($_POST['sosin'])) {
|
if (isset($_POST['sosin'])) {
|
||||||
$newadd = $_POST['newadd'];
|
$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');
|
$data = file_get_contents('links.json');
|
||||||
|
|
||||||
$arr = json_decode($data, true);
|
$arr = json_decode($data, true);
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
if ($newadd == $v) {
|
||||||
|
header('Location: /?newurl='.$k);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$newstring = mkstring();
|
$newstring = mkstring();
|
||||||
|
|
||||||
$arr[$newstring] = $newadd;
|
$arr[$newstring] = $newadd;
|
||||||
|
@ -29,6 +46,7 @@
|
||||||
file_put_contents('links.json', $newdata);
|
file_put_contents('links.json', $newdata);
|
||||||
|
|
||||||
header('Location: /?newurl='.$newstring);
|
header('Location: /?newurl='.$newstring);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
else if (null === $_GET['url'] && null !== $_GET['newurl']) {
|
else if (null === $_GET['url'] && null !== $_GET['newurl']) {
|
||||||
$newurl = $_GET['newurl'];
|
$newurl = $_GET['newurl'];
|
||||||
|
@ -57,6 +75,7 @@
|
||||||
$h1 = '【404】未検出';
|
$h1 = '【404】未検出';
|
||||||
$bg = 'daityan';
|
$bg = 'daityan';
|
||||||
$bgpos = 'top right 100px';
|
$bgpos = 'top right 100px';
|
||||||
|
$err = 'このURLを見つけられませんでした。';
|
||||||
include_once('../views/404.php');
|
include_once('../views/404.php');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
新しいイシューから参照