Files
Wallos/endpoints/notifications/testserverchannotifications.php
Miguel Ribeiro aff3ed06b1 feat: add OIDC_REQUIRE_EMAIL_VERIFIED environment variable and SSRF_ALLOWLIST environment variable
feat: add Arabic localization
feat: add manual logo search box and png prioritization
fix: pin discord notification action to a commit sha
fix: service worker caching stale logo search results and broken images as logos
fix: ai recommendations not handling varied provider responses
fix: deleting orphaned logos not taking into account themed variants
fix: stats page not using themed logo variants
fix: email notification test rejecting non-admin users
fix: notification test/send requests hanging on unreachable hosts
fix: progress bar showing 100% when next payment is more than one cycle away
2026-07-18 23:33:40 +02:00

58 lines
1.7 KiB
PHP

<?php
require_once '../../includes/connect_endpoint.php';
require_once '../../includes/validate_endpoint.php';
$postData = file_get_contents("php://input");
$data = json_decode($postData, true);
$enabled = $data["enabled"] ?? 0;
$sendkey = $data["sendkey"] ?? "";
if (!$enabled || $sendkey === "") {
echo json_encode([
"success" => false,
"message" => translate('fill_mandatory_fields', $i18n)
]);
exit;
}
function sc_send($text, $desp = '', $key = '') {
$postdata = http_build_query(array('text' => $text, 'desp' => $desp));
if (strpos($key, 'sctp') === 0) {
preg_match('/^sctp(\d+)t/', $key, $matches);
$num = $matches[1] ?? '';
$url = "https://{$num}.push.ft07.com/send/{$key}.send";
} else {
$url = "https://sctapi.ftqq.com/{$key}.send";
}
$opts = array('http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata,
'timeout' => 15
));
$context = stream_context_create($opts);
$result = @file_get_contents($url, false, $context);
return $result !== false ? $result : '';
}
$title = 'Wallos Notification Test';
$body = 'This is a test notification from Wallos via Serverchan.';
$result = sc_send($title, $body, $sendkey);
$info = json_decode($result, true);
$code = (is_array($info) && array_key_exists('code', $info)) ? $info['code'] : null;
if ($code === 0) {
echo json_encode([
"success" => true,
"message" => translate('notification_sent_successfuly', $i18n)
]);
} else {
echo json_encode([
"success" => false,
"message" => translate('notification_failed', $i18n)
]);
}