Skip to content

Instantly share code, notes, and snippets.

View maximilianoraul's full-sized avatar

Maximiliano Raul maximilianoraul

View GitHub Profile
$.jMaskGlobals = {
maskElements: 'input,td,span,div',
dataMaskAttr: '*[data-mask]',
dataMask: true,
watchInterval: 300,
watchInputs: true,
watchDataMask: false,
byPassKeys: [9, 16, 17, 18, 36, 37, 38, 39, 40, 91],
translation: {
'0': {pattern: /\d/},
@maximilianoraul
maximilianoraul / web.php
Created December 30, 2019 16:11
Manejo de errores con Yii2 para API y respuestas JSON
<?php
'components'=>[
'response' => [
'format' => \yii\web\Response::FORMAT_JSON,
'on beforeSend' => function ($event) {
$response = $event->sender;
$response = $event->sender;
if ($response->data !== null) {
$data = ['success' => $response->isSuccessful];
$rawdata = $response->data;
@maximilianoraul
maximilianoraul / ajax.php
Created December 20, 2014 13:23
AJAX Request
<script type="text/javascript">
$('form').submit(function () {
$('form button').attr("disabled", "disabled");
$('#loading').fadeIn();
$('#msj').html('');
$.post('<?php echo Flight::base_url('contacto'); ?>', $('form').serializeArray(), function (d) {
$('#loading').fadeOut();
$('form button').removeAttr('disabled');
$('#msj').html(d.msj);
$('html, body').animate({scrollTop: $("#msj").offset().top}, 500);
@maximilianoraul
maximilianoraul / index.php
Last active November 3, 2021 21:26
Listar Carpetas y Archivos de un directorio
<?php
//Directorio
$dir = getcwd();
$directorio = opendir($dir);
$archivos = array();
$carpetas = array();
//Carpetas y Archivos a excluir
$excluir = array('.', '..', 'index.php', 'favicon.ico','folder.png','file.png','.dropbox.cache','.dropbox');
@maximilianoraul
maximilianoraul / custom_view.php
Last active August 29, 2015 14:11
Flight Micro-Framework - Rendering Views with custom Layout
<h1><?php echo $text; ?></h1>
@maximilianoraul
maximilianoraul / reCaptcha.php
Created December 16, 2014 11:24
Implement the new google reCAPTCHA in PHP applications
<?php
// reCAPTCHA
// https://www.google.com/recaptcha/intro/index.html
if (isset($_POST['g-recaptcha-response']) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP)) {
$captcha = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=your_secret_key&response=' . $_POST['g-recaptcha-response'] . '&remoteip=' . $_SERVER['REMOTE_ADDR']), TRUE);
if (isset($captcha['success']) && $captcha['success'] === TRUE) {
//Captcha OK
} else {
//Captcha Error