logolinksrand Hamburg City Freelancer Server Foren-Übersicht
Players:2/69    *Mod here*
Server Load:1 msec 
Deaths per Minute:0
logorechts  
  SERVERIP : hc.flserver.de:2302
Discord Community: https://discord.gg/kH7wFRG


 
   
  Portal  •  Forum-FAQ  •   Suchen  •  Registrieren  •  Einloggen, um private Nachrichten zu lesen  •  Login  
  Donation/Spenden  •   Donation List  •   HC Forum Rangsystem Info  •   Player Rankings  •   Banned Players  
/

   
 php Webinterface for flhook / flcharadmin Nächstes Thema anzeigen
Vorheriges Thema anzeigen
Neues Thema eröffnenNeue Antwort erstellen
Autor Nachricht
Niwo



developer kreuz_gold

Webmissions: 21


Beiträge: 6495
Wohnort: Hamburg

Beitrag Titel: php Webinterface for flhook / flcharadmin
Verfasst am: 26.02.06 17:39
Antworten mit ZitatNach oben

Hi,

now i will release step by step the basis Technologies we use on HC Server.

It would be fine if changes/new features will be backposted to this forum .. thx for that.

Here we go, the first base technic it to have scriptable access to the flhook / flcharadmin commands (note flcharadmin is not released a this time)

flwebadmin.php
Code:

<?php
   require('telnet.class.php');
   require('flwebadmin_include.php');
   if ( !isset($_POST["cmd"]))
      $cmd = '';
   else
      $cmd = $_POST["cmd"];
?>

<html>
<head>
<title>FlAdmin/FlCharAdmin php Frontend V0.1</title>
</head>
<body>
<center>
<table>
<tr><td>FlAdmin/FlCharAdmin php Frontend V0.1</td></tr>
<tr><td>
<form method="post" action="flwebadmin.php">
<input type="text" name="cmd" size="30" maxlength="100" value=<?php echo "\"$cmd\""?>>
<input type="submit" value="Ausführen">
</form>
</td></tr>
<tr><td>
<?php
if (    preg_match("/ban/i", $cmd)
     || preg_match("/enable/i", $cmd)
     || preg_match("/disable/i", $cmd)
     || preg_match("/flush commands/i", $cmd)
     || preg_match("/kick/i", $cmd)
     || preg_match("/list commands/i", $cmd)
     || preg_match("/message/i", $cmd)
     || preg_match("/start/i", $cmd)
     || preg_match("/stop/i", $cmd)
     || preg_match("/unban/i", $cmd)
) {
   echo "<b>FLAdmin:</b><br>";
   $tn = new telnet($fladminhost,$fladminport);
   if ( $tn->sock ) {
      $tn->sethtml(true);
      $tn->read_till('PASSWORD? ');
      $tn->write("$fladminpassword\r\n");
      $tn->read_till('COMMAND> ');
      $tn->write("$cmd\r\n");
      echo $tn->read_till('COMMAND> ');
      $tn->write("logout\r\n");
      $tn->close();
   } else {
      echo "Connection Error: Can't connect to FLAdmin";
   }
}
if (    preg_match("/dumphtml/i", $cmd)
     || preg_match("/updateindex/i", $cmd)
     || preg_match("/loadindex/i", $cmd)
     || preg_match("/printindex/i", $cmd)
     || preg_match("/search /i", $cmd)
     || preg_match("/addmoney/i", $cmd)
     || preg_match("/update/i", $cmd)
     || preg_match("/list commands/i", $cmd)
     || preg_match("/help/i", $cmd)
     || preg_match("/get/i", $cmd)
) {
   echo "<br><hr><b>FLCharAdmin:</b><br>";
   $tn = new telnet($flcharadminhost,$flcharadminport);
   if ( $tn->sock ) {
      $tn->read_till('PASSWORD? ');
      $tn->write("$flcharadminpassword\r\n");
      $tn->read_till('COMMAND> ');
      $tn->write("$cmd\r\n");
      if ( $cmd != "dumphtml" )
         $tn->sethtml(true);
      echo $tn->read_till('COMMAND> ');
      $tn->write("logout\r\n");
      $tn->close();
   } else {
      echo "Connection Error: Can't connect to FLCharAdmin";
   }
}
?>
</td></tr>
</table>
</center>
<br><br><hr><small>(c) Niwo 2003</small>
</body>
</html>


telnet.class.php
Code:

<?
error_reporting(0);

class Telnet {
   // [email protected] 2001
   // patched by Niwo 2003 ([email protected])

   var $sock = NULL;
//   var $readbuf = '';
//   var $idxreadbuf = -1;
   var $htmloutput = false;

   function telnet($host,$port) {
    $this->sock = fsockopen($host,$port);
      socket_set_timeout($this->sock,2,0);
   }   

    function close() {
        if ($this->sock)
            fclose($this->sock);
        $this->sock = NULL;
   }

    function write($buffer) {
      $buffer = str_replace(chr(255),chr(255).chr(255),$buffer);
        fwrite($this->sock,$buffer);
   }

   function getc() {
//      if ( $this->idxreadbuf != strlen($this->readbuf) ) {
//         $this->readbuf = fread($this->sock, 1);
//         $this->idxreadbuf = 0;
//      }
//      return substr($this->readbuf,$this->idxreadbuf,1);
      return fgetc($this->sock);
   }

    function read_till($what)  {
        $buf = '';
      while (1) {
         $IAC  = chr(255);

         $DONT = chr(254);
         $DO   = chr(253);

         $WONT = chr(252);
         $WILL = chr(251);

         $theNULL = chr(0);

         $c = $this->getc();

         if ($c === false)
           if ( $this->htmloutput )
              return str_replace("\n",'<br>',$buf);
           else
              return $buf;

         if ($c == $theNULL) {
            continue;
         }

         if ($c == "\021") {
            continue;
         }

         if ($c != $IAC) {
            $buf .= $c;

            if ($what == (substr($buf,strlen($buf)-strlen($what)))) {
               if ( $this->htmloutput )
                  return str_replace(chr(13).chr(10),'<br>',substr($buf,0,strlen($buf)-strlen($what)));
               else
                  return substr($buf,0,strlen($buf)-strlen($what));
            } else {
               continue;
            }
         }

         $c = $this->getc();

         if ($c == $IAC) {
            $buf .= $c;
         } else if (($c == $DO) || ($c == $DONT)) {
            $opt = $this->getc();
         //   echo "we wont ".ord($opt)."\n";
            fwrite($this->sock,$IAC.$WONT.$opt);
         } elseif (($c == $WILL) || ($c == $WONT)) {
            $opt = $this->getc();
         //   echo "we dont ".ord($opt)."\n";
            fwrite($this->sock,$IAC.$DONT.$opt);
         } else {
         //   echo "where are we? c=".ord($c)."\n";
         }
      }

   }

   function sethtml($bool) {
      $this->htmloutput = $bool;
   }
}
?>


flwebadmin_include.php
Code:

<?php
   $fladminhost = "1.2.3.4";
   $fladminport = "6331";
   $fladminpassword = "pw";
   $flcharadminhost = "1.2.3.4";
   $flcharadminport = "6332";
   $flcharadminpassword = "pw";
?>


index.html
Code:

<html>
<head>
<title>Freelancer Server Web Admin Menu</title>
</head>
<body>
<center>
Freelancer Server Web Admin Menu
<hr>
<a href="flwebadmin.php">FlAdmin/FlCharAdmin php Frontend V0.1</a>
</center>
<br><br><hr><small>(c) Niwo 2003</small>
</body>
</html>


BTW: I save this Dir on the Webserver by a simply .htaccess file.

.htaccess
Code:

AuthUserFile /home/.../htpasswd
AuthType Basic
AuthGroupFile /dev/null
AuthName "Admin Bereich"

<Limit GET POST>
   order allow,deny
   allow from all

   require valid-user
</Limit>


If you are know what CVS is, all me sources are in a CVS archiv .. it could be usefull to configure a public CVS Server for that what we start today

but now have fun so far and stay tuned

geets Niwo
Niwo is offline Benutzer-Profile anzeigenPrivate Nachricht senden
Master Merlin







Beiträge: 13

Beitrag Titel:
Verfasst am: 29.11.07 22:49
Antworten mit ZitatNach oben

Reportin an error: i executed th "closeserver" command; but the server didn't closed, any resolution?
Master Merlin is offline Benutzer-Profile anzeigenPrivate Nachricht senden
Beiträge der letzten Zeit anzeigen:      
Neues Thema eröffnenNeue Antwort erstellen


 Gehe zu:   



Nächstes Thema anzeigen
Vorheriges Thema anzeigen
Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.


 



AD(S)-Hilfe
Last 10 Deaths





   
  13 users on website
powered by 230 volt, phpBB with modifications by Niwo. Alle Zeiten sind GMT + 1 Stunde
Servertime: 18:29:11


Spendenkontostand / donating account balance
Page generation time: 0.8489s (PHP: 11% - SQL: 89%) - SQL queries: 27 - GZIP disabled - Debug off