<? // if you aren an admin, I wanna make some space to place the admin controls in the sidebar
    
if ($users[disabled] == 2
        echo 
'
            <div id="admin-side-block"></div>'
;

?>
 

<div id="recent-interactions" class="sidebar-block">

    <h2 class="h2-sidebar">Currently Online</h2>

    <?
    $num_online_users 
sqleval("SELECT COUNT(*) FROM $playerdb WHERE online=1;");
    
//$minutes = round((((time() - $enemy[pageidle]) % (60 * 60 * 24)) % (60 * 60)) / 60, 0);
    
if($num_online_users 0)
{
    
$online_users dbquery("SELECT num, empire, disabled, clan, pageidle FROM $playerdb WHERE online=1 ORDER BY num ASC;");
    
$online_text = array();
    print 
"<ul id=\"currently-online\">";
    
$i 0;
    while(
$online mysql_fetch_array($online_users))
    {
        
$color "normal";
        if(
$online[disabled] == 2)
            
$color "admin";
        if(
$theme[clans])
        {
            if ((
$users[clan]) && ($online[clan] == $users[clan]))
            
$color "ally";
        }

        
$s time() - $online[pageidle];

        
$m=0;$hr=0;$d=0;$td="now"
        if(
$s>59) {
            
$m = (int)($s/60);
            
$s $s-($m*60); // sec left over
            
$td "$m min";
        } 
        if(
$m>59){
            
$hr = (int)($m/60);
            
$m $m-($hr*60); // min left over
            
$td "$hr hr"; if($hr>1$td .= "s";
            if(
$m>0$td .= ", $m min";
        }
        if(
$hr>23){
            
$d = (int)($hr/24);
            
$hr $hr-($d*24); // hr left over
            
$td "$d day"; if($d>1$td .= "s";
            if(
$d<3){
                if(
$hr>0$td .= ", $hr hr"; if($hr>1$td .= "s";
            }
        }
        
        if (
$td 'now') {
            
$online_text[$i] = "<li class=\"m$color\">".$online[empire]." (#".$online[num].")</li>";
            }
        else {
            
$online_text[$i] = "<li class=\"m$color\">".$online[empire]." (#".$online[num].") <span id=\"idle-time\">($td idle)</span></li>";
        }
        
        
        
$i++;
    }
    
    print 
implode($online_text);
    print 
"";
    print 
"</ul>";
}
?>

</div>





<? if($users[show_handy]) { ?>

    <div id="handy-stuff" class="sidebar-block">

    <h2 class="h2-sidebar">Handy Stuff</h2><?
        
    
if ($do_changetax) {
        
fixInputNum($new_tax);
        if (
$new_tax 5)
            
TheEnd("Cannot set your tax that low!");
        if (
$new_tax 70)
            
TheEnd("Cannot set your tax that high!");
        
$users[tax] = $new_tax;
        
saveUserData($users"tax");
        print 
"<p class=\"main-info\">Tax rate updated!</p>";
    }

    if (
$do_changeeco) {
        
$total 0;
        
fixInputNum($cashpct);
        
$total += $cashpct;
        
fixInputNum($foodpct);
        
$total += $foodpct;
        if ((
$cashpct 100) || ($cashpct 0) || ($foodpct 100) || ($foodpct 0))
            
theEnd("Ecnomic settings much be between 0% and 100%");
        else if ((
$total 100) || ($total 0))
            
theEnd("Total Economic settings must be equal to or lower than 100%");
        
$users[cashpct] = $cashpct;
        
$users[foodpct] = $foodpct;
        
saveUserData($users"cashpct foodpct");
        
//saveUserData($users, substr($foodpct, 1));
        
print "<p class=\"main-info\">Economic Settings updated!</p>";
    }
    if (
$do_settraining) {
        
$total 0;
        while (list(
$key$val) = each($ttrn)) {
            
fixInputNum($val);
            
$save .= " ttrn_$key";
            
$total += $val;
            
$users["ttrn_$key"] = $val;
            if ((
$val 100) || ($val 0))
                
theEnd("Training percents must be equal to or lower than 100%");
        }
        if ((
$total 100) || ($total 0))
            
theEnd("Training percents must be equal to or lower than 100%");

        
saveUserData($userssubstr($save1));
        print 
"<p class=\"main-info\">Troop Training settings updated!</p>";
    }
    if (
$do_changeindustry) {
        
$total 0;
        
reset($trplst);
        while (list(
$key$val) = each($trplst)) {
            
fixInputNum($ind[$val]);
            
$total += $ind[$val];
            if (($
$ind[$val] > 100) || ($$ind[$val] < 0))
                
TheEnd("Cannot set training at that level! It must be between 0 and 100");
            
$save .= " ind_$val";
        }

        if (
$total 100)     // total
            
TheEnd("Cannot set total training at that level! It must be equal to or lower than 100");
        
reset($trplst);
        while (list(
$key$val) = each($trplst))
            
$users["ind_" $val] = $ind[$val];
        
saveUserData($userssubstr($save1));
        print 
"<p class=\"main-info\">Training settings updated!</p>";
    }

    
?>

    <ul id="handy-list"> 
        <li>
          <form method="post">
              <table class="inputtable">
                  <tr><td>Tax Rate:</td>
                      <td class="aright"><input class="input_text" type="text" name="new_tax" size="3" value="<?= $users[tax?>">%</td></tr>
                  <tr><th colspan="2"><input class="button_submit" type="submit" name="do_changetax" value="Change Tax Rate"></th></tr>
              </table>
          </form>
        </li>
        <li>
            <form method="post">
              <table class="inputtable">
                  <tr><th colspan="2">Economic Settings</th></tr>
                      <tr><td><?= "Cash" ?></td>
                            <td class="aright"><input class="input_text" type="text" name="cashpct" size="3" value="<?= $users[cashpct?>">%</td></tr>
                      <tr><td><?= "Food" ?></td>
                            <td class="aright"><input class="input_text" type="text" name="foodpct" size="3" value="<?= $users[foodpct?>">%</td></tr>
                  <tr><th colspan="2"><input class="button_submit" type="submit" name="do_changeeco" value="Change Economy Settings"></th></tr>
              </table>
           </form>
        </li>
        <li>
             <form method="post">
             <table class="inputtable">
                  <tr><th colspan="2">Training Settings</th></tr>
        <?
                      reset
($trplst);
                      while (list(
$key$val) = each($trplst)) {
        
?>
                      <tr><td><?= $uera[$val?></td>
                          <td class="aright"><input class="input_text" type="text" name="ind[<?= $val ?>]" size="3" value="<?= $users["ind_" $val?>">%</td></tr>
        <? ?>
                <tr><th colspan="2"><input class="button_submit" type="submit" name="do_changeindustry" value="Update Settings"></th></tr>
              </table>
              </form>
        </li>
        
        
    </ul>
     
     </div>
 
 <?// end if for handy stuff ?>