dimanche 28 août 2016

Open the web between hours

actually the code appears every 4 hours but appears 1 code to every people to enter to the site, i want just appear 1 random code every 4 hours for who takes it win it

A friend told me is because the sesión_start(); but really no idea about php so, im here asking for your help :D

<?php

ini_set("session.use_cookies","1");  
ini_set("session.use_only_cookies","1");  
ini_set("session.use_trans_sid","0"); 
session_start();

$codetime = 240; // Cada cuantos minutos se puede usar la pag.
$szBuffer = "amx codes";
$gCanUse = 1;

if( isset($_SESSION["amxxcodes"])) 
{
if( ($_SESSION["amxxcodes"]+($codetime*60)) > time() )
{
    $szBuffer = "Aún no puedes revelar el código, intenta más tarde";
    $gCanUse = 0;
}
else
{
    unset($_SESSION["amxxcodes"]);
}
}

if( $gCanUse ) 
{
$db_host = "localhost"; // SQL HOST
$db_user = "test"; // SQL USER
$db_pass = "test"; // SQL PASS
$db_name = "Codes"; // SQL Database Name
$db_table = "data"; // SQL Table name

$APS_MIN = 1; // Monto minimo de aps que se pueden otorgar
$APS_MAX = 3; // Monto maximo de aps que se pueden otorgar

$conexion = mysqli_connect($db_host, $db_user, $db_pass, $db_name);

if (!$conexion) 
{
    die("Connection failed: " . mysqli_connect_error());
}

$code = generateRandomString( rand(12,25) );
$aps = rand( $APS_MIN , $APS_MAX );
$query = 'INSERT INTO `'.$db_table.'` (Code, Aps, Used) VALUES ("'.$code.'", '.$aps.', 0)';

if (mysqli_query($conexion, $query) ) 
{
    $szBuffer = "amx_code ". $code;
    $_SESSION["amxxcodes"] = time();
} 
else 
{
    echo "Error en consulta: " . mysqli_error($conexion);
}

mysqli_close($conexion);
}

function generateRandomString($length = 10) {
    return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)) )),1,$length);
}
?>


<!DOCTYPE html>
<html lang="en-us">
<head>
<style>
.text {
color: rgb(255, 225, 0);
text-shadow: 0px 0px 4px rgb(255, 108, 0);
}
</style>
</head>
<body bgcolor="#212121">

<center>
<table border="0" cellpadding="5" cellspacing="0" style="box-shadow: 0px 0px 8px white; border-radius: 5px; width: 50%;min-width: 50%;">
<tbody style="text-align:center;color:white;">
    <tr style="font-weight: bold;background-color: black;">
       <td> 
            <?php 
            if($gCanUse)
            {
                echo "AMXX Code escrito por Kikizon
                    <br><br>
                    Usa el siguiente código en consola del servidor y obten puntos napalm
                    <br><br><br><br><br><br><br><br><br>
                    <div class='text'>
                    ".$szBuffer."
                    </div>
                    <br><br><br><br><br>";
            }
            else 
                echo $szBuffer;
            ?>
       </td>
    </tr>
 </tbody>
</table>
</center>

</body>
</html>




Aucun commentaire:

Enregistrer un commentaire