echo "WSM Version: " . WSM_VERSION . "\n";
if ($argc != 2) {
    usage(-1);
}
if ($argv[1] == 'delete') {
    $service_name = 'wsm';
    try {
        $service = new WSM_Service($service_name);
        $service->delete();
    } catch (WSM_RuntimeException $wsm_rEx) {
        exit($wsm_rEx->getMessage());
    }
    echo "Service removed...\n";
} elseif ($argv[1] == 'create') {
    /*
    WSM_Service WSM_Service::create(
                    string $service_name, 
                    string $path, 
                    string $param, 
                    long $start_type, 
                    string $display_name)
    */
    try {
        $service = WSM_Service::create('wsm', dirname(__FILE__) . '\\wsm.exe', NULL, SERVICE_DEMAND_START, 'Hello WSM Service');
        echo "Service installed...\n";
    } catch (WSM_RuntimeException $wsm_rEx) {
        exit($wsm_rEx->getMessage());
    }
} else {
    usage(-1);
}
    function adminService($action = null, $serviceID = null){
        
        ///Validate if the user has been loggen in
        if (parent::allowAccess()){        
        
            $service_name = '';
            $server_name = '';
            $TCPport = '';
			
            //Log Stuff
            $message1 = '';
            $message2 = '';

            if ($serviceID > 0)
                $TCPport = $this->getFormatterTCPPort($serviceID);
            else
                $TCPport = $this->getServerTCPPort(0);

            switch($serviceID){
                case 0:	$server_name = 'Servidor CONRED ' . $this->getFileVersion($this->config->item('server_exe_path')) . ' [TCP ' . $TCPport . ']';
                        $service_name = str_replace('.exe', '', end(explode('\\', $this->config->item('server_exe_path')))); //'jTranServer_Conred';	
                        break;
                case 1:	$server_name = 'Formateador COMCEL ' . $this->getFileVersion($this->config->item('comcel_formatter_exe_path')) . ' [TCP ' . $TCPport . ']';
                        $service_name = str_replace('.exe', '', end(explode('\\', $this->config->item('comcel_formatter_exe_path')))); //'jTranServer_ComcelFormatter';	
                        break;
                case 2:	$server_name = 'Formateador MOVILRED ' . $this->getFileVersion($this->config->item('movilred_formatter_exe_path')) . ' [TCP ' . $TCPport . ']';
                        $service_name = str_replace('.exe', '', end(explode('\\', $this->config->item('movilred_formatter_exe_path')))); //'jTranServer_MovilredFormatter';	
                        break;
                case 3:	$server_name = 'Formateador TIGO ' . $this->getFileVersion($this->config->item('tigo_formatter_exe_path')) . ' [TCP ' . $TCPport . ']';
                        $service_name = str_replace('.exe', '', end(explode('\\', $this->config->item('tigo_formatter_exe_path')))); //'jTranServer_TigoFormatter';	
                        break;			
            }

            $service= new WSM_Service($service_name);

            switch($action){
                //Start Service
                case 1: $service->start();
                        sleep(1);
                        $service->start();
                        $message1 = $server_name . ' Iniciado.';
                        break;
                //Stop Service
                case 2: $service->stop();
                        sleep(1);
                        $service->stop();
                        $message1 = $server_name . ' Detenido.';
                        break;                
                //Restart Service
                case 3: $service->stop();
                        sleep(1);
                        $service->start();
                        $service->start();
                        sleep(1);
						$message1 = $server_name . ' Reiniciado.';
                        break;
            }

			if ($action > 0 ){
                            //Log Action, Web Form
                            $this->saveLog($message1, $message2);				
			}
			
            $image = '';
            $text = '';

            if ($service->status() == SERVICE_RUNNING){
                    $image = '<img src=\'images/start.png\' />';
                    $text = 'Iniciado';
            } else {
                    $image = '<img src=\'images/stop.png\' />';
                    $text = 'Detenido';
            }

            echo "<h4>" . $server_name . "</h4>
                    <p>Estado Servicio: " . $text . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $image . "</p>
                    <br />
                ";        
        }
        else{
			//Deny Hacking Access
			parent::destroySession();
        }        
    }
Example #3
0
<?php

/* $Id: run.php,v 1.1 2005/08/14 16:45:23 aurelian Exp $ */
include_once 'functions.inc';
echo "WSM Version: " . WSM_VERSION . "\n";
$s = 'FastWork2-MySQL4';
$service = new WSM_Service($s);
if ($service->status() == SERVICE_STOPPED) {
    include_once 'start.php';
} else {
    include_once 'stop.php';
}