156 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			156 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<!DOCTYPE html>
 | 
						|
<html lang="en">
 | 
						|
<head>
 | 
						|
    <meta charset="UTF-8">
 | 
						|
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | 
						|
    <title>Server Test - Debian PHP Apache</title>
 | 
						|
    <style>
 | 
						|
        body {
 | 
						|
            font-family: Arial, sans-serif;
 | 
						|
            background-color: #f4f4f4;
 | 
						|
            color: #333;
 | 
						|
            margin: 20px;
 | 
						|
            padding: 20px;
 | 
						|
        }
 | 
						|
        h2 {
 | 
						|
            color: #0056b3;
 | 
						|
            border-bottom: 2px solid #0056b3;
 | 
						|
            padding-bottom: 5px;
 | 
						|
        }
 | 
						|
        p {
 | 
						|
            background: #fff;
 | 
						|
            padding: 10px;
 | 
						|
            border-radius: 5px;
 | 
						|
            box-shadow: 0px 1px 3px rgba(0,0,0,0.1);
 | 
						|
        }
 | 
						|
        .container {
 | 
						|
            max-width: 700px;
 | 
						|
            margin: auto;
 | 
						|
            background: #fff;
 | 
						|
            padding: 20px;
 | 
						|
            border-radius: 8px;
 | 
						|
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
 | 
						|
        }
 | 
						|
        table {
 | 
						|
            width: 100%;
 | 
						|
            border-collapse: collapse;
 | 
						|
            margin-top: 10px;
 | 
						|
            background: #fff;
 | 
						|
        }
 | 
						|
        table, th, td {
 | 
						|
            border: 1px solid #ddd;
 | 
						|
        }
 | 
						|
        th, td {
 | 
						|
            padding: 10px;
 | 
						|
            text-align: left;
 | 
						|
        }
 | 
						|
        th {
 | 
						|
            background: #0056b3;
 | 
						|
            color: white;
 | 
						|
        }
 | 
						|
        .upload-section {
 | 
						|
            background: #e3f2fd;
 | 
						|
            padding: 15px;
 | 
						|
            border-radius: 5px;
 | 
						|
            margin-top: 20px;
 | 
						|
        }
 | 
						|
        .upload-section input[type="file"] {
 | 
						|
            padding: 5px;
 | 
						|
        }
 | 
						|
        .upload-section input[type="submit"] {
 | 
						|
            background: #0056b3;
 | 
						|
            color: white;
 | 
						|
            border: none;
 | 
						|
            padding: 8px 12px;
 | 
						|
            border-radius: 5px;
 | 
						|
            cursor: pointer;
 | 
						|
        }
 | 
						|
        .upload-section input[type="submit"]:hover {
 | 
						|
            background: #003d80;
 | 
						|
        }
 | 
						|
    </style>
 | 
						|
</head>
 | 
						|
<body>
 | 
						|
 | 
						|
<div class="container">
 | 
						|
    <h1>PHP Container Test Script</h1>
 | 
						|
    <p><a href="https://git.4lt.ca/4lt/phpcontainer">Four Lights PHP Container</a></p>
 | 
						|
 | 
						|
    
 | 
						|
    <h2>Server Information</h2>
 | 
						|
    <table>
 | 
						|
        <tr><th>PHP Version</th><td><?php echo phpversion(); ?></td></tr>
 | 
						|
        <tr><th>Current Date/Time (Vancouver)</th><td><?php date_default_timezone_set('America/Vancouver'); echo date('Y-m-d H:i:s'); ?></td></tr>
 | 
						|
        <tr><th>upload_max_filesize</th><td><?php echo ini_get('upload_max_filesize'); ?></td></tr>
 | 
						|
        <tr><th>post_max_size</th><td><?php echo ini_get('post_max_size'); ?></td></tr>
 | 
						|
        <tr><th>php.ini</th><td><?php echo php_ini_loaded_file(); ?></td></tr>
 | 
						|
    </table>
 | 
						|
 | 
						|
    <h2>Redis Test</h2>
 | 
						|
    <?php
 | 
						|
    $redis = new Redis();
 | 
						|
    try {
 | 
						|
        $redis->connect('redis', 6379);
 | 
						|
        echo "<p>✅ Redis connected</p>";
 | 
						|
        $redis->set("test_key", "There are FOUR Lights!");
 | 
						|
        echo "<p>Redis test_key: " . $redis->get("test_key") . "</p>";
 | 
						|
    } catch (Exception $e) {
 | 
						|
        echo "<p>❌ Redis connection failed: " . $e->getMessage() . "</p>";
 | 
						|
    }
 | 
						|
    ?>
 | 
						|
 | 
						|
    <h2>MariaDB Test</h2>
 | 
						|
    <?php
 | 
						|
    $mysqli = new mysqli('mariadb', 'user', 'password', 'dbname');
 | 
						|
    if ($mysqli->connect_error) {
 | 
						|
        echo "<p>❌ MariaDB connection failed: " . $mysqli->connect_error . "</p>";
 | 
						|
    } else {
 | 
						|
        echo "<p>✅ MariaDB connected</p>";
 | 
						|
        $result = $mysqli->query('SELECT NOW()');
 | 
						|
        $row = $result->fetch_row();
 | 
						|
        echo "<p>Current time in MariaDB: " . $row[0] . "</p>";
 | 
						|
        $mysqli->close();
 | 
						|
    }
 | 
						|
    ?>
 | 
						|
 | 
						|
    <h2>RemoteIP Test</h2>
 | 
						|
    <p>Your IP address (from Apache's remoteip module): <?php echo $_SERVER['REMOTE_ADDR']; ?></p>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h2>File Upload Test</h2>
 | 
						|
    <div class="upload-section">
 | 
						|
        <form action="" method="post" enctype="multipart/form-data">
 | 
						|
            <input type="file" name="testfile">
 | 
						|
            <input type="submit" name="upload" value="Upload">
 | 
						|
        </form>
 | 
						|
    </div>
 | 
						|
 | 
						|
    <?php
 | 
						|
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['testfile'])) {
 | 
						|
        if ($_FILES['testfile']['error'] === UPLOAD_ERR_OK) {
 | 
						|
            $uploadDir = '/data/public/uploads/';
 | 
						|
 | 
						|
            if (!is_dir($uploadDir)) {
 | 
						|
                mkdir($uploadDir, 0777, true);
 | 
						|
            }
 | 
						|
 | 
						|
            $destination = $uploadDir . basename($_FILES['testfile']['name']);
 | 
						|
 | 
						|
            if (move_uploaded_file($_FILES['testfile']['tmp_name'], $destination)) {
 | 
						|
                echo "<p>✅ File uploaded successfully to: <strong>" . htmlspecialchars($destination) . "</strong></p>";
 | 
						|
                echo "<p>Size: " . $_FILES['testfile']['size'] . " bytes</p>";
 | 
						|
            } else {
 | 
						|
                echo "<p>❌ Error moving file.</p>";
 | 
						|
            }
 | 
						|
        } else {
 | 
						|
            echo "<p>❌ Error uploading file. Error Code: " . $_FILES['testfile']['error'] . "</p>";
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    ?>
 | 
						|
</div>
 | 
						|
 | 
						|
</body>
 | 
						|
</html>
 |