FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


socket-connections allowed?





Moe479
before i make request for hosting my site i want to know if it is possible to control a gameserver via socket-connections from this space?

another thing im intrested in is gd2-support for the gallary i like to use, how about that?
Bondings
Gd is installed and working fine.

About the socket connections for the gameserver, that's not allowed.
n0obie4life
Bondings, do you know what he's talking about?

fsockopen then send commands to the server..that's not allowed???
Moe479
its not to host a gameserver itself, its about a php-script that send & recive ascii massages trough a socket-connection to/from the gameserver:

telnet.class.php:
Code:

<?
//error_reporting(0);

class Telnet {
   // thies@thieso.net 2001
   // patched by Niwo 2003 (niwo@freelancerserver.de)

   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;
   }
}
?>


config.php:
Code:

<?php
// Connection Settings
$host = "1.2.3.4";
$port = "1234";
$pass = "blabla";
?>


console.php:
Code:

<?php
require('config.php');
require('telnet.class.php');

if ( !isset($_POST["cmd"])) $cmd = '';
else $cmd = $_POST["cmd"];

?>
<html>
<head><title>FLWebHook-Console</title></head>
<body>
<b><i><font size="4" face="Arial">FLWebHook-Console:</font></i></b><br><hr>
<?php
if (   preg_match("/getplayerids/i", $cmd)
    || preg_match("/getplayers/i", $cmd)
    || preg_match("/getplayerinfo/i", $cmd)
    || preg_match("/serverinfo/i", $cmd)
    ) {
   echo "<b>FLHook:</b><br>";
   $tn = new telnet($host,$port);
   if ( $tn->sock )  {
      $tn->read_till('authenticate ');
      $tn->write("pass $pass\r\n");
      $tn->read_till('OK ');
      $tn->write("$cmd\r\n");
      echo $tn->read_till('OK ');
      $tn->write("quit\r\n");
      $tn->close();
   } else {
      echo "FLWebHook-Error: Can not connect to FLHook!";
   }
}
?>
<hr>
<form method="post" action="console.php">
<input type="text" name="cmd" size="40" maxlength="100" value=<?php echo "\"$cmd\""?>><input type="submit" value="Send">
</form>
<br>
<br>
<small>(c) MOE 2006</small> </p>
</body>
</html>
n0obie4life
Yes, that's what I'm trying to tell Bondings.

I think he misunderstood you.

I know what you are talking about..
Related topics
Python and CPU load
Viewing sql errors from phpMyAdmin
PHP-based Chatroom
Ftp Connecting Data Socket Problem....
Any admins online now?
My password
How many concurrent sql connections?
The Best 939 socket motherboard
HELP!!! How to create XML Socket
Need help of a XML Socket Server
Can't create socket while using ftp access
Ftp problem
FTP Error
is it allowed ?
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.