<?php

/*
// +--------------------------------------------------------------------------+
// | HTTP-User-Agents verwalten                                             |
// | by dada                                                              |
// +--------------------------------------------------------------------------+
// | Obige Zeilen dürfen nicht entfernt werden!    Do not remove above lines! |
// +--------------------------------------------------------------------------+
 */

require "include/bittorrent.php";
include("include/dagent.class.php");

dbconn();
loggedinorreturn();

if (get_user_class() < UC_ADMINISTRATOR)
    stderr("w00t","w00t");

$_a=0;
stdhead("Clienten verwalten");

// User Agents updaten
if (isset($_POST["agents"]) && is_array($_POST["agents"])) {
    foreach($_POST["agents"] as $agent_id => $aktiv){
        UserAgent::setAktiv($agent_id, $aktiv);
    }
}


$cp_agents = UserAgent::getAll("name");
?>

<table cellpadding="4" cellspacing="1" border="0" style="width:50%" class="tableinborder">
 <tr class="tabletitle" width="75%">
  <td colspan="10" width="75%"><span class="normalfont"><center><b>Clienten verwalten</b></center></span></td>
</tr>
<tr><td width="120%" align="center">


<form method="POST">
<table cellpadding="4" cellspacing="1" border="0">
    <tr>
        <td class="tablecat" align="center"><a href="?order=name">Name</a></td>
        <td class="tablecat" align="center"><a href="?order=hits">Hits</a></td>
        <td class="tablecat" align="center"><a href="?order=first">erste Anfrage</a></td>
        <td class="tablecat"><a href="?order=first">Aktiv?</a></td>
    </tr>
<?
$styles[0] = "#098f03";
$styles[1] = "#c80303";

if (is_array($cp_agents)) {
    $anz = count($cp_agents);
    for ($i=0;$i<$anz;$i++) {

        if ($cp_agents[$i]["aktiv"]) {
           ($st = $styles[0]);
        }
        else $st = $styles[1];
?>
    <tr>
        <td style="background-color: <?=$st?>"><?=$cp_agents[$i]["agent_name"]?></td>
        <td style="background-color: <?=$st?>" align="center"><?=$cp_agents[$i]["hits"]?></td>
        <td style="background-color: <?=$st?>" align="center"><?=date("d.m.y [H:i]", $cp_agents[$i]["ins_date"])?></td>
        <td style="background-color: <?=$st?>">
            <input type="radio" name="agents[<?=$cp_agents[$i]["agent_id"]?>]" value="0" <?=!$cp_agents[$i]["aktiv"]?" checked":"";?>>&nbsp;nein
            &nbsp;<input type="radio" name="agents[<?=$cp_agents[$i]["agent_id"]?>]" value="1" <?=$cp_agents[$i]["aktiv"]?" checked":"";?>>ja
        </td>
    </tr>
<?
    }
}
?>
<tr>
    <td class="tablecat" colspan="4" align="center"><input type="submit" value="speichern" style="width: 250px"></td>
</tr>
</table>

</td></tr>
</table>
</form>
<?php
stdfoot();
?>