exec("CREATE TABLE IF NOT EXISTS accheck (
id INTEGER PRIMARY KEY AUTOINCREMENT,
line TEXT NOT NULL
)");
$filepath = __DIR__ . '/AcCheck.txt';
if (!file_exists($filepath)) {
echo "❌ Không tìm thấy file AcCheck.txt tại: $filepath
";
exit;
}
// 4. Đọc dữ liệu từ file
$lines = file($filepath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if (!$lines || count($lines) === 0) {
echo "❌ File AcCheck.txt rỗng hoặc không đọc được
";
exit;
}
$count = 0;
foreach ($lines as $line) {
$stmt = $db->prepare("INSERT INTO accheck (line) VALUES (:line)");
$stmt->bindValue(':line', trim($line), SQLITE3_TEXT);
$stmt->execute();
$count++;
}
echo "✅ Đã nhập $count dòng dữ liệu từ AcCheck.txt vào database.";
?>