The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

php code

View previous topic View next topic Go down

php code

Post by punisher2202 on May 5th 2011, 5:08 pm

hello i have this php code it is php code for game server stats . i have a game server but I don't know how to put codes php into the forum.

my file php

Code:
<?php


function get_status($init_ip,$init_port)
 {
      $fp = fsockopen ("udp://" . $init_ip, $init_port, $errno, $errstr, 5);

        if (!$fp)        {$sv = "server not found";}

        else

        {

          $connection = true;
          $header = Chr(255) . Chr(255) . Chr(255) . Chr(255) . Chr(2);
          fputs($fp, $header . "getstatus");
          socket_set_timeout($fp, 1);
          $serverstatus = fread($fp, 5000);
          fclose($fp);
          $aServerStatus = explode(Chr(92),$serverstatus);

          For ($i=0;$i < count($aServerStatus);$i++)
        {
            If ($aServerStatus[$i]=="sv_hostname")            $sv['host'] = $aServerStatus[$i+1];
            If ($aServerStatus[$i]=="mapname")                $sv['map'] = $aServerStatus[$i+1];
            If ($aServerStatus[$i]=="timelimit")              $sv['time'] = $aServerStatus[$i+1];
            If ($aServerStatus[$i]=="g_gametypestring")      $sv['gamet'] = $aServerStatus[$i+1];
            If ($aServerStatus[$i]=="sv_maxclients")          $sv['maxplayers'] = $aServerStatus[$i+1];
            If ($aServerStatus[$i]=="sv_privateClients")      $sv['privatec'] = $aServerStatus[$i+1];

        }

          return $sv;
          }
 }
 //end function get_status///////////////////////////////////////////////////////
 
 
 
 
 
function  get_players($init_ip,$init_port_players)
{
      $no_players = "No Players on Server";
      $fp2 = fsockopen ("udp://" . $init_ip, $init_port_players, $errno, $errstr, 5);

        if (!$fp2) {$connection = false;}
       
        else
       
        {

          fputs($fp2, Chr(92)."players".Chr(92));
          socket_set_timeout($fp2, 1);
          $serverplayers = fread($fp2, 5000);
          fclose($fp2);
          $aServerPlayers = explode(Chr(92),$serverplayers);
          $k = 0;

      For ($j=0;$j<count($aServerPlayers);$j++)
        {
            If (SubStr($aServerPlayers[$j],0,7)=="player_")
              {

                $players[$k] = $aServerPlayers[$j+1];
                ++$k;
                              }
        }
        if (isset($players))
        {
        if (is_array($players))
          {
          for ($a=0;$a<count($players);$a++)
          {
            $splayers[$a] = $players[$a];
          }
          }
          }
          else
          {
          $splayers = $no_players;
          }

          return $splayers;
          }
 }
//end function get_players////////////////////////////////////////////////////////
 


function get_server($init_ip,$init_port,$init_port_players)
{
 $sv_stats = get_status($init_ip,$init_port);
  if (is_array($sv_stats))
  {
  switch (strtolower($sv_stats['map']))  {
                        case "dm/mp_stadt_dm":
                        {$map_pic = "server_mon/images/stadt";
                          $map_str = "Stadt";
                          break;}

                        case "dm/mp_brest_dm":
                        {$map_pic = "server_mon/images/brest";
                          $map_str = "Brest";
                          break;}

                        case "dm/mp_gewitter_dm":
                        {$map_pic = "server_mon/images/gewitter";
                          $map_str = "Gewitter" ;
                          break;}

                        case "dm/mp_malta_dm":
                        {$map_pic = "server_mon/images/malta";
                          $map_str = "Malta";
                          break;}

                        case "dm/mp_verschneit_dm":
                        {$map_pic = "server_mon/images/verschneit";
                          $map_str = "Verschneit";
                          break;}

                        case "dm/mp_bahnhof_dm":
                        {$map_pic = "server_mon/images/bahnhof";
                          $map_str = "Bahnhof";
                          break;}

                        case "dm/mp_unterseite_dm":
                        {$map_pic = "server_mon/images/unterseite";
                          $map_str = "Unterseite";
                          break;}

                        case "dm/mp_bazaar_dm":
                        {$map_pic = "server_mon/images/bazaar";
                          $map_str = "Bazaar";
                          break;}

                        case "dm/mp_holland_dm":
                        {$map_pic = "server_mon/images/holland";
                          $map_str = "Holland";
                          break;}


                        case "dm/mohdm1":
                        {$map_pic = "server_mon/images/mohdm1";
                          $map_str = "Southern France";
                          break;}

                        case "dm/mohdm2":
                        {$map_pic = "server_mon/images/mohdm2";
                          $map_str = "Destroyed Village";
                          break;}

                        case "dm/mohdm3":
                        {$map_pic = "server_mon/images/mohdm3";
                          $map_str = "Remagen";
                          break;}

                        case "dm/mohdm4":
                        {$map_pic = "server_mon/images/mohdm4";
                          $map_str = "Crossroads";
                          break;}

                        case "dm/mohdm5":
                        {$map_pic = "server_mon/images/mohdm5";
                          $map_str = "Snowy Park";
                          break;}

                        case "dm/mohdm6":
                        {$map_pic = "server_mon/images/mohdm6";
                          $map_str = "Stalingrad";
                          break;}

                        case "dm/mohdm7":
                        {$map_pic = "server_mon/images/algiers";
                          $map_str = "Algiers";
                          break;}
                         
                        case "dm/dmxfire";
                        {$map_pic = "server_mon/images/dmxfire";
                          $map_str = "Crossfire Courtyard";
                          break;}
                         
                        case "dm/harbourtown_final";
                        {$map_pic = "server_mon/images/harbour";
                          $map_str = "Harbourtown Final";
                          break;}
                         
                        case "dm/stalingrad-2";
                        {$map_pic = "server_mon/images/stal2";
                          $map_str = "Stalingrad 2 Full";
                          break;}
                         
                        case "dm/southern_france_2_final";
                        {$map_pic = "server_mon/images/sfr-final";
                          $map_str = "Southern France 2 Final";
                          break;}

                        default:
                        {$map_pic = "server_mon/images/nomappic";
                          $map_str = "Custom map";
                          break;}
                        }


  $sv_players = get_players($init_ip,$init_port_players);
  $content = "<table width=100% align=center border=1 > ";
  $content .="<tr><td colspan=3 class=cat align=center width=100%><span class=cattitle>".$sv_stats['host']." (".$init_ip.")</span></td></tr>";
  $content .="<tr><td width=40% valign=top><table cellspacing=1 width=100%>";
 
  if (is_array($sv_players))
  {
    for ($l=0;$l < count($sv_players);$l++)
      {
      $content .= "<tr><td class=code>".$sv_players[$l]."</td></tr>";
      }
      $s_players = count($sv_players);
  }
  else
  {
    $content .= "<tr><td align=center class=row1>".$sv_players."</td></tr>";
    $s_players = "0";
  }
 
  $content .="</table></td><td align=center width=50%>";
  $content .="<table align=center width=95%>";
  $content .="<tr><td class=code>".$map_str."(".$sv_stats['map'].")</td></tr>";
  $content .="<tr><td class=code>Time Limit: ".$sv_stats['time']." minutes</td></tr>";
  $content .="<tr><td class=code>Game Type: ".$sv_stats['gamet']."</td></tr>";
  $content .="<tr><td class=code>".$s_players."/".$sv_stats['maxplayers']." players</td></tr>";
  $content .="<tr><td class=code>".$sv_stats['privatec']." Private Slots</td></tr>";
 
  $content .="</table></td>";
  $content .="<td width=10% classe=forumline align=right>";
  $content .="<img src=".$map_pic."-sm.jpg></td></tr></table>";

  }
  else
  {
  $content = $sv_stats;
  }
  return $content;
}
//end function get_server/////////////////////////////////////////////////////////
 
//---add the IP of your server(s) to the lines below and uncomment them
// $sv1 = get_server('67.19.143.66','12203','12300');
// $sv2 = get_server('67.19.143.67','12203','12300');
// $sv3 = get_server('67.19.143.68','12203','12300');
// $sv4 = get_server('67.19.143.69','12203','12300');


// to add additional servers simply create another variable, i.e. $sv# and set equal to function get_server as above.
//then add the corresponding line below to display the server


?>


<!--///********content********-->
<center><span class="maintitle">[Your Clan Name] Spearhead Servers</span></center>
<?
// ---uncomment the lines below that correspond to the uncommented lines above
//  echo $sv1;
//  echo "<br>";
//  echo $sv2;
//  echo "<br>";
//  echo $sv3;
//  echo "<br>";
//  echo $sv4;
//  echo "<br>";
?>


and readme.txt :

Code:
////////////////////////////////////////////////
================================================================================
PHPMohMonitor
Version 1.01 (10/22/04)

Copyright (c) 2004 Bob Schacht
email: crusher@rindog.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================================================
//Thanks to [DAD]BoB for code portions        //
////////////////////////////////////////////////



Installation Time: 2 minutes.
Installation Difficulty: Super Easy
Files to edit: 2 (gmservers-forums.php and $phpbb_root_path/index.php)


<------------------------------------------------------------------------>
copy server_mon folder and gmservers-forums.php to forum directory

<------------------------------------------------------------------------>
Open gmservers-forums.php
  [--Find----------------------------------------------------]

      //---add the IP of your server(s) to the lines below and uncomment them
      // $sv1 = get_server('67.19.143.66','12203','12300');
  [--Uncomment one line for each server that you want to monitor and edit IP address and port numbers if needed---]
 
  [--Find ----------------------------------------------------]
      // ---uncomment the lines below that correspond to the uncommented lines above
      //  echo $sv1;
  [--Uncomment the line/s that correspond with the lines uncommented above --]

<------------------------------------------------------------------------>
Open index.php in your forums directory
  [--Find------------------------------------------------------]
 
    include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

  [--Before Add -----------------------------------------------]

    include($phpbb_root_path . 'gmservers-forums.php');
save index.php and enjoy
<------------------------------------------------------------------------->

please helpme

punisher2202
New Member

Posts : 4
Reputation : 0
Language : greek

Back to top Go down

Re: php code

Post by Base on May 5th 2011, 7:19 pm

Hi, because we don't have access to the database installing this would be impossible. Smile

Base
Forumaster

Male Posts : 10386
Reputation : 1687
Language : English and French
Location : United Kingdom, England

http://forumotionhub.net

Back to top Go down

Re: php code

Post by uafgrad on May 5th 2011, 7:37 pm

I am thinking this would also answer my question about affiliate links then (in another thread I made).

uafgrad
Forumember

Posts : 88
Reputation : 0
Language : English

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum