Exemple #1
0
            }
            if ($liOptSvc == "pbl") {
                $liOptStr = simple_decrypt($liUser->option->pushbul['eml']);
            }
            if ($liOptSvc == "pov") {
                $liOptStr = simple_decrypt($liUser->option->pushover['num']);
            }
            if ($liOptSvc == "bxc") {
                $liOptStr = simple_decrypt($liUser->option->boxcar['num']);
            }
        }
        $pagerline = array($liUid, $liUser->pager['sys'], simple_decrypt($liUser->pager['num']), $liOpt, $liOptSvc, $liOptStr);
        $liName = $liNameF . ' ' . $liNameL;
    }
    if ($liUser->pager['num']) {
        echo '<option value="' . simple_encrypt(implode(",", $pagerline)) . '" ' . ($liUid == $uid ? 'selected="selected"' : '') . '>' . $liName . '</option>' . "\r\n";
    }
}
?>
        </select>
        <label for="MYNAME">From:</label>
        <input type="text" name="MYNAME" id="MYNAME" value="" placeholder="REQUIRED" maxlength="20"/>
    </div>

    <div data-role="fieldcontain" style="text-align: right">
        <textarea name="MESSAGE" id="MESSAGE" maxlength="200"></textarea>
    </div>
    <input type="hidden" name="GROUP" value="<?php 
echo $group;
?>
">
<?php

$app->put('/verificarusuario/:id', function ($id) use($app) {
    $input = $app->request->getBody();
    $codrecibido = $input['codigo'];
    //Se crea el mismo código que se le fue enviado al usuario para comparar.
    $codcorrecto = simple_encrypt($id, $app->enc_key);
    $codcorrecto = substr($codcorrecto, 0, 6);
    //Por motivos de DEBUG se muestra el código correcto en caso de ser erroneo.
    if ($codrecibido != $codcorrecto) {
        $app->render(500, array('error' => TRUE, 'msg' => 'Codigo incorrecto. <br>El codigo correcto es <strong>' . $codcorrecto . '</strong>'));
    }
    $user = User::find($id);
    $user->auth = 1;
    //Incremento AUTH (1 = Usuario Verificado).
    $user->save();
    $app->render(200);
});
Exemple #3
0
    if (empty($email)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'email is required'));
    }
    $password = $input['password'];
    if (empty($password)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'password is required'));
    }
    $db = $app->db->getConnection();
    $user = $db->table('users')->select()->where('email', $email)->first();
    if (empty($user)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'user not exist'));
    }
    if ($user->pass != $password) {
        $app->render(500, array('error' => TRUE, 'msg' => 'password dont match'));
    }
    $token = simple_encrypt($user->id, $app->enc_key);
    $app->render(200, array('token' => $token));
});
$app->post('/usuario', function () use($app) {
    $input = $app->request->getBody();
    $name = $input['name'];
    if (empty($name)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'name is required'));
    }
    $password = $input['password'];
    if (empty($password)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'password is required'));
    }
    $email = $input['email'];
    if (empty($email)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'email is required'));
Exemple #4
0
    $error[] = '- Username harus diisi !!!';
}
if ($act == 'add' and $totalRows_cekpk > 0) {
    $error[] = '- Username sudah digunakan !!!';
}
if (trim($_POST['password']) == '') {
    $error[] = '- Password harus diisi !!!';
}
if (trim($akses) == '') {
    $error[] = '- Akses harus dicheck min 1 !!!';
}
/*End validasi */
if (isset($error)) {
    echo "<img src=\"images/alert.png\" width=\"16\" align=\"left\"/>&nbsp;&nbsp;<b style=\"color:red;\">Error : </b> <br />" . implode("<br />", $error);
} else {
    $pass = simple_encrypt($_POST['password']);
    if ($act == 'add') {
        echo $query = "INSERT INTO gl_admin (id, username, password, link, akses) VALUES (NULL, '{$_POST['username']}', '{$pass}', '{$_POST['karyawan']}', '{$akses}')";
    } else {
        if ($act == 'edit') {
            $query = "UPDATE gl_admin SET username='******'username']}', link='{$_POST['karyawan']}', akses='{$akses}'";
            if ($_POST['g_pass'] == '1') {
                $query .= ", password='******'";
            }
            $query .= " WHERE id='{$_POST['id']}'";
        } else {
            $query = "delete from gl_admin where id='{$_POST['id']}'";
        }
    }
    mysql_select_db($database_con_gl, $con_gl);
    $runquery = mysql_query($query, $con_gl);
        $app->render(500, array('error' => TRUE, 'msg' => 'Por favor, introduzca una clave.'));
    }
    //Debe contener al menos 4 caracteres.
    if ($passwordStr < 4) {
        $app->render(500, array('error' => TRUE, 'msg' => 'Tu clave debe contener mas de 4 caracteres.'));
    }
    //Las claves deben coincidir.
    if ($password != $confirmpassword) {
        $app->render(500, array('error' => TRUE, 'msg' => 'Las claves introducidas no coinciden.'));
    }
    //Si se llegó a esté punto, todo está "OK".
    $user = new User();
    $user->name = $name;
    $user->password = $password;
    $user->email = $email;
    $user->auth = 0;
    $user->save();
    //Ahora busco en la base de datos al usuario recién creado para buscar su ID.
    $db = $app->db->getConnection();
    $id = $db->table('usuarios')->select('id')->where('email', $email)->get();
    //Genero un código único en base a su ID (Es único) y la clave de encriptación de la API.
    $codigo = simple_encrypt($id[0]->id, $app->enc_key);
    $codigo = substr($codigo, 0, 6);
    //Código de longitud 6.
    //Mediante el Plugin Sendgrid envio un email con el codigo:
    $sendgrid = new SendGrid('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');
    $sendemail = new SendGrid\Email();
    $sendemail->addTo($email)->setFrom("*****@*****.**")->setSubject("[AppServis] Confirma tu cuenta.")->setHtml('Tu c&oacute;digo es: <strong style="font-size: 20px;">' . $codigo . '</strong> - Deber&aacute;s ingresaro cuando entres por primera vez a la aplicaci&oacute;n.');
    $sendgrid->send($sendemail);
    $app->render(200);
});
?>

<?php 
session_start();
$url = "index.php";
if (trim($_POST['username']) == '') {
    $error[] = '- Username harus diisi !!!';
}
if (trim($_POST['password']) == '') {
    $error[] = '- Password harus diisi !!!';
}
if (isset($error)) {
    echo "<img src=\"images/alert.png\" align=\"left\" hspace=\"5\" style=\"margin-top:2px;\"/><b>Error</b>: <br />" . implode("<br />", $error);
} else {
    mysql_select_db($database_con_gl, $con_gl);
    $query_login = "******"' AND gl_kontak.id = gl_admin.link";
    //echo $query_login;
    $login = mysql_query($query_login, $con_gl) or die(mysql_error());
    $row_login = mysql_fetch_assoc($login);
    $totalRows_login = mysql_num_rows($login);
    ?>

<?php 
    if ($totalRows_login > 0) {
        ?>

	<?php 
        $_SESSION[admin] = $row_login['username'];
        $_SESSION[akses] = $row_login['akses'];
        $_SESSION[nama] = $row_login['nama'];
        $_SESSION[lokasi] = $row_login['gudang'];
    if (empty($email)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'Se requiere el Email'));
    }
    $password = $input['password'];
    if (empty($password)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'Se requiere la Contraseña'));
    }
    $db = $app->db->getConnection();
    $usuario = $db->table('usuarios')->select()->where('email', $email)->first();
    if (empty($usuario)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'El usuario no existe'));
    }
    if ($usuario->password != $password) {
        $app->render(500, array('error' => TRUE, 'msg' => 'La password no coincide'));
    }
    $token = simple_encrypt($usuario->id, $app->enc_key);
    $app->render(200, array('token' => $token));
});
$app->get('/me', function () use($app) {
    $token = $app->request->headers->get('auth-token');
    if (empty($token)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'Not logged1'));
    }
    $id_user_token = simple_decrypt($token, $app->enc_key);
    $usuario = User::find($id_user_token);
    if (empty($usuario)) {
        $app->render(500, array('error' => TRUE, 'msg' => 'Not logged2'));
    }
    $app->render(200, array('data' => $usuario->toArray()));
});
$app->run();
Exemple #8
0
 }
 if ($tmpGroup == '') {
     $row++;
     continue;
 }
 usleep(1);
 $tmpLastName = trim($arrLine[$row][array_search('Last', $csvline)]);
 $tmpFirstName = trim($arrLine[$row][array_search('First', $csvline)]);
 $tmpPageSys = $arrLine[$row][array_search('System', $csvline)] == 'COOK' ? 'C' : ($arrLine[$row][array_search('System', $csvline)] == 'USAM' ? 'U' : 'ERR');
 $tmpPageNum = simple_encrypt($arrLine[$row][array_search('Pager', $csvline)]);
 $tmpCellSys = $arrLine[$row][array_search('Carrier', $csvline)] == 'ATT' ? 'A' : ($arrLine[$row][array_search('Carrier', $csvline)] == 'VZN' ? 'V' : ($arrLine[$row][array_search('Carrier', $csvline)] == 'TMO' ? 'T' : 'ERR'));
 $tmpCellNum = simple_encrypt($arrLine[$row][array_search('SMS', $csvline)]);
 $tmpSysOpt = $arrLine[$row][array_search('Mode', $csvline)] ?: 'A';
 $tmpNotifSys = $arrLine[$row][array_search('Carrier', $csvline)];
 $tmpCis = simple_encrypt($arrLine[$row][array_search('CIS', $csvline)]);
 $tmpEml = simple_encrypt($arrLine[$row][array_search('Email', $csvline)]);
 $tmpUserGrp = $imXml->groups->{$tmpGroup} ?: $imXml->groups->addChild($tmpGroup);
 if (substr($tmpLastName, 0, 3) == ":::") {
     $tmpSection = substr($tmpLastName, 4);
     !$tmpFirstName ?: ($tmpUserGrp['full'] = $tmpFirstName);
     $tmpLastName = "";
     $tmpFirstName = "";
     $tmpSysOpt = "";
 } else {
     $tmpSection = "";
 }
 $tmpUser = $tmpUserGrp->addChild('user');
 !$tmpLastName ?: ($tmpUser['last'] = $tmpLastName);
 !$tmpFirstName ?: ($tmpUser['first'] = $tmpFirstName);
 !$tmpSection ?: ($tmpUser['sec'] = $tmpSection);
 $tmpUser['uid'] = $groups->{$tmpGroup}->xpath("user[@last='" . $tmpLastName . "' and @first='" . $tmpFirstName . "']")[0]['uid'] ?: uniqid();