diff --git a/config.sample.php b/config.sample.php index 0858e5d..678ca77 100644 --- a/config.sample.php +++ b/config.sample.php @@ -1,19 +1,21 @@ diff --git a/helper.php b/helper.php index a992f97..a6c2bc9 100644 --- a/helper.php +++ b/helper.php @@ -1,13 +1,13 @@ diff --git a/helper/cookie.php b/helper/cookie.php index d65cf03..1a1a40e 100644 --- a/helper/cookie.php +++ b/helper/cookie.php @@ -1,8 +1,7 @@ ['var1', 'var2'...] - * insert|update|where => ['key1' => 'value1', 'key2' => 'value2'...] - * order => ['var', 'asc'|'desc'] + * select => ["var1", "var2"...] + * insert|update|where => ["key1" => "value1", "key2" => "value2"...] + * order => ["var", "asc"|"desc"] * limit => int * */ - function lolidb (string $table, array $val, string $mode='select'): array|bool { + function lolidb (string $table, array $val, string $mode="select"): array|bool { // モードは違う場合、やめる。If the mode is wrong, stop. - if ($mode != 'select' && $mode != 'one' && $mode != 'insert' && $mode != 'update' && $mode != 'delete') { + if ($mode != "select" && $mode != "one" && $mode != "insert" && $mode != "update" && $mode != "delete") { dd("モードは「select」、「one」、「insert」、「update」、「delete」です。\nMode should be \"select\", \"one\", \"insert\", \"update\", or \"delete\"."); return false; } // 順のチェック。Check order. - if (isset($val['order'])) { + if (isset($val["order"])) { // selectかoneじゃない場合。If not select or one. - if ($mode !== 'select' || $mode !== 'one') { + if ($mode !== "select" || $mode !== "one") { dd("「order」は「select」又は「one」のみで使えます。\n\"order\" can only be used with \"select\" or \"one\"."); return false; } // 複数の場合。If multiple. - if (count($val['order'] > 1)) { + if (count($val["order"] > 1)) { dd("複数「order」は未対応です。\nMultiple \"order\" is not yet supported."); return false; } - // ascかdescかどうか。Whether it's asc or desc. - foreach ($val['order'] as $k => $v) { - if ($v !== 'asc' && $v !== 'desc') { + // ascかdescかどうか。Whether it"s asc or desc. + foreach ($val["order"] as $k => $v) { + if ($v !== "asc" && $v !== "desc") { dd("「order」は「asc」又は「desc」です。\n\"order\" should be \"asc\" or \"desc\"."); return false; } @@ -39,28 +39,28 @@ } // 限界のチェック。Check limit. - if (($mode === 'select' || $mode === 'one') && isset($val['limit'])) { + if (($mode === "select" || $mode === "one") && isset($val["limit"])) { // oneの場合。If one. - if ($mode === 'one') { + if ($mode === "one") { dd("「one」の場合、「limit」はいつでも「1」です。「limit」は1以上は必要の場合、「select」を使って下さい。\nIn case of \"one\", \"limit\" is always \"1\". If \"limit\" needs to be more than \"1\", please use \"select\"."); return false; } // selectじゃない場合。If not select. - else if ($mode !== 'select') { + else if ($mode !== "select") { dd("「insert」、「update」及び「delete」で、「limit」を使えません。\n\"limit\" cannot be used with \"insert\", \"update\", and \"delete\"."); return false; } } // insertの場合。In case of insert. - if ($mode === 'insert' && !isset($val['insert'])) { + if ($mode === "insert" && !isset($val["insert"])) { dd("「insert」モードの場合、「insert」値は必須です。\nIn case of \"insert\" mode, \"insert\" value is necessary."); return false; } // updateの場合。In case of update. - if ($mode === 'update' && !isset($val['update'])) { + if ($mode === "update" && !isset($val["update"])) { dd("「update」モードの場合、「update」値は必須です。\nIn case of \"update\" mode, \"update\" value is necessary."); return false; } @@ -69,94 +69,94 @@ $mysqli = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_TABLE); $result = null; - if ($mode == 'select' || $mode == 'one') { + if ($mode == "select" || $mode == "one") { // select値がなければ、全部を選択する。If there is no select value, select everything. - if (!isset($val['select'])) { - $val['select'] = ['*']; + if (!isset($val["select"])) { + $val["select"] = ["*"]; } - $query = 'SELECT '.$val['select'].' FROM '.$table; + $query = "SELECT ".$val["select"]." FROM ".$table; - if (isset($val['where'])) { - $query .= ' WHERE '; - foreach ($val['where'] as $k => $v) { - $query .= $k.' = '.$v; - if ($k !== array_key_last($val['where'])) $query .= ' AND '; + if (isset($val["where"])) { + $query .= " WHERE "; + foreach ($val["where"] as $k => $v) { + $query .= $k." = ".$v; + if ($k !== array_key_last($val["where"])) $query .= " AND "; } } - if (isset($val['order'])) { - $query .= ' ORDER BY '; - foreach ($val['order'] as $k => $v) { + if (isset($val["order"])) { + $query .= " ORDER BY "; + foreach ($val["order"] as $k => $v) { $query .= $k; - $query .= ' '.strtoupper($v); + $query .= " ".strtoupper($v); } } - if ($mode == 'one') { - $query .= ' LIMIT 1'; + if ($mode == "one") { + $query .= " LIMIT 1"; } else { - if (isset($val['limit'])) { - $query .= ' LIMIT '.(int)$val['limit']; + if (isset($val["limit"])) { + $query .= " LIMIT ".(int)$val["limit"]; } } - $result = mysqli_query($mysqli, $query.';'); + $result = mysqli_query($mysqli, $query.";"); $row = mysqli_fetch_assoc($result); } else { - if ($mode == 'insert') { - $query .= 'INSERT INTO '.$table.' ('; - foreach ($val['insert'] as $k => $v) { + if ($mode == "insert") { + $query .= "INSERT INTO ".$table." ("; + foreach ($val["insert"] as $k => $v) { $query .= $k; - if ($k !== array_key_last($val['insert'])) { - $query .= ', '; + if ($k !== array_key_last($val["insert"])) { + $query .= ", "; } } - $query .= ') VALUES ('; - foreach ($val['insert'] as $k => $v) { + $query .= ") VALUES ("; + foreach ($val["insert"] as $k => $v) { $query .= $v; - if ($k !== array_key_last($val['insert'])) { - $query .= ', '; + if ($k !== array_key_last($val["insert"])) { + $query .= ", "; } } - $query .= ')'; + $query .= ")"; } - else if ($mode == 'update') { - $query .= 'UPDATE '.$table.' SET '; - foreach ($val['update'] as $k => $v) { - $query .= $k.' = '.$v; - if ($k !== array_key_last($val['update'])) { - $query .= ', '; + else if ($mode == "update") { + $query .= "UPDATE ".$table." SET "; + foreach ($val["update"] as $k => $v) { + $query .= $k." = ".$v; + if ($k !== array_key_last($val["update"])) { + $query .= ", "; } } - if (isset($val['where'])) { - $query .= ' WHERE '; - foreach ($val['where'] as $k => $v) { - $query .= $k.' = '.$v; - if ($k !== array_key_last($val['where'])) { - $query .= ' AND '; + if (isset($val["where"])) { + $query .= " WHERE "; + foreach ($val["where"] as $k => $v) { + $query .= $k." = ".$v; + if ($k !== array_key_last($val["where"])) { + $query .= " AND "; } } } } - else if ($mode == 'delete') { - $query .= 'DELETE FROM '.$table; + else if ($mode == "delete") { + $query .= "DELETE FROM ".$table; - if (isset($val['where'])) { - $query .= ' WHERE '; - foreach ($val['where'] as $k => $v) { - $query .= $k.' = '.$v; - if ($k !== array_key_last($val['where'])) { - $query .= ' AND '; + if (isset($val["where"])) { + $query .= " WHERE "; + foreach ($val["where"] as $k => $v) { + $query .= $k." = ".$v; + if ($k !== array_key_last($val["where"])) { + $query .= " AND "; } } } } - $stmt = mysqli_prepare($mysqli, $query.';'); + $stmt = mysqli_prepare($mysqli, $query.";"); } return $row; diff --git a/helper/debug.php b/helper/debug.php index c235f9e..1fd9998 100644 --- a/helper/debug.php +++ b/helper/debug.php @@ -1,22 +1,23 @@ '; + echo ""; + echo "
";
     var_dump($val);
-    echo '
'; + echo ""; die(); } - function lolilog (string $val, string $mode='info'): bool { - if (!$file = fopen('./lolilog', 'a+')) { - dd('lolilogファイルを開けられません。'); + function lolilog (string $val, string $mode="info"): bool { + if (!$file = fopen("./lolilog", "a+")) { + dd("lolilogファイルを開けられません。"); return false; } $time = time(); - $logtext = '['.date('Y-m-d H:i:s T', $time).' ('.$time.') - '.mb_strtoupper($mode)."]\n".$val."\n\n"; + $logtext = "[".date("Y-m-d H:i:s T", $time)." (".$time.") - ".mb_strtoupper($mode)."]\n".$val."\n\n"; if (fwrite($file, $logtext) === false) { - dd('lolilogファイルに書き出しに失敗しました。'); + dd("lolilogファイルに書き出しに失敗しました。"); return false; } diff --git a/helper/hash.php b/helper/hash.php index 1a80d93..b1ef201 100644 --- a/helper/hash.php +++ b/helper/hash.php @@ -1,5 +1,5 @@ $cost]); + password_hash("kero", PASSWORD_ARGON2ID, ["cost" => $cost]); $end = microtime(true); } while (($end - $start) < $millisec); - $addpepper = hash_hmac('sha256', $password, PASSWD_PEPPER); + $addpepper = hash_hmac("sha256", $password, PASSWD_PEPPER); $addmd5 = md5($addpepper); - return password_hash($addmd5, PASSWORD_ARGON2ID, ['cost' => $cost]); + return password_hash($addmd5, PASSWORD_ARGON2ID, ["cost" => $cost]); } function verifypasswd (string $raw, string $crypt): bool { - $addpepper = hash_hmac('sha256', $raw, PASSWD_PEPPER); + $addpepper = hash_hmac("sha256", $raw, PASSWD_PEPPER); $addmd5 = md5($addpepper); return password_verify($addmd5, $crypt); diff --git a/helper/php8compat.php b/helper/php8compat.php index 938c0e1..f46165b 100644 --- a/helper/php8compat.php +++ b/helper/php8compat.php @@ -1,31 +1,31 @@ htmlspecialchars($name)]; + return ["post" => htmlspecialchars($name)]; } else if (isset($_GET[$name])) { - return ['get' => htmlspecialchars($name)]; + return ["get" => htmlspecialchars($name)]; } else if (isset($_REQUEST[$name])) { - return ['request' => htmlspecialchars($name)]; + return ["request" => htmlspecialchars($name)]; } - return ['error' => '']; + return ["error" => ""]; } function request_all (): array { $res = []; if (!empty($_POST)) { - $res['post'] = []; - foreach ($_POST as $k => $v) $res['post'][$k] = htmlspecialchars($v); + $res["post"] = []; + foreach ($_POST as $k => $v) $res["post"][$k] = htmlspecialchars($v); } if (!empty($_GET)) { - $res['get'] = []; - foreach ($_GET as $k => $v) $res['get'][$k] = htmlspecialchars($v); + $res["get"] = []; + foreach ($_GET as $k => $v) $res["get"][$k] = htmlspecialchars($v); } if (!empty($_REQUEST)) { - $res['request'] = []; - foreach ($_REQUEST as $k => $v) $res['request'][$k] = htmlspecialchars($v); + $res["request"] = []; + foreach ($_REQUEST as $k => $v) $res["request"][$k] = htmlspecialchars($v); } return $res; diff --git a/helper/upload.php b/helper/upload.php index d29886a..fd18a8b 100644 --- a/helper/upload.php +++ b/helper/upload.php @@ -1,55 +1,55 @@ = ($bit * $bit * $bit * $bit * $bit)) { //dd(5); $size = $byte / ($bit * $bit * $bit * $bit * $bit); - $res = $iso ? 'TiB' : 'TB'; + $res = $iso ? "TiB" : "TB"; } else if ($byte >= ($bit * $bit * $bit * $bit)) { //dd(4); $size = $byte / ($bit * $bit * $bit * $bit); - $res = $iso ? 'TiB' : 'TB'; + $res = $iso ? "TiB" : "TB"; } else if ($byte >= ($bit * $bit * $bit)) { //dd(3); $size = $byte / ($bit * $bit * $bit); - $res = $iso ? 'GiB' : 'GB'; + $res = $iso ? "GiB" : "GB"; } else if ($byte >= ($bit * $bit)) { //dd(2); $size = $byte / ($bit * $bit); - $res = $iso ? 'MiB' : 'MB'; + $res = $iso ? "MiB" : "MB"; } else if ($byte >= $bit) { //dd(1); $size = $byte / $bit; - $res = $iso ? 'KiB' : 'kB'; + $res = $iso ? "KiB" : "kB"; } //dd($size); - return number_format($size, 2).' '.$res; + return number_format($size, 2)." ".$res; } function getmimetype (string $fname): string|null { $i = 0; foreach ($_FILES as $v) { - if ($fname == $v['name'][$i]) { - return $v['type'][$i]; + if ($fname == $v["name"][$i]) { + return $v["type"][$i]; } $i++; @@ -63,20 +63,20 @@ $i = 0; foreach ($_FILES as $file) { - if ($file['error'][$i] != 0) { - $err = ''; - switch ($file['error'][$i]) { - case 1: $err = 'php.iniでの「upload_max_filesize」値が超えています。ファイルサイズ:'.humanreadablesize($file['size'][$i]); break; - case 2: $err = 'HTMLフォームの「MAX_FILE_SIZE」値が超えています。ファイルサイズ:'.humanreadablesize($file['size'][$i]); break; - case 3: $err = 'ファイルの部分の失敗です。'; break; - case 4: $err = 'ファイルをアップロード出来ません。'; break; - case 5: $err = '不明'; break; - case 6: $err = '仮フォルダがありません。'; break; - case 7: $err = 'uploadフォルダに書き込めません。'; break; - case 8: $err = '拡張子がありません。'; break; + if ($file["error"][$i] != 0) { + $err = ""; + switch ($file["error"][$i]) { + case 1: $err = "php.iniでの「upload_max_filesize」値が超えています。ファイルサイズ:".humanreadablesize($file["size"][$i]); break; + case 2: $err = "HTMLフォームの「MAX_FILE_SIZE」値が超えています。ファイルサイズ:".humanreadablesize($file["size"][$i]); break; + case 3: $err = "ファイルの部分の失敗です。"; break; + case 4: $err = "ファイルをアップロード出来ません。"; break; + case 5: $err = "不明"; break; + case 6: $err = "仮フォルダがありません。"; break; + case 7: $err = "uploadフォルダに書き込めません。"; break; + case 8: $err = "拡張子がありません。"; break; } - $res[$file['name'][$i]] = $err; + $res[$file["name"][$i]] = $err; } $i++; @@ -86,18 +86,18 @@ } function loliupload (array $files): bool { - $dir = __DIR__.'/../public/static/upload/'; - $fname = ''; + $dir = __DIR__."/../public/static/upload/"; + $fname = ""; if (!file_exists($dir)) { mkdir($dir, 0777); } do { - $fname = uuid().'.'.fileextension($files['name'][0]); + $fname = uuid().".".fileextension($files["name"][0]); } while (file_exists($dir.$fname)); - if (move_uploaded_file($files['tmp_name'][0], $dir.$fname)) { + if (move_uploaded_file($files["tmp_name"][0], $dir.$fname)) { return true; } diff --git a/helper/uuid.php b/helper/uuid.php index dc222b0..39985e8 100644 --- a/helper/uuid.php +++ b/helper/uuid.php @@ -1,7 +1,7 @@ + + + + + - - - + " /> + + + + - - - - <?php echo $sitename.': '.$title; ?> + " /> + + + + <?= $sitename.": ".$title ?> + diff --git a/src/404/index.php b/src/404/index.php index 42aa00c..b53c139 100644 --- a/src/404/index.php +++ b/src/404/index.php @@ -1,4 +1,4 @@ diff --git a/src/about/index.php b/src/about/index.php index 1673e49..1dd3438 100644 --- a/src/about/index.php +++ b/src/about/index.php @@ -1,6 +1,6 @@ diff --git a/src/config.php b/src/config.php index a98bf10..07f8cad 100644 --- a/src/config.php +++ b/src/config.php @@ -1,7 +1,7 @@ diff --git a/src/cookie/index.php b/src/cookie/index.php index bed3a73..26a3645 100644 --- a/src/cookie/index.php +++ b/src/cookie/index.php @@ -1,15 +1,15 @@ time()+60*60*2, 'path' => '/cookie', 'httponly' => true]); - //setrawcookie('lolicon_cookie', $_POST['lolicon_cookie'], ['expires' => time()+60*60*2, 'path' => '/cookie', 'httponly' => true]); - header('Location: /cookie', 301); + setcookie("lolicon_cookie", $_POST["lolicon_cookie"], ["expires" => time()+60*60*2, "path" => "/cookie", "httponly" => true]); + //setrawcookie("lolicon_cookie", $_POST["lolicon_cookie"], ["expires" => time()+60*60*2, "path" => "/cookie", "httponly" => true]); + header("Location: /cookie", 301); } - $title = 'クッキー'; // 必須・Requirement - $sitedesc = 'クッキーの例え'; // config.phpの文字の交換・Change character of config.php - $siteurl .= '/cookie'; // config.phpの文字に追加・Add to character of config.php - $childview = '../ui/cookie/index.php'; // 必須・Requirement - $mycookie = getcookie('lolicon_cookie'); - //$mycookie = getrawcookie('lolicon_cookie'); + $title = "クッキー"; // 必須・Requirement + $sitedesc = "クッキーの例え"; // config.phpの文字の交換・Change character of config.php + $siteurl .= "/cookie"; // config.phpの文字に追加・Add to character of config.php + $childview = "../ui/cookie/index.php"; // 必須・Requirement + $mycookie = getcookie("lolicon_cookie"); + //$mycookie = getrawcookie("lolicon_cookie"); ?> diff --git a/src/curl/index.php b/src/curl/index.php index bd85de7..08362fa 100644 --- a/src/curl/index.php +++ b/src/curl/index.php @@ -1,9 +1,9 @@ diff --git a/src/hash/index.php b/src/hash/index.php index d78daa2..1c6abb8 100644 --- a/src/hash/index.php +++ b/src/hash/index.php @@ -1,9 +1,9 @@ diff --git a/src/home/index.php b/src/home/index.php index 0d3d73b..0b887b8 100644 --- a/src/home/index.php +++ b/src/home/index.php @@ -1,6 +1,6 @@ diff --git a/src/upload/index.php b/src/upload/index.php index 09c8ad9..5d487f9 100644 --- a/src/upload/index.php +++ b/src/upload/index.php @@ -1,16 +1,16 @@ diff --git a/ui/hash/index.php b/ui/hash/index.php index 1ce488d..942681a 100644 --- a/ui/hash/index.php +++ b/ui/hash/index.php @@ -6,8 +6,8 @@ Please enter "mysecurepassword".
'; - echo 'ポスワードは「mysecurepassword」ですか?:'.(verifypasswd('mysecurepassword', $setpasswd) ? 'はい' : 'いいえ'); + if (isset($_POST["password"])) { + echo "創作したパスワード(plaintext→sha256+pepper→md5→Argon2id): ".$setpasswd."
"; + echo "ポスワードは「mysecurepassword」ですか?:".(verifypasswd("mysecurepassword", $setpasswd) ? "はい" : "いいえ"); } ?> diff --git a/ui/home/index.php b/ui/home/index.php index 3572eb4..df035a6 100644 --- a/ui/home/index.php +++ b/ui/home/index.php @@ -2,7 +2,7 @@

例の一覧