Archive for May, 2009

Raw Sockets C Source Code on Linux

The structure of IP Header as given by RFC 791 is :

0 1 2 [...]

SYN Flood DOS Attack with C Source Code

TCP/IP 3-way handshake is done to establish a connection between a client and a server. The process is :
1. Client –SYN Packet–> Server
2. Server –SYN/ACK Packet –> Client
3. Client –ACK Packet –> Server

Top Games on Ubuntu Linux

So here is a list of games which can be played on Ubuntu.
On Ubuntu 8.10
1. TORCS – The Open Racing Car Simulator – Racing game

Get Country City from IP address in PHP

Here is a simple php script that lets you track the location of the visitor’s on your site using his IP address.
Code:
<?
$ip = $_SERVER['REMOTE_ADDR'];
$url = "http://www.ipmango.com/api.php?ip=".$ip;
$xml = simplexml_load_file($url);
echo "IP address : {$xml->ipaddress}";
echo "City : {$xml->city}";
echo "Region : {$xml->region}";
echo "Country Name : {$xml->countryname}";
echo "Latitude : {$xml->latitude}";
echo "Longitude : {$xml->longitude}";
?>

Parse and Format Dates between PHP and Mysql

Mysql Database stores dates in the format :
yyyy-mm-dd e.g. 2009-04-15
Whereas humans are more used to the formats like :
dd-mm-yyyy or mm-dd-yyyy e.g. 21-04-2009
And while reading a format like :
dd-Month-yyyy is more usable e.g. 21-Mar-2009

PHP Database Class to access Mysql

This is a simple class that evolved out of the php code I wrote so far.
It has the following functions :
1. dbms() – The constructor to do the initialisation like connecting to the database etc.
2. query($query) – The method to take a sql string and perform the query.
3. close() – Close the database connection
4. backup() [...]

Restore Mysql Database from a sql or zip file using PHP

In the previous post we saw how the backup of a database can be taken in the form of a sql file and then zipped.

Backup mysql database with php and zip it

PHP can be used to backup a mysql database and make a zip file of it.
mysqldump is the utility which can be used to perform this function of backing up a mysql database as sql file. The command would be like this :
mysqldump –user={$username} –password={$password} –quick –add-drop-table –add-locks –extended-insert –lock-tables –all {$db} > backups/backup.sql