このコミットが含まれているのは:
守矢諏訪子 2022-05-08 15:24:05 +09:00
コミット 9095635c68
6個のファイルの変更153行の追加0行の削除

ファイルの表示

@ -71,4 +71,8 @@
</tbody>
</table>
<form action="/shipping.php" method="post">
<input type="submit" name="toshipping" value="<?php echo $eigo ? 'To shipping information' : '配送情報へ' ?>" />
</form>
<?php require_once('include/footer.php'); ?>

94
shipping.php ノーマルファイル
ファイルの表示

@ -0,0 +1,94 @@
<?php
if (!isset($_POST['toshipping']) && !isset($_POST['topayment']) && !isset($_POST['complete'])) {
echo '禁止';
die();
}
include('include/god.php');
$pagetitle = $eigo ? 'Shipping' : '発送';
$item = $_GET['item'];
$step = 1;
$errcheck = [];
$err = '';
$tmpstore = [
'name' => null !== $_POST['name'] ? htmlspecialchars($_POST['name']) : '',
'zip' => null !== $_POST['zip'] ? htmlspecialchars($_POST['zip']) : '',
'prefecture' => null !== $_POST['prefecture'] ? htmlspecialchars($_POST['prefecture']) : '',
'city' => null !== $_POST['city'] ? htmlspecialchars($_POST['city']) : '',
'address1' => null !== $_POST['address1'] ? htmlspecialchars($_POST['address1']) : '',
'address2' => null !== $_POST['address2'] ? htmlspecialchars($_POST['address2']) : '',
'country' => null !== $_POST['country'] ? htmlspecialchars($_POST['country']) : '',
'email' => null !== $_POST['email'] ? htmlspecialchars($_POST['email']) : '',
];
if (isset($_POST['topayment'])) {
if (!isset($_POST['name']) || $_POST['name'] == '') $errcheck['name'] = $eigo ? 'Name' : 'お名前';
if (!isset($_POST['zip']) || $_POST['zip'] == '') $errcheck['zip'] = $eigo ? 'ZIP Code' : '郵便番号';
if (!isset($_POST['prefecture']) || $_POST['prefecture'] == '') $errcheck['prefecture'] = $eigo ? 'State/Province/Prefecture' : '都道府県';
if (!isset($_POST['city']) || $_POST['city'] == '') $errcheck['city'] = $eigo ? 'City/Town' : '市区町村';
if (!isset($_POST['address1']) || $_POST['address1'] == '') $errcheck['address1'] = $eigo ? 'Address 1' : '町名+番地';
if (!isset($_POST['country']) || $_POST['country'] == '') $errcheck['country'] = $eigo ? 'Country' : '国';
if (!isset($_POST['email']) || $_POST['email'] == '' || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) $errcheck['email'] = $eigo ? 'Email' : 'メール';
unset($_POST['topayment']);
if (count($errcheck) > 0) {
$err = $eigo ? 'Please check the following fields:' : '下記のフィールドをご確認下さい:';
echo $err .= '<br />';
foreach ($errcheck as $e) {
$err .= $e.'<br />';
}
}
else {
$step = 2;
}
}
else if (isset($_POST['complete'])) {
dd($_POST);
// TODO
// ・QRコード及びアドレスの表示
// ・支払いの確認
// ・支払いIDと配送情報をDBに入って、メールの送信
// ・管理者は毎日午後5時(日本時間)まで手動で確認すると、翌日午前12時(日本時間)配送予定ってメッセージの表示
// ・郵便局で配送すると、午後3時(日本時間)までメールで郵便追跡番号を送る
// ・日間後、配送情報は自動でDBから削除される(crontab)
}
$total = 0;
$cart = array_filter(explode(',', getcookie('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 price FROM item WHERE slug = ?')) {
mysqli_stmt_bind_param($stmt, 's', $c);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $price);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
if (!isset($items[$c])) $items[$c] = [
'price' => $price,
'count' => 1
];
else $items[$c]['count']++;
}
}
mysqli_close($sql);
if ($err != '') {
?>
<div class="error"><?php echo $err; ?></div>
<?php
}
require_once('include/header.php');
// TODO: 合計の表示
include('shipping/'.$step.'.php');
require_once('include/footer.php');
?>

1
shipping/0.php ノーマルファイル
ファイルの表示

@ -0,0 +1 @@
.

38
shipping/1.php ノーマルファイル
ファイルの表示

@ -0,0 +1,38 @@
<form method="post" action="/shipping.php">
<table class="address-form" border="0">
<tr>
<td class="required"><?php echo $eigo ? 'Name (nickname OK)' : 'お名前(異名OK)'; ?></td>
<td><input type="text" name="name" placeholder="<?php echo $eigo ? 'Anonymous' : 'アノニマス'; ?>" value="<?php echo $tmpstore['name'] ?>" /></td>
</tr>
<tr>
<td class="required"><?php echo $eigo ? 'ZIP Code' : '郵便番号'; ?></td>
<td><input type="text" name="zip" placeholder="100-0001" value="<?php echo $tmpstore['zip'] ?>" /></td>
</tr>
<tr>
<td class="required"><?php echo $eigo ? 'State/Province/Prefecture' : '都道府県'; ?></td>
<td><input type="text" name="prefecture" placeholder="<?php echo $eigo ? 'Tokyo' : '東京都'; ?>" value="<?php echo $tmpstore['prefecture'] ?>" /></td>
</tr>
<tr>
<td class="required"><?php echo $eigo ? 'City/Town' : '市区町村'; ?></td>
<td><input type="text" name="city" placeholder="<?php echo $eigo ? 'Shibuya' : '渋谷区'; ?>" value="<?php echo $tmpstore['city'] ?>" /></td>
</tr>
<tr>
<td class="required"><?php echo $eigo ? 'Address 1 (street + number)' : '町名+番地'; ?></td>
<td><input type="text" name="address1" placeholder="<?php echo $eigo ? 'Ebisu 1-2-3' : '恵比寿丁目2-3'; ?>" value="<?php echo $tmpstore['address1'] ?>" /></td>
</tr>
<tr>
<td><?php echo $eigo ? 'Address 2 (optional)' : 'マンション(任意)'; ?></td>
<td><input type="text" name="address2" placeholder="<?php echo $eigo ? 'Moriya Shrine 200F' : '守谷神社 200階'; ?>" value="<?php echo $tmpstore['address2'] ?>" /></td>
</tr>
<tr>
<td class="required"><?php echo $eigo ? 'Country' : '国'; ?></td>
<td><input type="text" name="country" placeholder="<?php echo $eigo ? 'Japan' : '日本'; ?>" value="<?php echo $tmpstore['country'] ?>" /></td>
</tr>
<tr>
<td class="required"><?php echo $eigo ? 'Email' : 'メール'; ?></td>
<td><input type="text" name="email" placeholder="weareanonymous@weare.legion" value="<?php echo $tmpstore['email'] ?>" /></td>
</tr>
</table>
<input type="submit" class="nextbutton" name="topayment" value="支払いへ" />
</form>

4
shipping/2.php ノーマルファイル
ファイルの表示

@ -0,0 +1,4 @@
<?php
$address = 'monero:'.MONERO_ADDRESS.'?tx_amount='.$sum;
?>
<img src="" alt="<?php echo $address; ?>" />

ファイルの表示

@ -169,3 +169,15 @@ a {
display: inline-block;
}
}
.address-form > tbody > tr > td > input {
width: 220px;
}
.error {
background-color: #da4453;
margin-top: 40px;
padding: 10px;
z-index: 5000;
border: 4px #ff1212 ridge;
}