Foros del Web » Programando para Internet » PHP »

Como integrar 2

Estas en el tema de Como integrar 2 en el foro de PHP en Foros del Web. no se mucho en el tema de mysql y php pero espero puedan ayudarme. Anadi a mi tabla de mysql 2 nuevos campos y quiero ...
  #1 (permalink)  
Antiguo 01/12/2015, 02:23
 
Fecha de Ingreso: noviembre-2015
Mensajes: 13
Antigüedad: 8 años, 5 meses
Puntos: 0
Como integrar 2

no se mucho en el tema de mysql y php pero espero puedan ayudarme. Anadi a mi tabla de mysql 2 nuevos campos y quiero integrarlo en un php de un admin panel que no cree yo. Necesito que filename1 y filename2 trabajen como account en este php. He tratado de todas las maneras que conosco que no es mucha experiencia la que tengo, soy un total novato. Les dejo la informacion de las tablas y el php para que me puedan comentar cual puede ser la mejor forma.

Table structure for table `accounts`
--

CREATE TABLE `accounts` (
`username` varchar(64) NOT NULL,
`account` varchar(64) NOT NULL,
`password` varchar(64) NOT NULL,
`filename1` varchar(64) NOT NULL,
`filename2` varchar(64) NOT NULL,
`expires` datetime NOT NULL,
PRIMARY KEY (`username`,`account`,`filename1`,`filename2`),
KEY `fk_username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `accounts`
--


-- --------------------------------------------------------

--
-- Table structure for table `transactions`
--

CREATE TABLE `transactions` (
`username` varchar(64) NOT NULL,
`transaction` int(10) unsigned NOT NULL,
`type` enum('CRDT','DBIT') NOT NULL,
`periods` int(10) unsigned NOT NULL,
`amount` decimal(10,2) default NULL,
`account` varchar(64) default NULL,
`filename1` varchar(64) NOT NULL,
`filename2` varchar(64) NOT NULL,
`timestamp` datetime NOT NULL,
`coverage_start` datetime default NULL,
`coverage_end` datetime default NULL,
PRIMARY KEY (`transaction`,`username`),
KEY `fk_user` (`username`),
KEY `fk_account` (`username`,`account`,`filename1`,`filename2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `transactions`
--


-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
`username` varchar(64) NOT NULL,
`password` varchar(64) NOT NULL,
`name` varchar(128) NOT NULL,
`type` enum('ROOT','SRSLR','RSLR') NOT NULL default 'RSLR',
`accounts_prefix` varchar(16) default NULL,
`username_owner` varchar(64) default NULL,
`status` enum('A','S') NOT NULL default 'A',
`comments` varchar(128) default NULL,
`current_login_time` datetime default NULL,
`last_login_time` datetime default NULL,
`credit` int(10) default NULL,
PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


[PHP]<?php
include("global.php");

if( ($G_user_type <> "ROOT") and ($G_user_type <> "SRSLR") ) { header("Location: logout.php"); die; }

if( !isset($_REQUEST["username"]) )
{
echo("ERROR: No reseller was specified.");
die;
}

$reseller = entry_filter($_REQUEST["username"]);
$status_message = "";

// -- check if it is a valid reseller username
if( $G_user_type == "SRSLR" )
{
if( query_scalar("select username_owner from users where username = '$reseller'") <> $G_username )
{
echo("ERROR: Invalid reseller specified.");
die;
}
}

// -- update subaccount expiry
if( isset($_REQUEST["update"]) )
{
$_REQUEST["update"] = entry_filter($_REQUEST["update"]);

if( !isset($_REQUEST["new_expiry"]) )
{
echo("ERROR: No new expiry date was specified.");
die;
}
$_REQUEST["new_expiry"] = entry_filter($_REQUEST["new_expiry"]);
$expiry_timestamp = text_datetime_to_timestamp($_REQUEST["new_expiry"]);

$effective_account = get_effective_account($_REQUEST["update"], query_scalar("select accounts_prefix from users where username = '$reseller'"));
if( server_update_account_expiry($effective_account, $expiry_timestamp, $server_status_description) )
{
mysql_begin();
if( db_update("accounts", array("expires" => date("Y-m-d", $expiry_timestamp)), "username = '$reseller' and account = '{$_REQUEST["update"]}'") )
{
$status_message = grs("RESELLER_SUBACCOUNT_EXPIRY_UPDATE_SUCCESS");
mysql_commit();
}
else
{
$status_message = grs("RESELLER_SUBACCOUNT_EXPIRY_UPDATE_FAILURE");
mysql_rollback();
}
}
else $status_message = "SERVER: ".$server_status_description;
}

// -- delete subaccount
if( isset($_REQUEST["delete"]) )
{
$_REQUEST["delete"] = entry_filter($_REQUEST["delete"]);

mysql_begin();
if( db_delete("transactions", "type = 'DBIT' and username = '$reseller' and account = '{$_REQUEST["delete"]}'") )
{
if( db_delete("accounts", "username = '$reseller' and account = '{$_REQUEST["delete"]}'") )
{
$status_message = grs("RESELLER_SUBACCOUNT_DELETE_SUCCESS");
mysql_commit();

$server_status_message = "";
$effective_account = get_effective_account($_REQUEST["delete"], query_scalar("select accounts_prefix from users where username = '$reseller'"));
if( !server_delete_account($effective_account, $server_status_message) )
$status_message .= ". ".grs("RESELLER_SUBACCOUNT_SERVER_WASNT_DELETED"). ": [$server_status_message]";
}
else
{
$status_message = grs("RESELLER_SUBACCOUNT_DELETE_FAILURE");
mysql_rollback();
}
}
else
{
$status_message = grs("RESELLER_SUBACCOUNT_DELETE_FAILURE");
mysql_rollback();
}
}

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( $reseller ) - (int)$_REQUEST["add_months"]) >= 0 )
{
// -- check if account already exists
if( (int)query_scalar("select count(*) from accounts where username = '$reseller' and ".
"upper(account) = '".strtoupper($_REQUEST["add_username"])."'") == 0 )
{
// -- add server user
$server_status_description = "";
$effective_account = get_effective_account($_REQUEST["add_username"], query_scalar("select accounts_prefix from users where username = '$reseller'"));
if( server_add_account($effective_account, $_REQUEST["add_password"], $coverage_end, TRUE,
sprintf($G_fslb_global_account_comment, $reseller), $server_status_description) )
{
// -- add record to the database
mysql_begin();
if( db_insert("accounts", array(
"username" => $reseller,
"account" => $_REQUEST["add_username"],
"password" => $_REQUEST["add_password"],
"expires" => date("Y-m-d", $coverage_end)) ) )
{
if( db_insert("transactions", array(
"username" => $reseller,
"transaction" => (int)query_scalar("select max(transaction) + 1 from transactions where username = '$reseller'"),
"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: sr-reseller-subaccounts.php?username=$reseller");
die;
}
else
{
$status_message_add = grs("HOME_ADD_FAILED");
mysql_rollback();
}
}
else
{
$status_message_add = grs("HOME_ADD_FAILED");
mysql_rollback();
}
}
else $status_message_add = "SERVER: ".$server_status_description;
}
else $status_message_add = grs("HOME_ADD_ALREADY_EXISTS");
}
else $status_message_add = grs("HOME_ADD_INSUFFICIENT_CREDIT");
}

$rs_reseller = mysql_query("select name, status, accounts_prefix from users where username = '$reseller'");
$rw_reseller = mysql_fetch_assoc( $rs_reseller );
if( !$rw_reseller )
{
echo("ERROR: Invalid reseller was specified.");
die;
}
  #2 (permalink)  
Antiguo 01/12/2015, 02:23
 
Fecha de Ingreso: noviembre-2015
Mensajes: 13
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Como integrar 2

esta es la continuacion del php

// -- get reseller sub-accounts
$rs_accounts = mysql_query("select account, password, unix_timestamp(expires) as expires, ".
"(select count(*) from transactions t where t.username = a.username and t.account = a.account) as ".
"transaction_count from accounts a where a.username = '$reseller' order by a.account");
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<link href="themes/<?php echo($G_theme); ?>/style.css" type="text/css" rel="stylesheet">
<title><?php grse("APP_NAME"); ?></title>
<script type="text/javascript" language="javascript"><!--
function save_expiry( account )
{
root_form = document.forms[0];

if( !confirm('<?php grse("RESELLER_SUBACCOUNT_EXPIRY_DATE_CHANGE_CONFI RM"); ?>.') ) return;

save_expiry_url = 'sr-reseller-subaccounts.php?scrollLeft=' +
escape(root_form.scrollLeft.value) + '&scrollTop=' +
escape(root_form.scrollTop.value) + '&__postback=1&username=<?php echo( $reseller ); ?>' +
'&update=' + account + '&new_expiry=' + root_form.new_expiry.value;

location.href = save_expiry_url;
}

function delete_subaccount( account )
{
root_form = document.forms[0];

if( !confirm('<?php grse("RESELLER_SUBACCOUNT_DELETE_CONFIRM"); ?>.') ) return;

delete_subaccount_url= 'sr-reseller-subaccounts.php?scrollLeft=' +
escape(root_form.scrollLeft.value) + '&scrollTop=' +
escape(root_form.scrollTop.value) + '&__postback=1&username=<?php echo( $reseller ); ?>' +
'&delete=' + account;

location.href = delete_subaccount_url;
}

function add_account()
{
root_form = document.forms[0];

if( root_form.add_username.value != '' && root_form.add_password.value != '' && root_form.add_months.value != '' )
{
if( !confirm('<?php grse("RESELLER_SUBACCOUNT_ADD_CONFIRM"); ?>.') ) return;

add_account_url = 'sr-reseller-subaccounts.php?scrollLeft=' +
escape(root_form.scrollLeft.value) + '&scrollTop=' +
escape(root_form.scrollTop.value) + '&__postback=1&username=<?php echo( $reseller ); ?>' +
'&add=1&add_username=' + escape(root_form.add_username.value) + '&add_password=' +
escape(root_form.add_password.value) + '&add_months=' + escape(root_form.add_months.value);

location.href = add_account_url;
}
else alert('<?php grse("HOME_ADD_OBLIGATORY"); ?>.');
}
// -->
</script>
</head>

<body>
<form name="root" action="sr-reseller-subaccounts.php" method="post">
<input type="hidden" name="username" value="<?php echo($reseller); ?>">
<table border="0" width="100%" id="tblSection_1">
<tr>
<td colspan="7" class="sectionTitle"><?php grse("RESELLER_EDIT_INFO"); ?></td>
</tr>
<tr>
<td width="25"></td>
<td class="fieldTitle" width="160"><?php grse("RESELLER_EDIT_RESELLER") ?>:</td>
<td><?php echo( $reseller ); ?></td>
</tr>
<tr>
<td width="25"></td>
<td class="fieldTitle" width="160"><?php grse("RESELLER_EDIT_NAME"); ?>:</td>
<td><?php echo( $rw_reseller["name"]); ?></td>
</tr>
<tr>
<td width="25"></td>
<td class="fieldTitle" width="160"><?php grse("RESELLER_EDIT_STATUS"); ?>:</td>
<td><?php
switch( $rw_reseller["status"] )
{
case "A":
grse("RESELLER_EDIT_ACTIVE");
break;

case "S":
grse("RESELLER_EDIT_SUSPENDED");
break;

default:
grse("RESELLER_EDIT_UNKNOWN");
break;
}
?></td>
</tr>
<tr>
<td width="25"></td>
<td class="fieldTitle" width="160"><?php grse("RESELLER_EDIT_CREDIT_BALANCE"); ?>:</td>
<td><?php echo( get_credit_balance( $reseller ) ); ?></td>
</tr>
<tr>
<td width="25"></td>
<td class="fieldTitle" width="160"><hr></td>
<td><hr></td>
</tr>
<tr>
<td width="25"></td>
<td class="fieldTitle" width="160"></td>
<td class="errorMessage"><?php if( $status_message <> "" ) echo( $status_message )."."; ?></td>
</tr>
</table>
<br>
<table border="0" width="100%" id="tblSection_2">
<tr>
<td class="sectionTitle"><?php grse("RESELLER_SUBACCOUNT_LIST"); ?></td>
</tr>
<tr>
<td>
<table border="0" width="100%">
<tr class="listHeader">
<td width="30%"><?php grse("HOME_LIST_SUBACCOUNT"); ?></td>
<td width="20%"><?php grse("HOME_LIST_PASSWORD"); ?></td>
<td width="30%"><?php grse("HOME_LIST_EXPIRY_DATE"); ?></td>
<td width="10%"><?php grse("RESELLER_SUBACCOUNT_TRANSACTION_COUNT"); ?></td>
<td width="10%"></td>
</tr>
<?php
if( mysql_num_rows( $rs_accounts ) )
{
while( ($rw_account = mysql_fetch_assoc( $rs_accounts )) )
{
?>
<tr>
<td width="30%"><?php echo( get_effective_account($rw_account["account"], $rw_reseller["accounts_prefix"]) ); ?></td>
<td width="20%"><?php echo($rw_account["password"]); ?></td>
<td width="30%"><?php
if( isset($_REQUEST["update_expiry"]) )
{
if($_REQUEST["update_expiry"] == $rw_account["account"])
$edit_mode = TRUE;
else
$edit_mode = FALSE;
}
else $edit_mode = FALSE;

if( $edit_mode )
{
echo("<input type=\"text\" name=\"new_expiry\" size=\"15\" maxlength=\"10\" value=\""._date_format($rw_account["expires"])."\">");
echo(" [<a href=\"javascript:save_expiry('{$rw_account["account"]}');\">".grs("RESELLER_SUBACCOUNT_EXPIRY_DATE_SAVE ")."</a>]");
}
else
{
echo(_date_format($rw_account["expires"]));
echo(" [<a href=\"sr-reseller-subaccounts.php?username=$reseller&update_expiry={ $rw_account["account"]}\">".grs("RESELLER_SUBACCOUNT_EXPIRY_DATE_CHANGE" )."</a>]");
}
?></td>
<td width="10%"><?php echo($rw_account["transaction_count"]); ?></td>
<td width="10%"><a href="javascript:delete_subaccount('<?php echo($rw_account["account"]); ?> ');"><?php grse("RESELLER_MANAGEMENT_DELETE"); ?></a></td>
</tr>
<?php[/PHP]

Etiquetas: integrar, mysql, select, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:55.