Auto Shorten dynamic URL by javascript

Live Demo

Thinking of using Url Shortening service in your site? You can use a simple javascript code in any page of your site, specially if it is a dynamic page. For example, look at a dynamic page of my online code compiling site:

The link of a dynamic page is somewhat this:

The link is too long. So, I automatically shortened the links, and gifted it to the viewers! 😉

how to use in your site

How to use service in your site

First, you need an account on To create one, go to the site and register.

Once you’ve registered, login and go to your Account page. There, you will find your API key.

Now, we’ve all the resources. Let’s go to the code section

The Code

Between the <HEAD> and </HEAD> tag of your page, place the following code:

  • <script type="text/javascript" charset="utf-8" src="******&apiKey=*****************"></script>
  • Replace the first ***** by your username and second ************** by your API key!

    Now, place the following code anywhere of your page. It is nothing but a text-input field, where shortened link will be placed. You can use anything instead of a text area, perhaps a <div>tag to display the shortened link!

    <h3>Link to this page</h3><br>
    Use this link to tell others about this page! <input onclick = "" type = 'text' id = "qlink" style = "width:100%;">

    Now, the final task. Place the following code just before </BODY> the tag of you page:

    	// API
    	BitlyCB.shortenResponse = function(data) {
    			var sss = '';
    			var first_result;
    			// Results are keyed by longUrl, so we need to grab the first one.
    			for     (var r in data.results) {
    					first_result = data.results[r]; break;
    			sss = first_result["shortUrl"].toString();
    			document.getElementById("qlink").value = sss;
    	BitlyClient.shorten(window.location, 'BitlyCB.shortenResponse');

    Yeah, you’re done! Now anyone entering the page with any query string, the link of the page with the query string will be automatically shortened 😀

    PHP Auto Sitemap Submit Script for Google Bing Yahoo or Other Search Engines

    Sitemaps are useful to tell search engines about different pages of your website. Once you submit a sitemap to a search engine, they can crawl all the links which you provided in your sitemap. So generating a sitemap for your website is very important. If you don’t have a sitemap for your site, create one by Google Codes or manually create one by Learning how to create a sitemap (it’s nothing but a simple XML file!)

    Now, there are two ways for making a scheduled update for your sitemap:

    Automatic: By PHP & Cron Job

    Download this PHP file. Give it a name, like “sitemap_updater.php”. Edit it to type in it the correct location of your sitemap. Now upload it to your server, suppose in /public_html/cron_jobs/ directory. Give the file a name, for example, sitemap_updater.php

    Now, go to Cron job section of your server from the Control Panel/Admin account of your hosting. If you’ve acces to Cpanel, you may click cron jobs like following:

    Next, click a option that suits you most. If you’re new, click standard

    Cron job - how to select method
    Cron job – how to select method

    Next we’re on the main panel. Select your schedule – how often you want to run the code. Then in the command to run box, type the following command:

    php -f /home/your-username/public_html/cron_jobs/sitemap_updater.php

    Look at the URL: /home/your-username/public_html/ replace it with appropritae location of your root directory.

    If you have a different location for the sitemap_updater.php file, type it accordingly. The following screen-shot might be helpful (ignore the command given in the image)!

    Cpanel how to execute PHP file as a Cron job

    More details on Cron jobs here

    Download the Sitemap_Updater.php file

    Manually Updating Site-maps

    Well, if you don’t have access to PHP/Cron jobs, you can manually update sitemaps. The trick is, we will create a HTML file, save it in our local disk, and run the file manually whenever we need to update the sitemap!

    1. Download this HTML file
    2. Rename it like something.html
    3. Open the file for editing, edit line # 5, give here your sitemap address. Save it
    4. Now whenever you need to update your sitemap, just open the HTML file in your brower! 🙂

    Well, that’s all. Rock with your sitemaps 😀

    Online Code Compile, Sharing Site – Host, Compile & Download your Codes

    🙂 Say hello to…

    Online free code hosting

    Whoa! At long last, I’ve finished my Code Sharing/Download/Hosting Project! And with bonus –  with the features to Compile & Execute your codes! 😀 Yummy, huh? Yes, I was looking for a online code storage so that I can demostrate my codes to others, with perfect syntax highlighting, direct one click download facilities etc. I dreamt of a site that would be handy, no registration will be required, just hit the site and paste your code. To spice up everything, I’ve also implemented comment from viewer facility – yes I know you want comment from your viewers! 😉 And lastly, online compilation of your code! Just hit the compile button, provide some input or not, and submit, you find your output that is permanent, share your code/compilation information with anyone on the web!

    So you can share your code here, compile it online, provide links at your blogs & it would be simply superb. Okay enough talking, now let’s see some eXclusive features of the site:

    Now what? Just try the site. If you like it, please recommend to others, I spent a significant amount of site in the development 😦 It’s totally free, and always will be. Please give me feedback, I will definitely take them seriously and implement ASAP……..

    Take care.

    Bangla/Bengali Web File Manager by PHP বাংলা ফাইল ম্যানেজার

    Hello, everybody! Today I’m going to share one of my little but proud contributions to the Bengali language – A Complete Bangla File Manager written in PHP. No, I didn’t write the core file manager script, as there are plenty of scripts available written by professional coders. So I chose File Thingie, a singe-file open source PHP based file manager script. The next thing I did, translated it to my mother lagnguage Bengali 🙂

    Check out the screenshots:

    So what you need to do?

    1. Download latest copy of File Thingie from here (recommended 2.5.3)
    2. Download Bangla Translation extension from here. Rename it to “ft_lang_bn.php” & put it in the same folder where your downloaded copy of File Thingie resides.
    3. Edit the file thingie script, select Bangla as the default language. All you need to do, is simply edit the File Thingie script, find the line containing $ft[“settings”][“LANG”] and set it to bn:

    $ft[“settings”][“LANG”]              = “bn”;

    Now it should be working properly, as working properly in my servers:

    Anyway, I think your tasks are simplified, since translating is not that kind of job for a programmer 😦 Anyway, some of my translations are spelled incorrectly, some of them might not be suitable. Please let me know about them. And you’re always at your freedom to modify the code as you need!

    Note: My translation also stays in the translation packages-download page of File thingie. But i recommend to download it from the hostcode-site, as i may update the script later.

    So fire up your bangla file manager now!!!

    Free PHP FTP Uploader Script

    As many of you already know, & rest will be known by the end of the post that you can make FTP connections and actions by PHP, we can create a simple one-page FTP based File Uploader running in PHP 🙂

    Well, are you wondering, what’s the need of this heck when we can already upload files by simple PHP calls? Well, many of us run our files on Free Hosting Providers, and they dont allow us to write files. They simply restrict opening files in Write mode, so though we can read the file from a remote location, we can’t write it safely in our server 😦

    So if we want to copy some files from another server to our server, & if you’re allowed to make FTP connections (that means you have an FTP username & password) we can use the script below. This is a one file PHP script, Put it in the directory where you want to upload files, and use it with simple efforts.

    The Script

    Yes, it’s free 🙂 Grab it from here

    The code is pretty self-explanatory, so if you’re going to modify it, you’ll find it a piece of cake!


    Really simple huh?


    • If FTP is not enabled in your server configuration, this will not work. Check your PHP configuration by phpinfo();
    • If your server configuration restricts remote opening file (reading files hosted in other server) , this will not work.

    TorrentFlux: How to automatically start downloading a Stopped Torrent

    I love downloading torrents with TorrentFlux. The problem occured with one of my servers, it stopped the torrents which I start downloading after few minutes. Looks like the Hosting Provider doesn’t want such processes. So every time I start torrent download, somehow it was stopped. I couldnot figure the problem 😦

    So what to do? Everytime I had to click on “Start Torrent” button to resume download. It started, and as usual stopped after a few minutes 😦 Grrrr…. so I made a change on scripts to automate the process:

    1. If the torrent is stopped, automatically open the Start torrent page “startpop.php” in new window
    2. Submit the page “startpop.php” automatically

    I know the solution is not perfect, but it works! I should have solved it by cron jobs, but I’m not that expert unfortunately 😦

    So here are the tricks….

    Go to your TorrentFlux directory where the scripts are available.

    Open the file “functions.php” and make changes:

    Replace line#2570 with this:

    $output .= "<script>StartTorrent('startpop.php?torrent=".urlencode($entry)."')</script>";

    Replace line#2574 with this:

    $output .= "<script>StartTorrent('startpop.php?torrent=".urlencode($entry)."')</script>";

    Ok, we’re done with this file. Now save It, and open the other file “startpop.php” for editing.

    Replace the line #163 with this:

    <body bgcolor="<?php echo $cfg["body_data_bg"]; ?>" onload = "StartTorrent();">

    Save the file, we are done! 😀 Now when the index page auto refreshes after 60 seconds (default time), It will check whether any torrent is stopped. If stopped, it will open the page “startpop.php” in a new window, so UNBLOCK POP-UPS for this domain on your browser. Once the window is opened, it will be automatically submitted, so our torrent download will begin again!

    Hope it will help. Any questions, ask me. Got a better solution? Help my by notifying!

    Browser plugin to type Bangla (phonetic) – Write Bangla in Firefox/Chrome

    Type Bangla/Bengali right now from your Browser!

    Yes, that’s right! Once you install this script in your browser, you will not need any additional software (like Avro) to type Bangla. Once you install the script, you can type Bangla on any website! Just click any text-input box or textarea, press Control+m (in FireFox) or Control + y (in Google Chrome) – that switches the mode from English to Bangla & vice-versa.

    Once more benefit, are you developing your own site? You want your visitors to comment/register in Bangla? you just tell them to install this script. Once they install it, they can type Bangla from their browser anytime. This is quite helpful if you want comments in Bangla from your visitors. For example, blogs hosted in don’t allow you to comment in Bangla. But when you/your visitors install our script, they can type Bangla on any Website!

    Isn’t it cool? Check out the project in it’s official website 🙂

    How to Install/Use:


    Click here to go to the project’s website!


    Keyboard Layout

    ইংরেজি লেখার মত করে বাংলা লিখুন। যেমন, “পাখি” লেখার জন্য ক্রমানুসারে নিচের কী গুলো প্রেস করুন: p > a > k > h > i


    Thanks to Hasin Hayder & Ekushey

    Hasin Hayder (Author of the  phonetic typing  javasScript). Credits goes to  Ekushey . I just made their scripts compatible for Browser plug-n-play & added Greasemonkey userscript support.


    Known Issues

    • Doesn’t work on sites which have text-boxes with their own event Handlers. Google is one of them, most of the services by Google (i.e google search, gmail) uses their own javascript handlers, which override our script. That means, the script will not work on these sites.
    • Our script works fine with any site which doesn’t override our event handlers (& you’ll be happy, most of the sites are friendly enough! like wordpress 😀 )
    • ব্যবহারকারীরা সহজেই যেকোন ওয়ার্ডপ্রেস ব্লগে বাংলায় কমেন্ট করতে পারবেন। তাছাড়া কোন ব্লগ লেখার সময় Excerpt অংশে বাংলা টাইপ করে মূল পোস্টে কপি করে দিতে পারবেন! (যেসব সাইটের মূল টেক্সবক্সগুলো আমাদের স্ক্রিপ্ট সাপোর্ট করেনা,সেই সব সাইটে এই ট্রিকের মাধ্যমে বাংলা টাইপ করা যাবে! 😉 )