<?php
/**
* PHP - The Server Behind the Curtain
* This page shows what PHP can do on the server.
*/
// Current time and date
date_default_timezone_set("Europe/Prague");
$currentTime = date("H:i:s");
$currentDate = date("F j, Y");
$dayOfWeek = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][date("w")];
// Random joke
$jokes = [
"Why do programmers wear glasses? Because they can't C#.",
"What did HTML say to CSS? Without you I have no style.",
"How many programmers does it take to change a light bulb? None - that's a hardware problem.",
"Why do Java and JavaScript not get along? Because they have different classes.",
"A SQL query walks into a bar, sees two tables, and asks... Can I JOIN you?",
"Why did the developer go broke? Because he used up all his cache.",
"Why did the database break up? Too many relationships.",
"What's a programmer's favorite hangout? Foo Bar."
];
$randomJoke = $jokes[array_rand($jokes)];
// Visit counter (saved in file)
$counterFile = __DIR__ . "/visit_counter.txt";
$visits = file_exists($counterFile) ? (int)file_get_contents($counterFile) : 0;
$visits++;
file_put_contents($counterFile, $visits);
// Server information
$phpVersion = phpversion();
$serverSoftware = $_SERVER["SERVER_SOFTWARE"] ?? "Unknown";
$userAgent = $_SERVER["HTTP_USER_AGENT"] ?? "Unknown";
$userIP = $_SERVER["REMOTE_ADDR"] ?? "Unknown";
// Greeting based on time of day
$hour = (int)date("G");
if ($hour < 6) $greeting = "Good night";
elseif ($hour < 12) $greeting = "Good morning";
elseif ($hour < 18) $greeting = "Good afternoon";
else $greeting = "Good evening";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PHP Server</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
min-height: 100vh;
font-family: "Segoe UI", system-ui, sans-serif;
background: linear-gradient(135deg, #0f0c29, #1a1a3e);
color: #e0e0e0;
padding: 2rem;
}
h1 {
text-align: center;
font-size: 2.2rem;
background: linear-gradient(to right, #00d4aa, #7b68ee);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 0.5rem;
}
.subtitle { text-align: center; color: #6b7280; margin-bottom: 2rem; }
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 1.5rem;
max-width: 900px;
margin: 0 auto;
}
.card {
background: rgba(255,255,255,0.04);
border: 1px solid rgba(255,255,255,0.08);
border-radius: 16px;
padding: 1.5rem;
}
.card h2 { color: #00d4aa; font-size: 1.1rem; margin-bottom: 1rem; }
.big-time {
font-size: 3rem;
font-weight: 800;
text-align: center;
color: #00d4aa;
font-family: monospace;
}
.date-info { text-align: center; color: #8892a4; margin-top: 0.5rem; }
.joke-text {
font-style: italic;
color: #c0c0c0;
line-height: 1.7;
padding: 1rem;
background: rgba(123,104,238,0.08);
border-radius: 12px;
border-left: 3px solid #7b68ee;
}
.counter-big {
font-size: 4rem;
font-weight: 800;
text-align: center;
background: linear-gradient(to right, #ff6b9d, #f59e0b);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.counter-label { text-align: center; color: #8892a4; }
.info-list { list-style: none; }
.info-list li {
padding: 0.6rem 0;
border-bottom: 1px solid rgba(255,255,255,0.05);
font-size: 0.9rem;
}
.info-list li:last-child { border: 0; }
.info-list strong { color: #a78bfa; }
.greeting-big {
font-size: 1.8rem;
text-align: center;
padding: 1rem;
}
.reload-btn {
display: block;
margin: 2rem auto 0;
padding: 0.8rem 2rem;
background: linear-gradient(135deg, #00d4aa, #7b68ee);
color: white;
border: none;
border-radius: 12px;
font-size: 1rem;
cursor: pointer;
transition: all 0.3s;
}
.reload-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,212,170,0.4); }
.php-badge {
text-align: center;
margin-top: 2rem;
color: #555;
font-size: 0.85rem;
}
@media (max-width: 600px) { body { padding: 1rem; } h1 { font-size: 1.8rem; } }
</style>
</head>
<body>
<h1>🖥️ PHP Server</h1>
<p class="subtitle">Everything on this page is generated by PHP on the server</p>
<div class="grid">
<div class="card">
<h2>⏰ Server Time</h2>
<div class="big-time"><?php echo $currentTime; ?></div>
<p class="date-info"><?php echo $dayOfWeek . ", " . $currentDate; ?></p>
</div>
<div class="card">
<h2>👋 Greeting</h2>
<div class="greeting-big"><?php echo $greeting; ?>!</div>
</div>
<div class="card">
<h2>😂 Joke of the Day</h2>
<div class="joke-text"><?php echo htmlspecialchars($randomJoke); ?></div>
</div>
<div class="card">
<h2>📊 Visit Count</h2>
<div class="counter-big"><?php echo number_format($visits); ?></div>
<p class="counter-label">total visits to this page</p>
</div>
<div class="card" style="grid-column: span 2">
<h2>⚙️ Server Info</h2>
<ul class="info-list">
<li><strong>PHP:</strong> <?php echo $phpVersion; ?></li>
<li><strong>Server:</strong> <?php echo htmlspecialchars($serverSoftware); ?></li>
<li><strong>Your browser:</strong> <?php echo htmlspecialchars(substr($userAgent, 0, 80)); ?>...</li>
<li><strong>Your IP:</strong> <?php echo htmlspecialchars($userIP); ?></li>
<li><strong>Random number:</strong> <?php echo rand(1, 1000); ?></li>
</ul>
</div>
</div>
<button class="reload-btn" onclick="location.reload()">🔄 Reload (new joke!)</button>
<p class="php-badge">Generated by PHP on server • <?php echo date("H:i:s"); ?></p>
</body>
</html>