Tal vez este otro php pueda ayudar. Este seria para update o habilitar las cuentas ya expiradas
Código PHP:
<?php
include("global.php");
if( !isset($_REQUEST["account"]) )
{
echo("ERROR: No account was specified.");
die;
}
$account = entry_filter($_REQUEST["account"]);
$status_message_info = "";
$status_message_server = "";
$status_message_service = "";
// -- check if it is a valid sub-account for this username
if( (int)query_scalar("select count(*) from accounts where username = '$G_username' and ".
"account = '$account'") == 0)
{
echo("ERROR: Invalid account specified.");
die;
}
// -- update account information
if( isset($_REQUEST["update"]) and isset($_REQUEST["account"]) and isset($_REQUEST["password"]) )
{
$_REQUEST["account"] = entry_filter( $_REQUEST["account"] );
$_REQUEST["password"] = entry_filter( $_REQUEST["password"] );
if( $_REQUEST["password"] <> "" )
{
$server_status_description = "";
if( server_update_account_password(get_effective_account($account, $G_user_account_prefix),
$_REQUEST["password"], $server_status_description) )
{
if( db_update("accounts", array("password" => $_REQUEST["password"]), "username = '$G_username' and ".
"account = '".$_REQUEST["account"]."'") )
{
$status_message_info = grs("ACCOUNT_ACTIONS_UPDATE_SUCCESS");
}
else $status_message_info = grs("ACCOUNT_ACTIONS_UPDATE_FAILURE");
}
else $status_message_info = "SERVER: ".$server_status_description;
}
}
// -- add service months
if( isset($_REQUEST["add_service_months"]) and isset($_REQUEST["add_months"]) and isset($_REQUEST["account"]) )
{
// -- add record to the database
if( (get_credit_balance( $G_username ) - (int)$_REQUEST["add_months"]) >= 0 )
{
$current_date = date("Ymd");
$account_expiry = query_scalar("select date_format(expires, '%Y%m%d') from accounts where ".
"username = '$G_username' and account = '$account'");
if( ((int)$account_expiry) > ((int)$current_date) )
{
$base_timestamp = mktime(0, 0, 0,
substr($account_expiry, 4, 2),
substr($account_expiry, 6, 2),
substr($account_expiry, 0, 4));
$coverage_start = $base_timestamp + (3600 * 24 * 1);
}
else
{
$base_timestamp = mktime(0, 0, 0,
substr($current_date, 4, 2),
substr($current_date, 6, 2),
substr($current_date, 0, 4));
$coverage_start = $base_timestamp;
}
$coverage_end = $base_timestamp + ((3600 * 24 * $G_days_per_month) * (int)$_REQUEST["add_months"]);
$server_status_description = "";
if( server_update_account_expiry(get_effective_account($account, $G_user_account_prefix),
$coverage_end, $server_status_description) )
{
mysql_begin();
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" => $account,
"timestamp" => date("Y-m-d H:i:s"),
"coverage_start" => date("Y-m-d", $coverage_start),
"coverage_end" => date("Y-m-d", $coverage_end)) ) )
{
if( mysql_query("update accounts set expires = (select max(coverage_end) from transactions ".
"where username = '$G_username' and account = '$account') where username = '$G_username' ".
"and account = '$account'") )
{
mysql_commit();
$status_message_service = grs("ACCOUNT_ACTIONS_ADD_SUCCESS");
}
else
{
$status_message_service = grs("ACCOUNT_ACTIONS_ADD_FAILURE");
mysql_rollback();
}
}
else
{
$status_message_service = grs("ACCOUNT_ACTIONS_ADD_FAILURE");
mysql_rollback();
}
}
else $status_message_service = "SERVER: ".$server_status_description;
}
else $status_message_service = grs("ACCOUNT_ACTIONS_ADD_INSUFFICIENT");
}
$rs_account = mysql_query("select password, unix_timestamp(expires) as expires from accounts where username = '$G_username' and ".
"account = '$account'");
$rw_account = mysql_fetch_assoc( $rs_account );
if( !$rw_account )
{
echo("ERROR: Invalid account was specified.");
die;
}