Torna indietro
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <link rel="icon" href="/favicon.png" />
        <title>Database di links</title>
    </head>
    <body>
        <a href=".">Torna indietro</a>
        <br>
<?php

$source 
$_GET["source"] ?? false;

if (
$source) {
    
highlight_file(__FILE__);
    return;
}

function 
render_content($content) {
    
printf("<h1>Lista links</h1>");
    
printf("<ul>");
    
$lines explode("\n"$content);
    foreach (
$lines as $line) {
        
$x explode(","trim($line), 2);
        
$link $x[0];
        
$description $x[1];
        
printf("<li><a href=\"https://%s\">%s</a> - %s</li>"$link$link$description);
    }
    
printf("</ul>");
}

$input_password $_GET["pwd"] ?? null;
$new_content $_GET["new_content"] ?? null;

$content file_get_contents("links.txt");

if (isset(
$new_content)) {
    
file_put_contents("links.txt"$new_content);
    
render_content($new_content);
    return;
}

if (
$input_password !== "gerardo") {
    
render_content($content);
    return;
}

printf("<h1>Editing links</h1>");
printf("<form action=\"script.php\">");
printf("<textarea name=\"new_content\">%s</textarea><br>"$content);
printf("<button type=\"submit\">Submit</button>");
printf("</form>");  

?>
    </body>
</html>