0,
'path' => '/',
'domain' => '',
'secure' => true,
'httponly' => true,
'samesite' => 'Lax'
]);
session_start();
session_regenerate_id(true);
try {
$option = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
);
$pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option);
} catch(PDOException $e) {
// 接続エラーのときエラー内容を取得する
$error_message[] = $e->getMessage();
}
if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) {
$passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid");
$passQuery->bindValue(':userid', safetext($_SESSION['userid']));
$passQuery->execute();
$res = $passQuery->fetch();
if(empty($res["userid"])){
header("Location: ../login.php");
exit;
}elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){
// セッションに値をセット
$userid = safetext($res['userid']); // セッションに格納されている値をそのままセット
$username = safetext($res['username']); // セッションに格納されている値をそのままセット
$loginid = safetext($res["loginid"]);
$role = safetext($res["role"]);
$sacinfo = safetext($res["sacinfo"]);
$myblocklist = safetext($res["blocklist"]);
$myfollowlist = safetext($res["follow"]);
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid, [
'expires' => time() + 60 * 60 * 24 * 28,
'path' => '/',
'samesite' => 'lax',
'secure' => true,
'httponly' => true,
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 28,
'path' => '/',
'samesite' => 'lax',
'secure' => true,
'httponly' => true,
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 28,
'path' => '/',
'samesite' => 'lax',
'secure' => true,
'httponly' => true,
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 28,
'path' => '/',
'samesite' => 'lax',
'secure' => true,
'httponly' => true,
]);
}else{
header("Location: ../login.php");
exit;
}
} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) {
$passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid");
$passQuery->bindValue(':userid', safetext($_COOKIE['userid']));
$passQuery->execute();
$res = $passQuery->fetch();
if(empty($res["userid"])){
header("Location: ../login.php");
exit;
}elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){
// セッションに値をセット
$userid = safetext($res['userid']); // クッキーから取得した値をセット
$username = safetext($res['username']); // クッキーから取得した値をセット
$loginid = safetext($res["loginid"]);
$role = safetext($res["role"]);
$sacinfo = safetext($res["sacinfo"]);
$myblocklist = safetext($res["blocklist"]);
$myfollowlist = safetext($res["follow"]);
$_SESSION['admin_login'] = true;
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['loginid'] = $res["loginid"];
setcookie('userid', $userid,[
'expires' => time() + 60 * 60 * 24 * 28,
'path' => '/',
'samesite' => 'lax',
'secure' => true,
'httponly' => true,
]);
setcookie('username', $username,[
'expires' => time() + 60 * 60 * 24 * 28,
'path' => '/',
'samesite' => 'lax',
'secure' => true,
'httponly' => true,
]);
setcookie('loginid', $res["loginid"],[
'expires' => time() + 60 * 60 * 24 * 28,
'path' => '/',
'samesite' => 'lax',
'secure' => true,
'httponly' => true,
]);
setcookie('admin_login', true,[
'expires' => time() + 60 * 60 * 24 * 28,
'path' => '/',
'samesite' => 'lax',
'secure' => true,
'httponly' => true,
]);
}else{
header("Location: ../login.php");
exit;
}
} else {
// ログインが許可されていない場合、ログインページにリダイレクト
header("Location: ../login.php");
exit;
}
if(empty($userid)){
header("Location: ../login.php");
exit;
}
if(empty($username)){
header("Location: ../login.php");
exit;
}
if(!($res["admin"] === "yes")){
header("Location: ../login.php");
exit;
}
$notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'");
$notiQuery->bindValue(':userid', $userid);
$notiQuery->execute();
$notiData = $notiQuery->fetch(PDO::FETCH_ASSOC);
$notificationcount = $notiData['notification_count'];
if(!empty($pdo)){
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
//User
$result = $mysqli->query("SELECT userid FROM account");
$count1 = $result->num_rows;
//ueuse
$result2 = $mysqli->query("SELECT uniqid FROM ueuse");
$count2 = $result2->num_rows;
//emoji
$result3 = $mysqli->query("SELECT sysid FROM emoji");
$count3 = $result3->num_rows;
//bot
$result4 = $mysqli->query("SELECT userid FROM account WHERE sacinfo = 'bot'");
$count4 = $result4->num_rows;
//DB_Data
try {
$dbname = DB_NAME;
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// データベース内の全テーブル名を取得
$query = "SELECT table_name FROM information_schema.tables WHERE table_schema = :database";
$stmt = $pdo->prepare($query);
$stmt->bindParam(':database', $dbname);
$stmt->execute();
$tables = $stmt->fetchAll(PDO::FETCH_COLUMN);
// 各テーブルの正確な行数を取得
$db_results = [];
foreach ($tables as $table) {
// 行数を取得
$rowQuery = "SELECT COUNT(*) as count FROM `$table`";
$rowStmt = $pdo->query($rowQuery);
$rowCount = (int)$rowStmt->fetchColumn();
// テーブルサイズを取得
$sizeQuery = "
SELECT
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS `Size`
FROM
information_schema.TABLES
WHERE
table_schema = :database AND table_name = :table;
";
$sizeStmt = $pdo->prepare($sizeQuery);
$sizeStmt->execute([':database' => $dbname, ':table' => $table]);
$size = (float)$sizeStmt->fetchColumn();
// 結果を格納
$db_results[] = [
'Table' => $table,
'Rows' => $rowCount,
'Size' => $size,
];
}
// サイズで並び替え
usort($db_results, function ($a, $b) {
return $b['Size'] <=> $a['Size'];
});
// 行数を最大桁数に揃えて0埋め
$maxRows = max(array_column($db_results, 'Rows'));
foreach ($db_results as &$table) {
$table['Rows'] = str_pad($table['Rows'], strlen($maxRows), '0', STR_PAD_LEFT);
}
unset($table); // 参照を解除
} catch (PDOException $e) {
$db_results = null;
}
}
if(function_exists("disk_free_space")){
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$disk = true;
$diskFree = (int) disk_free_space('C:') / 1024 / 1024;
$diskTotal = (int) disk_total_space('C:') / 1024 / 1024;
$diskUmari = $diskTotal - $diskFree;
if ($diskFree / $diskTotal < 0.1) {
$disk_over90p = true;
}else{
$disk_over90p = false;
}
$loadAve = null;
} else {
$disk = true;
$diskFree = (int) disk_free_space('/') / 1024 / 1024;
$diskTotal = (int) disk_total_space('/') / 1024 / 1024;
$diskUmari = $diskTotal - $diskFree;
if ($diskFree / $diskTotal < 0.1) {
$disk_over90p = true;
}else{
$disk_over90p = false;
}
if(function_exists("sys_getloadavg")){
$loadAve = sys_getloadavg()[0];
}else{
$loadAve = null;
}
}
}else{
$disk = false;
$diskFree = 5000;
$diskUmari = 5000;
$diskTotal = 10000;
$disk_over90p = false;
if(function_exists("sys_getloadavg")){
$loadAve = sys_getloadavg()[0];
}else{
$loadAve = null;
}
}
require('../logout/logout.php');
?>
サーバー概要 -