Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function checkAndUpdateStatus() {
- // SQLite database file path
- $dbPath = 'alarm.db';
- $botToken = 'ISI TOKEN';
- // Connect to SQLite database
- $db = new SQLite3($dbPath);
- if (!$db) {
- die("Error connecting to the database.");
- }
- // Get the current Unix timestamp
- $currentTimestamp = time();
- // Prepare the SQL statement to fetch records where timestamp is less than current time and status is 0
- $stmt = $db->prepare("SELECT * FROM your_table_name WHERE panenTime < :currentTimestamp AND status = 0");
- // Bind parameters
- $stmt->bindParam(':currentTimestamp', $currentTimestamp, SQLITE3_INTEGER);
- // Execute the statement
- $result = $stmt->execute();
- // Check for success
- if ($result) {
- // Fetch the records
- while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
- // Update the status or perform any other action
- $id = $row['id'];
- $userid = $row['userid'];
- $panenTime = date('H:i:s d-m-Y', $row['panenTime']);
- $comment = $row['comment'];
- // $msg = "```yaml\nWaktunya Panen / Claim Energy | $comment | $panenTime```";
- file_get_contents("https://api.telegram.org/bot" . $botToken . "/sendMessage?chat_id=" . $userid . "&text=```yaml Waktunya Panen / Claim Energy | $comment | $panenTime```&parse_mode=markdown");
- // Example: Update the status to 1
- $updateStmt = $db->prepare("UPDATE your_table_name SET status = 1 WHERE id = :id");
- $updateStmt->bindParam(':id', $id, SQLITE3_INTEGER);
- $updateStmt->execute();
- }
- } else {
- echo "Error querying database: " . $db->lastErrorMsg();
- }
- // Close the database connection
- $db->close();
- }
- checkAndUpdateStatus();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement