Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 16c99894c7 | |||
| d467d82a3e | |||
| 2ade56a952 | |||
| dd3a9027d5 | |||
| 1ae5df5420 | |||
| 445d6da9ef | |||
| 5a0cefbfbb | |||
| 837b3aaab5 | |||
| 34859e55b3 | |||
| efa4ceedf8 | |||
| 4b89165f8e | |||
| dca71147b4 |
+2
-1
@@ -1,4 +1,5 @@
|
||||
/images
|
||||
/drafts
|
||||
/database.php
|
||||
|
||||
/db.sqlite3
|
||||
/www/images
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Dao;
|
||||
|
||||
|
||||
class
|
||||
Response
|
||||
{
|
||||
public static function
|
||||
fetch_all (
|
||||
\SQLite3 $db,
|
||||
int $thread_id)
|
||||
: array
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
thread_id,
|
||||
response_id,
|
||||
name,
|
||||
message,
|
||||
date,
|
||||
image,
|
||||
held,
|
||||
deleted,
|
||||
pass,
|
||||
good,
|
||||
bad
|
||||
FROM
|
||||
responses
|
||||
WHERE
|
||||
id = $thread_id";
|
||||
|
||||
$result = $db -> query ($sql);
|
||||
|
||||
$responses = [];
|
||||
|
||||
while (($row = $result -> fetchArray (SQLITE_ASSOC)) !== false)
|
||||
{
|
||||
$response = new Dto\Response;
|
||||
|
||||
$response -> thread_id = $row['thread_id'];
|
||||
$response -> response_id = $row['response_id'];
|
||||
$response -> name = $row['name'];
|
||||
$response -> message = $row['message'];
|
||||
$response -> date = $row['date'];
|
||||
$response -> image = $row['image'];
|
||||
$response -> held = $row['held'];
|
||||
$response -> deleted = $row['deleted'];
|
||||
$response -> pass = $row['pass'];
|
||||
$response -> good = $row['good'];
|
||||
$response -> bad = $row['bad'];
|
||||
|
||||
$responses[] = $response;
|
||||
}
|
||||
|
||||
return $responses;
|
||||
}
|
||||
|
||||
|
||||
public static function
|
||||
like (
|
||||
\SQLite3 $db,
|
||||
int $thread_id,
|
||||
int $response_id)
|
||||
: void
|
||||
{
|
||||
$sql = "
|
||||
UPDATE
|
||||
responses
|
||||
SET
|
||||
good = good + 1
|
||||
WHERE
|
||||
(thread_id = $thread_id)
|
||||
AND (response_id = $response_id)";
|
||||
|
||||
$db -> query ($sql);
|
||||
}
|
||||
|
||||
|
||||
public static function
|
||||
dislike (
|
||||
\SQLite3 $db,
|
||||
int $thread_id,
|
||||
int $response_id)
|
||||
: void
|
||||
{
|
||||
$sql = "
|
||||
UPDATE
|
||||
responses
|
||||
SET
|
||||
bad = bad + 1
|
||||
WHERE
|
||||
(thread_id = $thread_id)
|
||||
AND (response_id = $response_id)";
|
||||
|
||||
$db -> query ($sql);
|
||||
}
|
||||
}
|
||||
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace Dao;
|
||||
|
||||
|
||||
class
|
||||
Thread
|
||||
{
|
||||
public static function
|
||||
fetch_all (
|
||||
\SQLite3 $db)
|
||||
: array
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
t.id,
|
||||
t.title,
|
||||
t.explain,
|
||||
MAX(r.date) AS latest
|
||||
FROM
|
||||
threads AS t
|
||||
LEFT OUTER JOIN
|
||||
responses AS r
|
||||
ON
|
||||
r.thread_id = t.id
|
||||
WHERE
|
||||
t.id <> 1
|
||||
-- AND t.deleted = 0
|
||||
GROUP BY
|
||||
t.id
|
||||
ORDER BY
|
||||
latest DESC";
|
||||
|
||||
$result = $db -> query ($sql);
|
||||
|
||||
$threads = [];
|
||||
|
||||
while (($row = $result -> fetchArray (SQLITE3_ASSOC)) !== false)
|
||||
{
|
||||
$thread = new Dto\Thread;
|
||||
|
||||
$thread -> id = $row['id'];
|
||||
$therad -> title = $row['title'];
|
||||
$thread -> explain = $row['explain'];
|
||||
$thread -> latest = $row['latest'];
|
||||
|
||||
$threads[] = $thread;
|
||||
}
|
||||
|
||||
return $therads;
|
||||
}
|
||||
|
||||
|
||||
public static function
|
||||
find (
|
||||
\SQLite3 $db,
|
||||
int $id)
|
||||
: ?\Dto\Thread
|
||||
{
|
||||
$sql = "
|
||||
SELECT
|
||||
t.id,
|
||||
t.title,
|
||||
t.explain,
|
||||
MAX(r.date) AS latest
|
||||
FROM
|
||||
threads AS t
|
||||
LEFT OUTER JOIN
|
||||
responses AS r
|
||||
ON
|
||||
r.thread_id = t.id
|
||||
WHERE
|
||||
t.id = $id
|
||||
GROUP BY
|
||||
t.id
|
||||
ORDER BY
|
||||
latest DESC";
|
||||
|
||||
$result = $db -> query ($sql);
|
||||
|
||||
if ($row === false)
|
||||
return null;
|
||||
|
||||
$row = $result -> fetchArray (SQLITE3_ASSOC);
|
||||
|
||||
if ($row === false)
|
||||
return null;
|
||||
|
||||
$thread = new \Dto\Thread;
|
||||
|
||||
$thread -> id = $row['id'];
|
||||
$thread -> title = $row['title'];
|
||||
$thread -> explain = $row['explain'];
|
||||
$thread -> length = $row['length'];
|
||||
|
||||
return $thread;
|
||||
}
|
||||
|
||||
|
||||
public static function
|
||||
create_thread (
|
||||
\SQLite3 $db,
|
||||
string $title,
|
||||
string $explain)
|
||||
: void
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
public static function
|
||||
delete_thread (
|
||||
\SQLite3 $db,
|
||||
int $id)
|
||||
: void
|
||||
{
|
||||
$db -> query ("
|
||||
DELETE FROM
|
||||
threads
|
||||
WHERE
|
||||
id = $id");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
function
|
||||
set_mysql ($db)
|
||||
{
|
||||
$url = 'localhost';
|
||||
$user = 'root';
|
||||
$pass = '';
|
||||
|
||||
return new mysqli ($url, $user, $pass, $db);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Dto;
|
||||
|
||||
|
||||
class
|
||||
Response
|
||||
{
|
||||
public int $thread_id;
|
||||
public int $response_id;
|
||||
public string $name;
|
||||
public ?string $message;
|
||||
public DateTime $date;
|
||||
public string $image;
|
||||
public bool $held;
|
||||
public bool $deleted;
|
||||
public ?string $pass;
|
||||
public int $good;
|
||||
public int $bad;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Dto;
|
||||
|
||||
|
||||
class
|
||||
Thread
|
||||
{
|
||||
public int $id;
|
||||
public string $title;
|
||||
public ?string $explain;
|
||||
public ?DateTime $latest;
|
||||
public bool $deleted;
|
||||
}
|
||||
|
||||
+54
-40
@@ -1,11 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="robots" content="noindex">
|
||||
<title><?= ($title == '') ? '' : ($title . ' - ') ?>キケッツチャンネル お絵描き掲示板(跡地)</title>
|
||||
<link rel="stylesheet" type="text/css" href="./styles/style.css">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="robots" content="noindex" />
|
||||
<title><?= ($title == '') ? '' : ($title . ' - ') ?>キケッツチャンネル お絵描き掲示板</title>
|
||||
<!-- <link rel="stylesheet" href="https://jpafonts.osdn.jp/webfonts/jpafonts.css" /> -->
|
||||
<link rel="stylesheet" type="text/css" href="./styles/style.css" />
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css" />
|
||||
<script defer src="https://use.fontawesome.com/releases/v5.15.4/js/all.js"></script>
|
||||
<script src="./scripts/colour-pad.js"></script>
|
||||
</head>
|
||||
@@ -23,13 +24,13 @@
|
||||
<div style="margin-bottom: 16px">
|
||||
<div>
|
||||
<label for="width">幅:</label>
|
||||
<input type="number" id="change-width" name="width" value="480" min="32" max="640">
|
||||
<input type="number" id="change-width" name="width" value="480" min="32" max="640" />
|
||||
<label>(32 〜 640)</label>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="height">高さ:</label>
|
||||
<input type="number" id="change-height" name="height" value="480" min="24" max="480">
|
||||
<input type="number" id="change-height" name="height" value="480" min="24" max="480" />
|
||||
<label>(24 〜 480)</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -40,14 +41,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1><a href="."><img src="./assets/kusobbs.gif" alt="クソ掲示板" style="width: 398px"></a></h1>
|
||||
<h1><a href="."><img src="/assets/kusobbs.gif" alt="クソ掲示板" style="width: 398px" /></a></h1>
|
||||
<div style="text-align: center"><a href="#" onclick="PauseMusic ()" id="mute"> </a></div>
|
||||
|
||||
<?php if ($thread == -1): ?>
|
||||
<form action="./modules/make_thread.php" method="POST">
|
||||
スレ名:<input type="text" name="thread-name"><br>
|
||||
スレ内容:<textarea name="thread-explain"></textarea><br>
|
||||
<input type="submit" value="スレ立て" disabled>
|
||||
スレ名:<input type="text" name="thread-name" /><br />
|
||||
スレ内容:<textarea name="thread-explain"></textarea><br />
|
||||
<input type="submit" value="スレ立て" />
|
||||
</form>
|
||||
|
||||
<?php if ($result = $mysqli -> query ("SELECT * FROM threads WHERE id <> 1 ORDER BY latest DESC")): ?>
|
||||
@@ -80,8 +81,8 @@
|
||||
</table>
|
||||
|
||||
<form id="message-form">
|
||||
<label>名前:</label><input type="text" id="user-name" name="name"><br>
|
||||
<label>削除用パスワード:</label><input type="password" id="password" name="password">
|
||||
<label>名前:</label><input type="text" id="user-name" name="name" /><br />
|
||||
<label>削除用パスワード:</label><input type="password" id="password" name="password" />
|
||||
<!-- <textarea id="message" name="message"></textarea> -->
|
||||
</form>
|
||||
|
||||
@@ -89,8 +90,8 @@
|
||||
<div style="display: flex; justify-content: center">
|
||||
<div class="button-area" style="margin-right: 64px">
|
||||
<button id="new">新規作成</button>
|
||||
<button id="send" disabled>送信</button>
|
||||
<button id="save" disabled>ダウンロード</button>
|
||||
<button id="send">送信</button>
|
||||
<button id="save">ダウンロード</button>
|
||||
<button id="change-size">サイズ変更</button>
|
||||
</div>
|
||||
|
||||
@@ -104,20 +105,28 @@
|
||||
<div class="radio">
|
||||
<form id="mode">
|
||||
<label>モード:</label>
|
||||
<label><input type="radio" name="mode" value="pen" id="pen" checked>ペン</label>
|
||||
<label><input type="radio" name="mode" value="rubber" id="rubber">消しゴム</label>
|
||||
<label><input type="radio" name="mode" value="bucket" id="bucket">塗りつぶし</label>
|
||||
<label><input type="radio" name="mode" value="pen" id="pen" checked />ペン</label>
|
||||
<label><input type="radio" name="mode" value="rubber" id="rubber" />消しゴム</label>
|
||||
<label><input type="radio" name="mode" value="bucket" id="bucket" />塗りつぶし</label>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="radio">
|
||||
<label>取込み:</label>
|
||||
<input id="load" type="file" onChange="LoadFile (this.files)">
|
||||
<input id="load" type="file" onChange="LoadFile (this.files)" />
|
||||
</div>
|
||||
|
||||
<div class="radio">
|
||||
<form id="colour">
|
||||
<label>色:</label>
|
||||
<!-- <input type="radio" name="colour" value="black" checked="checked" />黒
|
||||
<input type="radio" name="colour" value="blue" />ブルー
|
||||
<input type="radio" name="colour" value="red" />赤
|
||||
<input type="radio" name="colour" value="magenta" />マジェンタ
|
||||
<input type="radio" name="colour" value="lime" />ライム
|
||||
<input type="radio" name="colour" value="cyan" />青
|
||||
<input type="radio" name="colour" value="yellow" />イェロウ
|
||||
<input type="radio" name="colour" value="white" />白 -->
|
||||
<button id="colour-picker" type="button" onclick="cmanCP_JS_open(this)" cmanCPat="def_color:cns=#000000,rc_form:RGBA,rc_func:changeColour">選択</button>
|
||||
<label id="irorororo">黒</label>
|
||||
</form>
|
||||
@@ -126,30 +135,31 @@
|
||||
<div class="radio">
|
||||
<form id="size">
|
||||
<label>太さ:</label>
|
||||
<label><input type="radio" name="size" value="1">1</label>
|
||||
<label><input type="radio" name="size" value="2">2</label>
|
||||
<label><input type="radio" name="size" value="3" checked>3</label>
|
||||
<label><input type="radio" name="size" value="5">5</label>
|
||||
<label><input type="radio" name="size" value="7">7</label>
|
||||
<label><input type="radio" name="size" value="10">10</label>
|
||||
<label><input type="radio" name="size" value="15">15</label>
|
||||
<label><input type="radio" name="size" value="0">指定:
|
||||
<input style="width: 2em" type="number" name="size" id="size-free" value="57"></label>
|
||||
<label><input type="radio" name="size" value="1" />1</label>
|
||||
<label><input type="radio" name="size" value="2" />2</label>
|
||||
<label><input type="radio" name="size" value="3" checked="checked" />3</label>
|
||||
<label><input type="radio" name="size" value="5" />5</label>
|
||||
<label><input type="radio" name="size" value="7" />7</label>
|
||||
<label><input type="radio" name="size" value="10" />10</label>
|
||||
<label><input type="radio" name="size" value="15" />15</label>
|
||||
<!-- <input type="range" name="size" min="1" max="57" value="3" /> -->
|
||||
<label><input type="radio" name="size" value="0" />指定:
|
||||
<input style="width: 2em" type="number" name="size" id="size-free" value="57" /></label>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="radio">
|
||||
<form id="layer">
|
||||
<label>レイア:</label>
|
||||
<label><input onclick="reDraw ()" type="radio" name="layer" value="0" checked>基底</label>
|
||||
<label><input onclick="reDraw ()" type="radio" name="layer" value="1">1</label>
|
||||
<label><input onclick="reDraw ()" type="radio" name="layer" value="2">2</label>
|
||||
<label><input onclick="reDraw ()" type="radio" name="layer" value="0" checked="checked" />基底</label>
|
||||
<label><input onclick="reDraw ()" type="radio" name="layer" value="1" />1</label>
|
||||
<label><input onclick="reDraw ()" type="radio" name="layer" value="2" />2</label>
|
||||
<button type="button" name="del">削除</button>
|
||||
<button type="button" name="down">下へ</button>
|
||||
<button type="button" name="up">上へ</button>
|
||||
<button type="button" name="add">追加</button>
|
||||
<br>
|
||||
<label><input onclick="reDraw ()" type="checkbox" name="sep">レイアを分けて表示</label>
|
||||
<br />
|
||||
<label><input onclick="reDraw ()" type="checkbox" name="sep" />レイアを分けて表示</label>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -221,7 +231,7 @@
|
||||
font-size: 80%">
|
||||
<div style="grid-columns: 1; text-align: left;">
|
||||
<a style="color: blue; white-space: nowrap" title="低評価"
|
||||
tabindex="-1">
|
||||
href="?thread=<?= $thread ?>&sort=<?= $sort ?>&evaluate=bad&id=<?= $row['id'] ?>#<?= $row['id'] ?>">
|
||||
<i class="fas fa-thumbs-down"></i> <?= $row['bad'] ?>
|
||||
</a>
|
||||
</div>
|
||||
@@ -241,7 +251,7 @@
|
||||
</div>
|
||||
|
||||
<div style="grid-columns: 4; text-align: right">
|
||||
<a style="color: red" title="高評価" tabindex="-1">
|
||||
<a style="color: red" title="高評価" href="?thread=<?= $thread ?>&sort=<?= $sort ?>&evaluate=good&id=<?= $row['id'] ?>#<?= $row['id'] ?>">
|
||||
<?= $row['good'] ?> <i class="fas fa-thumbs-up"></i>
|
||||
</a>
|
||||
</div>
|
||||
@@ -256,7 +266,7 @@
|
||||
<?php elseif ($row['held']): ?>
|
||||
<tr><td><p>確認中です.</p></td></tr>
|
||||
<?php else: ?>
|
||||
<tr><td class="illust" style="display: grid; grid-template-columns: .375fr auto .375fr; align-items: end"><div style="grid-columns: 1"></div><div style="grid-columns: 2; text-align: center"><img style="border: solid 1px"src="<?= $dir . $row['image'] ?>"></div><div style="grid-columns: 3; justify-self: end; margin-right: 8px; margin-bottom: 8px; font-size: 80%"><a href="#del" onclick="deletePost (<?= $row['id'] ?>)">削除</a></div></td></tr>
|
||||
<tr><td class="illust" style="display: grid; grid-template-columns: .375fr auto .375fr; align-items: end"><div style="grid-columns: 1"></div><div style="grid-columns: 2; text-align: center"><img style="border: solid 1px"src="<?= $dir . $row['image'] ?>" /></div><div style="grid-columns: 3; justify-self: end; margin-right: 8px; margin-bottom: 8px; font-size: 80%"><a href="#del" onclick="deletePost (<?= $row['id'] ?>)">削除</a></div></td></tr>
|
||||
<?php endif ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -270,15 +280,19 @@
|
||||
</div>
|
||||
|
||||
<h3 id="del">レス削除</h3>
|
||||
削除したいレス番号と削除用パスワードを入力して “削除” を押してください.<br>
|
||||
<label>レス番号:</label><input type="text" id="del-id"><br>
|
||||
<label>削除用パスワード:</label><input type="password" id="del-pass"><br>
|
||||
削除したいレス番号と削除用パスワードを入力して “削除” を押してください.<br />
|
||||
<label>レス番号:</label><input type="text" id="del-id" /><br />
|
||||
<label>削除用パスワード:</label><input type="password" id="del-pass" /><br />
|
||||
<button id="delete" onclick="deletePostReally ()">削除</button>
|
||||
<?php endif ?>
|
||||
|
||||
<hr>
|
||||
<hr />
|
||||
|
||||
<footer>
|
||||
<div class="attention">
|
||||
このサイトでは,<a href="https://moji.or.jp/ipafont/license/" target="_blank">IPA フォントライセンス v1.0</a> で公開されてゐる <a href="https://jpafonts.osdn.jp/" target="_blank">JPA フォント</a>を使用してゐます.
|
||||
</div>
|
||||
|
||||
<div class="copyright">
|
||||
© このペィジへの投稿は,すべて,パブリック・ドメインとします.
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/daos/response.php';
|
||||
require_once __DIR__ . '/daos/thread.php';
|
||||
require_once __DIR__ . '/dtos/response.php';
|
||||
require_once __DIR__ . '/dtos/thread.php';
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once './database.php';
|
||||
|
||||
if (isset ($_GET['page']))
|
||||
$page = $_GET['page'];
|
||||
else
|
||||
$page = 0;
|
||||
|
||||
if (isset ($_GET['thread']))
|
||||
$thread = $_GET['thread'];
|
||||
else
|
||||
$thread = -1;
|
||||
|
||||
if (isset ($_GET['sort']))
|
||||
{
|
||||
$sort = $_GET['sort'];
|
||||
|
||||
if (!(in_array ($sort, array ('td', 'eg', 'ta', 'eb'))))
|
||||
$sort = 'td';
|
||||
}
|
||||
else
|
||||
$sort = 'td';
|
||||
|
||||
// 画像のディレクトリを開く.
|
||||
$dir = './images/';
|
||||
$handle = opendir ($dir);
|
||||
|
||||
// MySQL 宣言
|
||||
$mysqli = set_mysql ('miteruzo_bbs');
|
||||
|
||||
$mysqli -> set_charset ('utf8');
|
||||
|
||||
if ($result = $mysqli -> query ("SELECT * FROM threads WHERE id = $thread"))
|
||||
{
|
||||
$row = $result -> fetch_assoc ();
|
||||
|
||||
$title = $row['title'];
|
||||
$explain = $row['explain'];
|
||||
|
||||
$result -> close ();
|
||||
}
|
||||
|
||||
require_once './forms/index.frm.php';
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once './db_connection.php';
|
||||
|
||||
|
||||
$files = glob ('./migrations/*.sql');
|
||||
|
||||
foreach ($files as $file)
|
||||
$__db_connection -> query (file_get_contents ($file));
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
CREATE TABLE `miteruzo_bbs`.`threads` ( `id` INT NOT NULL AUTO_INCREMENT , `title` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL , `explain` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL , `latest` DATETIME NOT NULL , `length` INT NOT NULL DEFAULT '0' , PRIMARY KEY (`id`)) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
CREATE TABLE `miteruzo_bbs`.`responses` ( `thread_id` INT NOT NULL , `response_id` INT NOT NULL , `name` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '名なしさん' , `message` MEDIUMTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL , `date` DATETIME NOT NULL , `image` VARCHAR(31) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL , `held` TINYINT NOT NULL DEFAULT '0' , `deleted` TINYINT NOT NULL DEFAULT '0' , `pass` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL , `good` INT NOT NULL DEFAULT '0' , `bad` INT NOT NULL DEFAULT '0' , PRIMARY KEY (`thread_id`, `response_id`)) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
CREATE TABLE `threads` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT , `title` TEXT NOT NULL, `explain` TEXT NOT NULL , `latest` TEXT NOT NULL , `length` INTEGER NOT NULL DEFAULT 0) ;
|
||||
@@ -0,0 +1,2 @@
|
||||
CREATE TABLE `responses` ( `thread_id` INTEGER , `response_id` INTEGER , `name` TEXT NOT NULL DEFAULT '名なしさん' , `message` TEXT NOT NULL , `date` TEXT NOT NULL , `image` TEXT NOT NULL , `held` INTEGER NOT NULL DEFAULT 0 , `deleted` INTEGER NOT NULL DEFAULT 0 , `pass` TEXT NULL , `good` INTEGER NOT NULL DEFAULT 0, `bad` INTEGER NOT NULL DEFAULT 0 , PRIMARY KEY(thread_id, response_id ));
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
define ('SAVE_DIR', "${_SERVER['DOCUMENT_ROOT']}/drafts/");
|
||||
|
||||
$json = getParamJSON ();
|
||||
|
||||
if (!(isset ($json['data'])))
|
||||
{
|
||||
sendResult (false, 'Empty query Parameter: data');
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (!(preg_match ('/^data:image\/png;base64,/', $json['data'])))
|
||||
{
|
||||
sendResult (false, 'Not Allow data type: data');
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
$data = $json['data'];
|
||||
$data = str_replace ('data:image/png;base64,', '', $data);
|
||||
$data = str_replace (' ', '+', $data);
|
||||
$image = base64_decode ($data);
|
||||
|
||||
$file = sprintf ('%s.png', $_GET['id']);
|
||||
$result = file_put_contents (SAVE_DIR . $file, $image, LOCK_EX);
|
||||
|
||||
setcookie ('backup', $file, time () + 60 * 60 * 24 * 30);
|
||||
|
||||
|
||||
function
|
||||
getParamJSON ():
|
||||
array
|
||||
{
|
||||
$buff = file_get_contents ('php://input');
|
||||
$json = json_decode ($buff, true);
|
||||
|
||||
return ($json);
|
||||
}
|
||||
|
||||
function
|
||||
sendResult (
|
||||
$status,
|
||||
$data):
|
||||
string
|
||||
{
|
||||
header ('Access-Control-Allow-Origin: *');
|
||||
header ('Access-Control-Allow-Headers: *');
|
||||
|
||||
echo json_encode(["status" => $status,
|
||||
"result" => $data]);
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
require "${_SERVER['DOCUMENT_ROOT']}/database.php";
|
||||
|
||||
|
||||
$mysqli = set_mysql ('miteruzo_bbs');
|
||||
|
||||
$mysqli -> set_charset ('utf8');
|
||||
|
||||
$thread = $_GET['thread'];
|
||||
$id = $_GET['id'];
|
||||
$pass = $_GET['pass'];
|
||||
|
||||
if ($result = $mysqli -> query ("
|
||||
SELECT
|
||||
pass, image
|
||||
FROM
|
||||
responses
|
||||
WHERE
|
||||
(thread_id = {$_GET['thread']}) AND (response_id = {$_GET['id']})")):
|
||||
$row = $result -> fetch_assoc ();
|
||||
|
||||
if ($_GET['pass'] == $row['pass']):
|
||||
$mysqli -> query ("
|
||||
UPDATE
|
||||
responses
|
||||
SET
|
||||
deleted = 1
|
||||
WHERE
|
||||
(thread_id = $thread) AND (response_id = $id)");
|
||||
|
||||
echo "消しましたぁ!!<br /><br /><img style='border: solid 1px' src='/images/{$row['image']}' />";
|
||||
else:
|
||||
echo '残念.<br />削除用パスワードが違います.';
|
||||
endif;
|
||||
|
||||
echo "<br /><br />5 秒後に元のページに戻ります.<br /><br /><a href='/?thread=$thread#$id'>戻らない場合はこちら</a><script>setTimeout (function () {window.location.href = `/?thread=$thread#$id`}, 5000)</script>";
|
||||
endif;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
require "${_SERVER['DOCUMENT_ROOT']}/database.php";
|
||||
|
||||
|
||||
if (!(empty ($_POST['thread-name'])))
|
||||
{
|
||||
$explain = '<p>' . $_POST['thread-explain'] . '</p>';
|
||||
$explain = str_replace ("\n", '</p><p>', $explain);
|
||||
|
||||
$mysqli = set_mysql ('miteruzo_bbs');
|
||||
|
||||
$mysqli -> set_charset ('utf8');
|
||||
|
||||
$result = $mysqli -> query ('SELECT COUNT(*) FROM threads');
|
||||
$row = $result -> fetch_assoc ();
|
||||
$current = $row['COUNT(*)'];
|
||||
|
||||
$result -> close ();
|
||||
|
||||
$sql = "INSERT INTO threads (title, `explain`, latest, length) VALUES ('{$_POST['thread-name']}', '$explain', '" . date ('Y-m-d H:i:s') . "', 0)";
|
||||
$mysqli -> query ($sql);
|
||||
/* $sql = "CREATE TABLE `miteruzo_bbs`.`thread_$current` (
|
||||
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'レス番',
|
||||
`name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '名なしさん' COMMENT '名前',
|
||||
`message` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'レス',
|
||||
`date` DATETIME NOT NULL COMMENT '投稿日時',
|
||||
`image` VARCHAR( 31 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '画像 URL',
|
||||
`held` TINYINT( 1 ) NOT NULL DEFAULT '0' COMMENT '保留',
|
||||
`deleted` TINYINT( 1 ) NOT NULL DEFAULT '0' COMMENT '削除済',
|
||||
`pass` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '削除用パスワード',
|
||||
`good` INT( 11 ) NOT NULL DEFAULT '0' COMMENT '高評価数',
|
||||
`bad` INT( 11 ) NOT NULL DEFAULT '0' COMMENT '低評価数',
|
||||
INDEX ( `date` )
|
||||
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; */
|
||||
$mysqli -> query ($sql);
|
||||
|
||||
$mysqli -> close ();
|
||||
}
|
||||
|
||||
header ("location: ../?thread=$current");
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
require "${_SERVER['DOCUMENT_ROOT']}/database.php";
|
||||
|
||||
|
||||
define ('SAVE_DIR', "${_SERVER['DOCUMENT_ROOT']}/images/"); // 保存ディレクトリ定義
|
||||
|
||||
$thread = $_GET['thread'];
|
||||
// file_put_contents ('log.txt', $thread);
|
||||
|
||||
$json = getParamJSON (); // JSON パラメタ
|
||||
|
||||
// JSON に data メトッドがなぃ場合
|
||||
if (!(isset ($json['data']))):
|
||||
sendResult (false, 'Empty query Parameter: data');
|
||||
exit (1);
|
||||
endif;
|
||||
|
||||
// 適切な画像形式が示されてゐなぃ場合
|
||||
if (!(preg_match ('/^data:image\/png;base64,/', $json['data']))):
|
||||
sendResult (false, 'Not Allow data type: data');
|
||||
exit (1);
|
||||
endif;
|
||||
|
||||
// 画像ディタをデコゥド
|
||||
$data = $json['data'];
|
||||
$data = str_replace ('data:image/png;base64,', '', $data);
|
||||
$data = str_replace (' ', '+', $data);
|
||||
$image = base64_decode ($data);
|
||||
|
||||
$file = sprintf ('%s.png', uniqid ()); // ファイル名をタイマを基準に設定
|
||||
file_put_contents (SAVE_DIR . $file, $image, LOCK_EX); // 画像をファイルに保存
|
||||
|
||||
$mysqli = set_mysql ('miteruzo_bbs'); // ディタ・べィス指定
|
||||
|
||||
$mysqli -> set_charset ('utf8');
|
||||
|
||||
// スレのレス数を取得し,適切なレス番を設定する.
|
||||
if ($result = $mysqli -> query ("
|
||||
SELECT
|
||||
length
|
||||
FROM
|
||||
threads
|
||||
WHERE
|
||||
id = $thread")):
|
||||
$row = $result -> fetch_assoc ();
|
||||
|
||||
$id = $row['length'] + 1;
|
||||
|
||||
$result -> close (); // クヱリ結果を閉ぢる.
|
||||
endif;
|
||||
|
||||
if ($_GET['held']):
|
||||
mb_language ('Japanese');
|
||||
mb_internal_encoding ('UTF-8');
|
||||
mb_send_mail ('matuda.miteruzo@gmail.com', 'キケッツ掲示板の画像確認しろ!', '何か,保留中なうみ.', '謎');
|
||||
endif;
|
||||
|
||||
// 投稿情報に従ひ,ディタ・ベィスを更新
|
||||
$sql = "INSERT INTO
|
||||
responses (thread_id, response_id, name, pass, message, date, image, held,
|
||||
deleted)
|
||||
VALUES
|
||||
($thread, $id, '" . (($_GET['name'] == '') ? '名なしさん' : $_GET['name']) . "',
|
||||
" . (($_GET['pass'] == '') ? "NULL" : "'{$_GET['pass']}'") . ", '', '" . date ('Y-m-d H:i:s') . "', '$file', {$_GET['held']}, 0)";
|
||||
$mysqli -> query ($sql);
|
||||
$mysqli -> query ("
|
||||
UPDATE
|
||||
threads
|
||||
SET
|
||||
length = $id, latest = '" . date ('Y-m-d H:i:s') . "' WHERE id = $thread");
|
||||
|
||||
$mysqli -> close (); // ディタ・べィスを閉ぢる.
|
||||
|
||||
unlink ('draft/' . $_COOKIE['backup']);
|
||||
setcookie ('backup', '', 0);
|
||||
|
||||
|
||||
/*
|
||||
* フェッチ内容から JSON パラメタを取得する.
|
||||
*
|
||||
* 戻り値は,取得した JSON パラメタ.
|
||||
*/
|
||||
function
|
||||
getParamJSON ()
|
||||
{
|
||||
$buff = file_get_contents ('php://input');
|
||||
$json = json_decode ($buff, true);
|
||||
|
||||
return ($json);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* クヱリ送信者に,結果を返す.
|
||||
* $status:結果フラグ,$data:返信ディタ
|
||||
*
|
||||
* 戻り値は,なし.
|
||||
*/
|
||||
function
|
||||
sendResult ($status, $data)
|
||||
{
|
||||
header ('Access-Control-Allow-Origin: *');
|
||||
header ('Access-Control-Allow-Headers: *');
|
||||
|
||||
echo json_encode(["status" => $status,
|
||||
"result" => $data]);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
-1049
File diff suppressed because it is too large
Load Diff
@@ -1,169 +0,0 @@
|
||||
const music = new Audio ('./assets/music.mp3'); // BGM
|
||||
let playing = false; // 再生フラグ
|
||||
let nowPlay = true; // 再生すべきかどぅか
|
||||
|
||||
document.getElementById ('sort').addEventListener ('change', sortChange);
|
||||
|
||||
/*
|
||||
* BGM を再生しよぅとする.
|
||||
*
|
||||
* 戻り値は,なし.
|
||||
*/
|
||||
async function
|
||||
PlayMusic ()
|
||||
{
|
||||
// 再生中でなぃ場合
|
||||
if (playing === false)
|
||||
{
|
||||
// BGM を再生しよぅとする.
|
||||
try
|
||||
{
|
||||
await music.play ();
|
||||
music.loop = true;
|
||||
|
||||
playing = true;
|
||||
nowPlay = true;
|
||||
|
||||
// オン/オフ・ボタン
|
||||
document.getElementById ('mute').innerHTML = 'BGM がうるさい人用';
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
playing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* BGM の消音切替
|
||||
*
|
||||
* 戻り値は,なし.
|
||||
*/
|
||||
function
|
||||
PauseMusic ()
|
||||
{
|
||||
// 切替
|
||||
if (nowPlay && playing) // 再生中の場合
|
||||
{
|
||||
music.muted = true;
|
||||
document.getElementById ('mute').innerHTML = 'やっぱり BGM が恋しい人用';
|
||||
|
||||
nowPlay = false;
|
||||
}
|
||||
else // 消音中の場合
|
||||
{
|
||||
music.muted = false;
|
||||
document.getElementById ('mute').innerHTML = 'BGM がうるさい人用';
|
||||
|
||||
nowPlay = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 1000 ms ごとに BGM 再生試行
|
||||
window.setInterval (function
|
||||
()
|
||||
{
|
||||
PlayMusic ();
|
||||
},
|
||||
1000);
|
||||
|
||||
// 画面クリックで BGM 再生試行
|
||||
document.addEventListener ('click', function
|
||||
()
|
||||
{
|
||||
PlayMusic ();
|
||||
});
|
||||
|
||||
// 画面タッチで BGM 再生試行
|
||||
document.addEventListener ('touchstart', function
|
||||
()
|
||||
{
|
||||
PlayMusic ();
|
||||
});
|
||||
|
||||
const body = document.getElementsByTagName ('body')[0]; // body 要素
|
||||
const cv = document.getElementById ('work'); // 作業用 Canvas
|
||||
const g = cv.getContext ('2d'); // 作業用 Canvas のコンテクスト
|
||||
|
||||
const list = ['magenta', 'lime', 'cyan', 'yellow', 'orange', 'pink', 'aliceblue',
|
||||
'antiquewhite', 'aqua', 'aquamarine', 'bisque', 'lightgreen', 'linen',
|
||||
'lightsalmon', 'darkorange', 'palegreen'];
|
||||
// 色リスト
|
||||
let nowColour = Math.floor (Math.random () * list.length);
|
||||
// 前の色番号
|
||||
let nextColour = Math.floor (Math.random () * list.length);
|
||||
// 次の色番号
|
||||
let [tempR, tempG, tempB] = getRGB (list[nowColour]);
|
||||
// 現在の RGB 値
|
||||
|
||||
// 3000 ms ごとに次の色指定
|
||||
window.setInterval (function
|
||||
()
|
||||
{
|
||||
nowColour = nextColour;
|
||||
nextColour = Math.floor (Math.random () * list.length);
|
||||
},
|
||||
3000);
|
||||
|
||||
// 20 ms ごとに,ぢょぢょに,色変更
|
||||
window.setInterval (function
|
||||
()
|
||||
{
|
||||
let [nowR, nowG, nowB] = getRGB (list[nowColour]);
|
||||
let [nextR, nextG, nextB] = getRGB (list[nextColour]);
|
||||
|
||||
body.style.backgroundColor = `rgb(${tempR}, ${tempG}, ${tempB})`;
|
||||
|
||||
tempR += (nextR - nowR) / 150;
|
||||
tempG += (nextG - nowG) / 150;
|
||||
tempB += (nextB - nowB) / 150;
|
||||
},
|
||||
20);
|
||||
|
||||
/*
|
||||
* カラ・コゥド c を RGB 値に変換する.
|
||||
*
|
||||
* 戻り値は,RGB 値排列.
|
||||
*/
|
||||
function
|
||||
getRGB (c)
|
||||
{
|
||||
g.fillStyle = c;
|
||||
g.fillRect (0, 0, 1, 1);
|
||||
|
||||
const img = g.getImageData (0, 0, 1, 1);
|
||||
const px = img.data;
|
||||
const rgb = [px[0], px[1], px[2]];
|
||||
|
||||
return rgb;
|
||||
}
|
||||
|
||||
function
|
||||
sortChange (evt)
|
||||
{
|
||||
const searchParams = new URLSearchParams (window.location.search);
|
||||
|
||||
switch (evt.currentTarget.value)
|
||||
{
|
||||
default:
|
||||
window.location.href = `./?thread=${searchParams.get ('thread')}&sort=td`;
|
||||
|
||||
break;
|
||||
|
||||
case 'evaluate-good':
|
||||
window.location.href = `./?thread=${searchParams.get ('thread')}&sort=eg`;
|
||||
|
||||
break;
|
||||
|
||||
case 'time-asc':
|
||||
window.location.href = `./?thread=${searchParams.get ('thread')}&sort=ta`;
|
||||
|
||||
break;
|
||||
|
||||
case 'evaluate-bad':
|
||||
window.location.href = `./?thread=${searchParams.get ('thread')}&sort=eb`;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 805 KiB After Width: | Height: | Size: 805 KiB |
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../import.php';
|
||||
|
||||
use \Dto;
|
||||
|
||||
|
||||
$db = new SQLite3 ('../db.sqlite3');
|
||||
|
||||
if (isset ($_GET['page']))
|
||||
$page = $_GET['page'];
|
||||
else
|
||||
$page = 0;
|
||||
|
||||
if (isset ($_GET['thread']))
|
||||
$thread = $_GET['thread'];
|
||||
else
|
||||
$thread = -1;
|
||||
|
||||
if (isset ($_GET['sort']))
|
||||
{
|
||||
$sort = $_GET['sort'];
|
||||
|
||||
if (!(in_array ($sort, array ('td', 'eg', 'ta', 'eb'))))
|
||||
$sort = 'td';
|
||||
}
|
||||
else
|
||||
$sort = 'td';
|
||||
|
||||
// 画像のディレクトリを開く.
|
||||
$dir = './images/';
|
||||
$handle = opendir ($dir);
|
||||
|
||||
if ($row = \Dao\Thread :: find ($db, $thread))
|
||||
{
|
||||
$title = $row -> title;
|
||||
$explain = $row -> explain;
|
||||
}
|
||||
|
||||
if (isset ($_GET['id']))
|
||||
{
|
||||
if (($_GET['evaluate'] ?? '') === 'good')
|
||||
{
|
||||
\Dao\Response :: like ($db, (int) $_GET['id']);
|
||||
header ("Location: ./?thread=$thread&sort=$sort");
|
||||
}
|
||||
|
||||
if (($_GET['evaluate'] ?? '') === 'bad')
|
||||
{
|
||||
\Dao\Response :: dislike ($db, (int) $_GET['id']);
|
||||
header ("Location: ./?thread=$thread&sort=$sort");
|
||||
}
|
||||
}
|
||||
|
||||
require_once './forms/index.frm.php';
|
||||
|
||||
Reference in New Issue
Block a user