Tag Archives: XAMPP

SINGLE FILE PHP GALLERY

#24 SINGLE FILE PHP GALLERY

PHP Image Gallery Example

This is a web gallery in one single PHP file. All you have to do is copy the script to any directory containing images to make a gallery. Sub directories will be sub galleries. Thumbnails for images and directories are generated automatically.
Single File PHP Gallery does not require any configuration and is very easy to use and modify.

GOOGLE CHARTS

#22 GOOGLE CHARTS

A Simple Google Charts Example

Google Charts allows us to display big data in a visually appealing way. Google offers animation and lots of other options to modify google charts. The charts are rendered using HTML5/SVG technology and the charts themselves are exposed as JavaScript classes In this example five different charts are drawn and are refreshed every time the page is resized using a simple line in JavaScript:

The Charts Are embedded in iFrames.

window.onresize = function(){ location.reload();}

On page resize the page is refreshed. Since we are using the charts inside HTML iFrames this works quite well.

SIMPLE ANIMATIONS IN CSS

#12 SIMPLE ANIMATIONS IN CSS

CSS animations

The following is a few examples of web loading animations made entirely in HTML and CSS. jQuery is used to add and remove the CSS animations. For example once the document has loaded a jQuery click event can be triggered like so:

jQuery used to call animations

index.php shows a variety of different shapes combined. The following 3 small scripts show their respective shapes. anim.css holds all the animations.

HTML: Hyper Text Markup Language

CSS: Cascading Style Sheets

jQuery: lightweight JavaScript library

Folder structure.

PHP JSON API EXAMPLE

#10 PHP JSON API EXAMPLE

Example calling the scripts in Google Chrome

JSON: JavaScript Object Notation

PHP: Hypertext Preprocessor

MySQL:My Structured Query Language

A simple basic JSON API built with PHP and MySQL. Inside the api folder there are 4 PHP scripts. These scripts can be called using two parameters:

The API Key: e.g = API_KEY=926bc852-1d16-414e-8112-5595bc16ffeb

The Username: e.g = USERNAME=admin@gmail.com

Once the API key is verified the query will return a JSON string with the specified data returned. For example calling checkApiKey.php will return the JSON {"result": 0,"id": "16"} where result = 0 means success and any other result will be a failure code.

A full example calling checkApiKey.php bellow:

http://localhost/PHP_API/api/checkApiKey.php?API_KEY=926bc852-1d16-414e-8112-5595bc16ffeb&USERNAME=admin@gmail.com

Be sure to import test.sql into your MySQL database. test.sql contains two basic tables namely api_keys and users containing the data we want to query with this API.

Please note this is for demonstration purposes. Quite a few security checks have been left out for simplicity’s sake. I’ll make a sophisticated PHP API at a later stage.

API keys database in PHPMyAdmin
Users database in PHPMyAdmin

GENERATE A GUID FOR AN API

#3 GENERATE A GUID FOR AN API

Here is a RFC4122 version 4 compliant solution. simple click on the button to generate a GUID and optional copy button. This can be used to authenticate users and as a session log. Each unique ID can be used in an API as an API key for your users.

Example use in a home made API as follows:
https://myapidomain.com/api/count.php?&API_KEY=6f6825a7-ee36-4a01-ba19-c98cbc41049c&JSESSION=c0b3c124-66ae-4873-abf9-36cde947d78f&USERNAME=testing

Result example if there is an error:

{"result":5,"message":"api key does not exist!"}

The id attribute in the HTML allows the JS to execute the logic of this example

I tested the application using XAMPP which is a great lightweight Apache distribution which lets us create a local web server effortlessly.

You can read up on GUID’s here.