const express = require('express'); const app = express(); const port = process.env.SERVER_PORT || 3000; app.get('/', (req, res) => { res.send('Hello, world!'); }); app.get('/time.php', (req, res) => { // Logging if (req.headers['user-agent'] && req.headers['user-agent'].includes('Roblox/Linux')) { // Is roblox server console.log(`Request from Roblox server. Place ${req.headers['roblox-id']} (${req.headers['x-forwarded-for'] || 'unknown IP'})`); } else if(req.headers['user-agent'] && req.headers['user-agent'].includes('RobloxStudio')) { // Is roblox studio console.log(`Request from Roblox Studio. Place ${req.headers['roblox-id']} (${req.headers['x-forwarded-for'] || 'unknown IP'})`); } else { console.log(`Request from ${req.headers['user-agent'] || `unknown user agent ${req.headers['x-forwarded-for'] || 'unknown IP'}`}`); } const tz = req.query.zone || 'UTC'; const date = new Date(); try { const options = { timeZone: tz, hour12: false }; const formatter = new Intl.DateTimeFormat('en-GB', { ...options, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' }); const parts = formatter.formatToParts(date); const get = type => parts.find(p => p.type === type).value; const formatted = `${get('day')}${get('month')}${get('year')}${get('hour')}${get('minute')}${get('second')}`; res.send(formatted); } catch (e) { res.status(400).send('Invalid timezone'); } }); app.listen(port, () => { console.log(`Server is running on port ${port}`); });