もっと完成

このコミットが含まれているのは:
守矢諏訪子 2022-05-14 04:41:41 +09:00
コミット cf9a6bc4ce
12個のファイルの変更138行の追加32行の削除

1
.gitconfig ノーマルファイル
ファイルの表示

@ -0,0 +1 @@
www/links.json

4
config.php ノーマルファイル
ファイルの表示

@ -0,0 +1,4 @@
<?php
define('SITE_URL', 'https://urlo.li');
define('SITE_NAME', 'URLロリ');
?>

ファイルの表示

@ -1,32 +0,0 @@
<?php
// パラメートルがなければ、スキップ。
if (null !== $_GET['url'] && $_GET['url'] != '') {
$data = file_get_contents('links.json');
foreach (json_decode($data) as $k => $v) {
// jsonファイルでキーを見つければ、転送されます。なければ、エラーが出ます。
if ($_GET['url'] == $k) {
header('Location: '.$v);
exit;
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title>076エラー - 未検出</title>
<style>
body { background-color: #232629; color: #fcfcfc; }
a { color: #ea81e8; text-decoration: none; }
</style>
</head>
<body>
<div style="text-align: center;">
<h1>【404】未検出</h1>
<hr />
<p>匿名自営業076のウェブサイト又はサービスです。<br /><a href="https://www.076.moe">https://www.076.moe</a></p>
</div>
</body>
</html>

3
views/404.php ノーマルファイル
ファイルの表示

@ -0,0 +1,3 @@
<?php include_once('includes/header.php') ?>
このURLを見つけられませんでした。
<?php include_once('includes/footer.php'); ?>

7
views/includes/footer.php ノーマルファイル
ファイルの表示

@ -0,0 +1,7 @@
</div>
<p class="footer">
<a href="https://git.076.ne.jp/TechnicalSuwako/urlo.li"><img src="/static/git.png" alt="Git" /></a> |
<a href="https://076.moe">匿名自営業076</a>
</p>
</body>
</html>

10
views/includes/header.php ノーマルファイル
ファイルの表示

@ -0,0 +1,10 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title><?php echo $title; ?></title>
<link rel="stylesheet" type="text/css" href="/static/style.css" />
</head>
<body>
<h1><?php echo $h1; ?></h1>
<div class="nihongo">

10
views/index.php ノーマルファイル
ファイルの表示

@ -0,0 +1,10 @@
<?php require_once('includes/header.php') ?>
URLをご入力下さい。
<hr />
<div class="form">
<form action="/" method="post">
<input type="text" name="newadd" value="" />
<input type="submit" name="sosin" value="送信" />
</form>
</div>
<?php require_once('includes/footer.php'); ?>

4
views/submitted.php ノーマルファイル
ファイルの表示

@ -0,0 +1,4 @@
<?php include_once('includes/header.php') ?>
下記のURLからアクセス出来ます。<br />
<a href="<?php echo SITE_URL.'/'.$newurl; ?>"><?php echo SITE_URL.'/'.$newurl; ?></a>
<?php include_once('includes/footer.php'); ?>

56
www/index.php ノーマルファイル
ファイルの表示

@ -0,0 +1,56 @@
<?php
require_once('../config.php');
$title = SITE_NAME;
$h1 = SITE_NAME;
function mkstring () {
$stringchars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$newstring = '';
for ($i = 0; $i < 5; $i++) $newstring .= $stringchars[rand(0, strlen($stringchars))];
foreach ($arr as $k => $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ファイルでキーを見つければ、転送されます。なければ、エラーが出ます。
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');
}
?>

ファイルの表示

バイナリ
www/static/git.png ノーマルファイル

バイナリファイルは表示されません。

変更後

幅:  |  高さ:  |  サイズ: 8.3 KiB

43
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;
}