Skip to content

Commit 63838ea

Browse files
committed
Fix authentication issue and add setup-kari.php redirect***
***認証の問題を修正し、setup-kari.phpへのリダイレクトを追加
1 parent a023d8a commit 63838ea

7 files changed

Lines changed: 21 additions & 17 deletions

File tree

delete_url.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
3+
24
session_start();
35
if (!isset($_SESSION["user_id"]) || $_SESSION["user_id"] == 0) {
46
header("Location: login.php");

details.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
3+
24
session_start();
35
if (!isset($_SESSION["user_id"]) || $_SESSION["user_id"] == 0) {
46
header("Location: login.php");

index.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<?php
2+
if (!file_exists('db.php')) {
3+
header('Location: setup-kari.php');
4+
exit;
5+
}
6+
27
include 'db.php';
38

49
session_start();

login.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
include 'db.php';
34
session_start(); // セッションを開始
45

redirect.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
// データベース接続スクリプトが存在するか確認する
34
if (!file_exists('db.php')) {
45
// データベース接続スクリプトが存在しない場合はsetup-kari.phpにリダイレクトする

session.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
session_start();
34

45
if (isset($_SESSION["user_id"])) {

setup-kari.php

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,17 @@
9999
";
100100

101101
file_put_contents('db.php', $configContent);
102-
103-
echo "設定が正常に完了しました。<br>";
104-
echo "Kariの使い方:<br>";
105-
echo "1. ユーザー名とパスワードを入力してログインします。<br>";
106-
echo "2. 短縮したいURLを入力します。<br>";
107-
echo "3. 短縮URLが生成されます。<br>";
108-
echo "4. 短縮URLをクリックすると、元のURLにリダイレクトされます。<br>";
109-
echo "<form action=\"setup-kari.php\" method=\"post\">";
110-
echo "<input type=\"hidden\" name=\"delete\" value=\"true\">";
111-
echo "<input type=\"submit\" value=\"完了\">";
112-
echo "</form>";
113-
} elseif (isset($_POST['delete']) && $_POST['delete'] === 'true') {
114102
// 自身のファイルを削除する
115103
unlink(__FILE__);
116-
echo "この設定ファイルは削除されました。<br>";
104+
$_SESSION['flash_message'] = 'データベースの設定が成功しました。';
105+
// 設定が完了したらindex.phpにリダイレクト
106+
header('Location: index.php');
107+
exit;
108+
117109
}
118110
?>
119111

112+
120113
<!DOCTYPE html>
121114
<html>
122115
<head>
@@ -125,18 +118,17 @@
125118
</head>
126119
<body class="bg-gray-100">
127120
<div class="container mx-auto px-4 py-5">
128-
<h1 class="text-4xl font-bold mb-4">設定 Kari</h1>
129121
<form action="setup-kari.php" method="post" class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
130122
<div class="mb-4">
131-
<label class="block text-gray-700 text-sm font-bold mb-2" for="servername">サーバー名:</label>
123+
<label class="block text-gray-700 text-sm font-bold mb-2" for="servername">サーバー名(localhostとかのdbのサーバー名):</label>
132124
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="servername" name="servername" type="text" required>
133125
</div>
134126
<div class="mb-4">
135-
<label class="block text-gray-700 text-sm font-bold mb-2" for="username">ユーザー名:</label>
127+
<label class="block text-gray-700 text-sm font-bold mb-2" for="username">ユーザー名(dbのユーザー名):</label>
136128
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="username" name="username" type="text" required>
137129
</div>
138130
<div class="mb-4">
139-
<label class="block text-gray-700 text-sm font-bold mb-2" for="password">パスワード:</label>
131+
<label class="block text-gray-700 text-sm font-bold mb-2" for="password">パスワード(db_userのパスワード):</label>
140132
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="password" name="password" type="password" required>
141133
</div>
142134
<div class="mb-4">

0 commit comments

Comments
 (0)