Código PHP:
<?php
include("global.php");
$_METHOD = "post";
$_INCLUDER = "reseller-home.php";
include("header.php");
$status_message = "";
if( !isset($_REQUEST["show"]) ) $_REQUEST["show"] = "";
if( $_REQUEST["show"] == "" ) $_REQUEST["show"] = "not_expired";
if( !isset($_REQUEST["order_by"]) ) $_REQUEST["order_by"] = "";
if( $_REQUEST["order_by"] == "" ) $_REQUEST["order_by"] = "name";
// -- add account
if( !$G_disable_reseller_subaccount_creation )
{
if( isset($_REQUEST["add"]) and isset($_REQUEST["add_username"]) and isset($_REQUEST["add_password"]) and
isset($_REQUEST["add_months"]) )
{
$_REQUEST["add_username"] = entry_filter($_REQUEST["add_username"]);
$_REQUEST["add_password"] = entry_filter($_REQUEST["add_password"]);
$current_date = date("Ymd", time());
$coverage_start = mktime(0, 0, 0,
substr($current_date, 4, 2),
substr($current_date, 6, 2),
substr($current_date, 0, 4));
$coverage_end = $coverage_start + ((3600 * 24 * $G_days_per_month) * (int)$_REQUEST["add_months"]);
if( (get_credit_balance( $G_username ) - (int)$_REQUEST["add_months"]) >= 0 )
{
// -- check if account already exists
if( (int)query_scalar("select count(*) from accounts where username = '$G_username' and ".
"upper(account) = '".strtoupper($_REQUEST["add_username"])."'") == 0 )
{
// -- add server user
$server_status_description = "";
$effective_account = get_effective_account($_REQUEST["add_username"], $G_user_account_prefix);
if( server_add_account($effective_account, $_REQUEST["add_password"], $coverage_end, TRUE,
sprintf($G_fslb_global_account_comment, $G_username), $server_status_description) )
{
// -- add record to the database
include("acltvh.php");
mysql_begin();
if( db_insert("accounts", array(
"username" => $G_username,
"account" => $_REQUEST["add_username"],
"password" => $_REQUEST["add_password"],
"filename1" => $filename1,
"expires" => date("Y-m-d", $coverage_end)) ) )
{
if( db_insert("transactions", array(
"username" => $G_username,
"transaction" => (int)query_scalar("select max(transaction) + 1 from transactions where username = '$G_username'"),
"type" => "DBIT",
"periods" => (int)$_REQUEST["add_months"],
"account" => $_REQUEST["add_username"],
"timestamp" => date("Y-m-d H:i:s"),
"coverage_start" => date("Y-m-d", $coverage_start),
"coverage_end" => date("Y-m-d", $coverage_end)) ) )
{
mysql_commit();
header("Location: reseller-home.php");
die;
}
else
{
$status_message = grs("HOME_ADD_FAILED");
mysql_rollback();
}
}
else
{
$status_message = grs("HOME_ADD_FAILED");
mysql_rollback();
}
}
else $status_message = "SERVER: ".$server_status_description;
}
else $status_message = grs("HOME_ADD_ALREADY_EXISTS");
}
else $status_message = grs("HOME_ADD_INSUFFICIENT_CREDIT");
}
}
// -- get user sub-accounts
if( $_REQUEST["order_by"] == "expiry_date")
$query_order_by = "expires";
else
$query_order_by = "account";
switch( $_REQUEST["show"] )
{
case "expired":
$query_show = "and expires < current_date()";
break;
case "not_expired":
$query_show = "and expires >= current_date()";
break;
default:
$query_show = "";
break;
}
$rs_accounts = mysql_query("select account, password, unix_timestamp(expires) as expires from accounts where username = ".
"'$G_username' ".$query_show." order by ".$query_order_by);
// -- handle paging
$page_index = 1;
if( isset($_REQUEST["page_index"]) ) $page_index = (int)entry_filter($_REQUEST["page_index"]);
$page_count = ((int)(mysql_num_rows( $rs_accounts ) / $G_reselled_accounts_per_page)) + 1;
if( isset($_REQUEST["page_first"]) ) $page_index = 1;
if( isset($_REQUEST["page_previous"]) ) $page_index = (int)entry_filter($_REQUEST["page_index"]) - 1;
if( isset($_REQUEST["page_next"]) ) $page_index = (int)entry_filter($_REQUEST["page_index"]) + 1;
if( isset($_REQUEST["page_last"]) ) $page_index = $page_count;
// -- correct page index if needed
if( $page_index < 1 ) $page_index = 1;
if( $page_index > $page_count) $page_index = $page_count;
?>