V1.8 20.06.2023 -> neue Parameter und devid darf keine Zeichen sondern nur Buchstaben und Zahlen enthalten
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
/*
|
||||
Nenninger N-Tools.de
|
||||
Version 1.7
|
||||
Version 1.8
|
||||
|
||||
*20.06.2023 -> neue Parameter und devid darf keine Zeichen sondern nur Buchstaben und Zahlen enthalten
|
||||
|
||||
hermine@THW PHPConnector
|
||||
inspiriert von https://gitlab.com/aeberhardt/stashcat-api-client
|
||||
@@ -167,7 +169,7 @@ class UUID {
|
||||
|
||||
|
||||
class hermineConnect{
|
||||
private $VERSION = '1.3';
|
||||
private $VERSION = '1.8';
|
||||
private $hermineServer = 'https://api.thw-messenger.de';
|
||||
private $connectorID = "";
|
||||
private $user = "";
|
||||
@@ -190,7 +192,11 @@ class hermineConnect{
|
||||
$data = '';
|
||||
$eol = "\r\n";
|
||||
$delimiter = '-------------' . $boundary;
|
||||
|
||||
foreach ($fields as $name => $content) {
|
||||
/*echo "@@\n";
|
||||
print_r($content);
|
||||
echo "@@\n";*/
|
||||
$data .= "--" . $delimiter . $eol
|
||||
. 'Content-Disposition: form-data; name="' . $name . "\"".$eol.$eol
|
||||
. $content . $eol
|
||||
@@ -221,7 +227,7 @@ class hermineConnect{
|
||||
}
|
||||
$cID = array_map('hexdec', str_split('deadbeef'.sha1($_SERVER['SERVER_NAME']), 2));
|
||||
$cID = intArrayToString($cID);
|
||||
$this->connectorID = base64_encode($cID);
|
||||
$this->connectorID =str_replace(['+','/','='], ['','',''],base64_encode($cID));
|
||||
$this->user = $user;
|
||||
$this->password = $password;
|
||||
$this->passphrase = $passphrase;
|
||||
@@ -254,7 +260,6 @@ class hermineConnect{
|
||||
"Content-Length: " . strlen($_data),
|
||||
'Expect:'
|
||||
));
|
||||
|
||||
curl_setopt( $this->cURL, CURLOPT_COOKIESESSION, true );
|
||||
curl_setopt( $this->cURL, CURLOPT_COOKIEJAR, './hermineConnectCookie.txt' );
|
||||
curl_setopt( $this->cURL, CURLOPT_COOKIEFILE, './hermineConnectCookie.txt' );
|
||||
@@ -278,15 +283,32 @@ class hermineConnect{
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->lasterror = 'Curl error: ' . curl_error($cURL);
|
||||
$this->lasterror = 'Curl error: ' . curl_error($this->cURL);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function _check(){
|
||||
//Nenninger ab 20.06.2023 neue
|
||||
$data = [
|
||||
"app_name" => 'hermine@thw-PHP:'.$this->VERSION,
|
||||
"encrypted" => true,
|
||||
"callable" => false,
|
||||
"key_transfer_support" => false
|
||||
];
|
||||
$response = $this->request($this->hermineServer."/auth/check",$data);
|
||||
if($response !== false){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function _open_private_key(){
|
||||
$data = [];
|
||||
//Nenninger ab 20.06.2023 neue Parameter format=pem&type=encryption
|
||||
$data = ['format'=>'pem','type'=>'encryption'];
|
||||
$response = $this->request($this->hermineServer."/security/get_private_key",$data);
|
||||
$private_key = json_decode($response->keys->private_key);
|
||||
$privkey_decoded = openssl_pkey_get_private($private_key->private, $this->passphrase);
|
||||
@@ -496,6 +518,21 @@ class hermineConnect{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function _get_channel_infos($_id){
|
||||
$data = [
|
||||
"channel_id" => $_id,
|
||||
"without_members" => false
|
||||
];
|
||||
|
||||
$response = $this->request($this->hermineServer."/channels/info",$data);
|
||||
|
||||
if($response !== false){
|
||||
return $response->channels;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Öffentliche Funktionen
|
||||
@@ -525,6 +562,7 @@ class hermineConnect{
|
||||
$this->client_key = $savelogin->ClientKey;
|
||||
$this->connectorID = $savelogin->DeviceId;
|
||||
$this->user_id = $savelogin->UserID;
|
||||
$this->_check();
|
||||
if($this->_open_private_key()){
|
||||
$this->companies = $this->get_companies();
|
||||
$this->channels = $this->get_channels($this->companies->companies[0]->id);
|
||||
@@ -538,13 +576,15 @@ class hermineConnect{
|
||||
"password" => $this->password,
|
||||
"app_name" => 'hermine@thw-PHP:'.$this->VERSION,
|
||||
"encrypted" => true,
|
||||
"callable" => false
|
||||
"callable" => false,
|
||||
"key_transfer_support" => false
|
||||
];
|
||||
|
||||
$response = $this->request($this->hermineServer."/auth/login",$data);
|
||||
if($response !== false){
|
||||
$this->client_key = $response->client_key;
|
||||
$this->user_id = $response->userinfo->id;
|
||||
$this->_check();
|
||||
if($this->_open_private_key()){
|
||||
$this->companies = $this->get_companies();
|
||||
$this->channels = $this->get_channels($this->companies->companies[0]->id);
|
||||
@@ -610,6 +650,10 @@ class hermineConnect{
|
||||
public function get_channel_messages($_channel_id){
|
||||
return $this->get_messages(array('channel',$_channel_id),$_limit,$_offset);
|
||||
}
|
||||
|
||||
public function get_channel_infos($_channel_id){
|
||||
return $this->_get_channel_infos($_channel_id);
|
||||
}
|
||||
|
||||
public function search_user($_searchby, $_limit=50, $_offset=0){
|
||||
$data = [
|
||||
@@ -617,9 +661,9 @@ class hermineConnect{
|
||||
"offset" => $_offset,
|
||||
"key_hashes" => false,
|
||||
"search" => $_searchby,
|
||||
"sorting" => ["first_name_asc", "last_name_asc"],
|
||||
"exclude_user_ids" => [],
|
||||
"group_ids" => [],
|
||||
"sorting" => '["first_name_asc", "last_name_asc"]',
|
||||
"exclude_user_ids" => '[]',
|
||||
"group_ids" => '[]',
|
||||
];
|
||||
|
||||
$response = $this->request($this->hermineServer."/users/listing",$data);
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user