Category : "Coding"

All kinds of Programming.

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() - Create a backup of ...

Restore Mysql Database from a sql or zip file using PHP

In a previous post we learnt how to inside php. In this example the same zip file would be used to restore the database. Code // Function to restore from a file function restore($path) { $f = fopen('restore/temp.sql' , 'w+'); if(!$f) { echo "Error While Restoring Database"; return; } $zip = new ZipArchive(); ...

Backup mysql database with php and zip it

Many php applications prefer to backup the mysql database from within the application and save it as an archive. The mysqldump commandline utility 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 --opt $db_name > $dir/backup.sql The above command shall dump the database named $db_name ...

TCP Connect Port Scanner Source Code in C with Winsock

Tcp connect port scanning TCP connect() scanning is the most basic form of TCP scanning. The program performs a connect() command on those ports of the target machine which are to be checked. If the port is open then the connect() command will succeed and a connection will be established. If the port is closed the connect() function would simply timeout ...

Code a port scanner in C | linux

Tcp connect port scanning Tcp connect port scanner works by trying to establish a connection with every port that is to be scanned. If a connection is established then the port is open otherwise closed. This technique of port scanner is the most basic form of port scanning. However it is the slowest and not very stealthy and easily caught by ...

Php – parse text and convert urls into hyperlinks

The following function will parse a given text and convert all the urls into links. It does this using regular expressions. It converts email addresses to mailto links as well. Code function parse_links($str) { $str = str_replace('www.', 'http://www.', $str); $str = preg_replace('|http://(+)|', '<a href="http://$1">$1</a>', $str); $str = preg_replace('/((+)(.+)*@(+.)+{2,6})/', '<a href="mailto:$1">$1</a>', $str); ...

C Packet Sniffer Code with libpcap and linux sockets

Libpcap Libpcap is a packet capture library for linux which can be used to sniff packets or network traffic over a network interface. Pcap Documentation gives a description of the methods and data structures available in the libpcap library. To install libpcap on your linux distro you can either download the source from the website and compile it and install. Or if ...

Packet Sniffer Code in C using sockets | Linux

Packet sniffers Packet sniffers are programs that intercept the network traffic flowing in and out of a system through network interfaces. So if you are browsing the internet then traffic is flowing and a packet sniffer would be able to catch it in the form of packets and display them for whatever reasons required. Packet sniffers are used for various needs like ...

Run php scripts from cron

Automatic Running In a web application there are many cases, when a certain piece of code or script needs to run automatically in the background to perform certain tasks, without the need of any user to start it. Like scraping, extracting or crawling data from web or perform some regular tasks like sending emails, system maintenance or administration, taking backups or ...

Php set_time_limit wont take into account socket operations

The PHP function set_time_limit is used to set a time limit on the maximum execution time of a script. But if the script has socket operations using fsockopen , fread and fwrite or even CURL then the set_time_limit may not appear to have any effect on the scripts timelimit or timeout. Again if safe mode is on then also set_time_limit has ...



Connect with us