From 7e73fc49567f4324a9e7b26e1a6a20e3049d6786 Mon Sep 17 00:00:00 2001 From: genuineparts Date: Mon, 16 Jun 2025 17:59:01 +0200 Subject: [PATCH] Fixed adminpanel --- modules/chat/admin/manage.apnl.php | 57 ++++++++++++++---------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/modules/chat/admin/manage.apnl.php b/modules/chat/admin/manage.apnl.php index 702c21a..2b44015 100644 --- a/modules/chat/admin/manage.apnl.php +++ b/modules/chat/admin/manage.apnl.php @@ -35,10 +35,8 @@ class manage_chat_panel extends admin_module{ global $config, $db,$panel, $cache, $session; if(isset($_POST['start'])){ $istat = $this->get_status(); - exec('/bin/systemctl status austria|grep running',$cat); - $cat = trim($cat[0]); - if($istat==2 && $cat!="not"){ - shell_exec("kill -9 ".$cat); + if($istat['status']==2){ + shell_exec("kill -9 ".$istat['pid']); sleep(5); shell_exec("sudo /bin/systemctl restart austria"); }else{ @@ -47,10 +45,12 @@ class manage_chat_panel extends admin_module{ $panel->admin_message("Triggered", 'The Chatstart has been triggered. please refresh the page to see if it was successful.',TRUE,"manage_chat"); }elseif(isset($_POST['emergency'])){ $istat = $this->get_status(); - if($istat==1){ - shell_exec("sudo /sbin/restart topia"); - }elseif($istat==2){ - shell_exec("sudo /sbin/restart topia"); + if($istat['status']==1){ + shell_exec("sudo /bin/systemctl restart austria"); + }elseif($istat['status']==2){ + shell_exec("kill -9 ".$istat['pid']); + sleep(5); + shell_exec("sudo /bin/systemctl restart austria"); } $panel->admin_message("Triggered", 'The Emergency Chatrestart has been triggered. please refresh the page to see if it was successful.',TRUE,"manage_chat"); }else{ @@ -74,40 +74,37 @@ class manage_chat_panel extends admin_module{ function get_readable_status($status){ global $db, $config, $cache, $log; - if($status==1){ - exec('/sbin/status topia|awk \'{ print $4}\'',$cat); - $cat = trim($cat[0]); - return 'OK - Running - Process ID: '.$cat.''; - }elseif($status==2){ - exec('/sbin/status topia|awk \'{ print $4}\'',$cat); - $cat = trim($cat[0]); - return 'ALERT - Zombie - Process ID: '.$cat.''; + if($status['status']==1){ + return 'OK - Running - Process ID: '.$status['pid'].''; + }elseif($status['status']==2){ + return 'ALERT - Zombie - Process ID: '.$status['pid'].''; }else{ return 'ALERT - Stopped'; } } function get_status(){ - global $db, $config, $cache, $log; - $dat="/sbin/status topia|awk '{ print $4}'"; + $dat='/bin/systemctl status austria|grep "Main PID"'; exec($dat,$cat); - $cat = trim($cat[0]); - if($cat!='not'){ - exec("ps ax|grep ".$cat."|grep -v grep",$ps); + $data = explode(" ",$cat[0]); + $r['pid'] = $data[5]; + exec("ps ax|grep ".$r['pid']."|grep -v grep",$ps); + if(empty($ps)){ + $r['status'] = 0; + } else { $psr = preg_split("/\s/", $ps[0]); $psr = $this->removeEmptyValues($psr); $status = $psr[2]; $status=substr($status, 0, 1); - if($status=="S"||$status=="R"){ - return 1; - }elseif($status=="Z"){ - return 2; - }else{ - return 0; - } - }else{ - return 0; + if($status=="S"||$status=="R"){ + $r['status'] = 1; + }elseif($status=="Z"){ + $r['status'] = 2; + }else{ + $r['status'] = 0; + } } + return $r; } function removeEmptyValues($ar)