Solo usuarios registrados pueden comentar y agradecer, Logueate o Registrate

Autor Topic: Modulo exchangue (ayuda php) -Mu core 1.8  (Visto 1005 veces)

0 Miembros and 1 Guest are viewing this topic.

Offline ivaancruzz Posteado: August 10, 2017, 10:43:18 PM

  • 0 puntos por ventas
  • *
  • Rank: Puto amo
  • Posts: 442
  • Gracias recibida: 2317
  • ar
Buenas, que tal, queria saber si me pueden dar una mano.
e editado el archivo del modulo exchangue , lo modifique para que solamente pueda dar creditos por reset y horas jugadas, el tema es que quisiera ponerle algunos scripts de seguridad para que no me jodan la DB... alguien me puede ayudar a ponerle un par de codes para que prohíba caracteres? y si se puede y alguien sabe algunos scripts de seguridad de más??

les dejo el code:

Code: [Select]
<?php
$exchange_settings = simplexml_load_file('engine/config_mods/exchange.xml');
$cred = $exchange_settings->cash;


$resets_need = $exchange_settings->resets_need;
$online_hour_need = $exchange_settings->online_hour_need;

$onlinecheck1 = mssql_query("SELECT ConnectStat from MEMB_STAT where memb___id='$user_auth_id'");
$onlinecheck = mssql_fetch_row($onlinecheck1);

$character = HTMLSpecialChars(trim($_POST['character']), ENT_QUOTES);

if($onlinecheck[0] != 0)
{
  echo msg('0','You are in game.');
}
else
{

if (isset($_POST['movecoin']))
{
  $changec = htmlspecialchars($_POST['changec'],ENT_QUOTES);
  $amount = htmlspecialchars($_POST['coin_amount'],ENT_QUOTES);
  $character = htmlspecialchars(trim($_POST['character']), ENT_QUOTES);
  $cred =  mssql_query("SELECT cash FROM MEMB_INFO WHERE memb___id='$user_auth_id'");
  $kredit = mssql_fetch_array($cred);
 
  $online1 = mssql_query("SELECT OnlineHours from MEMB_STAT where memb___id='$user_auth_id'");
  $online = mssql_fetch_row($online1);
  $hours = floor($online[0] / 60);
 
  $resets1 = mssql_query("SELECT RESETS from Character where AccountID='$user_auth_id' and Name = '$character'");
  $resets = mssql_fetch_row($resets1);


  if($changec == 'resets')
  {
    if (!eregi("^[0-9\]{1,11}$", $amount))
    {
      echo  msg('0','Valor incorrecto');
    }
    elseif ($amount > $resets[0])
    {
      echo  msg('0','No tiene suficientes resets');
    }
    elseif (($amount % $resets_need) != 0)
    {
      echo  msg('0','Introduce el valor que se puede dividir por '.$resets_need.''); 
    }
    else
    {
      $new_cred = ($amount/$resets_need)+$kredit[0];
      $new_resets = $resets[0]-$amount;
      mssql_query("UPDATE MEMB_INFO SET cash='$new_cred' WHERE memb___id='$user_auth_id'");
      mssql_query("UPDATE Character SET RESETS='$new_resets' WHERE Name='$character'");
      echo  msg('1','El intercambio tuvo éxito');
    }
  }
 
  if($changec == 'online')
  {
    if (!eregi("^[0-9\]{1,11}$", $amount))
    {
      echo  msg('0','Valor incorrecto');
    }
    elseif ($amount > $hours)
    {
      echo  msg('0','No hay suficientes horas en línea');
    }
    elseif (($amount % $online_hour_need) != 0)
    {
      echo  msg('0','Introduce el valor que se puede dividir por '.$online_hour_need.''); 
    }
    else
    {
      $new_cred = ($amount/$online_hour_need)+$kredit[0];
      $new_time = ($hours-$amount) * 60;
      mssql_query("UPDATE MEMB_INFO SET cash='$new_cred' WHERE memb___id='$user_auth_id'");
      mssql_query("UPDATE MEMB_STAT SET OnlineHours='$new_time' WHERE memb___id='$user_auth_id'");
      echo  msg('1','El intercambio tuvo éxito');
    }
  }       
}

$cred =  mssql_query("SELECT cash FROM MEMB_INFO WHERE memb___id='$user_auth_id'");
$kredit = mssql_fetch_array($cred);


$online2 = mssql_query("SELECT OnlineHours from MEMB_STAT where memb___id='$user_auth_id'");
$online3 = mssql_fetch_row($online2);
$hours1 = floor($online3[0] / 60);

echo '<br><font color="white"><b>Creditos: '.number_format($kredit[0]).'</b><br>';
echo '<b>Tus Horas Online: '.number_format($hours1).'</b></font><br><br>';
?>


<form action="" method="post" onsubmit="request("form_vip","sh_","POST","getpage.php?cat=EX-change"); return false;">

<br><br>

<table>
<tr>
<td>
<b>Que deseas cambiar por creditos?</b>
</td>
<td align="right">
<select class="iRg_input" style="width: 100px" name="changec">
         
          <!--<option value="cred_zen">Zen</option>-->
          <option value="resets">Resets</option>
          <option value="online">Horas ON</option>
          <!--<option value="joc">JoC</option>-->
</select>
</td>
<td align="right">
<?php
$query = mssql_query("select [Name],[Class] from [Character] where [AccountID]='".$user_auth_id."'");
$i = 0;
$mychars= '';
while($i<mssql_num_rows($query)) {
$char = mssql_fetch_array($query);
$i++;
$mychars.="<option class=\"clchg\" value=\"".htmlspecialchars($char['Name'])."\">".$char['Name']."</option>";
}
?>
<select class="iRg_input" style="width: 100px" name="character">
<optgroup label="Select a character">
<?php echo $mychars; ?>
</select></td>
</tr>
<tr>
<td><b>Importe a canjear</b>
</td>
<td align="right"><input type="text" class="iRg_input" size="11" maxlength="11" name="coin_amount" value="0" />
</td>
</tr>
<tr><td><input type="submit" class="button-gray" name="movecoin" value="Canjear" /></td></tr>
</table>
<br><br>

<font color="white">*Nota*:<br>
<font color="yellow" >*Precios de intercambio:<br>

Horas / creditos:&nbsp;&nbsp;&nbsp; <?echo $online_hour_need;?> obtienes 20 creditos.<br>
Resets / Creditos:&nbsp;&nbsp;&nbsp; <?echo $resets_need;?> obtienes 25 creditos.
</font>

<?php
}
?>



Offline MiniBestia #1 Posteado: August 10, 2017, 10:59:06 PM

  • 0 puntos por ventas
  • *
  • Rank: Principiante
  • Posts: 17
  • Gracias recibida: 1
  • 00
Hola para comenzar te recomiendo que evites el uso de mssql_* ya que estas librerias fueron descontinuadas y ya no se usan. Te recomiendo que uses PDO, precisamente tienes un objeto con la conexión establecida en una variable llamda $core_db con la cual puedes preparar la sentencia y evitarte muchos intentos de inyección SQL.


Offline ivaancruzz #2 Posteado: August 10, 2017, 11:06:41 PM

  • 0 puntos por ventas
  • *
  • Rank: Puto amo
  • Posts: 442
  • Gracias recibida: 2317
  • ar
lamentablemente, no entiendo mucho de php, solo html, y hasta ahi nomas jaja, podrias darme una mano? que es PDO? tengo que intalar algo mas? no entiendo bien por favor..


Solo usuarios registrados pueden comentar y agradecer, Logueate o Registrate


 

Related Topics

  Subject / Started by Replies Last post
2 Replies
954 Views
Last post July 29, 2018, 09:13:26 AM
by Deidad
0 Replies
591 Views
Last post February 03, 2019, 02:52:44 PM
by manugaby1
1 Replies
761 Views
Last post March 29, 2019, 10:42:11 AM
by Tony
0 Replies
416 Views
Last post December 11, 2019, 07:21:43 PM
by AndresMe
1 Replies
685 Views
Last post April 05, 2020, 08:43:29 PM
by enriquexp