104 行
2.4 KiB
PHP
104 行
2.4 KiB
PHP
|
<?php
|
||
|
require_once('config.php');
|
||
|
|
||
|
// PHP8を実行していない場合
|
||
|
if (!function_exists('str_starts_with')) {
|
||
|
function str_starts_with (string $haystack, string $needle): bool {
|
||
|
return (string)$needle !== '' && strncmp($haystack, $needle, strlen($needle)) === 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!function_exists('str_ends_with')) {
|
||
|
function str_ends_with (string $haystack, string $needle): bool {
|
||
|
$needle_len = strlen($needle);
|
||
|
return ($needle_len === 0 || 0 === substr_compare($haystack, $needle, - $needle_len));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!function_exists('str_contains')) {
|
||
|
function str_contains (string $haystack, string $needle): bool {
|
||
|
return $needle !== '' && mb_strpos($haystack, $needle) !== false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!function_exists('array_key_first')) {
|
||
|
function array_key_first (array $array): int|string|null {
|
||
|
if (!is_array($array) || empty($array)) return NULL;
|
||
|
return array_keys($array)[0];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!function_exists('array_key_last')) {
|
||
|
function array_key_last (array $array): int|string|null {
|
||
|
if (!is_array($array) || empty($array)) return NULL;
|
||
|
return array_keys($array)[count($array)-1];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// デバッガー
|
||
|
// Debugger
|
||
|
function dd ($val) {
|
||
|
echo '<pre>';
|
||
|
var_dump($val);
|
||
|
echo '</pre>';
|
||
|
die();
|
||
|
}
|
||
|
|
||
|
// データベースエンジン
|
||
|
// Database engine
|
||
|
require_once('helper/db.php');
|
||
|
|
||
|
// リクエスト
|
||
|
// Request
|
||
|
function request (string $name): array {
|
||
|
if (isset($_POST[$name])) {
|
||
|
return ['post' => htmlspecialchars($name)];
|
||
|
}
|
||
|
else if (isset($_GET[$name])) {
|
||
|
return ['get' => htmlspecialchars($name)];
|
||
|
}
|
||
|
else if (isset($_REQUEST[$name])) {
|
||
|
return ['request' => htmlspecialchars($name)];
|
||
|
}
|
||
|
|
||
|
return ['error' => ''];
|
||
|
}
|
||
|
|
||
|
function request_all (): array {
|
||
|
$res = [];
|
||
|
if (!empty($_POST)) {
|
||
|
$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);
|
||
|
}
|
||
|
if (!empty($_REQUEST)) {
|
||
|
$res['request'] = [];
|
||
|
foreach ($_REQUEST as $k => $v) $res['request'][$k] = htmlspecialchars($v);
|
||
|
}
|
||
|
|
||
|
return $res;
|
||
|
}
|
||
|
|
||
|
// ファイルアップロード
|
||
|
function loliupload () {}
|
||
|
|
||
|
// CURL
|
||
|
function lolicurl () {}
|
||
|
|
||
|
// クッキー
|
||
|
function getcookie (string $name): array { return htmlspecialchars($_COOKIE[$name]); }
|
||
|
|
||
|
function getrawcookie (string $name): array { return $_COOKIE[$name]; }
|
||
|
|
||
|
// メール
|
||
|
function lolimail () {}
|
||
|
|
||
|
// セッション
|
||
|
|
||
|
// ハッシュ
|
||
|
|
||
|
?>
|