Jump to content

Recommended Posts

Hi,

I have the following code to change font color from within an IF staement but I can't seem to sort it out.

 

//code

if ($server['b']['ip'] == $adminarray1[6] && $server['b']['c_port'] == $adminarray2[6] && $player['name'] == $adminarray3[6])

{

$player['name'] = "<font color='blue'>{$server['p'][$key]['name']}</font>";

}

//code

 

any help would be greatly appreciated.

-Dodge

Link to comment
https://forums.phpfreaks.com/topic/234245-change-font-color-in-if-statement/
Share on other sites

my apologies.

ok I will try to be clearer. this is the code I am using ...

 

<?php

  global $lgsl_config, $lgsl_zone_number;

  if (!isset($lgsl_zone_number)) { exit("LGSL PROBLEM: $lgsl_zone_number NOT SET"); }

  require "lgsl_class.php";
  include "lgsl_newest_maps.php";
  include "lgsl_server_admins.php";
  
  
  $zone_width = $lgsl_config['zone']['width']."px";
  $zone_grid  = isset($lgsl_config['grid'][$lgsl_zone_number]) ? $lgsl_config['grid'][$lgsl_zone_number] : 1;
  $zone_count = 0;

//------------------------------------------------------------------------------------------------------------+

  $request     = empty($lgsl_config['players'][$lgsl_zone_number]) ? "s" : "sep";
  $server_list = lgsl_query_group( array( "request"=>$request, "zone"=>$lgsl_zone_number ) );
  $server_list = lgsl_sort_servers($server_list);

//------------------------------------------------------------------------------------------------------------+

  if (!$server_list)
  {
    $output .= "<div style='margin:auto; text-align:center'>NO SERVERS IN ZONE {$lgsl_zone_number}</div>"; return;
  }


//------------------------------------------------------------------------------------------------------------+

  $output .= "
  <table cellpadding='0' cellspacing='0' style='width:100%; margin:auto; text-align:center'>
    <tr>";

    foreach ($server_list as $key => $server)
    {
      $server = lgsl_sort_players($server);
      $misc   = lgsl_server_misc($server);
      $server = lgsl_server_html($server);

//------------------------------------------------------------------------------------------------------------+
      if ($zone_count != 0 && !($zone_count % $zone_grid))
      {
        $output .= "
        </tr>
        <tr>";
      }

      $zone_count ++;
//------------------------------------------------------------------------------------------------------------+

      $output .= "
      <td style='padding-top:5px; padding-bottom:5px; vertical-align:top; text-align:center'>

        <table style='width:{$zone_width}; margin:auto; text-align:center' cellpadding='0' cellspacing='2'>

          <tr>
            <td title='{$lgsl_config['text']['slk']}' style='padding:0px; text-align:center'>
              <div style='left:0px; right:0px; top:0px; bottom:0px; width:{$zone_width}; white-space:nowrap; overflow:hidden; text-align:center'>
                <a href='{$misc['software_link']}' style='text-decoration:none'>
                  {$server['b']['ip']}:{$server['b']['c_port']}
                </a>
              </div>
            </td>
          </tr>

          <tr>
            <td title='{$server['s']['name']}' style='padding:0px; text-align:center'>
              <div style='left:0px; right:0px; top:0px; bottom:0px; width:{$zone_width}; white-space:nowrap; overflow:hidden; text-align:center'>
                {$server['o']['comment']}
              </div>
            </td>
          </tr>

          <tr>
            <td style='padding:0px; text-align:center'>
              <div style='left:0px; right:0px; top:0px; bottom:0px; width:{$zone_width}; padding:0px; position:relative'>
                <p align='center'>America's Army 2.8.5</p>
			<a href='".lgsl_link($server['o']['id'])."'>

                  <img alt='' src='{$misc['image_map']}'          title='{$lgsl_config['text']['vsd']}' style='border:none; vertical-align:middle' />
                  <img alt='' src='{$misc['image_map_password']}' title='{$lgsl_config['text']['vsd']}' style='border:none; position:absolute; z-index:2; top:0px; left:0px;' />
                  <img alt='' src='{$misc['icon_game']}'          title='{$misc['text_type_game']}'     style='border:none; position:absolute; z-index:2; bottom:4px; left:4px;' />
                  <img alt='' src='{$misc['icon_location']}'      title='{$misc['text_location']}'      style='border:none; position:absolute; z-index:2; bottom:4px; right:4px;' />
                </a>
              </div>
            </td>
          </tr>

          <tr>
            <td title='{$server['s']['map']}' style='padding:0px; text-align:center'>
              <div style='left:0px; right:0px; top:0px; bottom:0px; width:{$zone_width}; white-space:nowrap; overflow:hidden; text-align:center'>
                <p align='center' title='Map name is {$server["s"]["map"]}'><a href='map_dload.php?name={$server['s']['map']}'><font color='lightgreen' size=2>{$server['s']['map']}</font></a><br />
                    <align='center' title='{$server["s"]["map"]} map layout'><a href='layout.php?name={$server['s']['map']}'><font color='lightgreen' size=2>Map Layout</font></a><br />
				<a href='http://www.gametracker.com/server_info/{$server['b']['ip']}:{$server['b']['c_port']}/top_players/' target='_blank' title='Player scores provided by gametracker'><font color='lightgreen' size=2>Player Scores</font></a></p>
	      </div>
            </td>
          </tr>";

//This section is for New map to show on trackers. If you want more or less then also change lgsl_newest_maps.php limit to same.		  
	  
	  
	if ($server['s']['map']==$myarray[0]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[0]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[1]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[1]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[2]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[2]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[3]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[3]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[4]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[4]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[5]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[5]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[6]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[6]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[7]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[7]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[8]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[8]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[9]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[9]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[10]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[10]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[11]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[11]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[12]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[12]'>---- New Map ----</font></span>
              </td>
          </tr>";
	}

	if ($server['s']['map']==$myarray[13]){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on $myarray2[13]'>---- New Map ----</font></span>
              </td>
          </tr>";
	  }


	 if ($server['p'] && $lgsl_config['players'][$lgsl_zone_number])
        {
          $zone_height = $lgsl_config['zone']['line_size'] * (count($server['p']) + 2);
          $zone_height = $zone_height > $lgsl_config['zone']['height'] ? "{$lgsl_config['zone']['height']}px" : "{$zone_height}px";

          $output .= "
          <tr>
            <td style='padding:4px; border:4px double'>
              <div style='left:0px; right:0px; top:0px; bottom:0px; width:{$zone_width}; height:{$zone_height}; overflow:auto; text-align:left'>
                <span style='padding:1px; float:left'> {$lgsl_config['text']['zpl']} </span>
                <span style='padding:1px; float:right'> {$server['s']['players']} / {$server['s']['playersmax']} </span>
                <br />
                <br />";
    
//Hard coded Server Owner Names. May need brackets around player name

foreach ($server['p'] as $key => $player)
{
if ($server['b']['ip'] == '205.234.152.101' && $server['b']['c_port'] == 1716 && $player['name'] == '-=[FSD]=-TOGA')
{
$player['name'] = "{$server['p'][$key]['name']} --Owner"; 
}

if ($server['b']['ip'] == '65.99.193.91' && $server['b']['c_port'] == 1716 && $player['name'] == 'dodgeitorelse')
{
$player['name'] = "{$server['p'][$key]['name']}"; 
}

if ($server['b']['ip'] == '65.99.193.92' && $server['b']['c_port'] == 1716 && $player['name'] == ChevyNightmare)
{
$player['name'] = "Owner- {$server['p'][$key]['name']}"; 
}

if ($server['b']['ip'] == '65.99.193.93' && $server['b']['c_port'] == 1716 && $player['name'] == ChevyNightmare)
{
$player['name'] = "Owner- {$server['p'][$key]['name']}"; 
}

if ($server['b']['ip'] == '216.221.12.120' && $server['b']['c_port'] == 1716 && $player['name'] == '-{KWK}-Kman')
{
$player['name'] = "Owner- {$server['p'][$key]['name']}"; 
}


//Admin names retrieved from database. Count should be 1 less than database.

if ($server['b']['ip'] == $adminarray1[0] && $server['b']['c_port'] == $adminarray2[0] && $player['name'] == $adminarray3[0])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[1] && $server['b']['c_port'] == $adminarray2[1] && $player['name'] == $adminarray3[1])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[2] && $server['b']['c_port'] == $adminarray2[2] && $player['name'] == $adminarray3[2])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[3] && $server['b']['c_port'] == $adminarray2[3] && $player['name'] == $adminarray3[3])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[4] && $server['b']['c_port'] == $adminarray2[4] && $player['name'] == $adminarray3[4])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[5] && $server['b']['c_port'] == $adminarray2[5] && $player['name'] == $adminarray3[5])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[6] && $server['b']['c_port'] == $adminarray2[6] && $player['name'] == $adminarray3[6])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[7] && $server['b']['c_port'] == $adminarray2[7] && $player['name'] == $adminarray3[7])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[8] && $server['b']['c_port'] == $adminarray2[8] && $player['name'] == $adminarray3[8])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[9] && $server['b']['c_port'] == $adminarray2[9] && $player['name'] == $adminarray3[9])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[10] && $server['b']['c_port'] == $adminarray2[10] && $player['name'] == $adminarray3[10])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[11] && $server['b']['c_port'] == $adminarray2[11] && $player['name'] == $adminarray3[11])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[12] && $server['b']['c_port'] == $adminarray2[12] && $player['name'] == $adminarray3[12])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[13] && $server['b']['c_port'] == $adminarray2[13] && $player['name'] == $adminarray3[13])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[14] && $server['b']['c_port'] == $adminarray2[14] && $player['name'] == $adminarray3[14])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[15] && $server['b']['c_port'] == $adminarray2[15] && $player['name'] == $adminarray3[15])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[16] && $server['b']['c_port'] == $adminarray2[16] && $player['name'] == $adminarray3[16])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[17] && $server['b']['c_port'] == $adminarray2[17] && $player['name'] == $adminarray3[17])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[18] && $server['b']['c_port'] == $adminarray2[18] && $player['name'] == $adminarray3[18])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[19] && $server['b']['c_port'] == $adminarray2[19] && $player['name'] == $adminarray3[19])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[20] && $server['b']['c_port'] == $adminarray2[20] && $player['name'] == $adminarray3[20])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[21] && $server['b']['c_port'] == $adminarray2[21] && $player['name'] == $adminarray3[21])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[22] && $server['b']['c_port'] == $adminarray2[22] && $player['name'] == $adminarray3[22])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[23] && $server['b']['c_port'] == $adminarray2[23] && $player['name'] == $adminarray3[23])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[24] && $server['b']['c_port'] == $adminarray2[24] && $player['name'] == $adminarray3[24])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[25] && $server['b']['c_port'] == $adminarray2[25] && $player['name'] == $adminarray3[25])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[26] && $server['b']['c_port'] == $adminarray2[26] && $player['name'] == $adminarray3[26])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[27] && $server['b']['c_port'] == $adminarray2[27] && $player['name'] == $adminarray3[27])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[28] && $server['b']['c_port'] == $adminarray2[28] && $player['name'] == $adminarray3[28])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[29] && $server['b']['c_port'] == $adminarray2[29] && $player['name'] == $adminarray3[29])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[30] && $server['b']['c_port'] == $adminarray2[30] && $player['name'] == $adminarray3[30])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[31] && $server['b']['c_port'] == $adminarray2[31] && $player['name'] == $adminarray3[31])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[32] && $server['b']['c_port'] == $adminarray2[32] && $player['name'] == $adminarray3[32])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[33] && $server['b']['c_port'] == $adminarray2[33] && $player['name'] == $adminarray3[33])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[34] && $server['b']['c_port'] == $adminarray2[34] && $player['name'] == $adminarray3[34])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[35] && $server['b']['c_port'] == $adminarray2[35] && $player['name'] == $adminarray3[35])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[36] && $server['b']['c_port'] == $adminarray2[36] && $player['name'] == $adminarray3[36])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[37] && $server['b']['c_port'] == $adminarray2[37] && $player['name'] == $adminarray3[37])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[38] && $server['b']['c_port'] == $adminarray2[38] && $player['name'] == $adminarray3[38])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[39] && $server['b']['c_port'] == $adminarray2[39] && $player['name'] == $adminarray3[39])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[40] && $server['b']['c_port'] == $adminarray2[40] && $player['name'] == $adminarray3[40])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[41] && $server['b']['c_port'] == $adminarray2[41] && $player['name'] == $adminarray3[41])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[42] && $server['b']['c_port'] == $adminarray2[42] && $player['name'] == $adminarray3[42])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[43] && $server['b']['c_port'] == $adminarray2[43] && $player['name'] == $adminarray3[43])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[44] && $server['b']['c_port'] == $adminarray2[44] && $player['name'] == $adminarray3[44])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[45] && $server['b']['c_port'] == $adminarray2[45] && $player['name'] == $adminarray3[45])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[46] && $server['b']['c_port'] == $adminarray2[46] && $player['name'] == $adminarray3[46])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[47] && $server['b']['c_port'] == $adminarray2[47] && $player['name'] == $adminarray3[47])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[48] && $server['b']['c_port'] == $adminarray2[48] && $player['name'] == $adminarray3[48])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[49] && $server['b']['c_port'] == $adminarray2[49] && $player['name'] == $adminarray3[49])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[50] && $server['b']['c_port'] == $adminarray2[50] && $player['name'] == $adminarray3[50])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[51] && $server['b']['c_port'] == $adminarray2[51] && $player['name'] == $adminarray3[51])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[52] && $server['b']['c_port'] == $adminarray2[52] && $player['name'] == $adminarray3[52])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[53] && $server['b']['c_port'] == $adminarray2[53] && $player['name'] == $adminarray3[53])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[54] && $server['b']['c_port'] == $adminarray2[54] && $player['name'] == $adminarray3[54])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[55] && $server['b']['c_port'] == $adminarray2[55] && $player['name'] == $adminarray3[55])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[56] && $server['b']['c_port'] == $adminarray2[56] && $player['name'] == $adminarray3[56])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[57] && $server['b']['c_port'] == $adminarray2[57] && $player['name'] == $adminarray3[57])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[58] && $server['b']['c_port'] == $adminarray2[58] && $player['name'] == $adminarray3[58])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[59] && $server['b']['c_port'] == $adminarray2[59] && $player['name'] == $adminarray3[59])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[60] && $server['b']['c_port'] == $adminarray2[60] && $player['name'] == $adminarray3[60])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[61] && $server['b']['c_port'] == $adminarray2[61] && $player['name'] == $adminarray3[61])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[62] && $server['b']['c_port'] == $adminarray2[62] && $player['name'] == $adminarray3[62])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[63] && $server['b']['c_port'] == $adminarray2[63] && $player['name'] == $adminarray3[63])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[64] && $server['b']['c_port'] == $adminarray2[64] && $player['name'] == $adminarray3[64])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[65] && $server['b']['c_port'] == $adminarray2[65] && $player['name'] == $adminarray3[65])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[66] && $server['b']['c_port'] == $adminarray2[66] && $player['name'] == $adminarray3[66])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[67] && $server['b']['c_port'] == $adminarray2[67] && $player['name'] == $adminarray3[67])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[68] && $server['b']['c_port'] == $adminarray2[68] && $player['name'] == $adminarray3[68])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[69] && $server['b']['c_port'] == $adminarray2[69] && $player['name'] == $adminarray3[69])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[70] && $server['b']['c_port'] == $adminarray2[70] && $player['name'] == $adminarray3[70])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[71] && $server['b']['c_port'] == $adminarray2[71] && $player['name'] == $adminarray3[71])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[72] && $server['b']['c_port'] == $adminarray2[72] && $player['name'] == $adminarray3[72])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[73] && $server['b']['c_port'] == $adminarray2[73] && $player['name'] == $adminarray3[73])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[74] && $server['b']['c_port'] == $adminarray2[74] && $player['name'] == $adminarray3[74])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[75] && $server['b']['c_port'] == $adminarray2[75] && $player['name'] == $adminarray3[75])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[76] && $server['b']['c_port'] == $adminarray2[76] && $player['name'] == $adminarray3[76])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[77] && $server['b']['c_port'] == $adminarray2[77] && $player['name'] == $adminarray3[77])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[78] && $server['b']['c_port'] == $adminarray2[78] && $player['name'] == $adminarray3[78])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[79] && $server['b']['c_port'] == $adminarray2[79] && $player['name'] == $adminarray3[79])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[80] && $server['b']['c_port'] == $adminarray2[80] && $player['name'] == $adminarray3[80])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[81] && $server['b']['c_port'] == $adminarray2[81] && $player['name'] == $adminarray3[81])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[82] && $server['b']['c_port'] == $adminarray2[82] && $player['name'] == $adminarray3[82])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[83] && $server['b']['c_port'] == $adminarray2[83] && $player['name'] == $adminarray3[83])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}

if ($server['b']['ip'] == $adminarray1[84] && $server['b']['c_port'] == $adminarray2[84] && $player['name'] == $adminarray3[84])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[85] && $server['b']['c_port'] == $adminarray2[85] && $player['name'] == $adminarray3[85])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[86] && $server['b']['c_port'] == $adminarray2[86] && $player['name'] == $adminarray3[86])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[87] && $server['b']['c_port'] == $adminarray2[87] && $player['name'] == $adminarray3[87])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[88] && $server['b']['c_port'] == $adminarray2[88] && $player['name'] == $adminarray3[88])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[89] && $server['b']['c_port'] == $adminarray2[89] && $player['name'] == $adminarray3[89])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[90] && $server['b']['c_port'] == $adminarray2[90] && $player['name'] == $adminarray3[90])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[91] && $server['b']['c_port'] == $adminarray2[91] && $player['name'] == $adminarray3[91])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}

if ($server['b']['ip'] == $adminarray1[92] && $server['b']['c_port'] == $adminarray2[92] && $player['name'] == $adminarray3[92])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}

if ($server['b']['ip'] == $adminarray1[93] && $server['b']['c_port'] == $adminarray2[93] && $player['name'] == $adminarray3[93])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[94] && $server['b']['c_port'] == $adminarray2[94] && $player['name'] == $adminarray3[94])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[95] && $server['b']['c_port'] == $adminarray2[95] && $player['name'] == $adminarray3[95])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[96] && $server['b']['c_port'] == $adminarray2[96] && $player['name'] == $adminarray3[96])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[97] && $server['b']['c_port'] == $adminarray2[97] && $player['name'] == $adminarray3[97])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[98] && $server['b']['c_port'] == $adminarray2[98] && $player['name'] == $adminarray3[98])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[99] && $server['b']['c_port'] == $adminarray2[99] && $player['name'] == $adminarray3[99])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[100] && $server['b']['c_port'] == $adminarray2[100] && $player['name'] == $adminarray3[100])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[101] && $server['b']['c_port'] == $adminarray2[101] && $player['name'] == $adminarray3[101])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[102] && $server['b']['c_port'] == $adminarray2[102] && $player['name'] == $adminarray3[102])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[103] && $server['b']['c_port'] == $adminarray2[103] && $player['name'] == $adminarray3[103])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[104] && $server['b']['c_port'] == $adminarray2[104] && $player['name'] == $adminarray3[104])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[105] && $server['b']['c_port'] == $adminarray2[105] && $player['name'] == $adminarray3[105])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[106] && $server['b']['c_port'] == $adminarray2[106] && $player['name'] == $adminarray3[106])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[107] && $server['b']['c_port'] == $adminarray2[107] && $player['name'] == $adminarray3[107])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[108] && $server['b']['c_port'] == $adminarray2[108] && $player['name'] == $adminarray3[108])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[109] && $server['b']['c_port'] == $adminarray2[109] && $player['name'] == $adminarray3[109])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[110] && $server['b']['c_port'] == $adminarray2[110] && $player['name'] == $adminarray3[110])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[111] && $server['b']['c_port'] == $adminarray2[111] && $player['name'] == $adminarray3[111])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[112] && $server['b']['c_port'] == $adminarray2[112] && $player['name'] == $adminarray3[112])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[113] && $server['b']['c_port'] == $adminarray2[113] && $player['name'] == $adminarray3[113])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[114] && $server['b']['c_port'] == $adminarray2[114] && $player['name'] == $adminarray3[114])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[115] && $server['b']['c_port'] == $adminarray2[115] && $player['name'] == $adminarray3[115])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[116] && $server['b']['c_port'] == $adminarray2[116] && $player['name'] == $adminarray3[116])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[117] && $server['b']['c_port'] == $adminarray2[117] && $player['name'] == $adminarray3[117])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[118] && $server['b']['c_port'] == $adminarray2[118] && $player['name'] == $adminarray3[118])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}


if ($server['b']['ip'] == $adminarray1[119] && $server['b']['c_port'] == $adminarray2[119] && $player['name'] == $adminarray3[119])
{
$player['name'] = "{$server['p'][$key]['name']} --Admin"; 
}

don't simply paste hundreds of lines of code.

 

Ummm. You wouldn't ever write hundreds of lines of code that only differ in the array index value they use. You would use a loop.

 

Also, the global keyword only has meaning inside a function definition (and even there it should not be used.) Why do you have global $lgsl_config, $lgsl_zone_number; in your code?

don't simply paste hundreds of lines of code.

 

Ummm. You wouldn't ever write hundreds of lines of code that only differ in the array index value they use. You would use a loop.

 

Also, the global keyword only has meaning inside a function definition (and even there it should not be used.) Why do you have global $lgsl_config, $lgsl_zone_number; in your code?

 

Good points, all.  My eyes glazed over when I looked at the OP's wall of code, so I never noticed.

I also cannot help to wonder, since most of the data values being compared are coming from a database table, if most of the code cannot simply be replaced with a few (1 or 2) queries to get only the data you want or if there is only one matching entry per pass through the main server loop and all you really need to do is a simple array access/lookup instead of repeating code or even replacing repeated code with a loop.

 

The lines of code 104 - 229 could be replaced with about 10 lines (if you have multiple values) and possibly 3-4 lines (if there is only one matching value at a time.)

 

By having a type column that holds an owner/admin flag, all the code starting with the foreach(){} loop at line 247, through to the end of what you posted could (probably) be replaced with ~20 lines of code that you won't ever need to edit as the number of owners/admins change.

 

That being said, you haven't actually indicated what you are trying to accomplish with the color change? Are you trying to make certain type(s) of players (owner, admin, player) different colors? Make specific players certain colors? And if so, wouldn't it be better to just make the change in one place instead of hundreds of places throughout the code by simplifying the code first?

Sorry guys, I did have other parts of code in post with explanations but all the rest was removed (editted) by Nightslyr.

 

I obviously don't understand what parts of code you would like to see outside the ones I had posted. I will try to do what was suggested as far as shortend code on my end and will post if I have any success. Thank you all for your time.

 

One example for the posted code, lines 104 - 229, if you create the $myarray with the key being the $server['s']['map'] value and the value being the release information you are putting into $myarray2, you can replace all that code with the following -

 

if(isset($myarray[$server['s']['map']])){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on {$myarray[$server['s']['map']]}'>---- New Map ----</font></span>
              </td>
          </tr>";
}

One example for the posted code, lines 104 - 229, if you create the $myarray with the key being the $server['s']['map'] value and the value being the release information you are putting into $myarray2, you can replace all that code with the following -

 

if(isset($myarray[$server['s']['map']])){
	  $output .= "
	  <tr>
            <td style='padding:4px; border:2px solid'>
              <span style='padding:1px; float:center'><font color='white' title='Released on {$myarray[$server['s']['map']]}'>---- New Map ----</font></span>
              </td>
          </tr>";
}

 

ty I will try this and I assume it will be the same for lines 277 - 1015?

Another example for lines 277 - 991 (the last that is in the post), without changing any of the data, and assuming there could be multiple admins per ip/port, all that code could be changed to the following (untested of course) -

 

// If there are multiples of the same ip in $adminarray1
$found = array_keys($adminarray1, $server['b']['ip']); // find the recored(s) with the ip
if(is_array($found) && !empty($found)){
// have an array of keys
foreach($found as $key){
	if($server['b']['c_port'] == $adminarray2[$key] && $player['name'] == $adminarray3[$key]){
		$player['name'] = "{$server['p'][$key]['name']} --Admin";
	}
}
}

Another example for lines 277 - 991 (the last that is in the post), without changing any of the data, and assuming there could be multiple admins per ip/port, all that code could be changed to the following (untested of course) -

 

// If there are multiples of the same ip in $adminarray1
$found = array_keys($adminarray1, $server['b']['ip']); // find the recored(s) with the ip
if(is_array($found) && !empty($found)){
// have an array of keys
foreach($found as $key){
	if($server['b']['c_port'] == $adminarray2[$key] && $player['name'] == $adminarray3[$key]){
		$player['name'] = "{$server['p'][$key]['name']} --Admin";
	}
}
}

 

ok ty, this is what I meant in my last post. I will try both your suggestions.

Here is some code (untested) to replace the 'owner' section -

 

Put this near the start of the code (outside of any loops) -

// data that defines the owners (assuming only one owner per ip/port) -
$owners = array();
$owners['205.234.152.101|1716'] = '-=[FSD]=-TOGA';
$owners['65.99.193.91|1716'] = 'dodgeitorelse';
$owners['65.99.193.92|1716'] = 'ChevyNightmare';
$owners['65.99.193.93|1716'] = 'ChevyNightmare';
$owners['216.221.12.120|1716'] = '-{KWK}-Kman';

 

Replace the existing lines of code with this -

 // code to test if the player is the owner
$ip_port = $server['b']['ip'] . '|' . $server['b']['c_port'];
if(isset($owners[$ip_port]) && $owners[$ip_port] == $player['name']){
	$player['name'] = "{$server['p'][$key]['name']} --Owner"; 
}

  • 2 weeks later...

ok I managed to get the new map section shrtened to just a few lines by using this;

 

 foreach($myarray as $currentValue) 
    {
      if($server['s']['map'] == $currentValue) 
      {
        $output .= "<tr><td style='padding:4px; border:2px solid'><span style='padding:1px; float:center'><font color='white'>---- New Map ----</font></span></td></tr>";
        break;
      }
    }

 

Still working on the admin section that has 1000 plus lines for the if statements lol

If you are just looking up the data to see if it is in the array (the code I showed was based on you getting the Released on information which your current code isn't referencing) you can replace the above loop with an in_array statement.

 

Somehow you are stuck thinking you need to scan through the information to find things (your database queries already did the scanning to find and retrieve the data from the database.) Your php code should simply check if the data is present. The only loop I used in the code I posted in this thread was where I assumed there could be more than one admin per server and even that could probably be replaced with a simpler in_array statement.

 

If you have the data in an array, use php's array functions, such as in_array, array_keys, and array_search or setup the keys in the array so that you can directly test if the value you are looking for is in the array to find the data. Don't loop through every element of the array until you find the value in the array.

 

The code I posted in this thread, based on what I could determine you were trying to accomplish, was tested using dummy data and should either work as is or should be close to what you need.

As you can probably tell I am very new to php and mysql. What I am doing is trying to modify these files to fit our needs. I have gone to the creator to try to get help however he has been inactive for quite some time.

 

To answer the previous question about why the globals are used ...... I have no answer as I have no idea what the globals even do. His files are set up to do a lot of different things depending on how they are used.

 

When I tried the code you gave me for the new maps section the trackers would not display. I simply stumbled across what I used to get it to work by hit and miss. I am not sure what is relevant to the code so I can show it here as values and all are coming from a whole lot of different files.

 

I will look into the part you say I seem to be stuck on (which I am sure you are correct) and will look into the php's array functions, such as in_array(), array_keys(), and array_search()

 

Will let you know how I turn out. Again thank you so much for helping me. I am not looking for someone to hand me the code I need, just a point in the right direction which at this point I have no idea what direction I am headed.

ok, I was able to replace the 1000 plus lines of code for admin section with your code

 


$found = array_keys($adminarray1, $server['b']['ip']);
if(is_array($found) && !empty($found)){
foreach($found as $key2){
	if($server['b']['c_port'] == $adminarray2[$key2] && $player['name'] == $adminarray3[$key2]){
		$player['name'] = "{$server['p'][$key]['name']} --$adminarray4[$key2]";
	}
}
}

 

but had to change $key to $key2 as $key was already assigned in another area in my code. This works great and a big thank you to you.

What this does is looks to see if a player is an admin on the server and will put --Admin after his name.

 

the actual code that outputs the player name is further into my code such as ...

 


  $output .= "
                  <div style='left:0px; right:0px; top:0px; bottom:0px; padding:1px; white-space:nowrap; overflow:hidden; text-align:left' title='{$player['name']}'> {$player['name']} </div>";
                }

                $output .= "
              </div>
            </td>
          </tr>";

 

Now that we have reduced my code to just a few lines I am struggling to get the admin names to be a different color than the regular players. Any thoughts?

 

Also I am still working on the previous post for the new map part where you said

 

Somehow you are stuck thinking you need to scan through the information to find things (your database queries already did the scanning to find and retrieve the data from the database.) Your php code should simply check if the data is present. The only loop I used in the code I posted in this thread was where I assumed there could be more than one admin per server and even that could probably be replaced with a simpler in_array statement.

hi again. color issue was an easy fix. I used this...

 


$found = array_keys($admin_ip, $server['b']['ip']);
if(is_array($found) && !empty($found)){
foreach($found as $key2){
	if($server['b']['c_port'] == $admin_port[$key2] && $player['name'] == $admin_player_name[$key2])
	{
	$server['p'][$key]['name'] = "<font color='lightblue'>".$server['p'][$key]['name']."</font>"; 
	$player['name'] = "{$server['p'][$key]['name']}  <b style='color:lightblue;'>- ($admin_status[$key2])</b>";
		} 
	}
}

 

and to stop the name from showing twice i had to edit this....

 


$output .= "
                  <div style='left:0px; right:0px; top:0px; bottom:0px; padding:1px; white-space:nowrap; overflow:hidden; text-align:left' title='{$player['name']}'> {$player['name']} </div>";
                }

 

by removing the title section. Topic solved and thank you so much.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.