<?
########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

include_once("auth.php");
include_once("../include/cron_functions.php");
include_once("../include/module.Database.php");

db_connect($db_host, $db_user, $db_pass);

## userdaten ermitteln und anzeigen, wenn angezeigt werden soll
$loUser = new SQLString($PHP_AUTH_USER);
$id = safe_query2( "SELECT * FROM anbieter WHERE anbieter = ?", $loUser );
$werte = db_fetch_array($id);
$id = db_query("select * from admin");
$admin = db_fetch_array($id);
$name = $werte["name"];
$firma = $werte["firma"];
$anschrift = $werte["anschrift"];
$plzort = $werte["plzort"];
$telefon = $werte["telefon"];
$fax = $werte["fax"];
$emailadresse = $werte["emailadresse"];
$kundennummer = $werte["kundennummer"];
$freifeldname1 = $werte["freifeldname1"];
$freifeldname2 = $werte["freifeldname2"];
$freifeldname3 = $werte["freifeldname3"];
$freifeldwert1 = $werte["freifeldwert1"];
$freifeldwert2 = $werte["freifeldwert2"];
$freifeldwert3 = $werte["freifeldwert3"];
$kundendatenanzeigen = $werte["kundendatenanzeigen"];

$maxkunden = $werte["maxkunden"];
$maxkb = $werte["maxkb"];
$maxtransfer = $werte["maxtransfer"];
$maxdomains = $werte["maxdomains"];
$maxsubdomains = $werte["maxsubdomains"];
$maxwildcards = $werte["maxwildcards"];
$maxatdomains = $werte["maxatdomains"];
$maxpop3 = $werte["maxpop"];
$maxftp = $werte["maxftp"];
$maxemail = $werte["maxemail"];
$maxcronjobs = $werte["maxcronjobs"];
$maxautoresponder = $werte["maxautoresponder"];
$maxmaillist = $admin["majordomo"] ? $werte['maxmaillist'] : 0;

$maxmysql = $werte["maxmysql"];

$gender = $werte["gender"];
$firstname = $werte["firstname"];
$plz = $werte["plz"];
$land = $werte["land"];

$id = safe_query2("select count(kunde) as anzahlkunden, (sum(kbhomedir) + sum(kbdb)) as kbbenutzt, sum(maxkb) as kbvergeben from kunden where anbieter = '$PHP_AUTH_USER'");
$werte = db_fetch_array($id);
$anzahlkunden = $werte["anzahlkunden"];
$kbbenutzt = $werte["kbbenutzt"];
$kbvergeben = $werte["kbvergeben"];

## set assigned space to '-1' if one of reseller's users have maxkb = '-1'
$id = db_query("SELECT COUNT(*) as cnt FROM kunden WHERE anbieter='$PHP_AUTH_USER' AND maxkb = -1");
$data_maxkb = db_fetch_array($id);
if ( $data_maxkb["cnt"] )
    $kbvergeben = -1;
##    

## datum
$jahr = date("Y");
$monat = date("n");
$monatstr = $lang_months[$monat];
## /datum

$id = safe_query2( "SELECT (SUM(ftp) + SUM(web) + SUM(email)) AS transfer FROM transfer ".
								" WHERE anbieter=? and monat=$monat and jahr=$jahr", $loUser);
$werte = db_fetch_array($id);
$transfer = $werte["transfer"];

$id = safe_query2( "SELECT COUNT(anbieter) AS pop3 FROM pop3 WHERE anbieter = ?", $loUser );
$werte = db_fetch_array($id);
$pop3 = $werte["pop3"];

$id = safe_query2( "SELECT COUNT(account) AS ftp FROM ftp WHERE anbieter = ?", $loUser );
$werte = db_fetch_array($id);
$usedftp = $werte["ftp"];

$id = safe_query2( "SELECT COUNT(anbieter) AS email FROM email WHERE anbieter = ?", $loUser );
$werte = db_fetch_array($id);
$email = $werte["email"];

$id = safe_query2( "SELECT COUNT(ident) AS autoresponder FROM autoresponder WHERE anbieter = ?", $loUser );
$werte = db_fetch_array($id);
$autoresponder = $werte["autoresponder"];

$id = safe_query2( "SELECT COUNT(anbieter) AS subdomains FROM domains WHERE anbieter = ? and richtigedomain = 0", $loUser);
$werte = db_fetch_array($id);
$subdomains = $werte["subdomains"];

$id = safe_query2( "SELECT SUM(wildcard) AS wildcards FROM kunden WHERE anbieter = ? and wildcard = 1", $loUser);
$werte = db_fetch_array($id);
$wildcards = $werte["wildcards"];

$id = safe_query2( "SELECT COUNT(*) AS atd FROM atdomains, domains, kunden WHERE kunden.anbieter = ?" .
										" AND kunden.kunde=domains.kunde AND domains.id=atdomains.id_from", $loUser );
$werte = db_fetch_array($id);
$atdomains = $werte["atd"];

$id = safe_query2( "SELECT COUNT(anbieter) AS domains FROM domains WHERE anbieter = ? and richtigedomain = 1", $loUser);
$werte = db_fetch_array($id);
$domains = $werte["domains"];
## anzahl mysql-datenbanken ermitteln
$id = safe_query2( "SELECT COUNT(datenbank) AS anzahlmysql FROM mysql_datenbanken WHERE anbieter = ?", $loUser);
$werte = db_fetch_array($id);
$mysql = $werte["anzahlmysql"];
## //anzahl mysql-datenbanken ermitteln

$id = safe_query2( "SELECT COUNT(*) AS cnt FROM idn_aliases INNER JOIN domains ON (domains.id = idn_aliases.domain_id) ".
							 "WHERE domains.anbieter=?", $loUser);
$werte = db_fetch_array($id);
$idn = $werte["cnt"];

$id = safe_query2( "SELECT COUNT(*) AS cnt FROM maillist INNER JOIN domains ON (domains.id = maillist.domain_id) ".
									 "WHERE domains.anbieter=?", $loUser);
$werte = db_fetch_array($id);
$maillist = $werte["cnt"];


## cron jobs
$cronjobs = count_cron_jobs_reseller($PHP_AUTH_USER);
##
?>
<HTML>
<HEAD>
<META content="text/html; charset=<? echo $lang_html_charset; ?>" http-equiv=Content-Type>
<LINK href="<?=$strSkinName?>/style.css" rel=stylesheet type=text/css>
</HEAD>

<BODY bgColor=#ffffff bottomMargin=0 leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0">
<br><? include("../fehler.inc.php"); ?>
<script>
function doChange()
{
document.forms[0].submit();
}
</script>
<table class="tblbgcolor" align="left" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr>
    <TD class="titel-3"  colspan=2>
      <? echo ltext("alst_title1"); ?> <? echo $PHP_AUTH_USER; ?>
      </td></tr>
<?
if ($kundendatenanzeigen == 1) {
?> <tr><td colspan=2 class="titel-3" ><? echo ltext("alst_title2"); ?></td></tr>
<? if (!istleer($firma)) { ?>
<tr> 
          <td> 
            <div align=right> 
            <? echo ltext("alst_cell_firm"); ?></div>
          </td>
          <td> 
            <? echo $firma; ?></td>
        </tr>
        <? }

if (!istleer($name) || !istleer($firstname)) { ?>
        <tr> 
          <td> 
            <div align=right> 
            <? echo ltext("alst_cell_name"); ?></div>
          </td>
          <td> 
            <? echo $firstname."&nbsp;".$name; ?></td>
        </tr>
        <? } 

if (!istleer($anschrift)) { ?> 
        <tr> 
          <td> 
            <div align=right> 
            <? echo ltext("alst_cell_address"); ?></div>
          </td>
          <td> 
            <? echo $anschrift; ?></td>
        </tr>
        <? }
if (!istleer($plzort) || !istleer($plz)) { ?> 
        <tr> 
          <td> 
            <div align="right"><? echo ltext("alst_cell_city"); ?></div>
          </td>
          <td><? echo $plz."&nbsp;".$plzort; ?></td>
        </tr>
        <? }
if (!istleer($telefon)) { ?> 
        <tr> 
          <td> 
            <div align="right">
              <? echo ltext("alst_cell_tel"); ?>
              </div>
          </td>
          <td><? echo $telefon; ?></td>
        </tr>
        <? }
if (!istleer($fax)) { ?> 
        <tr> 
          <td> 
            <div align=right> 
              <? echo ltext("alst_cell_fax"); ?>
              </div>
          </td>
          <td> 
            <? echo $fax; ?></td>
        </tr>
        <? }
if (!istleer($emailadresse)) { ?> 
        <tr> 
          <td> 
            <div align=right>
              <? echo ltext("alst_cell_email"); ?>
              </div>
          </td>
          <td> 
            <? echo $emailadresse; ?></td>
        </tr>
        <? }
if (!istleer($kundennummer)) { ?> 
        <tr> 
          <td> 
            <div align="right">
              <? echo ltext("alst_cell_cid"); ?>
              </div>
          </td>
          <td> <? echo $kundennummer; ?></td>
        </tr>
        <? }
if (!istleer($freifeldwert1)) { ?> 
        <tr> 
          <td> 
            <div align="right"><? echo $freifeldname1; ?></div>
          </td>
          <td> <? echo $freifeldwert1; ?></td>
        </tr>
        <? }
if (!istleer($freifeldwert2)) { ?> 
        <tr> 
          <td> 
            <div align="right"><? echo $freifeldname2; ?></div>
          </td>
          <td> <? echo $freifeldwert2; ?></td>
        </tr>
        <? }
if (!istleer($freifeldwert3)) { ?> 
        <tr> 
          <td> 
            <div align="right"><? echo $freifeldname3; ?></div>
          </td>
          <td> <? echo $freifeldwert3; ?></td>
        </tr>
        <? } ?>
      <? } ?>
      <tr><td colspan=2 class="titel-3" ><? echo ltext("alst_title3"); ?></td></tr>
        <TR> 
          <TD> 
            <DIV align=right>
              <? echo ltext("alst_cell_users"); ?>
              </DIV>
          </TD>
          <TD <? if (($anzahlkunden > $maxkunden) && ($maxkunden <> -1)){ echo "bgcolor=\"$fehlerfarbe\""; } ?>> 
            
            <? echo sinnv_intwert($anzahlkunden,ltext("g_nolimit"))." (".sinnv_intwert($maxkunden,ltext("g_nolimit")).")"; ?></TD>
        </TR>
        <TR> 
          <TD align="right">
            <? echo ltext("alst_cell_space"); ?>
            </TD>
          <TD <? if ( ( ($kbvergeben > $maxkb) || ($kbvergeben == -1) )&& ($maxkb <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>>
             <? echo sinnv_kbwert($kbvergeben,ltext("g_nolimit")); ?> 
            (<? echo sinnv_kbwert($maxkb,ltext("g_nolimit")); ?>)</TD>
        </TR>
        <TR> 
          <TD align="right"> 
            <DIV align=right>
              <? echo ltext("alst_cell_du"); ?>
              </DIV>
          </TD>
          <TD <? if (($kbbenutzt > $maxkb) && ($maxkb <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>> 
            
            <? echo sinnv_kbwert($kbbenutzt,ltext("g_nolimit")); ?></TD>
        </TR>
        <TR> 
          <TD> 
            <div align="right"> 
              <? echo ltext("alst_cell_traffic"); ?>
              <? echo "$monatstr $jahr"; ?>
              </div>
          </TD>
          <TD <? if (($transfer > $maxtransfer) && ($maxtransfer <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; }?>><? echo sinnv_kbwert($transfer,ltext("g_nolimit"))." (". sinnv_kbwert($maxtransfer,ltext("g_nolimit")) .")"; ?></TD>
        </TR>
        <TR> 
          <TD> 
            <DIV align=right>
              <? echo ltext("alst_cell_pop3"); ?>
              </DIV>
          </TD>
          <TD <? if (($pop3 > $maxpop3) && ($maxpop3 <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; }?>> 
            
            <? echo sinnv_intwert($pop3,ltext("g_nolimit"))." (".sinnv_intwert($maxpop3,ltext("g_nolimit")).")"; ?></TD>
        </TR>
        <TR> 
          <TD> 
            <DIV align=right>
              <? echo ltext("alst_cell_email"); ?>
              </DIV>
          </TD>
          <TD <? if (($email > $maxemail) && ($maxemail <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>> 
            
            <? echo sinnv_intwert($email,ltext("g_nolimit"))." (".sinnv_intwert($maxemail,ltext("g_nolimit")).")"; ?></TD>
        </TR>
        <TR> 
          <TD> 
            <DIV align=right>
              <? echo ltext("alst_cell_autoresponder"); ?>
              </DIV>
          </TD>
          <TD <? if (($autoresponder > $maxautoresponder) && ($maxautoresponder <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>> 
            
            <? echo sinnv_intwert($autoresponder,ltext("g_nolimit"))." (".sinnv_intwert($maxautoresponder,ltext("g_nolimit")).")"; ?></TD>
        </TR>
        <TR> 
          <TD align="right">
            <? echo ltext("alst_cell_domains"); ?>
            </TD>
          <TD <? if (($domains > $maxdomains) && ($maxdomains <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>> 
             
            <? echo sinnv_intwert($domains,ltext("g_nolimit")); ?>
            (<? echo sinnv_intwert($maxdomains,ltext("g_nolimit")); ?>)
        </TD>
        </TR>
        <? if ($maxsubdomains != 0) { ?> 
        <TR> 
          <TD> 
            <div align="right">
              <? echo ltext("alst_cell_subdomains"); ?>
              </div>
          </TD>
          <TD <? if (($subdomains > $maxsubdomains) && ($maxsubdomains <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>> 
            <? echo sinnv_intwert($subdomains,ltext("g_nolimit"))." (".sinnv_intwert($maxsubdomains,ltext("g_nolimit")).")"; ?></TD>
        </TR>
        <tr> 
          <td> 
            <div align="right"> 
              <? echo ltext("alst_cell_wildcards"); ?>
              </div>
          </td>
          <td <? if (($wildcards > $maxwildcards) && ($maxwildcards <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>> 
            <? echo sinnv_intwert($wildcards,ltext("g_nolimit"))." (".sinnv_intwert($maxwildcards,ltext("g_nolimit")).")"; ?></td>
        </tr>
        <tr>
          <td>
            <div align="right">
              <? echo ltext("alst_cell_atdomains"); ?>
              </div>
          </td>
          <td <? if (($atdomains > $maxatdomains) && ($maxatdomains <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>>
            <? echo sinnv_intwert($atdomains,ltext("g_nolimit"))." (".sinnv_intwert($maxatdomains,ltext("g_nolimit")).")"; ?></td>
        </tr>
        <? }
if ($maxmysql != 0) { ?> 
        <TR> 
          <TD> 
            <div align="right">
              <? echo ltext("alst_cell_mysql"); ?>
              </div>
          </TD>
          <TD <? if (($mysql > $maxmysql) && ($maxmysql <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>> 
            <? echo sinnv_intwert($mysql,ltext("g_nolimit"))." (".sinnv_intwert($maxmysql,ltext("g_nolimit")).")"; ?></TD>
        </TR>
<? } ?>

<? if($maxcronjobs != 0): ?>
        <TR> 
          <TD> 
            <div align="right">
              <? echo ltext("alst_cell_cron"); ?>
              </div>
          </TD>
          <TD <? if (($cronjobs > $maxcronjobs) && ($maxcronjobs <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>> 
            <? echo sinnv_intwert($cronjobs,ltext("g_nolimit"))." (".sinnv_intwert($maxcronjobs,ltext("g_nolimit")).")"; ?></TD>
        </TR>
<? endif; ?>
	
<? if($maxmaillist != 0): ?>
         <TR>
           <TD>
             <div align="right">
               <? echo ltext("alst_cell_maillist"); ?>
               </div>
           </TD>
           <TD <? if (($maillist > $maxmaillist) && ($maxmaillist <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>>
             <? echo sinnv_intwert($maillist,ltext("g_nolimit"))." (".sinnv_intwert($maxmaillist,ltext("g_nolimit")).")"; ?></TD>
         </TR>
<? endif; ?>

<?	
if ($maxftp != 0) { ?> 
        <td> 
            <div align="right">
              <? echo ltext("alst_cell_ftp"); ?>
              </div>
        </td>
        <td <? if (($usedftp > $maxftp) && ($maxftp <> -1)) { echo "bgcolor=\"$fehlerfarbe\""; } ?>> 
          <? echo sinnv_intwert($usedftp,ltext("g_nolimit"))." (".sinnv_intwert($maxftp,ltext("g_nolimit")).")"; ?></td>
        </tr>
        <? } ?>
      <tr><td colspan=2><? echo ltext("alst_descr1"); ?>
    </TD>
  </TR>
</TABLE>
</BODY>
</HTML>
