adding support for telegram
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
//exec('run_baby_run > /dev/null &');
|
//exec('run_baby_run > /dev/null &');
|
||||||
|
|
||||||
function send($message){
|
function send($message){
|
||||||
|
$message=urlencode($message);
|
||||||
include "../../../config.php";
|
include "../../../config.php";
|
||||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
||||||
if ($conn->connect_error) {
|
if ($conn->connect_error) {
|
||||||
@@ -18,36 +19,23 @@ function send($message){
|
|||||||
$telegram_bot="";
|
$telegram_bot="";
|
||||||
$result = $stmt->get_result();
|
$result = $stmt->get_result();
|
||||||
if ($result->num_rows > 0) {
|
if ($result->num_rows > 0) {
|
||||||
// Fetch the first row as an associative array
|
|
||||||
$row = $result->fetch_assoc();
|
$row = $result->fetch_assoc();
|
||||||
// Extract the value of the 'value' column
|
|
||||||
$telegram_bot = $row['value'];
|
$telegram_bot = $row['value'];
|
||||||
// Do something with the value, for example:
|
$stmt->close();
|
||||||
echo "Telegram Bot API Key: " . $telegram_bot;
|
//now send a message to every user which has a telegram id
|
||||||
|
$sql = "SELECT telegram_id FROM users";
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
// Execute the statement
|
||||||
|
$stmt->execute();
|
||||||
|
// Get the result
|
||||||
|
$telegram_id="";
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
|
||||||
|
while($row = $result->fetch_assoc()) {
|
||||||
|
$telegram_id=$row["telegram_id"];
|
||||||
|
exec("curl \"https://api.telegram.org/$telegram_bot/sendMessage?chat_id=$telegram_id&text=$message\" > /dev/null &");
|
||||||
|
}
|
||||||
|
$stmt -> close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
send("");
|
?>
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
//if able to, send a telegram notification to user
|
|
||||||
$sql = "SELECT telegram_id FROM users";
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
// Execute the statement
|
|
||||||
$stmt->execute();
|
|
||||||
// Get the result
|
|
||||||
$telegram_id="";
|
|
||||||
$result = $stmt->get_result();
|
|
||||||
|
|
||||||
while($row = $result->fetch_assoc()) {
|
|
||||||
$telegram_id=$row["telegram_id"];
|
|
||||||
//exec("curl \"https://api.telegram.org/$api/sendMessage?chat_id=$telegram_id&text=$text\"");
|
|
||||||
$url="https://api.telegram.org/$";
|
|
||||||
$ch = curl_init($url);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
$fileContents = curl_exec($ch);
|
|
||||||
}
|
|
||||||
$stmt -> close();
|
|
||||||
*/
|
|
||||||
@@ -5,7 +5,7 @@ include "../accessctrl/check_apikey.php";
|
|||||||
if(check_apikey()!==true){
|
if(check_apikey()!==true){
|
||||||
die("no_auth");
|
die("no_auth");
|
||||||
}
|
}
|
||||||
|
include "../notifications/sendmessage.php";
|
||||||
//add the entry to the log db
|
//add the entry to the log db
|
||||||
//this page has no gui, it may return ok or error
|
//this page has no gui, it may return ok or error
|
||||||
if(!isset($_GET["machine_id"]) or !isset($_GET["hash"]) or !isset($_GET["file"]) or !isset($_GET["action"]))
|
if(!isset($_GET["machine_id"]) or !isset($_GET["hash"]) or !isset($_GET["file"]) or !isset($_GET["action"]))
|
||||||
@@ -31,5 +31,6 @@ else{
|
|||||||
echo("wrt_ok");
|
echo("wrt_ok");
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
$conn->close();
|
$conn->close();
|
||||||
|
send("[VIRUS WARNING!]\nhash: $hash\npath: $path\nmachine_id: $machine_id\naction: $action\n");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -72,6 +72,7 @@ if(isset($_SESSION["login"])){
|
|||||||
$_SESSION["login"]=true;
|
$_SESSION["login"]=true;
|
||||||
$_SESSION["perms"]=$row["perms"];
|
$_SESSION["perms"]=$row["perms"];
|
||||||
$_SESSION["email"]=$row["email"];
|
$_SESSION["email"]=$row["email"];
|
||||||
|
$_SESSION["telegram_id"]=$row["telegram_id"];
|
||||||
|
|
||||||
echo '<script>window.location.href = "/system/secure_zone/php/index.php";</script>';
|
echo '<script>window.location.href = "/system/secure_zone/php/index.php";</script>';
|
||||||
exit();
|
exit();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ if (!isset($_SESSION['username']) or !isset($_SESSION["login"])) {
|
|||||||
$username = $_SESSION['username'];
|
$username = $_SESSION['username'];
|
||||||
$perms = $_SESSION["perms"];
|
$perms = $_SESSION["perms"];
|
||||||
$email = $_SESSION["email"];
|
$email = $_SESSION["email"];
|
||||||
|
$_SESSION["telegram_id"]=$telegram_id;
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
//update the info, if provided.
|
//update the info, if provided.
|
||||||
@@ -19,6 +20,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
include "../../../config.php";
|
include "../../../config.php";
|
||||||
$email=htmlspecialchars($_POST["email"]);
|
$email=htmlspecialchars($_POST["email"]);
|
||||||
$username_new=htmlspecialchars($_POST["username"]);
|
$username_new=htmlspecialchars($_POST["username"]);
|
||||||
|
$telegram_id=htmlspecialchars($_POST["telegram_id"]);
|
||||||
// Create connection
|
// Create connection
|
||||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
||||||
|
|
||||||
@@ -27,17 +29,19 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
$success=0;
|
$success=0;
|
||||||
die("Connection failed: " . $conn->connect_error);
|
die("Connection failed: " . $conn->connect_error);
|
||||||
}
|
}
|
||||||
$stmt = $conn->prepare("UPDATE users set email = ?, username = ? where username = ?");
|
$stmt = $conn->prepare("UPDATE users set email = ?, username = ?, telegram_id = ? where username = ?");
|
||||||
$stmt->bind_param("sss", $email, $username_new, $username);
|
$stmt->bind_param("ssss", $email, $username_new,$telegram_id, $username);
|
||||||
|
|
||||||
$email=htmlspecialchars($_POST["email"]);
|
$email=htmlspecialchars($_POST["email"]);
|
||||||
$username_new=htmlspecialchars($_POST["username"]);
|
$username_new=htmlspecialchars($_POST["username"]);
|
||||||
|
$telegram_id=htmlspecialchars($_POST["telegram_id"]);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
$conn->close();
|
$conn->close();
|
||||||
$username=$username_new;
|
$username=$username_new;
|
||||||
$_SESSION["username"]=$username;
|
$_SESSION["username"]=$username;
|
||||||
$_SESSION["email"]=$email;
|
$_SESSION["email"]=$email;
|
||||||
|
$_SESSION["telegram_id"]=$telegram_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -67,6 +71,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
<label for="email">Email:</label>
|
<label for="email">Email:</label>
|
||||||
<input type="email" class="form-control" id="email" name="email" value="<?php echo($email); ?>" required>
|
<input type="email" class="form-control" id="email" name="email" value="<?php echo($email); ?>" required>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="telegram_id">Telegram ID:</label>
|
||||||
|
<input type="text" class="form-control" id="telegram_id" name="telegram_id" value="<?php echo($telegram_id); ?>">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="perms">Permissions:
|
<label for="perms">Permissions:
|
||||||
<a data-bs-target="#perms_help" data-bs-toggle="modal" href="#perms_help">?</a>
|
<a data-bs-target="#perms_help" data-bs-toggle="modal" href="#perms_help">?</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user