Skip to content

Instantly share code, notes, and snippets.

View juanwilde's full-sized avatar

Juan González juanwilde

  • Metro Markets GmbH
  • Palma de Mallorca
View GitHub Profile
@juanwilde
juanwilde / acceso.php
Created January 27, 2014 15:09
acceso
if(isset($_POST['intro'])){
$link = mysql_connect('localhost', 'root', 'admin')
or die('No se ha podido conectar al server');
mysql_select_db('dwes') or die('No se ha encontrado la base de datos');
$query = 'select * from usuarios';
$result = mysql_query($query, $link);
$is = false;
while($lines = mysql_fetch_row($result)){
if(($lines[0] == $_POST['user'] && $lines[1] == $_POST['pass'])){
@juanwilde
juanwilde / index.html
Created February 20, 2014 17:33
select¿?
<!DOCTYPE html>
<html>
<head>
<title>Gestion de formularios 1</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<script src="js/jscript.js" type="text/javascript"></script>
</head>
<body>
<form name="form1" action="index.html">
<?php
/**
* Created by PhpStorm.
* User: Juan
* Date: 10/7/2015
* Time: 8:15 PM
*/
class indexController extends customersController
{
public function getCustomers()
{
$customers = $this->_db->query('select c.*, ctrl.seen, ctrl.date as edited from customers c, control ctrl where c.id = ctrl.customer_id and ctrl.user_id = ' . Session::get('id_user') . ' order by ctrl.date desc, c.date desc');
return $customers->fetchAll(PDO::FETCH_ASSOC);
}
@juanwilde
juanwilde / CustomerType.php
Created November 19, 2015 00:37
Formulario de fichas de clientes
<?php
namespace Ourentec\CustomersBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class CustomerType extends AbstractType
{
@juanwilde
juanwilde / Controller.php
Created December 21, 2015 13:52
Patrón MVC básico
protected function getSql($key)
{
if (isset($_POST[$key]) && !empty($_POST[$key])) {
$_POST[$key] = strip_tags($_POST[$key]);
if (!get_magic_quotes_gpc()) {
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($mysqli->connect_error) {
die('Connection error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
@juanwilde
juanwilde / example.php
Created March 10, 2016 21:02
Example
public function save($data)
{
$customer = new Customer();
$customer->setName($data['name']);
if (isset($data['lastname'])) $customer->setLastname($data['lastname']);
$customer->setPhone($data['phone']);
if (isset($data['address'])) $customer->setAddress($data['address']);
if (isset($data['email'])) $customer->setEmail($data['email']);
@juanwilde
juanwilde / suscriptions.php
Last active April 11, 2016 01:09
Part of suscriptions.php
/**
* @param $msisdn
* @param $amount
* @param $token
* @return array
*/
public function getBill($msisdn, $amount, $token)
{
if($this->_billError500 == true) {
error_log(print_r('ha dado error 500', true));
@juanwilde
juanwilde / factory.js
Last active May 7, 2016 13:33
Ejemplo de envío
// factory.js
.factory('Nombre', ['$resource', function ($resource) {
return $resource('http://url.api/api/login', {}, {
save: {
method: 'POST',
headers: {Authentication: 'tu_token_o_apikey'}
}
});
}]);
@juanwilde
juanwilde / show.php
Created August 23, 2016 06:44
Ejemplo para mostrar imagen obtenida mediante scraping con simple_html_dom.php
<?php
foreach ($imgPaths as $img) {
echo '<img src="' . $img->attr["src"] . '"'/>
}