diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..7efae6a --- /dev/null +++ b/.gitconfig @@ -0,0 +1 @@ +www/links.json diff --git a/config.php b/config.php new file mode 100644 index 0000000..6bdfae2 --- /dev/null +++ b/config.php @@ -0,0 +1,4 @@ + diff --git a/index.php b/index.php deleted file mode 100644 index da09b30..0000000 --- a/index.php +++ /dev/null @@ -1,32 +0,0 @@ - $v) { - // jsonファイルでキーを見つければ、転送されます。なければ、404エラーが出ます。 - if ($_GET['url'] == $k) { - header('Location: '.$v); - exit; - } - } - } -?> - - - - - 076エラー - 未検出 - - - -
-

【404】未検出

-
-

匿名自営業076のウェブサイト又はサービスです。
https://www.076.moe

-
- - diff --git a/views/404.php b/views/404.php new file mode 100644 index 0000000..566483d --- /dev/null +++ b/views/404.php @@ -0,0 +1,3 @@ + + このURLを見つけられませんでした。 + diff --git a/views/includes/footer.php b/views/includes/footer.php new file mode 100644 index 0000000..cb2c158 --- /dev/null +++ b/views/includes/footer.php @@ -0,0 +1,7 @@ + + + + diff --git a/views/includes/header.php b/views/includes/header.php new file mode 100644 index 0000000..713fda4 --- /dev/null +++ b/views/includes/header.php @@ -0,0 +1,10 @@ + + + + + <?php echo $title; ?> + + + +

+
diff --git a/views/index.php b/views/index.php new file mode 100644 index 0000000..aff294f --- /dev/null +++ b/views/index.php @@ -0,0 +1,10 @@ + + URLをご入力下さい。 +
+
+
+ + +
+
+ diff --git a/views/submitted.php b/views/submitted.php new file mode 100644 index 0000000..2d74cef --- /dev/null +++ b/views/submitted.php @@ -0,0 +1,4 @@ + + 下記のURLからアクセス出来ます。
+ + diff --git a/www/index.php b/www/index.php new file mode 100644 index 0000000..08c8b4e --- /dev/null +++ b/www/index.php @@ -0,0 +1,56 @@ + $v) { + if ($newstring == $k) return mkstring(); + } + + return $newstring; + } + + // パラメートルがなければ、スキップ。 + if (isset($_POST['sosin'])) { + $newadd = $_POST['newadd']; + $data = file_get_contents('links.json'); + + $arr = json_decode($data, true); + $newstring = mkstring(); + + $arr[$newstring] = $newadd; + $newdata = json_encode($arr); + file_put_contents('links.json', $newdata); + + header('Location: /submitted?newurl='.$newstring); + } + else if (null === $_GET['url'] && null !== $_GET['newurl']) { + $newurl = $_GET['newurl']; + include_once('../views/submitted.php'); + } + else if (null !== $_GET['url'] && $_GET['url'] != '') { + $data = file_get_contents('links.json'); + + foreach (json_decode($data) as $k => $v) { + // jsonファイルでキーを見つければ、転送されます。なければ、404エラーが出ます。 + if ($_GET['url'] == $k) { + header('Location: '.$v); + exit; + } + } + } + else if (null === $_GET['url'] && $_SERVER['REQUEST_URI'] == '/') { + include_once('../views/index.php'); + } + else { + $title = '076エラー - 未検出'; + $h1 = '【404】未検出'; + include_once('../views/404.php'); + } +?> diff --git a/links.sample.json b/www/links.sample.json similarity index 100% rename from links.sample.json rename to www/links.sample.json diff --git a/www/static/git.png b/www/static/git.png new file mode 100644 index 0000000..df3afde Binary files /dev/null and b/www/static/git.png differ diff --git a/www/static/style.css b/www/static/style.css new file mode 100644 index 0000000..70d713f --- /dev/null +++ b/www/static/style.css @@ -0,0 +1,43 @@ +body { + background-color: #232629; + color: #fcfcfc; +} + +a { + color: #ea81e8; + text-decoration: none; +} + +h1, .footer { + text-align: center; +} + +.nihongo { + background-color: #21082b; + border: 1px #f2f groove; + color: #d6a9d6; + max-width: 830px; + padding: 4px; + margin: 8px auto; +} + +.nihongo > a { + color: #ffeb3b; +} + +.form { + margin: auto; + text-align: center; +} + +input[type="text"], input[type="submit"] { + background-color: #683c7a; + border: 1px #f9f groove; + border-radius: 2px; + margin: 4px; auto; +} + +input[type="text"] { + width: 98%; + max-width: 820px; +}