<?php
require_once 'config.php';
require_once 'includes/debug.php';
require_once 'includes/functions.php';
$erro = "";
$sucesso = "";
if (isset($_POST["subReg"])) {
    if ($_POST["licen"] == "" || $_POST["licen2"] == "") {
        $erro = "Inseria uma licença válida...";
    } elseif (trim($_POST["licen"]) != ept($h, $s) || trim($_POST["licen2"]) != ept(dirname(__FILE__), $s)) {
        $erro = "Licença Inválida!";
    } else {
        $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die(sqlerror());
        mysql_select_db($dbname, $conn);
        $rs = mysql_query("UPDATE cmum_settings SET rndpasschr='{$_POST["licen"]}', rndpasschrlength='{$_POST["licen2"]}'");
        if ($rs) {
            $sucesso = "Sistema Está Ativado.";
        }
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Registre Sua Cópia</title>
        <link href="css/main.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="js/jquery.js"></script>
        <style>
            #regCorpo{
                width: 600px;

                border: solid 1px;
                font-family: sans-serif;
                top: 50%;
                left: 50%;
                margin-left: -300px;

                position: absolute;
            }
            .top{
                text-align: center;
                font-weight: bolder;
                font-size: 16pt;
                padding-top: 5px;
                padding-bottom: 5px;
                background-color: #990000;
                color: #ffffff;
            }
            .rod{
                text-align: right;
                padding: 2px;
                font-family: monospace;

            }
            .erro{
                text-align: center;
                margin-top: 5px;
                margin-bottom: 5px;
                font-weight: bold;
                color: rede;
            }
            .sucesso{
                text-align: center;
                font-weight: bolder;
                font-size: 16pt;
                padding-top: 5px;
                padding-bottom: 5px;
                background-color: #9ecb2d;
                color: #ffffff;
            }
        </style>
    </head>
    <body style="background-color: white;">
        <div id="regCorpo">
            <?php
            $conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die(sqlerror());
            mysql_select_db($dbname, $conn);
            $v = ept($h, $s);
            $v2 = ept(dirname(__FILE__), $s);
            $rs = mysql_query("SELECT rndpasschr FROM cmum_settings WHERE rndpasschr = '{$v}' AND rndpasschrlength = '{$v2}'");
            if (mysql_num_rows($rs) > 0) {
                $sucesso = "Sistema Está Ativado.";
            }
            ?>
            <?php if (isset($sucesso) && $sucesso != ""): ?>
                <div class="sucesso">
                    <?php echo $sucesso; ?>
                </div>
            </div>
        </body>
    </html>
    <?php
    exit();
endif;
?>
<div class="top">CÓPIA NÃO REGISTRADA</div>
<div class="corp">
    <?php if (isset($erro) && $erro != ""): ?>
        <div class="erro">
            <?php echo $erro; ?>
        </div>
    <?php endif; ?>
    <fieldset>
        <legend>Registro</legend>
        <form method="post">
            <label>Chave 1:</label>&nbsp;<input type="text" size="75" name="licen" value="<?php echo isset($_POST['licen']) ? $_POST['licen'] : ""; ?>"/><br/><br/>
            <label>Chave 2:</label>&nbsp;<input type="text" size="75" name="licen2" value="<?php echo isset($_POST['licen2']) ? $_POST['licen2'] : ""; ?>"/><br/><br/>
            <input type="submit" value="Registrar" name="subReg"/>
        </form>
    </fieldset>
</div>
<div class="rod">
    contatos: aznordeste@gmail.com
</div>
</div>
<script>
    var h = $("#regCorpo").outerHeight();        
    $("#regCorpo").css('margin-top', '-'+(h/2)+'px');
       
</script>
</body>
</html>
