'Configuration File', 'status' => file_exists(__DIR__ . '/config.php') ? 'OK' : 'FAIL', 'message' => file_exists(__DIR__ . '/config.php') ? 'Config file exists' : 'Config file not found' ]; // Test 2: Verify bot token $tests['bot_token'] = [ 'name' => 'Bot Token', 'status' => (!empty($api_config['telegram']['bot_token']) && $api_config['telegram']['bot_token'] !== '123456789:ABCdefGHIjklmNOPQRstuvwxyz') ? 'OK' : 'FAIL', 'message' => (!empty($api_config['telegram']['bot_token']) && $api_config['telegram']['bot_token'] !== '123456789:ABCdefGHIjklmNOPQRstuvwxyz') ? 'Bot token is set' : 'Please set your bot token in config.php' ]; // Test 3: Verify channel ID $tests['channel_id'] = [ 'name' => 'Channel ID', 'status' => (!empty($api_config['telegram']['channel_id']) && $api_config['telegram']['channel_id'] !== 'YOUR_CHANNEL_ID') ? 'OK' : 'FAIL', 'message' => (!empty($api_config['telegram']['channel_id']) && $api_config['telegram']['channel_id'] !== 'YOUR_CHANNEL_ID') ? 'Channel ID is set' : 'Please set your channel ID in config.php' ]; // Test 4: Test Telegram API connection and channel access function testTelegramAPI($bot_token, $channel_id) { // First test bot token $url = "https://api.telegram.org/bot{$bot_token}/getMe"; $result = file_get_contents($url); if ($result === false) { return ['status' => 'FAIL', 'message' => 'Could not connect to Telegram API']; } $response = json_decode($result, true); if (!$response['ok']) { return ['status' => 'FAIL', 'message' => 'Invalid bot token']; } // Then test channel access $url = "https://api.telegram.org/bot{$bot_token}/getChat?chat_id={$channel_id}"; $result = file_get_contents($url); if ($result === false) { return ['status' => 'FAIL', 'message' => 'Could not access channel']; } $response = json_decode($result, true); return [ 'status' => $response['ok'] ? 'OK' : 'FAIL', 'message' => $response['ok'] ? 'Successfully connected to Telegram API and channel' : 'Failed to access channel. Make sure bot is an admin.' ]; } $telegram_test = testTelegramAPI($api_config['telegram']['bot_token'], $api_config['telegram']['channel_id']); $tests['telegram_api'] = [ 'name' => 'Telegram API & Channel Access', 'status' => $telegram_test['status'], 'message' => $telegram_test['message'] ]; // Test 5: Check database connection $tests['database'] = [ 'name' => 'Database Connection', 'status' => isset($class_database) ? 'OK' : 'FAIL', 'message' => isset($class_database) ? 'Database connection is available' : 'Database connection failed' ]; // Test 6: Check file permissions $tests['permissions'] = [ 'name' => 'File Permissions', 'status' => is_writable(__DIR__) ? 'OK' : 'FAIL', 'message' => is_writable(__DIR__) ? 'Directory is writable' : 'Directory is not writable' ]; // Output test results echo "
| Test | Status | Message |
|---|---|---|
| {$test['name']} | "; echo "{$test['status']} | "; echo "{$test['message']} | "; echo "