2 Replies Latest reply on Apr 27, 2006 9:17 PM by Scooby_Doobie_Doo

    how WOULD i write this in Cold Fusion?

    Scooby_Doobie_Doo
      This is a PHP function that shows me how many users are in my chatroom, but I don't know how to do this in Cold Fusion. I need to in order to see who's in my chat room. Any ideas on how I'd do this?

      Here's the working PHP code

      <?
      $port = 10010;
      function getServerAPI( $apiCommand ) {
      global $port;
      $result = "";
      $fp = fsockopen("localhost", $port, &$errno, &$errstr, 2);
      if(!$fp) {
      echo "$errstr ($errno)\n";
      } else {
      fputs($fp,"GET /?".$apiCommand." HTTP/1.0\n\n");
      $header = true;
      while(!feof($fp)) {
      $line = fgets($fp,128);
      if ( $header == false ) $result .= $line;
      if ( trim($line) == "" ) $header = false;
      }
      fclose($fp);
      }
      return $result;
      }

      $userCount = getServerAPI( "api.UserCount" );
      $roomList = getServerAPI( "api.RoomList" );
      $PeopleInRoom = getServerAPI("api.PeopleInRoom=The%20Lobby" );

      echo "<b>Users Online Now:</b> ".$PeopleInRoom."<br><br>";
      ?>