linpc
Гуру форума
- Регистрация
- 6 Апр 2012
- Сообщения
- 178
- Реакции
- 55
- Автор темы
- #1
Подскажите пожалуйста, после выполнения кода допустим, если если нажмут перегрузить фрейм то данные снова добавятся, как дубликат, как мне это исправить?
PHP:
$timenow = time();
if(isset($_POST['post_id']) and trim($_POST['post_id']) and $_POST['post_id']=='2'){
if(isset($_POST['act']) and trim($_POST['act']) and $_POST['act']=='4' and $_POST['vcode'] == md5( $_SESSION['u'].".account" )){
foreach ( $_POST as $key => $value )
{
if ( strpos( $key, "SID_" ) !== false )
{
$SSQL .= ( $SSQL ? "," : "" ).intval( $value );
}
}
if (isset($SSQL) )
{
$serv_min = 2000000000;
$res = mysql_query( "SELECT users_services.service_type,users_services.time,service_types.service_class FROM users_services,service_types WHERE users_services.playerid=".$player['id']." AND service_types.service_type=users_services.service_type" );
while ($rx = mysql_fetch_row( $res ) )
{
if ( $timenow < $rx[1] )
{
if ( $rx[1] < $serv_min )
{
$serv_min = $rx[1];
}
$_SESSION['PA'] |= pow( 2, $rx[0] );
if ( 259200 < $rx[1] - $timenow )
{
$stype[] = $rx[2];
}
else
{
$active[$rx[2]] = $rx[1];
}
}
}
$res = mysql_query( "SELECT service_list.service_type,service_list.service_days,service_list.service_dnv,service_types.service_class FROM service_list,service_types WHERE service_list.list_id IN (".$SSQL.") AND service_types.service_type=service_list.service_type" );
$dnv = 0;
$newserv = array( );
if ($rx = mysql_fetch_row( $res ) )
{
if ( $rx[0] == 18 )
{
$wmlog = date( "d.m.Y H:i", $timenow )."|".$player['login']."|".$rx[2];
}
else
{
if ( in_array( $rx[0], array( 18, 19, 20 ) ) )
{
$CLSQL .= !$CLSQL ? "INSERT INTO service_clients (playerid,service_type,service_dnv,service_time) VALUES (".$player['id'].",".$rx[0].",".$rx[2].",".$timenow.")" : ",(".$player['id'].",".$rx[0].",".$rx[2].",".$timenow.")";
}
$newserv[$rx[3]] = array( $rx[1], $rx[2], $rx[0] );
$dnv += floatval( $rx[2] );
}
}
$fault = 1;
print_r(mysql_num_rows( $res ));
if(( 0 < mysql_num_rows( $res ) )){
if (isset($fault) )
{
$dnv = round( $dnv, 2 );
$dmo = round( floatval( $player['dhr'] ), 2 );
if ( $dnv <= $dmo )
{
mysql_query( "UPDATE user SET dhr=dhr-".$dnv." WHERE id=".$player['id']." AND dhr>=".$dnv );
$player['dhr'] = $dmo - $dnv;
$oper_log = $dnv." DNL списано со счета персонажа ".$player['login'];
$timemax = 0;
foreach ( $newserv as $key => $value )
{
$oper_log .= "\n".( "Сервис (класс: " ).$key." тип: ".$value[2]." / ".$value[0]." суток) ";
$stime = !$active[$key] ? $timenow + 86400 * $value[0] : $active[$key] + 86400 * $value[0];
if ( $timemax < $stime )
{
$timemax = $stime;
}
if ( $stime < $serv_min )
{
$serv_min = $stime;
}
mysql_query( "INSERT INTO users_services (playerid,service_type,time) VALUES (".$player['id'].",".$value[2].",".$stime.")" );
$oper_log .= "TRUE";
$_SESSION['PA'] |= pow( 2, $value[2] );
}
if ( $player['account'] < $timemax )
{
$oper_log .= "\n".( "Время аккаунта в таблице user " );
mysql_query( "UPDATE user SET account=".$timemax." WHERE id=".$player['id'] );
$oper_log .= "TRUE";
}
if ( $CLSQL )
{
$oper_log .= "\n".( "Фиксирование в таблице клиентов " );
mysql_query( $CLSQL );
$oper_log .= "TRUE";
}
mysql_query( "UPDATE user SET account_min=".$serv_min.",access=".$_SESSION['PA']." WHERE id=".$player['id'] );
$player['access'] = $_SESSION['PA'];
$player['account_min'] = $serv_min;
mail( "kuzmenko@ussurstroydvor.ru", "Платные сервисы", $oper_log."\n\n".microtime( )." ".uniqid( mt_rand( ) ), "From: NeverLands Service <robot@neverlands.ru>" );
}
}
}else{
echo'fff';
}
}
}
}