Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/tabs/b.php
<?php

include('attrshow.php'); 
echo "
<title>subscription analysis for $pullUser</title>";
$now = time();
$num = 0;

$now_str = $oreon->database->database->escape_string($now_str);
$prev_str = $oreon->database->database->escape_string($prev_str);
echo "
<head>
<title>subscription analysis for $pullUser</title>
</head>
<center>
<table class=\"tabTable\"  border=0 width=550 cellpadding=0 cellspacing=0>
</table>
<br>
<table class=\"tabTable\"  border=0 width=1040 cellpadding=1 cellspacing=1>
<tr valign=top>
<td  width=65%></td>
<td bgcolor=\"black\" width=35%>
	<table class=\"tabTable\" border=0 width=100% cellpadding=2 cellspacing=0>
	<tr bgcolor=\" #666699\" align=right valign=top><th>
	<font color=\"white\">Subscription Analysis for $pullUser</font>&nbsp;
	</th></tr>
	</table>
</td></tr>
<tr bgcolor=\"black\" valign=top><td  colspan=2>
	<table class=\"tabTable\" border=0 width=100% cellpadding=12 cellspacing=0  valign=top>
	<tr><td class=\"bl\" >

<p>
	<table class=\"tabTable\" border=1 bordercolordark=#ffffe0 bordercolorlight=#000000 width=100% cellpadding=2 cellspacing=0  valign=top>
	<tr bgcolor=\"#D7E5F2\" >
	<th >#</th>";

for($i=1;$i<=9;$i++){
	if ($acct_attrs["ua"]["$i"] != '')
		echo "<th>" . $acct_attrs['ua']["$i"] . "</th>\n";
}

echo "</tr>";

$search = "SELECT * FROM radacct WHERE username = '$pullUser'  ORDER BY acctstarttime $order $limit;";
$acct_sessiontime_sum='';
$acct_upload_sum='';
$acct_download_sum='';
$result = $oreon->database->database->query($search) or die("Query database error !");
if ($result){
  $arrayres=$oreon->database->database->fetch_array($result);
   while( $arrayres != NULL && $row = array_change_key_case($arrayres)) {
    $arrayres=$oreon->database->database->fetch_array($result);
    $tr_color='White';
    $num++;
    $acct_type = $row['framedprotocol'].'/'.$row['nasporttype'];
    if ($acct_type == '')
      $acct_type = '-';
    $acct_logedin = $row['acctstarttime'];
    $acct_sessiontime = $row['acctsessiontime'];
    $acct_sessiontime_sum += $acct_sessiontime;
    $acct_sessiontime = time2str($acct_sessiontime);
    $acct_ip = $row['framedipaddress'];
    if ($acct_ip == '')
      $acct_ip = '-';
    $acct_upload = $row["$acctinputoctetsattr"];
    $acct_upload_sum += $acct_upload;
    $acct_upload = octets2str($acct_upload);
    $acct_download = $row["$acctoutputoctetsattr"];
    $acct_download_sum += $acct_download;
    $acct_download = octets2str($acct_download);
    $acct_server = $row['nasipaddress'];
    if ($acct_server != ''){
      $acct_server = $da_name_cache[$row['nasipaddress']];
      if (!isset($acct_server)){
	$acct_server = @gethostbyaddr($row['nasipaddress']);
      }
    }
    else
      $acct_server = '-';
    
    $acct_server = $acct_server.":".$row['nasportid'];
    $acct_terminate_cause = $row['acctterminatecause'];
    if ($acct_terminate_cause == '')
      $acct_terminate_cause = '-';
    if (ereg('Login-Incorrect',$acct_terminate_cause) ||
	ereg('Multiple-Logins', $acct_terminate_cause) || ereg('Invalid-User',$acct_terminate_cause))
      $tr_color='#ffe8e0';
    $acct_callerid = $row['callingstationid'];
    if ($acct_callerid == '')
      $acct_callerid = '-';
    echo "<tr align=center bgcolor=\"$tr_color\">
    <td class=\"bl\" ><small>$num</small></td>";
    if ($acct_attrs['ua'][1] != '') echo "<td class=\"bl\" ><small>$acct_type</small></td>\n";
    if ($acct_attrs['ua'][2] != '') echo "<td class=\"bl\" ><small>$acct_logedin</small></td>\n";
    if ($acct_attrs['ua'][3] != '') echo "<td class=\"bl\" ><small>$acct_sessiontime</small></td>\n";
    if ($acct_attrs['ua'][4] != '') echo "<td class=\"bl\" ><small>$acct_ip</small></td>\n";
    if ($acct_attrs['ua'][5] != '') echo "<td class=\"bl\" ><small>$acct_upload</small></td>\n";
    if ($acct_attrs['ua'][6] != '') echo "<td class=\"bl\" ><small>$acct_download</small></td>\n";
    if ($acct_attrs['ua'][7] != '') echo "<td class=\"bl\" ><small>$acct_server</small></td>\n";
    if ($acct_attrs['ua'][8] != '') echo "<td class=\"bl\" ><small>$acct_terminate_cause</small></td>\n";
    if ($acct_attrs['ua'][9] != '') echo "<td class=\"bl\" ><small>$acct_callerid</small></td>\n";
    echo "</tr>\n";
  }
  $acct_sessiontime_sum = time2str($acct_sessiontime_sum);
  $acct_upload_sum = octets2str($acct_upload_sum);
  $acct_download_sum = octets2str($acct_download_sum);
}
else
echo "<b>Database query failed: </b><br>\n";

$colspan = 3;
if ($acct_attrs['ua']['1'] == '')
     $colspan--;
if ($acct_attrs['ua']['2'] == '')
	$colspan--;
echo "
			<tr bgcolor=\"lightyellow\">
			<td class=\"bl\" colspan=$colspan align=\"right\"><b>Page Total</b></td>";
			if ($acct_attrs['ua'][3] != '') echo "<td align=\"center\"><b><small>$acct_sessiontime_sum</small></td>\n";
				if ($acct_attrs['ua'][4] != '') echo "<td   >&nbsp;</td>\n";
				if ($acct_attrs['ua'][5] != '') echo "<td   align=\"right\" nowrap><small><b>$acct_upload_sum</small></td>\n";
				if ($acct_attrs['ua'][6] != '') echo "<td   align=\"right\" nowrap><small><b>$acct_download_sum</small></td>\n";
				if ($acct_attrs['ua'][7] != '') echo "<td>&nbsp;</td>\n";
				if ($acct_attrs['ua'][8] != '') echo "<td>&nbsp;</td>\n";
				if ($acct_attrs['ua'][9] != '') echo "<td>&nbsp;</td>\n";
echo "</tr>";
echo "</table>";
echo '<br>';
echo '';
if ($Type=="Hourly" or $Type=="Subscription Time") 
{
printf("<form  action=\"bill.php\" target=\"_blank\" method=\"post\" >");
echo ('<input type="hidden" name="buttonID" value="bill_user_time"> ');
echo ("<input type=\"hidden\" name=\"usr\" value=\"$pullUser\"> ");
echo ("<input type=\"hidden\" name=\"time\" value=\"$Max\"> ");
echo ("<input type=\"hidden\" name=\"billingplan\" value=\"$idBp\"> ");
echo ("<input type=\"hidden\" name=\"phpmyprepaid\" value=\"".session_id()."\"> ");
echo ("<input type=\"submit\" name=\"submit\" action=\"bill.php\" class=\"button\" value=\"Bill User based on connection time \"/>");
echo '</form>';
 
}
else if ($Type=="Octets" or $Type=="Subscription Octets")
{
printf("<form  action=\"bill.php\" target=\"_blank\" method=\"post\" >");
echo ('<input type="hidden" name="buttonID" value="bill_user_octet"> ');
echo ("<input type=\"hidden\" name=\"usr\" value=\"$pullUser\"> ");
echo ("<input type=\"hidden\" name=\"octet\" value=\"$Max\"> ");
echo ("<input type=\"hidden\" name=\"billingplan\" value=\"$idBp\"> ");
echo ("<input type=\"hidden\" name=\"phpmyprepaid\" value=\"".session_id()."\"> ");
echo ("<input type=\"submit\" name=\"submit\" class=\"button\" value=\"Bill User based on download mega octet \"/>");
echo '</form>';
}
else if ($Type=="Subscription Expiration" or $Type="Expiration")
{
printf("<form  action=\"bill.php\" target=\"_blank\" method=\"post\" >");
echo ("<input type=\"hidden\" name=\"usr\" value=\"$pullUser\"> ");
echo ("<input type=\"hidden\" name=\"expiration\" value=\"$Max\"> ");
echo ("<input type=\"hidden\" name=\"billingplan\" value=\"$idBp\"> ");
echo ("<input type=\"hidden\" name=\"phpmyprepaid\" value=\"".session_id()."\"> ");
echo ('<input type="hidden" name="buttonID" value="bill_user_expiration"> ');
echo ("<input type=\"submit\" name=\"submit\" class=\"button\" value=\"Bill User based on expiration date \"/>");
echo '</form>';
}
		

 echo "

</table>
</tr>
</table>";
?>
Return current item: phpMyPrepaid