SetProperty( "C_System_Services_Socks_Enabled", 1 ); $api->Save(); break; case "LDAP": case "SIP": $api->SetProperty( "C_System_Services_".$serv."_Enable", 1 ); $api->Save(); break; case "FTP": $api->SetProperty("C_FTPService_Active", 1); $api->Save(); break; default: $stat->start( $serv ); break; } $needReload = 1; } function StopService( $serv ) { global $needReload, $skindata, $api, $stat; switch($serv){ case "SOCKS": $api->SetProperty( "C_System_Services_Socks_Enabled", 0 ); $api->Save(); break; case "LDAP": case "SIP": $api->SetProperty( "C_System_Services_".$serv."_Enable", 0 ); $api->Save(); break; case "FTP": $api->SetProperty("C_FTPService_Active", 0); $api->Save(); break; default: $stat->stop( $serv ); break; } $needReload = 1; $skindata['reload'] = 1; } function RestartService( $serv ) { StopService( $serv ); StartService( $serv ); } function RestartAllServices() { global $act_services; foreach ( $act_services as $serv ) RestartService( $serv ) ; } function StartAllServices() { global $act_services; foreach ( $act_services as $serv ) StartService( $serv ) ; } $api = createobject("api"); $stat = createobject("statistics"); //@$api->UpdateConfiguration; $os_linux = $api->GetProperty( "C_OS" ); //Labels $labels = explode("|",$alang["TConfigForm_ServicesList"]); $skindata['charset'] = $encoding; $skindata['service'] = $labels[0]; $skindata['protocol'] = $labels[1]; $skindata['state'] = $labels[2]; $skindata['rtime'] = $labels[3]; $skindata['connections'] = $labels[4]; $skindata['peak'] = $labels[5]; $skindata['total'] = $labels[6]; $skindata['data'] = $labels[7]; $skindata['memory'] = $labels[8]; $skindata['path'] = $skin_dir; //Buttons $skindata['refresh'] = $alang["TStatisticsForm_ChartRefreshButton"]; $skindata['start'] = $alang["TConfigForm_StartButton"]; $skindata['stop'] = $alang["TConfigForm_StopButton"]; $skindata['properties'] = $alang["TConfigForm_ServiceEditButton"]; $skindata['restart'] = $alang["TConfigForm_RestartButton"]; $skindata['restartall'] = $alang["TConfigForm_RestartAllButton"]; $skindata['startall'] = $alang["TConfigForm_StartAllItem"]; //Services array if ( $os_linux ) $services = Array ("SMTP","POP3","IMAP","Control","FTP","GW","IM","VoIP"); else $services = Array ("SMTP","POP3","IMAP","Control","FTP","GW","IM","SIP","LDAP","SOCKS"); $act_services = Array ( "SMTP", "POP3", "IM", "GW" ); //Handle action - start / stop / restart all $skindata['reload']=0; $needReload = 0; switch(@$_REQUEST['s_action']) { case 'start': StartService( $service ); if ( $needReload ) @$api->ReloadServices; break; case 'stop': StopService( $service ); if ( $needReload ) @$api->ReloadServices; break; case 'restart_one': RestartService( $service ); if ( $needReload ) @$api->ReloadServices; break; case 'restart': RestartAllServices(); if ( $needReload ) @$api->ReloadServices; @$api->UpdateConfiguration; break; case 'startall': StartAllServices(); if ( $needReload ) @$api->ReloadServices; @$api->UpdateConfiguration; break; } function getvalue($val, $running) { return /*($running)?*/(string)$val/*:""*/; } $i = 0; foreach ($services as $v){ if (($v=="LDAP" || $v=="FTP") && osversion=="linux" ) continue; $i++; switch($v){ /*case "LDAP": if (osversion=="linux") continue; $running = $stat->Poll($v); //$running = $api->GetProperty("C_System_Services_LDAP_Enable"); break;*/ /*case "FTP": if (osversion=="linux") continue; $running = $stat->Poll($v); //$running = $api->GetProperty("C_FTPService_Active"); break;*/ case "SIP": $running = $stat->Poll($v); $running = $api->GetProperty("C_System_Services_SIP_Enable"); break; default: /*$running = */$stat->Poll($v); $running = $stat->IsRunning($v); break; } $item = array(); $item["service"] = $v; $item["even"] = $i%2; if ($running) { $item["state"] = $alang["TStrings_servicerunning"]; $item["img"] = $skin_dir.'images/s_on.gif'; } else{ $item["state"] = $alang["TStrings_servicenotrunning"]; $item["img"] = $skin_dir.'images/s_off.gif'; } //if ($v!="LDAP") //{ if($stat->GetProperty("ST_RunningTime")!=-1) $item["rtime"] = getvalue(timetostr($stat->GetProperty("ST_RunningTime")), $running); $item["connections"] = (string) getvalue($stat->GetProperty("ST_Server") + $stat->GetProperty("ST_Client") , $running); $item["peak"] = (string) getvalue($stat->GetProperty("ST_ClientPeak")+$stat->GetProperty("ST_ServerPeak"), $running); $item["data"] = (string) getvalue(round(($stat->GetProperty("ST_ServerIn")+$stat->GetProperty("ST_ServerOut"))/1024,2), $running); $item["total"] = (string) getvalue(($stat->GetProperty("st_serverconns")+$stat->GetProperty("ST_Server") + $stat->GetProperty("ST_Client")), $running); $item["memory"] = (string) getvalue(round($stat->GetProperty("ST_PageFileUsage")/(1024*1024),2), $running); if ( !$item["connections"] ) $item["connections"] = (string) "0"; if ( !$item["peak"] ) $item["peak"] = (string) "0"; if ( !$item["total"] ) $item["peak"] = (string) "0"; //} if ($v=='Control'){ $item["connections"]--; $item["total"]--; } $item["checked"] = ''; if (@$service==$v) { $item["checked"]='checked="checked"'; $skindata["selected"]=$v; } if($item['service']=='SIP'){ $item['label'] = 'VoIP'; $item['protocol'] = 'SIP'; } if($item['service']=='IM'){ $item['label'] = 'Instant Messaging'; $item['protocol'] = 'XMPP'; } if($item['service']=='GW'){ $item['label'] = 'GroupWare'; $item['protocol'] = 'GW'; } if($item['service']=='Control'){ $item['label'] = 'Control'; $item['protocol'] = 'HTTP,RCP'; } if(!$item['protocol']){ $item['protocol'] = $v; } $items[] = $item; } $skindata['serv']['num'] = $items; echo template ($skin_dir.'tree/services.tpl',$skindata); ?>