<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-393831674762332267</id><updated>2024-12-17T12:10:32.814+01:00</updated><category term="jquery"/><category term="php"/><category term="javascript"/><category term="validaciones"/><category term="css3"/><category term="magento"/><category term="HTML5"/><category term="Laravel"/><category term="css"/><category term="PhoneGap"/><category term="ckeditor"/><category term=".htaccess"/><category term="Apache"/><category term="jQuery Mobile"/><category term="MySql"/><category term="ckfinder"/><category term="excepciones"/><category term="jQuery UI"/><category term="Ajax"/><category term="Blade"/><category term="Carbon"/><category term="Drupal"/><category term="HTML"/><category term="Metro Style"/><category term="NodeJS"/><category term="Sql"/><category term="Unicode"/><category term="Windows 8"/><category term="Wordpress"/><category term="Zend"/><category term="carrusel"/><category term="color"/><category term="degradados"/><category term="jquery.corners"/><category term="jquery.numeric"/><category term="noticias"/><title type='text'>da-software</title><subtitle type='html'>Php, MySql, Html5, CSS3, JavaScript, jQuery y más ... </subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>99</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-893074307346202063</id><published>2020-05-11T13:05:00.001+02:00</published><updated>2020-05-11T13:06:43.597+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Laravel"/><category scheme="http://www.blogger.com/atom/ns#" term="validaciones"/><title type='text'>Validar Nif NIE con Laravel</title><content type='html'>Para validar si un Cif o NIE es correcto podemos emplear una &lt;b&gt;Rule&lt;/b&gt; personalizada. El código completo de la regla sería:&lt;br&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;div class=&quot;codigo&quot;&gt;
namespace App\Rules;&lt;br&gt;
&lt;br&gt;
use Illuminate\Contracts\Validation\Rule;&lt;br&gt;
&lt;br&gt;
class NifNie implements Rule&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; &amp;nbsp;/**&lt;br&gt;
&amp;nbsp; &amp;nbsp;* Create a new rule instance.&lt;br&gt;
&amp;nbsp; &amp;nbsp;*&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @return void&lt;br&gt;
&amp;nbsp; &amp;nbsp;*/&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function __construct()&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;//&lt;br&gt;
&amp;nbsp; &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;/**&lt;br&gt;
&amp;nbsp; &amp;nbsp;* Determine if the validation rule passes.&lt;br&gt;
&amp;nbsp; &amp;nbsp;*&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @param  string  $attribute&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @param  mixed  $value&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @return bool&lt;br&gt;
&amp;nbsp; &amp;nbsp;*/&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function passes($attribute, $value)&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return ($this-&gt;isValidNif($value) || $this-&gt;isValidNie($value));&lt;br&gt;
&amp;nbsp; &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;/**&lt;br&gt;
&amp;nbsp; &amp;nbsp;* Get the validation error message.&lt;br&gt;
&amp;nbsp; &amp;nbsp;*&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @return string&lt;br&gt;
&amp;nbsp; &amp;nbsp;*/&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function message()&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return &#39;Debe ser un Nif o Nie válido&#39;;&lt;br&gt;
&amp;nbsp; &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function isValidNif($nif)&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;$nifRegEx = &#39;/^[0-9]{8}[A-Z]$/i&#39;;&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;$letras = &quot;TRWAGMYFPDXBNJZSQVHLCKE&quot;;&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;if (preg_match($nifRegEx, $nif)) {&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return ($letras[(substr($nif, 0, 8) % 23)] == $nif[8]);&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return false;&lt;br&gt;
&amp;nbsp; &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function isValidNie($nif)&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;$nieRegEx = &#39;/^[KLMXYZ][0-9]{7}[A-Z]$/i&#39;;&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;$letras = &quot;TRWAGMYFPDXBNJZSQVHLCKE&quot;;&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;if (preg_match($nieRegEx, $nif)) {&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;$r = str_replace([&#39;X&#39;, &#39;Y&#39;, &#39;Z&#39;], [0, 1, 2], $nif);&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return ($letras[(substr($r, 0, 8) % 23)] == $nif[8]);&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return false;&lt;br&gt;
&amp;nbsp; &amp;nbsp;}    &lt;br&gt;
}&lt;br&gt;
&lt;/div&gt;
Para usarlo en nuestra request, haríamos:&lt;br&gt;
&lt;div class=&quot;codigo&quot;&gt;
    public function rules()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; &amp;nbsp; return [&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&#39;vat&#39; =&gt; [new NifNie, &#39;required&#39;, &#39;string&#39;, &#39;max:255&#39;, &#39;unique:users,vat&#39;],&lt;br&gt;
            
&amp;nbsp; &amp;nbsp;];&lt;br&gt;
}&lt;br&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/893074307346202063/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2020/05/validar-nif-nie-con-laravel.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/893074307346202063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/893074307346202063'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2020/05/validar-nif-nie-con-laravel.html' title='Validar Nif NIE con Laravel'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-5843976136692188868</id><published>2020-05-11T12:18:00.000+02:00</published><updated>2020-05-11T12:18:37.668+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Laravel"/><category scheme="http://www.blogger.com/atom/ns#" term="validaciones"/><title type='text'>Rules, validaciones personalizadas en Laravel</title><content type='html'>Laravel ya nos ofrece gran cantidad de validaciones para emplear en las request, pero muchas veces nos puede surgir la necesidad de crear una propia. Se hará mediantes &lt;b&gt;Rules&lt;/b&gt; y el comando de artisan para crear una nueva sería:
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class=&quot;codigo&quot;&gt;
php artisan make:rule MyRule
&lt;/div&gt; 
&lt;br&gt;
Se creará el archivo MyRule.php dentro de la carpeta app/Rules con el siguiente contenido:&lt;br&gt;

&lt;div class=&quot;codigo&quot;&gt;

namespace App\Rules;&lt;br&gt;
&lt;br&gt;
use Illuminate\Contracts\Validation\Rule;&lt;br&gt;
&lt;br&gt;
class MyRule implements Rule&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; &amp;nbsp;/**&lt;br&gt;
&amp;nbsp; &amp;nbsp;* Create a new rule instance.&lt;br&gt;
&amp;nbsp; &amp;nbsp;*&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @return void&lt;br&gt;
&amp;nbsp; &amp;nbsp;*/&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function __construct()&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;//&lt;br&gt;
&amp;nbsp; &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;/**&lt;br&gt;
&amp;nbsp; &amp;nbsp;* Determine if the validation rule passes.&lt;br&gt;
&amp;nbsp; &amp;nbsp;*&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @param  string  $attribute&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @param  mixed  $value&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @return bool&lt;br&gt;
&amp;nbsp; &amp;nbsp;*/&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function passes($attribute, $value)&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;//&lt;br&gt;
&amp;nbsp; &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;/**&lt;br&gt;
&amp;nbsp; &amp;nbsp;* Get the validation error message.&lt;br&gt;
&amp;nbsp; &amp;nbsp;*&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @return string&lt;br&gt;
&amp;nbsp; &amp;nbsp;*/&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function message()&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return &#39;The validation error message.&#39;;&lt;br&gt;
&amp;nbsp; &amp;nbsp;}&lt;br&gt;
}
&lt;/div&gt;
&lt;br&gt;
Dentro de la funcción &lt;b&gt;passes()&lt;/b&gt; es donde escribiríamos nuestra validación, que tendrá que devolver true o false dependiendo si la pasa o no.&lt;br&gt;
&lt;br&gt;
A modo de ejemplo, vamos a modificar MyRule para que verifique que un número A es mayor que otro número B. Una validación que se podría hacer con la validaciones que trae Laravel, pero que vamos a  realizarla a modo explicativo:
&lt;div class=&quot;codigo&quot;&gt;

namespace App\Rules;&lt;br&gt;
&lt;br&gt;
use Illuminate\Contracts\Validation\Rule;&lt;br&gt;
&lt;br&gt;
class MyRule implements Rule&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; &amp;nbsp; private $number_a;&lt;br&gt;
&amp;nbsp; &amp;nbsp; private $number_b;&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;/**&lt;br&gt;
&amp;nbsp; &amp;nbsp;* Create a new rule instance.&lt;br&gt;
&amp;nbsp; &amp;nbsp;*&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @return void&lt;br&gt;
&amp;nbsp; &amp;nbsp;*/&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function __construct($number_a, $number_b)&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; $this-&gt;number_a = $number_a;&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; $this-&gt;number_b = $number_b;&lt;br&gt;
&amp;nbsp; &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;/**&lt;br&gt;
&amp;nbsp; &amp;nbsp;* Determine if the validation rule passes.&lt;br&gt;
&amp;nbsp; &amp;nbsp;*&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @param  string  $attribute&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @param  mixed  $value&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @return bool&lt;br&gt;
&amp;nbsp; &amp;nbsp;*/&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function passes($attribute, $value)&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return $number_a &gt; $number_b;&lt;br&gt;
&amp;nbsp; &amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp; &amp;nbsp;/**&lt;br&gt;
&amp;nbsp; &amp;nbsp;* Get the validation error message.&lt;br&gt;
&amp;nbsp; &amp;nbsp;*&lt;br&gt;
&amp;nbsp; &amp;nbsp;* @return string&lt;br&gt;
&amp;nbsp; &amp;nbsp;*/&lt;br&gt;
&amp;nbsp; &amp;nbsp;public function message()&lt;br&gt;
&amp;nbsp; &amp;nbsp;{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return &#39;El numero A no es mayor que el B&#39;;&lt;br&gt;
&amp;nbsp; &amp;nbsp;}&lt;br&gt;
}
&lt;/div&gt;

El constructor de la regla recibirá dos parámetros que serán los números a verificar. La funcción &lt;b&gt;passes()&lt;/b&gt; devuelve el resultado de la comparación de los dos valores. Por último, la funcción &lt;b&gt;message()&lt;/b&gt; devuelve el texto del error.&lt;br&gt;
&lt;br&gt;
Para usar nuestra nueva regla, lo haríamos de la siguiente forma en la request:
&lt;br&gt;
&lt;div class=&quot;codigo&quot;&gt;
public function rules()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; &amp;nbsp;return [&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&#39;number_a&#39; =&gt; [&#39;required&#39;, &#39;integer&#39;, new MyRule($this-&gt;number_a, $this-&gt;number_b)],&lt;br&gt;
&amp;nbsp; &amp;nbsp;];&lt;br&gt;
}&lt;br&gt;
&lt;/div&gt;

Al campo number_a de la request, ademas de que sea requerido e integer, le agregamos nuestra regla MyRule. Pasándole al constructor los dos valores a comprobar, que en este caso serán dos parámetros de la propia request, number_a y number_b.</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/5843976136692188868/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2020/05/rules-validaciones-personalizadas-en.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/5843976136692188868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/5843976136692188868'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2020/05/rules-validaciones-personalizadas-en.html' title='Rules, validaciones personalizadas en Laravel'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-3561864072129607564</id><published>2020-05-11T11:16:00.000+02:00</published><updated>2020-05-11T11:16:36.979+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Blade"/><category scheme="http://www.blogger.com/atom/ns#" term="Carbon"/><category scheme="http://www.blogger.com/atom/ns#" term="Laravel"/><title type='text'>Carbon en plantillas Blade de Laravel</title><content type='html'>Usar Carbon en Blade es imprescindible y se puede hacer de forma muy sencilla. Unos ejemplos de uso:
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;p&gt;Hoy: {{ \Carbon\Carbon::now()-&gt;format(&#39;d-m-Y&#39;)) }}&lt;/p&gt;
&lt;p&gt;Nueva fecha: {{ \Carbon\Carbon::createFromFormat(&#39;Y-m-d&#39;, &#39;2000-01-01&#39;)-&gt;format(&#39;d/m/Y&#39;) }}&lt;/p&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/3561864072129607564/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2020/05/carbon-en-plantillas-blade-de-laravel.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/3561864072129607564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/3561864072129607564'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2020/05/carbon-en-plantillas-blade-de-laravel.html' title='Carbon en plantillas Blade de Laravel'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-4652058855310007639</id><published>2020-05-11T10:18:00.001+02:00</published><updated>2020-05-11T10:21:52.533+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Laravel"/><title type='text'>Rutas con slug en Laravel 7</title><content type='html'>Una de las nuevas funcionalidad que trae Laravel 7 es la facilidad para enlazar los modelos a las rutas por un campo slug, o cualquier otro  de nuestro modelo. La forma es bien sencilla:
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br&gt;
&lt;div class=&quot;codigo&quot;&gt;&lt;br&gt;
//ruta para visitantes&lt;br&gt;
Route::get(&#39;/post/{post:slug}&#39;, function(Post $post){&lt;br&gt;
&amp;nbsp; &amp;nbsp; dd($post);&lt;br&gt;
});&lt;br&gt;
&lt;br&gt;
//ruta para administradores&lt;br&gt;
Route::get(&#39;/admin/post/{post}&#39;, function(Post $post){&lt;br&gt;
&amp;nbsp; &amp;nbsp; dd($post);&lt;br&gt;
});&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
En el código anterior se definen dos rutas, una para visitantes de un blog y otra para los administradores. En la primera, se accederá al post mediante el campo slug del modelo con :slug; mientras que en la segunda, se enlazará al modelo mediante el campo por defecto id, es decir, sería lo mismo que indicar :id en la ruta definida para administradores.
&lt;br&gt;&lt;br&gt;
Para versiones de Laravel anteriores a la 7, se puede modificar el comportamiento por defecto de enlazar la ruta al modelo mediante en campo id. Esto se puede hacer mediante la función &lt;b&gt;getRouteKeyName()&lt;/b&gt;, en el articulo &lt;a href=&quot;https://da-software.blogspot.com/2020/05/rutas-con-slug-en-laravel.html&quot;&gt;Rutas con slug en Laravel&lt;/a&gt; explico el funcionamiento.</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/4652058855310007639/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2020/05/rutas-con-slug-en-laravel-7.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/4652058855310007639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/4652058855310007639'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2020/05/rutas-con-slug-en-laravel-7.html' title='Rutas con slug en Laravel 7'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-1520838100894800056</id><published>2020-05-11T10:11:00.001+02:00</published><updated>2020-05-11T10:21:12.092+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Laravel"/><title type='text'>Rutas con slug en Laravel</title><content type='html'>En Laravel, si queremos enlazar un modelo a un ruta se hace por el campo id de dicho modelo, es decir:
&lt;br&gt;
&lt;div class=&quot;codigo&quot;&gt;
Route::get(&#39;/post/{post}&#39;, function(Post $post){&lt;br&gt;
&amp;nbsp; &amp;nbsp; dd($post);&lt;br&gt;
});
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br&gt;
Para cambiar este comportamiento de Laravel de enlazar al modelo mediante el campo id, podemos hacerlo mediante la función &lt;b&gt;getRouteKeyName()&lt;/b&gt; en el modelo:
&lt;br&gt;
&lt;div class=&quot;codigo&quot;&gt;
namespace App;&lt;br&gt;
&lt;br&gt;
use Illuminate\Database\Eloquent\Model;&lt;br&gt;
&lt;br&gt;
class Post extends Model&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; &amp;nbsp; function getRouteKeyName(){&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return &#39;slug&#39;;&lt;br&gt;
&amp;nbsp; &amp;nbsp; }&lt;br&gt;
}&lt;br&gt;
&lt;/div&gt;

</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/1520838100894800056/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2020/05/rutas-con-slug-en-laravel.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1520838100894800056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1520838100894800056'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2020/05/rutas-con-slug-en-laravel.html' title='Rutas con slug en Laravel'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-4424133332950919175</id><published>2013-09-15T18:21:00.001+02:00</published><updated>2013-09-15T18:23:29.765+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="css"/><category scheme="http://www.blogger.com/atom/ns#" term="HTML"/><title type='text'>Centrado horizontal y vertical de un elemento HTML</title><content type='html'>Para centrar cualquier elemento &lt;b&gt;HTML&lt;/b&gt; tenemos que tener en cuenta como esta definida su anchura y altura. Las dimensiones de los elementos podemos definirlas en porcentajes o en píxeles y dependiendo de esta unidad de medida el elemento será centrado de una forma u otra.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Cuando las dimensiones del elemento están definidas en porcentajes su centrado es muy sencillo y se hará de la siguiente forma:
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
#elemento{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;width: 60%;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;height: 40%;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;margin-left: 20%;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;margin-right: 20%;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;margin-top: 30%;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;margin-bottom: 30%;&lt;br /&gt;
}
&lt;/div&gt;
&lt;br /&gt;
Es decir, habrá que asignar un margen con la mitad del ancho y alto del elemento&lt;br /&gt;
&lt;br /&gt;
Cuando el tamaño del elemento esta definido en píxeles haremos lo siguiente:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
#elemento{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;width: 540px;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;height: 400px;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;margin: -200px 0 0 -270px;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;left: 50%:&lt;br /&gt;
&amp;nbsp; &amp;nbsp;top: 50%;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;position: relative;&lt;br /&gt;
}
&lt;/div&gt;
&lt;br /&gt;
Asignamos un margen negativo por la izquierda de la mitad del ancho total del elemento; un margen superior negativo con la mitad de la altura total; lo posicionamos tanto por la izquierda como por la parte superior al 50% y establecemos su posición a relativa.</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/4424133332950919175/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/09/centrado-horizontal-y-vertical-un.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/4424133332950919175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/4424133332950919175'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/09/centrado-horizontal-y-vertical-un.html' title='Centrado horizontal y vertical de un elemento HTML'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-583498385944654924</id><published>2013-08-19T19:19:00.000+02:00</published><updated>2013-08-19T19:19:48.419+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="jquery"/><category scheme="http://www.blogger.com/atom/ns#" term="NodeJS"/><title type='text'>Libros Javascript gratuitos</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn1JobOREA3xQ56CBGUC4uYVztaTMBJGw2Av6Xk8CWZfWOh_veK-YSLm74oRy9iObghSvAWehFp_ExMwttwlvwUASMhu7A8ly67-1PGL-WfTckMTSLERfKJcjrBCa6OLGywiwgCKVJ-i52/s1600/JavaScript.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn1JobOREA3xQ56CBGUC4uYVztaTMBJGw2Av6Xk8CWZfWOh_veK-YSLm74oRy9iObghSvAWehFp_ExMwttwlvwUASMhu7A8ly67-1PGL-WfTckMTSLERfKJcjrBCa6OLGywiwgCKVJ-i52/s1600/JavaScript.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
JSbooks es una amplia colección de libros &lt;b&gt;Javascript&lt;/b&gt; gratuitos clasificados según el nivel de dificultad, encontrado los mejores libros para principiantes, programadores con nivel intermedio y para programadores &lt;b&gt;Javascript&lt;/b&gt; avanzados.&lt;br /&gt;
&lt;br /&gt;
Entre los distintos títulos encontrarás libros dedicados a &lt;b&gt;Javascript&lt;/b&gt;, &lt;b&gt;jQuery&lt;/b&gt; y &lt;b&gt;NodeJS&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Para acceder a la guía completa de libros puedes acceder desde &lt;a href=&quot;http://jsbooks.revolunet.com/&quot; target=&quot;_blank&quot;&gt;JSbooks&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/583498385944654924/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/08/libros-javascript-gratuitos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/583498385944654924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/583498385944654924'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/08/libros-javascript-gratuitos.html' title='Libros Javascript gratuitos'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn1JobOREA3xQ56CBGUC4uYVztaTMBJGw2Av6Xk8CWZfWOh_veK-YSLm74oRy9iObghSvAWehFp_ExMwttwlvwUASMhu7A8ly67-1PGL-WfTckMTSLERfKJcjrBCa6OLGywiwgCKVJ-i52/s72-c/JavaScript.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-1342437886649205770</id><published>2013-08-19T19:13:00.002+02:00</published><updated>2013-08-19T19:13:54.249+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="css"/><category scheme="http://www.blogger.com/atom/ns#" term="css3"/><title type='text'>Almanaque CSS</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtGyihIEPJ2D22n94PIhj1rYSN8MHfbYlQnceTpYbN12i9naP6cMKWbubzfNRduQCcArl3Glo38X9mUFVYGFS84E3nxYBycptI1zB99egMdX5Bxi1__6flT-471tNhyOwplYPBLU0De-SN/s1600/css3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;112&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtGyihIEPJ2D22n94PIhj1rYSN8MHfbYlQnceTpYbN12i9naP6cMKWbubzfNRduQCcArl3Glo38X9mUFVYGFS84E3nxYBycptI1zB99egMdX5Bxi1__6flT-471tNhyOwplYPBLU0De-SN/s200/css3.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Fantástica recopilación de selectores y propiedades &lt;b&gt;CSS&lt;/b&gt;. Un almanaque completo, ordenado por orden alfabético, con todos los selectores &lt;b&gt;CSS&lt;/b&gt; y propiedades &lt;b&gt;CSS&lt;/b&gt; con sus correspondientes especificaciones y ejemplos de uso.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
También incluye consejos y guías de buenas prácticas que te ayudaran a manejar de forma correcta los selectores y propiedades &lt;b&gt;CSS&lt;/b&gt;. El almanaque completo puedes verlo en css-tricks.com pinchando &lt;a href=&quot;http://css-tricks.com/almanac/&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/1342437886649205770/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/08/almanaque-css.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1342437886649205770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1342437886649205770'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/08/almanaque-css.html' title='Almanaque CSS'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtGyihIEPJ2D22n94PIhj1rYSN8MHfbYlQnceTpYbN12i9naP6cMKWbubzfNRduQCcArl3Glo38X9mUFVYGFS84E3nxYBycptI1zB99egMdX5Bxi1__6flT-471tNhyOwplYPBLU0De-SN/s72-c/css3.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-1386246131750002366</id><published>2013-08-14T15:45:00.003+02:00</published><updated>2013-08-14T15:45:50.031+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jquery"/><title type='text'>Detectar si jQuery está cargado</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisr9rpf65PBQx8hwkXZ9QclN23yunEoOwvf5k5t9-kryaFpZSXu9jwQeruBtr0Q4fWFKOFPJFEbpbypBdVgqdU94ghnBj9T2HWITjzXDQsse-SXmxADErvku-jZZcQiJM7wl4Llhg5gKv8/s1600/jquery.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;72&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisr9rpf65PBQx8hwkXZ9QclN23yunEoOwvf5k5t9-kryaFpZSXu9jwQeruBtr0Q4fWFKOFPJFEbpbypBdVgqdU94ghnBj9T2HWITjzXDQsse-SXmxADErvku-jZZcQiJM7wl4Llhg5gKv8/s200/jquery.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
A veces es importante detectar si &lt;b&gt;jQuery&lt;/b&gt; está o no cargado, ya que en caso de ya este cargado y volvamos a hacerlo puede producir errores inesperados en nuestro script. Si por el contrario no está cargado, nuestro script no funcionará.&lt;br /&gt;
&lt;br /&gt;
Esto se evidencia durante la creación de plugins, ya que si nuestro plugin precisa de &lt;b&gt;jQuery&lt;/b&gt;, deberíamos comprobar si ya ha sido previamente cargado por otro plugin.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Para detectar si &lt;b&gt;jQuery&lt;/b&gt; está cargado y cargarlo en caso de que no lo este, haríamos:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(!window.jQuery) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var script = document.createElement(&#39;script&#39;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;script.type = &quot;text/javascript&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;script.src = &quot;http://www.dominio.com/jquery.js&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;document.getElementsByTagName(&#39;head&#39;)[0].appendChild(script);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/1386246131750002366/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/08/detectar-si-jquery-esta-cargado.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1386246131750002366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1386246131750002366'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/08/detectar-si-jquery-esta-cargado.html' title='Detectar si jQuery está cargado'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisr9rpf65PBQx8hwkXZ9QclN23yunEoOwvf5k5t9-kryaFpZSXu9jwQeruBtr0Q4fWFKOFPJFEbpbypBdVgqdU94ghnBj9T2HWITjzXDQsse-SXmxADErvku-jZZcQiJM7wl4Llhg5gKv8/s72-c/jquery.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-4810412480763937608</id><published>2013-08-10T09:50:00.000+02:00</published><updated>2013-08-10T09:50:20.873+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>Obtener sistema operativo del visitante con PHP</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAhW1CIhsZhxqaI4lLiekxdZvxPMCV625OkZiwWwfttbvMGtc8do4IzDFS3s1Sn9MSckRRrFmQDWoQ8DGqQq2RNFCPaeeeCF4BwhNpIqmC7l1YKBLTFvRtV0gJecOCI7HOMsTWBq7l9ot6/s1600/php.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;128&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAhW1CIhsZhxqaI4lLiekxdZvxPMCV625OkZiwWwfttbvMGtc8do4IzDFS3s1Sn9MSckRRrFmQDWoQ8DGqQq2RNFCPaeeeCF4BwhNpIqmC7l1YKBLTFvRtV0gJecOCI7HOMsTWBq7l9ot6/s200/php.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Para realizar estadísticas de uso de una Web, resulta interesante obtener el sistema operativo empleado por cada usuario, así podremos conocer los hábitos de los visitas a nuestra.&lt;br /&gt;
&lt;br /&gt;
Para obtener el sistema operativo o plataforma empleada en una visita, en primer lugar, debemos obtener el USER_AGENT. El USER_AGENT nos dará toda la información necesaria sobre el sistema operativo y navegador de la visita.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;En el artículo &lt;a href=&quot;http://da-software.blogspot.com.es/2013/08/obtener-navegador-del-visitante-con-php.html&quot; target=&quot;_blank&quot;&gt;Obtener navegador del visitante con PHP&lt;/a&gt; explico cómo obtener el navegador empleado. Para recoger el USER_AGENT de la visita lo haremos:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
$user_agent = $_SERVER[&#39;HTTP_USER_AGENT&#39;];&lt;/div&gt;
&lt;br /&gt;
Una vez obtenido el user_agent únicamente tenemos que pasar este valor a nuestra función &lt;i&gt;getPlatform()&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
function getPlatform($user_agent) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;$plataformas = array(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Windows 8&#39; =&amp;gt; &#39;Windows NT 6.2+&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Windows 7&#39; =&amp;gt; &#39;Windows NT 6.1+&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Windows Vista&#39; =&amp;gt; &#39;Windows NT 6.0+&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Windows XP&#39; =&amp;gt; &#39;Windows NT 5.1+&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Windows 2003&#39; =&amp;gt; &#39;Windows NT 5.2+&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Windows&#39; =&amp;gt; &#39;Windows otros&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;iPhone&#39; =&amp;gt; &#39;iPhone&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;iPad&#39; =&amp;gt; &#39;iPad&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Mac OS X&#39; =&amp;gt; &#39;(Mac OS X+)|(CFNetwork+)&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Mac otros&#39; =&amp;gt; &#39;Macintosh&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Android&#39; =&amp;gt; &#39;Android&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;BlackBerry&#39; =&amp;gt; &#39;BlackBerry&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Linux&#39; =&amp;gt; &#39;Linux&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;foreach($plataformas as $plataforma=&amp;gt;$pattern){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if (eregi($pattern, $user_agent))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return $plataforma;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;return &#39;Otras&#39;;&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
La función nos devolverá una cadena de texto con el nombre del sistema operativo. En caso de que no lo reconozca devolverá &lt;i&gt;“Otras&lt;/i&gt;”.&lt;br /&gt;
&lt;br /&gt;
A medida que van surgiendo nuevas plataformas o nuevas versiones, podemos ir ampliando la función getPlatform() para así reconocerlos y que la función no nos devuelva el valor “&lt;i&gt;Otras&lt;/i&gt;”.</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/4810412480763937608/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/08/obtener-sistema-operativo-del-visitante.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/4810412480763937608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/4810412480763937608'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/08/obtener-sistema-operativo-del-visitante.html' title='Obtener sistema operativo del visitante con PHP'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAhW1CIhsZhxqaI4lLiekxdZvxPMCV625OkZiwWwfttbvMGtc8do4IzDFS3s1Sn9MSckRRrFmQDWoQ8DGqQq2RNFCPaeeeCF4BwhNpIqmC7l1YKBLTFvRtV0gJecOCI7HOMsTWBq7l9ot6/s72-c/php.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-7214498617339788677</id><published>2013-08-10T09:43:00.000+02:00</published><updated>2013-08-10T09:52:02.895+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>Obtener navegador del visitante con PHP</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAhW1CIhsZhxqaI4lLiekxdZvxPMCV625OkZiwWwfttbvMGtc8do4IzDFS3s1Sn9MSckRRrFmQDWoQ8DGqQq2RNFCPaeeeCF4BwhNpIqmC7l1YKBLTFvRtV0gJecOCI7HOMsTWBq7l9ot6/s1600/php.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;128&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAhW1CIhsZhxqaI4lLiekxdZvxPMCV625OkZiwWwfttbvMGtc8do4IzDFS3s1Sn9MSckRRrFmQDWoQ8DGqQq2RNFCPaeeeCF4BwhNpIqmC7l1YKBLTFvRtV0gJecOCI7HOMsTWBq7l9ot6/s200/php.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
A la hora de realizar estadísticas de uso de una Web, es interesante obtener el navegador empleado por cada usuario, así podremos conocer los hábitos de los visitas a nuestra Web y poder tomar decisiones en función de ello.&lt;br /&gt;
&lt;br /&gt;
Para obtener el navegador empleado en una visita, en primer lugar, debemos obtener el USER_AGENT. El USER_AGENT nos dará toda la información necesaria sobre el navegador y sistema operativo de la visita.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;En el artículo &lt;a href=&quot;http://www.da-software.blogspot.com.es/2013/08/obtener-sistema-operativo-del-visitante.html&quot; target=&quot;_blank&quot;&gt;Obtener sistema operativo del visitante con PHP&lt;/a&gt; explico cómo obtener el sistema operativo. Para recoger el USER_AGENT de la visita lo haremos:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
$user_agent = $_SERVER[&#39;HTTP_USER_AGENT&#39;];&lt;/div&gt;
&lt;br /&gt;
Una vez obtenido el USER_AGENT únicamente tenemos que pasar este valor a nuestra función &lt;i&gt;getBrowser()&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
function getBrowser($user_agent) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;$navegadores = array(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Opera&#39; =&amp;gt; &#39;Opera&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Chrome&#39; =&amp;gt; &#39;Chrome&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Safari&#39; =&amp;gt; &#39;Safari&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Mozilla Firefox&#39;=&amp;gt; &#39;(Firebird)|(Firefox)&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Galeon&#39; =&amp;gt; &#39;Galeon&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Mozilla&#39;=&amp;gt;&#39;Gecko&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;MyIE&#39;=&amp;gt;&#39;MyIE&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Lynx&#39; =&amp;gt; &#39;Lynx&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Netscape&#39; =&amp;gt; &#39;(Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79)&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Konqueror&#39;=&amp;gt;&#39;Konqueror&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;IExplorer 10&#39; =&amp;gt; &#39;(MSIE 10\.[0-9]+)&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;IExplorer 9&#39; =&amp;gt; &#39;(MSIE 9\.[0-9]+)&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;IExplorer 8&#39; =&amp;gt; &#39;(MSIE 8\.[0-9]+)&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;IExplorer 7&#39; =&amp;gt; &#39;(MSIE 7\.[0-9]+)&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;IExplorer 6&#39; =&amp;gt; &#39;(MSIE 6\.[0-9]+)&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;IExplorer 5&#39; =&amp;gt; &#39;(MSIE 5\.[0-9]+)&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;IExplorer 4&#39; =&amp;gt; &#39;(MSIE 4\.[0-9]+)&#39;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;foreach($navegadores as $navegador=&amp;gt;$pattern){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if (eregi($pattern, $user_agent))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return $navegador;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;return &#39;Otros&#39;;&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
La función nos devolverá una cadena de texto con el nombre del navegador. En caso de que no lo reconozca devolverá “&lt;i&gt;Otros&lt;/i&gt;”.&lt;br /&gt;
&lt;br /&gt;
A medida que van surgiendo nuevos navegadores o nuevas versiones de los navegadores, podemos ir ampliando la función &lt;i&gt;getBrowser()&lt;/i&gt; para así reconocerlos y que la función no nos devuelva el valor “&lt;i&gt;Otros&lt;/i&gt;”.</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/7214498617339788677/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/08/obtener-navegador-del-visitante-con-php.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/7214498617339788677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/7214498617339788677'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/08/obtener-navegador-del-visitante-con-php.html' title='Obtener navegador del visitante con PHP'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAhW1CIhsZhxqaI4lLiekxdZvxPMCV625OkZiwWwfttbvMGtc8do4IzDFS3s1Sn9MSckRRrFmQDWoQ8DGqQq2RNFCPaeeeCF4BwhNpIqmC7l1YKBLTFvRtV0gJecOCI7HOMsTWBq7l9ot6/s72-c/php.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-2372763661785737592</id><published>2013-08-06T19:10:00.000+02:00</published><updated>2013-09-15T13:20:41.614+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="PhoneGap"/><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>Capturar imagen y subir imagen con PhoneGap</title><content type='html'>&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXU/cjBRKhWJ0co/s1600/phonegap.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;http://4.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXU/cjBRKhWJ0co/s200/phonegap.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Para capturar una imagen realizada
desde la cámara de un dispositivo móvil y posteriormente subirla a
un servidor Web mediante &lt;b&gt;PhoneGap&lt;/b&gt;, deberemos realizar dos pasos:
primero realizar la captura de la imagen y en segundo lugar subir el
archivo.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
Para hacer la captura y el envío del
archivo al servidor Web emplearemos las funciones nativas de
&lt;b&gt;PhoneGap&lt;/b&gt;, posteriormente necesitaremos guardar la imagen en el
servidor y para ello se empleará cualquier lenguaje de programación
del lado del servidor, en este ejemplo se empleara &lt;b&gt;PHP&lt;/b&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
En primer lugar la captura y subida de
la imagen. El código &lt;b&gt;HTML&lt;/b&gt; y &lt;b&gt;Javascript&lt;/b&gt; sería el siguiente, a
continuación la explicación:&lt;/div&gt;
&lt;div class=&quot;codigo&quot;&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;title&amp;gt;Subida de fotos&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;&lt;span style=&quot;color: #990000;&quot;&gt;script&lt;/span&gt; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot; src=&quot;phonegap-1.2.0.js&quot;&amp;gt;&amp;lt;/&lt;span style=&quot;color: #990000;&quot;&gt;script&lt;/span&gt;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;&lt;span style=&quot;color: #990000;&quot;&gt;script&lt;/span&gt; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #999999;&quot;&gt;// Esperar a que cargue PhoneGap&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; document.addEventListener(&quot;deviceready&quot;, onDeviceReady, false);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #999999;&quot;&gt;// PhoneGap listo&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; function onDeviceReady() {&lt;br /&gt;
&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;         &lt;span style=&quot;color: #999999;&quot;&gt; // lo que tengas que hacer&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; function getImage() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; navigator.camera.getPicture(uploadPhoto, function(message) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;                  &lt;/span&gt;alert(&#39;error al capturar imagen&#39;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;            &lt;/span&gt;},{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;                  &lt;/span&gt;quality: 50,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;                  &lt;/span&gt;destinationType: navigator.camera.DestinationType.FILE_URI,&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;                  &lt;/span&gt;sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;            &lt;/span&gt;});&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; function uploadPhoto(imageURI) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var options = new FileUploadOptions(),&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; params = new Object ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; options.fileKey=&quot;file&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; options.fileName=imageURI.substr(imageURI.lastIndexOf(&#39;/&#39;)+1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; options.mimeType=&quot;image/jpeg&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; params.value1 = &quot;test&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; params.value2 = &quot;param&quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; options.params = params;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; options.chunkedMode = false;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var ft = new FileTransfer();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ft.upload(imageURI,&quot;http://miservidor.com/services/upload.php&quot;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;function(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;console.log(&#39;imagen subida correctamente&#39;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;},&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;function(err){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;console.log(&#39;error al subir la imagen, error code: &#39; + err.code);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;},&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;options);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;span style=&quot;color: #990000;&quot;&gt;script&lt;/span&gt;&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;button onclick=&quot;getImage();&quot; id=”subir-foto”&amp;gt;Subir foto&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
Lo primero será cargar &lt;b&gt;PhoneGap&lt;/b&gt; y
esperar a que esté listo para usar sus funciones. Crearemos la
función &lt;i&gt;getImage()&lt;/i&gt; que será la encarda de capturar la imagen. En
caso de que la captura se realice con éxito llamará a la función
&lt;i&gt;uploadPhoto()&lt;/i&gt; que será la encargada de subirla al servidor (si se
produce algún error al realizar la captura se mostrará una alerta
indicándolo)&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
La función &lt;i&gt;uploadPhoto()&lt;/i&gt; realizará la
subida del archivo, para ello emplearemos el &lt;a href=&quot;http://docs.phonegap.com/en/2.2.0/cordova_file_file.md.html#FileTransfer&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif;&quot;&gt;File
Transfer API&lt;/span&gt;&lt;/a&gt;&amp;nbsp;de PhoneGap. Lo
primero será crear los objetos &lt;i&gt;options&lt;/i&gt;, &lt;i&gt;params&lt;/i&gt; y &lt;i&gt;ft&lt;/i&gt; necesarios.
&lt;i&gt;FileKey&lt;/i&gt; será empleado por el fichero PHP para obtener la imagen;
&lt;i&gt;fileName&lt;/i&gt; es el nombre del archivo creado al capturar la imagen desde
la cámara, al cual le quitaremos la ruta completa para quedarnos
únicamente con el nombre; &lt;i&gt;mimeType&lt;/i&gt; es empleado para indicar al
servidor que tipo de archivo estamos enviando. En el objeto &lt;i&gt;params&lt;/i&gt;
podemos incluir cualquier otro tipo de variable que necesitemos en
nuestra aplicación y posteriormente añadimos &lt;i&gt;params&lt;/i&gt; al objeto
&lt;i&gt;options&lt;/i&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
A continuación se crea el objeto &lt;i&gt;ft&lt;/i&gt;
FileTransfer y llamamos a su método upload para la realizar la
subida del archivo indicando el fichero; la ruta del fichero &lt;b&gt;PHP&lt;/b&gt;
encargado de guardarlo en el servidor remoto; callback para cuando
falla la subida; callback para cuando la subida se ejecuta
correctamente; y las opciones definidas previamente&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
La captura y el envío de la imagen se
realizar al pulsar el botón &lt;b&gt;HTML&lt;/b&gt; con id “subir foto” que llamará
a la función &lt;i&gt;getImage()&lt;/i&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
Por último, el fichero upload.php alojado en tu servidor y que
guarda la foto en el servidor sería:&lt;/div&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;$ruta =&amp;nbsp;&quot;images/&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;$nombre_imagen = &quot;unnombre.jpg&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;move_uploaded_file($_FILES[&quot;file&quot;][&quot;tmp_name&quot;], $ruta.$nombre_imagen);&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
La realización de este tutorial está
realizada en base al artículo obtenido de
&lt;a href=&quot;http://zacvineyard.com/blog/2011/03/upload-a-file-to-a-remote-server-with-phonegap&quot;&gt;http://zacvineyard.com/blog/2011/03/upload-a-file-to-a-remote-server-with-phonegap&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/2372763661785737592/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/08/capturar-imagen-y-subir-imagen-con.html#comment-form' title='7 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/2372763661785737592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/2372763661785737592'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/08/capturar-imagen-y-subir-imagen-con.html' title='Capturar imagen y subir imagen con PhoneGap'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXU/cjBRKhWJ0co/s72-c/phonegap.png" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-3537461588021291266</id><published>2013-08-05T18:32:00.002+02:00</published><updated>2013-08-05T18:34:56.123+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".htaccess"/><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>Servicio Web RESTful con Php</title><content type='html'>La creación de Servicios Web esta hoy en día en un total auge debido a la proliferación de las aplicaciones para dispositivos móviles. Los servicios web nos permiten distribuir los datos entre distintos tipos de aplicaciones, páginas Web, etc. Estos servicios Web generarán una respuesta a una petición realizado por un cliente del servicio, respuesta que generalmente será en formato &lt;b&gt;JSON&lt;/b&gt; o &lt;b&gt;XML&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
El ejemplo que os muestro a continuación está basado en el artículo incluido en &lt;a href=&quot;http://www.9lessons.info/2012/05/create-restful-services-api-in-php.html&quot;&gt;http://www.9lessons.info/2012/05/create-restful-services-api-in-php.html&lt;/a&gt; el cual generará una respuesta &lt;b&gt;JSON&lt;/b&gt;. El código principal de la API &lt;b&gt;RESTful&lt;/b&gt; será la siguiente:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: inherit, Times New Roman, serif;&quot;&gt;&lt;b&gt;&amp;lt;?php&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;require_once&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;Rest.inc.php&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;);&lt;br /&gt;&lt;br /&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;API&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;extends&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;REST&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;$data
= &quot;&quot;;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; const&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;DB_SERVER
= &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;localhost&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;const&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;DB_USER
= &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;Database_Username&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; const&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;DB_PASSWORD
= &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;Database_Password&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;const&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;DB
= &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;Database_Name&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;$db
=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;__construct&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; parent::&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;__construct&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;//
Init parent contructor&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;dbConnect&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;//
Initiate Database connection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; //Database
connection&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;dbConnect&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()&lt;br /&gt;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;db=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;mysql_connect&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(self::DB_SERVER,self::DB_USER,self::DB_PASSWORD);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if($this-&amp;gt;db)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;mysql_select_db&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(self::DB,$this-&amp;gt;db);&lt;br /&gt;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; //Public
method for access api.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; //This
method dynmically call the method based on the query&amp;nbsp;
string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; public&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;processApi&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $func
=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;strtolower&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;trim&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;str_replace&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&quot;/&quot;,&quot;&quot;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;$_REQUEST&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;[&#39;rquest&#39;])));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((int)method_exists($this,$func)
&amp;gt; 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;$func();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&#39;&#39;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;404&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //
If the method not exist with in this class, response would be &quot;Page
not
found&quot;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;login&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..............&lt;br /&gt;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;users&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..............&lt;br /&gt;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;deleteUser&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .............&lt;br /&gt;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;//Encode
array into
JSON&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp; &lt;/span&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;json&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($data)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;is_array&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($data)){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;json_encode&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($data);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;//
Initiiate Library&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;$api
= new&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;API&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;;&lt;br /&gt;$api-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;processApi&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: inherit, Times New Roman, serif;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: inherit, Times New Roman, serif;&quot;&gt;&lt;b&gt;?&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
En el API se establecen los valores de
conexión con la base de datos &lt;b&gt;MySql&lt;/b&gt; y las funciones necesarias para
realizar dicha conexión. A continuación crearemos tres métodos:
login(), que realizará la función de autentificación de un usuario
en la base de datos; users(), que nos devolverá una lista de los
usuarios que tengamos la tabla de base de datos; y el método
deleteUser(), el cual borrará un usuario.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;Login&lt;/b&gt;: será una petición del tipo
POST. En la petición se enviarán dos parámetros, “email” y
“pwd”. La función lo primero que hace es comprobar el tipo de
petición y que sea del tipo POST, en caso contrario enviara una
respuesta de error 406 (en el fichero Rest.inc.php se pueden
consultar las posibles respuestas). Una vez recibida la petición se
verificarán los parámetros enviados, se consultará a la base de
datos y en caso de que los datos sean correctos se devolverá la
respuesta &lt;b&gt;JSON&lt;/b&gt; con los datos del usuario y las correspondientes
cabeceras de que la consulta se realizo correctamente (200).&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;login&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()&lt;br /&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; //
Cross validation if the request method is POST else it will return
&quot;Not Acceptable&quot; status&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp; if($this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;get_request_method&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()
!= &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;POST&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&#39;&#39;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;406&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; $email
= $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;_request&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;[&#39;email&#39;];&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;
 &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp; $password
= $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;_request&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;[&#39;pwd&#39;];&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; //
Input validations&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp; if(!&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;empty&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($email)
and
!&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;empty&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($password))&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;filter_var&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($email,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;FILTER_VALIDATE_EMAIL&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;)){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $sql
=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;mysql_query&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;SELECT
user_id, user_fullname, user_email FROM users WHERE user_email =
&#39;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;$email&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&#39;
AND user_password = &#39;&quot;.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;md5&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;$password&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;).&quot;&#39;
LIMIT 1&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;,
$this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;db&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;mysql_num_rows&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($sql)
&amp;gt; 0){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $result =&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;mysql_fetch_array&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($sql,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;MYSQL_ASSOC&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //
If success everythig is good send header as &quot;OK&quot; and user
details&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;json&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($result),&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;200&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&#39;&#39;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;204&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //
If no records &quot;No Content&quot; status&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp; //
If invalid inputs &quot;Bad Request&quot; status message and
reason&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; $error
=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;array&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&#39;status&#39;
=&amp;gt; &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;Failed&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;,
&quot;msg&quot; =&amp;gt; &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;Invalid
Email address or
Password&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($this-&amp;gt;json($error),&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;400&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;Users&lt;/b&gt;: será una petición del tipo
GET. Al igual que en login(), lo primero que haremos será comprobar
el tipo de petición. Si la petición es correcta se realizará la
consulta SQL y se devolverá la lista de usuarios en formato &lt;b&gt;JSON&lt;/b&gt;.&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;function&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;users&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()&lt;br /&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp; &lt;span style=&quot;color: orange;&quot;&gt;//
Cross validation if the request method is GET else it will return
&quot;Not Acceptable&quot; status&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; if($this-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;get_request_method&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()
!= &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;GET&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&#39;&#39;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;406&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; $sql
=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;mysql_query&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;SELECT
user_id, user_fullname, user_email FROM users WHERE user_status = 1&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;,
$this-&amp;gt;db);&lt;br /&gt;&amp;nbsp; if(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;mysql_num_rows&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($sql)
&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $result
=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;array&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;while&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($rlt
=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;mysql_fetch_array&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($sql,MYSQL_ASSOC))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $result[]
= $rlt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //
If success everythig is good send header as &quot;OK&quot; and return
list of users in JSON
format&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;json&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($result),&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;200&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&#39;&#39;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;204&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;//
If no records &quot;No Content&quot; status&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;b&gt;DeleteUser&lt;/b&gt;: como siempre lo primero es
verificar el tipo de petición, posteriormente recibimos el parámetro
“id” que será el usuario a borrar de nuestra tabla. Si todo es
correcto ejecutamos la consulta SQL y lanzamos la correspondiente
respuesta JSON confirmando la acción.&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;function
deleteUser()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; if($this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;get_request_method&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;()
!= &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;DELETE&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&#39;&#39;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;406&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; $id
= (int)$this-&amp;gt;_request[&#39;id&#39;];&lt;br /&gt;&amp;nbsp; if($id &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;)&lt;br /&gt;&amp;nbsp; {&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;
   &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mysql_query&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;DELETE
FROM users WHERE user_id =&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;$id&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $success
=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;array&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&#39;status&#39;
=&amp;gt; &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;Success&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;,
&quot;msg&quot; =&amp;gt; &quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;Successfully
one record
deleted.&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;json&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;($success),&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;200&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; else&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $this-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;response&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;(&#39;&#39;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;204&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: orange;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;//
If no records &quot;No Content&quot; status&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
Hasta aquí hemos visto como
desarrollar las funciones básicas para desarrollar nuestra API&lt;b&gt;
RESTful&lt;/b&gt;. Para probar su funcionamiento podemos utilizar una extensión
para Chrome: &lt;span style=&quot;color: blue;&quot;&gt;&lt;a href=&quot;https://chrome.google.com/webstore/detail/hgmloofddffdnphfgcellkdfbfbjeloo&quot; target=&quot;_blank&quot;&gt;AdvancedREST client Application&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
Adicionalmente, podemos crear un
fichero &lt;b&gt;.htaccess&lt;/b&gt; para generar URLs amigables y que las llamadas a
los métodos de nuestro servicio sean mas sencillas. El fichero
&lt;b&gt;.htaccess&lt;/b&gt;:&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;lt;IfModule
mod_rewrite.c&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;RewriteEngine&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #e06666;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;On&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;RewriteCond
%{&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;REQUEST_FILENAME&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;}
!-d&lt;br /&gt;RewriteCond %{&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;REQUEST_FILENAME&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;}
!-s&lt;br /&gt;RewriteRule ^(.*)$&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;api.php&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;?&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;rquest=&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;$1
[QSA,NC,L]&lt;br /&gt;&lt;br /&gt;RewriteCond %{&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;REQUEST_FILENAME&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;}
-d&lt;br /&gt;RewriteRule ^(.*)$&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;api.php&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;[QSA,NC,L]&lt;br /&gt;&lt;br /&gt;RewriteCond
%{&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;REQUEST_FILENAME&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;}
-s&lt;br /&gt;RewriteRule ^(.*)$&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;api.php&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;[QSA,NC,L]&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;span style=&quot;font-family: Courier, monospace;&quot;&gt;&amp;lt;/IfModule&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
Y para hacer las llamadas a los
métodos del servicio seria:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;http://mi_dominio.com/ruta_del_servicio/login&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;http://mi_dominio.com/ruta_del_servicio/users&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;http://mi_dominio.com/ruta_del_servicio/DeleteUser &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
Puedes descargar el ejemplo completo desde &lt;a href=&quot;https://sites.google.com/site/nogueradavid2012/rest.zip&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.
</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/3537461588021291266/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/08/servicio-web-restful-con-php.html#comment-form' title='3 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/3537461588021291266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/3537461588021291266'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/08/servicio-web-restful-con-php.html' title='Servicio Web RESTful con Php'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-7523411731748328869</id><published>2013-08-02T16:58:00.000+02:00</published><updated>2013-08-02T16:58:08.915+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="PhoneGap"/><title type='text'>Cerrar aplicación PhoneGap</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXU/cjBRKhWJ0co/s1600/phonegap.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;http://4.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXU/cjBRKhWJ0co/s200/phonegap.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
Una de las acciones básicas e
imprescindibles en el desarrollo de una aplicación para dispositivos
móviles es la de cerrar la propia aplicación. En &lt;b&gt;PhoneGap&lt;/b&gt;
disponemos del método &lt;b&gt;exitApp()&lt;/b&gt; para realizar esta acción.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;A continuación os dejo un ejemplo
completo de un botón que realiza la función de cerrar la
aplicación:
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;lt;a onclick=&quot;showConfirm();
return false;&quot; href=&quot;#&quot; &amp;gt;salir&amp;lt;/a&amp;gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;
&amp;lt;script language=&quot;javascript&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;function showConfirm() {&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;navigator.notification.confirm(&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;¿Seguro que quieres cerrar la
aplicación?&#39;,  // mensaje a mostrar&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exitFromApp,              //
callback a invocar cuando el botón es presionado&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Salir&#39;,            // titulo
de la ventana&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &#39;Cancelar,Si&#39;         //
etiquetas de los botones&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;);&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;function exitFromApp(buttonIndex) {&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (buttonIndex==2){
navigator.app.exitApp();}&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
El botón será un enlace que al hacer
click en él llamara a la función showConfirm() (en el evento
onclick también incluiremos un return false; para evitar la acción
por defecto de los enlaces y que no se produzca un refresco de la
página).&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
La función showConfirm() desplegará
una ventana de notificación con dos botones y que al presionar
alguno de ellos se llamará a la función exitFromApp(), la cual
recibirá el parámetro buttonIndex que nos indicará cuál de los
botones de la ventana de notificación fue pulsado. En el caso de que
el usuario presionase el botón &quot;Si&quot;, identificado por el
índice 2, se ejecutará la función nativa de &lt;b&gt;PhoneGap
navigator.app.exitApp()&lt;/b&gt; que cerrará nuestra aplicación.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/7523411731748328869/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/08/cerrar-aplicacion-phonegap.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/7523411731748328869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/7523411731748328869'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/08/cerrar-aplicacion-phonegap.html' title='Cerrar aplicación PhoneGap'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXU/cjBRKhWJ0co/s72-c/phonegap.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-1349340251308216999</id><published>2013-08-02T16:50:00.000+02:00</published><updated>2013-08-02T16:58:36.071+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="PhoneGap"/><title type='text'>Variables en PhoneGap</title><content type='html'>&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://4.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXU/cjBRKhWJ0co/s1600/phonegap.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;http://4.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXU/cjBRKhWJ0co/s200/phonegap.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
El uso de variables en &lt;b&gt;PhoneGap&lt;/b&gt; es tan
necesario como en cualquier otro tipo de aplicación. Para crear y
asignar el valor a una variable lo haremos mediante el método
&lt;b&gt;setItem&lt;/b&gt; y para recuperar el valor de una variable con &lt;b&gt;getItem&lt;/b&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
A continuación un ejemplo en el que
guardamos el valor &quot;mi_valor&quot; en la variable &quot;mi_variable&quot;:&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;lt;script language=&quot;javascript&quot;&amp;gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;window.localStorage.setItem(&quot;mi_variable&quot;,
&quot;mi_valor&quot;);&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;var mi_var_js =
window.localStorage.getItem(&quot;mi_variable&quot;);&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/1349340251308216999/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/08/variables-en-phonegap.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1349340251308216999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1349340251308216999'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/08/variables-en-phonegap.html' title='Variables en PhoneGap'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXU/cjBRKhWJ0co/s72-c/phonegap.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-1743854525385652443</id><published>2013-08-02T16:45:00.001+02:00</published><updated>2013-08-05T00:00:31.943+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PhoneGap"/><title type='text'>Personalizar icono PhoneGap app</title><content type='html'>&lt;a href=&quot;http://1.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXQ/-mi7xOOGsJ4/s1600/phonegap.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;http://1.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXQ/-mi7xOOGsJ4/s200/phonegap.png&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;Para personalizar el icono de tu aplicación desarrollada con &lt;b&gt;PhoneGap&lt;/b&gt; necesitarás el mismo icono en cuatro tamaños. Esto es debido a las diferentes resoluciones de pantalla que se pueden encontrar en los distintos dispositivos móviles.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
En concreto serán necesarios iconos para resoluciones bajas (36x36 píxeles), resolución media (48x48 píxeles), resolución alta (72x72 píxeles) y resolución extra alta (96x96 píxeles).
Los iconos deberán ser imágenes en formato PNG y la ubicación dentro de tu proyecto PhoneGap la siguiente:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #999999;&quot;&gt;Miapp/res/drawable-ldpi/icon.png – para baja resolución (ldpi)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #999999;&quot;&gt;Miapp/res/drawable-mdpi/icon.png – para resolución media (mdpi)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #999999;&quot;&gt;Miapp/res/drawable-hdpi/icon.png – para alta resolución (hdpi)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #999999;&quot;&gt;Miapp/res/drawable-xhdpi/icon.png – para extra alta resolución (xhdpi)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
En estas ubicaciones podrás encontrar los archivos icon.png que se generan por defecto si has creado tu proyecto/app mediante el asistente de &lt;b&gt;PhoneGap&lt;/b&gt;. Simplemente tendrás que reemplazarlos o bien copiarlos si es que no existen.</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/1743854525385652443/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/08/icono-phonegap-app.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1743854525385652443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1743854525385652443'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/08/icono-phonegap-app.html' title='Personalizar icono PhoneGap app'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-fB32MYSy5O4/UfvFbjSF_qI/AAAAAAAAAXQ/-mi7xOOGsJ4/s72-c/phonegap.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-539242748136105856</id><published>2013-06-12T10:06:00.000+02:00</published><updated>2013-06-12T10:06:03.345+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Unicode"/><title type='text'>Tabla caracteres Unicode</title><content type='html'>La tabla definitiva con todos los caracteres Unicode. Un importante recurso para todos los programadores Web. Además de todos los caracteres de los distintos alfabetos, en la última versión de Unicode encontramos todo tipo de símbolos.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;En la última versión de Unicode se definen más de 100.000 caracteres, entre los que podemos encontrar símbolos meteorológicos, reproductores de audio y de vídeo, todo tipo de flechas y un largo etcétera. Todos los caracteres los podemos encontrar, perfectamente ordenados y clasificados en&amp;nbsp;&lt;a href=&quot;http://unicode-table.com/en&quot; target=&quot;_blank&quot;&gt;unicode-table.com&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/539242748136105856/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/06/tabla-caracteres-unicode.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/539242748136105856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/539242748136105856'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/06/tabla-caracteres-unicode.html' title='Tabla caracteres Unicode'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-5366331301649146817</id><published>2013-03-22T11:57:00.001+01:00</published><updated>2013-03-22T12:00:02.498+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Drupal"/><title type='text'>Chuleta Drupal7</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://1.bp.blogspot.com/-6cMHPVXlJng/UUw3Wg2iUzI/AAAAAAAAAMc/UrTb42cQcq8/s1600/drupal.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;http://1.bp.blogspot.com/-6cMHPVXlJng/UUw3Wg2iUzI/AAAAAAAAAMc/UrTb42cQcq8/s200/drupal.png&quot; width=&quot;174&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Siguiendo la colección de chuletas Web, en esta ocasión recogemos una importante ayuda para los desarrolladores del gestor de contenidos Drupal en su versión 7.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Para descargar la chuleta en formato PDF has click &lt;a href=&quot;https://sites.google.com/site/nogueradavid2012/Drupal7-theming-cheatsheet_2.pdf&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-J5LFDrtiW8c/UUw5YVw2hRI/AAAAAAAAAMo/UtyWSrUJ-gU/s1600/Drupal7-cheatsheet.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;232&quot; src=&quot;http://2.bp.blogspot.com/-J5LFDrtiW8c/UUw5YVw2hRI/AAAAAAAAAMo/UtyWSrUJ-gU/s400/Drupal7-cheatsheet.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;chuleta Drupal 7&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/5366331301649146817/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/03/chuleta-drupal7.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/5366331301649146817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/5366331301649146817'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/03/chuleta-drupal7.html' title='Chuleta Drupal7'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-6cMHPVXlJng/UUw3Wg2iUzI/AAAAAAAAAMc/UrTb42cQcq8/s72-c/drupal.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-5559113393047682105</id><published>2013-02-25T10:09:00.000+01:00</published><updated>2013-02-25T10:09:19.025+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Wordpress"/><title type='text'>Chuleta Wordpress</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX9OeYawaR3vH_or-4EFfvaFntIw0-Gs4BUall5gIlOxqbLc6L3FWeIvHUfprjoi03HTABXa3cKJk4ta7-441GKcNHheCorHBqFhoAHuxlw3H_GQ8N-hDisgYtE9fp7NboCf1sOlHlFzJA/s1600/wp_logo.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;200&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX9OeYawaR3vH_or-4EFfvaFntIw0-Gs4BUall5gIlOxqbLc6L3FWeIvHUfprjoi03HTABXa3cKJk4ta7-441GKcNHheCorHBqFhoAHuxlw3H_GQ8N-hDisgYtE9fp7NboCf1sOlHlFzJA/s200/wp_logo.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Otra chuleta imprescindible para los que trabajen con Wordpress.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
Para descargar la plantilla en formato pdf haz click &lt;a href=&quot;https://sites.google.com/site/nogueradavid2012/Wordpress-Cheat-Sheet.pdf&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiGyqptFEK0cRgbe9U66eh5KaI09iuy6HjVIvwOMbsiuWP_vcfIsSoq9TrErreAvic8Q0HsOmIbHUmf842H3WqqMteDFOq78DLf-PYBavErJ2ptnLa5lU0JY1QMvqRb3OQLzd5HUm8A51J/s1600/wp.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;190&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiGyqptFEK0cRgbe9U66eh5KaI09iuy6HjVIvwOMbsiuWP_vcfIsSoq9TrErreAvic8Q0HsOmIbHUmf842H3WqqMteDFOq78DLf-PYBavErJ2ptnLa5lU0JY1QMvqRb3OQLzd5HUm8A51J/s320/wp.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/5559113393047682105/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/02/chuleta-wordpress.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/5559113393047682105'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/5559113393047682105'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/02/chuleta-wordpress.html' title='Chuleta Wordpress'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX9OeYawaR3vH_or-4EFfvaFntIw0-Gs4BUall5gIlOxqbLc6L3FWeIvHUfprjoi03HTABXa3cKJk4ta7-441GKcNHheCorHBqFhoAHuxlw3H_GQ8N-hDisgYtE9fp7NboCf1sOlHlFzJA/s72-c/wp_logo.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-6904131708666427224</id><published>2013-01-10T15:23:00.002+01:00</published><updated>2013-01-10T15:23:29.873+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="css"/><title type='text'>Cortar palabras con puntos suspensivos y CSS</title><content type='html'>Cuando tenemos un texto demasiado largo para que entre en una sola linea, podemos cortarlo y añadirle unos puntos suspensivos de forma sencilla mediante &lt;b&gt;CSS&lt;/b&gt;. Para ello debemos definir unas cuantas propiedades para el elemento contenedor:&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
.contenedor {&lt;br /&gt;
&amp;nbsp; overflow: hidden;&lt;br /&gt;
&amp;nbsp; text-overflow: ellipsis;&lt;br /&gt;
&amp;nbsp;white-space: nowrap;&lt;br /&gt;
&amp;nbsp;width: 120px;&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;
Una serie de consideraciones a tener en cuenta: todas las propiedades definidas anteriormente son necesarias y este truco no sirve para textos con multilínea.</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/6904131708666427224/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/01/cortar-palabras-con-puntos-suspensivos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/6904131708666427224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/6904131708666427224'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/01/cortar-palabras-con-puntos-suspensivos.html' title='Cortar palabras con puntos suspensivos y CSS'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-3738536348894490400</id><published>2013-01-10T12:58:00.000+01:00</published><updated>2013-01-10T12:58:42.920+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jquery"/><title type='text'>Igualar la altura de unas capas con jQuery</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisr9rpf65PBQx8hwkXZ9QclN23yunEoOwvf5k5t9-kryaFpZSXu9jwQeruBtr0Q4fWFKOFPJFEbpbypBdVgqdU94ghnBj9T2HWITjzXDQsse-SXmxADErvku-jZZcQiJM7wl4Llhg5gKv8/s1600/jquery.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;72&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisr9rpf65PBQx8hwkXZ9QclN23yunEoOwvf5k5t9-kryaFpZSXu9jwQeruBtr0Q4fWFKOFPJFEbpbypBdVgqdU94ghnBj9T2HWITjzXDQsse-SXmxADErvku-jZZcQiJM7wl4Llhg5gKv8/s200/jquery.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Supongamos que tenemos varias capas en nuestras Web y que queremos que todas tengan la misma altura, pero sin definir una altura fija. Lo que haremos es igualar la altura de las capas más pequeñas a la altura de la capa mas alta:&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;div class=&quot;codigo&quot;&gt;
var maxHeight = 0;&lt;br /&gt;
&lt;br /&gt;
$(&quot;div&quot;).each(function(){&lt;br /&gt;
&amp;nbsp; if ($(this).height() &amp;gt; maxHeight) { maxHeight = $(this).height(); }&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
$(&quot;div&quot;).height(maxHeight);
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/3738536348894490400/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/01/igualar-la-altura-de-unas-capas-con.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/3738536348894490400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/3738536348894490400'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/01/igualar-la-altura-de-unas-capas-con.html' title='Igualar la altura de unas capas con jQuery'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisr9rpf65PBQx8hwkXZ9QclN23yunEoOwvf5k5t9-kryaFpZSXu9jwQeruBtr0Q4fWFKOFPJFEbpbypBdVgqdU94ghnBj9T2HWITjzXDQsse-SXmxADErvku-jZZcQiJM7wl4Llhg5gKv8/s72-c/jquery.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-1126606180746793502</id><published>2013-01-10T12:34:00.000+01:00</published><updated>2013-01-10T12:59:47.737+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jquery"/><category scheme="http://www.blogger.com/atom/ns#" term="validaciones"/><title type='text'>Comprobar si un elemento existe con jQuery y length</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisr9rpf65PBQx8hwkXZ9QclN23yunEoOwvf5k5t9-kryaFpZSXu9jwQeruBtr0Q4fWFKOFPJFEbpbypBdVgqdU94ghnBj9T2HWITjzXDQsse-SXmxADErvku-jZZcQiJM7wl4Llhg5gKv8/s1600/jquery.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;72&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisr9rpf65PBQx8hwkXZ9QclN23yunEoOwvf5k5t9-kryaFpZSXu9jwQeruBtr0Q4fWFKOFPJFEbpbypBdVgqdU94ghnBj9T2HWITjzXDQsse-SXmxADErvku-jZZcQiJM7wl4Llhg5gKv8/s200/jquery.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Comprobar si un elemento existe es muy sencillo mediante &lt;b&gt;jQuery&lt;/b&gt; y la propiedad &lt;i&gt;length&lt;/i&gt;. Sea nuestro elemento con &lt;i&gt;id=&quot;miElemento&quot;&lt;/i&gt;, para verificar si existe&amp;nbsp;haríamos:&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
if ($(&quot;#miElemento&quot;).length &amp;gt; 0){&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #666666;&quot;&gt;//el elemento existe&lt;/span&gt;&lt;br /&gt;
}&lt;/div&gt;
La propiedad &lt;i&gt;length&lt;/i&gt; nos devolverá el número de elementos que hay en el objeto &lt;b&gt;jQuery&lt;/b&gt;. Si por ejemplo, tenemos 3 elementos con la clase &lt;i&gt;miClase&lt;/i&gt; podríamos saber el número de elementos con la clase &lt;i&gt;miClase&lt;/i&gt; de la siguiente forma:
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
&amp;nbsp; $(document).ready(function(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; var elementos = $(&quot;.miClase&quot;).length; &amp;nbsp;&lt;span style=&quot;color: #666666;&quot;&gt; //devolverá 3&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; });&lt;br /&gt;
&amp;lt;/script&amp;gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&quot;miClase&quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&quot;miClase&quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&quot;miClase&quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/1126606180746793502/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/01/comprobar-si-un-elemento-existe-con.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1126606180746793502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/1126606180746793502'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/01/comprobar-si-un-elemento-existe-con.html' title='Comprobar si un elemento existe con jQuery y length'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisr9rpf65PBQx8hwkXZ9QclN23yunEoOwvf5k5t9-kryaFpZSXu9jwQeruBtr0Q4fWFKOFPJFEbpbypBdVgqdU94ghnBj9T2HWITjzXDQsse-SXmxADErvku-jZZcQiJM7wl4Llhg5gKv8/s72-c/jquery.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-5790913738220665430</id><published>2013-01-09T09:55:00.000+01:00</published><updated>2013-01-09T09:55:02.555+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>Math.random() en Javascript</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn1JobOREA3xQ56CBGUC4uYVztaTMBJGw2Av6Xk8CWZfWOh_veK-YSLm74oRy9iObghSvAWehFp_ExMwttwlvwUASMhu7A8ly67-1PGL-WfTckMTSLERfKJcjrBCa6OLGywiwgCKVJ-i52/s1600/JavaScript.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn1JobOREA3xQ56CBGUC4uYVztaTMBJGw2Av6Xk8CWZfWOh_veK-YSLm74oRy9iObghSvAWehFp_ExMwttwlvwUASMhu7A8ly67-1PGL-WfTckMTSLERfKJcjrBCa6OLGywiwgCKVJ-i52/s1600/JavaScript.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
La función&amp;nbsp;&lt;b&gt;Math.random()&lt;/b&gt; genera&amp;nbsp;números&amp;nbsp;aleatorios en &lt;b&gt;Javascript&lt;/b&gt;, pero hay que tener en cuenta una serie de consideraciones:&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Math.random()&lt;/b&gt; genera numero aleatorios entre 0 y 1, por lo que al ejecutar la función nos podría devolver un resultado como 0.5632785542115765.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si&amp;nbsp;necesitásemos&amp;nbsp;obtener un número aleatorio entre 0 y 10 o entre 0 y 100 lo&amp;nbsp;haríamos&amp;nbsp;de la siguiente forma:&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;span style=&quot;color: #666666;&quot;&gt;//random entre 0 y 10&lt;/span&gt;&lt;br /&gt;
var num = Math.floor((Math.random()*10)+1);&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #666666;&quot;&gt;//random entre 0 y 100&lt;/span&gt;&lt;br /&gt;
var num = Math.floor((Math.random()*100)+1);
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/5790913738220665430/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2013/01/mathrandom-en-javascript.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/5790913738220665430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/5790913738220665430'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2013/01/mathrandom-en-javascript.html' title='Math.random() en Javascript'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn1JobOREA3xQ56CBGUC4uYVztaTMBJGw2Av6Xk8CWZfWOh_veK-YSLm74oRy9iObghSvAWehFp_ExMwttwlvwUASMhu7A8ly67-1PGL-WfTckMTSLERfKJcjrBCa6OLGywiwgCKVJ-i52/s72-c/JavaScript.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-6398342754803444996</id><published>2012-11-27T13:15:00.002+01:00</published><updated>2012-11-27T13:28:23.897+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="css3"/><title type='text'>Selectores CSS3 ^=, $= y *=</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtGyihIEPJ2D22n94PIhj1rYSN8MHfbYlQnceTpYbN12i9naP6cMKWbubzfNRduQCcArl3Glo38X9mUFVYGFS84E3nxYBycptI1zB99egMdX5Bxi1__6flT-471tNhyOwplYPBLU0De-SN/s1600/css3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;112&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtGyihIEPJ2D22n94PIhj1rYSN8MHfbYlQnceTpYbN12i9naP6cMKWbubzfNRduQCcArl3Glo38X9mUFVYGFS84E3nxYBycptI1zB99egMdX5Bxi1__6flT-471tNhyOwplYPBLU0De-SN/s200/css3.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&amp;nbsp;En la nueva definición de las hojas de estilo en cascada &lt;b&gt;CSS3&lt;/b&gt; se agregan nuevos selectores, así como nuevas pseudo-clases y pseudo-elementos. En cuanto a selectores, se añaden 3 nuevos selectores de atributos: &lt;b&gt;^=&lt;/b&gt;, &lt;b&gt;$=&lt;/b&gt; y &lt;b&gt;*=&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;elemento[atributo^=&quot;valor&quot;]: selecciona todos los elementos que disponen de ese atributo y cuyo valor comienza exactamente por la cadena de texto indicada.&lt;/li&gt;
&lt;li&gt;elemento[atributo$=&quot;valor&quot;]: selecciona todos los elementos que disponen de ese atributo y cuyo valor termina exactamente por la cadena de texto indicada.&lt;/li&gt;
&lt;li&gt;elemento[atributo*=&quot;valor&quot;]: selecciona todos los elementos que disponen de ese atributo y cuyo valor contiene la cadena de texto indicada.&lt;/li&gt;
&lt;/ul&gt;
Algunos ejemplos: &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;/*selecciona todos los enlaces que tienen el atributo class y comienza por icon*/&lt;/span&gt;&lt;br /&gt;
a[class^=&quot;icon&quot;]{...} &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;/*selecciona todos los enlaces que tienen el atributo class y acaba en icon*/&lt;/span&gt;&lt;br /&gt;
a[class$=&quot;icon&quot;]{...}&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;/*selecciona todos los enlaces que tienen el atributo class y contiene la palabra icon*/&lt;/span&gt;&lt;br /&gt;
a[class*=&quot;icon&quot;]{...}&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;/*selecciona todos los elementos que tienen el atributo class y comienza por icon*/&lt;/span&gt;&lt;br /&gt;
[class^=&quot;icon&quot;]{...}&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/6398342754803444996/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2012/11/selectores-css3-y.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/6398342754803444996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/6398342754803444996'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2012/11/selectores-css3-y.html' title='Selectores CSS3 ^=, $= y *='/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtGyihIEPJ2D22n94PIhj1rYSN8MHfbYlQnceTpYbN12i9naP6cMKWbubzfNRduQCcArl3Glo38X9mUFVYGFS84E3nxYBycptI1zB99egMdX5Bxi1__6flT-471tNhyOwplYPBLU0De-SN/s72-c/css3.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-393831674762332267.post-2660255282426852079</id><published>2012-10-24T17:45:00.001+02:00</published><updated>2012-10-24T18:03:17.221+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="css3"/><title type='text'>Rotar elementos con transform y efectos con transition y CSS3</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtGyihIEPJ2D22n94PIhj1rYSN8MHfbYlQnceTpYbN12i9naP6cMKWbubzfNRduQCcArl3Glo38X9mUFVYGFS84E3nxYBycptI1zB99egMdX5Bxi1__6flT-471tNhyOwplYPBLU0De-SN/s1600/css3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;112&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtGyihIEPJ2D22n94PIhj1rYSN8MHfbYlQnceTpYbN12i9naP6cMKWbubzfNRduQCcArl3Glo38X9mUFVYGFS84E3nxYBycptI1zB99egMdX5Bxi1__6flT-471tNhyOwplYPBLU0De-SN/s200/css3.jpg&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Ahora con &lt;b&gt;CSS3&lt;/b&gt; podemos&amp;nbsp;fácilmente&amp;nbsp;rotar elementos, tanto&amp;nbsp;imágenes, divs o cualquier otro, tarea que antes resultaba un poco pesada ya que se tenia que recurrir a javascript u otras artimañas. Ahora con &lt;b&gt;CSS3&lt;/b&gt; únicamente tenemos que incluir una linea de código en nuestros estilos:&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
#midiv{transform: rotate(60deg)}&lt;/div&gt;
&lt;br /&gt;
Aplicamos una rotación de 60 grados al elemento con id &lt;i&gt;midiv&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Como los distintos navegadores no han acabado de soportar CSS3 en todas sus características y cada uno lo hace a su manera, para que el efecto de rotación sea visible en todos aquellos que soporten CSS3 deberemos incluir la especificación para cada uno:
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
#midiv{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;transform: rotate(60deg);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -webkit-transform: rotate(60deg);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -moz-transform: rotate(60deg);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -o-transform: rotate(60deg)&lt;br /&gt;
}&lt;/div&gt;
El efecto de rotación puede ser combinado con el efecto &lt;i&gt;transform&lt;/i&gt; de CSS3. Su&amp;nbsp;sintaxis es la siguiente:&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
transition:[Propiedad CSS] [Duración] [Función de Tiempo] [Retardo]
&lt;/div&gt;
Por lo que aplicado a nuestro ejemplo:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
transition:all 0.8s ease-in;
&lt;/div&gt;
&lt;br /&gt;
Un ejemplo completo de los dos efectos convinados sería:&lt;br /&gt;
&lt;div class=&quot;codigo&quot;&gt;
#midiv{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; width: 150px;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; height:150px;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; background:#ccc;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; transition:all 0.8s ease-in;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -webkit-transition:all 0.8s ease-in;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -moz-transition:all 0.8s ease-in;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -o-transition:all 0.8s ease-in;&lt;br /&gt;
}&lt;br /&gt;
#midiv:hover{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; transform: rotate(360deg);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -webkit-transform: rotate(360deg);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -moz-transform: rotate(360deg);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; -o-transform: rotate(360deg);&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
Pasa el ratón por encima del cuadro gris para ver como rota con el efecto &lt;b&gt;transition&lt;/b&gt;:
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;midiv-effccs3&quot;&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://da-software.blogspot.com/feeds/2660255282426852079/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://da-software.blogspot.com/2012/10/rotar-elementos-con-transform-y-efectos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/2660255282426852079'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/393831674762332267/posts/default/2660255282426852079'/><link rel='alternate' type='text/html' href='http://da-software.blogspot.com/2012/10/rotar-elementos-con-transform-y-efectos.html' title='Rotar elementos con transform y efectos con transition y CSS3'/><author><name>Daweed</name><uri>http://www.blogger.com/profile/16529217133871751924</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtGyihIEPJ2D22n94PIhj1rYSN8MHfbYlQnceTpYbN12i9naP6cMKWbubzfNRduQCcArl3Glo38X9mUFVYGFS84E3nxYBycptI1zB99egMdX5Bxi1__6flT-471tNhyOwplYPBLU0De-SN/s72-c/css3.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>