Tuesday, November 3, 2009

How to htaccess: Password Protecting Your Pages

  • You're building a new site, but you only want yourself (and maybe a select few) to be able to view the work-in-progress.

  • You have an area of your site that you never want the general public to have access to - for example, your web stats or private pages.

  • You have some paid (subscription) content on your site that only subscribers should be able to access.

Apache lets you password protect individual files, folders, or your entire site fairly easily. Read on to find out how it's done.

What to do:

To add password protection to your pages, you need to do the following two things:

  1. Create a text file on your server that will store your username and password.
  2. Create a special file called .htaccess in the folder you want to protect.

That's it! Now let's take a look at how to do each step.

How to do:

  • Creating the Password file:

The first step is to create a simple text file that will store your username and password, separated by a colon (:). The small catch is that the password must be encrypted. Luckily, there are many free web-based utilities that will encrypt the password for you. Try one of these:

Simply enter your desired username and password in one of these pages and submit the form. You'll get back a string similar to the following:


Now, open up your favourite text editor (e.g. Notepad or TextEdit), then copy and paste the username/password string into the editor. Save the file and call it .htpasswd.

Next, upload this file to your website. Make sure you place it outside the Web root of your site if possible, as you don't want just anyone to be able to view the file! For example, place it above your public_html or htdocs folder. (Having said this, Apache is often set up by default to block web-based access to files beginning with .ht. Better safe than sorry though!)

If you can't place your .htpasswd file outside your Web root, name it something that's not easily guessable - for example, .htxuymwp - so that people won't be able to find it easily. (In addition, it helps to start the filename with .ht; as mentioned earlier, Apache usually blocks access to files starting with .ht.)

Alternative: Creating the password file using htpasswd
If you have SSH access to your web server (or you're running Apache on a local machine), you can encrypt your password and add it to your password file in one go by using the htpasswd utility that comes with Apache. Simply SSH to your server or open up a terminal window on your local machine, cd to the folder where you want to create your password file, and type:

htpasswd -c .htpasswd fred

(where fred is the username you want to use). You'll be prompted to enter and retype your password, then the .htpasswd file will be created for you.

  • Creating the .htaccess file :
Now that you have created and uploaded your password file, you need to tell Apache to use it to protect your page(s) or site. This is what your .htaccess file will do.

Open your text editor again, create a new file, and save it as .htaccess.

Protecting a folder: To password protect a folder on your site, you need to put the following code in your .htaccess file:
AuthUserFile /full/path/to/.htpasswd
AuthType Basic
AuthName "My Secret Folder"
Require valid-user

/full/path/to/.htpasswd should be the full path to the .htpasswd file that you uploaded earlier. The full path is the path to the file from the Web server's volume root - for example, /home/username/.htpasswd or C:\wwwroot\username\.htpasswd. (If you're not sure of the full path to your site or home directory, ask your Web hosting company for this info.)

The above .htaccess file will password protect all files in the folder that it is placed in, and all sub-folders under that folder too. So if you wanted to password protect your entire site, you would place the .htaccess file in your Web root folder.

Protecting a file: To password protect just a single file in a folder, use the following .htaccess file:

AuthUserFile /full/path/to/.htpasswd
AuthType Basic
AuthName "Restricted Access"
Require valid-user
This will password protect just the mypage.html file in the folder where you put the .htaccess file.

  • Uploading the .htaccess file
Once you've created your .htaccess file, upload it to your website, placing it in the folder (or folder containing the file) that you want to protect.

Now use your Web browser to visit the folder or file that you've protected. You should see a password dialog like the one shown at the start of this tutorial. Type in the username and (unencrypted) password that you chose earlier, and you should be given access to your folder or file!

Note: with this type of password protection, you continue to have access to the password protected stuff until you restart your browser.

You have got issues?
If you can't access your stuff and the dialog keeps popping up, check that you entered the username and password correctly. If it still doesn't work, check the path to your .htpasswd file on the server - make sure the path specified in the AuthUserFile directive is correct. Also make sure that both the .htpasswd and .htaccess files are readable by the Web server user (chmod 644 should do the trick for UNIX/Linux/FreeBSD servers).

If the password protection isn't working (i.e. you can still access your stuff without needing to enter a username/password), check that you uploaded your .htaccess file to the right folder. Also check that your web server supports .htaccess password protection (it needs to be an Apache server, and your server admin needs to have enabled the AuthConfig override for your site).

Password protecting more stuff
  • If you want to password protect other folders (that aren't under the currently protected folder), simply copy your .htaccess file to the new folder to be protected.
  • To password protect more than one file in the same folder, just create more blocks within the same .htaccess file - for example:
AuthUserFile /full/path/to/.htpasswd
AuthType Basic
AuthName "My Secret Page"

<Files "mypage.html">
Require valid-user

<Files "myotherpage.html">
Require valid-user

Adding more usernames and passwords
You're not restricted to just one username/password. If you want to add other usernames and passwords, simply repeat the "Creating the password file" procedure above, but add each new username/password line to your existing .htpasswd file, e.g.:


Alternatively, if you're using htpasswd to create your passwords, as described earlier, then you can add extra users with the command:

htpasswd .htpasswd stranger

(where stranger is the username you want to add). Make sure you don't include the -c option when adding additional users, or htpasswd will attempt to create a new password file!


Friday, October 23, 2009

Trimming with Javascript

I simple but effective implementation of javascript for trimming extra spaces from a string. A good use of it could be on form validation.
The custom trim function :
function trim (str) {
var str = str.replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
Typical use of trim :
function validate()
val = document.getElementById("txt").value;
retval = trim12(val);

Surely if you use any rich javascript library a trim method should come with it. Have fun :)

Thursday, October 8, 2009

Clouds in the net

I'm always a web addict and the thing that amaze me these days is the clouds in the net. So, I thought why don I list all of the clouds that I went through and think pretty interesting :)
You can have a look at them. Happy clouding :

Skydrive: 25GB[started with 5GB !!] of free file storage and sharing cloud service brought by microsoft live.
Live Mesh: Brought by microsoft live for synching files and folders from your your devices and making them available over one another plus over an webdesktop.
eyeOS: Opensource Cloud desktop. The first cloud that I got amazed of the one that inspired me in next generation web application development.
Google Docs:Document sharing cloud on the net that use to store and share and collaboration on creating a document.
gOS: Connecting all the open services online on a thin client over a light weight linux OS. I guess the same approach is being adopted by Google OS.
CloudDB: As the name says it is a cloud for databases. And the service is free - at least to some extent

[To be continuted...]

Some Popular Youtube Clone - Video Portal Scripts

For those of you who may be interested in setting up a niche video website based on the Youtube video sharing Social Media model - there are plenty of php scripts out there that will basically allow you to easily setup a Youtube clone website. I have worked with a lot of them - specifically the top popular ones, and this post is a brief review of video sharing scripts. These scripts can be installed on solo websites or within a sub-domain or folder within your current existing website. While there are now plenty of Video Share scripts out their (many of them just re-writes and refurbished clones of original ones), the scripts I review below are the ones that are on the top of the list.

PHPmotion -This is a free, opensource script and a good startig point if you do not have the money, but would like to experiment to see what kind of traffic your video niche portal can attract. I would not recommend it to anyone who is serious. It works well, but the design templates and the functionality is not that great. But, if you are on a shoestring budget and all you want to do is throw up something quickly and cheap - you can try this. Score: 7/10

Clip-Share - One of the initial players in this space. Has amazing graphical and layout templates that can be purchased in addition to the 4 basic templates that come pre-packaged. This is a solid script and a highly recommended choice for the serious. They sell 2 different versions - a Lite version at $99 and a Pro version at $199. You can purchase additional Web2.0 look-and-feel design template for $100 each. The template files can easily be customized as you wish. I had no problem whatsoever with their support and they were prompt to answer and get back to me with solutions to the problems I faced. If you have the budget go for this one. Recently GodTube.com that uses their script gota funding round of $30 million. Score: 9/10

Rayyz.net - This script is not just for video sharing. It is a complete Social Media website that has has video, photo, music, files, articles, games, blogs and community networking built into the dash board. If you’re looking for a more than just video and a full fledged script of Social Networking around various media - then take a look at this script. Athough, I have not personally tested this script or worked with it - it seems to be alright. the price is a bit steep at $418. If you are serious about setting up a Social Netowrking site around media sharing content, it would be better if you installed Boonex (which has a free version). However, dont strike out Rayzz from your list - as it is quite powerful in its own way (it focuses more on the Social Media sharing tools and aspect than the Social Networking aspect, which is what Boonex does). Score 6.5/10

Attachmax - This script will allow users to download the videos in addition to viewing them streamed. The script comes with a basic database of videos so you can have pre-populated content on your site. While the layout and graphic design may suit some people, I thought the script was pretty average and not too focused. At $$ , this may be a good buy to some of you. Score: 6/10

Alstrasoft Video Share Enterprise - Stay far far away from this one. Its got holes in it and the people behind it have a very bad reputation. I don’t want to bash them too much, but just do a search on Google with their name and you will see what other disgruntled people are saying on various forums. At $300 this is a complete waste of money (even though I would not pay even $10 for it). You have been warned! Score: 0/10

MediaMax Script - This script is a recent re-branding of Video Watch Pro. They have videos, pitcure, audio and social networking too - built into this script. The site and demo looks pretty impressive at $299 and they even have a Google Adsense flash video integration - which will allow you to earn more money within the flahs player. I have read elsewhere that their customer service is not up to mark - but this is not from a confirmed source. I think - you are good to go if you like their look and feel and functionality. Quite impressive. Score: 8/10

VShare - This is the script with the highest value-for-money at $10 !! The features are very advanced and their are plenty of them. I was quite taken by surprise to see the amount of features this script had packed into it - such as, alternate video server uploading, youtube direct embedding etc. The only drawback was the graphical template… it looked a bit ordinary. So, if you have the time and resources to alter template files - then i recommend this script highly. Although there are a few vendors on their site forums who are selling laternate templates, I am yet to see one which is “professional looking”. Also, I’d like to point out that their support and forums are extremely good and I got answers very quickly. Install this script if you have the ability to dabble around with the template and improve its basic look. Score: 9/10

osTube - This script is a media sharing model and offers Video, Photo, Audio, Documents, Community and Blogs. The pre-packaged templates look quite impressive and the functionality and video player look good. I don’t have any idea what it costs - but you should test drive their free version, which has limited features, before you buy their paid versions. They are definitely the most impressive “media sharing” scripts out their from what I can see. May not have as many functions as Rayzz (above), but definitely a better and sleeker dashboard - although I dont know how the engine is under the hood. On what i’ve seen and assuming this script works well, I give them - Score: 8/10

PHPmelody - If you’re looking to setup a Music Videos website, then this is script is fantastic. It does not allow you and your visitors to directly upload videos to the site - but one can embed videos from Youtube - which is a fantastic feature, as not only does it save bandwidth and server resources but it also allows you to quickly add content. They also have a neat “keyword” based search that the admin can use to find videos on Youtube and add them with one click! The script comes pre-packaged with thousands of pre-populated music videos - if you want to get content included right away. A breeze to install, and definitely worth the price at $39 with additional layout templates at $10 to $19. Support is excellent and prompt. Score: 10/10 if you are creating a Music Video website.

VidiScript - This one is a free script and it looked pretty decent (front end) - with ability to show pre-roll ads, insert text banner ads inside video player, a decent flash player, and two not-so-good light and dark templates (that can always be improved by you). VidiScript not only supports Videos, but now also supports Audio, Photo and Flash Game uploads. I dont know how stable this script is and how it will hold up for a busy site, but… hey… its free! and so definitely worth a try. Score: 8/10 (based on what I saw in the front end demo)

Clip-Bucket too. Its free and open sourced. I am not sure how secure it is and how it performs when measured up with the scripts above, as I had a quick look at the front end, but did not install it or use it on a site of my own. I must say for free price, the templates, the player the look and feel are HIGHLY professional and the folks behind it have done a great job in making a very neat user interface and front end. By the looks of it - this is going to be a killer video sharing script … and will probably put behind vhsare and phpmotion - if the backend lives up to the quality of the front end.

Mass video populator: It claims that it will allow you to mass populate and add videos to your video site (all scripts above are supported), in a few clicks. The price, I believe is the only downside as they have gone in for a bulk pricing, which works out to around 10 cents a video - steep I thought, for someone who wants to add say 1000 videos. Its a web based remote service.

VideoWatchPro: It is not that great, and scores around 5/10, from a brief look. I havent seen it in depth - but it doesn’t look to be anything worth spending more time on.

Conclusion: I suggest that you pick and choose from the scripts above and if you are selecting one not listed above you do your homework well - as their are many clones and copies of pre-existing scripts out their with holes in them. Start doing your research on this page of hotscripts.com - that lists a whole bunch of media sharing php scripts, and also make sure you visit forums such as Programming Talk to read reviews posted by other customers.

Tuesday, October 6, 2009

Open Source Social Networking Software

Top 10 Open-Source Platforms that Allow You to Build Your Own Social Network

Top 10 Open-Source Platforms that Allow You to Build Your Own Social Network   

Pilgg :  Pligg was created as a social networking CMS. While most content management systems are designed for only a handful of authors, Pligg CMS was designed to manage a site with an unlimited number of authors. All of these registered users are in control of the website’s content. It is a user driven CMS that relies on independent authors’ content and participation to manage news articles.

Mxxt :   Mixxt is a intelligently designed open source platform that helps you build your very own social network at rapid development speeds. Develop, manage, and run your own community with ease and the help of forums, wikis, a custom design, the addition of photos, and a private network that’s dedicated to your community. You’ll also be able to work alongside other members to build and grow your community.


spree is an expert search engine where users ask questions to find other participating users, who are knowledgeable in that area and willing to help.


iSocial is a free social networking CMS software that allows you to create your own Friendster and Orkut like sites. Use bookmarks, dating and create groups with just one mouse click.


Mahara is fully featured electronic portfolio, weblog, resume builder, and social networking system for connecting users and creating online communities.


This is a Social Network module for xoops CMS. You have seen Facebook, Orkut, Myspace , try Yogurt for Xoops!


VMukti is a Unified Social Collaborative conferencing engine. Allows access through personalized, mashable web-interface. Core features:- Video conferencing, Audio conferencing, IP Telephony, Desktop sharing, Chat, Whiteboard, Presentation & More.

The PeopleAggregator

The PeopleAggregator is a next-generation social networking system that goes beyond the idea of social networks as mating games, and attempts to use open standards, network inter-connectivity and massive flexibility.


Appleseed is (augmented) social networking software, ie Friendster, only distributed. Sites running Appleseed will interoperate, and form the 'Appleseed Social Network.' Development is focused on privacy and security, as well as ease of configuration.

Mugshot Project

Mugshot was a social networking website created by Red Hat. Unlike most other social networking websites (which are concerned with advertising), it offered a desktop client and web widgets. Mugshot was meant to facilitate real-world interactions with friends, and make one's normal computer use more social. It provided the functionality of a social network aggregator.


Web 2.0 bookmarking system, both social (with tags) and private (with folders). Import and export your bookmarks from Firefox, IE, Mozilla, Netscape. Admin management section, translations, groups, bookmarklets, Firefox extension, RSS feeds, and more!


Akarru is a social bookmarking engine, is used to build social bookmarkings sites, like www.blogmemes.com. Users posts links and promote links to front page using voting system.


Web-based social bookmarking system. Allows multiple users to store, share and tag their favourite links online.


SemanticScuttle is a social bookmarking tool (based on Scuttle) experimenting new features as hierarchical tags, collaborative descriptions or OpenID authentification.


Create collaborative social websites (like Ning, Myspace, Yahoo or Google groups). Each group can create a multiple web pages. They get a drop in guestbook, blog, forum and wiki. Each group is fully customizable using xHTML, CSS, Javascript and PHP.


Clonesumating is the open source version of the code that runs CONSUMATING.COM. It features many state of the art social networking functions including user profiles, user tagging, matching and discovery based on quirky tag combinations, group activities such as weekly photo contests and blog questions, an event calendar, RSS feeds for everything, etc. It is written primarily in mod_perl.

BeWelcome Rox

Get to know the global village and other cultures, share your place. BW Rox is the platform driving www.bewelcome.org and other social networks, aiming to bring people together in real life. Organize your travel or stay abroad, travelblog, meetings, ...


ICEcore open team collaboration software uses social networking to unify team workspaces w/ real-time web conferencing. Collaboration for knowledge networking, program management, communities-of-practice, telework, ...


Memephage is an automated web log (blog). It passively gathers and summarizes links from various places. Currently: IRC, social MUDs, e-mail, and web browsers. Uses the POE multitasking and networking framework for Perl.


A platform for the delivery and support of online learning. It differs from many other elearning platforms in that its aim is to concentrate on the social/interactive aspects of teaching and learning rather than the delivery of content to students.


Elgg is an open source social networking platform developed for LAMP (Linux, Apache, MySQL, PHP) which encompasses weblogging, file storage, RSS aggregation, personal profiles, FOAF functionality and more.


CommunityNews uses social bookmarking and bayesian techinques to provide periodic postings to blogs. Users can vote for or against RSS sources ti increase the chances that the source is used again. Spam filtering (bayesian) is provided by spam bayes.


OpenPNE is a Social Networking Service Engine written in PHP. It has many features(friend control,friend invitation,diary,blog feeds,message box,etc).


Feed Aggregator Reader (branched from FeedOnFeeds) with Social Bookmarks (del.icio.us, Blogger, Newsvine, Technorati, mailto), Article Starring, Feed Tagging, OPML, Article Search, Reblogging and Refeeding, Aging, and Edit feed attributes.


NewsCloud is an open source media platform for citizen journalism and the social news network hosted at NewsCloud.com.

Feed Me Links

Feed Me Links stores your bookmarks online so you can get to them anywhere. Import your favorites and share your links with friends. Add tags to organize your links. Discover new things.


WorldSpace is a user-extensible shared virtual environment, aimed at being a next-generation social networking system.

Social Networking POC

A networking site on the lines of Orkut.Right now we plan to build it on Jboss seam and use a Java content management system like apache Jackrabbit as the backend. It would be more of a POC than an actual commercial app.


Zoints is intimately aware that online communities are the most important aspect of the internet. Our free software solutions are designed to help solve the three major problems forum owners face: Member acquisition, Member retention and Profitability.


A simulation of the world, there will be a global map representation and players can choose a country or civilization and develop it's social, political and military existence.


PHPizabi is one of the most powerful social networking platforms on the planet. With literally thousands of websites powered by PHPizabi including everything from simple friends sites to the most complex networking super sites out there.


Ozcode is the source code behind Ozmozr.com, a microformat-aware RSS aggregator, social networking, resource sharing, identity aggregation and presentation site.


TallStreet.com is a new search engine concept where users make investments, with fictional money, in their favourite websites and the rankings are determined entirely by the users.


Jamss is a social news site based off of Digg.com. Jamss allows for peer submission and review of web articles and can be adapted to fit a variety of themes. Jamss runs on PHP/MySQL.


Dolphin is open-source and free, although there is a cost associated with removing the company�s links from your site.


Ospo is an opensource social portal project. It use standard function (add, remove friends, top10), forums integration, music module (artists directory with albums, songs), shoutcast integration, blog (add, delete, modify, view) and so on.


AstroSPACES is the world's first open source social networking solution. Coded from scratch, it is highly efficient and very easy to use.


FlightFeather's goal is "social networking for everyone". This means that anyone should have a chance to run a popular social networking site -- on minimal hardware, and without wasting bandwidth.


Social Networking Open Source Software, an open source social networking framework, written in PHP, Javascript and MySQL with an AJAX UI.


OpenSocialNetwork is a social network of open source. Its main task is to create a social network releasing the source code.


S3B - Social Semantic Search and Browsing - is a middleware that delivers a set of search and browsing components that can be used in J2EE web applications to deliver user-oriented features based on semantic descriptions and social networking.


Facelift is a visualization and analysis software for online social networking services. It displays a given community as a node-link diagram and provides several search / filtering functions as well as cluster analysis features.
Anahita Social Engine - Anahita is a scalable social networking platform that is built as Joomla extensions using the Nooku framework.

Anahita Social Engine
Community Engine - Community Engine is an open source plugin for Ruby on Rails applications that provides the common features of social networking applications

Community Engine

Oxwall -Oxwall is unbelievably flexible and easy to use PHP/MySQL community software platform.

Monday, September 14, 2009

SEO friendly URL redirection

There are couple of things that one should maintain while redirecting urls not to let the site rank fall down on the search ranks.
Lets first learn about some redirects and then we'll see how to implement them on different servers and/or environment.
  • Redirection : In the HTTP protocol used by the World Wide Web, a redirect is a response with a status code beginning with 3 that induces a browser to go to another location. The HTTP standard defines several status codes for redirection:

    • 300 multiple choices (e.g. offer different languages)
    • 301 moved permanently
    • 302 found (e.g. temporary redirect)
    • 303 see other (e.g. for results of cgi-scripts)
    • 307 temporary redirect

  • Dealing the redirection :
    • html:
    HTTP/1.1 301 Moved Permanently
    Location: http://www.example.org/
    Content-Type: text/html
    Content-Length: 174

    <p>This page has moved to <a href="http://www.example.org/">http://www.example.org/</a>.</p>
    • CF : Put the following code on the Application.cfm/cfc or on the home page
    <cfheader statuscode="301" statustext="Moved Permanently" />
    <cfheader name="location" value="http://www.new-url.com"; />
    <cfabort />
    • Apache server : Put the following lines on the .htaccess file
    Redirect ^oldpage.html http://www.example.com/newpage.html [R=301,L]
    • php
References :

Wednesday, September 9, 2009

C# Word Counter

I don write code for long time. I wrote this program just to count an essay ;) So not a very big deal actually.
What I have practiced here :
  • Openfiledialog : How to open and select a file.
OpenFileDialog fDialog = new OpenFileDialog();
fDialog.Title = "File to read";
fDialog.Filter = "txt files|*.txt";
fDialog.InitialDirectory = @"C:\Documents and Settings\roni\Desktop\Temp";

if (fDialog.ShowDialog() == DialogResult.OK)
  • Reading a file:
StringBuilder newFile = new StringBuilder();
string filestring = File.ReadAllText(@"C:\p_keydump.txt");
filestring = filestring.Replace("\r\n", ",");
  • Count the number of words is the file.
countedWords = strText.Split(' ').Length;

Thursday, August 13, 2009

Invoking webservice using php

Yah, I just finished primary work for an online application. Basically I just learned how to use SOAP to access a webservice using php.
PHP 5 has introduced SoapClient class to do such things. Following is the code that I used :

$wsdl_url = "http://urltowebservice.wsdl";
$client = new SoapClient($wsdl_url);
$params = array('pasrm1'=>7, 'param2'=>'EN');
try {
$objectResult = $client->SomeMethod($params);
echo $objectResult->ResponseResult;
} catch (SoapFault $exception) {
echo $exception;

Reference :
If you are interested about working with simpler SOAPS without using a wsdl file you can check the following:

Tuesday, July 21, 2009

Php page/URL redirect with header() function

If you are a php developer then you must know how to redirect a page from current page using php header() function. And example script should look like as follows :
header("Location: http://www.myurl.abc");
echo "I don know what to do next";
The only thing that you should take care of is that NOTHING should be printed before the header() function call.
Now if you need to call this header function in the middle of any of your html design- what to do ? Simple call ob_start() at the very first line of your page then call have all your html tags,call your header() function and and call ob_end_flush() immidiately after header() function call. The code should look like as follows :
//Your html and or other code to print html
echo "A line before header() call";
header("Location: http://www.url");

Monday, July 20, 2009

Five useful URL rewriting rules

If you are looking for the examples of URL rewriting then this post might be useful for you. In this post, five useful examples of URL rewriting using .htacess are depicted.

Now let’s look at the examples

1)Rewriting product.php?id=12 to product-12.html

It is a simple redirection in which .php extension is hidden from the browser’s address bar and dynamic url (containing “?” character) is converted into a static URL.

RewriteEngine on
RewriteRule ^product-([0-9]+)\.html$ product.php?id=$1

2) Rewriting product.php?id=12 to product/ipod-nano/12.html

SEO expert always suggest to display the main keyword in the URL. In the following URL rewriting technique you can display the name of the product in URL.

RewriteEngine on
RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2

3) Redirecting non www URL to www URL

If you type yahoo.com in browser it will be redirected to www.yahoo.com. If you want to do same with your website then put the following code to .htaccess file. What is benefit of this kind of redirection?? Please check the post about SEO friendly redirect (301) redirect in php and .htaccess.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^optimaxwebsolutions\.com$
RewriteRule (.*) http://www.optimaxwebsolutions.com/$1 [R=301,L]

4) Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz

Have you checked zorpia.com.If you type http://zorpia.com/youruserid in browser you can see youuserid's profile over there. If you want to do the same kind of redirection i.e http://yoursite.com/xyz to http://yoursite.com/user.php?username=xyz then you can add the following code to the .htaccess file.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1

5) Redirecting the domain to a new subfolder of inside public_html.

Suppose the you’ve redeveloped your site and all the new development reside inside the “new” folder of inside root folder.Then the new development of the website can be accessed like “test.com/new”. Now moving these files to the root folder can be a hectic process so you can create the following code inside the .htaccess file and place it under the root folder of the website. In result, www.test.com point out to the files inside “new” folder.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.test\.com$
RewriteCond %{REQUEST_URI} !^/new/
RewriteRule (.*) /new/$1

Friday, June 19, 2009

Fix-it from Microsoft for Bangladesh 2009 Daylight Saving Time

Owao... M$ seems to be pretty interested providing patch for BD windows users !! :D Check the following notice :

Notice: Optional Fix-it Available for Bangladesh 2009 Daylight Saving Time
As reported in the Bangladesh Government’s Gazette, Bangladesh has announced the introduction of Daylight Saving Time (DST). The start of DST for 2009 is on June 19th at 11:00 PM.
Microsoft has produced an automated workaround (called a fix-it) to implement the DST Start time change for Windows XP, Windows Server 2003, Windows Vista and Windows Server 2008. The Fix it solution is a MSI file so it is deployed as any other MSI based software package.
If interested in downloading this workaround please refer to KB972423 titled:”An optional update is available to update the Daylight Saving Time for Bangladesh for the year 2009 for Windows XP, Windows Server 2003, Windows Vista and Windows Server 2008 based computers”
For other Windows versions, please refer to KB 914387 “How to configure daylight saving time for Microsoft Windows operating systems” on how to update the time zone registry key.


Friday, June 12, 2009

The Climb

Alexander, J; Mabe, J;

I can almost see it
That dream I am dreaming
But there's a voice inside my head saying
"You'll never reach it"

Every step I'm taking
Every move I make feels
Lost with no direction
My faith is shaking

But I gotta keep trying
Gotta keep my head held high

There's always gonna be another mountain
I'm always gonna wanna make it move
Always gonna be a uphill battle
Sometimes I'm gonna have to lose

Ain't about how fast I get there
Ain't about what's waiting on the other side
It's the climb

The struggles I'm facing
The chances I'm taking
Sometimes might knock me down
But no, I'm not breaking

I may not know it
But these are the moments that
I'm gonna remember most, yeah
Just gotta keep going

And I, I got to be strong
Just keep pushing on

'Cause there's always gonna be another mountain
I'm always gonna wanna make it move
Always gonna be a uphill battle
Sometimes I'm gonna have to lose

Ain't about how fast I get there
Ain't about what's waiting on the other side
It's the climb, yeah!

There's always gonna be another mountain
I'm always gonna wanna make it move
Always gonna be an uphill battle
Somebody's gonna have to lose

Ain't about how fast I get there
Ain't about what's waiting on the other side
It's the climb, yeah!

Keep on moving, keep climbing
Keep the faith, baby
It's all about, it's all about the climb
Keep the faith, keep your faith, whoa

Monday, May 18, 2009

Computer Vision and Artificial Inteligence

I's studying computer vission for couple of days and as a open source fan follwing are the libraries that I though I should work with :

  • AForge.Net: AForge.NET is a C# framework designed for developers and researchers in the fields of Computer Vision and Artificial Intelligence - image processing, neural networks, genetic algorithms, machine learning, robotics, etc.
  • OpenCV: OpenCV is a computer vision library originally developed by Intel. It is free for commercial and research use under a BSD license. The library is cross-platform, and runs on Windows, Mac OS X, Linux, PSP, VCRT (Real-Time OS on Smart camera) and other embedded devices. It focuses mainly on real-time image processing, as such, if it finds Intel's Integrated Performance Primitives on the system, it will use these commercial optimized routines to accelerate itself. Released under the terms of the BSD license, OpenCV is open source software.
  • EmguCV:EmguCV is a cross platform .Net wrapper to the Intel OpenCV image processing library. Allowing OpenCV functions to be called from .NET compatible languages such as C#, VB, VC++, IronPython etc. The wrapper can be compiled in Mono and run on Linux / Mac OS X.


Thursday, April 30, 2009

Dot Net Socket Programming-2 : Asynchronous Socket Client

I just 'CTRL+C and CTRL+V'ed from client socket code on MSDN samples. The following code should be self explanatory. If I get enough time I'd write a brief description of it though.
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;

// State object for receiving data from remote device.
public class StateObject
// Client socket.
public Socket workSocket = null;
// Size of receive buffer.
public const int BufferSize = 1024;
// Receive buffer.
public byte[] buffer = new byte[BufferSize];
// Received data string.
public StringBuilder sb = new StringBuilder();

public class AsynchronousClient
// The port number for the remote device.
private const int port = 5656;

// ManualResetEvent instances signal completion.
private static ManualResetEvent connectDone =new ManualResetEvent(false);
private static ManualResetEvent sendDone =new ManualResetEvent(false);
private static ManualResetEvent receiveDone =new ManualResetEvent(false);

// The response from the remote device.
private static String response = String.Empty;

private static void StartClient()
// Connect to a remote device.
// Establish the remote endpoint for the socket.
IPHostEntry ipHostInfo = Dns.Resolve("localhost");
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint ep = new IPEndPoint(ipAddress, port);

// Create a TCP/IP socket.
Socket client = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);

// Connect to the remote endpoint.
new AsyncCallback(ConnectCallback), client);

// Send test data to the remote device.
Send(client, "Data Send to local server.");

// Receive the response from the remote device.

// Write the response to the console.
Console.WriteLine("Response received : {0}", response);

// Release the socket.

catch (Exception e)

private static void ConnectCallback(IAsyncResult ar)
// Retrieve the socket from the state object.
Socket client = (Socket)ar.AsyncState;

// Complete the connection.

Console.WriteLine("Socket connected to {0}",client.RemoteEndPoint.ToString());

// Signal that the connection has been made.
catch (Exception e)

private static void Receive(Socket client)
// Create the state object.
StateObject state = new StateObject();
state.workSocket = client;

// Begin receiving the data from the remote device.
client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,
new AsyncCallback(ReceiveCallback), state);
catch (Exception e)

private static void ReceiveCallback(IAsyncResult ar)
// Retrieve the state object and the client socket
// from the asynchronous state object.
StateObject state = (StateObject)ar.AsyncState;
Socket client = state.workSocket;

// Read data from the remote device.
int bytesRead = client.EndReceive(ar);

if (bytesRead > 0)
// There might be more data, so store the data received so far.
state.sb.Append(Encoding.ASCII.GetString(state.buffer, 0, bytesRead));

// Get the rest of the data.
client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,new AsyncCallback(ReceiveCallback), state);
// All the data has arrived; put it in response.
if (state.sb.Length > 1)
response = state.sb.ToString();
// Signal that all bytes have been received.
catch (Exception e)

private static void Send(Socket client, String data)
// Convert the string data to byte data using ASCII encoding.
byte[] byteData = Encoding.ASCII.GetBytes(data);

// Begin sending the data to the remote device.
client.BeginSend(byteData, 0, byteData.Length, 0,new AsyncCallback(SendCallback), client);

private static void SendCallback(IAsyncResult ar)
// Retrieve the socket from the state object.
Socket client = (Socket)ar.AsyncState;

// Complete sending the data to the remote device.
int bytesSent = client.EndSend(ar);
Console.WriteLine("Sent {0} bytes to server.", bytesSent);

// Signal that all bytes have been sent.
catch (Exception e)

public static int Main(String[] args)
return 0;

Dot Net Socket Programming-1 : Asynchronous Socket Server

To use socket asynchronously Microsoft has provide very helpful technology in .Net. We just use some inbuilt functions with ‘Begin-End’ scenario with three word ‘Accept, Send & Receive’. These functions are:

BeginAccept() - EndAccept()
BeginReceive() - EndReceive()
BeginSend() - EndSend()

These functions, when invoked, create & start internal threads and each works on a separate thread and continue working. So it doesn’t hamper main thread. Also inter-thread communication is maintained by ‘ManualResetEvent’. ManualResetEvent object handles the communication over its three functions :
Set ()

For this example, we going to make use of transfer of some string data. So we are going to use ‘StringBuilder’ for string operation instead of simple ‘string’ class. Both class does same work, but ‘StringBuilder’ is very fast than ‘string’, but you can go with ‘string’ for this example.

The exact codes we are going to use is given below. Beore the tag line I'm gonna add some of my notes- you can give that a look as well.
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;

// State object for reading client data asynchronously
public class StateObject
// Client socket.
public Socket workSocket = null;
// Size of receive buffer.
public const int BufferSize = 1024;
// Receive buffer.
public byte[] buffer = new byte[BufferSize];
// Received data string.
public StringBuilder sb = new StringBuilder();

public class AsynchronousSocketListener
// Thread signal.
public static ManualResetEvent allDone = new ManualResetEvent(false);

public AsynchronousSocketListener()

public static void StartListening()
// Temp storage for incoming data.
byte[] recvDataBytes = new Byte[1024];

// Make endpoint for the socket.
//IPAddress serverAdd = Dns.Resolve("localhost"); - That line was wrong
//'baaelSiljan' has noticed it and then I've modified that line, correct line will be as:
IPHostEntry ipHost = Dns.Resolve("localhost");
IPAddress serverAdd = ipHost.AddressList[0];

IPEndPoint ep = new IPEndPoint(serverAdd, 5656);

// Create a TCP/IP socket for listner.
Socket listenerSock = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);

// Bind the socket to the endpoint and wait for listen for incoming connections.

while (true)
// Set the event to nonsignaled state.

// Start an asynchronous socket to listen for connections.
Console.WriteLine("Waiting for Client...");
new AsyncCallback(AcceptCallback),

// Wait until a connection is made before continuing.

catch (Exception e)

Console.WriteLine("\nPress ENTER to continue...");


public static void AcceptCallback(IAsyncResult ar)
// Signal the main thread to continue.

// Get the socket that handles the client request.
Socket listener = (Socket)ar.AsyncState;
Socket handler = listener.EndAccept(ar);

// Create the state object.
StateObject state = new StateObject();
state.workSocket = handler;
handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,
new AsyncCallback(ReadCallback), state);

public static void ReadCallback(IAsyncResult ar)
String content = String.Empty;

// Retrieve the state object and the handler socket
// from the asynchronous state object.
StateObject state = (StateObject)ar.AsyncState;
Socket handler = state.workSocket;

// Read data from the client socket.
int bytesRead = handler.EndReceive(ar);

if (bytesRead > 0)
// There might be more data, so store the data received so far.
state.buffer, 0, bytesRead));

// Check for end-of-file tag. If it is not there, read
// more data.
content = state.sb.ToString();
if (content.IndexOf("") > -1)
// All the data has been read from the
// client. Display it on the console.
Console.WriteLine("Read {0} bytes from socket. \n Data : {1}",
content.Length, content);
// Echo the data back to the client.
Send(handler, content);
// Not all data received. Get more.
handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,
new AsyncCallback(ReadCallback), state);

private static void Send(Socket handler, String data)
// Convert the string data to byte data using ASCII encoding.
byte[] byteData = Encoding.ASCII.GetBytes(data);

// Begin sending the data to the remote device.
handler.BeginSend(byteData, 0, byteData.Length, 0,
new AsyncCallback(SendCallback), handler);

private static void SendCallback(IAsyncResult ar)
// Retrieve the socket from the state object.
Socket handler = (Socket)ar.AsyncState;

// Complete sending the data to the remote device.
int bytesSent = handler.EndSend(ar);
Console.WriteLine("Sent {0} bytes to client.", bytesSent);


catch (Exception e)

public static int Main(String[] args)
return 0;
  1. Why am I using Asynchronous socket and not synchronous socket ? Because using asynchronous socket we can transfer data over different threads and data can transfer more smoothly. If anyone tries to send large data without any multi-threading model then he will see that when data is being transfered, his program might look like ‘crashed’. However surely there are some advantages of Synchronous sockets over Asynchronous one.
  2. Always keep in mind here system is using default thread pool which by default handles maximum 25 threads; which may be problematic in large application, but for small application it should be fine.
  3. It’s using internal multi-threading technology which is comparatively slower than raw threading program.
Feeling interested ? ' Be right back with other articles for Socket programming.

How To : Styling a file type input

Of all form fields, the file upload field is by far the worst when it comes to styling. Explorer Windows offers some (but not many) style possibilities, Mozilla slightly less, and the other browsers none at all. The "Browse" button, especially, is completely inaccessible to CSS manipulation.

The Solution

Fortunately, reader Michael McGrady invented a very neat trick that allows us to (more or less) style file upload fields. The credits for the solution presented on this page are wholly his, I only added the position: relative, a few notes and tests, and ported it entirely to JavaScript.

McGrady's technique is elegant in its simplicity:

  1. Take a normal <input type="file"> and put it in an element with position: relative.
  2. To this same parent element, add a normal <input> and an image, which have the correct styles. Position these elements absolutely, so that they occupy the same place as the <input type="file">.
  3. Set the z-index of the <input type="file"> to 2 so that it lies on top of the styled input/image.
  4. Finally, set the opacity of the <input type="file"> to 0. The <input type="file"> now becomes effectively invisible, and the styles input/image shines through, but you can still click on the "Browse" button. If the button is positioned on top of the image, the user appears to click on the image and gets the normal file selection window.
(Note that you can't use visibility: hidden, because a truly invisible element is unclickable, too, and we need the <input type="file"> to remain clickable)

Until here the effect can be achieved through pure CSS. However, one feature is still lacking.

  • When the user has selected a file, the visible, fake input field should show the correct path to this file, as a normal <input type="file"> would. It's simply a matter of copying the new value of the <input type="file"> to the fake input field, but we need JavaScript to do this.

Therefore this technique will not wholly work without JavaScript. For reasons I'll explain later, I decided to port the entire idea to JavaScript. If you're willing to do without the visible file name you can use the pure CSS solution. I'm not sure if this would be a good idea, though.

The HTML/CSS Structure

I've decided on the following HTML/CSS approach:

div.fileinputs {
position: relative;

div.fakefile {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;

input.file {
position: relative;
text-align: right;
-moz-opacity:0 ;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;

<div class="fileinputs">
<input type="file" class="file" />
<div class="fakefile">
<input />
<img src="search.gif" />

For original article check at www.quirksmode.org

Tuesday, March 31, 2009

How To : Put HTML Code in your post

How to put HTML code in blogspot post or blogger post actually is a topic that out of date. Since many of my friends still ask me how to do that, I guess it’s better if I write the trick here. And here we go the trick.
  1. Open http://centricle.com/tools/html-entities/ on your browser.
  2. Copy your HTML code that you want to post and start encode there.
  3. If it’s finished, now move to your posting area.
  4. Make sure you choose the “edit HTML” options
  5. then simply paste the encoded code that you have from centricle.
  6. After that, you can continue edit your post or simply publish it.
Happy blogging then :)

How To : SEO friendly URLs

When you are working with web portals SEO is almost a must now a days. And when you are working for SEO, seo friendly URL is what you should take care of. Again when you are playing with php and Apache following are the ways that you can utilize :
  • Using Apache mod_rewrite:
There is some debate as to whether or not this is actually a front controller design, since no index.php file is utilized. However, I thought it would be worthwhile to demonstrate how URL rewrites work at the highest level before moving onto advanced solutions. Remember, this is not the preferred approach, but it is a good primer. The following is an example of one-to-one relationship URL rewrites in an .htaccess. If you have less than a dozen pages on a small Web site, this can be a useful quick fix.
<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteRule ^our-services/strategic-consulting$ /our_services.php?id=1 [L]
RewriteRule ^our-services/web-design$ /our_services.php?id=2 [L]
RewriteRule ^our-services/web-development$ /our_services.php?id=3 [L]

The IfModule conditional directive wraps a section of rewrite rules, and ensures that they will only get executed on a server that has mod_rewrite capabilities. If the module did not exist, and there was no conditional directive, users will receive an HTTP Error 500 - Internal Server Error. It is good practice to always use this directive.

According to the documentation, “The RewriteEngine directive enables or disables the runtime rewriting engine.” RewriteEngine can be declared multiple times within .htaccess, which can actually help with debugging. The directive can be turned on or off, and instead of commenting out or deleting a line during testing, it is best to use RewriteEngine Off. In the example there is only the need to turn the rewrite engine on once.

The RewriteRule directive is one of the most powerful aspects of mod_rewrite. I invite you to bookmark and eventually read the official documentation for RewriteRule. There are too many facets to this directive to cover them all, so I will mention just a few.

  1. RewriteRule uses pattern substitution through regular expressions. So, the more you know about regular expressions, the more powerful your rewrite rules can become.
  2. Each rule begins with RewriteRule, and multiple rules can be applied to a single URL string before the page request is passed along to a PHP (or other) file.
  3. Definition order is important. Top down is the order of execution. You cannot skip rules unless they are commented out.
  4. The first portion of a rule is the pattern to match. The caret anchor (^) designates the beginning of a pattern match (start of line). The dollar anchor ($) designates the end of a pattern match (end of line). (This is the URL that the user typed into the address bar.)
  5. The second portion of the rule designates the file path that should actually handle the request behind the scenes if, and only if, a pattern match was found in the first portion of the rule. You can use regular expression groups and backreferences to pass information from the first portion of the URL to the second portion of the URL. More on that later.
  6. The final portion of the rule is a flag. It provides additional flexibility without the use of further pattern substitutions. The flag in the example above is “last rule”, and states that if a match was found, no further rules should be processed. The request is then forwarded on to the application. Multiple flags can be separated by a comma, all of them contained between a single set of brackets.
  • Writing own PHP engine for URL translation:
Step 1.
In your .htaccess file (If you don't have one, then create a new one in the folder where your index.php resides) add the following:

<FilesMatch "index">
ForceType application/x-httpd-php

This simply tells your apache server to treat "index" in the url as "index.php". If you are using a server other than apache, then you will need to configure it to do this.

Step 2.
Implement the class below so that an instance is create each time index.php is executed. What this does is it takes the special url www.mysite.com/index/menuID_28-type_article and
splits it into www.mysite.com/index/ and menuID_28-type_article strings, then it creates an array:
array['menuID'] = 28
array['type'] = article
You cannot use $_GET['paramName'], instead call getItem($key) method in UrlFilter passing the name of the parameter you want, for exaple: $this->urlFilter -> getItem("menuID").
You can use any number of parameters, and name them as you wish, all you have to do is use the getItem() method and you got yourself nice URLs. Ofcourse you will need to build your links correctly for this to work, use getOriginalUrl() for this, then add your parameters to it: /param_value-param2_value2-param3_value3 and so on...
// constructs search friendly urls and create correct url paths for links and images
class UrlFilter {
var $origUrl;
var $numOfItems;
var $itemsMap;

function UrlFilter()

function processURI()
$array = explode("index", $_SERVER['PHP_SELF']);
$newUrl = str_replace("/", "", $array[count($array)-1]);
$array = explode("-", $newUrl);
$num = count($array);
$this->numOfItems = $num;
$url_array = array();

$items = explode("-", $newUrl);
$num = count($items);
for ($i = 0 ; $i < $num ; $i++) { $item = explode("_", $items[$i]); $this->itemsMap[$item[0]] = $item[1] ;

function constructBaseUrl()
// need to construct the original url
$array = explode("index", $_SERVER['PHP_SELF']);
$num = count($array);
$this->origUrl = "";
for ($i = 0; $i < $num-1 ; $i++) { $this->origUrl = $this->origUrl . $array[$i];

function getItem($key)
if (array_key_exists($key, $this->itemsMap)) {
return $this->itemsMap[$key];
} else {
return null;

function getOriginalUrl()
return $this->origUrl . "index";

function getBaseUrl()
return $this->origUrl;


Wednesday, March 25, 2009

Cloud coumputing : new era in internet technology

I'm too addicted to web2.0 concept and I's listening about Amazon clouds for couple of days and then started searching for what actually it signifies. This post actually is to depict the very basic of cloud computing :

After couple googling wikipedia satisfied me with an actual and to-the-point definition,"Cloud computing is Internet ("cloud") based development and use of computer technology ("computing"). It is a style of computing in which dynamically scalable and often virtualised resources are provided as a service over the Internet.Users need not have knowledge of, expertise in, or control over the technology infrastructure "in the cloud" that supports them.

The concept incorporates infrastructure as a service (IaaS), platform as a service (PaaS) and software as a service (SaaS) as well as Web 2.0 and other recent (ca. 2007–2009) technology trends which have the common theme of reliance on the Internet for satisfying the computing needs of the users. Examples of SaaS vendors include Salesforce.com, NetSuite.com and Google Apps which provide common business applications online that are accessed from a web browser, while the software and data are stored on the servers.

The term cloud is used as a metaphor for the Internet, based on how the Internet is depicted in computer network diagrams, and is an abstraction for the complex infrastructure it conceals."

Ok I got the very basic idea; then I searched on youtube.com and this is what I though I should include :

Finally I'd like to add some of the cool cloud application that I I think really neat :
  1. Google app
  2. eyeOS
I'd love to continue writing on cloud computing as I have just decided I will work more on this new concept. Let me know if you have got some more information that I have missed.

Wednesday, February 4, 2009

"Bondho Janala"

"Bondho Janala"
Title Song of the album by
Album- Bondho Janala
lyric and tune: Zia

Arekbar dure jete chai, rim jhim shudurpur
Obak roud bheja topto dupur
Arekbar tomader, laal neel rong anonde
Ekla rastay ek chilte roddur
Shara bela bondho janala....
Arekbar jete chai laal neel laal shudurpur

Jodi tomader onek shobdo amar janalay
Soto soto anonder sporshe angule rekhe jay
Jodi shohosro shobder utshob theme jay
Shara bela bondho janala....

Jodi tomader laal neel golpo
Amar shorire
Kono ekla rastay obak vromone
Jodi ichcher neel rong akash chuye jay
Shara bela bondho janala....

Sunday, February 1, 2009

Curly use of cURL in php

I's interested in cURL in php since when Rashim was looking for something to get the yahoo weather feed as it is. He made it using cURL and I just loved it- amazed with versatile use of cURL.

I's looking for a way to get the all the statistics and searching facilities for expired or deleted domain names. And finally I decided to use cURL to search from some free service providers on the net although the usual approach I got is to store the names performing some scheduled search from who-is servers.
Anyway, here I'm gonna share all I've been playing with cURL :

Getting required html content from a website using cURL :
$url = "http://www.example.com/domains/detailedStatistics";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);
$regex = '~(.*?)
echo "Detailed domain statistics:
echo "
". $match[0]."


Searching on a website using cURL and parsing the html to get desired result:

I used a html form to post input values to a searcher file. The code on the searcher file looked like :
//A Beautiful html dom parser
$cat = explode("?",$_SERVER['REQUEST_URI']);

$url = "http://www.example.com/Domain_Name_Search_Results.aspx?".$cat[1];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);

// find all tabele tags with id=results
$html = str_get_html($curl_scraped_page);

$thetable = $html->find('table[class=BlackLeftRight]',0);
foreach($thetable->find('img') as $img)
$img->outertext = "";
echo "".$thetable->innertext."
" ;

That's it :) Happy curling then :)


Monday, January 19, 2009

Interesting Trivia

  • No piece of normal-size paper can be folded in half more than 7 times.
  • The first product to have a bar code scanned was Wrigley's gum.
  • Earth is the only planet not named after a pagan God.

  • A Boeing 747s wingspan is longer than the Wright brother's first flight.

  • The new 787 Boeing was revealed on 7/8/07 or July 8th, 07.

  • The Germans tried to copy Coca-Cola and came up with the drink Fanta.

  • Every day is about 55 billionths of a second longer than the day before it

  • Venus is the only planet that rotates clockwise.

  • The largest potato was grown in Lebanon by Khalil Semhat near Tyre. The spud was 11.3 kilos (24.9 pounds)

  • Footprints of astronauts who landed on the moon should last at least 10 million years since the moon has no atmosphere.

  • The national orchestra of Monaco (a nation in Europe) has more individuals than its army.

  • Earthworms have five hearts

  • The Himalayan gogi berry contains, weight for weight, more iron than steak, more beta carotene than carrots, more vitamin C than oranges.

  • Paraguay and Moldova are the only countries with national flags with different emblems on the obverse and reverse sides.

  • Fingerprints of koalas are similar (in pattern, shape and size) to the fingerprints of humans

  • Genetically-engineered babies were born first in 2001.

  • If an Amish man has a beard, he is married.

  • If a native Hawaiian woman places the flower on her right ear, she is available. (The bigger the flower, the more desperate)

  • Apples, not caffeine, are more efficient at waking you up in the morning.

  • Pope Pius II wrote an erotic book "Historia de duobos amantibus" in 1444.

  • SCUBA divers cannot pass gas at depths of 33 feet or below

  • Pele has always hated his nickname, which he says sounds like "baby-talk in Portuguese".

  • As of 2006, 200 million blogs were left without updates
  • Urban birds have developed a short, fast "rap style" of singing, different from their rural counterparts.
  • The lion costume in the film Wizard of Oz was made from real lions.
  • Fathers tend to determine the height of their child, mothers their weight.
  • The Pope's been known to wear red Prada shoes.
  • Donald Rumsfeld was both the youngest and the oldest defense secretary in US history.
  • Coco Chanel started the trend for sun tans in 1923 when she got accidentally burnt on a cruise.
  • Up to 25% of hospital keyboards carry the MRSA infection.
  • In ancient Greece, children of wealthy families were dipped in olive oil at birth to keep them hairless throughout their lives.
  • Ghandi didn't allow his wife to take penicillin to save her life from pneumonia but took quinine to save himself from malaria.
  • Sex workers (Prostitutes) in Roman times charged the equivalent price of eight glasses of red wine.
  • As of 2006, more than one in eight people in the United States show signs of addiction to the internet.
  • More than 90% of plane crashes have survivors.
  • The Mona Lisa used to hang on the wall of Napoleon’s bedroom.
  • Barbie's full name is Barbie Millicent Roberts.
  • Eating a packet of crisps a day is equivalent to drinking five liters of cooking oil a year.
  • Plant seeds that have been stored for more than 200 years can be coaxed into new life.
  • For every 10 successful attempts to climb Mount Everest there is one fatality. (As of 2006)
  • Watching television can act as a natural painkiller for children
  • Forty-one percent of English women have punched or kicked their partners, according to a study.
  • The more panels a football has - and therefore the more seams - the easier it is to control in the air.
  • Music can help reduce chronic pain by more than 20% and can alleviate depression by up to 25%.
  • The egg came first.
  • Modern teenagers are better behaved than their counterparts of 20 years ago, showing "less problematic behavior" involving sex, drugs and drink.
  • Britain is still paying off debts that predate the Napoleonic wars because it's cheaper to do so than buy back the bonds on which they are based.
  • In Bhutan government policy is based on Gross National Happiness; thus most street advertising is banned, as are tobacco and plastic bags.
  • The best-value consumer purchase in terms of the price and usage is an electric kettle.
  • Camel's milk, which is widely drunk in Arab countries, has 10 times more iron than cow's milk.
  • Iceland has the highest concentration of broadband users in the world.
  • Native Hawaiian women were not allowed to cook.
  • The age limit for marriage in France was, until recently, 15 for girls, but 18 for boys. The age for girls was raised to 18 in 2006.
  • The brain is soft and gelatinous - its consistency is something between jelly and cooked pasta.
  • The Himalayas cover one-tenth of the Earth's surface.
  • A "lost world" exists in the Indonesian jungle that is home to dozens of hitherto unknown animal and plant species.
  • The two most famous actors who portrayed the “Marlboro Man” in the cigarette ads died of lung cancer.
  • All US Presidents have worn glasses. Some just didn't like being seen wearing them in public.

  • The Mona Lisa has no eyebrows. It was the fashion in Renaissance Florence to shave them off.

  • Walt Disney was afraid of mice.

  • The first known marketer of the flushing toilet was Thomas Crapper.

  • The average bed is home to over 6 billion dust mites.

  • The cigarette lighter was invented before the match.

  • The average chocolate bar has 8 insect legs in it.

  • The average American consumes 1.2 pounds of spider eggs a year and eat 2.5 pounds of insect parts a year. (This fact and the one prior to it have been judged as urban legends by many)

  • Right-handed people live, on average, nine years longer than left-handed people do. (Makes you think about ambidextrous people) This fact is based on a study that had errors in it, thus it might not be a fact.

  • Its impossible to smoke oneself to death with weed. You won\'t be able to retain enough motor control and consciousness to do so after such a large amount.

  • Every drop of seawater contains approximately 1 billion gold atoms.

  • The US national anthem actually has three verses, but everyone just knows the first one.

  • During World War II, IBM built counting machines the Nazis used to manage their death/concentration camps.

  • During World War II, the British Intelligence used the Colossus Machines (precursor to computers) at Bletchley Park to help decode the enigma code of the Nazis.

  • The first Computer was ENIAC, short for Electronic Numerical Integrator And Computer, unveiled on February 14, 1946 (Thanks D.B. of AU)

  • The total combined weight of the worlds ant population is heavier than the weight of the human population.

  • The deadliest war in history excluding World War II was a civil war in China in the 1850s in which the rebels were led by a man who thought he was the brother of Jesus Christ.

  • Just about 3 people are born every second, and about 1.3333 people die every second. The result is about a 2 and 2/3 net increase of people every second. Almost 10 people more live on this Earth now, than before you finished reading this.

  • Happy Birthday (the song) is copyrighted.

  • The number of people alive on earth right now is higher than the number of all the people that have died. Ever.

  • Men with a certain rare medical condition can breastfeed babies

  • There is a rare condition called Exploding Head Syndrome which you have probably never heard of.

  • Scientists have determined that fungi are more closely related to human beings and animals than to other plants.

  • In some (maybe all) Asian countries, the family name is written
    first and the individual name written second

  • Abe Lincoln bought 50 cents worth of cocaine in 1860

  • A German World War II submarine was sunk due to malfunction of the toilet.

  • Washington State has the longest single beach in the United States.Long Beach, WA

  • The largest living thing on the face of the Earth is a mushroom underground in Oregon, it measures three and a half miles in diameter.

  • The town of Los Angeles, California, was originally named "El Pueblo la Nuestra Senora de Reina de los Angeles de la Porciuncula"

  • 9 out of 10 people believe Thomas Edison invented the light bulb.This isn't true; Joseph Swan did.

  • Honey is the only food that does not spoil. Honey found in the tombs of Egyptian pharaohs has been tasted by archaeologists and found edible.

  • The Population of the world can live within the state boundaries of Texas.

  • Plastic lawn flamingos outnumber real flamingos in the U.S.A.

  • Ernest Vincent Wright wrote a novel with over 50,000 words, none of which containing the letter "e."

  • Tourists visiting Iceland should know that tipping at a restaurant is not considered an insult! Despite the expensive food, tipping is welcome as in any other country.

  • The largest pumpkin weighed 377 pounds.

  • The largest cabbage weighed 144 pounds.

  • Pinocchio was made of pine.

  • Alfred Hitchcock had no belly button for it was eliminated during surgery.

  • A quarter has 119 grooves around the edge.

  • A dime has 118 ridges around the edge.

  • Cranberry Jell-0 is the only kind that contains real fruit.

  • The plastic things on the end of shoelaces are called aglets.

  • Maine is the toothpick capital of the world.

  • New Jersey has a spoon museum with over 5,400 spoons from almost all the states.

  • There was once a town in West Virginia called "6."

  • The parking meter was invented in North Dakota.

  • Napoleon made his battle plans in a sandbox.

  • Roman Emperor Caligula made his horse a senator.

  • The green stuff on the occasional freak potato chip is chlorophyll.

  • Neil Armstrong stepped on the moon with his left foot first.

  • There are 333 toilet paper squares on a toilet paper roll.

  • The Eiffel Tower has 2,500,000 rivets in it.

  • "Jaws" is the most common name for a goldfish.

  • On an average work day, a typist's fingers travel 12.6 miles.

  • Every minute in the U.S. six people turn 17.

  • Ten tons of space dust falls on the Earth every day.

  • On average, a 4-year-old child asks 437 questions a day.

  • Blue and white are the most common school colors.

  • Swimming pools in Phoenix, Arizona, pick up 20 pounds of dust a year.

  • In a normal lifetime an American will eat 200 pounds of peanuts and 10,000 pounds of meat.

  • A new book is published every 13 minutes in America.

  • America's best selling ice cream flavor is vanilla.

  • Every year the sun loses 360 million tons.

  • Because of Animal Crackers, many kids until they reach the age of ten, believe a bear is as tall as a giraffe.

  • The Gulf Stream could carry a message in a bottle at an average of 4 miles per hour.

  • The bulls-eye on a dartboard must be 5 feet 8 inches off the ground.

  • The doorbell was invented in 1831.

  • The electric shaver was patented on November 6, 1928.

  • Japan is the largest exporter of frog's legs.

  • There are seven points on the Statue of Liberty's crown.

  • Napoleon was terrified of cats.

  • The first Lifesaver flavor was peppermint.

  • The typical American eats 263 eggs a year.

  • The parking meter was invented by C.C. Magee in 1935.

  • The oldest known vegetable is the pea.

  • Jack is the most common name in nursery rhymes.

  • The avocado has the most calories of any fruit.

  • The first zoo in the USA was in Philadelphia.

  • France has the highest per capita consumption of cheese.

  • The shortest English word that contains the letters A, B, C, D, E, and F is "feedback."

  • The state of California raises the most turkeys out of all of the states.

  • George Washington Carver invented peanut butter.

  • Iceland was the first country to legalize abortion in 1935.

  • The dumbest domesticated animal is the turkey.

  • Russia has the most movie theaters in the world.

  • The most fatal car accidents occur on Saturday.

  • The Eiffel Tower has 1792 steps.

  • The mongoose was barred live entry into the U.S. in 1902.

  • Goldfish swallowing started at Harvard in 1939.

  • Dry fish food can make goldfish constipated.

  • The stall closest to the door in a bathroom is the cleanest, because it is the least used.

  • Toilet paper was invented in 1857.

  • Alaska could hold the 21 smallest States.

  • Before Prohibition, Schlitz Brewery owned more property in Chicago than anyone else, except the Catholic church.

  • If you put a raisin in a glass of champagne, it will keep floating to the top and sinking to the bottom.

  • Kermit the Frog is left-handed.

  • Nondairy creamer is flammable.

  • The car in the foreground on the back of a $10 bill is a 1925 Hupmobile.

  • If you can see a rainbow you must have your back to the sun.

  • The reason firehouses have circular stairways is from the days of yore when the engines were pulled by horses. The horses were stabled on the ground floor and figured out how to walk up straight staircases.

  • It's rumored that sucking on a copper penny will cause a breathalyzer to read 0. Myth Busters on the Discovery Channel proved this wrong.

  • The ship, the Queen Elizabeth 2, should always be written as QE2. QEII is the actual queen.

  • The correct response to the Irish greeting, "Top of the morning to you," is "and the rest of the day to yourself."

  • Columbia University is the second largest landowner in New York City, after the Catholic Church.

  • When the University of Nebraska Cornhuskers play football at home to a sellout crowd, the stadium becomes the state's third largest city.

  • Ohio is listed as the 17th state in the U.S., but technically it is Number 47. Until August 7, 1953, Congress forgot to vote on a resolution to admit Ohio to the Union.

  • When Saigon fell, the signal for all Americans to evacuate was Bing Crosby's "White Christmas" being played on the radio.

  • The pet ferret was domesticated more than 500 years before the house cat.

  • The dome on Monticello, Thomas Jefferson's home, conceals a billiards room. In Jefferson's day, billiards were illegal in Virginia.

  • The most common speed limit sign in the United States is 25 m.p.h.

  • At any one time, there are 100 million phone conversations going on in the United States.

  • The world's record for continuous pogo stick jumping is 41 hours.

  • The Ottoman Empire once had seven emperors in seven months. They died of (in order): burning, choking, drowning, stabbing, heart failure, poisoning and being thrown from a horse.

  • You can make edible cheese from the milk of 24 different mammals.

  • Sir Isaac Newton, who invented Calculus, had trouble with names to the point where he would forget his brothers' names.

  • In medieval Thailand, they had moveable type printing presses. The type was made from baked oxen dung.

  • By law, employees do not have to wash hands after sneezing.

  • The average American consumes enough caffeine in one year to kill a horse.

  • More American workers (18%) call sick on Friday than any other day of the week. Tuesday has the lowest percent of absenteeism (11%).

  • Enough beer is poured every Saturday across America to fill the Orange Bowl.

  • A newborn expels its own body weight in waste every 60 hours.

  • Whales die if their echo system fails.

  • Florida's beaches lose 20 million cubic yards of sand annually.

  • Naturalists use marshmallows to lure alligators out of swamps.

  • It takes a ton of water to make a pound of refined sugar.

  • Weevils are more resistant to poisons in the morning than at night.

  • Cacao, the main ingredient of chocolate is the most pest-ridden tree in the jungle.

  • In deep space most lubricants will disappear.

  • America once issued a 5-cent bill.

  • The average person can live 11 days without water.

  • In 1221 the daughter of Genghis Khan ordered the killing of the entire population of the city of Nishapur (about 60,000) in one hour. The order came after her husband killing. (Moguls claim that 1.7 million were killed)

  • There are 35 million digestive glands in the stomach.

  • In 1800 on 50 cities on earth had a population of more than 100,000.

  • More steel in the US is used to make bottle caps than to manufacture automobile bodies.

  • It is possible for any American citizen to give whatever name he or she chooses to any unnamed mountain or hill in the United States.

  • King Henry III of France, Louis XVI of France and Napoleon all suffered from ailurophobia--fear of cats.

  • Before 1850 golf balls were made of leather and stuffed with feathers.

  • Clocks made before 1687 had only one hand, and hour hand.

  • The motto of the American people, "In God We Trust," was not adopted as the national slogan until 1956.

  • More Americans have died in automobile accidents than have died in all the wars ever fought by the United States.

  • The ampersand (&) was once a letter of the English alphabet.

  • The principality of Monaco consists of 370 acres.

  • There are more than 40,000 characters in Chinese script.

  • During the time of Peter the Great, any Russian man who had a beard was required to pay a special tax.

  • The first couple to be shown in bed together on prime time television was Fred and Wilma Flintstone.

  • Coca-Cola was originally green.

  • Every day more money is printed for Monopoly than the U.S. treasury.

  • The Hawaiian alphabet has 12 letters (I was thankfully corrected by a friend: The Hawai'ian alphabet has 13 letters, A, E, I, O, U, H, K, L, M, N, P, W, ' (which is called an okina).

  • Men can read smaller print than women; women can hear better.