mep de la gw sms !

This commit is contained in:
fab
2026-08-21 19:03:17 +02:00
parent cc28aebe4e
commit 9ed820193a
3 changed files with 67 additions and 0 deletions
+1
View File
@@ -38,6 +38,7 @@ services:
- icons:/var/www/htdocs/images/ - icons:/var/www/htdocs/images/
- lang:/var/www/lang/ - lang:/var/www/lang/
- ./UIHooks:/var/www/kaz/ - ./UIHooks:/var/www/kaz/
- ./smsapi-kaz.inc.php:/var/www/lib/smsapi-kaz.inc.php:ro
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.${ldapUIName}.rule=Host(`${ldapUIHost}.${domain}`)" - "traefik.http.routers.${ldapUIName}.rule=Host(`${ldapUIHost}.${domain}`)"
+62
View File
@@ -0,0 +1,62 @@
<?php
//utilisable avec https://github.com/capcom6/android-sms-gateway
class KazSMS
{
private $sms_api_url;
private $sms_api_user;
private $sms_api_password;
public function __construct($sms_api_url, $sms_api_user, $sms_api_password)
{
$this->sms_api_url = $sms_api_url;
$this->sms_api_user = $sms_api_user;
$this->sms_api_password = $sms_api_password;
}
public function send_sms_by_api($sms, $sms_message)
{
$data = json_encode([
'textMessage' => [
'text' => $sms_message
],
'phoneNumbers' => [
$sms
]
]);
$ch = curl_init($this->sms_api_url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => $this->sms_api_user . ':' . $this->sms_api_password,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Content-Length: ' . strlen($data)
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 15
]);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
error_log("KazSMS cURL error: $error");
return false;
}
if ($http_code < 200 || $http_code >= 300) {
error_log("KazSMS HTTP error $http_code: $response");
return false;
}
return true;
}
}
+4
View File
@@ -7,3 +7,7 @@ LDAPUI_ADMIN_BIND_PWD=@@pass@@ldapui@@p@@
LDAPUI_IGNORE_CERT_ERRORS=TRUE LDAPUI_IGNORE_CERT_ERRORS=TRUE
LDAPUI_PASSWORD=@@pass@@ldapuipass@@p@@ LDAPUI_PASSWORD=@@pass@@ldapuipass@@p@@
LDAPUI_MM_ADMIN_TOKEN=@@crossvar@@mattermostAdmin_mattermost_token@@cv@@ LDAPUI_MM_ADMIN_TOKEN=@@crossvar@@mattermostAdmin_mattermost_token@@cv@@
SMS_API_URL=
SMS_API_USER=
SMS_API_PASSWORD=