How to use proxy with curl in php

Curl is a very useful library for transferring data over various protocols like http, ftp, https etc. In other words curl can be used to programatically download a web page, or upload file to ftp etc. It also supports using a proxy. This means that curl requests can go through a proxy server just like a web browser does when configured to use a proxy. Using a proxy with curl is very simple and straight [...]

Convert excel to csv in php

When working with data import and export for example, file formats like csv and excel are commonly used. Data can be exported to csv format and imported elsewhere. Also data might be entered manually in an excel file and then imported in the database. So there might be a need to convert excel files to csv format, so that they can be parsed easily and processed. Converting excel files to csv is very easily done [...]

How to setup an ftp server on windows 8

Ftp Ftp servers can be used to transfer files to a web server or download files from a web server. Windows 8 has an inbuilt ftp server that can be used to do this. Setting up the inbuilt ftp server of windows 8 requires more steps than installing a 3rd party ftp server. However we are going to try to do it in this tutorial. Turn on FTP The first step is to turn the [...]

How to encrypt / password protect directories in ubuntu

Securing confidential data We often need to put some confidential data on the hard drive, in which case it becomes essential to have some kind of security mechanism to keep it hidden from unauthorised access of any kind. It could contain credit card numbers, bank statements and list of passwords for various online services. One way to protect such data with security is to put them in a directory that is password protected or is [...]

Generate qrcode and pdf417 barcodes in php with tcpdf

Tcpdf is a pdf creation library for php that is written in pure php and works without the need of any external library. It also has the feature to generate 2d barcodes like qrcode and pdf417. The 2d barcodes can store much more information than the 2d ones like code39 and ISBN. It is recommended to generate barcodes inside pdf so that they are printed very accurately on hard media like paper and then read [...]

Php – Output content to browser in realtime without buffering

Consider a long running php script that does many tasks and after each task it outputs the status. echo ‘Task 1 complete’; …. some delay … echo ‘Task 2 complete’; …. more delay and more tasks … Now for such scripts it may be important to load the contents in browser as quickly as they are generated so that the user can understand the progress of the script. If the entire output were to appear [...]

Ajax based streaming without polling

Streaming Streaming means to send content part by part at some intervals in the same request. Or in other words, the client is able to process the response part by part, instead of waiting for the whole transfer to complete. The best tool for streaming over the http protocol is SSE or Server Sent Events. But SSE is not available IE 10 so far. While looking for a clean solution (that is one without much [...]

Monitor progress of long running php scripts with html5 server sent events

Server sent events When running a long serverside task inside a web application it becomes very useful, if not necessary to report the progress of that task in realtime to the clientside, that is the browser. Earlier there was no easy way to do this and hacks had to be constructed to achieve such a realtime notification. Classical solutions include ajax polling, loading in a iframe with raw output, or even flash. But html5 brings [...]

How to create password protected zip archive on ubuntu

Command Line The zip command can be used to create password protected zip files easily. Here is a quick example $ zip -P *secret* compressed.zip file.txt Note that the P is capital. Can also type “–password” instead of the “-P”. $ zip –password *secret* compressed.zip file.txt The above approach might be a bit insecure since the password is visible and the command is stored in the terminal history and can be retrieved. Another option is [...]

Monitor and auto restart crond in cpanel/whm

Crond is the cron daemon that is responsible for running the cron tasks of all users on a linux system. Most hosting providers provide it on the servers they sell. Cpanel is a popular server management application that can manage various such daemons and services and restart them if they shut down for some reason. It has a component called ‘chkservd’ that monitors the services that are included in it and restarts them if they [...]