terça-feira, 27 de dezembro de 2016

Security in PHP web pages

One concern that must be present in all Web developers is the security of their products.

In this article we start a series of articles which will explore some basic security issues related to injecting SQL statements into web forms or URL parameters.

Examples of code with security issues and how to avoid them are presented.

So let's start with a simple login form implemented with the following code:

In this example, the code checks to see if more than one database record has been returned, thereby assuming that the credentials provided are correct.

The biggest mistake involves concatenating the values ​​received from the form with the SQL statement, thus allowing the user to manipulate the instruction to his or her own pleasure.

Regardless of the user name entered, simply type in the password the following text if you choose to indicate that the login has been successfully completed: o' or 1=1 #

With this text the SQL statement will always return a record because 1 equals 1. The # at the end lets you ignore the rest of the statement as it is the symbol for comments in MySQL.

The solution to this problem is to use parameters, preparing the statement before executing it. So the following code resolves this problem:

terça-feira, 14 de junho de 2016

Google OAuth 2.0 in ASPX

In this post I will demonstrate how to use Google OAuth in a ASPX webform with C#.

This project uses Visual Studio 2015 and as a option for the user to sign-up and other to check the sign-in.

Let's start by creating a new project.

PacMan 3D

In this post we will be making a simple and classic game, the Pacman, with Unity 3D.

Let's create a new a new project

segunda-feira, 4 de abril de 2016

Entity Framework

This post is about entity framework and how to use it to make, almost with a simple mouse click, the CRUD (create, read, update and delete) operations over a table.

Let's start by creating a web MVC project with Visual Studio 2015.

sexta-feira, 25 de março de 2016

Mobile == Optimization

 Going mobile is not easy, so you must consider it from the beginning.

So I decided to develop a new project for the mobile devices and having a simple structure working I started looking at de frame rate and, surprise surprise, it look bad. I mean it was 6 to 8 frames per second and the scene was almost empty.

Then I look at the bag of optimizations and started the kung fu:
- first simplify the models, less vertices, less faces, less edges all led to faster rendering;
- change the Unity shaders to mobile;
- I'm using a terrain so looking at the options I started messing with this:
  - pixel error;
  - base map distance;
  - detail distance;
- Theres one directional light in the scene so here's what I changed:
  - baking to baked;
  - shadows to hard shadows;

In the scripts I looked at:
- string concatenation - make it with stringbuilder;
- function calls, some times can be avoided;
- some functions can be optimizaded like the Mathf.Abs that I changed for  x = (x > 0 ? x : -x).

After all this tricks I get 20 frames per second, not bad! And the frame rate is stabel, not droping has I add more elements to the scene.

There are some more changes that I'm going to test with the physics engine but for now I'm happy.

sábado, 12 de março de 2016

New Unity 3D Project

Today I will present a new project that I started.

From the post about the car I am building a game with cars, or transportation. The idea is very simple: the player starts with a car and a mission, when he is done with the mission he gets some cash that can be spent buying a new vehicle.

Here are some pics:

- the car in Unity

- the car in Blender

- working in the texture

- looks great

- a wheel

- the texture in Gimp

- back in Unity testing different materials  like water

- and code

quinta-feira, 25 de fevereiro de 2016

Tic Tac Toe in Unity 3D

In this post I will present you with a tutorial to make a simple Tic Tac Toe game in Unity 3D.

Watch the video and download de project.

Project in GitHub

quarta-feira, 24 de fevereiro de 2016

Arduino through PHP

This post presents a project that will use three programming languages in order to communicate with an Arduino board from the browser.

The objective is simple: a Web page will send and receive data from the Arduino connected to a web server.

In the Arduino there will be a simple communication protocol that's responsible for the interaction with the sensors.

The Web server is running Apache over Windows and the programming language selected is PHP.

A small programming will allow for the web page, built with PHP, to send and receive data through the USB port. It's a small console mode application created with C#. The PHP web page server side will run this command with different parameters and it will return the data read from the Arduino.

Although there are multiple PHP frameworks that claim to work with the USB port none of them worked for me.

terça-feira, 23 de fevereiro de 2016

Let's make a car in Unity 3D

In this post we will make a simple car in Unity 3D.

The Unity 3D physics engine is used in order to give the car a real behavior.

This are the steps:

[1] - Create a new Project