6 || die('bad token');
// Other parameters.
$_action = $_GET['action'] ?? '';
$_weight = $_GET['weight'] ?? 10;
$_email = $_GET['email'] ?? '';
$_podmin_statement = $_GET['podmin_statement'] ?? '';
$_podmin_notify = $_GET['podmin_notify'] ?? 0;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../config.php';
try {
$pod = R::findOne('pods', 'domain = ?', [$_domain]);
$pod || die('domain not found');
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
$pod['token'] === $_token || die('token mismatch');
$pod['tokenexpire'] >= date('Y-m-d H:i:s') || die('token expired');
// Delete and exit.
if ('delete' === $_action) {
try {
$pod['status'] = PodStatus::User_Deleted;
R::store($pod);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
die('pod deleted');
}
// Pause and exit.
if ('pause' === $_action) {
try {
$pod['status'] = PodStatus::Paused;
R::store($pod);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
die('pod paused');
}
// Un-Pause and exit.
if ('unpause' === $_action) {
try {
$pod['status'] = PodStatus::Recheck;
R::store($pod);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
die('pod unpaused');
}
// Save and exit.
if ('save' === $_action) {
$_weight <= 10 || die('10 is max weight');
try {
$pod['email'] = $_email;
$pod['weight'] = $_weight;
$pod['podmin_statement'] = $_podmin_statement;
$pod['podmin_notify'] = $_podmin_notify;
R::store($pod);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
$to = $_email;
$headers = ['From: ' . $adminemail, 'Cc: ' . $pod['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