最初のコミット

このコミットが含まれているのは:
守矢諏訪子 2022-05-08 02:56:47 +09:00
コミット e6d5e206f6
16個のファイルの変更605行の追加0行の削除

4
.gitignore vendored ノーマルファイル
ファイルの表示

@ -0,0 +1,4 @@
include/config.php
img/*
!img/.suwawa
!img/nowprinting.jpg

74
cart.php ノーマルファイル
ファイルの表示

@ -0,0 +1,74 @@
<?php
include('include/god.php');
$pagetitle = $eigo ? 'Cart' : 'カート';
?>
<?php require_once('include/header.php'); ?>
<?php
$items = [];
$total = 0;
$cart = array_filter(explode(',', $_COOKIE['cart']));
$sql = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
foreach ($cart as $c) {
if ($stmt = mysqli_prepare($sql, 'SELECT name, slug, language, author, price, filename FROM item WHERE slug = ?')) {
mysqli_stmt_bind_param($stmt, 's', $c);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $name, $slug, $language, $author, $price, $filename);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
$booklang = $language == 'en' ? ($eigo ? 'English' : '英語') : ($eigo ? 'Japanese' : '日本語');
if (!isset($items[$c])) $items[$c] = [
'name' => $name,
'slug' => $slug,
'language' => $booklang,
'author' => $author,
'price' => $price,
'filename' => $filename,
'count' => 1
];
else $items[$c]['count']++;
}
}
mysqli_close($sql);
?>
<table class="cart">
<tbody>
<?php foreach ($items as $v) { ?>
<tr>
<?php $fname = null !== $v['filename'] ? $v['filename'] : 'nowprinting.png'; ?>
<td><img src="/img/<?php echo $fname; ?>" alt="<?php echo $fname; ?>" style="width: 60px;" /></td>
<td style="width: 60%;">
<div class="cart-title"><?php echo $v['name']; ?></div>
<div class="cart-author"><?php echo $v['author']; ?></div>
<div class="cart-language"><?php echo $v['language']; ?></div>
</td>
<td>
</td>
<td>
<form action="/cart.php" method="post">
<input type="hidden" name="item" value="<?php echo $v['slug']; ?>" />
<input type="submit" name="cart-minus" value="-" /> <?php echo $v['count']; ?> <input type="submit" name="cart-plus" value="+" />
</form>
</td>
<td><div class="cart-price"><img src="/static/monero.png" alt="XMR" /> <?php echo $v['price']; ?></div></td>
</tr>
<?php $total += ($v['price'] * $v['count']); ?>
<?php } ?>
<tr class="cart-total">
<td colspan="4"><?php echo $eigo ? 'Total' : '合計'; ?></td>
<td><img src="/static/monero.png" alt="XMR" /> <?php echo $total; ?></td>
</tr>
</tbody>
</table>
<?php require_once('include/footer.php'); ?>

0
img/.suwawa ノーマルファイル
ファイルの表示

バイナリ
img/nowprinting.jpg ノーマルファイル

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

変更後

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

18
include/config.sample.php ノーマルファイル
ファイルの表示

@ -0,0 +1,18 @@
<?php
// アプリ
define('STORE_NAME', '本屋');
// データベース
define('DB_CONN', 'mysql');
define('DB_HOST', 'localhost');
define('DB_PORT', 3306);
define('DB_USER', '');
define('DB_PASS', '');
define('DB_NAME', '');
// メール
define('MAIL_ADDRESS', '');
define('MAIL_HOST', '');
define('MAIL_PASSWD', '');
define('MAIL_SMTPPORT', 587);
?>

8
include/footer.php ノーマルファイル
ファイルの表示

@ -0,0 +1,8 @@
</div>
</div>
<div class="footer">
<a href="https://git.076.ne.jp/TechnicalSuwako/honya"><img src="/static/git.png" alt="Git" /></a> |
<a href="https://076.moe">匿名事業社076</a>
</div>
</body>
</html>

47
include/god.php ノーマルファイル
ファイルの表示

@ -0,0 +1,47 @@
<?php
include('config.php');
include('helper.php');
if (isset($_POST['langchange'])) {
$lang = null !== $_COOKIE['lang'] && $_COOKIE['lang'] == 'en' ? 'ja' : 'en';
setcookie('lang', $lang);
unset($_POST['langchange']);
header('Location: /');
}
if (isset($_POST['addtocart'])) {
$cart = null !== $_COOKIE['cart'] ? $_COOKIE['cart'] : '';
$cart .= $_POST['item'].',';
setcookie('cart', $cart);
unset($_POST['item']);
unset($_POST['addtocart']);
header('Location: /cart.php');
}
if (isset($_POST['cart-minus'])) {
$cart = null !== $_COOKIE['cart'] ? $_COOKIE['cart'] : '';
$cart = array_filter(explode(',', $cart));
foreach ($cart as $k => $v) {
if ($v == $_POST['item']) { unset($cart[$k]); break; }
}
$cart = array_values($cart);
$cart = implode(',', $cart).',';
setcookie('cart', $cart);
unset($_POST['item']);
unset($_POST['cart-minus']);
header('Location: /cart.php');
}
if (isset($_POST['cart-plus'])) {
$cart = null !== $_COOKIE['cart'] ? $_COOKIE['cart'] : '';
$cart .= $_POST['item'].',';
setcookie('cart', $cart);
unset($_POST['item']);
unset($_POST['cart-minus']);
header('Location: /cart.php');
}
$eigo = null !== $_COOKIE['lang'] && $_COOKIE['lang'] == 'en';
$cart = null !== $_COOKIE['cart'] && $_COOKIE['cart'] != 0;
$styles = ['style'];
?>

43
include/header.php ノーマルファイル
ファイルの表示

@ -0,0 +1,43 @@
<!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 $eigo ? STORE_NAME_EN : STORE_NAME_JA; ?></title>
<?php
if (!empty($styles)) {
foreach ($styles as $s) {
?>
<link rel="stylesheet" type="text/css" href="/static/<?php echo $s; ?>.css" />
<?php
}
}
?>
</head>
<body>
<div class="jswarning" id="jswarning">
<?php echo $eigo ?
'Warning: JavaScript is ON. For safety and security reasons, please turn JavaScript OFF.' : '注意JavsScriptはONです。安全・安心の為、JavaScriptをOFFにしてお願い致します。'; ?>
</div>
<script type="text/javascript">
document.getElementById('jswarning').style.display = 'block';
</script>
<h1><?php echo $eigo ? STORE_NAME_EN : STORE_NAME_JA; ?></h1>
<div class="container">
<form method="post" action="/">
<input class="langchange" type="submit" name="langchange" value="<?php echo $eigo ? '日本語に戻る' : 'Switch to English'; ?>" />
</form>
<h2><?php echo $pagetitle; ?></h2>
<?php $countcart = count(array_filter(explode(',', $_COOKIE['cart']))); ?>
<div class="nav">
<ul>
<li><a href="/"><?php echo $eigo ? 'Home' : 'トップページ'; ?></a></li>
<li>
<a href="/cart.php">
<?php echo $eigo ? 'Cart' : 'カート'; ?>
</a>
<?php if ($countcart > 0) { ?><div class="cart-count"><?php echo $countcart < 99 ? $countcart : '99'; ?></div> <?php } ?>
</li>
</ul>
</div>
<div class="anarchy">

23
include/helper.php ノーマルファイル
ファイルの表示

@ -0,0 +1,23 @@
<?php
function getcookie (string $name): string {
return htmlspecialchars($_COOKIE[$name]);
}
function dd ($val) {
echo '<pre>';
var_dump($val);
echo '</pre>';
die();
}
function uuid () {
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand(0, 0xffff), mt_rand(0, 0xffff), // 32bitlow
mt_rand(0, 0xffff), // 16bitmid
mt_rand(0, 0x0fff) | 0x4000, // 16bithigh
mt_rand(0, 0x3fff) | 0x8000, // 16bit|8bithigh|low
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) // 48bitnode
);
}
?>

46
index.php ノーマルファイル
ファイルの表示

@ -0,0 +1,46 @@
<?php
include('include/god.php');
$pagetitle = $eigo ? 'Home' : 'トップページ';
$books = [];
$sql = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($stmt = mysqli_prepare($sql, 'SELECT name, slug, author, price, quantity, filename FROM item')) {
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $name, $slug, $author, $price, $quantity, $filename);
while (mysqli_stmt_fetch($stmt)) {
$books[] = [
'name' => $name,
'slug' => $slug,
'author' => $author,
'price' => $price,
'quantity' => $quantity,
'filename' => $filename
];
}
mysqli_stmt_close($stmt);
}
mysqli_close($sql);
?>
<?php require_once('include/header.php'); ?>
<?php
foreach ($books as $b) {
?>
<div class="item-card">
<?php $fname = null !== $b['filename'] ? $b['filename'] : 'nowprinting.png'; ?>
<a href="/item.php?slug=<?php echo $b['slug']; ?>"><img src="/img/<?php echo $fname; ?>" alt="<?php echo $fname; ?>" style="width: 200px;" /></a>
<h3><a href="/item.php?slug=<?php echo $b['slug']; ?>"><?php echo mb_strlen($b['name']) > 9 ? mb_substr($b['name'], 0, 9).'…' : $b['name']; ?></a></h3>
<p class="author"><?php echo $b['author']; ?></p>
<p class="price">XMR <?php echo $b['price']; ?> / <?php echo $eigo ? 'Quantity' : '商品数'; ?><?php echo $b['quantity']; ?></p>
</div>
<?php
}
?>
<?php require_once('include/footer.php'); ?>

51
item.php ノーマルファイル
ファイルの表示

@ -0,0 +1,51 @@
<?php
include('include/god.php');
$item = 'sasa';
$pagetitle = ($eigo ? 'Item: ' : '商品:').$item;
$styles[] = 'item';
$books = [];
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$sql = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($stmt = mysqli_prepare($sql, 'SELECT name, slug, language, author, description, price, filename, pagecount FROM item WHERE slug = ?')) {
mysqli_stmt_bind_param($stmt, 's', $_GET['slug']);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $name, $slug, $language, $author, $description, $price, $filename, $pagecount);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
}
$booklang = $language == 'en' ? ($eigo ? 'English' : '英語') : ($eigo ? 'Japanese' : '日本語');
mysqli_close($sql);
?>
<?php require_once('include/header.php'); ?>
<div class="item-container">
<?php $fname = null !== $filename ? $filename : 'nowprinting.png'; ?>
<div class="item-photo"><img src="/img/<?php echo $fname; ?>" alt="<?php echo $fname; ?>" /></div>
<div class="item-main">
<div class="item-header-container">
<div class="item-header-title"><?php echo $name; ?></div>
<div class="item-header-price"><img src="/static/monero.png" alt="XMR" /> <?php echo $price; ?></div>
</div>
<div class="item-author"><?php echo $author; ?></div>
<div class="item-language"><?php echo $booklang; ?></div>
<p><?php echo $description; ?></p>
<p><?php echo $pagecount.($eigo ? ' pages' : 'ページ'); ?></p>
<form method="post" action="/cart.php">
<input type="hidden" name="item" value="<?php echo $slug; ?>" />
<input type="submit" name="addtocart" value="<?php echo $eigo ? 'Add to cart' : 'カートに追加'; ?>" />
</form>
</div>
</div>
<?php require_once('include/footer.php'); ?>

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

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

変更後

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

62
static/item.css ノーマルファイル
ファイルの表示

@ -0,0 +1,62 @@
.item-container {
display: flex;
}
.item-photo {
width: 40%;
}
.item-photo > img {
width: 300px;
}
@media (max-width: 800px) {
.item-photo {
display: contents;
}
.item-photo > img {
width: 200px;
}
}
@media (max-width: 800px) {
.item-photo > img {
width: 100px;
height: 150px;
}
}
.item-main {
text-align: left;
width: 60%;
}
.item-header-container {
clear: both;
max-width: 800px;
display: flex;
}
.item-header-title, .item-header-price {
color: #abab00;
line-height: 1.2;
}
.item-header-title {
width: 80%;
font-size: xx-large;
}
.item-header-price {
font-size: x-large;
text-align: right;
}
.item-author, .item-language {
font-size: large;
}
.item-author {
color: #4d4d4d;
}

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

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

変更後

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

171
static/style.css ノーマルファイル
ファイルの表示

@ -0,0 +1,171 @@
body {
background: #232629;
color: #fcfcfc;
}
.clear {
clear: both;
}
.jswarning {
background-color: rgb(170, 170, 0);
color: rgb(252, 252, 252);
display: none;
padding: 10px;
z-index: 5000;
position: fixed;
top: 0px;
left: 0px;
right: 0px;
border: 4px #dde22d ridge;
}
h1, .footer {
text-align: center;
}
.footer {
padding-top: 16px;
}
hr {
border-color: #8800dd;
box-shadow: 2px 2px 10px #9900ff;
width: 100%;
max-width: 1700px;
}
a {
color: #ffeb3b;
}
.container {
width: 100%;
text-align: center;
}
.anarchy, .nav {
padding: 8px 0;
background-color: #16170b;
border: 1px #ffeb3b groove;
color: #d5de5c;
}
.anarchy {
max-width: 1400px;
margin: 0 auto;
}
.langchange {
background-color: #31363b;
color: #fcfcfc;
}
.item-card {
display: inline-block;
background: #4d4d4d;
border: 1px solid #fcfcfc;
border-radius: 10px;
padding: 8px;
margin: 0 8px;
width: 220px;
}
.item-card > a > img {
width: 200px;
height: 284px;
}
.nav {
text-align: left;
}
.nav ul {
padding: 0;
margin: .5em;
}
.nav li {
list-style: none;
background: #4d4d4d;
border-radius: 10px;
padding: .5em;
max-width: 7em;
}
.nav li:hover {
background: #bdc3c7;
color: #232629;
}
.cart {
text-align: left;
width: 100%;
background: #31363b;
margin: 8px auto;
border-radius: 10px;
}
.cart-total {
background: #eff0f1;
color: #232629;
}
.cart-count {
background: #da4453;
color: #fcfcfc;
border-radius: 50%;
width: 10px;
height: 10px;
padding: 4px;
text-align: center;
cursor: default;
display: inline-block;
font-size: xx-small;
}
@media (min-width: 1200px) and (max-width: 1399px) {
.anarchy {
max-width: 800px;
}
}
@media (min-width: 1400px) and (max-width: 1599px) {
.anarchy {
max-width: 1000px;
}
}
@media (min-width: 1600px) and (max-width: 1799px) {
.anarchy {
max-width: 1000px;
}
}
@media (min-width: 1200px) {
.nav {
float: left;
width: 175px;
position: fixed;
}
.nav li {
display: block;
text-align: center;
margin: .5em auto;
}
}
@media (max-width: 1199px) {
.nav {
text-align: center;
clear: both;
max-width: 850px;
margin: auto;
margin-bottom: 20px;
}
.nav li {
display: inline-block;
}
}

58
tbl ノーマルファイル
ファイルの表示

@ -0,0 +1,58 @@
DROP DATABASE IF EXISTS `honya_db`;
CREATE DATABASE `honya_db` CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
DROP TABLE IF EXISTS `item`;
CREATE TABLE `item` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`slug` varchar(100) NOT NULL,
`author` varchar(100),
`language` varchar(2) NOT NULL,
`description` text,
`price` float(10, 8) NOT NULL,
`quantity` int(10) NOT NULL,
`filename` varchar(100) NOT NULL,
`pagecount` int(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `item_img`;
CREATE TABLE `item_img` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`item_id` int(10) NOT NULL,
`filename` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `author`;
CREATE TABLE `author` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`slug` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `shipping`;
CREATE TABLE `shipping` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`slug` varchar(100) NOT NULL,
`zip` varchar(100) NOT NULL,
`housenr` varchar(100) NOT NULL,
`address1` varchar(100) NOT NULL,
`address2` varchar(100),
`country` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`shipped` int(1),
`shippedtime` int(10),
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`item_id` int(10) NOT NULL,
`shipping_id` int(10) NOT NULL,
`payment_id` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;