2025-06-02 10:01:12 +02:00
|
|
|
|
<?php
|
2025-06-23 20:45:15 +02:00
|
|
|
|
If (!defined("INBCWE")) {
|
2025-06-02 10:01:12 +02:00
|
|
|
|
die("Dieses Script kann nicht ausserhalb des Frameworks laufen!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Case insensitive version of array_key_exists.
|
|
|
|
|
* Returns the matching key on success, else false.
|
|
|
|
|
*
|
|
|
|
|
* @param string $key
|
|
|
|
|
* @param array $search
|
|
|
|
|
* @return string|false
|
|
|
|
|
*/
|
|
|
|
|
function array_key_exists_chat($key, $search) {
|
|
|
|
|
if (array_key_exists($key, $search)) {
|
|
|
|
|
return $key;
|
|
|
|
|
}
|
|
|
|
|
if (!(is_string($key) && is_array($search) && count($search))) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$key = strtolower($key);
|
|
|
|
|
foreach ($search as $k => $v) {
|
|
|
|
|
if (strtolower($k) == $key) {
|
|
|
|
|
return $k;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_user_list() {
|
|
|
|
|
global $config, $ccache;
|
|
|
|
|
// Open URL to userlist
|
|
|
|
|
// erzeuge einen neuen cURL-Handle
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
// setze die URL und andere Optionen
|
2025-06-02 22:38:25 +02:00
|
|
|
|
curl_setopt($ch, CURLOPT_URL, "https://chat.funch.at/info");
|
2025-06-02 10:01:12 +02:00
|
|
|
|
//curl_setopt($ch, CURLOPT_URL, "https://46.4.58.184/info");
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
|
|
curl_setopt($ch, CURLOPT_HEADER, false);
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
2025-06-23 20:45:15 +02:00
|
|
|
|
// f<>hre die Aktion aus und gebe die Daten an den Browser weiter
|
2025-06-02 10:01:12 +02:00
|
|
|
|
$fh=curl_exec($ch);
|
|
|
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
//var_dump(curl_getinfo($ch));
|
|
|
|
|
|
2025-06-23 20:45:15 +02:00
|
|
|
|
// schlie<69>e den cURL-Handle und gebe die Systemresourcen frei
|
2025-06-02 10:01:12 +02:00
|
|
|
|
curl_close($ch);
|
|
|
|
|
|
|
|
|
|
if($httpCode >= 200 && $httpCode < 300){
|
|
|
|
|
//$content = $ccache->get('roomdata');
|
|
|
|
|
|
|
|
|
|
$content = json_decode($fh,true);
|
|
|
|
|
$userlist = array();
|
|
|
|
|
foreach($content as $room) {
|
|
|
|
|
$room_name = $room['room'];
|
|
|
|
|
$userlist[$room_name]['s'] = $room_state;
|
|
|
|
|
$userlist[$room_name]['u'] = array();
|
|
|
|
|
$userlist[$room_name]['g'] = $type;
|
|
|
|
|
if(!is_array($room['users'])){
|
|
|
|
|
unset($userlist[$room_name]);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
foreach($room['users'] as $user) {
|
|
|
|
|
$userlist[$room_name]['u'][$user['nick']] = $user['color'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return userlist
|
|
|
|
|
return $userlist;
|
|
|
|
|
}else{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_user_room($username) {
|
2025-06-18 20:12:29 +02:00
|
|
|
|
global $config, $ccache;
|
|
|
|
|
// Open URL to userlist
|
|
|
|
|
// erzeuge einen neuen cURL-Handle
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
// setze die URL und andere Optionen
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, "https://chat.funch.at/info/".$username);
|
|
|
|
|
//curl_setopt($ch, CURLOPT_URL, "https://46.4.58.184/info");
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
|
|
curl_setopt($ch, CURLOPT_HEADER, false);
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
2025-06-23 20:45:15 +02:00
|
|
|
|
// f<>hre die Aktion aus und gebe die Daten an den Browser weiter
|
2025-06-18 20:12:29 +02:00
|
|
|
|
$fh=curl_exec($ch);
|
|
|
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
curl_close($ch);
|
2025-06-02 10:01:12 +02:00
|
|
|
|
|
2025-06-18 20:12:29 +02:00
|
|
|
|
if($httpCode >= 200 && $httpCode < 300){
|
|
|
|
|
//$content = $ccache->get('roomdata');
|
|
|
|
|
if($content = ""){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$content = json_decode($fh,true);
|
|
|
|
|
// Return userlist
|
|
|
|
|
return $content;
|
2025-06-02 10:01:12 +02:00
|
|
|
|
}else{
|
2025-06-18 20:12:29 +02:00
|
|
|
|
return false;
|
2025-06-02 10:01:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function chat_online(){
|
|
|
|
|
global $session, $config;
|
|
|
|
|
$online=get_user_list();
|
|
|
|
|
if($online!==FALSE){
|
|
|
|
|
$rooms=array_keys($online);
|
|
|
|
|
$i=0;
|
|
|
|
|
$data["usercount"]=0;
|
|
|
|
|
$data["gdusercount"]=0;
|
|
|
|
|
if(!isset($online[""])){
|
|
|
|
|
foreach($rooms as $room){
|
|
|
|
|
if(($session->userdata['allow_grimdark']==0 || $session->userdata['uid']==0) && $online[$room]['g']=='grimdark'){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if($online[$room]["s"]=="locked"){
|
|
|
|
|
$data[$i]["room"]=$room . " <span style=\"color:red;\">[abgeschlossen]</span>";
|
|
|
|
|
}elseif($online[$room]["s"]=="password"){
|
|
|
|
|
$data[$i]["room"]=$room . " <span style=\"color:red;\">[password]</span>";
|
|
|
|
|
}else{
|
|
|
|
|
$data[$i]["room"]=$room . " <span style=\"color:green;\">[offen]</span>";
|
|
|
|
|
}
|
|
|
|
|
$users=array_keys($online[$room]["u"]);
|
|
|
|
|
foreach($users as $user){
|
|
|
|
|
if($data[$i]["users"]){
|
|
|
|
|
$data[$i]["users"].=', ';
|
|
|
|
|
}
|
|
|
|
|
if($online[$room]['g']=='grimdark'){
|
|
|
|
|
$data['gdusercount']++;
|
|
|
|
|
}else{
|
|
|
|
|
$data['usercount']++;
|
|
|
|
|
}
|
|
|
|
|
$data[$i]["users"].='<a href="//'.$config['domain'].'/np/'.$user.'" target="_blank"><span style="color:#'.$online[$room]["u"][$user].'">'.$user.'</span></a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $data;
|
|
|
|
|
}else{
|
|
|
|
|
$data["chat_offline"]=true;
|
|
|
|
|
$data["usercount"]=0;
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function chat_data(){
|
|
|
|
|
$online=get_user_list();
|
|
|
|
|
if($online!==FALSE){
|
|
|
|
|
$rooms=array_keys($online);
|
|
|
|
|
$i=0;
|
|
|
|
|
if(!isset($online[""])){
|
|
|
|
|
foreach($rooms as $room){
|
|
|
|
|
$users=array_keys($online[$room]["u"]);
|
|
|
|
|
foreach($users as $user){
|
|
|
|
|
$data[$i]["user"]=$user;
|
|
|
|
|
$data[$i]["room"]=$room;
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach($data as $user){
|
|
|
|
|
echo "(".$user["user"].") (".$user["room"].")\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
$data["chat_offline"]=true;
|
|
|
|
|
$data["usercount"]=0;
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-02 22:38:25 +02:00
|
|
|
|
?>
|