miércoles, 10 de mayo de 2017

Cómo configurar Firewall con UFW en Ubuntu 17.04 Linux

Vamos a ver este tutorial que nos ofrece este magnifico blog llamado www.solvetic.com


Origen:  https://www.solvetic.com/tutoriales/article/3443-como-configurar-firewall-ufw-ubuntu-linux/


Cuando de incrementar la seguridad en los equipos cliente de una organización, o propios, se trata, existen numerosas herramientas y buenas prácticas que podemos implementar que ayudan a conservar los estándares de seguridad adecuados para tal fin.

Aunque recurrimos a herramientas externas muchas veces no podemos dejar a un lado las utilidades que vienen incluidas dentro del propio Sistema Operativo las cuales han sido desarrolladas para ejecutar tareas específicas de una forma correcta y totalmente compatible con el Sistema Operativo en uso.

Una de estas herramientas es UFW (Uncomplicated Firewall) la cual, aunque viene por defecto en Ubuntu, se encuentra deshabilitada.

Hoy analizaremos en detalle cómo habilitar y sacar el máximo provecho a esta importante utilidad de Ubuntu 17.04

Rol del firewall en un Sistema Operativo
Antes de conocer cómo usar UFW en Ubuntu 16 es importante conocer la importancia de un firewall dentro de un Sistema Operativo.
Un firewall puede ser un componente de hardware o software cuya función es gestionar y administrar todo el tráfico de red, entrante y saliente, que hay entre dos o más redes. Dentro de las principales ventajas que encontramos al usar un firewall tenemos:
  • Proteger la red.
  • Mantener la integridad de la información almacenada en el equipo.
  • Evitar ataques de denegación del servicio.
  • Preservar la privacidad propia y de la organización.
  • Evitar intrusiones de usuarios no autorizados al sistema.


jueves, 16 de marzo de 2017

Arquitectura de InnoDB

Buffer Pool

The buffer pool is an area in main memory where InnoDB caches table and index data as data is accessed. The buffer pool allows frequently used data to be processed directly from memory, which speeds up processing. On dedicated database servers, up to 80% of physical memory is often assigned to the InnoDB buffer pool.
For efficiency of high-volume read operations, the buffer pool is divided into pages that can potentially hold multiple rows. For efficiency of cache management, the buffer pool is implemented as a linked list of pages; data that is rarely used is aged out of the cache, using a variation of the LRU algorithm.

miércoles, 15 de marzo de 2017

Tutorial PHP - PDO : Insertar , Modificar, Eliminar y Listar registros

Tutorial PHP - PDO : Insertar , Modificar, Eliminar y Listar registros




Para los que recien inician con PHP y han oido algo de PDO, bueno PDO es una libreria de PHP que nos permite abstraer ciertos conceptos de manejo de base de datos, las siglas dePDO significa PHP Data Objects (Objetos de Datos PHP), en resumidas utilizando PDO, nos permite evitar utilizar funciones propias de cada driver de base de datos, por ejemplo si usasMySQL dependiendo de la libreria mysql o mysqli, para conectarte usaras mysql_connect("localhost", "usuario", "contraseña") o $mysqli = new mysqli("localhost", "usuario", "contraseña", "basedatos"), de esto nos evita PHP PDO.

PHP PDO - setAttribute, beginTransaction and commit

PHP PDO - setAttribute, beginTransaction and commit

source : http://coursesweb.net/php-mysql/pdo-setattribute-begintransaction-commit

About try ... catch()

When it is created a PDO object with a connection to a database, in case of an error will throw the PDOException. If the error is not catched with try ... catch() PHP will stop the execution of the script.
PDOException is an extension of the PHP Exception class, that can "catch" the errors.
With try ... catch(), besides the fact that the error is taken and the script can continue its execution, it can also personalize the error message which will be displayed.
Syntax:
try {
  // ... PHP instructions
}
catch(PDOException $e) {
  echo 'Custom Error Message';

  // Output the error code and the error message
  echo $e->getCode(). '-'. $e->getMessage();
}
$e - is the object that will store the error detected by PHP.
getCode() - returns the error code.
getMessage() returns the error message.
If these methods are not added, it can be displayed only a custom message.

PHP PDO - prepare and execute

PHP PDO - prepare and execute



source : http://coursesweb.net/php-mysql/pdo-prepare-execute



With the exec() and query() methods the SQL command is automatically executed.
There is another variant, too. With PDO it's posible to "prepare" a SQL command without send /execute it. This is accomplished with the prepare() method.
- The prepare() method takes as argument an SQL statement and returns a PDOStatement object. This object contains an execute() method that will execute the SQL statement when it is called.
- The execute() returns TRUE, or FALSE in case of error.

So, prepare() can prepare an SQL statement to be executed by the execute() method, using this syntax:
$sqlprep = $PDOconnection->prepare("SQL statement");
$sqlprep->execute(Array);
- The "SQL statement" - can be any valid SQL statement: INSERT, SELECT, UPDATE, DELETE.
- The Array argument from the execute() method - is optional. It's an array of values with as many elements as there are bound parameters in the SQL statement being executed, specified in the prepare().

The prepared SQL instruction can be used to be executed multiple times, with different values. You can understand from the examples below.

• The examples presented it this tutorial use the "sites" table, created in the previous lessons, containig these data:
| id | | name               | | category          | | link                         |
------------------------------------------------------------------------------------
| 1 | | Courses - Tutorials | | education         | | http://coursesweb.net           |
| 2 | | PHP-MySQL Course    | | programming       | | http://coursesweb.net/php-mysql |
| 3 | | English Courses     | | foreign languages | | www.marplo.net/engleza       |

PHP PDO - Select query, fetch


PHP PDO - Select query, fetch

soruce: http://coursesweb.net/php-mysql/pdo-select-query-fetch



To select data in a MySQL table, use the SELECT query, and the PDO query() method. Then, you can get rows data with the fetch() methods and their FETCH constants.

Select data in a MySQL table

Once you have created and added some data in a MYSQL table, you can use a SELECT query, with the PDO query() method to get those data.
The query() method returns a result set with data returned by MySQL, or FALSE in case of error.
In the examples in this lesson it is used the "sites" table, created in the previous lesson, having these 3 rows:
| id | | name               | | category          | | link                         |
------------------------------------------------------------------------------------
| 1 | | Courses - Tutorials | | education         | | http://coursesweb.net           |
| 2 | | PHP-MySQL Course    | | programming       | | http://coursesweb.net/php-mysql |
| 3 | | English Courses     | | foreign languages | | www.marplo.net/engleza       |

PHP PDO - exec (INSERT, UPDATE, DELETE) MySQL

PHP PDO - exec (INSERT, UPDATE, DELETE) MySQL

source : http://coursesweb.net/php-mysql/pdo-exec-insert-update-delete

After the connection to database is successfully created and the PDO object instance is set, the object can be used to perform SQL queries.
The SQL queries with PDO can be made in two ways:
        - directly using "exec()", and "query()" methods,
        - or with the prepare() ... execute() statement.
The first variant is more simple, in this lesson it's presented the exec method.