#!/usr/bin/php-cgi -dcgi.force_redirect=0 [ "title" => "Contact info", "desc" => "This is usually just an email address. For using git-fast-export this must be a single line.", ], "homepage" => [ "title" => "Homepage URLs", "desc" => "This will create a new column for listing user urls. Which is used by the IndieAuth plugin to verify authorization requests.", ], ]; #-- database (== fossil repo) function db($sql="", $params=[]) { static $db; if (empty($db)) { $db = new PDO("sqlite:$_SERVER[FOSSIL_REPOSITORY]"); } if ($params) { $stmt = $db->prepare($sql); $stmt->execute($params); return $stmt->fetchAll(PDO::FETCH_ASSOC); } else { return $db->query($sql)->fetchAll(); } } #-- fossil HTML output function page_html($html) { header("Content-Type: text/html; charset=utf-8"); $html = << \n$html\n HTML; print($html); } function missing_param($name) { die(page_html("
URL lacks &$name=
parameter."));
}
function page_md($text) {
header("Content-Type: text/x-markdown; charset=utf-8");
print($text);
}
function h($s) {
return htmlspecialchars($s, ENT_QUOTES|ENT_HTML5, "UTF-8");
}
#-- show available fields
function field_inputs($user, $names="info,homepage") {
global $fields;
// get existing columns
$values = db("SELECT * FROM user WHERE login=?", [$user])[0];
// output form
$html = ""; $h = "h";
foreach ($fields as $name=>$props) {
extract($props);
$html .= <<
Edit contact infos requires an active login."); } elseif (!empty($_POST["save"])) { unset($_POST["save"]); save_fields($user, $_POST); } else { $html = field_inputs($user); $html = <<Edit user details
HTML; page_html($html); } ?>