repl.it
@William3/

repl-auth-php

PHP Web Server

No description

fork
loading
Files
  • index.php
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
    // Store request headers to $headers
    function getRequestHeaders() {
        $headers = array();
        foreach($_SERVER as $key => $value) {
            if (substr($key, 0, 5) <> 'HTTP_') {
                continue;
            }
            $header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
            $headers[$header] = $value;
        }
        return $headers;
    }
    $headers = getRequestHeaders();

    // Check if authenticated, if not, prompt for authentication
    if (!isset($headers['X-Replit-User-Id']) || $headers['X-Replit-User-Id'] == "") {
        echo '<div><script authed="location.reload()" src="https://auth.turbio.repl.co/script.js"></script></div>';
        die();
    };

    // Continue if authenticated!



    echo "Hello, ".$headers['X-Replit-User-Name']."!";
    ?>
Fetching token
?