Saturday, February 28, 2009

Display Live Cricket Score on your site

I wanted to display live cricket score on my site, so I pushed the tea cup aside and got down in front of my PC googling for something significant, to find an hour later that the previous hour I spent went in no man's land!!! I got an inspiration here too from the blog comments BBC Backstage. Ok, so I went ahead and decided to pull out the live score data from wap.cricinfo.com. I first tried to pull out their page source into a string using PHP built in function file_get_contents() but apparently it didn't work out because cricinfo server is too nasty to respond to your http GET request if you don't provide the user-agent string. So, I formulated my own http request and then it worked out effectively. Below is the PHP code fully commented for clarity. The code is in aqua and comments in yellow.

<?php
$matchid=18307; //enter the matchid here
/*How to get match id? Open wap.cricnfo.com through Opera or FF with XHTML-MP extension. Then click the match that you're interested in. From the address bar, read the matchid.
Ok, so now we've got the match ID lets proceed
*/

$fp = fsockopen("wap.cricinfo.com", 80, $errno, $errstr, 30);
/*the above line is to open a socket connection to their server and bind it to a file stream
*/

if (!$fp) {
echo "$errstr ($errno)
\n";
echo "Data not available!";
} else {

/* and these four lines below are our http request */
$out = "GET /liveScore.do?matchId=$matchid HTTP/1.1\r\n";
$out .= "Host: wap.cricinfo.com\r\n";
$out .= "User-Agent: SonyEricssonK800i/R1AA Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1\r\n";
$out .= "\r\n";
fwrite($fp, $out);

/* the below while loop reads the response from their server and stores it into a string i.e. $page
*/

while (!feof($fp)) {
$page.=fread($fp, 512 );
}
fclose($fp);

/* now we've got the page source, just use explode to pull out only the live score from it
*/

$blah=explode("<tr align=\"center\" bgcolor=\"#85ADE4\">", $page);
$blah=explode("</tr>", $blah[1]);
echo $blah[0];
?>


Now you've got the live score in the variable $blah[0], you can do anything with it. Format it according to your site theme and add wherever you want :) You may also use the PHP GD library to create an image from it. Possibilities are endless...

Wednesday, February 25, 2009

Sony Ericsson Idou

Freaking hell!!! It boasts of a 12.1 megapixel camera, a 3.5 inch screen with resolution 640x360, a TV tuner and everything else!!! It'll run on the new open source Symbian OS that isn't yet complete. It was previewed by SE at MWC.
The GSMArena page containing its specs is here.
And, here are some pics of this stunning beauty.(Source: gsmarena.com)


New Site

On 19th of this month I purchased a new shared hosting plan from Umbrahosting. I couldn't get one from IXWebhosting cuz of some technical problems. At Umbra, I chose the Planet plan. Its good. They claim to give 10 gigs of disk space, 100 gigs transfer per month, unlimited FTP accounts, unlimited mail accounts, unlimited add-on domains, a free domain, unlimited DBs, unlimited subdomains and all other bells and whistles that any other host offers!!! Looks great!!! They charge $6.99 per month. On using the coupon code 20off I got a discount of 20% and got it for one year for only $59.99. They support payment through non-verified PayPal accounts too.SO far, the service seems pretty good. They had some downtime problems on their barbara server on which my site is hosted but it was resolved quickly. The support department is good and they respond very quick to tickets. My first ticket was replied just after 16 minutes of creation. They use cpanel for the management which is the best of all hosting control panel softwares. OS they use is centOS. The response times are pretty fast. The domain I took as free was indifun.org.
But I wanted indifun.in so I purchased it from Rediff and added to the site.
About the site
IndiFun has been my most dreamt off project since mid last year. I've been working on it with my oldest net friend REY619 but due to bad lucks hitting at regular intervals we coluldn't manage to run it smoothly and were always jumping from host to host. Free hosts suck!!!! We jumped from VNDV to Orgfree, to x10hosting.com to Freehostia and all of them are crap as hell!!! Finally we got a paid hosting solution and an stable site now. Now I aspire to carry IF to new heights.
IF is basically a mobile community based on the leaked ravingwap script in PHP, with several mods and added features that we both coded together. It works on low-end phones, hi end phones and PCs seamlessly. Check it out yourself if you're connected in someway to mobile sites. Click
If you're interested in purchasing the script just ask me. The price is $80 for non-Indian users and Rs.3000 INR for Indian users. Payments accepted through PayPal for non-Indians. For Indians, direct bank funds transfer is an added option.

Saturday, February 7, 2009

The Linux Cheatsheets

While browing Ubuntu forums after a long time, I came across the Linux cheatsheets maintained by FOSSwire.com. They're great for the experienced Linux n00bs!!!
Check them out:
Ubuntu Cheatsheet
Linux Cheatsheet
Linux is fun! Linux is great! Enjoy Linux! Spread Linux! Create awareness about Linux! Share Linux! Teach Linux! Use Linux!

My first online earning!!

I'm a netizen since June 2001, but never earned anything on net. Last year, I thought why shouldn't I try earning something using the Internet???? And finally I got success in selling a script for $80USD. I received the payment in my PayPal account. The customer was an Australian.
But PayPal deducted $5.02USD as their fee!!! lol
I'm planning to invest that amount in purchasing a nice webhosting plan for my dream site. I, after a few hours of Googling found that ixwebhosting.com is the best for me. But the 2 year expert plan requires $94.80USD. I'm almost $20USD short of that in my account. Ok, lets see how do I manage the rest. Being a student, I don't have any credit card so can't even get the restrictions lifted from my PayPal account.
I'm attaching a screenshot here.

Adsense glitches

I tried signing up for adsense for my blog. But I don't have any clue why Google doesn't want me to.
First of all I went straight to adsense site and there tried signing up with my primary gmail account. It said - "a user with that account already exists". Ok, thats me, I thought. So, I tried signing in directly, and it said "no account exists with that name"!!! Google glitch??? Seems to be.
I then clueless, decided to sign up for a new Google account just for adsense. I used my rediff email account for signing up. My application was accepted for review. A day letter my phone beeped and I knew I've a new mail in my rediff account. I checked and was surprised to see that my Google Adsense application has been rejected. The reason stated was:
My blog address is not a TLD!!!
What the ....???!!!
I see thousands of blogspot sites using adsense and they don't have any TLD.

Ok, finally I tried the Adsense gadget integrated in blogger. I signed up, confirmed my email and my application was taken for review. And afterwards I haven't got any reply from them although I was supposed to get one withinn 2-3 days!

So???? Is it that Google hates me???? I haven't sued them ever, nor ever had thrown a pie over Larry Page and countless more of them....