Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Webserver

Allgemeines zum Thema EventGhost
Post Reply
Pantau
Posts: 8
Joined: Thu Jun 29, 2006 10:07 pm

Webserver

Post by Pantau »

Hallo
Existiert ein Beispiel f├╝r den Webserver ?

Gruss
Beat
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

http://www.eventghost.org/downloads/Webserver_Demo.zip

Irgendwohin entpacken, das "Datenverzeichnis" in der Plugin-Konfiguration dann auf den "html" Ordner zeigen lassen und dann sollte es mit http://localhost/ losgehen.
Eggert
Posts: 14
Joined: Wed Nov 15, 2006 9:06 am

Post by Eggert »

Hallo,

gibt es eine M├Âglichkeit, die Features ohne javascript oder derartiges per html-link, also <a href...> ├╝bers Internet zu senden?

Danke f├╝r alle Tipps.
Eggert
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Das Ereignis wird einfach mit einem Fragezeichen an die URL angehängt. Z.B. so:

http://localhost/index.html?MeinEreignis
Eggert
Posts: 14
Joined: Wed Nov 15, 2006 9:06 am

Post by Eggert »

Suuuuuper, danke, Lars!

Welcher Quelltext ist denn daf├╝r verantwortlich, dass EG den string versteht?
Also, was ist der minimalste quelltext f├╝r die index.html, damit das geht?

Und: kann man den Werbserver mit einem Passwort versehen?

Danke!
Eggert
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Der minimalste Text: Es ist v├Âllig egal, was sich unter der URL befindet. EG wertet alles nach dem Fragezeichen als Ereignis aus und versucht dann den Anfang der URL an den Webbrowser zu schicken.

Passwort geht nicht. Wenn man es tatsächlich außerhalb seines Intranets verwenden will, dann muss man schon einen richtigen Webserver wie Apache nehmen. Da kann man z.B. mit einem PHP-Skript das Gleiche erreichen.
Eggert
Posts: 14
Joined: Wed Nov 15, 2006 9:06 am

Post by Eggert »

Das funktioniert fantastisch!

Da ich mehrere Programme per WebInterface steuern wollte, hätte ich gerne so viele es geht unter einem Hut, also gesteuert mit einem Webserver, das von Dir erwähnte Apache z.B.

Gibt es ein fertiges Skript, das mir das Benutzen eines externen Webservers erlaubt? So eine Art Schnittstelle zum Apache?

Ansonsten wäre ich mit dem PHP-Skript, das beide kombiniert, mehr als glücklich.

Danke,
Eggert
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Post by Bitmonster »

Ich verwende dieses PHP-Skript f├╝r meinen Apache-Webserver:

Code: Select all

<?
function sendMsg($args)
{
    $fp = fsockopen($args["host"],$args["port"], $errno, $errstr, 10);
    
    if (!$fp)
    { //Something didn't work....
        echo "ERROR: $errno - $errstr\n";
        return FALSE;

    } else {

        // First wake up the server, for security reasons it does not
        // respond by it self it needs this string, why this odd word ?
        // well if someone is scanning ports "connect" would be very obvious
        // this one you'd never guess :-)
        
        fputs($fp, "quintessence\n\r");
        
        // The server now returns a cookie, the protocol works like the
        // APOP protocol. The server gives you a cookie you add :<password>
        // calculate the md5 digest out of this and send it back
        // if the digests match you are in.
        // We do this so that noone can listen in on our password exchange
        // much safer then plain text.
        
        $cookie = fgets($fp, 400);		
        
        // Trim all enters and whitespaces off
        $cookie = trim($cookie);
        
        // Combine the token <cookie>:$args[pword]
        $token = $cookie . ":" . $args["password"];
        
        // Calculate the digest
        $digest = md5($token);
        
        // add the enters
        $digest = $digest . "\n";
                
        // Send it to the server		
        fputs($fp, $digest );
        
        // Get the answer
        $res = fgets($fp, 400);
        
        // If the password was correct and you are allowed to connect
        // to the server, you'll get "accept"
        if ( trim($res) != "accept" )
        {
             fclose($fp);
             return FALSE;
        }
        
        if (isset($args['payload']))
        {
            if (is_array($args['payload']))
            {
                foreach($args['payload'] as $key => $value)
                    fputs($fp, "payload " . $value . "\n");
            }else
            {
                if ( $args["payload"] <> "" )
                    fputs($fp, "payload ".$args["payload"]."\n");		
            }		
        }
        // now just pipe those commands to the server
        fputs($fp, $args["eventstring"]."\n");
        
        // tell the server that we are done nicely.
        fputs($fp, "close\n");
        
        fclose($fp);
            
        return TRUE;
    }
}


if (isset($_GET))
{	
    if(isset($_GET['host']))
        $args['host'] = urldecode($_GET['host']);
    else
        $args['host'] = '127.0.0.1';
    $args['port'] = 32333;
    $args['password'] = 'password';
    $args['eventstring'] =  urldecode($_GET['event']);
    foreach($_GET as $key => $value)
        if(strcasecmp(substr($key, 0, 3), 'pld') == 0)
            $args['payload'][] = urldecode($value);
    sendMsg($args);
    if(!isset($_GET['REFERER']))
        $_GET['REFERER'] = "index.html";
    header("Location: http://".$_SERVER['HTTP_HOST']
           . dirname($_SERVER['PHP_SELF'])
           ."/".$_GET["REFERER"]);
}
?>

Die Password- und Port-Variablen m├╝ssen entsprechend angepasst werden. Der zu verwendende Link ist auch anders als bei dem EG-Webserver. Der sieht etwa so aus:
http://localhost/wo_immer_es_auch_liegt ... seite.html

REFERER ├╝bergibt dann die Seite die dem User nach der Ausf├╝hrung des Skriptes angezeigt werden soll.

Das Skript ist eigentlich f├╝r Girder gedacht gewesen, aber da EG das gleiche Protokoll verwendet, funktioniert es da auch.
Post Reply