BSNL online recharge (e-recharge) facility using credit card or net banking still a dream!
BSNL is India’s largest telecom service provider with unmatched infrastructure. Mobile or land line services provided by BSNL is extremely competitive in terms of price and features. BSNL has forced other private players to offer better services and reduce their prices. The same has been happening in broadband service area. In Kerala for example, BSNL forced Asianet dataline to upgrade their infrastructure and provide broadband service up to a speed of 2mbps (previously Asianet was providing 128kbps "broadband"!)
But again when it comes to billing or online support for its services, BSNL lags behind everyone. It is so pathetic that sometime you wonder whether there is a conspiracy behind it! I will give you some examples.
Online payment of BSNL land line phone bills
There is no unified online billing system for BSNL. Some of the local BSNL offices (Bangalore for example) provide independent online billing. But when you are in Trivandrum, you cannot pay BSNL bill through credit card or net banking services.
Currently there is only one way to pay your landline bills online. If you have online banking service of SBI (State Bank of India), you can register BSNL as a biller by giving your consumer number and phone number. If everything goes well (which will take sometime) you can start paying your bills through SBI. I am yet to pay a bill successfully!
If you go to any of the main BSNL offices you can see long queues of people trying to pay their landline bills! Building an online bill payment system will only cost peanuts as far as BSNL is concerned. But still it remains a dream…
Erecharge coupons for BSNL prepaid services
BSNL mobile services are good in terms of price and service. The only problem is recharging your prepaid mobile service. There is currently only way to do this. Buy a physical recharge card, scratch it, send the 18 digit number to *123*. There is no way to purchase these recharge cards online and there is no way to do an e-recharge through credit card or net banking. What is surprising is the fact that selling these recharge coupons through online facilities is only going to increase the profit per card for BSNL since there is no dealer commission to be paid!
What BSNL should do?
BSNL should look at complete integration of its services across the country. It should also look at single billing system. A single online system to manage all the services provided to customer is a must. For example, I should be able to enable caller id feature just by clicking a checkbox. For e-recharge or any other valued added services, a feature similar to what is seen in Indian Railways online reservation system (operated by IRCTC) must be provided. IRCTC payment system is very impressive and it supports a wide range of Internet banking services, credit card payments and other payment systems as can be seen below.
I hope that this article becomes obsolete at least within a year of posting!
The PHP vulnerabilities, exploits and hacks in phpBB3, WordPress etc.
I have a couple of sites running under WordPress and phpBB3. When it comes to usability, these products have come a long way. The best part is they are completely free and since they are based on php language, all web hosting service providers support them. But the really ugly part is the vulnerabilities, exploits and hacks out there on these products. You need to constantly watch for any new updates and then apply the patch or latest version immediately. This sounds simple for a single site, but when you have more than a couple of sites it is a nightmare.
There are so many script kiddies out there that it is a matter of time before an exploit or hack is found even on the latest version of WordPress or phpBB. These exploits are usually based on SQL injection, remote file upload or cross site scripting. I briefly cover what each of this means.
SQL Injection attack - This happens when the attacker passes a block of SQL as a user input. This is of course the simplest form. In almost all cases the reason for this exploit is lack of validations on query parameters. This type of attack is the most common and they can be seen in thousands of WordPress plugins out there. The problem with this attack is simple. Once the hacker gets DB under his command, he can create administrative users, drop or add tables or do whatever he want on the application.
Cross site scripting attack - This attack involves methods which injects scripts inside the wordpress blog or phpBB3 site. The injected script may open popup or other browser windows with objectionable content or phishing sites. Assume that a request parameter is displayed on a web page. If someone passes a block of JavaScript as request parameter, it may get displayed and it may get executed as well. Now if someone can execute script on your site’s behalf, it means disaster.
File upload exploit - In this method attacker somehow manages to upload a php file to your hosting folders. Now that gives him complete power to do anything he wants. Typically this is used for spamming. The php file will have a list of email addresses and it will send spamming mail to each of these addresses using the sendmail feature of your server. Recently my web hosting account had a list.php in publi_html folder which was used for spamming and phishing attack.
Couple of my sites have been hacked in the last 2 years. Identifying what got hacked and removing it and then restoring your site to its original form is tedious and time consuming. I really hate script kiddies!
One day I got a warning mail from the hosting provider saying that my account will be closed if I don’t stop spamming. It was a complete shock that someone else had managed to upload a file on my server and then use it on my behalf for illegal purpose! I changed all my passwords and then upgraded WordPress and phpBB3 to latest versions. But still I am very uneasy at the thought that even latest versions can have exploits.
Then another day I got a mail from Technorati saying that my blog is hacked. I checked my web page and there was nothing wrong. When I looked at the HTML source I noticed billions of spam mails under hidden div tags! Someone had hacked into the theme files of WordPress and had cleverly inserted these links. It appears there are automated tools out there which scans for vulnerable WordPress blogs and then hacks them. So for the hacker there is no manual work!
How to minimize hacking/exploit attempts to your website/blog?
There is no 100% sure way to prevent vulnerability attacks. If you don’t use WordPress or phpBB3 you are in a very safe position! But then you miss some great tools. Here are some of my recommendations to minimize vulnerability attacks.
- Use strong passwords for everything. Strong means it should have capital letters, numbers and special characters and should have a minimum length of 8 characters.
- Ensure that all the software you use (WordPress/phpBB3 etc.) are up to date. You need to subscribe to mailing lists to know whenever a new version is out and then apply the patch ASAP.
- Minimize use of plugins or mods. If you have to use a plugin, just use the most reliable and most widely used plugin only. The same applies for phpBB3 mods. Most of these mods and plugins are created by newbie programmers and there is a high probability that they contain SQL injection attack vulnerability.
- Monitor your web folders for any unexpected new files or any file modifications. If you have shell access, you can write a simple shell script to list all files changed in the last week.
- Backup your databases and your web site content regularly. This way you can delete everything and then quickly reinstall stuff if an attack is suspected.
- Use you own custom content management system! - WordPress or phpBB3 is open source and hence people can look for vulnerabilities. If your requirements are simple, you can even look at writing you own stuff. Using custom implementation can stop a lot of automated attacks.
- Access your web site using browser and then look at the HTML source. If you see spamming links or phishing links hidden in your page, you are hacked. Soon Google will apply search penalty and your site may disappear from its search index. So delete everything, restore from backup and then upgrade everything to latest version. Then change all passwords!
How to close all open popup windows on logout action?
Many Web applications I have seen/worked before use HTML popup windows to handle editor/add new screens. But unfortunately there are many issues (lack of modal dialog support for example) with popups and hence using them should be the last option.
How do you close all the popup windows when user clicks on the “logout” link in the main page? I had hoped that there would be some collection in the window object which keeps track of the popups opened from it. But unfortunately there is no such thing. You can use window.opener to find the instance of the parent window, but not the other way around. The only option is to keep track of the popup windows generated using JavaScript.
Following is the approach I have taken. It is not perfect, but so far I haven’t come across any major issues. But if your application is already built and has a lot of window.open() calls, the following approach will affect a lot of source files.
1. Encapsulate window.open() method in a custom application method such as appShowPopup(). The method signature can be same as window.open. This is an important design technique. Whenever you access an important API, it makes sense to wrap it using a application level custom API.
var gblPopupArray = new Array(); function appShowPopup(url,name,features) { for(var i=0;i<gblPopupArray.length;i++) { try { if(name==gblPopupArray[i].name) { gblPopupArray[i] = window.open(url,name,features); return; } } } gblPopupArray[gblPopupArray.length]=window.open(url,name,features); }
2. Inside appShowPopup() keep a track of all the popup windows using a global page level JavaScript array. Ensure that every popup window is named properly using the second argument. Before adding a popup instance check whether there are any instances in the array with same name. If there is one, replace it (instead of adding a new instance to array).
3. On logout, use the popup window array to close all popups. You will need to check the existence of a window before closing. An easier way will be to put the close() code in a try catch block.
function closeAllPopups() { for(var i=0;i<gblPopupArray.length;i++) { try { gblPopupArray[i].close(); }catch(ex) {} } gblPopupArray = new Array(); }
How to assemble a multi purpose computer under Rs. 30000
Computer component prices are falling all the time and it is now easy to assemble a high end multi purpose pc just under Rs. 30000. When I say “high end” I don’t mean using the latest or the highest spec components. But rather a machine which can be used for decent gaming, media work and programming applications.
Since this machine is intended for gaming, you need a PCI Express card and that puts atleast an additional Rs. 5000 on the budget. So if gaming is not your passion, you can reduce the budget to Rs. 25000.
CPU - Intel E4600 (Rs. 5000) - Intel E4600 is a decent CPU which has a front bus speed of 800MHz and a processor speed of 2.4GHz. But there is no virtualization support. If you can spare about Rs. 1000 more you can go for Intel E7200 which I highly recommend. E7200 features VT technology and can support bus speed of 1066Mhz.
Motherboard - Intel DP35DP (Rs. 5500) - Intel DP35DP (which belongs to the media series) supports upto 8GB of RAM and also supports quad core processors. Note that there is no built in video and you will require a PCI Express card for display. If you are looking for integrated video try DG31PR in the classic series.
Memory - 2GB DDR2 800MHz (Rs. 2000) - 2GB of RAM is the minimum you need these days. For an optimum system I would recommend 4GB of RAM.
Graphics Card - XFX GEFORCE 8600 GT 256MB PCI-E DDR3 (Rs. 6000) - XFX 8600 GT is a good graphics for a fair price. The advantage is that you can play almost all games in decent resolution. In future if you get more money, you can easily replace this with 9600GT which costs about Rs. 10000. XFX 8600 GT supports dual DVI links (DVI to analog adapter is also included) and hence support 2 monitors at the same time.
Hard disk - Seagate 160GB SATA (Rs. 2000) - Personally I think 80GB harddisk is good enough. If you need more space you can buy an additional disk later. But again since the price difference is minimal, I would recommend 160GB disk. Note that there are different categories of SATA drive which varies in price and performance.
DVD Writer/reader - Sony DVD (Rs. 1500) - Get the original Sony DVD writer which supports both CD and DVD writing.
Keyboard - Logitech Multimedia USB (Rs. 400) - Get a USB keyboard which works!
Mouse - Logitech Optical USB (Rs. 300) - Get a USB mouse which works!
Computer display - Samsung 19” LCD 920 NW (Rs. 8000) - I have given Samsung just as reference. Explore a couple of different 19″ models before you purchase one. Most good dealers provide a peek at the monitors before you buy it. AOC is another brand which is very cheap especially for higher models (22″). But I am not sure how reliable those monitors are.
Computer cabinet with 450W SMPS (Rs. 1500) - 450W is the minimum you should look for. Again it is good to spend some more money to get a good cabinet. Also ensure that there is enough fans for heat dissipation.
The total cost of all the above components is over Rs. 30000. But if you are good in bargaining, you may be able to get this config assembled under Rs. 30000! :-) Wondering what you will use as operating system? Don’t think of spending Rs. 5000 on a Windows Vista. Instead download or get a copy of Ubuntu 8.0.4. If you still require a Windows OS, go for Windows XP Professional with SP3.
Following list will give you an idea as to what you can do with this computer.
- You can play Doom3 at 1280 resolution with anti-aliasing turned on. At around 60fps gameplay is smooth.
- You can develop Web applications using Eclipse or Netbeans IDE and at the same time run a MySQL server on the machine.
- You can play a divx/xvid video. You can also encode a video into divx.
Installing nVidia drivers on Ubuntu 8.0.4 (Hardy Heron)
nVidia recently has released (May 2008) production quality device drivers for linux 64-bit systems. So if you have Ubuntu 64 bit installed with an nVidia card, download the latest driver from nVidia site.
1. Download 64 bit nVidia driver for Ubuntu. This driver supports the following cards,

- Quadro FX 3600M
- GeForce 9800 GX2
- GeForce 9800 GTX
- GeForce 9600 GT
- GeForce 9600 GSO
- GeForce 9500M GS
- GeForce 8400
- GeForce 8400 GS
2. In order to install the latest driver, it must be compiled for the kernel you have. For this you need development tools such as make and gcc installed. You will also require linux-headers package for your kernel version. Packages pkg-config and xserver-xorg-dev are also required.
3. Uninstall any existing nVidia drivers from your Ubuntu installation. This easier said than done. Following are some of the steps you can take to ensure that no obsolete nVidia drivers are used.
- Remove the package nvidia-glx from the system.
- Remove /etc/init.d/nvidia-glx and /etc/init.d/nvidia-kernel files.
- Remove linux-restricted-modules or linux-restricted-modules-common packages.
- Instead of disabling the above packages, you can edit /etc/default/linux-restricted-modules or /etc/default/linux-restricted-modules-common and add a line, DISABLED_MODULES=”nv nvidia_new”
- Delete /lib/linux-restricted-modules/.nvidia_new_installed file if it exists.
4. Ensure that the downloaded driver installer file NVIDIA-Linux-x86_64-173.14.05-pkg2.run is executable. You can do this by,
Then invoke the installer using the command,
5. The installer can also make the required changes to X server configuration file. Select the required options and continue.
6. Reboot the system. If everything went well, you will see the nVidia logo during the display initialization!
During nVidia driver installation, I encountered a strange problem. Immediately after the driver installation, I was getting complete access to nVidia features and the driver was working. But once I restarted the machine, the display driver was changed and the nVidia features was no longer available. Also the available resolution was reduced. I traced this problem to the existence of generic nVidia drivers still present in the installation. Once I removed every trace of them and re-installed the driver, everything was working in perfect condition!
How to create a cd/dvd iso image in Ubuntu
Recently I needed to backup a couple of cds to a single dvd. The best solution was to extract iso images from cds and then write all of them as data files to a single dvd. I could then use the dvd as a backup. Whenever I needed a cd, I can insert the dvd and then mount the corresponding cd iso image.
How to extract iso image from cd/dvd in ubuntu?
In recent versions of Ubuntu (Hardy Heron etc.), cd or dvd is automatically mounted when you insert them in the drive. So first you need to unmount using the following command (you can also right click on the mounted volume to unmount it),
The above command is used in my system. In your system you may have to replace cdrom0 with dvd or scd0 or even cdrom1 (if you have multiple drives).
Now use the dd command to dump the dvd/cd image to an iso file,
This command will create an iso file named mydisk.iso. Again replace cdrom0 with whatever device name you have on your system for the drive used.
After you have copied all the cd iso files, you can create a new dvd project (using Brasero tool) and then add these iso files as data files. This create a dvd containing these cd iso images.
How to mount a cd iso image in Ubuntu?
Now the question is how to mount these cd iso images when you need the data inside? Well in Ubuntu, it is as easy as issuing a single command,
Here /home/jayson/mydisk is an existing folder under which the iso image will be mounted.
How to burn an iso image to a cd in Ubuntu?
You can use Brasero tool to burn the iso image to a cd rom. Another option is to use the following command line,
Configuring JNDI datasource in Tomcat 6
I was starting on a new project yesterday and I needed the MySQL connection to be configured as a JNDI datasource on Tomcat 6. Tomcat 6 has a separate Web page detailing the steps required to configure JNDI datasource.
So following that advice, I copied the MySQL connection java driver (mysql-connector-java-3.0.17-ga-bin.jar) to TOMCAT_HOME/lib and then added the required entries in server.xml and web.xml as given below. Here xpc is the MySQL database instance I want to connect.
server.xml entry (under Context section)
<resource name="jdbc/xpc" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/xpc?autoReconnect=true"/>web.xml entry
<resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/xpc</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
Then I wrote sample code to connect to MySQL and select a value from a test table. The code is given below. In this sample, JSP calls the Test class to print the value of temp_val from test table. This code also demonstrates how to connect to a MySQL database using JNDI lookup.
Test.java
import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.sql.DataSource; public class Test { public static String t() { try { Context ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/xpc"); Connection connection = ds.getConnection(); Statement stmt = connection.createStatement(); ResultSet resultSet = stmt.executeQuery("select * from test"); while (resultSet.next()) { String temp_val = resultSet.getString("temp_val"); return temp_val; } } catch (NamingException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return null; } }
Test.jsp
<html> <body> <%=Test.t()%> </body>