Jump to content

dodgeitorelse

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Posts posted by dodgeitorelse

  1. ok so far I have this which does display my messages (3 of them) using

     

    <script type="text/javascript">
    var customMessages = Array('Click \"Image\" to see server details....', 'Click \"Map Name\" to go directly to download link for that map....', 'Click \"Player Scores\" to see top 10 players for that server');
    
    var secondsPassed = 0;
    function show_notes()
    {
    var t = setTimeout("load()", 3000);
    }
    
    function load()
    {
    document.getElementById("tracker_notes").style.color = "red";
    document.getElementById("tracker_notes").innerHTML = customMessages[secondsPassed];
    if(++secondsPassed < 6)
    	var t = setTimeout("load()", 4000);
    else
    	document.getElementById("tracker_notes").innerHTML = '';
    }
    </script>
    

     

    however at the end of the third code it then displays "undefined as if it were another message. I can't for the life of me see what is undefined.

     

    I am also working on getting this function to keep reloading so that it repeats the 3 messages over and over. Am I going in the right direction or am I way off here?

  2. Hi, is it possible to change a text string after a 5 second period? What i want is text string "A" to display on page, then after five seconds replace text string "A" with text string "B" then after another 5 seconds replace with text string "C" then after 5 seconds display text string "A" again and keep doing this?

  3. I use this to check which browser and if its IE then it tells my users that site is best viewed with blah blah blah

     

    function getBrowser() 
    { 
        $u_agent = $_SERVER['HTTP_USER_AGENT']; 
        $bname = 'Unknown';
        $platform = 'Unknown';
        $version= "";
    
        //First get the platform?
        if (preg_match('/linux/i', $u_agent)) {
            $platform = 'linux';
        }
        elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
            $platform = 'mac';
        }
        elseif (preg_match('/windows|win32/i', $u_agent)) {
            $platform = 'windows';
        }
        
        // Next get the name of the useragent yes seperately and for good reason
        if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) 
        { 
            $bname = 'Internet Explorer'; 
            $ub = "MSIE"; 
        } 
        elseif(preg_match('/Firefox/i',$u_agent)) 
        { 
            $bname = 'Mozilla Firefox'; 
            $ub = "Firefox"; 
        } 
        elseif(preg_match('/Chrome/i',$u_agent)) 
        { 
            $bname = 'Google Chrome'; 
            $ub = "Chrome"; 
        } 
        elseif(preg_match('/Safari/i',$u_agent)) 
        { 
            $bname = 'Apple Safari'; 
            $ub = "Safari"; 
        } 
        elseif(preg_match('/Opera/i',$u_agent)) 
        { 
            $bname = 'Opera'; 
            $ub = "Opera"; 
        } 
        elseif(preg_match('/Netscape/i',$u_agent)) 
        { 
            $bname = 'Netscape'; 
            $ub = "Netscape"; 
        } 
        
        // finally get the correct version number
        $known = array('Version', $ub, 'other');
        $pattern = '#(?<browser>' . join('|', $known) .
        ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
        if (!preg_match_all($pattern, $u_agent, $matches)) {
            // we have no matching number just continue
        }
        
        // see how many we have
        $i = count($matches['browser']);
        if ($i != 1) {
            //we will have two since we are not using 'other' argument yet
            //see if version is before or after the name
            if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
                $version= $matches['version'][0];
            }
            else {
                $version= $matches['version'][1];
            }
        }
        else {
            $version= $matches['version'][0];
        }
        
        // check if we have a number
        if ($version==null || $version=="") {$version="?";}
        
        return array(
            'userAgent' => $u_agent,
            'name'      => $bname,
            'version'   => $version,
            'platform'  => $platform,
            'pattern'    => $pattern
        );
    } 
    
    // now try it
    $ua=getBrowser();
    $yourbrowser= "Your browser: " . $ua['name'] . " " . $ua['version'] . " on " .$ua['platform'];
    //print_r($yourbrowser);
    
    if ($ua['name'] == "Mozilla Firefox") {
    echo "<br />";
    print("Enjoy your stay .... <br />and tell your friends about this site!");
    }
    
    if ($ua['name'] == "Google Chrome") {
    echo "<br />";
    print("Enjoy your stay .... <br />and tell your friends about this site!");
    }
    
    if ($ua['name'] == "Apple Safari") {
        print("Enjoy your stay .... <br />and tell your friends about this site!");
    }
    
    if ($ua['name'] == "Opera") {
        print("Enjoy your stay .... <br />and tell your friends about this site!");
    }
    
    if ($ua['name'] == "Internet Explorer") {
        print("This site is best viewed with ....<br />Firefox, Chrome, Opera or Safari<br /><font color='red'>$yourbrowser</font><br /><br />Please tell your friends about this site!");
    }
    
    if ($ua['name'] == "Netscape") {
        print("This site is best viewed with Firefox or Chrome<br /><font color='red'>$yourbrowser</font><br /><br />Please tell your friends about this site!");
    }
    

     

     

    I am sure this could be shortened up and tidied but it works for me.

  4. I should have more clear....

     

    my database has 2 columns which are clan and site.

     

    I have put both into arrays as such in a file called web_sites.php:

    
    while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
    $clanname[]= $row['clan'];
    $siteaddy[]= $row['site'];
    }
    

     

     

    then in another file called zone.php I have included web_sites.php

     

    I then look through $clanname array to see if I have a match and if I

    do I want to output the $siteaddy result. I tried this

     

    
    $found2 = array_keys($clanname, $server['o']['comment']);
    if(is_array($found2) && !empty($found2)){
    foreach($found2 as $key3){
    	if($server['o']['comment'] == $clanname[$key3])
    	{
    	$server2 = $siteaddy;
    		} 
    	}
    }
    
    $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='{$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'>
                    $server2
                  </div>
                </td>
              </tr>
    

     

    The $server['o']['comment'] does store a name of the clan that might be in the $clanname array which is in a 3rd file called class.php which is included in the zone.php file.

     

    So basically if $server['o']['comment'] is someclanname and is found in the $clanname array I want the web site address that is stored in the $siteaddy array to display in the table.

     

    I hope this is clearer picture of what I have.

  5. my database has 2 columns which are clan and site.

     

    I have put both into arrays as such:

    while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
    $clanname[]= $row['clan'];
    $siteaddy[]= $row['site'];
    }
    

     

    I then look through $clanname array to see if I have a match and if I

    do I want to output the $siteaddy result. I tried this

    $found2 = array_keys($clanname, $server['o']['comment']);
    if(is_array($found2) && !empty($found2)){
    foreach($found2 as $key3){
    	if($server['o']['comment'] == $clanname[$key3])
    	{
    	$server2 = $siteaddy;
    		} 
    	}
    }
    

    but all it returns is ARRAY and not the actual data for the $siteaddy.

    I would appreciate any suggestions.

  6. To dynamically generate variable names, the curly quotes need to go around the entire variable name:

     

    ${'list' . $server['o']['id']}

     

    Thank you very much . I had tried the curly quotes but put first one before the dollar sing instead of after. Again thank you for your working solution.  :D

  7. Hi everyone,

    I have several variables named $list1 through $list20.

    I need to know if it is possible to use another variable to fill in the number at the end of the first variable depending on a server that is selected.

    The variable to determine the server is $server['o']['id']

    The id is a number from 1 - 20

    I tried $list{$server['o']['id']} but all I get for a value is the number and not the $list before it.

    Due to the existing code that I am trying to use this in I have to be able to do this inside single quotes as double quotes kills all the code (shows nothing but a blank page for everything)

    How can this be achieved?

  8. 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.

  9. 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.
  10. 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.

  11. 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

  12. 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.

  13. 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?

  14. 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.

     

×
×
  • 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.