6 || die('bad token');
// Other parameters.
$_action = $_GET['action'] ?? '';
$_weight = $_GET['weight'] ?? '';
$_email = $_GET['email'] ?? '';
$_stats_apikey = $_GET['stats_apikey'] ?? '';
$_terms = $_GET['terms'] ?? '';
require_once __DIR__ . '/../config.php';
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
$dbh || die('Error in connection: ' . pg_last_error());
$sql = 'SELECT domain,email,token,tokenexpire,weight,terms FROM pods WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
while ($row = pg_fetch_array($result)) {
$row['token'] === $_token || die('token mismatch');
$row['tokenexpire'] >= date('Y-m-d H:i:s') || die('token expired');
// Delete and exit.
if ('delete' === $_action) {
$sql = 'DELETE FROM pods WHERE domain = $1';
$result = pg_query_params($dbh, $sql, [$_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
die('pod removed from DB');
}
// Save and exit
if ('save' === $_action) {
$_weight <= 10 || die('10 is max weight');
$sql = 'UPDATE pods SET email = $1, weight = $2, terms = $3 WHERE domain = $4';
$result = pg_query_params($dbh, $sql, [$_email, $_weight, $_terms, $_domain]);
$result || die('Error in SQL query: ' . pg_last_error());
$to = $_email;
$headers = ['From: ' . $adminemail, 'Cc: ' . $row['email'], 'Bcc: ' . $adminemail];
$subject = 'Edit notice from poduptime';
$message = 'Data for ' . $_domain . ' updated. If it was not you reply and let me know!';
@mail($to, $subject, $message, implode("\r\n", $headers));
die('Data saved. Will go into effect on next hourly change');
}
// Forms.
?>
Authorized to edit until